Main Page Widgets Namespaces Book

# Gtk::TextMark Class Reference
[TextView Classes]

Inheritance diagram for Gtk::TextMark:

[legend]

List of all members.

## Detailed Description

Typedefed as Gtk::TextBuffer::Mark.

A position in the buffer, preserved across buffer modifications.

A Mark is like a bookmark in a text buffer; it preserves a position in the text. 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. The standard text cursor in left-to-right languages is a mark with right gravity, because it stays to the right of inserted text.

Like tags, marks can be either named or anonymous. There are two marks built-in to Gtk::TextBuffer; these are named "insert" and "selection_bound" and refer to the insertion point and the boundary of the selection which is not the insertion point, respectively. If no text is selected, these two marks will be in the same position. You can manipulate what is selected and where the cursor appears by moving these marks around.

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

You can convert the mark to an iterator using Gtk::TextBuffer::get_iter_at_mark().

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::TextBuffer::Mark object around.

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

## Public Member Functions

Glib::RefPtr<const TextBuffer> | get_buffer () const
| Gets the buffer this mark is located inside, or `0` if the mark is deleted.
Glib::RefPtr<TextBuffer> | get_buffer ()
| Gets the buffer this mark is located inside, or `0` if the mark is deleted.
bool | get_deleted () const
| Return value: whether the mark is deleted.
TextIter | get_iter ()
bool | get_left_gravity () const
| Determines whether the mark has left gravity.
Glib::ustring | get_name () const
| Return value: mark name.
bool | get_visible () const
| Return value: `true` if visible.
const GtkTextMark* | gobj () const
| Provides access to the underlying C GObject.
GtkTextMark* | gobj ()
| Provides access to the underlying C GObject.
GtkTextMark* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | set_visible (bool setting=true)
| Sets the visibility of mark; the insertion point is normally visible, i.e. you can see it as a vertical bar.
virtual | ~TextMark ()

## Static Public Member Functions

static Glib::RefPtr<TextMark> | create (const Glib::ustring& name, bool left_gravity=true)
| Creates a text mark.
static Glib::RefPtr<TextMark> | create (bool left_gravity=true)
| Creates an anoymous text mark.

## Protected Member Functions

| TextMark (const Glib::ustring& name, bool left_gravity=true)
| Creates a text mark.
| TextMark (bool left_gravity=true)
| Creates an anoymous text mark.

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr<Gtk::TextMark> | wrap (GtkTextMark* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Constructor & Destructor Documentation

virtual Gtk::TextMark::~TextMark | ( |  | ) | `[virtual]`

Gtk::TextMark::TextMark | ( | bool | left_gravity = `true` | ) | `[explicit, protected]`

Creates an anoymous text mark.

Add it to a buffer using Gtk::TextBuffer::add_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).

Parameters:

  | name | mark name.
  | left_gravity | Whether the mark should have left gravity.

Since gtkmm 2.12:

Gtk::TextMark::TextMark | ( | const Glib::ustring & | name,
|  | bool | left_gravity = `true` |
| ) |  |  | `[explicit, protected]`

Creates a text mark.

Add it to a buffer using Gtk::TextBuffer::add_mark(). The mark can be retrieved by name using Gtk::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).

Parameters:

  | name | mark name.
  | left_gravity | Whether the mark should have left gravity.

Since gtkmm 2.12:

## Member Function Documentation

static Glib::RefPtr<TextMark> Gtk::TextMark::create | ( | const Glib::ustring & | name,
|  | bool | left_gravity = `true` |
| ) |  |  | `[static]`

Creates a text mark.

Add it to a buffer using Gtk::TextBuffer::add_mark(). The mark can be retrieved by name using Gtk::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).

Parameters:

  | name | mark name.
  | left_gravity | Whether the mark should have left gravity.

Returns:
  A RefPtr to a new text mark.

Since gtkmm 2.12:

static Glib::RefPtr<TextMark> Gtk::TextMark::create | ( | bool | left_gravity = `true` | ) | `[static]`

Creates an anoymous text mark.

Add it to a buffer using Gtk::TextBuffer::add_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).

Parameters:

  | name | mark name.
  | left_gravity | Whether the mark should have left gravity.

Returns:
  A RefPtr to a new text mark.

Since gtkmm 2.12:

Glib::RefPtr<const TextBuffer> Gtk::TextMark::get_buffer | ( |  | ) | const

Gets the buffer this mark is located inside, or `0` if the mark is deleted.

Returns:
  The mark's Gtk::TextBuffer.

Glib::RefPtr<TextBuffer> Gtk::TextMark::get_buffer | ( |  | ) |

Gets the buffer this mark is located inside, or `0` if the mark is deleted.

Returns:
  The mark's Gtk::TextBuffer.

bool Gtk::TextMark::get_deleted | ( |  | ) | const

Return value: whether the mark is deleted.

Returns:
  Whether the mark is deleted.

TextIter Gtk::TextMark::get_iter | ( |  | ) |

bool Gtk::TextMark::get_left_gravity | ( |  | ) | const

Determines whether the mark has left gravity.

Returns:
  `true` if the mark has left gravity, `false` otherwise.

Glib::ustring Gtk::TextMark::get_name | ( |  | ) | const

Return value: mark name.

Returns:
  Mark name.

bool Gtk::TextMark::get_visible | ( |  | ) | const

Return value: `true` if visible.

Returns:
  `true` if visible.

const GtkTextMark* Gtk::TextMark::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GtkTextMark* Gtk::TextMark::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GtkTextMark* Gtk::TextMark::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Gtk::TextMark::set_visible | ( | bool | setting = `true` | ) |

Sets the visibility of mark; the insertion point is normally visible, i.e. you can see it as a vertical bar.

Also, the text widget uses a visible mark to indicate where a drop will occur when dragging-and-dropping text. Most other marks are not visible. Marks are not visible by default.

Parameters:

  | setting | Visibility of mark.

## Friends And Related Function Documentation

Glib::RefPtr<Gtk::TextMark> wrap | ( | GtkTextMark * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- textmark.h