Gjsify LogoGjsify Logo

Subclass of [classGtk.TextBuffer].

A GtkSourceBuffer object is the model for [classView] widgets. It extends the [classGtk.TextBuffer] class by adding features useful to display and edit source code such as syntax highlighting and bracket matching.

To create a GtkSourceBuffer use [ctorGtkSource.Buffer.new] or [ctorGtkSource.Buffer.new_with_language]. The second form is just a convenience function which allows you to initially set a [classLanguage]. You can also directly create a [classView] and get its [classBuffer] with [methodGtk.TextView.get_buffer].

The highlighting is enabled by default, but you can disable it with [methodBuffer.set_highlight_syntax].

Context Classes:

It is possible to retrieve some information from the syntax highlighting engine. The default context classes that are applied to regions of a GtkSourceBuffer:

  • comment: the region delimits a comment;
  • no-spell-check: the region should not be spell checked;
  • path: the region delimits a path to a file;
  • string: the region delimits a string.

Custom language definition files can create their own context classes, since the functions like [methodBuffer.iter_has_context_class] take a string parameter as the context class.

GtkSourceBuffer provides an API to access the context classes: [methodBuffer.iter_has_context_class], [methodBuffer.get_context_classes_at_iter], [methodBuffer.iter_forward_to_context_class_toggle] and [methodBuffer.iter_backward_to_context_class_toggle].

And the [signalGtkSource.Buffer::highlight-updated] signal permits to be notified when a context class region changes.

Each context class has also an associated [classGtk.TextTag] with the name gtksourceview:context-classes:<name>. For example to retrieve the [classGtk.TextTag] for the string context class, one can write:

GtkTextTagTable *tag_table;
GtkTextTag *tag;

tag_table = gtk_text_buffer_get_tag_table (buffer);
tag = gtk_text_tag_table_lookup (tag_table, "gtksourceview:context-classes:string");

The tag must be used for read-only purposes.

Accessing a context class via the associated [classGtk.TextTag] is less convenient than the GtkSourceBuffer API, because:

  • The tag doesn't always exist, you need to listen to the [signalGtk.TextTagTable::tag-added] and [signalGtk.TextTagTable::tag-removed] signals.
  • Instead of the [signalGtkSource.Buffer::highlight-updated] signal, you can listen to the [signalGtk.TextBuffer::apply-tag] and [signalGtk.TextBuffer::remove-tag] signals.

A possible use-case for accessing a context class via the associated [classGtk.TextTag] is to read the region but without adding a hard dependency on the GtkSourceView library (for example for a spell-checking library that wants to read the no-spell-check region).

Hierarchy

Index

Constructors

Properties

Methods

Constructors

Properties

canRedo: boolean

Denotes that the buffer can reapply the last undone action.

canUndo: boolean

Denotes that the buffer can undo the last applied action.

cursorPosition: number

The position of the insert mark.

This is an offset from the beginning of the buffer. It is useful for getting notified when the cursor moves.

enableUndo: boolean

Denotes if support for undoing and redoing changes to the buffer is allowed.

gTypeInstance: TypeInstance
hasSelection: boolean

Whether the buffer has some text currently selected.

highlightMatchingBrackets: boolean

Whether to highlight matching brackets in the buffer.

highlightSyntax: boolean

Whether to highlight syntax in the buffer.

implicitTrailingNewline: boolean

Whether the buffer has an implicit trailing newline. See [methodBuffer.set_implicit_trailing_newline].

parentInstance: Gtk.TextBuffer
styleScheme: GtkSource.StyleScheme

Style scheme. It contains styles for syntax highlighting, optionally foreground, background, cursor color, current line color, and matching brackets style.

tagTable: Gtk.TextTagTable

The GtkTextTagTable for the buffer.

text: string

The text content of the buffer.

Without child widgets and images, see [methodGtk.TextBuffer.get_text] for more information.

name: string

Methods

  • Adds the mark at position where.

    The mark must not be added to another buffer, and if its name is not %NULL then there must not be another mark in the buffer with the same name.

    Emits the [signalGtk.TextBuffer::mark-set] signal as notification of the mark's initial placement.

    Parameters

    Returns void

  • Adds clipboard to the list of clipboards in which the selection contents of buffer are available.

    In most cases, clipboard will be the GdkClipboard returned by [methodGtk.Widget.get_primary_clipboard] for a view of buffer.

    Parameters

    Returns void

  • Emits the “apply-tag” signal on buffer.

    The default handler for the signal applies tag to the given range. start and end do not have to be in order.

    Parameters

    Returns void

  • Emits the “apply-tag” signal on buffer.

    Calls [methodGtk.TextTagTable.lookup] on the buffer’s tag table to get a GtkTextTag, then calls [methodGtk.TextBuffer.apply_tag].

    Parameters

    • name: string

      name of a named GtkTextTag

    • start: Gtk.TextIter

      one bound of range to be tagged

    • end: Gtk.TextIter

      other bound of range to be tagged

    Returns void

  • backspace(iter: Gtk.TextIter, interactive: boolean, defaultEditable: boolean): boolean
  • Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by iter.

    In the normal case a single character will be deleted, but when combining accents are involved, more than one character can be deleted, and when precomposed character and accent combinations are involved, less than one character will be deleted.

    Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, the iter will be re-initialized to point to the location where text was deleted.

    Parameters

    • iter: Gtk.TextIter

      a position in buffer

    • interactive: boolean

      whether the deletion is caused by user interaction

    • defaultEditable: boolean

      whether the buffer is editable by default

    Returns boolean

  • Moves iter to the position of the previous [classMark] of the given category.

    Returns %TRUE if iter was moved. If category is NULL, the previous source mark can be of any category.

    Parameters

    • iter: Gtk.TextIter

      an iterator.

    • category: string

      category to search for, or %NULL

    Returns [boolean, Gtk.TextIter]

  • beginIrreversibleAction(): void
  • Denotes the beginning of an action that may not be undone.

    This will cause any previous operations in the undo/redo queue to be cleared.

    This should be paired with a call to [methodGtk.TextBuffer.end_irreversible_action] after the irreversible action has completed.

    You may nest calls to gtk_text_buffer_begin_irreversible_action() and gtk_text_buffer_end_irreversible_action() pairs.

    Returns void

  • beginUserAction(): void
  • Called to indicate that the buffer operations between here and a call to gtk_text_buffer_end_user_action() are part of a single user-visible operation.

    The operations between gtk_text_buffer_begin_user_action() and gtk_text_buffer_end_user_action() can then be grouped when creating an undo stack. GtkTextBuffer maintains a count of calls to gtk_text_buffer_begin_user_action() that have not been closed with a call to gtk_text_buffer_end_user_action(), and emits the “begin-user-action” and “end-user-action” signals only for the outermost pair of calls. This allows you to build user actions from other user actions.

    The “interactive” buffer mutation functions, such as [methodGtk.TextBuffer.insert_interactive], automatically call begin/end user action around the buffer operations they perform, so there's no need to add extra calls if you user action consists solely of a single call to one of those functions.

    Returns void

  • Creates a binding between source_property on source and target_property on target.

    Whenever the source_property is changed the target_property is updated using the same value. For instance:

      g_object_bind_property (action, "active", widget, "sensitive", 0);
    

    Will result in the "sensitive" property of the widget #GObject instance to be updated with the same value of the "active" property of the action #GObject instance.

    If flags contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well.

    The binding will automatically be removed when either the source or the target instances are finalized. To remove the binding without affecting the source and the target you can just call g_object_unref() on the returned #GBinding instance.

    Removing the binding by calling g_object_unref() on it must only be done if the binding, source and target are only used from a single thread and it is clear that both source and target outlive the binding. Especially it is not safe to rely on this if the binding, source or target can be finalized from different threads. Keep another reference to the binding and use g_binding_unbind() instead to be on the safe side.

    A #GObject can have multiple bindings.

    Parameters

    • sourceProperty: string

      the property on source to bind

    • target: GObject.Object

      the target #GObject

    • targetProperty: string

      the property on target to bind

    • flags: BindingFlags

      flags to pass to #GBinding

    Returns Binding

  • Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    This function is the language bindings friendly version of g_object_bind_property_full(), using #GClosures instead of function pointers.

    Parameters

    • sourceProperty: string

      the property on source to bind

    • target: GObject.Object

      the target #GObject

    • targetProperty: string

      the property on target to bind

    • flags: BindingFlags

      flags to pass to #GBinding

    • transformTo: TClosure<any, any>

      a #GClosure wrapping the transformation function from the source to the target, or %NULL to use the default

    • transformFrom: TClosure<any, any>

      a #GClosure wrapping the transformation function from the target to the source, or %NULL to use the default

    Returns Binding

  • Changes the case of the text between the specified iterators.

    Since 5.4, this function will update the position of start and end to surround the modified text.

    Parameters

    Returns void

  • connect(sigName: "bracket-matched", callback: GtkSource.Buffer_BracketMatchedSignalCallback): number
  • connect(sigName: "cursor-moved", callback: GtkSource.Buffer_CursorMovedSignalCallback): number
  • connect(sigName: "highlight-updated", callback: GtkSource.Buffer_HighlightUpdatedSignalCallback): number
  • connect(sigName: "source-mark-updated", callback: GtkSource.Buffer_SourceMarkUpdatedSignalCallback): number
  • connect(sigName: "notify::highlight-matching-brackets", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::highlight-syntax", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::implicit-trailing-newline", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::language", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::style-scheme", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::can-redo", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::can-undo", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::cursor-position", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::enable-undo", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::has-selection", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::tag-table", callback: ((...args: any[]) => void)): number
  • connect(sigName: "notify::text", callback: ((...args: any[]) => void)): number
  • connect(sigName: string, callback: ((...args: any[]) => void)): number
  • Creates and inserts a child anchor.

    This is a convenience function which simply creates a child anchor with [ctorGtk.TextChildAnchor.new] and inserts it into the buffer with [methodGtk.TextBuffer.insert_child_anchor].

    The new anchor is owned by the buffer; no reference count is returned to the caller of this function.

    Parameters

    Returns Gtk.TextChildAnchor

  • Creates a mark at position where.

    If mark_name is %NULL, the mark is anonymous; otherwise, the mark can be retrieved by name using [methodGtk.TextBuffer.get_mark]. If a mark has left gravity, and text is inserted at the mark’s current location, the mark will be moved to the left of the newly-inserted text. If the mark has right gravity (left_gravity = %FALSE), the mark will end up on the right of newly-inserted text. The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you’re typing).

    The caller of this function does not own a reference to the returned GtkTextMark, so you can ignore the return value if you like. Marks are owned by the buffer and go away when the buffer does.

    Emits the [signalGtk.TextBuffer::mark-set] signal as notification of the mark's initial placement.

    Parameters

    • markName: string

      name for mark

    • where: Gtk.TextIter

      location to place mark

    • leftGravity: boolean

      whether the mark has left gravity

    Returns Gtk.TextMark

  • Creates a source mark in the buffer of category category.

    A source mark is a [classGtk.TextMark] but organized into categories. Depending on the category a pixbuf can be specified that will be displayed along the line of the mark.

    Like a [classGtk.TextMark], a [classMark] can be anonymous if the passed name is %NULL. Also, the buffer owns the marks so you shouldn't unreference it.

    Marks always have left gravity and are moved to the beginning of the line when the user deletes the line they were in.

    Typical uses for a source mark are bookmarks, breakpoints, current executing instruction indication in a source file, etc..

    Parameters

    • name: string

      the name of the mark, or %NULL.

    • category: string

      a string defining the mark category.

    • where: Gtk.TextIter

      location to place the mark.

    Returns GtkSource.Mark

  • cutClipboard(clipboard: Gdk.Clipboard, defaultEditable: boolean): void
  • Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.

    Parameters

    • clipboard: Gdk.Clipboard

      the GdkClipboard object to cut to

    • defaultEditable: boolean

      default editability of the buffer

    Returns void

  • Deletes text between start and end.

    The order of start and end is not actually relevant; gtk_text_buffer_delete() will reorder them.

    This function actually emits the “delete-range” signal, and the default handler of that signal deletes the text. Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, the start and end will be re-initialized to point to the location where text was deleted.

    Parameters

    Returns void

  • Deletes all editable text in the given range.

    Calls [methodGtk.TextBuffer.delete] for each editable sub-range of [start,``end). start and end are revalidated to point to the location of the last deleted range, or left untouched if no text was deleted.

    Parameters

    • startIter: Gtk.TextIter

      start of range to delete

    • endIter: Gtk.TextIter

      end of range

    • defaultEditable: boolean

      whether the buffer is editable by default

    Returns boolean

  • Deletes mark, so that it’s no longer located anywhere in the buffer.

    Removes the reference the buffer holds to the mark, so if you haven’t called g_object_ref() on the mark, it will be freed. Even if the mark isn’t freed, most operations on mark become invalid, until it gets added to a buffer again with [methodGtk.TextBuffer.add_mark]. Use [methodGtk.TextMark.get_deleted] to find out if a mark has been removed from its buffer.

    The [signalGtk.TextBuffer::mark-deleted] signal will be emitted as notification after the mark is deleted.

    Parameters

    Returns void

  • deleteMarkByName(name: string): void
  • Deletes the mark named name; the mark must exist.

    See [methodGtk.TextBuffer.delete_mark] for details.

    Parameters

    • name: string

      name of a mark in buffer

    Returns void

  • deleteSelection(interactive: boolean, defaultEditable: boolean): boolean
  • Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text.

    If interactive is %TRUE, the editability of the selection will be considered (users can’t delete uneditable text).

    Parameters

    • interactive: boolean

      whether the deletion is caused by user interaction

    • defaultEditable: boolean

      whether the buffer is editable by default

    Returns boolean

  • emit(sigName: "bracket-matched", state: GtkSource.BracketMatchType, ...args: any[]): void
  • emit(sigName: "cursor-moved", ...args: any[]): void
  • emit(sigName: "highlight-updated", end: Gtk.TextIter, ...args: any[]): void
  • emit(sigName: "source-mark-updated", ...args: any[]): void
  • emit(sigName: "notify::highlight-matching-brackets", ...args: any[]): void
  • emit(sigName: "notify::highlight-syntax", ...args: any[]): void
  • emit(sigName: "notify::implicit-trailing-newline", ...args: any[]): void
  • emit(sigName: "notify::language", ...args: any[]): void
  • emit(sigName: "notify::style-scheme", ...args: any[]): void
  • emit(sigName: "notify::can-redo", ...args: any[]): void
  • emit(sigName: "notify::can-undo", ...args: any[]): void
  • emit(sigName: "notify::cursor-position", ...args: any[]): void
  • emit(sigName: "notify::enable-undo", ...args: any[]): void
  • emit(sigName: "notify::has-selection", ...args: any[]): void
  • emit(sigName: "notify::tag-table", ...args: any[]): void
  • emit(sigName: "notify::text", ...args: any[]): void
  • emit(sigName: string, ...args: any[]): void
  • endIrreversibleAction(): void
  • Denotes the end of an action that may not be undone.

    This will cause any previous operations in the undo/redo queue to be cleared.

    This should be called after completing modifications to the text buffer after [methodGtk.TextBuffer.begin_irreversible_action] was called.

    You may nest calls to gtk_text_buffer_begin_irreversible_action() and gtk_text_buffer_end_irreversible_action() pairs.

    Returns void

  • endUserAction(): void
  • Ends a user-visible operation.

    Should be paired with a call to [methodGtk.TextBuffer.begin_user_action]. See that function for a full explanation.

    Returns void

  • Forces buffer to analyze and highlight the given area synchronously.

    Note:

    This is a potentially slow operation and should be used only when you need to make sure that some text not currently visible is highlighted, for instance before printing.

    Parameters

    Returns void

  • forceFloating(): void
  • This function is intended for #GObject implementations to re-enforce a [floating][floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling g_object_ref_sink().

    Returns void

  • Moves iter to the position of the next [classMark] of the given category.

    Returns %TRUE if iter was moved. If category is NULL, the next source mark can be of any category.

    Parameters

    • iter: Gtk.TextIter

      an iterator.

    • category: string

      category to search for, or %NULL

    Returns [boolean, Gtk.TextIter]

  • freezeNotify(): void
  • Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.

    This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.

    Returns void

  • getCanRedo(): boolean
  • getCanUndo(): boolean
  • getCharCount(): number
  • Gets the number of characters in the buffer.

    Note that characters and bytes are not the same, you can’t e.g. expect the contents of the buffer in string form to be this many bytes long.

    The character count is cached, so this function is very fast.

    Returns number

  • Get all defined context classes at iter.

    See the [classBuffer] description for the list of default context classes.

    Parameters

    Returns string[]

  • getData(key?: string): object
  • Gets a named field from the objects table of associations (see g_object_set_data()).

    Parameters

    • Optional key: string

      name of the key for that association

    Returns object

  • getEnableUndo(): boolean
  • Gets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.

    See [methodGtk.TextBuffer.begin_irreversible_action] and [methodGtk.TextBuffer.end_irreversible_action] to create changes to the buffer that cannot be undone.

    Returns boolean

  • Initializes iter with the “end iterator,” one past the last valid character in the text buffer.

    If dereferenced with [methodGtk.TextIter.get_char], the end iterator has a character value of 0. The entire buffer lies in the range from the first position in the buffer (call [methodGtk.TextBuffer.get_start_iter] to get character position 0) to the end iterator.

    Returns Gtk.TextIter

  • getHasSelection(): boolean
  • getHighlightMatchingBrackets(): boolean
  • Determines whether bracket match highlighting is activated for the source buffer.

    Returns boolean

  • getHighlightSyntax(): boolean
  • Determines whether syntax highlighting is activated in the source buffer.

    Returns boolean

  • getImplicitTrailingNewline(): boolean
  • Returns the mark that represents the cursor (insertion point).

    Equivalent to calling [methodGtk.TextBuffer.get_mark] to get the mark named “insert”, but very slightly more efficient, and involves less typing.

    Returns Gtk.TextMark

  • getIterAtLine(lineNumber: number): [boolean, Gtk.TextIter]
  • Initializes iter to the start of the given line.

    If line_number is greater than or equal to the number of lines in the buffer, the end iterator is returned.

    Parameters

    • lineNumber: number

      line number counting from 0

    Returns [boolean, Gtk.TextIter]

  • getIterAtLineIndex(lineNumber: number, byteIndex: number): [boolean, Gtk.TextIter]
  • Obtains an iterator pointing to byte_index within the given line.

    byte_index must be the start of a UTF-8 character. Note bytes, not characters; UTF-8 may encode one character as multiple bytes.

    If line_number is greater than or equal to the number of lines in the buffer, the end iterator is returned. And if byte_index is off the end of the line, the iterator at the end of the line is returned.

    Parameters

    • lineNumber: number

      line number counting from 0

    • byteIndex: number

      byte index from start of line

    Returns [boolean, Gtk.TextIter]

  • getIterAtLineOffset(lineNumber: number, charOffset: number): [boolean, Gtk.TextIter]
  • Obtains an iterator pointing to char_offset within the given line.

    Note characters, not bytes; UTF-8 may encode one character as multiple bytes.

    If line_number is greater than or equal to the number of lines in the buffer, the end iterator is returned. And if char_offset is off the end of the line, the iterator at the end of the line is returned.

    Parameters

    • lineNumber: number

      line number counting from 0

    • charOffset: number

      char offset from start of line

    Returns [boolean, Gtk.TextIter]

  • Initializes iter to a position char_offset chars from the start of the entire buffer.

    If char_offset is -1 or greater than the number of characters in the buffer, iter is initialized to the end iterator, the iterator one past the last valid character in the buffer.

    Parameters

    • charOffset: number

      char offset from start of buffer, counting from 0, or -1

    Returns Gtk.TextIter

  • Returns the [classLanguage] associated with the buffer, see [methodBuffer.set_language].

    The returned object should not be unreferenced by the user.

    Returns GtkSource.Language

  • getLineCount(): number
  • getMaxUndoLevels(): number
  • Gets the maximum number of undo levels to perform.

    If 0, unlimited undo actions may be performed. Note that this may have a memory usage impact as it requires storing an additional copy of the inserted or removed text within the text buffer.

    Returns number

  • getModified(): boolean
  • Indicates whether the buffer has been modified since the last call to [methodGtk.TextBuffer.set_modified] set the modification flag to %FALSE.

    Used for example to enable a “save” function in a text editor.

    Returns boolean

  • getProperty(propertyName?: string, value?: any): void
  • Gets a property of an object.

    The value can be:

    • an empty #GValue initialized by %G_VALUE_INIT, which will be automatically initialized with the expected type of the property (since GLib 2.60)
    • a #GValue initialized with the expected type of the property
    • a #GValue initialized with a type to which the expected type of the property can be transformed

    In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling g_value_unset().

    Note that g_object_get_property() is really intended for language bindings, g_object_get() is much more convenient for C programming.

    Parameters

    • Optional propertyName: string

      the name of the property to get

    • Optional value: any

      return location for the property value

    Returns void

  • getQdata(quark: number): object
  • This function gets back user data pointers stored via g_object_set_qdata().

    Parameters

    • quark: number

      A #GQuark, naming the user data pointer

    Returns object

  • Returns the mark that represents the selection bound.

    Equivalent to calling [methodGtk.TextBuffer.get_mark] to get the mark named “selection_bound”, but very slightly more efficient, and involves less typing.

    The currently-selected text in buffer is the region between the “selection_bound” and “insert” marks. If “selection_bound” and “insert” are in the same place, then there is no current selection. [methodGtk.TextBuffer.get_selection_bounds] is another convenient function for handling the selection, if you just want to know whether there’s a selection and what its bounds are.

    Returns Gtk.TextMark

  • Returns %TRUE if some text is selected; places the bounds of the selection in start and end.

    If the selection has length 0, then start and end are filled in with the same value. start and end will be in ascending order. If start and end are %NULL, then they are not filled in, but the return value still indicates whether text is selected.

    Returns [boolean, Gtk.TextIter, Gtk.TextIter]

  • Returns the text in the range [start,``end).

    Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is %FALSE. The returned string includes a 0xFFFC character whenever the buffer contains embedded images, so byte and character indexes into the returned string do correspond to byte and character indexes into the buffer. Contrast with [methodGtk.TextBuffer.get_text]. Note that 0xFFFC can occur in normal text as well, so it is not a reliable indicator that a paintable or widget is in the buffer.

    Parameters

    • start: Gtk.TextIter

      start of a range

    • end: Gtk.TextIter

      end of a range

    • includeHiddenChars: boolean

      whether to include invisible text

    Returns string

  • Returns the list of marks of the given category at iter.

    If category is %NULL it returns all marks at iter.

    Parameters

    • iter: Gtk.TextIter

      an iterator.

    • category: string

      category to search for, or %NULL

    Returns GtkSource.Mark[]

  • getSourceMarksAtLine(line: number, category: string): GtkSource.Mark[]
  • Returns the list of marks of the given category at line.

    If category is %NULL, all marks at line are returned.

    Parameters

    • line: number

      a line number.

    • category: string

      category to search for, or %NULL

    Returns GtkSource.Mark[]

  • Initialized iter with the first position in the text buffer.

    This is the same as using [methodGtk.TextBuffer.get_iter_at_offset] to get the iter at character offset 0.

    Returns Gtk.TextIter

  • Returns the [classStyleScheme] associated with the buffer, see [methodBuffer.set_style_scheme].

    The returned object should not be unreferenced by the user.

    Returns GtkSource.StyleScheme

  • Returns the text in the range [start,``end).

    Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is %FALSE. Does not include characters representing embedded images, so byte and character indexes into the returned string do not correspond to byte and character indexes into the buffer. Contrast with [methodGtk.TextBuffer.get_slice].

    Parameters

    • start: Gtk.TextIter

      start of a range

    • end: Gtk.TextIter

      end of a range

    • includeHiddenChars: boolean

      whether to include invisible text

    Returns string

  • getv(names: string[], values: any[]): void
  • Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

    Parameters

    • names: string[]

      the names of each property to get

    • values: any[]

      the values of each property to get

    Returns void

  • insert(iter: Gtk.TextIter, text: string, len: number): void
  • Inserts len bytes of text at position iter.

    If len is -1, text must be nul-terminated and will be inserted in its entirety. Emits the “insert-text” signal; insertion actually occurs in the default handler for the signal. iter is invalidated when insertion occurs (because the buffer contents change), but the default signal handler revalidates it to point to the end of the inserted text.

    Parameters

    • iter: Gtk.TextIter

      a position in the buffer

    • text: string

      text in UTF-8 format

    • len: number

      length of text in bytes, or -1

    Returns void

  • insertAtCursor(text: string, len: number): void
  • Inserts text in buffer.

    Simply calls [methodGtk.TextBuffer.insert], using the current cursor position as the insertion point.

    Parameters

    • text: string

      text in UTF-8 format

    • len: number

      length of text, in bytes

    Returns void

  • Inserts a child widget anchor into the text buffer at iter.

    The anchor will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode “object replacement character” 0xFFFC. Note that the “slice” variants for obtaining portions of the buffer as a string include this character for child anchors, but the “text” variants do not. E.g. see [methodGtk.TextBuffer.get_slice] and [methodGtk.TextBuffer.get_text].

    Consider [methodGtk.TextBuffer.create_child_anchor] as a more convenient alternative to this function. The buffer will add a reference to the anchor, so you can unref it after insertion.

    Parameters

    Returns void

  • insertInteractive(iter: Gtk.TextIter, text: string, len: number, defaultEditable: boolean): boolean
  • Inserts text in buffer.

    Like [methodGtk.TextBuffer.insert], but the insertion will not occur if iter is at a non-editable location in the buffer. Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive).

    default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of [methodGtk.TextView.get_editable] is appropriate here.

    Parameters

    • iter: Gtk.TextIter

      a position in buffer

    • text: string

      some UTF-8 text

    • len: number

      length of text in bytes, or -1

    • defaultEditable: boolean

      default editability of buffer

    Returns boolean

  • insertInteractiveAtCursor(text: string, len: number, defaultEditable: boolean): boolean
  • Inserts text in buffer.

    Calls [methodGtk.TextBuffer.insert_interactive] at the cursor position.

    default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of [methodGtk.TextView.get_editable] is appropriate here.

    Parameters

    • text: string

      text in UTF-8 format

    • len: number

      length of text in bytes, or -1

    • defaultEditable: boolean

      default editability of buffer

    Returns boolean

  • insertMarkup(iter: Gtk.TextIter, markup: string, len: number): void
  • Inserts the text in markup at position iter.

    markup will be inserted in its entirety and must be nul-terminated and valid UTF-8. Emits the [signalGtk.TextBuffer::insert-text] signal, possibly multiple times; insertion actually occurs in the default handler for the signal. iter will point to the end of the inserted text on return.

    Parameters

    • iter: Gtk.TextIter

      location to insert the markup

    • markup: string

      a nul-terminated UTF-8 string containing Pango markup

    • len: number

      length of markup in bytes, or -1

    Returns void

  • Inserts an image into the text buffer at iter.

    The image will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode “object replacement character” 0xFFFC. Note that the “slice” variants for obtaining portions of the buffer as a string include this character for paintable, but the “text” variants do not. e.g. see [methodGtk.TextBuffer.get_slice] and [methodGtk.TextBuffer.get_text].

    Parameters

    Returns void

  • Copies text, tags, and paintables between start and end and inserts the copy at iter.

    The order of start and end doesn’t matter.

    Used instead of simply getting/inserting text because it preserves images and tags. If start and end are in a different buffer from buffer, the two buffers must share the same tag table.

    Implemented via emissions of the ::insert-text and ::apply-tag signals, so expect those.

    Parameters

    Returns void

  • Copies text, tags, and paintables between start and end and inserts the copy at iter.

    Same as [methodGtk.TextBuffer.insert_range], but does nothing if the insertion point isn’t editable. The default_editable parameter indicates whether the text is editable at iter if no tags enclosing iter affect editability. Typically the result of [methodGtk.TextView.get_editable] is appropriate here.

    Parameters

    • iter: Gtk.TextIter

      a position in buffer

    • start: Gtk.TextIter

      a position in a GtkTextBuffer

    • end: Gtk.TextIter

      another position in the same buffer as start

    • defaultEditable: boolean

      default editability of the buffer

    Returns boolean

  • isFloating(): boolean
  • Moves backward to the next toggle (on or off) of the context class.

    If no matching context class toggles are found, returns %FALSE, otherwise %TRUE. Does not return toggles located at iter, only toggles after iter. Sets iter to the location of the toggle, or to the end of the buffer if no toggle is found.

    See the [classBuffer] description for the list of default context classes.

    Parameters

    • iter: Gtk.TextIter

      a #GtkTextIter.

    • contextClass: string

      the context class.

    Returns [boolean, Gtk.TextIter]

  • Moves forward to the next toggle (on or off) of the context class.

    If no matching context class toggles are found, returns %FALSE, otherwise %TRUE. Does not return toggles located at iter, only toggles after iter. Sets iter to the location of the toggle, or to the end of the buffer if no toggle is found.

    See the [classBuffer] description for the list of default context classes.

    Parameters

    • iter: Gtk.TextIter

      a #GtkTextIter.

    • contextClass: string

      the context class.

    Returns [boolean, Gtk.TextIter]

  • iterHasContextClass(iter: Gtk.TextIter, contextClass: string): boolean
  • Check if the class context_class is set on iter.

    See the [classBuffer] description for the list of default context classes.

    Parameters

    • iter: Gtk.TextIter

      a #GtkTextIter.

    • contextClass: string

      class to search for.

    Returns boolean

  • moveMarkByName(name: string, where: Gtk.TextIter): void
  • Moves the mark named name (which must exist) to location where.

    See [methodGtk.TextBuffer.move_mark] for details.

    Parameters

    • name: string

      name of a mark

    • where: Gtk.TextIter

      new location for mark

    Returns void

  • notify(propertyName: string): void
  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    • propertyName: string

      the name of a property installed on the class of object.

    Returns void

  • Emits a "notify" signal for the property specified by pspec on object.

    This function omits the property name lookup, hence it is faster than g_object_notify().

    One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:

      enum
    {
    PROP_0,
    PROP_FOO,
    PROP_LAST
    };

    static GParamSpec *properties[PROP_LAST];

    static void
    my_object_class_init (MyObjectClass *klass)
    {
    properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
    0, 100,
    50,
    G_PARAM_READWRITE);
    g_object_class_install_property (gobject_class,
    PROP_FOO,
    properties[PROP_FOO]);
    }

    and then notify a change on the "foo" property with:

      g_object_notify_by_pspec (self, properties[PROP_FOO]);
    

    Parameters

    • pspec: ParamSpec

      the #GParamSpec of a property installed on the class of object.

    Returns void

  • off(sigName: "bracket-matched", callback: GtkSource.Buffer_BracketMatchedSignalCallback): EventEmitter
  • off(sigName: "cursor-moved", callback: GtkSource.Buffer_CursorMovedSignalCallback): EventEmitter
  • off(sigName: "highlight-updated", callback: GtkSource.Buffer_HighlightUpdatedSignalCallback): EventEmitter
  • off(sigName: "source-mark-updated", callback: GtkSource.Buffer_SourceMarkUpdatedSignalCallback): EventEmitter
  • off(sigName: "notify::highlight-matching-brackets", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::highlight-syntax", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::implicit-trailing-newline", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::language", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::style-scheme", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::can-redo", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::can-undo", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::cursor-position", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::enable-undo", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::has-selection", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::tag-table", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: "notify::text", callback: ((...args: any[]) => void)): EventEmitter
  • off(sigName: string, callback: ((...args: any[]) => void)): EventEmitter
  • on(sigName: "bracket-matched", callback: GtkSource.Buffer_BracketMatchedSignalCallback, after?: boolean): EventEmitter
  • on(sigName: "cursor-moved", callback: GtkSource.Buffer_CursorMovedSignalCallback, after?: boolean): EventEmitter
  • on(sigName: "highlight-updated", callback: GtkSource.Buffer_HighlightUpdatedSignalCallback, after?: boolean): EventEmitter
  • on(sigName: "source-mark-updated", callback: GtkSource.Buffer_SourceMarkUpdatedSignalCallback, after?: boolean): EventEmitter
  • on(sigName: "notify::highlight-matching-brackets", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::highlight-syntax", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::implicit-trailing-newline", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::language", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::style-scheme", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::can-redo", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::can-undo", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::cursor-position", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::enable-undo", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::has-selection", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::tag-table", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: "notify::text", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • on(sigName: string, callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • Parameters

    Returns EventEmitter

  • Parameters

    Returns EventEmitter

  • Parameters

    Returns EventEmitter

  • Parameters

    Returns EventEmitter

  • Parameters

    • sigName: "notify::highlight-matching-brackets"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::highlight-syntax"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::implicit-trailing-newline"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::language"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::style-scheme"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::can-redo"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::can-undo"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::cursor-position"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::enable-undo"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::has-selection"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::tag-table"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::text"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: string
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • once(sigName: "bracket-matched", callback: GtkSource.Buffer_BracketMatchedSignalCallback, after?: boolean): EventEmitter
  • once(sigName: "cursor-moved", callback: GtkSource.Buffer_CursorMovedSignalCallback, after?: boolean): EventEmitter
  • once(sigName: "highlight-updated", callback: GtkSource.Buffer_HighlightUpdatedSignalCallback, after?: boolean): EventEmitter
  • once(sigName: "source-mark-updated", callback: GtkSource.Buffer_SourceMarkUpdatedSignalCallback, after?: boolean): EventEmitter
  • once(sigName: "notify::highlight-matching-brackets", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::highlight-syntax", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::implicit-trailing-newline", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::language", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::style-scheme", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::can-redo", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::can-undo", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::cursor-position", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::enable-undo", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::has-selection", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::tag-table", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: "notify::text", callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • once(sigName: string, callback: ((...args: any[]) => void), after?: boolean): EventEmitter
  • Parameters

    Returns EventEmitter

  • Parameters

    Returns EventEmitter

  • Parameters

    Returns EventEmitter

  • Parameters

    Returns EventEmitter

  • Parameters

    • sigName: "notify::highlight-matching-brackets"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::highlight-syntax"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::implicit-trailing-newline"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::language"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::style-scheme"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::can-redo"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::can-undo"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::cursor-position"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::enable-undo"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::has-selection"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::tag-table"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: "notify::text"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Parameters

    • sigName: string
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional after: boolean

    Returns EventEmitter

  • Pastes the contents of a clipboard.

    If override_location is %NULL, the pasted text will be inserted at the cursor position, or the buffer selection will be replaced if the selection is non-empty.

    Note: pasting is asynchronous, that is, we’ll ask for the paste data and return, and at some point later after the main loop runs, the paste data will be inserted.

    Parameters

    • clipboard: Gdk.Clipboard

      the GdkClipboard to paste from

    • overrideLocation: Gtk.TextIter

      location to insert pasted text

    • defaultEditable: boolean

      whether the buffer is editable by default

    Returns void

  • This function moves the “insert” and “selection_bound” marks simultaneously.

    If you move them to the same place in two steps with [methodGtk.TextBuffer.move_mark], you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.

    Parameters

    Returns void

  • redo(): void
  • Increases the reference count of object.

    Since GLib 2.56, if GLIB_VERSION_MAX_ALLOWED is 2.56 or greater, the type of object will be propagated to the return type (using the GCC typeof() extension), so any casting the caller needs to do on the return type must be explicit.

    Returns GObject.Object

  • Increase the reference count of object, and possibly remove the [floating][floating-ref] reference, if object has a floating reference.

    In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.

    Since GLib 2.56, the type of object will be propagated to the return type under the same conditions as for g_object_ref().

    Returns GObject.Object

  • Removes all tags in the range between start and end.

    Be careful with this function; it could remove tags added in code unrelated to the code you’re currently writing. That is, using this function is probably a bad idea if you have two or more unrelated code sections that add tags.

    Parameters

    Returns void

  • Remove all marks of category between start and end from the buffer.

    If category is NULL, all marks in the range will be removed.

    Parameters

    • start: Gtk.TextIter

      a #GtkTextIter.

    • end: Gtk.TextIter

      a #GtkTextIter.

    • category: string

      category to search for, or %NULL.

    Returns void

  • Emits the “remove-tag” signal.

    The default handler for the signal removes all occurrences of tag from the given range. start and end don’t have to be in order.

    Parameters

    Returns void

  • Emits the “remove-tag” signal.

    Calls [methodGtk.TextTagTable.lookup] on the buffer’s tag table to get a GtkTextTag, then calls [methodGtk.TextBuffer.remove_tag].

    Parameters

    • name: string

      name of a GtkTextTag

    • start: Gtk.TextIter

      one bound of range to be untagged

    • end: Gtk.TextIter

      other bound of range to be untagged

    Returns void

  • runDispose(): void
  • Releases all references to other objects. This can be used to break reference cycles.

    This function should only be called from object system implementations.

    Returns void

  • This function moves the “insert” and “selection_bound” marks simultaneously.

    If you move them in two steps with [methodGtk.TextBuffer.move_mark], you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.

    Parameters

    • ins: Gtk.TextIter

      where to put the “insert” mark

    • bound: Gtk.TextIter

      where to put the “selection_bound” mark

    Returns void

  • setData(key: string, data?: object): void
  • Each object carries around a table of associations from strings to pointers. This function lets you set an association.

    If the object already had an association with that name, the old association will be destroyed.

    Internally, the key is converted to a #GQuark using g_quark_from_string(). This means a copy of key is kept permanently (even after object has been finalized) — so it is recommended to only use a small, bounded set of values for key in your program, to avoid the #GQuark storage growing unbounded.

    Parameters

    • key: string

      name of the key

    • Optional data: object

      data to associate with that key

    Returns void

  • setEnableUndo(enableUndo: boolean): void
  • Sets whether or not to enable undoable actions in the text buffer.

    Undoable actions in this context are changes to the text content of the buffer. Changes to tags and marks are not tracked.

    If enabled, the user will be able to undo the last number of actions up to [methodGtk.TextBuffer.get_max_undo_levels].

    See [methodGtk.TextBuffer.begin_irreversible_action] and [methodGtk.TextBuffer.end_irreversible_action] to create changes to the buffer that cannot be undone.

    Parameters

    • enableUndo: boolean

      %TRUE to enable undo

    Returns void

  • setHighlightMatchingBrackets(highlight: boolean): void
  • Controls the bracket match highlighting function in the buffer.

    If activated, when you position your cursor over a bracket character (a parenthesis, a square bracket, etc.) the matching opening or closing bracket character will be highlighted.

    Parameters

    • highlight: boolean

      %TRUE if you want matching brackets highlighted.

    Returns void

  • setHighlightSyntax(highlight: boolean): void
  • Controls whether syntax is highlighted in the buffer.

    If highlight is %TRUE, the text will be highlighted according to the syntax patterns specified in the [classLanguage] set with [methodBuffer.set_language].

    If highlight is %FALSE, syntax highlighting is disabled and all the [classGtk.TextTag] objects that have been added by the syntax highlighting engine are removed from the buffer.

    Parameters

    • highlight: boolean

      %TRUE to enable syntax highlighting, %FALSE to disable it.

    Returns void

  • setImplicitTrailingNewline(implicitTrailingNewline: boolean): void
  • Sets whether the buffer has an implicit trailing newline.

    If an explicit trailing newline is present in a [classGtk.TextBuffer], [classGtk.TextView] shows it as an empty line. This is generally not what the user expects.

    If implicit_trailing_newline is %TRUE (the default value):

    • when a [classFileLoader] loads the content of a file into the buffer, the trailing newline (if present in the file) is not inserted into the buffer.
    • when a [classFileSaver] saves the content of the buffer into a file, a trailing newline is added to the file.

    On the other hand, if implicit_trailing_newline is %FALSE, the file's content is not modified when loaded into the buffer, and the buffer's content is not modified when saved into a file.

    Parameters

    • implicitTrailingNewline: boolean

      the new value.

    Returns void

  • Associates a [classLanguage] with the buffer.

    Note that a [classLanguage] affects not only the syntax highlighting, but also the context classes. If you want to disable just the syntax highlighting, see [methodBuffer.set_highlight_syntax].

    The buffer holds a reference to language.

    Parameters

    Returns void

  • setMaxUndoLevels(maxUndoLevels: number): void
  • Sets the maximum number of undo levels to perform.

    If 0, unlimited undo actions may be performed. Note that this may have a memory usage impact as it requires storing an additional copy of the inserted or removed text within the text buffer.

    Parameters

    • maxUndoLevels: number

      the maximum number of undo actions to perform

    Returns void

  • setModified(setting: boolean): void
  • Used to keep track of whether the buffer has been modified since the last time it was saved.

    Whenever the buffer is saved to disk, call gtk_text_buffer_set_modified (buffer, FALSE). When the buffer is modified, it will automatically toggled on the modified bit again. When the modified bit flips, the buffer emits the [signalGtk.TextBuffer::modified-changed] signal.

    Parameters

    • setting: boolean

      modification flag setting

    Returns void

  • setProperty(propertyName: string, value?: any): void
  • Sets a [classStyleScheme] to be used by the buffer and the view.

    Note that a [classStyleScheme] affects not only the syntax highlighting, but also other [classView] features such as highlighting the current line, matching brackets, the line numbers, etc.

    Instead of setting a %NULL scheme, it is better to disable syntax highlighting with [methodBuffer.set_highlight_syntax], and setting the [classStyleScheme] with the "classic" or "tango" ID, because those two style schemes follow more closely the GTK theme (for example for the background color).

    The buffer holds a reference to scheme.

    Parameters

    Returns void

  • setText(text: string, len: number): void
  • Deletes current contents of buffer, and inserts text instead.

    If len is -1, text must be nul-terminated. text must be valid UTF-8.

    Parameters

    • text: string

      UTF-8 text to insert

    • len: number

      length of text in bytes

    Returns void

  • Sort the lines of text between the specified iterators.

    Parameters

    • start: Gtk.TextIter

      a #GtkTextIter.

    • end: Gtk.TextIter

      a #GtkTextIter.

    • flags: GtkSource.SortFlags

      #GtkSourceSortFlags specifying how the sort should behave

    • column: number

      sort considering the text starting at the given column

    Returns void

  • stealData(key?: string): object
  • Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

    Parameters

    • Optional key: string

      name of the key

    Returns object

  • stealQdata(quark: number): object
  • This function gets back user data pointers stored via g_object_set_qdata() and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

    void
    object_add_to_user_list (GObject *object,
    const gchar *new_string)
    {
    // the quark, naming the object data
    GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
    // retrieve the old string list
    GList *list = g_object_steal_qdata (object, quark_string_list);

    // prepend new string
    list = g_list_prepend (list, g_strdup (new_string));
    // this changed 'list', so we need to set it again
    g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
    }
    static void
    free_string_list (gpointer data)
    {
    GList *node, *list = data;

    for (node = list; node; node = node->next)
    g_free (node->data);
    g_list_free (list);
    }

    Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().

    Parameters

    • quark: number

      A #GQuark, naming the user data pointer

    Returns object

  • thawNotify(): void
  • Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

    Duplicate notifications for each property are squashed so that at most one #GObject::notify signal is emitted for each property, in the reverse order in which they have been queued.

    It is an error to call this function when the freeze count is zero.

    Returns void

  • undo(): void
  • unref(): void
  • Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

    If the pointer to the #GObject may be reused in future (for example, if it is an instance variable of another object), it is recommended to clear the pointer to %NULL rather than retain a dangling pointer to a potentially invalid #GObject instance. Use g_clear_object() for this.

    Returns void

  • watchClosure(closure: TClosure<any, any>): void
  • This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling g_closure_invalidate() on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, g_object_ref() and g_object_unref() are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

    Parameters

    • closure: TClosure<any, any>

      #GClosure to watch

    Returns void

  • compatControl(what: number, data: object): number
  • Find the #GParamSpec with the given name for an interface. Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().

    Parameters

    • gIface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface

    • propertyName: string

      name of a property to look up.

    Returns ParamSpec

  • Add a property to an interface; this is only useful for interfaces that are added to GObject-derived types. Adding a property to an interface forces all objects classes with that interface to have a compatible property. The compatible property could be a newly created #GParamSpec, but normally g_object_class_override_property() will be used so that the object class only needs to provide an implementation and inherits the property description, default value, bounds, and so forth from the interface property.

    This function is meant to be called from the interface's default vtable initialization function (the class_init member of #GTypeInfo.) It must not be called after after class_init has been called for any object types implementing this interface.

    If pspec is a floating reference, it will be consumed.

    Parameters

    • gIface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface.

    • pspec: ParamSpec

      the #GParamSpec for the new property

    Returns void

  • Lists the properties of an interface.Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().

    Parameters

    • gIface: TypeInterface

      any interface vtable for the interface, or the default vtable for the interface

    Returns ParamSpec[]

  • Creates a new source buffer using the highlighting patterns in language.

    This is equivalent to creating a new source buffer with a new tag table and then calling [methodBuffer.set_language].

    Parameters

    Returns GtkSource.Buffer

  • Creates a new instance of a #GObject subtype and sets its properties.

    Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY) which are not explicitly specified are set to their default values.

    Parameters

    • objectType: GType<unknown>

      the type id of the #GObject subtype to instantiate

    • parameters: GObject.Parameter[]

      an array of #GParameter

    Returns GObject.Object

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method