Class Fox::FXText

In: | FXText.rb
Parent: | FXScrollArea

Multiline text widget

# Attributes

marginTop: | top margin [Integer]
marginBottom: | bottom margin [Integer]
marginLeft: | left margin [Integer]
marginRight: | right margin [Integer]
wrapColumns: | wrap columns [Integer]
tabColumns: | tab columns [Integer]
barColumns: | number of columns used for line numbers [Integer]
modified: | indicates whether text is modified [Boolean]
editable: | indicates whether text is editable [Boolean]
styled: | indicates whether text is styled [Boolean]
delimiters: | word delimiters [String]
font: | text font [FXFont]
textColor: | text color [FXColor]
selBackColor: | selected text background color [FXColor]
selTextColor: | selected text color [FXColor]
hiliteTextColor: | highlight text color [FXColor]
hiliteBackColor: | highlight text background color [FXColor]
activeBackColor: | active background color [FXColor]
cursorColor: | cursor color [FXColor]
numberColor: | line number color [FXColor]
barColor: | bar color [FXColor]
helpText: | status line help text [String]
tipText: | tool tip message [String]
text: | the text buffer [String]
length: | the length of the text buffer [Integer]
anchorPos: | anchor position [Integer]
cursorPos: | cursor position [Integer]
selStartPos: | selection start position [Integer]
selEndPos: | selection end position [Integer]
textStyle: | text widget style [Integer]
visRows: | number of visible rows [Integer]
visCols: | number of visible columns [Integer]
hiliteMatchTime: | brace and parenthesis match highlighting time, in milliseconds [Integer]. A hiliteMatchTime of 0 disables brace matching.
hiliteStyles: | array of hilite styles [an Array of FXHiliteStyle instances]

# Events

The following messages are sent by FXText to its target:

`SEL_KEYPRESS`: | sent when a key is pressed; the message data is an FXEvent instance.
`SEL_KEYRELEASE`: | sent when a key is released; the message data is an FXEvent instance.
`SEL_LEFTBUTTONPRESS`: | sent when the left mouse button goes down; the message data is an FXEvent instance.
`SEL_LEFTBUTTONRELEASE`: | sent when the left mouse button goes up; the message data is an FXEvent instance.
`SEL_MIDDLEBUTTONPRESS`: | sent when the middle mouse button goes down; the message data is an FXEvent instance.
`SEL_MIDDLEBUTTONRELEASE`: | sent when the middle mouse button goes up; the message data is an FXEvent instance.
`SEL_RIGHTBUTTONPRESS`: | sent when the right mouse button goes down; the message data is an FXEvent instance.
`SEL_RIGHTBUTTONRELEASE`: | sent when the right mouse button goes up; the message data is an FXEvent instance.
`SEL_INSERTED`: | sent after text is inserted into the text buffer; the message data is a two-element array indicating the position at which the text was inserted and the number of characters inserted.
`SEL_DELETED`: | sent before text is removed from the text buffer; the message data is a two-element array indicating the position at which text will be removed and the number of characters to be removed.
`SEL_CHANGED`: | sent when the contents of the text buffer change in any way; the message data is an integer indicating the cursor position.
`SEL_SELECTED`: | sent after text is selected; the message data is a two-element array indicating the starting position of the selected text and the number of characters selected.
`SEL_DESELECTED`: | sent before text is deselected; the message data is a two-element array indicating the starting position of the deselected text and the number of characters deselected.

# Text widget options

`TEXT_READONLY`: | Text is not editable
`TEXT_WORDWRAP`: | Wrap at word breaks
`TEXT_OVERSTRIKE`: | Overstrike mode
`TEXT_FIXEDWRAP`: | Fixed wrap columns
`TEXT_NO_TABS`: | Insert spaces for tabs
`TEXT_AUTOINDENT`: | Autoindent
`TEXT_SHOWACTIVE`: | Show active line

# Selection modes

`SELECT_CHARS` `SELECT_WORDS` `SELECT_LINES`

# Text styles

`STYLE_UNDERLINE`: | underline text
`STYLE_STRIKEOUT`: | strike out text

# Message identifiers

`ID_CURSOR_TOP`:: `ID_CURSOR_BOTTOM`:: `ID_CURSOR_HOME`:: `ID_CURSOR_END`:: `ID_CURSOR_RIGHT`:: `ID_CURSOR_LEFT`:: `ID_CURSOR_UP`:: `ID_CURSOR_DOWN`:: `ID_CURSOR_WORD_LEFT`:: `ID_CURSOR_WORD_RIGHT`:: `ID_CURSOR_PAGEDOWN`:: `ID_CURSOR_PAGEUP`:: `ID_CURSOR_SCRNTOP`:: `ID_CURSOR_SCRNBTM`:: `ID_CURSOR_SCRNCTR`:: `ID_CURSOR_PAR_HOME`:: `ID_CURSOR_PAR_END`:: `ID_SCROLL_UP`:: `ID_SCROLL_DOWN`:: `ID_MARK`:: `ID_EXTEND`:: `ID_OVERST_STRING`:: `ID_INSERT_STRING`:: `ID_INSERT_NEWLINE`:: `ID_INSERT_TAB`:: `ID_CUT_SEL`:: `ID_COPY_SEL`:: `ID_PASTE_SEL`:: `ID_DELETE_SEL`:: `ID_SELECT_CHAR`:: `ID_SELECT_WORD`:: `ID_SELECT_LINE`:: `ID_SELECT_ALL`:: `ID_SELECT_MATCHING`:: `ID_SELECT_BRACE`:: `ID_SELECT_BRACK`:: `ID_SELECT_PAREN`:: `ID_SELECT_ANG`:: `ID_DESELECT_ALL`:: `ID_BACKSPACE`:: `ID_BACKSPACE_WORD`:: `ID_BACKSPACE_BOL`:: `ID_DELETE`:: `ID_DELETE_WORD`:: `ID_DELETE_EOL`:: `ID_DELETE_LINE`:: `ID_TOGGLE_EDITABLE`:: `ID_TOGGLE_OVERSTRIKE`:: `ID_CURSOR_ROW`:: `ID_CURSOR_COLUMN`:: `ID_CLEAN_INDENT`:: `ID_SHIFT_LEFT`:: `ID_SHIFT_RIGHT`:: `ID_SHIFT_TABLEFT`:: `ID_SHIFT_TABRIGHT`:: `ID_UPPER_CASE`:: `ID_LOWER_CASE`:: `ID_GOTO_MATCHING`:: `ID_GOTO_SELECTED`:: `ID_GOTO_LINE`:: `ID_SEARCH_FORW_SEL`:: `ID_SEARCH_BACK_SEL`:: `ID_SEARCH`:: `ID_REPLACE`:: `ID_LEFT_BRACE`:: `ID_LEFT_BRACK`:: `ID_LEFT_PAREN`:: `ID_LEFT_ANG`:: `ID_RIGHT_BRACE`:: `ID_RIGHT_BRACK`:: `ID_RIGHT_PAREN`:: `ID_RIGHT_ANG`:: `ID_BLINK`:: `ID_FLASH`::

Methods

appendStyledText appendText changeStyle editable? extendSelection extractStyle extractText findText getBottomLine getChar getStyle getTopLine insertStyledText insertText killHighlight killSelection leftWord lineEnd lineStart makePositionVisible modified? new nextLine nextRow positionAt positionSelected? positionVisible? prevLine prevRow removeText replaceStyledText replaceText rightWord rowEnd rowStart selectAll setBottomLine setCenterLine setCursorCol setCursorPos setCursorRow setHighlight setSelection setStyledText setText setTopLine shiftText styled? validPos wordEnd wordStart

Attributes

activeBackColor | [RW] |
anchorPos | [RW] |
barColor | [RW] |
barColumns | [RW] |
cursorCol | [RW] |
cursorColor | [RW] |
cursorPos | [R] |
cursorRow | [RW] |
delimiters | [RW] |
editable | [W] |
font | [RW] |
helpText | [RW] |
hiliteBackColor | [RW] |
hiliteMatchTime | [RW] |
hiliteStyles | [RW] |
hiliteTextColor | [RW] |
length | [R] |
marginBottom | [RW] |
marginLeft | [RW] |
marginRight | [RW] |
marginTop | [RW] |
modified | [W] |
numberColor | [RW] |
selBackColor | [RW] |
selEndPos | [R] |
selStartPos | [R] |
selTextColor | [RW] |
styled | [W] |
tabColumns | [RW] |
text | [RW] |
textColor | [RW] |
textStyle | [RW] |
tipText | [RW] |
visCols | [RW] |
visRows | [RW] |
wrapColumns | [RW] |

Public Class methods

new(aComposite, target=nil, selector=0, opts=0, x=0, y=0, w=0, h=0) {|theText| ...}

Construct multiline text widget

Public Instance methods

modified?()

Return `true` if text was modified

editable?()

Return `true` if text is editable

styled?()

Return `true` if styled text

getChar(pos)

Get character at position pos in text buffer

getStyle(pos)

Get style at position pos in style buffer

extractText(pos, n)

Extract n characters of text from position pos in the text buffer

extractStyle(pos, n)

Extract n characters of style info from position pos in the style buffer

replaceText(pos, m, text, notify=false)

Replace the m characters at pos with text. If notify is `true`, a `SEL_DELETED` message is sent to the text widget's message target before the old text is removed, and a `SEL_INSERTED` and `SEL_CHANGED` message is sent after the new text is inserted.

replaceStyledText(pos, m, text, style=0, notify=false)

Replace the m characters at pos with text. If notify is `true`, a `SEL_DELETED` message is sent to the text widget's message target before the old text is removed, and a `SEL_INSERTED` and `SEL_CHANGED` message is sent after the new text is inserted.

appendText(text, notify=false)

Append text to the end of the text buffer. If notify is `true`, `SEL_INSERTED` and `SEL_CHANGED` messages are sent to the text widget's message target after the new text is added.

appendStyledText(text, style=0, notify=false)

Append text to the end of the text buffer. If notify is `true`, `SEL_INSERTED` and `SEL_CHANGED` messages are sent to the text widget's message target after the new text is added.

insertText(pos, text, notify=false)

Insert text at position pos in the text buffer. If notify is `true`, `SEL_INSERTED` and `SEL_CHANGED` messages are sent to the text widget's message target after the new text is inserted.

insertStyledText(pos, text, style=0, notify=false)

Insert text at position pos in the text buffer. If notify is `true`, `SEL_INSERTED` and `SEL_CHANGED` messages are sent to the text widget's message target after the new text is inserted.

removeText(pos, n, notify=false)

Remove n characters of text at position pos in the buffer If notify is `true`, a `SEL_DELETED` message is sent to the text widget's message target before the text is removed and a `SEL_CHANGED` message is sent after the change occurs.

changeStyle(pos, n, style)

Change the style of n characters at position pos in the text buffer to style. Here, style is either an integer into the style table, indicating the new style for all the affected characters; or style is a String...

setText(text, notify=false)

Change the text If notify is `true`, `SEL_INSERTED` and `SEL_CHANGED` messages are sent to the text widget's message target after the new text is set.

setStyledText(text, style=0, notify=false)

Change the text in the buffer to new text If notify is `true`, `SEL_INSERTED` and `SEL_CHANGED` messages are sent to the text widget's message target after the new text is set.

shiftText(startPos, endPos, amount, notify=false)

Shift block of lines from position startPos up to endPos by given amount. If notify is `true`, a `SEL_DELETED` message is sent to the text widget's message target before the old text is removed, and a `SEL_INSERTED` and `SEL_CHANGED` message is sent after the new text is inserted.

findText(string, beg=nil, end=nil, start=0, flags=SEARCH_FORWARD|SEARCH_WRAP|SEARCH_EXACT, npar=1)

Search for string in text buffer, returning the extent of the string in beg and end. The search starts from the given start position, scans forward (`SEARCH_FORWARD`) or backward (`SEARCH_BACKWARD`), and wraps around if `SEARCH_WRAP` has been specified. The search type is either a plain search (`SEARCH_EXACT`), case insensitive search (`SEARCH_IGNORECASE`), or regular expression search (`SEARCH_REGEX`). For regular expression searches, capturing parentheses are used if npar is greater than 1; in this case, the number of entries in the beg and end arrays must be npar also. If either beg or end or both are nil, internal arrays are used.

positionSelected?(pos)

Return `true` if position pos is selected

positionVisible?(pos)

Return `true` if position pos is fully visible

positionAt(x, y)

Return text position at given visible (x, y) coordinate

lineStart(pos)

Return position of beginning of line containing position pos

lineEnd(pos)

Return position of end of line containing position pos

nextLine(pos, nl=1)

Return start of next line

prevLine(pos, nl=1)

Return start of previous line

rowStart(pos)

Return row start

rowEnd(pos)

Return row end

nextRow(pos, nr=1)

Return start of next row

prevRow(pos, nr=1)

Return start of previous row

leftWord(pos)

Return end of previous word

rightWord(pos)

Return begin of next word

wordStart(pos)

Return begin of word

wordEnd(pos)

Return end of word

validPos(pos)

Return validated position

setTopLine(pos)

Make line containing pos the top line

getTopLine()

Return position of top line

setBottomLine(pos)

Make line containing pos the bottom line

getBottomLine()

Return the position of the bottom line

setCenterLine(pos)

Make line containing pos the center line

setCursorRow(row, notify=false)

Set cursor row. If notify is `true`, a `SEL_CHANGED` message is sent to the text widget's message target after the change occurs.

setCursorCol(col, notify=false)

Set cursor column. If notify is `true`, a `SEL_CHANGED` message is sent to the text widget's message target after the change occurs.

setCursorPos(pos, notify=false)

Set cursor position. If notify is `true`, a `SEL_CHANGED` message is sent to the text widget's message target after the change occurs.

selectAll(notify=false)

Select all text. If notify is `true`, a `SEL_DESELECTED` message is sent to the text widget's message target before any previously selected text is deselected, then a `SEL_SELECTED` message is sent after the new text is selected.

setSelection(pos, len, notify=false)

Select len characters starting at position pos. If notify is `true`, a `SEL_DESELECTED` message is sent to the text widget's message target before any previously selected text is deselected, then a `SEL_SELECTED` message is sent after the new text is selected.

extendSelection(pos, textSelectionMode=SELECT_CHARS, notify=false)

Extend selection to pos. If notify is `true`, a `SEL_DESELECTED` message is sent to the text widget's message target before any previously selected text is deselected, then a `SEL_SELECTED` message is sent after the new text is selected.

killSelection(notify=false)

Kill the selection. If notify is `true`, a `SEL_DESELECTED` message is sent to the text widget's message target before the text is deselected.

setHighlight(pos, len)

Highlight len characters starting at position pos

killHighlight()

Unhighlight the text

makePositionVisible(pos)

Scroll text to make the given position visible