Graphics.UI.Gtk.Multiline.TextBuffer

gtk-0.12.4: Binding to the Gtk+ graphical user interface library.

Portability | portable (depends on GHC)
Stability | provisional
Maintainer | gtk2hs-users@lists.sourceforge.net
Safe Haskell | None

Graphics.UI.Gtk.Multiline.TextBuffer

Contents

- Detail
- Class Hierarchy
- Types
- Constructors
- Methods
- Attributes
- Signals
- Deprecated

Description

Stores attributed text for display in a `TextView`

Synopsis

- data TextBuffer
- class GObjectClass o => TextBufferClass o
- castToTextBuffer :: GObjectClass obj => obj -> TextBuffer
- gTypeTextBuffer :: GType
- toTextBuffer :: TextBufferClass o => o -> TextBuffer
- textBufferNew :: Maybe TextTagTable -> IO TextBuffer
- textBufferGetLineCount :: TextBufferClass self => self -> IO Int
- textBufferGetCharCount :: TextBufferClass self => self -> IO Int
- textBufferGetTagTable :: TextBufferClass self => self -> IO TextTagTable
- textBufferInsert :: TextBufferClass self => self -> TextIter -> String -> IO ()
- textBufferInsertByteString :: TextBufferClass self => self -> TextIter -> ByteString -> IO ()
- textBufferInsertAtCursor :: TextBufferClass self => self -> String -> IO ()
- textBufferInsertByteStringAtCursor :: TextBufferClass self => self -> ByteString -> IO ()
- textBufferInsertInteractive :: TextBufferClass self => self -> TextIter -> String -> Bool -> IO Bool
- textBufferInsertByteStringInteractive :: TextBufferClass self => self -> TextIter -> ByteString -> Bool -> IO Bool
- textBufferInsertInteractiveAtCursor :: TextBufferClass self => self -> String -> Bool -> IO Bool
- textBufferInsertByteStringInteractiveAtCursor :: TextBufferClass self => self -> ByteString -> Bool -> IO Bool
- textBufferInsertRange :: TextBufferClass self => self -> TextIter -> TextIter -> TextIter -> IO ()
- textBufferInsertRangeInteractive :: TextBufferClass self => self -> TextIter -> TextIter -> TextIter -> Bool -> IO Bool
- textBufferDelete :: TextBufferClass self => self -> TextIter -> TextIter -> IO ()
- textBufferDeleteInteractive :: TextBufferClass self => self -> TextIter -> TextIter -> Bool -> IO Bool
- textBufferSetByteString :: TextBufferClass self => self -> ByteString -> IO ()
- textBufferGetByteString :: TextBufferClass self => self -> TextIter -> TextIter -> Bool -> IO ByteString
- textBufferGetByteStringSlice :: TextBufferClass self => self -> TextIter -> TextIter -> Bool -> IO ByteString
- textBufferSetText :: TextBufferClass self => self -> String -> IO ()
- textBufferGetText :: TextBufferClass self => self -> TextIter -> TextIter -> Bool -> IO String
- textBufferGetSlice :: TextBufferClass self => self -> TextIter -> TextIter -> Bool -> IO String
- textBufferInsertPixbuf :: TextBufferClass self => self -> TextIter -> Pixbuf -> IO ()
- textBufferCreateMark :: TextBufferClass self => self -> Maybe MarkName -> TextIter -> Bool -> IO TextMark
- textBufferAddMark :: TextBufferClass self => self -> TextMark -> TextIter -> IO ()
- textBufferMoveMark :: (TextBufferClass self, TextMarkClass mark) => self -> mark -> TextIter -> IO ()
- textBufferMoveMarkByName :: TextBufferClass self => self -> MarkName -> TextIter -> IO ()
- textBufferDeleteMark :: (TextBufferClass self, TextMarkClass mark) => self -> mark -> IO ()
- textBufferDeleteMarkByName :: TextBufferClass self => self -> MarkName -> IO ()
- textBufferGetMark :: TextBufferClass self => self -> MarkName -> IO (Maybe TextMark)
- textBufferGetInsert :: TextBufferClass self => self -> IO TextMark
- textBufferGetSelectionBound :: TextBufferClass self => self -> IO TextMark
- textBufferPlaceCursor :: TextBufferClass self => self -> TextIter -> IO ()
- textBufferApplyTag :: (TextBufferClass self, TextTagClass tag) => self -> tag -> TextIter -> TextIter -> IO ()
- textBufferRemoveTag :: (TextBufferClass self, TextTagClass tag) => self -> tag -> TextIter -> TextIter -> IO ()
- textBufferApplyTagByName :: TextBufferClass self => self -> TagName -> TextIter -> TextIter -> IO ()
- textBufferRemoveTagByName :: TextBufferClass self => self -> TagName -> TextIter -> TextIter -> IO ()
- textBufferRemoveAllTags :: TextBufferClass self => self -> TextIter -> TextIter -> IO ()
- textBufferGetIterAtLineOffset :: TextBufferClass self => self -> Int -> Int -> IO TextIter
- textBufferGetIterAtOffset :: TextBufferClass self => self -> Int -> IO TextIter
- textBufferGetIterAtLine :: TextBufferClass self => self -> Int -> IO TextIter
- textBufferGetIterAtMark :: (TextBufferClass self, TextMarkClass mark) => self -> mark -> IO TextIter
- textBufferGetStartIter :: TextBufferClass self => self -> IO TextIter
- textBufferGetEndIter :: TextBufferClass self => self -> IO TextIter
- textBufferGetModified :: TextBufferClass self => self -> IO Bool
- textBufferSetModified :: TextBufferClass self => self -> Bool -> IO ()
- textBufferDeleteSelection :: TextBufferClass self => self -> Bool -> Bool -> IO Bool
- textBufferHasSelection :: TextBufferClass self => self -> IO Bool
- textBufferGetSelectionBounds :: TextBufferClass self => self -> IO (TextIter, TextIter)
- textBufferSelectRange :: TextBufferClass self => self -> TextIter -> TextIter -> IO ()
- textBufferGetBounds :: TextBufferClass self => self -> IO (TextIter, TextIter)
- textBufferBeginUserAction :: TextBufferClass self => self -> IO ()
- textBufferEndUserAction :: TextBufferClass self => self -> IO ()
- textBufferBackspace :: TextBufferClass self => self -> TextIter -> Bool -> Bool -> IO Bool
- textBufferInsertChildAnchor :: TextBufferClass self => self -> TextIter -> TextChildAnchor -> IO ()
- textBufferCreateChildAnchor :: TextBufferClass self => self -> TextIter -> IO TextChildAnchor
- textBufferGetIterAtChildAnchor :: TextBufferClass self => self -> TextIter -> TextChildAnchor -> IO ()
- textBufferPasteClipboard :: TextBufferClass self => self -> Clipboard -> TextIter -> Bool -> IO ()
- textBufferPasteClipboardAtCursor :: TextBufferClass self => self -> Clipboard -> Bool -> IO ()
- textBufferCopyClipboard :: TextBufferClass self => self -> Clipboard -> IO ()
- textBufferCutClipboard :: TextBufferClass self => self -> Clipboard -> Bool -> IO ()
- textBufferAddSelectionClipboard :: TextBufferClass self => self -> Clipboard -> IO ()
- textBufferRemoveSelectionClipboard :: TextBufferClass self => self -> Clipboard -> IO ()
- textBufferTagTable :: (TextBufferClass self, TextTagTableClass textTagTable) => ReadWriteAttr self TextTagTable textTagTable
- textBufferText :: TextBufferClass self => Attr self String
- textBufferModified :: TextBufferClass self => Attr self Bool
- applyTag :: TextBufferClass self => Signal self (TextTag -> TextIter -> TextIter -> IO ())
- beginUserAction :: TextBufferClass self => Signal self (IO ())
- bufferChanged :: TextBufferClass self => Signal self (IO ())
- deleteRange :: TextBufferClass self => Signal self (TextIter -> TextIter -> IO ())
- endUserAction :: TextBufferClass self => Signal self (IO ())
- insertPixbuf :: TextBufferClass self => Signal self (TextIter -> Pixbuf -> IO ())
- insertChildAnchor :: TextBufferClass self => Signal self (TextIter -> TextChildAnchor -> IO ())
- bufferInsertText :: TextBufferClass self => Signal self (TextIter -> String -> IO ())
- markDeleted :: TextBufferClass self => Signal self (TextMark -> IO ())
- markSet :: TextBufferClass self => Signal self (TextIter -> TextMark -> IO ())
- modifiedChanged :: TextBufferClass self => Signal self (IO ())
- pasteDone :: TextBufferClass self => Signal self (Clipboard -> IO ())
- removeTag :: TextBufferClass self => Signal self (TextTag -> TextIter -> TextIter -> IO ())
- onApplyTag :: TextBufferClass self => self -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId self)
- afterApplyTag :: TextBufferClass self => self -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId self)
- onBeginUserAction :: TextBufferClass self => self -> IO () -> IO (ConnectId self)
- afterBeginUserAction :: TextBufferClass self => self -> IO () -> IO (ConnectId self)
- onBufferChanged :: TextBufferClass self => self -> IO () -> IO (ConnectId self)
- afterBufferChanged :: TextBufferClass self => self -> IO () -> IO (ConnectId self)
- onDeleteRange :: TextBufferClass self => self -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId self)
- afterDeleteRange :: TextBufferClass self => self -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId self)
- onEndUserAction :: TextBufferClass self => self -> IO () -> IO (ConnectId self)
- afterEndUserAction :: TextBufferClass self => self -> IO () -> IO (ConnectId self)
- onInsertPixbuf :: TextBufferClass self => self -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId self)
- afterInsertPixbuf :: TextBufferClass self => self -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId self)
- onBufferInsertText :: TextBufferClass self => self -> (TextIter -> String -> IO ()) -> IO (ConnectId self)
- afterBufferInsertText :: TextBufferClass self => self -> (TextIter -> String -> IO ()) -> IO (ConnectId self)
- onMarkDeleted :: TextBufferClass self => self -> (TextMark -> IO ()) -> IO (ConnectId self)
- afterMarkDeleted :: TextBufferClass self => self -> (TextMark -> IO ()) -> IO (ConnectId self)
- onMarkSet :: TextBufferClass self => self -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId self)
- afterMarkSet :: TextBufferClass self => self -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId self)
- onModifiedChanged :: TextBufferClass self => self -> IO () -> IO (ConnectId self)
- afterModifiedChanged :: TextBufferClass self => self -> IO () -> IO (ConnectId self)
- onRemoveTag :: TextBufferClass self => self -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId self)
- afterRemoveTag :: TextBufferClass self => self -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId self)

# Detail

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.

# Class Hierarchy

     | GObject
     | +----TextBuffer

# Types

data TextBuffer

Instances

Eq TextBuffer |
Ord TextBuffer |
GObjectClass TextBuffer |
TextBufferClass TextBuffer |

class GObjectClass o => TextBufferClass o

Instances

TextBufferClass TextBuffer |

castToTextBuffer :: GObjectClass obj => obj -> TextBuffer

gTypeTextBuffer :: GType

toTextBuffer :: TextBufferClass o => o -> TextBuffer

# Constructors

textBufferNew

Arguments

:: Maybe TextTagTable | `table` - a tag table, or `Nothing` to create a new one
-> IO TextBuffer |

Creates a new text buffer.

# Methods

textBufferGetLineCount :: TextBufferClass self => self -> IO Int

Obtains the number of lines in the buffer. This value is cached, so the function is very fast.

textBufferGetCharCount :: TextBufferClass self => self -> IO Int

Gets the number of characters in the buffer. The character count is cached, so this function is very fast.

textBufferGetTagTable :: TextBufferClass self => self -> IO TextTagTable

Get the `TextTagTable` associated with this buffer.

textBufferInsert

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - a position in the buffer
-> String | `text` - text to insert
-> IO () |

Inserts `text` at position `iter`. Emits the `insertText` signal; insertion actually occurs in the default handler for the signal. `iter` is invalidated when insertion occurs (because the buffer contents change).

textBufferInsertByteString

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - a position in the buffer
-> ByteString | `text` - text to insert
-> IO () |

Inserts `text` at position `iter`. Similar to `textBufferInsert` but uses `ByteString` buffers.

- The passed-in buffer must contain a valid UTF-8 encoded string.

textBufferInsertAtCursor :: TextBufferClass self => self -> String -> IO ()

Simply calls `textBufferInsert`, using the current cursor position as the insertion point.

textBufferInsertByteStringAtCursor :: TextBufferClass self => self -> ByteString -> IO ()

Simply calls `textBufferInsert`, using the current cursor position as the insertion point. Similar to `textBufferInsertAtCursor` but uses `ByteString` buffers.

- The passed-in buffer must contain a valid UTF-8 encoded string.

textBufferInsertInteractive

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - a position in `buffer`
-> String | `text` - the text to insert
-> Bool | `defaultEditable` - default editability of buffer
-> IO Bool | returns whether text was actually inserted

Like `textBufferInsert`, but the insertion will not occur if `iter` is at a non-editable location in the buffer. Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive).

If no tag is at the specified position, use the default value `def` to decide if the text should be inserted. This value could be set to the result of `textViewGetEditable`.

textBufferInsertByteStringInteractive

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - a position in `buffer`
-> ByteString | `text` - the text to insert
-> Bool | `defaultEditable` - default editability of buffer
-> IO Bool | returns whether text was actually inserted

Similar to `textBufferInsertInteractive` but uses `ByteString` buffers.

- The passed-in buffer must contain a valid UTF-8 encoded string.

textBufferInsertInteractiveAtCursor

Arguments

:: TextBufferClass self |
=> self |
-> String | `text` - the text to insert
-> Bool | `defaultEditable` - default editability of buffer
-> IO Bool | returns whether text was actually inserted

Calls `textBufferInsertInteractive` at the cursor position.

textBufferInsertByteStringInteractiveAtCursor

Arguments

:: TextBufferClass self |
=> self |
-> ByteString | `text` - the text to insert
-> Bool | `defaultEditable` - default editability of buffer
-> IO Bool | returns whether text was actually inserted

Similar to `textBufferInsertInteractiveAtCursor` but uses `ByteString` buffers.

- The passed-in buffer must contain a valid UTF-8 encoded string.

textBufferInsertRange

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - a position in the buffer
-> TextIter | `start` - a position in a `TextBuffer`
-> TextIter | `end` - another position in the same buffer as `start`
-> IO () |

Copies text, tags, and pixbufs between `start` and `end` (the order of `start` and `end` doesn't matter) and inserts the copy at `iter`. Used instead of simply getting/inserting text because it preserves images and tags. If `start` and `end` are in a different buffer from `buffer`, the two buffers must share the same tag table.

Implemented via emissions of the insert-text and `applyTag` signals, so expect those.

textBufferInsertRangeInteractive

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - a position in the buffer
-> TextIter | `start` - a position in a `TextBuffer`
-> TextIter | `end` - another position in the same buffer as `start`
-> Bool | `defaultEditable` - default editability of the buffer
-> IO Bool | returns whether an insertion was possible at `iter`

Same as `textBufferInsertRange`, but does nothing if the insertion point isn't editable. The `defaultEditable` parameter indicates whether the text is editable at `iter` if no tags enclosing `iter` affect editability. Typically the result of `textViewGetEditable` is appropriate here.

textBufferDelete

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `start` - a position in `buffer`
-> TextIter | `end` - another position in `buffer`
-> IO () |

Deletes text between `start` and `end`. The order of `start` and `end` is not actually relevant; `textBufferDelete` will reorder them. This function actually emits the `deleteRange` 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.

textBufferDeleteInteractive

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `startIter` - start of range to delete
-> TextIter | `endIter` - end of range
-> Bool | `defaultEditable` - whether the buffer is editable by default
-> IO Bool | returns whether some text was actually deleted

Deletes all editable text in the given range. Calls `textBufferDelete` for each editable sub-range of [`start`,`end`). `start` and `end` are revalidated to point to the location of the last deleted range, or left untouched if no text was deleted.

textBufferSetByteString

Arguments

:: TextBufferClass self |
=> self |
-> ByteString | `text` - text to insert
-> IO () |

Deletes current contents of `buffer`, and inserts `text` instead. Similar to `textBufferSetText` but uses `ByteString` buffers.

- The passed-in buffer must contain a valid UTF-8 encoded string.

textBufferGetByteString

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `start` - start of a range
-> TextIter | `end` - end of a range
-> Bool | `includeHiddenChars` - whether to include invisible text
-> IO ByteString |

Returns the text in the range [`start`,`end`). Similar to `textBufferGetText` but uses `ByteString` buffers.

- The returned buffer is a UTF-8 encoded string.

textBufferGetByteStringSlice

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `start` - start of a range
-> TextIter | `end` - end of a range
-> Bool | `includeHiddenChars` - whether to include invisible text
-> IO ByteString |

Returns the text in the range [`start`,`end`). Similar to `textBufferGetSlice` but uses `ByteString` buffers.

- The returned buffer is a UTF-8 encoded string.

textBufferSetText

Arguments

:: TextBufferClass self |
=> self |
-> String | `text` - text to insert
-> IO () |

Deletes current contents of `buffer`, and inserts `text` instead.

textBufferGetText

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `start` - start of a range
-> TextIter | `end` - end of a range
-> Bool | `includeHiddenChars` - whether to include invisible text
-> IO String |

Returns the text in the range [`start`,`end`). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if `includeHiddenChars` is `False`. Does not include characters representing embedded images, so character indexes into the returned string do not correspond to character indexes into the buffer. Contrast with `textBufferGetSlice`.

textBufferGetSlice

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `start` - start of a range
-> TextIter | `end` - end of a range
-> Bool | `includeHiddenChars` - whether to include invisible text
-> IO String |

Returns the text in the range [`start`,`end`). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if `includeHiddenChars` is `False`. The returned string includes a `(chr 0xFFFC)` character whenever the buffer contains embedded images, so character indexes into the returned string do correspond to character indexes into the buffer. Contrast with `textBufferGetText`. Note that `(chr 0xFFFC)` can occur in normal text as well, so it is not a reliable indicator that a pixbuf or widget is in the buffer.

textBufferInsertPixbuf

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - location to insert the pixbuf
-> Pixbuf | `pixbuf` - a `Pixbuf`
-> IO () |

Inserts an image into the text buffer at `iter`. The image will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode "object replacement character" `(chr 0xFFFC)`. Note that the "slice" variants for obtaining portions of the buffer as a string include this character for pixbufs, but the "text" variants do not. e.g. see `textBufferGetSlice` and `textBufferGetText`.

textBufferCreateMark

Arguments

:: TextBufferClass self |
=> self |
-> Maybe MarkName | `markName` - name for mark, or `Nothing`
-> TextIter | `where` - location to place mark
-> Bool | `leftGravity` - whether the mark has left gravity
-> IO TextMark | returns the new `TextMark` object

Creates a mark at position `where`. If `markName` is `Nothing`, the mark is anonymous; otherwise, the mark can be retrieved by name using `textBufferGetMark`. 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 `markSet` signal as notification of the mark's initial placement.

textBufferAddMark

Arguments

:: TextBufferClass self |
=> self |
-> TextMark | `mark` the mark to add
-> TextIter | `iter` location to place mark
-> IO () |

Adds the mark at position given by the `TextIter`. The mark may not be added to any other buffer.

Emits the `markSet` signal as notification of the mark's initial placement.

textBufferMoveMark

Arguments

:: (TextBufferClass self, TextMarkClass mark) |
=> self |
-> mark | `mark` - a `TextMark`
-> TextIter | `where` - new location for `mark` in the buffer
-> IO () |

Moves `mark` to the new location `where`. Emits the `markSet` signal as notification of the move.

textBufferMoveMarkByName

Arguments

:: TextBufferClass self |
=> self |
-> MarkName | `name` - name of a mark
-> TextIter | `where` - new location for mark
-> IO () |

Moves the mark named `name` (which must exist) to location `where`. See `textBufferMoveMark` for details.

textBufferDeleteMark

Arguments

:: (TextBufferClass self, TextMarkClass mark) |
=> self |
-> mark | `mark` - a `TextMark` in the buffer
-> IO () |

Deletes `mark`, so that it's no longer located anywhere in the buffer. Most operations on `mark` become invalid. There is no way to undelete a mark. `textMarkGetDeleted` will return `True` after this function has been called on a mark; `textMarkGetDeleted` indicates that a mark no longer belongs to a buffer. The `markDeleted` signal will be emitted as notification after the mark is deleted.

textBufferDeleteMarkByName

Arguments

:: TextBufferClass self |
=> self |
-> MarkName | `name` - name of a mark in `buffer`
-> IO () |

Deletes the mark named `name`; the mark must exist. See `textBufferDeleteMark` for details.

textBufferGetMark

Arguments

:: TextBufferClass self |
=> self |
-> MarkName | `name` - a mark name
-> IO (Maybe TextMark) | returns a `TextMark`, or `Nothing`

Returns the mark named `name` in the buffer, or `Nothing` if no such mark exists in the buffer.

textBufferGetInsert :: TextBufferClass self => self -> IO TextMark

Returns the mark that represents the cursor (insertion point). Equivalent to calling `liftM fromJust $ textBufferGetMark "insert"`, but very slightly more efficient, and involves less typing.

textBufferGetSelectionBound :: TextBufferClass self => self -> IO TextMark

Returns the mark that represents the selection bound. Equivalent to calling `liftM fromJust $ textBufferGetMark "selection_bound"`, but very slightly more efficient, and involves less typing.

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. `textBufferGetSelectionBounds` is another convenient function for handling the selection, if you just want to know whether there's a selection and what its bounds are.

textBufferPlaceCursor

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `where` - where to put the cursor
-> IO () |

This function moves the "insert" and "selection_bound" marks simultaneously. If you move them to the same place in two steps with `textBufferMoveMark`, you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.

textBufferApplyTag

Arguments

:: (TextBufferClass self, TextTagClass tag) |
=> self |
-> tag | `tag` - a `TextTag`
-> TextIter | `start` - one bound of range to be tagged
-> TextIter | `end` - other bound of range to be tagged
-> IO () |

Emits the `applyTag` signal on the buffer. The default handler for the signal applies `tag` to the given range. `start` and `end` do not have to be in order.

textBufferRemoveTag

Arguments

:: (TextBufferClass self, TextTagClass tag) |
=> self |
-> tag | `tag` - a `TextTag`
-> TextIter | `start` - one bound of range to be untagged
-> TextIter | `end` - other bound of range to be untagged
-> IO () |

Emits the `removeTag` signal. The default handler for the signal removes all occurrences of `tag` from the given range. `start` and `end` don't have to be in order.

textBufferApplyTagByName

Arguments

:: TextBufferClass self |
=> self |
-> TagName | `name` - name of a named `TextTag`
-> TextIter | `start` - one bound of range to be tagged
-> TextIter | `end` - other bound of range to be tagged
-> IO () |

Calls `textTagTableLookup` on the buffer's tag table to get a `TextTag`, then calls `textBufferApplyTag`.

textBufferRemoveTagByName

Arguments

:: TextBufferClass self |
=> self |
-> TagName | `name` - name of a `TextTag`
-> TextIter | `start` - one bound of range to be untagged
-> TextIter | `end` - other bound of range to be untagged
-> IO () |

Calls `textTagTableLookup` on the buffer's tag table to get a `TextTag`, then calls `textBufferRemoveTag`.

textBufferRemoveAllTags

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `start` - one bound of range to be untagged
-> TextIter | `end` - other bound of range to be untagged
-> IO () |

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.

textBufferGetIterAtLineOffset

Arguments

:: TextBufferClass self |
=> self |
-> Int | `lineNumber` - line number counting from 0
-> Int | `charOffset` - char offset from start of line
-> IO TextIter |

Obtains an iterator pointing to `charOffset` within the given line. The `charOffset` must exist, offsets off the end of the line are not allowed.

textBufferGetIterAtOffset

Arguments

:: TextBufferClass self |
=> self |
-> Int | `charOffset` - char offset from start of buffer (counting from 0) or -1
-> IO TextIter |

Creates an iterator pointing to a position `charOffset` chars from the start of the entire buffer. If `charOffset` is -1 or greater than the number of characters in the buffer, the end iterator is returned, that is the iterator one past the last valid character in the buffer.

textBufferGetIterAtLine

Arguments

:: TextBufferClass self |
=> self |
-> Int | `lineNumber` - line number counting from 0
-> IO TextIter |

Create an iterator at a specific line.

textBufferGetIterAtMark

Arguments

:: (TextBufferClass self, TextMarkClass mark) |
=> self |
-> mark | `mark` - a `TextMark` in the buffer
-> IO TextIter |

Create an iterator from a mark.

textBufferGetStartIter :: TextBufferClass self => self -> IO TextIter

Create an iterator at the first position in the text buffer. This is the same as using `textBufferGetIterAtOffset` to get the iter at character offset 0.

textBufferGetEndIter :: TextBufferClass self => self -> IO TextIter

Returns the "end iterator," one past the last valid character in the text buffer. If dereferenced with `textIterGetChar`, the end iterator has a character value of 0. The entire buffer lies in the range from the first position in the buffer (call `textBufferGetStartIter` to get character position 0) to the end iterator.

textBufferGetModified

Arguments

:: TextBufferClass self |
=> self |
-> IO Bool | returns `True` if the buffer has been modified

Indicates whether the buffer has been modified since the last call to `textBufferSetModified` set the modification flag to `False`. Used for example to enable a "save" function in a text editor.

It is often more convenient to use `onModifiedChanged`.

textBufferSetModified :: TextBufferClass self => self -> Bool -> IO ()

Used to keep track of whether the buffer has been modified since the last time it was saved. Whenever the buffer is saved to disk, call ``textBufferSetModified` buffer False`. When the buffer is modified, it will automatically toggled on the modified bit again. When the modified bit flips, the buffer emits a `modifiedChanged` signal.

textBufferDeleteSelection

Arguments

:: TextBufferClass self |
=> self |
-> Bool | `interactive` - whether the deletion is caused by user interaction
-> Bool | `defaultEditable` - whether the buffer is editable by default
-> IO Bool | returns whether there was a non-empty selection to delete

Deletes the range between the "insert" and "selection_bound" marks, that is, the currently-selected text. If `interactive` is `True`, the editability of the selection will be considered (users can't delete uneditable text).

textBufferHasSelection :: TextBufferClass self => self -> IO Bool

Check if a selection exists.

textBufferGetSelectionBounds

Arguments

:: TextBufferClass self |
=> self |
-> IO (TextIter, TextIter) | `(start, end)` returns the selection start and end iterators

Returns the bounds of the selection (if the selection has length 0, then `start` and `end` will be the same). `start` and `end` will be in ascending order.

textBufferSelectRange

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `ins` - where to put the "insert" mark
-> TextIter | `bound` - where to put the "selection_bound" mark
-> IO () |

This function moves the "insert" and "selection_bound" marks simultaneously. If you move them in two steps with `textBufferMoveMark`, you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.

- Available since Gtk+ version 2.4

textBufferGetBounds

Arguments

:: TextBufferClass self |
=> self |
-> IO (TextIter, TextIter) | return the first and last iterators in the buffer

Retrieves the first and last iterators in the buffer, i.e. the entire buffer lies within the range `[start,end)`.

textBufferBeginUserAction :: TextBufferClass self => self -> IO ()

Called to indicate that the buffer operations between here and a call to `textBufferEndUserAction` are part of a single user-visible operation. The operations between `textBufferBeginUserAction` and `textBufferEndUserAction` can then be grouped when creating an undo stack. `TextBuffer` maintains a count of calls to `textBufferBeginUserAction` that have not been closed with a call to `textBufferEndUserAction`, and emits the `beginUserAction` and `endUserAction` signals only for the outermost pair of calls. This allows you to build user actions from other user actions.

The "interactive" buffer mutation functions, such as `textBufferInsertInteractive`, 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.

textBufferEndUserAction :: TextBufferClass self => self -> IO ()

Should be paired with a call to `textBufferBeginUserAction`. See that function for a full explanation.

textBufferBackspace

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - a position in `buffer`
-> Bool | `interactive` - whether the deletion is caused by user interaction
-> Bool | `defaultEditable` - whether the buffer is editable by default
-> IO Bool | returns `True` if the buffer was modified

Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by `iter`. In the normal case a single character will be deleted, but when combining accents are involved, more than one character can be deleted, and when precomposed character and accent combinations are involved, less than one character will be deleted.

Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, the `iter` will be re-initialized to point to the location where text was deleted.

- Available since Gtk+ version 2.6

textBufferInsertChildAnchor

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - location to insert the anchor
-> TextChildAnchor | `anchor` - a `TextChildAnchor`
-> IO () |

Inserts a child widget anchor into the text buffer at `iter`. The anchor will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode "object replacement character" `(chr 0xFFFC)`. Note that the "slice" variants for obtaining portions of the buffer as a string include this character for child anchors, but the "text" variants do not. e.g. see `textBufferGetSlice` and `textBufferGetText`. Consider `textBufferCreateChildAnchor` as a more convenient alternative to this function.

textBufferCreateChildAnchor

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - location in the buffer
-> IO TextChildAnchor | returns the created child anchor

This is a convenience function which simply creates a child anchor with `textBufferChildAnchorNew` and inserts it into the buffer with `textBufferInsertChildAnchor`.

textBufferGetIterAtChildAnchor

Arguments

:: TextBufferClass self |
=> self |
-> TextIter | `iter` - an iterator to be initialized
-> TextChildAnchor | `anchor` - a child anchor that appears in `buffer`
-> IO () |

Obtains the location of `anchor` within `buffer`.

textBufferPasteClipboard

Arguments

:: TextBufferClass self |
=> self |
-> Clipboard | `clipboard` - the GtkClipboard to paste from
-> TextIter | `location` - location to insert pasted text
-> Bool | `defaultEditable` - whether the buffer is editable by default
-> IO () |

Pastes the contents of a clipboard at the given `location`. (Note: pasting is asynchronous, that is, we'll ask for the paste data and return, and at some point later after the main loop runs, the paste data will be inserted.)

textBufferPasteClipboardAtCursor

Arguments

:: TextBufferClass self |
=> self |
-> Clipboard | `clipboard` - the GtkClipboard to paste from
-> Bool | `defaultEditable` - whether the buffer is editable by default
-> IO () |

Pastes the contents of a clipboard at the insertion point. (Note: pasting is asynchronous, that is, we'll ask for the paste data and return, and at some point later after the main loop runs, the paste data will be inserted.)

textBufferCopyClipboard

Arguments

:: TextBufferClass self |
=> self |
-> Clipboard | `clipboard` - the GtkClipboard object to copy to
-> IO () |

Copies the currently-selected text to a clipboard.

textBufferCutClipboard

Arguments

:: TextBufferClass self |
=> self |
-> Clipboard | `clipboard` - the GtkClipboard object to cut to
-> Bool | `defaultEditable` - whether the buffer is editable by default
-> IO () |

Copies the currently-selected text to a clipboard, then deletes said text if it's editable.

textBufferAddSelectionClipboard

Arguments

:: TextBufferClass self |
=> self |
-> Clipboard | `clipboard` - the `Clipboard` object to add
-> IO () |

Adds clipboard to the list of clipboards in which the selection contents of `self` are available. In most cases, `clipboard` will be the `Clipboard` of type `selectionPrimary` for a view of `self`.

textBufferRemoveSelectionClipboard

Arguments

:: TextBufferClass self |
=> self |
-> Clipboard | `clipboard` - the `Clipboard` object to remove
-> IO () |

Removes a `Clipboard` added with `textBufferAddSelectionClipboard`.

# Attributes

textBufferTagTable :: (TextBufferClass self, TextTagTableClass textTagTable) => ReadWriteAttr self TextTagTable textTagTable

Text Tag Table.

textBufferText :: TextBufferClass self => Attr self String

The text content of the buffer. Without child widgets and images, see `textBufferGetText` for more information.

Default value: ""

textBufferModified :: TextBufferClass self => Attr self Bool

The 'modified' property. See `textBufferGetModified` and `textBufferSetModified`

# Signals

applyTag :: TextBufferClass self => Signal self (TextTag -> TextIter -> TextIter -> IO ())

A `TextTag` was applied to a region of text.

beginUserAction :: TextBufferClass self => Signal self (IO ())

A new atomic user action is started.

- Together with `endUserAction` these signals can be used to build an undo stack.

bufferChanged :: TextBufferClass self => Signal self (IO ())

Emitted when the contents of the buffer change.

deleteRange :: TextBufferClass self => Signal self (TextIter -> TextIter -> IO ())

A range of text is about to be deleted.

endUserAction :: TextBufferClass self => Signal self (IO ())

An atomic action has ended.

- see `beginUserAction`

insertPixbuf :: TextBufferClass self => Signal self (TextIter -> Pixbuf -> IO ())

A `Pixbuf` is inserted into the buffer.

- See note in `bufferInsertText`.

insertChildAnchor :: TextBufferClass self => Signal self (TextIter -> TextChildAnchor -> IO ())

The `insertChildAnchor` signal is emitted to insert a `TextChildAnchor` in a `TextBuffer`. Insertion actually occurs in the default handler.

- See note in `bufferInsertText`.

bufferInsertText :: TextBufferClass self => Signal self (TextIter -> String -> IO ())

Some text is inserted. Insertion actually occurs in the default handler.

- The function connected to this handler may not modify the buffer since this would invalidate the iterator. If this function replaces the default handler, it needs to stop the emission of this signal in order to prevent the default handler from running. If additional text should be inserted, this can be done using the `after` function to connect.

markDeleted :: TextBufferClass self => Signal self (TextMark -> IO ())

A `TextMark` within the buffer was deleted.

markSet :: TextBufferClass self => Signal self (TextIter -> TextMark -> IO ())

A `TextMark` was inserted into the buffer.

modifiedChanged :: TextBufferClass self => Signal self (IO ())

pasteDone :: TextBufferClass self => Signal self (Clipboard -> IO ())

The `pasteDone` signal is emitted after paste operation has been completed. This is useful to properly scroll the view to the end of the pasted text. See `textBufferPasteClipboard` for more details.

removeTag :: TextBufferClass self => Signal self (TextTag -> TextIter -> TextIter -> IO ())

The textbuffer has changed.

# Deprecated

onApplyTag :: TextBufferClass self => self -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId self)

A `TextTag` was applied to a region of text.

afterApplyTag :: TextBufferClass self => self -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId self)

A `TextTag` was applied to a region of text.

onBeginUserAction :: TextBufferClass self => self -> IO () -> IO (ConnectId self)

A new atomic user action is started.

- Together with `onEndUserAction` these signals can be used to build an undo stack.

afterBeginUserAction :: TextBufferClass self => self -> IO () -> IO (ConnectId self)

A new atomic user action is started.

- Together with `onEndUserAction` these signals can be used to build an undo stack.

onBufferChanged :: TextBufferClass self => self -> IO () -> IO (ConnectId self)

Emitted when the contents of the buffer change.

afterBufferChanged :: TextBufferClass self => self -> IO () -> IO (ConnectId self)

Emitted when the contents of the buffer change.

onDeleteRange :: TextBufferClass self => self -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId self)

A range of text is about to be deleted.

afterDeleteRange :: TextBufferClass self => self -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId self)

A range of text is about to be deleted.

onEndUserAction :: TextBufferClass self => self -> IO () -> IO (ConnectId self)

An atomic action has ended.

- see `onBeginUserAction`

afterEndUserAction :: TextBufferClass self => self -> IO () -> IO (ConnectId self)

An atomic action has ended.

- see `onBeginUserAction`

onInsertPixbuf :: TextBufferClass self => self -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId self)

A `Pixbuf` is inserted into the buffer.

afterInsertPixbuf :: TextBufferClass self => self -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId self)

A `Pixbuf` is inserted into the buffer.

onBufferInsertText :: TextBufferClass self => self -> (TextIter -> String -> IO ()) -> IO (ConnectId self)

Some text was inserted.

afterBufferInsertText :: TextBufferClass self => self -> (TextIter -> String -> IO ()) -> IO (ConnectId self)

Some text was inserted.

onMarkDeleted :: TextBufferClass self => self -> (TextMark -> IO ()) -> IO (ConnectId self)

A `TextMark` within the buffer was deleted.

afterMarkDeleted :: TextBufferClass self => self -> (TextMark -> IO ()) -> IO (ConnectId self)

A `TextMark` within the buffer was deleted.

onMarkSet :: TextBufferClass self => self -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId self)

A `TextMark` was inserted into the buffer.

afterMarkSet :: TextBufferClass self => self -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId self)

A `TextMark` was inserted into the buffer.

onModifiedChanged :: TextBufferClass self => self -> IO () -> IO (ConnectId self)

The textbuffer has changed.

afterModifiedChanged :: TextBufferClass self => self -> IO () -> IO (ConnectId self)

The textbuffer has changed.

onRemoveTag :: TextBufferClass self => self -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId self)

A `TextTag` was removed.

afterRemoveTag :: TextBufferClass self => self -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId self)

A `TextTag` was removed.