intentForMacOSSelector function Null safety

Intent? intentForMacOSSelector(
  1. String selectorName
)

Maps the selector from NSStandardKeyBindingResponding to the Intent if the selector is recognized.

Implementation

Intent? intentForMacOSSelector(String selectorName) {
  const Map<String, Intent> selectorToIntent = <String, Intent>{
    'deleteBackward:': DeleteCharacterIntent(forward: false),
    'deleteWordBackward:': DeleteToNextWordBoundaryIntent(forward: false),
    'deleteToBeginningOfLine:': DeleteToLineBreakIntent(forward: false),
    'deleteForward:': DeleteCharacterIntent(forward: true),
    'deleteWordForward:': DeleteToNextWordBoundaryIntent(forward: true),
    'deleteToEndOfLine:': DeleteToLineBreakIntent(forward: true),

    'moveLeft:': ExtendSelectionByCharacterIntent(forward: false, collapseSelection: true),
    'moveRight:': ExtendSelectionByCharacterIntent(forward: true, collapseSelection: true),
    'moveForward:': ExtendSelectionByCharacterIntent(forward: true, collapseSelection: true),
    'moveBackward:': ExtendSelectionByCharacterIntent(forward: false, collapseSelection: true),

    'moveUp:': ExtendSelectionVerticallyToAdjacentLineIntent(forward: false, collapseSelection: true),
    'moveDown:': ExtendSelectionVerticallyToAdjacentLineIntent(forward: true, collapseSelection: true),

    'moveLeftAndModifySelection:': ExtendSelectionByCharacterIntent(forward: false, collapseSelection: false),
    'moveRightAndModifySelection:': ExtendSelectionByCharacterIntent(forward: true, collapseSelection: false),
    'moveUpAndModifySelection:': ExtendSelectionVerticallyToAdjacentLineIntent(forward: false, collapseSelection: false),
    'moveDownAndModifySelection:': ExtendSelectionVerticallyToAdjacentLineIntent(forward: true, collapseSelection: false),

    'moveWordLeft:': ExtendSelectionToNextWordBoundaryIntent(forward: false, collapseSelection: true),
    'moveWordRight:': ExtendSelectionToNextWordBoundaryIntent(forward: true, collapseSelection: true),
    'moveToBeginningOfParagraph:': ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: true),
    'moveToEndOfParagraph:': ExtendSelectionToLineBreakIntent(forward: true, collapseSelection: true),

    'moveWordLeftAndModifySelection:': ExtendSelectionToNextWordBoundaryOrCaretLocationIntent(forward: false),
    'moveWordRightAndModifySelection:': ExtendSelectionToNextWordBoundaryOrCaretLocationIntent(forward: true),
    'moveParagraphBackwardAndModifySelection:': ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: false, collapseAtReversal: true),
    'moveParagraphForwardAndModifySelection:': ExtendSelectionToLineBreakIntent(forward: true, collapseSelection: false, collapseAtReversal: true),

    'moveToLeftEndOfLine:': ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: true),
    'moveToRightEndOfLine:': ExtendSelectionToLineBreakIntent(forward: true, collapseSelection: true),
    'moveToBeginningOfDocument:': ExtendSelectionToDocumentBoundaryIntent(forward: false, collapseSelection: true),
    'moveToEndOfDocument:': ExtendSelectionToDocumentBoundaryIntent(forward: true, collapseSelection: true),

    'moveToLeftEndOfLineAndModifySelection:': ExpandSelectionToLineBreakIntent(forward: false),
    'moveToRightEndOfLineAndModifySelection:': ExpandSelectionToLineBreakIntent(forward: true),
    'moveToBeginningOfDocumentAndModifySelection:': ExpandSelectionToDocumentBoundaryIntent(forward: false),
    'moveToEndOfDocumentAndModifySelection:': ExpandSelectionToDocumentBoundaryIntent(forward: true),

    'transpose:': TransposeCharactersIntent(),

    'scrollToBeginningOfDocument:': ScrollToDocumentBoundaryIntent(forward: false),
    'scrollToEndOfDocument:': ScrollToDocumentBoundaryIntent(forward: true),

    'scrollPageUp:': ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page),
    'scrollPageDown:': ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page),
    'pageUpAndModifySelection:': ExtendSelectionVerticallyToAdjacentPageIntent(forward: false, collapseSelection: false),
    'pageDownAndModifySelection:': ExtendSelectionVerticallyToAdjacentPageIntent(forward: true, collapseSelection: false),

    // Escape key when there's no IME selection popup.
    'cancelOperation:': DismissIntent(),
    // Tab when there's no IME selection.
    'insertTab:': NextFocusIntent(),
    'insertBacktab:': PreviousFocusIntent(),
  };
  return selectorToIntent[selectorName];
}