public class EditorGuiImpl extends Editor<GuiOutputManager> implements AutoResizable<EditorConfig>
Modifier and Type | Class and Description |
---|---|
private class |
EditorGuiImpl.EditorContent
Worker class which is responsible of drawing the editor's text.
|
private class |
EditorGuiImpl.EditorScrollContainer
The editor's scroll container.
|
private static class |
EditorGuiImpl.UndoableEditor
This class implements the editor's undo (CTRL-Z) behavior.
|
Editor.Line, Editor.LocalFocusListener
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private int |
barScrollX
Offset when scrolling horizontally via the scrollbar (the cursor does not move).
|
private int |
barScrollY
Offset when scrolling vertically via the scrollbar (the cursor does not move).
|
private Border<GuiOutputManager> |
border
Cached border instance.
|
private static int |
BORDER_SIZE
Total size of the editor border 1 pixel on each side.
|
private CoordinatesConversion |
cc
Coordinate converter
|
private EditorGuiImpl.EditorScrollContainer |
contentPane
The scrollable container to place inside the ScrollPane.
|
private EditorGuiImpl.EditorContent |
editor
The editor content, where the text is actually drawn.
|
private BorderedPanel<GuiOutputManager> |
editorBorder
Editor border.
|
private ScrollPaneGuiImpl |
editorScroll
Scroll pane which is actual container.
|
private GuiColorResolver |
gc
Color resolver
|
private GuiDriver |
gd
Screen driver
|
private GuiFontResolver |
gf
Font resolver
|
private int[] |
lineSplitIndexes
Indexes where the content must be split.
|
private java.util.Set<java.lang.Integer> |
newLineIndexes
It holds indexes from
lineSplitIndexes , for which the split was caused by a
new-line character. |
private GuiOutputManager |
screen
Output manager
|
private NativePoint |
selectionEnd
The location of last selected character (regardless of where the cursor is).
|
private NativePoint |
selectionStart
The location of first selected character (regardless of where the cursor is).
|
private EditorGuiImpl.UndoableEditor |
undo
Instance which manages the editor's UNDO/CTRL-Z.
|
CR, forceRedraw, insert, LF, maxSizes, parsedText, SPACE, SPACE_LF, widgetFocused
config
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
EditorGuiImpl(WidgetId id,
EditorConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
protected int |
absoluteX()
Get absolute horizontal position in text.
|
private void |
adjustCursorX(int prevY,
int prevX,
int setCaretTo)
Adjust the horizontal cursor so that it preservers the pixel-column, when moving up or down.
|
private void |
adjustScrollY()
If we are removing the last line in the editor, then all content needs to "scroll up" one
row so that the editor's last line is on the bottom.
|
private void |
adjustSelection()
Adjust the selection interval so that the SELECTION-START and SELECTION-END attributes
reflect the current selection.
|
protected void |
adjustSize(boolean init)
Adjust Editor.
|
void |
afterConfigUpdate(EditorConfig beforeUpdate)
The method is called after the configuration associated with
the implementor changes.
|
protected void |
backspace()
Handle BACKSPACE key.
|
protected boolean |
canPlaceChar()
Determine if a character can be placed in the editor.
|
private int |
computeHorizontalDelta(int absY,
int barX)
Compute the full horizontal delta (i.e.
|
private int |
computeHorizontalScrollDelta(int barX)
Compute the horizonta scroll delta, based on how far the scroll bar was moved via mouse to
the left or the right, relative to the current
EditorConfig.scrollX value. |
private void |
computeLineWidths(Editor.Line l)
Compute the widths for this line (if not already computed).
|
private void |
computeLineWidths(int from,
int to)
Compute the line widths (if not already computed) in the given interval.
|
private void |
computeSplitIndexes(java.lang.String source,
int start,
int offset,
boolean placeChar)
Compute the split indexes for the given text.
|
protected MouseHoverAction |
createMouseHoverAction()
Create handler for processing mouse hover events
|
protected void |
cursorDown()
Move cursor one row down, if possible.
|
protected void |
cursorEndOfLine()
Move cursor to the end of line.
|
protected void |
cursorLeft()
Move cursor one char left, if possible.
|
protected void |
cursorPos(int pos)
Split absolute horizontal cursor position into two components - position
of the first visible character and relative cursor position in the
visible region.
|
protected void |
cursorRight()
Move cursor one char right.
|
protected void |
cursorUp()
Move cursor one row up, if possible.
|
protected void |
deleteCharacterKey()
Delete character at current cursor position - called by
processKeyEvent(com.goldencode.p2j.ui.client.event.KeyInput) . |
void |
destroy()
Destroy this widget.
|
void |
draw(Color color)
Render this editor.
|
void |
drawCaretUnconditionally()
Sets position of terminal's cursor unconditionally (even if this editor is not in focus).
|
Widget<GuiOutputManager> |
findMouseSource(NativePoint p)
Find the widget positioned just bellow the specified mouse position (in physical units).
|
private int |
findScrollOffset(int width)
Find a scroll offset to set the
EditorConfig.scrollX value. |
void |
firstFocus()
Set focus to first focusable widget.
|
private GuiFontResolver |
fontResolver()
Get the font resolver
|
NativeRectangle |
getActualBounds()
Get the widget's actual bounds
|
protected int |
getNextSplitPosition(java.lang.String line,
int splitAfter)
Get the next split position of this line, so that it fits the editor.
|
Dimension |
getScrollableSize()
Returns the size of the scrollable area of this widget in character
units.
|
java.lang.String |
getSelectedText()
Obtain any selected text in the widget for copying to the clipboard.
|
private java.lang.String |
getSelectedText(boolean remove)
Get the currently selected sub-text.
|
int |
getTextWidthNative(Editor.Line line,
int start,
int end,
int font)
Get the width of the specified substring, in the given line.
|
int |
getTextWidthNative(int lineNo,
int start,
int end,
int font)
Get the width of the specified substring, in the given line.
|
protected boolean |
goToNewLine(java.lang.String subtext,
boolean placeChar)
Check if the given text needs to output on a new line.
|
void |
initialize(WidgetId id,
EditorConfig cfg)
Replacement API for the logic which should exist in the widget's c'tor, but the logic
can't be executed as it depends on the widget being registered into the official registry.
|
protected boolean |
insertBlankLineOnLF()
Determine if a blank line needs to be inserted when RETURN key is pressed on a empty line.
|
void |
invalidateSelection()
Invalidate the editor's selection.
|
boolean |
isAutoResize()
Get the AUTO-RESIZE status
|
boolean |
isRMBEntrySupported()
Check if this widget gains ENTRY event when right/middle mouse button is clicked.
|
boolean |
isSelectionValid()
Determine if the editor has selected text.
|
private int |
maxLineWidthNative()
Compute the maximum line width in this editor, in native units.
|
protected void |
mergeLines(int row)
Merge line with subsequent one(s) if possible
|
protected int[] |
mouseActions()
Determine the mouse actions processed by this widget.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Notification of a mouse clicked event occurred for this widget.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Notification of a mouse pressed event occurred for this widget.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Notification of a mouse pressed event occurred for this widget.
|
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Notification of a mouse wheel event occurred for this widget.
|
protected java.util.List<Editor.Line> |
parseContentImpl(java.lang.String source,
int start,
int offset,
boolean placeChar)
Worker to parse content of the editor and prepare array of displayable values.
|
protected java.lang.String |
processEOLChars(java.lang.String src)
Processing for unusual EOL characters in GUI mode.
|
void |
processKeyEvent(KeyInput ke)
Process KeyEvents for this widget.
|
boolean |
processMnemonic(int key)
Process the given key, if this widget's mnemonic matches the key.
|
private void |
processScrollPane()
Resize editor scroll pane, and other scroll-related processing (colors for the child
widgets, scrollbars, etc).
|
protected void |
refresh()
Refresh the editor.
|
void |
removeSelectedText()
Removes (deletes) the selected text.
|
private Window<?> |
resolveWindow()
Get the parent window
|
protected java.lang.String |
rtrim(java.lang.String value)
Remove trailing whitespaces.
|
java.lang.Boolean |
search(java.lang.String pattern,
int mode)
Searches for a specified string starting from the current text caret position.
|
boolean |
setCursorChar(int pos,
boolean redraw)
Sets the cursor position in the current line
|
boolean |
setCursorLine(int line)
Sets the cursor line
|
void |
setEnabled(boolean enable)
Enable/disable the widget for editing.
|
private void |
setScrollPosition()
Adjust the scroll position.
|
boolean |
setSelection(int start,
int end)
Selects text in a widget between start and end points.
|
void |
setValue(BaseDataType value)
Sets the new variable value in the editor.
|
protected void |
splitLine(java.lang.String line,
int row,
int splitAfter)
Replace line, splitting it if necessary
|
boolean |
supportsCustomMousePointer()
Check if the widget supports LOAD-MOUSE-POINTER() method
|
void |
updateSize(EditorConfig beforeUpdate)
Update widget's size after config update
|
private void |
wordLeft()
Move cursor one word left.
|
private void |
wordRight()
Move cursor one word right.
|
absoluteY, bell, clear, contentLength, currentFocus, cursorBeginOfLine, cursorEndOfPrevLine, cursorHome, defaultFocus, deleteCharacter, deleteLine, deleteToEndOfLine, draw, drawCaret, editorReadFile, editorSaveFile, focusTraversable, fullHeight, getCursorChar, getCursorLine, getCursorOffset, getFocusListener, getLength, getLine, getLineCount, getLineText, getText, getValue, insertFile, insertString, lastRow, manageSystemActions, parseContent, placeChar, placeLF, replaceSelectionText, replaceString, requestFocus, resolveContent, setCursorChar, setCursorLineAndChar, setCursorOffset, updateOffset
config, defaultMousePtr, getColon, getColumnLabelText, getColumnMnemonic, getLabelInstance, getLabelText, getMnemonic, getTo, isForceLabel, isModified, isNoLabels, isRightAligned, postprocessConfig, setColumnMnemonic, setHidden, setLabelInstance, setMnemonic, setNoLabels, setVisible, setWasVisible, wasVisible
minimumSize
add, add, add, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, currentFocus, cycleFocus, detach, dimension, doLayout, endSizeChange, focus, focusWorker, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getWidgetsList, hasFocusable, height, insets, lastFocus, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, prepareWidgets, prevFocus, remove, repaint, replace, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setSize, setWidth, startSizeChange, unrealize, updateSizeWorker, widgets, width
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, enable, enclosingFrame, forceCursorOnFocus, forceVisibility, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isTabStop, isThreeD, isTotallyObscured, isVisible, location, mouseEntered, mouseExited, mouseMoved, mouseReleased, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, sync, topLevelWindow, toString, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, dimension, displayPhysicalLocation, enclosingFrame, enforceDefaultMousePtr, forceCursorOnFocus, forceVisibility, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getState, getVisiblePart, getZOrderClass, hasFocus, height, hidden, hide, highlighted, insets, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isTabStop, isThreeD, isTotallyObscured, isVisible, location, minimumSize, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, raiseLegacyMouseEvents, repaint, repaint, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, topLevelWindow, unrealize, width, window
mouseEntered, mouseExited, mouseReleased
createMnemonic, getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, isMnemonicSupported, updateMnemonic
private final GuiDriver gd
private final GuiOutputManager screen
private final CoordinatesConversion cc
private GuiColorResolver gc
private GuiFontResolver gf
private EditorGuiImpl.EditorScrollContainer contentPane
private ScrollPaneGuiImpl editorScroll
private BorderedPanel<GuiOutputManager> editorBorder
private final EditorGuiImpl.EditorContent editor
private int barScrollX
private int barScrollY
private NativePoint selectionStart
private NativePoint selectionEnd
private final EditorGuiImpl.UndoableEditor undo
private Border<GuiOutputManager> border
private int[] lineSplitIndexes
private java.util.Set<java.lang.Integer> newLineIndexes
lineSplitIndexes
, for which the split was caused by a
new-line character.private static final int BORDER_SIZE
public EditorGuiImpl(WidgetId id, EditorConfig cfg)
id
- The widget's ID.cfg
- Configuration data.public void initialize(WidgetId id, EditorConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<EditorConfig>
initialize
in class Editor<GuiOutputManager>
id
- The widget's ID.cfg
- The config used to initialize this widget.public void firstFocus()
firstFocus
in interface Container<GuiOutputManager>
firstFocus
in class AbstractContainer<GuiOutputManager>
public boolean processMnemonic(int key)
processMnemonic
in interface Widget<GuiOutputManager>
processMnemonic
in class AbstractWidget<GuiOutputManager>
key
- The pressed mnemonic key code.true
if this widget accepted this mnemonic key. Not enabled or not
visible widget will not accept it.public void processKeyEvent(KeyInput ke)
processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class Editor<GuiOutputManager>
ke
- Key event structure.public void setValue(BaseDataType value)
setValue
in interface DataContainer
setValue
in class Editor<GuiOutputManager>
value
- New value for the screen buffer.public void drawCaretUnconditionally()
drawCaretUnconditionally
in class Editor<GuiOutputManager>
public void draw(Color color)
draw
in class Editor<GuiOutputManager>
color
- Color for drawing. Ignored.public void destroy()
destroy
in interface Widget<GuiOutputManager>
destroy
in class LabeledDataContainer<GuiOutputManager,EditorConfig>
public java.lang.String getSelectedText()
getSelectedText
in interface Widget<GuiOutputManager>
getSelectedText
in class AbstractWidget<GuiOutputManager>
null
if there is no selected text or if the
widget type does not support clipboard operations.public void setEnabled(boolean enable)
RECALL
key.
In GUI, it registers this widget with the driver, to allow responsive actions when the mouse is hovered over the widget.
setEnabled
in interface Widget<GuiOutputManager>
setEnabled
in class AbstractWidget<GuiOutputManager>
enable
- true
to enable editing in this widget.public void mousePressed(java.awt.event.MouseEvent e)
If the editor is enabled, it will position the caret.
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mouseDragged(java.awt.event.MouseEvent e)
If the editor is enabled and has focus, it will re-adjust the selected text depending on where the mouse is moving.
mouseDragged
in interface java.awt.event.MouseMotionListener
mouseDragged
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mouseClicked(java.awt.event.MouseEvent e)
If the widget is not already focused, it forces the focus to it. After the focus was received, it computes the caret location, based on the mouse position over the widget's content.
mouseClicked
in interface java.awt.event.MouseListener
mouseClicked
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
If the editor is vertically scrollable, enabled and has focus, it will scroll the content vertically or horizontally.
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
mouseWheelMoved
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public Dimension getScrollableSize()
The scrollable area is the total area including the hidden parts that must be scrolled in order to be visible.
getScrollableSize
in class AbstractContainer<GuiOutputManager>
public void afterConfigUpdate(EditorConfig beforeUpdate)
afterConfigUpdate
in interface ConfigOwner<EditorConfig>
afterConfigUpdate
in class LabeledDataContainer<GuiOutputManager,EditorConfig>
beforeUpdate
- The previous configuration.public boolean setCursorChar(int pos, boolean redraw)
setCursorChar
in class Editor<GuiOutputManager>
pos
- The new cursor position value.redraw
- request redraw/synctrue
if the cursor position is valid and setpublic void removeSelectedText()
removeSelectedText
in interface TextSelection
public boolean setSelection(int start, int end)
setSelection
in interface TextSelection
setSelection
in class Editor<GuiOutputManager>
start
- Starting offset.end
- Ending offset.true
if the operation succeeded.public java.lang.Boolean search(java.lang.String pattern, int mode)
search
in class Editor<GuiOutputManager>
pattern
- The string to be search. No wildcard allowed.mode
- a combinations of flags that specifies the type of search to be performed. The
following values are accepted:
Type of search | Flag value |
---|---|
EditorWidget.FIND_NEXT_OCCURRENCE | 1 |
EditorWidget.FIND_PREV_OCCURRENCE | 2 |
EditorWidget.FIND_CASE_SENSITIVE | 4 |
EditorWidget.FIND_WRAP_AROUND | 16 |
EditorWidget.FIND_SELECT | 32 |
yes
.public boolean isAutoResize()
isAutoResize
in interface AutoResizable<EditorConfig>
true
is AUTO-RESIZE is enabledpublic void updateSize(EditorConfig beforeUpdate)
updateSize
in interface AutoResizable<EditorConfig>
beforeUpdate
- previous value of the widget's configpublic Widget<GuiOutputManager> findMouseSource(NativePoint p)
For editors, if the sources is either editor
or contentPane
, then return
this widget.
findMouseSource
in interface Widget<GuiOutputManager>
findMouseSource
in class AbstractContainer<GuiOutputManager>
p
- The mouse physical location.null
if none found.public NativeRectangle getActualBounds()
getActualBounds
in interface Widget<GuiOutputManager>
getActualBounds
in class AbstractWidget<GuiOutputManager>
public boolean isRMBEntrySupported()
isRMBEntrySupported
in interface Widget<GuiOutputManager>
isRMBEntrySupported
in class AbstractWidget<GuiOutputManager>
true
if this widget gains ENTRY event
when right/middle mouse button is clicked.protected int[] mouseActions()
mouseActions
in class AbstractWidget<GuiOutputManager>
protected void adjustSize(boolean init)
init
- true
if this is called from initialize(com.goldencode.p2j.ui.WidgetId, com.goldencode.p2j.ui.EditorConfig)
.protected void refresh()
refresh
in class Editor<GuiOutputManager>
protected boolean goToNewLine(java.lang.String subtext, boolean placeChar)
goToNewLine
in class Editor<GuiOutputManager>
subtext
- The text.placeChar
- flag indicating if this call is from Editor.placeChar(char)
.true
if the text will output on a new line.protected boolean insertBlankLineOnLF()
insertBlankLineOnLF
in class Editor<GuiOutputManager>
true
for GUI mode.protected void cursorPos(int pos)
cursorPos
in class Editor<GuiOutputManager>
pos
- The new absolute cursor position.protected void mergeLines(int row)
mergeLines
in class Editor<GuiOutputManager>
row
- line's rowprotected int getNextSplitPosition(java.lang.String line, int splitAfter)
getNextSplitPosition
in class Editor<GuiOutputManager>
line
- The line to be split.splitAfter
- minimal split position.protected void splitLine(java.lang.String line, int row, int splitAfter)
splitLine
in class Editor<GuiOutputManager>
line
- line's contentrow
- line's rowsplitAfter
- minimal split positionprotected java.util.List<Editor.Line> parseContentImpl(java.lang.String source, int start, int offset, boolean placeChar)
It uses computeSplitIndexes(String, int, int, boolean)
to determine the text's
split indexes.
parseContentImpl
in class Editor<GuiOutputManager>
source
- Source string to parse.start
- Row index to start parsing from.offset
- Text offset to start parsing from.placeChar
- Set to true
if called from Editor.placeChar(char)
method in insert mode.protected void cursorRight()
cursorRight
in class Editor<GuiOutputManager>
protected void cursorDown()
cursorDown
in class Editor<GuiOutputManager>
protected void cursorUp()
cursorUp
in class Editor<GuiOutputManager>
protected void cursorLeft()
cursorLeft
in class Editor<GuiOutputManager>
protected void cursorEndOfLine()
cursorEndOfLine
in class Editor<GuiOutputManager>
public boolean setCursorLine(int line)
setCursorLine
in class Editor<GuiOutputManager>
line
- the new cursor line valuetrue
if the cursor line is valid and setprotected void backspace()
backspace
in class Editor<GuiOutputManager>
protected void deleteCharacterKey()
processKeyEvent(com.goldencode.p2j.ui.client.event.KeyInput)
.deleteCharacterKey
in class Editor<GuiOutputManager>
protected java.lang.String rtrim(java.lang.String value)
rtrim
in class Editor<GuiOutputManager>
value
- the string to be truncatedprotected int absoluteX()
absoluteX
in class Editor<GuiOutputManager>
protected boolean canPlaceChar()
canPlaceChar
in class Editor<GuiOutputManager>
true
if the editor is not read-only and its content is less than
the EditorConfig.maxChars
value (or MAX-CHARS attribute is not set).protected java.lang.String processEOLChars(java.lang.String src)
processEOLChars
in class Editor<GuiOutputManager>
src
- the string to be processed.public boolean supportsCustomMousePointer()
supportsCustomMousePointer
in interface Widget<GuiOutputManager>
supportsCustomMousePointer
in class AbstractWidget<GuiOutputManager>
true
if the widget supports LOAD-MOUSE-POINTER() methodprotected MouseHoverAction createMouseHoverAction()
createMouseHoverAction
in class AbstractWidget<GuiOutputManager>
private void computeSplitIndexes(java.lang.String source, int start, int offset, boolean placeChar)
source
- Source string to parse.start
- Row index to start parsing from.offset
- Text offset to start parsing from.placeChar
- Set to true
if called from Editor.placeChar(char)
method in insert mode.private void adjustCursorX(int prevY, int prevX, int setCaretTo)
This is also used on mouse click, when the content is scrolled via the scroll bar
(barScrollX
is non zero). In this case, the setCaretTo
parameter will
be set to a value other than Integer.MIN_VALUE
, and will represent the relative
pixel column (to the editor) where the mouse was clicked. Using this, it will preserve the
mouse scroll (so that the left-edge character will be referenced by
EditorConfig.scrollX
) and the cursor X will be adjusted to represent the clicked
character.
prevY
- Absolute line before the up/down key was processed.prevX
- Absolute column before the up/down key was processed.private void wordLeft()
private void wordRight()
private void processScrollPane()
private void setScrollPosition()
private int computeHorizontalDelta(int absY, int barX)
The absY
represents the line index to which the EditorConfig.scrollX
will be applied. The length of the this prefix text (from 0 to scroll X) will be computed
for this line, and to this value the mouse scroll
delta
.
absY
- The reference line from where to take the caret-scrolled prefix.barX
- The physical delta scrolled by mouse, in number of clicks.private int computeHorizontalScrollDelta(int barX)
EditorConfig.scrollX
value. This is
always computed using the font's width multiplied by the given delta.barX
- The physical delta scrolled by mouse, in number of clicks.private int maxLineWidthNative()
private int findScrollOffset(int width)
EditorConfig.scrollX
value.width
- The pixel width for the text to be scrolled.private void adjustScrollY()
public void invalidateSelection()
invalidateSelection
in interface TextSelection
public boolean isSelectionValid()
isSelectionValid
in interface TextSelection
true
if the selectionStart
and selectionEnd
are set.private void adjustSelection()
private java.lang.String getSelectedText(boolean remove)
remove
parameter is set to
true
, this text is also removed.remove
- Flag determining if the selected text needs to be removed.private Window<?> resolveWindow()
private GuiFontResolver fontResolver()
private void computeLineWidths(int from, int to)
from
- Start index in the parsed content.to
- End index in the parsed content (inclusive).private void computeLineWidths(Editor.Line l)
l
- The line for which the widths need to be computed.public int getTextWidthNative(int lineNo, int start, int end, int font)
If the line's intermediate widths were computed, use these to compute the substring's width.
Otherwise, default to the AbstractWidget.getTextWidthNative(java.lang.String, int)
.
lineNo
- The line number (0-base).start
- The start index in the line.end
- The end index in the line (exclusive).font
- The font.public int getTextWidthNative(Editor.Line line, int start, int end, int font)
If the line's intermediate widths were computed, use these to compute the substring's width.
Otherwise, default to the AbstractWidget.getTextWidthNative(java.lang.String, int)
.
line
- The line instance.start
- The start index in the line.end
- The end index in the line (exclusive).font
- The font.