Skip to content

ScintillaDocument

Bases: QObject

Wraps a Scintilla document buffer independently of any ScintillaEdit view.

Obtain one from an existing editor via ScintillaEdit.get_doc() (and share it with another editor via set_doc()), or construct one standalone to hold text off-screen. Exposes a subset of ScintillaEdit's editing/undo API directly on the buffer, plus modified/save_point/etc. signals.

error_occurred = ... class-attribute

An internal error occurred while editing the document. status is one of Scintilla's internal Status codes (e.g. out-of-memory or a malformed regular expression) -- not currently exposed as an enum by this binding.

modified = ... class-attribute

The document's text or styling changed, or is about to (SCN_MODIFIED). modification_type is a Scintilla.ModificationFlags bitmask describing what; text holds the inserted/deleted bytes for Scintilla.ModificationFlags.InsertText/DeleteText.

modify_attempt = ... class-attribute

An edit was attempted while the document is read-only (SCN_MODIFYATTEMPTRO).

save_point = ... class-attribute

The document entered (True) or left (False) its save point (SCN_SAVEPOINTREACHED/SCN_SAVEPOINTLEFT).

style_needed = ... class-attribute

Container-lexer styling is needed up to pos (SCN_STYLENEEDED). Only sent if Scintilla.Message.SetILexer was passed None.

__init__(parent=..., pdoc_=...)

Wrap a Scintilla document buffer, creating a new empty one unless pdoc_ is given.

pdoc_ is a native document pointer, as returned by pointer() -- pass it to share an existing document, e.g. one obtained via ScintillaEdit.get_doc().

begin_undo_action(coalesceWithPrior=...)

Start a sequence of actions that is undone/redone as a single unit.

If coalesceWithPrior, merge it with the previous undo action when possible.

can_redo()

Return whether there is an action to redo.

can_undo()

Return whether there is an action to undo.

decoration_fill_range(position, value, fillLength)

Set fillLength bytes starting at position to value for the current indicator (see set_current_indicator).

decorations_end(indic, position)

Return the end of the run of indicator indic that includes position.

decorations_start(indic, position)

Return the start of the run of indicator indic that includes position.

decorations_value_at(indic, position)

Return the value of indicator indic at position.

delete_chars(pos, len)

Delete len characters starting at pos. Returns whether anything was deleted.

delete_undo_history()

Discard the undo history.

end_undo_action()

End a sequence of actions started by begin_undo_action.

ensure_styled_to(position)

Ensure the document is styled up to at least position, emitting style_needed as needed.

get_char_range(position, length)

Return length bytes of the document's text starting at position.

get_character(pos)

Return the character at pos.

get_code_page()

Return the code page used to interpret the document's bytes as characters.

get_end_styled()

Return the position up to which the document has been styled.

get_eol_mode()

Return the line ending type (Scintilla.EndOfLine value) used for new lines.

insert_string(position, str)

Insert str at position.

is_collecting_undo()

Return whether undo actions are being collected.

is_cr_lf(pos)

Return whether the line ending at pos is CR+LF, as opposed to a lone CR or LF.

is_read_only()

Return whether the document refuses modification.

is_save_point()

Return whether the document is at its save point (unmodified since set_save_point).

length()

Return the number of bytes in the document.

line_end(lineno)

Return the position of the end of line lineno, before any line ending characters.

line_end_position(pos)

Return the position of the end of the line containing pos, before any line ending characters.

line_from_position(pos)

Return the line containing position pos.

line_start(lineno)

Return the position of the start of line lineno.

lines_total()

Return the number of lines in the document.

move_position_outside_char(pos, move_dir, check_line_end)

Move pos outside of a multi-byte character towards move_dir.

If check_line_end, also move it outside of a line ending.

pointer()

Return the underlying native document pointer, for sharing with another ScintillaDocument.

redo()

Redo one action from the undo history. Returns the position of the start of the change.

set_code_page(code_page)

Set the code page used to interpret the document's bytes as characters.

set_current_indicator(indic)

Set the indicator used by subsequent decoration_fill_range calls.

set_eol_mode(eol_mode)

Set the line ending type (Scintilla.EndOfLine value) used for new lines.

set_read_only(read_only)

Set whether the document refuses modification.

set_save_point()

Mark the document's current state as unmodified (the save point).

set_style_for(length, style)

Set the next length bytes from the current styling position (see start_styling) to style.

Returns whether successful.

set_undo_collection(collect_undo)

Enable or disable collection of undo actions. Returns the previous setting.

start_styling(position)

Set the styling position to position; subsequent set_style_for calls style from there.

style_at(position)

Return the style byte at position.

undo()

Undo one action from the undo history. Returns the position of the start of the change.