/** * Determines whether a caret was in the first line before inserting a new line above. */ public static boolean wasInFirstLine(@NotNull Caret caret) { Boolean res = caret.getUserData(WAS_IN_FIRST_LINE); return (res != null) && res; }
/** * Gets the text range for current visual operator action. */ @Nullable public static TextRange getVisualTextRange(@NotNull Caret caret) { return caret.getUserData(VISUAL_TEXT_RANGE); }
/** * Gets the previous visual operator range on the caret. */ @Nullable public static VisualChange getLastVisualOperatorRange(@NotNull Caret caret) { return caret.getUserData(VISUAL_OP); }
/** * Gets the visual change for current visual operator action. */ @Nullable public static VisualChange getVisualChange(@NotNull Caret caret) { return caret.getUserData(VISUAL_CHANGE); }
/** * Gets the visual block end for the caret. */ public static int getVisualEnd(@NotNull Caret caret) { Integer visualEnd = caret.getUserData(VISUAL_END); if (visualEnd == null) { return caret.getOffset(); } else { return visualEnd; } }
/** * Gets the previous last column (set by {@link com.maddyhome.idea.vim.handler.VisualOperatorActionHandler.VisualStartFinishRunnable}). */ public static int getPreviousLastColumn(@NotNull Caret caret) { @Nullable Integer ret = caret.getUserData(PREV_LAST_COLUMN); if (ret == null) { return caret.getLogicalPosition().column; } else { return ret; } }
/** * Gets the visual block start for the caret. */ public static int getVisualStart(@NotNull Caret caret) { Integer visualStart = caret.getUserData(VISUAL_START); if (visualStart == null) { return caret.getOffset(); } else { return visualStart; } }
/** * Gets the visual offset for the caret. */ public static int getVisualOffset(@NotNull Caret caret) { Integer visualOffset = caret.getUserData(VISUAL_OFFSET); if (visualOffset == null) { return caret.getOffset(); } else { return visualOffset; } }
/** * Gets the insertion start for the caret */ public static int getInsertStart(@NotNull Caret caret) { Integer ret = caret.getUserData(INSERT_START); if (ret == null) { return caret.getOffset(); } else { return ret; } }
/** * This gets the last column the caret was in. * * @param caret The caret to get the last column for * @return Returns the last column as set by {@link #setLastColumn} or the current caret column */ public static int getLastColumn(@NotNull Caret caret) { Integer col = caret.getUserData(LAST_COLUMN); if (col == null) { return caret.getVisualPosition().column; } else { return col; } }