Package xtwm.ui
Class InternalEditorWindow
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TWindow
-
- jexer.TScrollableWindow
-
- xtwm.ui.InternalEditorWindow
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>
,Scrollable
public class InternalEditorWindow extends TScrollableWindow
InternalEditorWindow is a basic text file editor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
InternalEditorWindow.InternalEditorWidget
InternalEditorWidget is a TEditorWidget that highlights the breakpoint and execution lines.
-
Field Summary
Fields Modifier and Type Field Description protected InternalEditorWindow.InternalEditorWidget
editField
Hang onto my editor so I can resize it with the window.-
Fields inherited from class jexer.TScrollableWindow
hScroller, vScroller
-
Fields inherited from class jexer.TWindow
ABSOLUTEXY, CENTERED, helpTopic, HIDEONCLOSE, inKeyboardResize, inWindowMove, inWindowResize, MODAL, mouse, NOCLOSEBOX, NOZOOMBOX, OVERRIDEMENU, RESIZABLE, statusBar
-
-
Constructor Summary
Constructors Constructor Description InternalEditorWindow(TApplication parent)
Public constructor.InternalEditorWindow(TApplication parent, java.io.File file)
Public constructor opens a file.InternalEditorWindow(TApplication parent, java.io.File file, int x, int y, int width, int height)
Public constructor opens a file.InternalEditorWindow(TApplication parent, java.lang.String title)
Public constructor with a custom title.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
askToSave()
Ask to save the file if it is dirty.void
draw()
Draw the window.java.lang.String
getEditingRawLine(int row)
Get the current editing row plain text.int
getEditingRowNumber()
Get the current editing row number.java.lang.String
getFilename()
Get the filename being edited.int
getLineCount()
Get the number of lines in the underlying Document.java.lang.String
getSelection()
Copy text within the selection bounds to a string.int
getSelectionStartColumn()
Get the selection starting column number.int
getSelectionStartRow()
Get the selection starting row number.java.lang.String
getText()
Get the entire contents of the editor as one string.boolean
hasHiddenMouse()
Returns true if this window does not want the application-wide mouse cursor drawn over it.boolean
hasSelection()
Check if selection is available.void
onCommand(TCommandEvent command)
Method that subclasses can override to handle posted command events.void
onFocus()
Called by application.switchWindow() when this window gets the focus, and also by application.addWindow().void
onKeypress(TKeypressEvent keypress)
Handle keystrokes.void
onMenu(TMenuEvent menu)
Handle posted menu events.void
onMouseDown(TMouseEvent mouse)
Handle mouse press events.void
onMouseMotion(TMouseEvent mouse)
Method that subclasses can override to handle mouse movements.void
onMouseUp(TMouseEvent mouse)
Handle mouse release events.void
onPreClose()
Prompt the user to save if we are about to be closed and the editor is dirty.void
onResize(TResizeEvent event)
Handle window/screen resize events.void
onUnfocus()
Called by application.switchWindow() when another window gets the focus.void
replaceSelection(java.lang.String text)
Replace whatever is being selected with new text.void
saveIfDirty()
Save the file if it is dirty.void
setEditingColumnNumber(int column)
Set the current editing column number.void
setEditingPositionNumber(int row, int column)
Set the current editing row and column number.void
setEditingRowNumber(int row)
Set the current editing row number.void
setSelection(int startRow, int startColumn, int endRow, int endColumn)
Set the selection.protected void
setupAfterEditor()
Setup other fields after the editor is created.-
Methods inherited from class jexer.TScrollableWindow
bigHorizontalDecrement, bigHorizontalIncrement, bigVerticalDecrement, bigVerticalIncrement, getBottomValue, getHorizontalBigChange, getHorizontalScroller, getHorizontalSmallChange, getHorizontalValue, getLeftValue, getRightValue, getTopValue, getVerticalBigChange, getVerticalScroller, getVerticalSmallChange, getVerticalValue, horizontalDecrement, horizontalIncrement, maximize, mouseOnHorizontalScroller, mouseOnVerticalScroller, placeScrollbars, reflowData, restore, setBottomValue, setHorizontalBigChange, setHorizontalSmallChange, setHorizontalValue, setLeftValue, setRightValue, setTopValue, setVerticalBigChange, setVerticalSmallChange, setVerticalValue, toBottom, toEnd, toHome, toLeft, toRight, toTop, verticalDecrement, verticalIncrement
-
Methods inherited from class jexer.TWindow
activate, addShortcutKeypress, center, clearShortcutKeypresses, close, ensureOnScreen, getApplication, getBackground, getBorder, getBorderControls, getHelpTopic, getMaximumWindowHeight, getMaximumWindowWidth, getMinimumWindowHeight, getMinimumWindowWidth, getScreen, getStatusBar, getTitle, getZ, hasCloseBox, hasOverriddenMenu, hasZoomBox, hide, inMovements, isHidden, isModal, isResizable, isShortcutKeypress, isShown, mouseOnClose, mouseOnMaximize, mouseOnResize, newStatusBar, onClose, onHide, onShow, removeShortcutKeypress, setCloseBox, setHiddenMouse, setMaximumWindowHeight, setMaximumWindowWidth, setMinimumWindowHeight, setMinimumWindowWidth, setResizable, setTitle, setZ, setZoomBox, show, stopMovements, toString
-
Methods inherited from class jexer.TWidget
activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getHeight, getLayoutManager, getParent, getTheme, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onIdle, onMouseDoubleClick, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, vLineXY
-
-
-
-
Field Detail
-
editField
protected InternalEditorWindow.InternalEditorWidget editField
Hang onto my editor so I can resize it with the window.
-
-
Constructor Detail
-
InternalEditorWindow
public InternalEditorWindow(TApplication parent)
Public constructor.- Parameters:
parent
- the main application
-
InternalEditorWindow
public InternalEditorWindow(TApplication parent, java.lang.String title)
Public constructor with a custom title.- Parameters:
parent
- the main applicationtitle
- the window title
-
InternalEditorWindow
public InternalEditorWindow(TApplication parent, java.io.File file) throws java.io.IOException
Public constructor opens a file.- Parameters:
parent
- the main applicationfile
- the file to open- Throws:
java.io.IOException
- if a java.io operation throws
-
InternalEditorWindow
public InternalEditorWindow(TApplication parent, java.io.File file, int x, int y, int width, int height) throws java.io.IOException
Public constructor opens a file.- Parameters:
parent
- the main applicationfile
- the file to open, or null for a new filex
- column relative to parenty
- row relative to parentwidth
- width of windowheight
- height of window- Throws:
java.io.IOException
- if a java.io operation throws
-
-
Method Detail
-
onFocus
public void onFocus()
Called by application.switchWindow() when this window gets the focus, and also by application.addWindow().
-
onUnfocus
public void onUnfocus()
Called by application.switchWindow() when another window gets the focus.
-
onPreClose
public void onPreClose()
Prompt the user to save if we are about to be closed and the editor is dirty.- Overrides:
onPreClose
in classTWindow
-
onMouseDown
public void onMouseDown(TMouseEvent mouse)
Handle mouse press events.- Overrides:
onMouseDown
in classTWindow
- Parameters:
mouse
- mouse button press event
-
onMouseUp
public void onMouseUp(TMouseEvent mouse)
Handle mouse release events.
-
onMouseMotion
public void onMouseMotion(TMouseEvent mouse)
Method that subclasses can override to handle mouse movements.- Overrides:
onMouseMotion
in classTWindow
- Parameters:
mouse
- mouse motion event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypress
in classTWindow
- Parameters:
keypress
- keystroke event
-
onResize
public void onResize(TResizeEvent event)
Handle window/screen resize events.- Overrides:
onResize
in classTScrollableWindow
- Parameters:
event
- resize event
-
onCommand
public void onCommand(TCommandEvent command)
Method that subclasses can override to handle posted command events.
-
onMenu
public void onMenu(TMenuEvent menu)
Handle posted menu events.
-
hasHiddenMouse
public boolean hasHiddenMouse()
Returns true if this window does not want the application-wide mouse cursor drawn over it.- Overrides:
hasHiddenMouse
in classTWindow
- Returns:
- true if this window does not want the application-wide mouse cursor drawn over it
-
setupAfterEditor
protected void setupAfterEditor()
Setup other fields after the editor is created.
-
getFilename
public java.lang.String getFilename()
Get the filename being edited.- Returns:
- the filename, or null if this is a new file that has never been saved
-
askToSave
public void askToSave()
Ask to save the file if it is dirty. If the user accepts, save the file.
-
saveIfDirty
public void saveIfDirty()
Save the file if it is dirty.
-
setEditingColumnNumber
public void setEditingColumnNumber(int column)
Set the current editing column number. 1-based.- Parameters:
column
- the new editing column number. Column 1 is the leftmost column.
-
getEditingRowNumber
public int getEditingRowNumber()
Get the current editing row number. 1-based.- Returns:
- the editing row number. Row 1 is the first row.
-
setEditingRowNumber
public void setEditingRowNumber(int row)
Set the current editing row number. 1-based.- Parameters:
row
- the new editing row number. Row 1 is the first row.
-
getLineCount
public int getLineCount()
Get the number of lines in the underlying Document.- Returns:
- the number of lines
-
getEditingRawLine
public java.lang.String getEditingRawLine(int row)
Get the current editing row plain text. 1-based.- Parameters:
row
- the new editing row number. Row 1 is the first row.- Returns:
- the plain text of the row
-
setEditingPositionNumber
public void setEditingPositionNumber(int row, int column)
Set the current editing row and column number. 1-based.- Parameters:
row
- the new editing row number. Row 1 is the first row.column
- the new editing column number. Column 1 is the leftmost column.
-
setSelection
public void setSelection(int startRow, int startColumn, int endRow, int endColumn)
Set the selection.- Parameters:
startRow
- the starting row number. 0-based: row 0 is the first row.startColumn
- the starting column number. 0-based: column 0 is the first column.endRow
- the ending row number. 0-based: row 0 is the first row.endColumn
- the ending column number. 0-based: column 0 is the first column.
-
replaceSelection
public void replaceSelection(java.lang.String text)
Replace whatever is being selected with new text. If not in selection, nothing is replaced.- Parameters:
text
- the new replacement text
-
hasSelection
public boolean hasSelection()
Check if selection is available.- Returns:
- true if a selection has been made
-
getSelection
public java.lang.String getSelection()
Copy text within the selection bounds to a string.- Returns:
- the selection as a string, or null if there is no selection
-
getSelectionStartRow
public int getSelectionStartRow()
Get the selection starting row number.- Returns:
- the starting row number, or -1 if there is no selection. 0-based: row 0 is the first row.
-
getSelectionStartColumn
public int getSelectionStartColumn()
Get the selection starting column number.- Returns:
- the starting column number, or -1 if there is no selection. 0-based: column 0 is the first column.
-
getText
public java.lang.String getText()
Get the entire contents of the editor as one string.- Returns:
- the editor contents
-
-