Gtk2HsContentsIndex
Graphics.UI.Gtk.Multiline.TextBuffer
Description

This storage object holds text to be displayed by one or more TextView widgets.

  • See "Text Widget Overview" in the Gtk+ docs.
  • The following convenience functions are omitted: gtk_text_buffer_insert_with_tags gtk_text_buffer_insert_with_tags_by_name gtk_text_buffer_create_tag gtk_text_buffer_get_bounds gtk_text_buffer_get_selection_bounds
  • The following functions do not make sense due to Haskell's wide character representation of Unicode: gtk_text_buffer_get_iter_at_line_index
  • The function gtk_text_buffer_get_selection_bounds is only used to test if there is a selection (see textBufferHasSelection).

TODO

  • The functionality of inserting widgets (child anchors) is not implemented since there will probably some changes before the final release. The following functions are not bound: gtk_text_buffer_insert_child_anchor gtk_text_buffer_create_child_anchor gtk_text_buffer_get_iter_at_anchor connectToInsertChildAnchor
  • Check textBufferGetInsert, in case there is no cursor in the editor, is there a mark called "insert"? If not, the function needs to return Maybe TextMark. The same holds for textBufferGetSelectionBound.
  • If Clipboards are bound, then these functions need to be bound as well: gtk_text_buffer_paste_clipboard gtk_text_buffer_copy_clipboard gtk_text_buffer_cut_clipboard gtk_text_buffer_add_selection_clipboard gtk_text_buffer_remove_selection_clipboard
Synopsis
data TextBuffer
class GObjectClass o => TextBufferClass o
castToTextBuffer :: GObjectClass obj => obj -> TextBuffer
textBufferNew :: Maybe TextTagTable -> IO TextBuffer
textBufferGetLineCount :: TextBufferClass tb => tb -> IO Int
textBufferGetCharCount :: TextBufferClass tb => tb -> IO Int
textBufferGetTagTable :: TextBufferClass tb => tb -> IO TextTagTable
textBufferInsert :: TextBufferClass tb => tb -> TextIter -> String -> IO ()
textBufferInsertAtCursor :: TextBufferClass tb => tb -> String -> IO ()
textBufferInsertInteractive :: TextBufferClass tb => tb -> TextIter -> String -> Bool -> IO Bool
textBufferInsertInteractiveAtCursor :: TextBufferClass tb => tb -> String -> Bool -> IO Bool
textBufferInsertRange :: TextBufferClass tb => tb -> TextIter -> TextIter -> TextIter -> IO ()
textBufferInsertRangeInteractive :: TextBufferClass tb => tb -> TextIter -> TextIter -> TextIter -> Bool -> IO Bool
textBufferDelete :: TextBufferClass tb => tb -> TextIter -> TextIter -> IO ()
textBufferDeleteInteractive :: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO Bool
textBufferSetText :: TextBufferClass tb => tb -> String -> IO ()
textBufferGetText :: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO String
textBufferGetSlice :: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO String
textBufferInsertPixbuf :: TextBufferClass tb => tb -> TextIter -> Pixbuf -> IO ()
textBufferCreateMark :: TextBufferClass tb => tb -> Maybe MarkName -> TextIter -> Bool -> IO TextMark
textBufferMoveMark :: TextBufferClass tb => tb -> TextMark -> TextIter -> IO ()
textBufferMoveMarkByName :: TextBufferClass tb => tb -> MarkName -> TextIter -> IO ()
textBufferDeleteMark :: TextBufferClass tb => tb -> TextMark -> IO ()
textBufferDeleteMarkByName :: TextBufferClass tb => tb -> MarkName -> IO ()
textBufferGetMark :: TextBufferClass tb => tb -> MarkName -> IO (Maybe TextMark)
textBufferGetInsert :: TextBufferClass tb => tb -> IO TextMark
textBufferGetSelectionBound :: TextBufferClass tb => tb -> IO TextMark
textBufferPlaceCursor :: TextBufferClass tb => tb -> TextIter -> IO ()
textBufferApplyTag :: TextBufferClass tb => tb -> TextTag -> TextIter -> TextIter -> IO ()
textBufferRemoveTag :: TextBufferClass tb => tb -> TextTag -> TextIter -> TextIter -> IO ()
textBufferApplyTagByName :: TextBufferClass tb => tb -> TagName -> TextIter -> TextIter -> IO ()
textBufferRemoveTagByName :: TextBufferClass tb => tb -> TagName -> TextIter -> TextIter -> IO ()
textBufferRemoveAllTags :: TextBufferClass tb => tb -> TextIter -> TextIter -> IO ()
textBufferGetIterAtLineOffset :: TextBufferClass tb => tb -> Int -> Int -> IO TextIter
textBufferGetIterAtOffset :: TextBufferClass tb => tb -> Int -> IO TextIter
textBufferGetIterAtLine :: TextBufferClass tb => Int -> tb -> IO TextIter
textBufferGetIterAtMark :: TextBufferClass tb => tb -> TextMark -> IO TextIter
textBufferGetStartIter :: TextBufferClass tb => tb -> IO TextIter
textBufferGetEndIter :: TextBufferClass tb => tb -> IO TextIter
textBufferGetModified :: TextBufferClass tb => tb -> IO Bool
textBufferSetModified :: TextBufferClass tb => tb -> Bool -> IO ()
textBufferDeleteSelection :: TextBufferClass tb => tb -> Bool -> Bool -> IO Bool
textBufferHasSelection :: TextBufferClass tb => tb -> IO Bool
textBufferBeginUserAction :: TextBufferClass tb => tb -> IO ()
textBufferEndUserAction :: TextBufferClass tb => tb -> IO ()
onApplyTag :: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
afterApplyTag :: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
onBeginUserAction :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
afterBeginUserAction :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onBufferChanged :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
afterBufferChanged :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onDeleteRange :: TextBufferClass tb => tb -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
afterDeleteRange :: TextBufferClass tb => tb -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
onEndUserAction :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
afterEndUserAction :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onInsertPixbuf :: TextBufferClass tb => tb -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId tb)
afterInsertPixbuf :: TextBufferClass tb => tb -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId tb)
onInsertText :: TextBufferClass tb => tb -> (TextIter -> String -> IO ()) -> IO (ConnectId tb)
afterInsertText :: TextBufferClass tb => tb -> (TextIter -> String -> IO ()) -> IO (ConnectId tb)
onMarkDeleted :: TextBufferClass tb => tb -> (TextMark -> IO ()) -> IO (ConnectId tb)
afterMarkDeleted :: TextBufferClass tb => tb -> (TextMark -> IO ()) -> IO (ConnectId tb)
onMarkSet :: TextBufferClass tb => tb -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId tb)
afterMarkSet :: TextBufferClass tb => tb -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId tb)
onModifiedChanged :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
afterModifiedChanged :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onRemoveTag :: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
afterRemoveTag :: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
Documentation
data TextBuffer
Instances
TextBufferClass TextBuffer
GObjectClass TextBuffer
class GObjectClass o => TextBufferClass o
Instances
TextBufferClass SourceBuffer
TextBufferClass TextBuffer
castToTextBuffer :: GObjectClass obj => obj -> TextBuffer
textBufferNew :: Maybe TextTagTable -> IO TextBuffer
Create a new text buffer, possibly taking a table of TextTag.
textBufferGetLineCount :: TextBufferClass tb => tb -> IO Int
Obtain the number of lines in the buffer.
textBufferGetCharCount :: TextBufferClass tb => tb -> IO Int

Obtain the number of characters in the buffer.

  • Note that the comment in the Gtk+ documentation about bytes and chars does not hold because Haskell uses 31-bit characters and not UTF8.
textBufferGetTagTable :: TextBufferClass tb => tb -> IO TextTagTable
Extract the tag table that is associated with this text buffer.
textBufferInsert :: TextBufferClass tb => tb -> TextIter -> String -> IO ()
Insert text at the position specified by the TextIter.
textBufferInsertAtCursor :: TextBufferClass tb => tb -> String -> IO ()
Insert text at the cursor.
textBufferInsertInteractive :: TextBufferClass tb => tb -> TextIter -> String -> Bool -> IO Bool

Insert text at the TextIter only if a normal user would be able to do so as well.

  • Insert the text obeying special editable or non-editable Tags.
  • 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.
textBufferInsertInteractiveAtCursor :: TextBufferClass tb => tb -> String -> Bool -> IO Bool
Insert text at cursor only if a normal user would be able to do so as well.
textBufferInsertRange :: TextBufferClass tb => tb -> TextIter -> TextIter -> TextIter -> IO ()
Copy text between the two TextIter start and end to another location ins.
textBufferInsertRangeInteractive :: TextBufferClass tb => tb -> TextIter -> TextIter -> TextIter -> Bool -> IO Bool

Copy text as textBufferInsertRange does, but obey editable and non-editable tags.

  • Insert the text obeying special editable or non-editable Tags.
  • 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.
textBufferDelete :: TextBufferClass tb => tb -> TextIter -> TextIter -> IO ()
Delete some text.
textBufferDeleteInteractive :: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO Bool
Delete some text but obey editable and non-editable tags.
textBufferSetText :: TextBufferClass tb => tb -> String -> IO ()
Replace the text in the current TextBuffer.
textBufferGetText :: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO String

Extract all the text between start and end from a TextBuffer.

  • The start position is included, end is not.
  • If incl is True, text tagged with the invisible attribute is also returned.
  • Characters representing embedded images are not included. (So offsets within the returned text are different from the Buffer itself.)
textBufferGetSlice :: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO String

Extract text and special characters between start and end.

  • As opposed to textBufferGetText, this function returns (chr 0xFFFC) for images, so offsets within the returned string correspond to offsets in the TextBuffer. Note the (chr 0xFFFC) can occur in normal text without images as well.
textBufferInsertPixbuf :: TextBufferClass tb => tb -> TextIter -> Pixbuf -> IO ()

Insert an image into the TextBuffer.

textBufferCreateMark :: TextBufferClass tb => tb -> Maybe MarkName -> TextIter -> Bool -> IO TextMark

Create a TextMark from an iterator.

  • Pass Nothing as mark name for an anonymous TextMark.
  • Set gravity to True if the mark should keep left.
textBufferMoveMark :: TextBufferClass tb => tb -> TextMark -> TextIter -> IO ()

Move a mark.

  • Emits "mark_set".
textBufferMoveMarkByName :: TextBufferClass tb => tb -> MarkName -> TextIter -> IO ()

Move a named mark.

  • The mark should exist (otherwise a nasty warning is generated).
textBufferDeleteMark :: TextBufferClass tb => tb -> TextMark -> IO ()

Delete a mark.

  • This renders the TextMark tm unusable forever.
textBufferDeleteMarkByName :: TextBufferClass tb => tb -> MarkName -> IO ()

Delete a mark by name.

  • The mark should exist (otherwise a nasty warning is generated).
textBufferGetMark :: TextBufferClass tb => tb -> MarkName -> IO (Maybe TextMark)
Retrieve a TextMark by name.
textBufferGetInsert :: TextBufferClass tb => tb -> IO TextMark

Get the current cursor position.

  • This is equivalent to liftM unJust $ textBufferGetMark "insert"
textBufferGetSelectionBound :: TextBufferClass tb => tb -> IO TextMark
Get a TextMark for the other side of a selection.
textBufferPlaceCursor :: TextBufferClass tb => tb -> TextIter -> IO ()

Place the cursor.

  • This is faster than moving the "insert" and the "selection_bound" marks in sequence since it avoids generating a transient selection.
textBufferApplyTag :: TextBufferClass tb => tb -> TextTag -> TextIter -> TextIter -> IO ()
Tag a range of text.
textBufferRemoveTag :: TextBufferClass tb => tb -> TextTag -> TextIter -> TextIter -> IO ()
Remove a tag from a range of text.
textBufferApplyTagByName :: TextBufferClass tb => tb -> TagName -> TextIter -> TextIter -> IO ()
Apply a tag that is specified by name.
textBufferRemoveTagByName :: TextBufferClass tb => tb -> TagName -> TextIter -> TextIter -> IO ()
Remove a tag from a range of text.
textBufferRemoveAllTags :: TextBufferClass tb => tb -> TextIter -> TextIter -> IO ()

Remove all tags within a range.

  • 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 :: TextBufferClass tb => tb -> Int -> Int -> IO TextIter

Create an iterator at a specific line and offset.

  • The line and offset arguments must be valid.
textBufferGetIterAtOffset :: TextBufferClass tb => tb -> Int -> IO TextIter

Create an iterator at a specific offset.

  • The offset arguments must be valid, starting from the first character in the buffer.
textBufferGetIterAtLine :: TextBufferClass tb => Int -> tb -> IO TextIter

Create an iterator at a specific line.

  • The line arguments must be valid.
textBufferGetIterAtMark :: TextBufferClass tb => tb -> TextMark -> IO TextIter
Create an iterator from a mark.
textBufferGetStartIter :: TextBufferClass tb => tb -> IO TextIter
Create an iterator at the beginning of the buffer.
textBufferGetEndIter :: TextBufferClass tb => tb -> IO TextIter

Create an iterator at the end of the buffer.

  • The iterator represents the position after the last character in the buffer.
textBufferGetModified :: TextBufferClass tb => tb -> IO Bool

Query if the buffer was modified.

  • This flag is reset by calling textBufferSetModified.
  • It is usually more convenient to use "connectToModifiedChanged".
textBufferSetModified :: TextBufferClass tb => tb -> Bool -> IO ()
Set the "buffer-is-modified" flag.
textBufferDeleteSelection :: TextBufferClass tb => tb -> Bool -> Bool -> IO Bool

Delete the current selection.

  • The interactive flag determines if this function is invoked on behalf of the user (i.e. if we honour editable/non-editable tags).
  • See textBufferInsertAtCursor for information on def.
  • The function returns True if a non-empty selection was deleted.
textBufferHasSelection :: TextBufferClass tb => tb -> IO Bool
Check if a selection exists.
textBufferBeginUserAction :: TextBufferClass tb => tb -> IO ()

Start a new atomic user action.

  • 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 objects maintains a count of calls to textBufferBeginUserAction that have not been closed with a call to textBufferEndUserAction, and emits the "begin_user_action" and "end_user_action" 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 tb => tb -> IO ()
End an atomic user action.
onApplyTag :: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
A TextTag was applied to a region of text.
afterApplyTag :: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
onBeginUserAction :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)

A new atomic user action is started.

  • Together with connectToEndUserAction these signals can be used to build an undo stack.
afterBeginUserAction :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onBufferChanged :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
Emitted when the contents of the buffer change.
afterBufferChanged :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onDeleteRange :: TextBufferClass tb => tb -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
A range of text is about to be deleted.
afterDeleteRange :: TextBufferClass tb => tb -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
onEndUserAction :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)

An atomic action has ended.

  • see connectToBeginUserAction
afterEndUserAction :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onInsertPixbuf :: TextBufferClass tb => tb -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId tb)

A widgets is inserted into the buffer. connectToInsertChildAnchor :: TextBufferClass tb => (TextIter -> TextChildAnchor -> IO ()) -> ConnectAfter -> tb -> IO (ConnectId tb) connectToInsertChildAnchor = connect_BOXED_OBJECT__NONE insert_child_anchor mkTextIter

A Pixbuf is inserted into the buffer.

afterInsertPixbuf :: TextBufferClass tb => tb -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId tb)
onInsertText :: TextBufferClass tb => tb -> (TextIter -> String -> IO ()) -> IO (ConnectId tb)
Some text was inserted.
afterInsertText :: TextBufferClass tb => tb -> (TextIter -> String -> IO ()) -> IO (ConnectId tb)
onMarkDeleted :: TextBufferClass tb => tb -> (TextMark -> IO ()) -> IO (ConnectId tb)
A TextMark within the buffer was deleted.
afterMarkDeleted :: TextBufferClass tb => tb -> (TextMark -> IO ()) -> IO (ConnectId tb)
onMarkSet :: TextBufferClass tb => tb -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId tb)
A TextMark was inserted into the buffer.
afterMarkSet :: TextBufferClass tb => tb -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId tb)
onModifiedChanged :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
The textbuffer has changed.
afterModifiedChanged :: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onRemoveTag :: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
A TextTag was removed.
afterRemoveTag :: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
Produced by Haddock version 0.6