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


Both these methods return the length of the document.


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.


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.


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.


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, end)

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

returns:a tuple (start,end) of the selection bounds.

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

returns:The selected text. See Multiple Selection for information on how multiple and rectangular selections and virtual space are returned.

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


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.


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.


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


returns:the current position.

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



This returns the current anchor position.


This retrieves the text of the line containing the caret.

Informations about positions

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.

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.


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.


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).


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.

return:the x and y display pixel location of text at position pos in the document.



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.


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.



: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


This Page