buttonDown method Null safety

  1. @override
void buttonDown(
  1. Operation key
)
override

Implementation

@override
void buttonDown(Operation key) {
  if (model.shift != ShiftKey.none) {
    model.shift = ShiftKey.none;
    // key.pressed(this) might set the shift key again.
  }
  if (key == controller.gtoOperation && controller is RealController) {
    // This is a little tricky.  GTO has this quirk, where "GTO . nnn"
    // positions the current line.  It still enables stack lift,
    // which is what the normal key.pressed() does.
    key.pressed(this);
    changeState(WaitingForGotoDot(controller, this));
    return;
  }
  final Arg arg = key.arg;
  if (arg is ArgDone) {
    // If it's a no-arg operation
    calculate(key, arg);
  } else {
    if (key.calcDisabled(controller)) {
      key.pressed(this);
    } else {
      // If our current mode doesn't disable calculations.  A branching
      // operation disables itself when we're not running a program.
      controller.getArgsAndRun(key, arg, this);
    }
  }
}