/** * Sets the visual block mode flag in the beginning of handling visual operator actions */ public static boolean wasVisualBlockMode(@NotNull Editor editor) { Boolean res = editor.getUserData(WAS_VISUAL_BLOCK_MODE); return res != null && res; }
/** * Checks whether a keeping visual mode visual operator action is performed on editor. */ public static boolean isKeepingVisualOperatorAction(@NotNull Editor editor) { Boolean res = editor.getUserData(IS_KEEPING_VISUAL_OPERATOR_ACTION); if (res == null) { return false; } else { return res; } }
public static boolean getChangeGroup(@NotNull Editor editor) { Boolean res = editor.getUserData(CHANGE_GROUP); if (res != null) { return res; } else { return false; } }
/** * Asks whether next down move should be ignored. */ public static boolean shouldIgnoreNextMove(@NotNull Editor editor) { Boolean ret = editor.getUserData(IGNORE_NEXT_MOVE); if (ret == null) { return false; } else { return ret; } }
public static boolean getMotionGroup(@NotNull Editor editor) { return editor.getUserData(MOTION_GROUP) == Boolean.TRUE; }
public static boolean isLineNumbersShown(@NotNull Editor editor) { return editor.getUserData(LINE_NUMBERS_SHOWN) == Boolean.TRUE; }
public static boolean getEditorGroup(@NotNull Editor editor) { return editor.getUserData(EDITOR_GROUP) == Boolean.TRUE; }
/** * Gets the mode to which the editor should switch after a change/visual action. */ @Nullable public static CommandState.Mode getChangeSwitchMode(@NotNull Editor editor) { return editor.getUserData(CHANGE_ACTION_SWITCH_MODE); }
/** * Gets the last caret used in down movement. */ @Nullable public static Caret getLastDownCaret(@NotNull Editor editor) { return editor.getUserData(LAST_DOWN_CARET); }
@Nullable public static CommandState getCommandState(@NotNull Editor editor) { return editor.getUserData(COMMAND_STATE); }
@Nullable public static TestInputModel getTestInputModel(@NotNull Editor editor) { return editor.getUserData(TEST_INPUT_MODEL); }
@Nullable public static String getLastSearch(@NotNull Editor editor) { return editor.getUserData(LAST_SEARCH); }
@Nullable public static Collection<RangeHighlighter> getLastHighlights(@NotNull Editor editor) { return editor.getUserData(LAST_HIGHLIGHTS); }
@Nullable public static ExOutputPanel getMorePanel(@NotNull Editor editor) { return editor.getUserData(MORE_PANEL); }
@Nullable public static ExOutputModel getExOutputModel(@NotNull Editor editor) { return editor.getUserData(EX_OUTPUT_MODEL); }
/** * Gets the visual block end for the editor. * * @param editor The editor */ public static int getVisualBlockEnd(@NotNull Editor editor) { Integer visualBlockEnd = editor.getUserData(VISUAL_BLOCK_END); if (visualBlockEnd == null) { return editor.getCaretModel().getPrimaryCaret().getOffset(); } else { return visualBlockEnd; } }
/** * Gets the visual block start for the editor. * * @param editor The editor */ public static int getVisualBlockStart(@NotNull Editor editor) { Integer visualBlockStart = editor.getUserData(VISUAL_BLOCK_START); if (visualBlockStart == null) { return editor.getCaretModel().getPrimaryCaret().getOffset(); } else { return visualBlockStart; } }
/** * Gets the visual block offset for the editor. * * @param editor The editor */ public static int getVisualBlockOffset(@NotNull Editor editor) { Integer visualBlockOffset = editor.getUserData(VISUAL_BLOCK_OFFSET); if (visualBlockOffset == null) { return editor.getCaretModel().getPrimaryCaret().getOffset(); } else { return visualBlockOffset; } }
private MyFontMetrics getFontMetrics(Editor editor) { String familyName = UIManager.getFont("Label.font").getFamily(); int size = (int)(Math.max(1, editor.getColorsScheme().getEditorFontSize() - 1) * factor); MyFontMetrics metrics = editor.getUserData(HINT_FONT_METRICS); if (metrics != null && !metrics.isActual(editor, familyName, size)) { metrics = null; } if (metrics == null) { metrics = new MyFontMetrics(editor, familyName, size); editor.putUserData(HINT_FONT_METRICS, metrics); } return metrics; }
@Override public void editorReleased(@NotNull EditorFactoryEvent event) { Editor editor = event.getEditor(); if (editor.getProject() != null && editor.getProject() != project) { return; } GrammarEditorMouseAdapter listener = editor.getUserData(EDITOR_MOUSE_LISTENER_KEY); if (listener != null) { editor.removeEditorMouseListener(listener); editor.putUserData(EDITOR_MOUSE_LISTENER_KEY, null); } } }