public class EditorImpl extends Editor<ChuiOutputManager>
Modifier and Type | Class and Description |
---|---|
protected class |
EditorImpl.LocalChuiFocusListener
Some actions on focus hanging.
|
Editor.Line, Editor.LocalFocusListener
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private static int |
EDITOR_TAB_SIZE
Editor widget TAB size in spaces.
|
private boolean |
fakeInsert
If true then the editor is into read-only mode and INSERT key hasn't
been pressed.
|
CR, forceRedraw, insert, LF, maxSizes, parsedText, SPACE, SPACE_LF, widgetFocused
config
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
EditorImpl(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.
|
void |
afterConfigUpdate(EditorConfig beforeUpdate)
The method is called after the configuration associated with
the implementor changes.
|
private void |
appendLine()
Handle APPEND-LINE event.
|
protected double |
calcHpos(double size)
Calculate horizontal position of the scroll-bar thumb.
|
protected double |
calcVpos(double size)
Calculate vertical position of the scroll-bar thumb.
|
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.
|
private boolean |
deleteLineWorker()
Delete the line of text in which the cursor currently resides.
|
private void |
deleteWord()
Delete word.
|
void |
draw(Color color)
Actual drawing routine.
|
void |
drawCaretUnconditionally()
Sets position of terminal's cursor unconditionally (even if this editor
is not in focus).
|
private void |
editorBackTab()
Handle EDITOR-BACKTAB event.
|
private void |
editorTab()
Handle EDITOR-TAB event.
|
protected FocusListener |
getFocusListener()
Get the focus listener instance.
|
private boolean |
getInsertMode()
Returns the insert mode state.
|
protected int |
getNextSplitPosition(java.lang.String line,
int splitAfter)
Get the next split position of this line, so that it fits the editor.
|
private int |
getNextWordSize()
Get length of the first word in the next row.
|
protected boolean |
goToNewLine(java.lang.String subtext,
boolean placeChar)
Check if the given text needs to output on a new line.
|
protected boolean |
insertBlankLineOnLF()
Determine if a blank line needs to be inserted when RETURN key is pressed on a empty line.
|
protected void |
mergeLines(int row)
Merge line with subsequent one(s) if possible
|
private void |
openLineAbove()
Insert empty line above current line.
|
protected void |
placeLF()
Place new line character at current cursor position.
|
private java.lang.String |
prepareTextRow(boolean uninit,
int width,
java.lang.String space,
int line)
Prepare text for display.
|
protected java.lang.String |
processEOLChars(java.lang.String src)
Processing for unusual EOL characters in ChUI mode.
|
void |
processKeyEvent(KeyInput ke)
Process KeyEvents for this widget.
|
boolean |
setCursorChar(int pos,
boolean redraw)
Sets the cursor position in the current line
|
protected void |
setCursorX(int pos)
Calculate and set the cursor X position.
|
protected void |
setInsertMode(boolean mode)
Changes the insert mode state in the window.
|
void |
setLabelInstance(Label<ChuiOutputManager> label)
Assign new instance of
Label to the fill-in widget. |
protected <C extends WidgetConfig> |
updateSizeWorker(C beforeUpdate)
Instructs the widget that its size may have changed.
|
private void |
wordLeft()
Move cursor one word left.
|
private void |
wordRight()
Move cursor one word right.
|
absoluteY, backspace, bell, canPlaceChar, clear, contentLength, currentFocus, cursorBeginOfLine, cursorDown, cursorEndOfPrevLine, cursorHome, cursorUp, defaultFocus, deleteCharacter, deleteCharacterKey, deleteLine, deleteToEndOfLine, draw, drawCaret, editorReadFile, editorSaveFile, focusTraversable, fullHeight, getCursorChar, getCursorLine, getCursorOffset, getLength, getLine, getLineCount, getLineText, getText, getValue, initialize, insertFile, insertString, lastRow, manageSystemActions, parseContent, parseContentImpl, placeChar, refresh, replaceSelectionText, replaceString, requestFocus, resolveContent, rtrim, search, setCursorChar, setCursorLine, setCursorLineAndChar, setCursorOffset, setSelection, setValue, splitLine, updateOffset
config, defaultMousePtr, destroy, getColon, getColumnLabelText, getColumnMnemonic, getLabelInstance, getLabelText, getMnemonic, getTo, isForceLabel, isModified, isNoLabels, isRightAligned, postprocessConfig, setColumnMnemonic, setHidden, setMnemonic, setNoLabels, setVisible, setWasVisible, wasVisible
minimumSize
add, add, add, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, currentFocus, cycleFocus, detach, dimension, doLayout, endSizeChange, findMouseSource, firstFocus, focus, focusWorker, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, 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, widgets, width
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, enable, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
invalidateSelection, isSelectionValid, removeSelectedText
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, dimension, displayPhysicalLocation, enclosingFrame, enforceDefaultMousePtr, findMouseSource, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hasFocus, height, hidden, hide, highlighted, insets, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, minimumSize, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, repaint, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, supportsCustomMousePointer, topLevelWindow, unrealize, width, window
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
createMnemonic, getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, isMnemonicSupported, updateMnemonic
private static final int EDITOR_TAB_SIZE
private boolean fakeInsert
public EditorImpl(WidgetId id, EditorConfig cfg)
id
- The widget's ID.cfg
- Configuration data.public void processKeyEvent(KeyInput ke)
processKeyEvent
in interface Widget<ChuiOutputManager>
processKeyEvent
in class Editor<ChuiOutputManager>
ke
- Key event structure.public void afterConfigUpdate(EditorConfig beforeUpdate)
afterConfigUpdate
in interface ConfigOwner<EditorConfig>
afterConfigUpdate
in class LabeledDataContainer<ChuiOutputManager,EditorConfig>
beforeUpdate
- The previous configuration.public void setLabelInstance(Label<ChuiOutputManager> label)
Label
to the fill-in widget.setLabelInstance
in interface LabeledWidget<ChuiOutputManager>
setLabelInstance
in class LabeledDataContainer<ChuiOutputManager,EditorConfig>
label
- Reference to new Label
instance.public void drawCaretUnconditionally()
drawCaretUnconditionally
in class Editor<ChuiOutputManager>
public void draw(Color color)
draw
in class Editor<ChuiOutputManager>
color
- Color for drawing.public boolean setCursorChar(int pos, boolean redraw)
setCursorChar
in class Editor<ChuiOutputManager>
pos
- the new cursor position value\redraw
- request redraw/synctrue
if the cursor position is valid and setprotected double calcHpos(double size)
size
- The width of the scroll-bar.protected double calcVpos(double size)
size
- The height of the scroll-bar.protected int absoluteX()
absoluteX
in class Editor<ChuiOutputManager>
protected boolean goToNewLine(java.lang.String subtext, boolean placeChar)
goToNewLine
in class Editor<ChuiOutputManager>
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 void mergeLines(int row)
mergeLines
in class Editor<ChuiOutputManager>
row
- line's rowprotected void setInsertMode(boolean mode)
mode
- New state.
false
- overwrite mode,
true
- insert mode.
protected void placeLF()
placeLF
in class Editor<ChuiOutputManager>
protected boolean insertBlankLineOnLF()
insertBlankLineOnLF
in class Editor<ChuiOutputManager>
false
.protected void cursorRight()
cursorRight
in class Editor<ChuiOutputManager>
protected void cursorEndOfLine()
cursorEndOfLine
in class Editor<ChuiOutputManager>
protected void cursorLeft()
cursorLeft
in class Editor<ChuiOutputManager>
protected void setCursorX(int pos)
pos
- New cursor position (0-based).protected void cursorPos(int pos)
cursorPos
in class Editor<ChuiOutputManager>
pos
- The new absolute cursor position.protected FocusListener getFocusListener()
getFocusListener
in class Editor<ChuiOutputManager>
protected int getNextSplitPosition(java.lang.String line, int splitAfter)
getNextSplitPosition
in class Editor<ChuiOutputManager>
line
- The line to be split.splitAfter
- minimal split position.protected <C extends WidgetConfig> void updateSizeWorker(C beforeUpdate)
This implementation ignores the supplied config instance. Instead it relies
on AbstractContainer.size
and LabeledDataContainer.config()
to detect whether size has changed.
updateSizeWorker
in class AbstractContainer<ChuiOutputManager>
beforeUpdate
- BaseConfig
reference or null
.protected java.lang.String processEOLChars(java.lang.String src)
processEOLChars
in class Editor<ChuiOutputManager>
src
- the string to be processed.private void wordLeft()
private void wordRight()
private int getNextWordSize()
private void editorBackTab()
private void editorTab()
private void appendLine()
private boolean getInsertMode()
false
- overwrite mode,
true
- insert mode.
private void openLineAbove()
private java.lang.String prepareTextRow(boolean uninit, int width, java.lang.String space, int line)
uninit
- true
if the widget is uninitialized.width
- Width of the displayed area.space
- Prepared string filled with spaces.line
- Index in the array of parsed strings.private boolean deleteLineWorker()
true
if anything is deleted.private void deleteWord()