| 1 |
/* Copyright (C) 1998-2002 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
_CONFIGINCLUDE(gtkmmconfig.h) |
| 18 |
|
| 19 |
#include <glibmm/object.h> |
| 20 |
|
| 21 |
_DEFS(gtkmm,gtk) |
| 22 |
_PINCLUDE(glibmm/private/object_p.h) |
| 23 |
|
| 24 |
namespace Gtk |
| 25 |
{ |
| 26 |
|
| 27 |
class GTKMM_API TextBuffer; |
| 28 |
class GTKMM_API TextIter; |
| 29 |
|
| 30 |
/** Typedefed as Gtk::TextBuffer::Mark. A position in the buffer, preserved across buffer modifications. |
| 31 |
* |
| 32 |
* 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 |
| 33 |
* their behavior is defined when text is inserted or deleted. When text containing a mark is deleted, the mark remains in |
| 34 |
* the position originally occupied by the deleted text. When text is inserted at a mark, a mark with left gravity will be |
| 35 |
* moved to the beginning of the newly-inserted text, and a mark with right gravity will be moved to the end. |
| 36 |
* The standard text cursor in left-to-right languages is a mark with right gravity, because it stays to the right of inserted |
| 37 |
* text. |
| 38 |
* |
| 39 |
* Like tags, marks can be either named or anonymous. There are two marks built-in to Gtk::TextBuffer; these are named "insert" and |
| 40 |
* "selection_bound" and refer to the insertion point and the boundary of the selection which is not the insertion point, |
| 41 |
* respectively. If no text is selected, these two marks will be in the same position. You can manipulate what is selected and |
| 42 |
* where the cursor appears by moving these marks around. |
| 43 |
* |
| 44 |
* "left" and "right" here refer to logical direction (left is the toward the start of the buffer); in some languages such as |
| 45 |
* Hebrew the logically-leftmost text is not actually on the left when displayed. |
| 46 |
* |
| 47 |
* You can convert the mark to an @link Gtk::TextIter iterator@endlink using Gtk::TextBuffer::get_iter_at_mark(). |
| 48 |
* |
| 49 |
* 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. |
| 50 |
* |
| 51 |
* Marks optionally have names; these can be convenient to avoid passing the Gtk::TextBuffer::Mark object around. |
| 52 |
* |
| 53 |
* Marks are typically created using the Gtk::TextBuffer::create_mark() function. |
| 54 |
* |
| 55 |
* @ingroup TextView |
| 56 |
*/ |
| 57 |
class GTKMM_API TextMark : public Glib::Object |
| 58 |
{ |
| 59 |
_CLASS_GOBJECT(TextMark, GtkTextMark, GTK_TEXT_MARK, Glib::Object, GObject, , , GTKMM_API) |
| 60 |
protected: |
| 61 |
|
| 62 |
/** Creates an anoymous text mark. Add it to a buffer using Gtk::TextBuffer::add_mark(). |
| 63 |
* If a mark has left |
| 64 |
* gravity, and text is inserted at the mark's current location, the mark |
| 65 |
* will be moved to the left of the newly-inserted text. If the mark has |
| 66 |
* right gravity (@a left_gravity = false), the mark will end up on the |
| 67 |
* right of newly-inserted text. The standard left-to-right cursor is a |
| 68 |
* mark with right gravity (when you type, the cursor stays on the right |
| 69 |
* side of the text you're typing). |
| 70 |
* |
| 71 |
* @param left_gravity Whether the mark should have left gravity. |
| 72 |
* @newin{2,12} |
| 73 |
*/ |
| 74 |
explicit TextMark(bool left_gravity = true); |
| 75 |
|
| 76 |
/** Creates a text mark. Add it to a buffer using Gtk::TextBuffer::add_mark(). |
| 77 |
* The mark can be retrieved by name using Gtk::TextBuffer::get_mark(). If a mark has left |
| 78 |
* gravity, and text is inserted at the mark's current location, the mark |
| 79 |
* will be moved to the left of the newly-inserted text. If the mark has |
| 80 |
* right gravity (@a left_gravity = false), the mark will end up on the |
| 81 |
* right of newly-inserted text. The standard left-to-right cursor is a |
| 82 |
* mark with right gravity (when you type, the cursor stays on the right |
| 83 |
* side of the text you're typing). |
| 84 |
* |
| 85 |
* @param name mark name. |
| 86 |
* @param left_gravity Whether the mark should have left gravity. |
| 87 |
* @newin{2,12} |
| 88 |
*/ |
| 89 |
_WRAP_CTOR(TextMark(const Glib::ustring& name, bool left_gravity = true), gtk_text_mark_new) |
| 90 |
|
| 91 |
public: |
| 92 |
|
| 93 |
/** Creates an anoymous text mark. Add it to a buffer using Gtk::TextBuffer::add_mark(). |
| 94 |
* If a mark has left |
| 95 |
* gravity, and text is inserted at the mark's current location, the mark |
| 96 |
* will be moved to the left of the newly-inserted text. If the mark has |
| 97 |
* right gravity (@a left_gravity = false), the mark will end up on the |
| 98 |
* right of newly-inserted text. The standard left-to-right cursor is a |
| 99 |
* mark with right gravity (when you type, the cursor stays on the right |
| 100 |
* side of the text you're typing). |
| 101 |
* |
| 102 |
* @param left_gravity Whether the mark should have left gravity. |
| 103 |
* @result A RefPtr to a new text mark. |
| 104 |
* @newin{2,12} |
| 105 |
*/ |
| 106 |
_WRAP_CREATE(bool left_gravity = true) |
| 107 |
|
| 108 |
/** Creates a text mark. Add it to a buffer using Gtk::TextBuffer::add_mark(). |
| 109 |
* The mark can be retrieved by name using Gtk::TextBuffer::get_mark(). If a mark has left |
| 110 |
* gravity, and text is inserted at the mark's current location, the mark |
| 111 |
* will be moved to the left of the newly-inserted text. If the mark has |
| 112 |
* right gravity (@a left_gravity = false), the mark will end up on the |
| 113 |
* right of newly-inserted text. The standard left-to-right cursor is a |
| 114 |
* mark with right gravity (when you type, the cursor stays on the right |
| 115 |
* side of the text you're typing). |
| 116 |
* |
| 117 |
* @param name mark name. |
| 118 |
* @param left_gravity Whether the mark should have left gravity. |
| 119 |
* @result A RefPtr to a new text mark. |
| 120 |
* @newin{2,12} |
| 121 |
*/ |
| 122 |
_WRAP_CREATE(const Glib::ustring& name, bool left_gravity = true) |
| 123 |
|
| 124 |
_WRAP_METHOD(void set_visible(bool setting = true), gtk_text_mark_set_visible) |
| 125 |
_WRAP_METHOD(bool get_visible() const, gtk_text_mark_get_visible) |
| 126 |
_WRAP_METHOD(Glib::ustring get_name() const, gtk_text_mark_get_name) |
| 127 |
_WRAP_METHOD(bool get_deleted() const, gtk_text_mark_get_deleted) |
| 128 |
_WRAP_METHOD(Glib::RefPtr<TextBuffer> get_buffer(), gtk_text_mark_get_buffer, refreturn) |
| 129 |
_WRAP_METHOD(Glib::RefPtr<const TextBuffer> get_buffer() const, gtk_text_mark_get_buffer, refreturn, constversion) |
| 130 |
_WRAP_METHOD(bool get_left_gravity() const, gtk_text_mark_get_left_gravity) |
| 131 |
|
| 132 |
//TODO: Add a const overload, if we have a ConstTextIter. |
| 133 |
TextIter get_iter(); |
| 134 |
|
| 135 |
_WRAP_PROPERTY("name", Glib::ustring) |
| 136 |
_WRAP_PROPERTY("left-gravity", bool) |
| 137 |
}; |
| 138 |
|
| 139 |
} //namespace Gtk |