class Gtk::TextMark

Overview

A Gtk::TextMark is a position in a Gtk::Textbuffer that is preserved across modifications.

You may wish to begin by reading the text widget conceptual overview, which gives an overview of all the objects and data types related to the text widget and how they work together.

A Gtk::TextMark is like a bookmark in a text buffer; it preserves a position in the text. You can convert the mark to an iterator using Gtk::TextBuffer#iter_at_mark. Unlike iterators, marks remain valid across buffer mutations, because their behavior is defined when text is inserted or deleted. When text containing a mark is deleted, the mark remains in the position originally occupied by the deleted text. When text is inserted at a mark, a mark with “left gravity” will be moved to the beginning of the newly-inserted text, and a mark with “right gravity” will be moved to the end.

Note that “left” and “right” here refer to logical direction (left is the toward the start of the buffer); in some languages such as Hebrew the logically-leftmost text is not actually on the left when displayed.

Marks are reference counted, but the reference count only controls the validity of the memory; marks can be deleted from the buffer at any time with Gtk::TextBuffer#delete_mark. Once deleted from the buffer, a mark is essentially useless.

Marks optionally have names; these can be convenient to avoid passing the Gtk::TextMark object around.

Marks are typically created using the Gtk::TextBuffer#create_mark function.

Defined in:

lib/gi-crystal/src/auto/gtk-4.0/text_mark.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new(name : String | Nil, left_gravity : Bool) : self #

Creates a text mark.

Add it to a buffer using Gtk::TextBuffer#add_mark. If name is nil, the mark is anonymous; otherwise, the mark can be retrieved by name using Gtk::TextBuffer#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).


[View source]
def self.new #

Initialize a new TextMark.


[View source]
def self.new(*, left_gravity : Bool | Nil = nil, name : String | Nil = nil) #

[View source]

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def buffer : Gtk::TextBuffer | Nil #

Gets the buffer this mark is located inside.

Returns nil if the mark is deleted.


[View source]
def deleted : Bool #

Returns true if the mark has been removed from its buffer.

See Gtk::TextBuffer#add_mark for a way to add it to a buffer again.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def left_gravity : Bool #

Determines whether the mark has left gravity.


[View source]
def left_gravity=(value : Bool) : Bool #

[View source]
def left_gravity? : Bool #

[View source]
def name : String | Nil #

Returns the mark name.

Returns nil for anonymous marks.


[View source]
def name=(value : String) : String #

[View source]
def name=(value : Nil) : Nil #

Set #name property to nil.


[View source]
def name? : String | Nil #

Same as #name, but can return nil.


[View source]
def visible : Bool #

Returns true if the mark is visible.

A cursor is displayed for visible marks.


[View source]
def visible=(setting : Bool) : Nil #

[View source]