update method

  1. @override
(TableModel, Cmd?) update(
  1. Msg msg
)
override

Updates the component state in response to a message.

Returns the updated component (often this) and an optional command.

Implementation

@override
(TableModel, Cmd?) update(Msg msg) {
  if (!_focused) {
    return (this, null);
  }

  if (msg is KeyMsg) {
    if (keyMatches(msg.key, [keyMap.lineUp])) {
      moveUp(1);
    } else if (keyMatches(msg.key, [keyMap.lineDown])) {
      moveDown(1);
    } else if (keyMatches(msg.key, [keyMap.pageUp])) {
      moveUp(_viewport.height ?? 0);
    } else if (keyMatches(msg.key, [keyMap.pageDown])) {
      moveDown(_viewport.height ?? 0);
    } else if (keyMatches(msg.key, [keyMap.halfPageUp])) {
      moveUp((_viewport.height ?? 0) ~/ 2);
    } else if (keyMatches(msg.key, [keyMap.halfPageDown])) {
      moveDown((_viewport.height ?? 0) ~/ 2);
    } else if (keyMatches(msg.key, [keyMap.gotoTop])) {
      gotoTop();
    } else if (keyMatches(msg.key, [keyMap.gotoBottom])) {
      gotoBottom();
    }
  }

  return (this, null);
}