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

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)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, 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)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? 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, 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

compat_control(what : UInt64, data : Pointer(Void)?) : 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

Constructor Detail

def self.new(name : String?, 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).


def self.new #

Initialize a new TextMark.


def self.new(*, left_gravity : Bool? = nil, name : String? = nil) #

Class Method Detail

def self.g_type : UInt64 #

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


Instance Method Detail

def buffer : Gtk::TextBuffer? #

Gets the buffer this mark is located inside.

Returns nil if the mark is deleted.


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.


def left_gravity : Bool #

Determines whether the mark has left gravity.


def left_gravity=(value : Bool) : Bool #

def left_gravity? : Bool #

def name : String? #

Returns the mark name.

Returns nil for anonymous marks.


def name=(value : String) : String #

def visible : Bool #

Returns true if the mark is visible.

A cursor is displayed for visible marks.


def visible=(setting : Bool) : Nil #