org.gnu.gtk
public class TextBuffer extends GObject
Constructor Summary | |
---|---|
TextBuffer(TextTagTable table)
Creates a new text buffer.
| |
TextBuffer()
Creates a new buffer and a new default TextTagTable. |
Method Summary | |
---|---|
void | addClipboard(Clipboard clipboard)
Adds clipboard to the list of clipboards in which the selection contents
of buffer are available. |
void | addListener(TextBufferListener listener)
Register an object to receive text view event notification.
|
void | applyTag(TextTag tag, TextIter start, TextIter end)
Emits the "apply_tag" signal on buffer. |
void | applyTag(String name, TextIter start, TextIter end)
Looks up a tag by name and then applies it.
|
boolean | backspace(TextIter iter, boolean interactive, boolean default_editable)
Performs the appropriate action as if the user hit the delete key with
the cursor at the position specified by iter. |
void | beginUserAction()
Called to indicate that the buffer operations between here and a call to
{@link #endUserAction()} are part of a single user-visible operation. |
void | copyClipboard(Clipboard clip)
Copies the currently-selected text to a clipboard.
|
TextChildAnchor | createChildAnchor(TextIter iter)
This is a convenience function which simply creates a child anchor with
{link TextChildAnchor#TextChildAnchor()} and inserts it into the buffer
|
TextMark | createMark(String markName, TextIter where, boolean leftGravity)
Creates a mark at position where . |
TextTag | createTag(String name)
Creates a TextTag initialised for use in this TextBuffer. |
void | cutClipboard(Clipboard clipboard, boolean defaultEditable)
Copies the currently-selected text to a clipboard, then deletes said text
if it's editable.
|
void | deleteMark(TextMark mark)
Deletes mark , so that it's no longer located anywhere in
the buffer. |
void | deleteMark(String name)
Deletes the mark named name ; the mark must exist.
|
boolean | deleteSelection(boolean interactive, boolean defaultEditable)
Deletes the range between the "insert" and "selection_bound" marks, that
is, the currently-selected text. |
void | deleteText(TextIter start, TextIter end)
Deletes text between start and end . |
boolean | deleteTextInteractive(TextIter start, TextIter end, boolean defaultEditable)
Deletes all editable text in the given range. |
void | endUserAction()
Should be paired with a call to {@link #beginUserAction()}. |
int | getCharCount()
Gets the number of characters in the buffer. |
TextIter | getEndIter()
Returns Iterator for the end of the text
|
Class | getEventListenerClass(String signal)
TextView event handling.
|
EventType | getEventType(String signal) |
TextMark | getInsert()
Returns the mark that represents the cursor (insertion point). |
TextIter | getIter(int lineNumber, int charOffset)
Obtains an iterator pointing to charOffset within the given line. |
TextIter | getIter(int charOffset)
Obtains an iterator pointing to charOffset within the entire string,
statring from the beginning
|
TextIter | getIter(TextMark mark)
Returns an iter at the given mark
|
TextIter | getIter(TextChildAnchor anchor)
Obtains the location of anchor within buffer.
|
int | getLineCount()
Obtains the number of lines in the buffer. |
TextIter | getLineIter(int line)
Obtains an iterator pointing to the start of the given line
|
TextMark | getMark(String name)
Returns the mark named name in the buffer, or
null if no such mark exists in the buffer |
boolean | getModified()
Indicates whether the buffer has been modified since the last call to
{@link #setModified(boolean)} set the modification flag to FALSE. |
boolean | getSelected()
Returns true if an area of the buffer is selected
|
TextMark | getSelectionBound()
Returns the mark that represents the selection bound. |
TextIter | getSelectionEnd()
Returns an iterator for the end of the selection, or null
if no text is selected. |
TextIter | getSelectionStart()
Returns an iterator for the start of the selected text, or
null if no text is selected. |
String | getSlice(TextIter start, TextIter end, boolean includeHiddenChars)
Returns the text in the range start,end. |
TextIter | getStartIter()
Returns an iterator for the start of the text
|
String | getText(TextIter start, TextIter end, boolean includeHiddenChars)
Returns the text in the range start,end. |
TextTagTable | getTextTagTable()
Get the GtkTextTagTable associated with this buffer.
|
static Type | getType()
Retrieve the runtime type used by the GLib library. |
void | inserChildAnchor(TextIter iter, TextChildAnchor anchor)
Inserts a child widget anchor into the text buffer at iter. |
void | insertPixbuf(TextIter iter, Pixbuf pixbuf)
Inserts an image into the text buffer at iter. |
void | insertRange(TextIter iter, TextIter start, TextIter end)
Copies text, tags, and pixbufs between start and end (the order of start
and end doesn't matter) and inserts the copy at iter. |
boolean | insertRangeInteractive(TextIter iter, TextIter start, TextIter end, boolean defaultEditable)
Same as {@link #insertRange(TextIter, TextIter, TextIter)}, but does
nothing if the insertion point isn't editable. |
void | insertText(TextIter iter, String text)
Inserts text at position iter. |
void | insertText(String text)
Inserts text at the current cursor position
|
void | insertText(TextIter iter, String text, String tag)
Inserts text and applies a tag to that text.
|
void | insertText(TextIter iter, String text, String[] tags)
Inserts text and applies tags to that text.
|
boolean | insertTextInteractive(TextIter iter, String text, boolean defaultEditable)
Like {@link #insertText(TextIter, String)}, but the insertion will not
occur if iter is at a non-editable location in the buffer. |
boolean | insertTextInteractive(String text, boolean defaultEditable)
Calls {@link #insertTextInteractive(TextIter, String, boolean)} at the
cursor position.
|
boolean | markExists(String name)
Returns true if a mark exists with the given name. |
void | moveMark(TextMark mark, TextIter where)
Moves mark to the new location where .
|
void | moveMark(String name, TextIter where)
Moves the mark named name (which must exist) to location
where
|
void | pasteClipboard(Clipboard clipboard, TextIter location, boolean defaultEditable)
Pastes the contents of a clipboard at location. |
void | pasteClipboard(Clipboard clipboard, boolean defaultEditable)
Pastes the contents of a clipboard at the insertion point. |
void | placeCursor(TextIter where)
This function moves the "insert" and "selection_bound" marks
simultaneously. |
void | removeAllTags(TextTag start, TextTag end)
Removes all tags in the range between start and end. |
void | removeAllTags(TextIter start, TextIter end)
Removes all tags in the range between start and end. |
void | removeClipboard(Clipboard clipboard)
Removes a clipboard added with {@link #addClipboard(Clipboard)}
|
void | removeListener(TextBufferListener listener)
Unregister an object that was receiving text view event notification.
|
void | removeTag(TextTag tag, TextIter start, TextIter end)
Emits the "remove_tag" signal. |
void | removeTag(String name, TextIter start, TextIter end)
Removes a tag based on it's name.
|
void | selectRange(TextIter ins, TextIter bound)
This function moves the "insert" and "selection_bound" marks
simultaneously. |
void | setModified(boolean setting)
Used to keep track of whether the buffer has been modified since the last
time it was saved. |
void | setText(String text)
Deletes current contents of buffer, and inserts text
instead.
|
Parameters: table A tag table
Parameters: clipboard A ClipBoard
Parameters: listener The object that has implemented the TextBufferListener interface that is to receive the text view events.
Parameters: tag A TextTag start One bound of range to be tagged end Other bound of range to be tagged
Parameters: name Name of a named TextTag start One bound of range to be tagged end Other bound of range to be tagged
Parameters: iter A position in the buffer. interactive Whether the deletion is caused by user interaction. default_editable Whether the buffer is editable by default.
Returns: TRUE if the buffer was modified.
The "interactive" buffer mutation functions 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.
Parameters: clip The clipboard to copy the text to
Parameters: iter Location in the buffer
Returns: The created child anchor
where
. Otherwise, the mark can
be retrieved by name using {@link #getMark(String)}. 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 (leftGravity = 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).
Emits the "mark_set" event as notification of the mark's initial placement.
Parameters: markName Name for mark where Location to place mark leftGravity Whether the mark has left gravity
Returns: The new TextMark object
Parameters: clipboard The Clipboard object to cut to. defaultEditable Default editability of the buffer
mark
, so that it's no longer located anywhere in
the buffer. There is no way to undelete a mark.
{@link TextMark#getDeleted()} indicates that a mark no longer belongs to
a buffer. The "mark_deleted" signal will be emitted as notification after
the mark is deleted.
Parameters: mark A TextMark in buffer
name
; the mark must exist.
Parameters: name The name of the mark to delete
See Also: deleteMark
Parameters: interactive Whether the deletion is caused by user interaction defaultEditable Whether the buffer is editable by default
Returns: Whether there was a non-empty selection to delete
start
and end
. The
order of start and end is not actually relevant. 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: start A position in buffer end Another position in buffer.
start
and end
are revalidated to
point to the location of the last deleted range, or left untouched if no
text was deleted.
Parameters: start Start of range to delete end End of range defaultEditable Ehether the buffer is editable by default
Returns: Whether some text was actually deleted
Returns: Number of characters in the buffer.
Returns: Iterator for the end of the text.
Returns: Insertion point mark
Parameters: lineNumber Line number counting from 0 charOffset Char offset from start of line
Returns: Iterator
Parameters: charOffset Character offset from the beginning of the text
Returns: Iterator pointing to that point.
Parameters: mark The position for the iter
Returns: Iterator
Parameters: anchor An anchor that appears in the buffer.
Returns: Iterator
Returns: The number of lines in the buffer.
Parameters: line The line
Returns: Iterator
name
in the buffer, or
null
if no such mark exists in the bufferReturns: TRUE if the buffer has been modified
Returns: True if an area is selected
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.
Returns: Mark for the selection
null
if no text is selected.null
if no text is selected.Parameters: start Start of a range end End of a range. includeHiddenChars Whether to include invisible text
Returns: The string
Returns: iterator
Parameters: start Start of a range end End of a range includeHiddenChars Whether to include invisible text
Returns: The text of the buffer
Returns: Associated TextTagTable.
Parameters: iter Location to insert the anchor anchor A TextChildAnchor
Parameters: iter Location to insert the pixbuf pixbuf A Pixbuf
Implemented via emissions of the insert_text and apply_tag signals, so expect those.
Parameters: iter A position in the buffer start A position in a TextBuffer end Another position in the same buffer as start
Parameters: iter A position in buffer start A position in a TextBuffer end Another position in the same buffer as start defaultEditable default editability of the buffer
Returns: Whether an insertion was possible at iter.
Parameters: iter A position in the buffer text The text to insert
Throws: IllegalArgumentException
If text
is null
Parameters: text The text to insert
Throws: IllegalArgumentException
If text
is null
Parameters: iter Place to insert text text Text to insert tag name of TextTag to apply to that text.
Throws: IllegalArgumentException
If text
is null
Parameters: iter Place to insert text text Text to insert tags Array of TextTag names to apply to that text.
defaultEditable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of {@link TextView#getEditable()} is appropriate here.
Parameters: iter A position in buffer text The text to insert defaultEditable Default editability of buffer
Returns: Whether text was actually inserted
Throws: IllegalArgumentException
If text
is null
defaultEditable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of {@link TextView#getEditable()} is appropriate here.
Parameters: text The text to insert. defaultEditable Default editability of buffer
Returns: Whether text was actually inserted.
Throws: IllegalArgumentException
If text
is null
mark
to the new location where
.
Emits the "mark_set" event as notification of the move.
Parameters: mark A TextMark where New location for mark in buffer
name
(which must exist) to location
where
Parameters: name Name of a mark where New location for mark
Parameters: clipboard The Clipboard to paste from location Location to insert pasted text defaultEditable Whether the buffer is editable by default
Parameters: clipboard The Clipboard to paste from defaultEditable Whether the buffer is editable by default
Parameters: where Where to put the cursor
Deprecated:
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.THIS METHOD IS INCORRECT AND SHOULD NOT BE USED Use {@link #removeAllTags(TextIter, TextIter)} instead
Parameters: start One bound of range to be untagged end Other bound of range to be untagged
Parameters: start end
Parameters: clipboard The clipboard to remove
Parameters: listener The object that is to no longer receive text view events.
Parameters: tag A TextTag start One bound of range to be untagged end Other bound of range to be untagged
Parameters: name Name of a TextTag start One bound of range to be untagged end Other bound of range to be untagged
Parameters: ins where to put the "insert" mark bound where to put the "selection_bound" mark
Since: 2.4
Parameters: setting Modification flag setting
text
instead.
Parameters: text The text to use as the content of the buffer.
Throws: IllegalArgumentException
If text
is null