Selection and Information

Scintilla maintains a selection that stretches between two points, the anchor and the current position. If the anchor and the current position are the same, there is no selected text. Positions in the document range from 0 (before the first character), to the document size (after the last character).

Informations about text

gtkscintilla.Scintilla.get_text_length()
gtkscintilla.Scintilla.get_length()

Both these methods return the length of the document.

gtkscintilla.Scintilla.get_line_count()

This returns the number of lines in the document. An empty document contains 1 line. A document holding only an end of line sequence has 2 lines.

gtkscintilla.Scintilla.get_first_visible_line()

This returns the line number of the first visible line in the Scintilla view. The first line in the document is numbered 0. The value is a visible line rather than a document line.

gtkscintilla.Scintilla.lines_on_screen()

This returns the number of complete lines visible on the screen. With a constant line height, this is the vertical space available divided by the line separation. Unless you arrange to size your window to an integral number of lines, there may be a partial line visible at the bottom of the view.

gtkscintilla.Scintilla.get_modify()

This returns True if the document is modified and False if it is unmodified. The modified status of a document is determined by the undo position relative to the save point. The save point is set by set_save_point(), usually when you have saved data to a file.

If you need to be notified when the document becomes modified, Scintilla notifies the container that it has entered or left the save point with the save-point-reached and save-point-left notification messages.

Selections

gtkscintilla.Scintilla.select(start, end)

Select a range of text. The caret is scrolled into view after this operation.

gtkscintilla.Scintilla.get_selection_bounds()
returns:a tuple (start,end) of the selection bounds.
gtkscintilla.Scintilla.select_all()

This selects all the text in the document. The current position is not scrolled into view.

gtkscintilla.Scintilla.get_selected_text()
returns:The selected text. See Multiple Selection for information on how multiple and rectangular selections and virtual space are returned.
gtkscintilla.Scintilla.selection_is_rectangle()

This returns 1 if the current selection is in rectangle mode, 0 if not.

gtkscintilla.Scintilla.set_selection_mode(mode)
gtkscintilla.Scintilla.get_selection_mode()

The two functions set and get the selection mode, which can be stream (SC_SEL_STREAM=0) or rectangular (SC_SEL_RECTANGLE=1) or by lines (SC_SEL_LINES=2) or thin rectangular (SC_SEL_THIN=3). When set in these modes, regular caret moves will extend or reduce the selection, until the mode is cancelled by a call with same value or with cancel() . The get function returns the current mode even if the selection was made by mouse or with regular extended moves. SC_SEL_THIN is the mode after a rectangular selection has been typed into and ensures that no characters are selected.

gtkscintilla.Scintilla.move_caret_inside_view()

If the caret is off the top or bottom of the view, it is moved to the nearest line that is visible to its current position. Any selection is lost.

gtkscintilla.Scintilla.set_current_pos(pos)

This sets the current position and creates a selection between the anchor and the current position. The caret is not scrolled into view.

See also

scroll_caret()

gtkscintilla.Scintilla.get_current_pos()
returns:the current position.
gtkscintilla.Scintilla.set_anchor(pos)

This sets the anchor position and creates a selection between the anchor position and the current position. The caret is not scrolled into view.

See also

scroll_caret()

gtkscintilla.Scintilla.get_anchor()

This returns the current anchor position.

gtkscintilla.Scintilla.get_cur_line(text)

This retrieves the text of the line containing the caret.

Informations about positions

gtkscintilla.Scintilla.line_from_position(pos)
returns:the line that contains the position pos in the document. The return value is 0 if pos <= 0. The return value is the last line if pos is beyond the end of the document.
gtkscintilla.Scintilla.position_from_line(line)

This returns the document position that corresponds with the start of the line. If line is negative, the position of the line holding the start of the selection is returned. If line is greater than the lines in the document, the return value is -1. If line is equal to the number of lines in the document (i.e. 1 line past the last line), the return value is the end of the document.

gtkscintilla.Scintilla.get_line_end_position(line)

This returns the position at the end of the line, before any line end characters. If line is the last line in the document (which does not have any end of line characters), the result is the size of the document.

gtkscintilla.Scintilla.line_length(line)

This returns the length of the line, including any line end characters. If line is negative or beyond the last line in the document, the result is 0. If you want the length of the line not including any end of line characters, use get_line_end_position() (line) - position_from_line() (line).

gtkscintilla.Scintilla.get_column(pos)

This message returns the column number of a position pos within the document taking the width of tabs into account. This returns the column number of the last tab on the line before pos, plus the number of characters between the last tab and pos. If there are no tab characters on the line, the return value is the number of characters up to the position on the line. In both cases, double byte characters count as a single character. This is probably only useful with monospaced fonts.

gtkscintilla.Scintilla.find_column(line, column)

This message returns the position of a column on a line taking the width of tabs into account. It treats a multi-byte character as a single column. Column numbers, like lines start at 0.

gtkscintilla.Scintilla.position_from_point(x, y)
gtkscintilla.Scintilla.position_from_point_close(x, y)

position_from_point() finds the closest character position to a point and position_from_point_close() is similar but returns -1 if the point is outside the window or not close to any characters.

gtkscintilla.Scintilla.point_from_position(pos)
return:the x and y display pixel location of text at position pos in the document.

Goto

gtkscintilla.Scintilla.goto_pos(pos)

This removes any selection, sets the caret at pos and scrolls the view to make the caret visible, if necessary. It is equivalent to select() (pos, pos). The anchor position is set the same as the current position.

gtkscintilla.Scintilla.goto_line(line)

This removes any selection and sets the caret at the start of line number line and scrolls the view (if needed) to make it visible. The anchor position is set the same as the current position. If line is outside the lines in the document (first line is 0), the line set is the first or last.

Word

gtkscintilla.Scintilla.word_from_position(pos)

:return the start and end of words using the same definition of words as used internally within Scintilla. You can set your own list of characters that count as words with set_word_chars().

Table Of Contents

Previous topic

Undo and Redo

Next topic

Margins

This Page