Пример #1
0
 private static void navigatePage(
     jetbrains.mps.openapi.editor.EditorContext context, boolean isDown) {
   EditorComponent editor = (EditorComponent) context.getEditorComponent();
   jetbrains.mps.openapi.editor.cells.EditorCell selection = editor.getSelectedCell();
   Rectangle rect = editor.getVisibleRect();
   int height = (int) rect.getHeight();
   height = isDown ? height : -height;
   int caretX = selection.getCaretX();
   int y = selection.getY() + (selection.getHeight() / 2);
   int newY = y + height;
   jetbrains.mps.openapi.editor.cells.EditorCell target = editor.findCellWeak(caretX, newY);
   if (target == null) {
     target =
         isDown
             ? editor.myRootCell.findChild(CellFinders.LAST_SELECTABLE_LEAF)
             : editor.myRootCell.findChild(CellFinders.FIRST_SELECTABLE_LEAF);
     editor.changeSelection(target);
   } else {
     target.setCaretX(caretX);
     editor.changeSelection(target);
   }
 }
Пример #2
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorComponent editorComponent = (EditorComponent) context.getEditorComponent();
   EditorCell selection = editorComponent.getSelectedCell();
   editorComponent.changeSelection(selection.getPrevLeaf(CellConditions.EDITABLE));
 }