Name

TextBuffer —

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

Synopsis

textBufferNew:: Maybe TextTagTable -> IO TextBuffer
textBufferApplyTag:: TextBufferClass tb => tb -> TextTag -> TextIter -> TextIter -> IO ()
textBufferApplyTagByName:: TextBufferClass tb => tb -> TagName -> TextIter -> TextIter -> IO ()
textBufferBeginUserAction:: TextBufferClass tb => tb -> IO ()
textBufferCreateMark:: TextBufferClass tb => tb -> Maybe MarkName -> TextIter -> Bool -> IO TextMark
textBufferDelete:: TextBufferClass tb => tb -> TextIter -> TextIter -> IO ()
textBufferDeleteInteractive:: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO Bool
textBufferDeleteMark:: TextBufferClass tb => tb -> TextMark -> IO ()
textBufferDeleteMarkByName:: TextBufferClass tb => tb -> MarkName -> IO ()
textBufferDeleteSelection:: TextBufferClass tb => tb -> Bool -> Bool -> IO Bool
textBufferEndUserAction:: TextBufferClass tb => tb -> IO ()
textBufferGetCharCount:: TextBufferClass tb => tb -> IO Int
textBufferGetEndIter:: TextBufferClass tb => tb -> IO TextIter
textBufferGetInsert:: TextBufferClass tb => tb -> IO TextMark
textBufferGetIterAtLine:: TextBufferClass tb => Int -> tb -> IO TextIter
textBufferGetIterAtLineOffset:: TextBufferClass tb => tb -> Int -> Int -> IO TextIter
textBufferGetIterAtMark:: TextBufferClass tb => tb -> TextMark -> IO TextIter
textBufferGetIterAtOffset:: TextBufferClass tb => tb -> Int -> IO TextIter
textBufferGetLineCount:: TextBufferClass tb => tb -> IO Int
textBufferGetMark:: TextBufferClass tb => tb -> MarkName -> IO (Maybe TextMark)
textBufferGetModified:: TextBufferClass tb => tb -> IO Bool
textBufferGetSelectionBound:: TextBufferClass tb => tb -> IO TextMark
textBufferGetSlice:: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO String
textBufferGetStartIter:: TextBufferClass tb => tb -> IO TextIter
textBufferGetTagTable:: TextBufferClass tb => tb -> IO TextTagTable
textBufferGetText:: TextBufferClass tb => tb -> TextIter -> TextIter -> Bool -> IO String
textBufferHasSelection:: TextBufferClass tb => tb -> IO Bool
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
textBufferInsertPixbuf:: TextBufferClass tb => tb -> TextIter -> Pixbuf -> IO ()
textBufferInsertRange:: TextBufferClass tb => tb -> TextIter -> TextIter -> TextIter -> IO ()
textBufferInsertRangeInteractive:: TextBufferClass tb => tb -> TextIter -> TextIter -> TextIter -> Bool -> IO Bool
textBufferMoveMark:: TextBufferClass tb => tb -> TextMark -> TextIter -> IO ()
textBufferMoveMarkByName:: TextBufferClass tb => tb -> MarkName -> TextIter -> IO ()
textBufferPlaceCursor:: TextBufferClass tb => tb -> TextIter -> IO ()
textBufferRemoveAllTags:: TextBufferClass tb => tb -> TextIter -> TextIter -> IO ()
textBufferRemoveTag:: TextBufferClass tb => tb -> TextTag -> TextIter -> TextIter -> IO ()
textBufferRemoveTagByName:: TextBufferClass tb => tb -> TagName -> TextIter -> TextIter -> IO ()
textBufferSetModified:: TextBufferClass tb => tb -> Bool -> IO ()
textBufferSetText:: TextBufferClass tb => tb -> String -> IO ()
onApplyTag:: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
onBeginUserAction:: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)

onChanged <no type information>

onDeleteRange:: TextBufferClass tb => tb -> (TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)
onEndUserAction:: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)

onInsertChildAnchor <no type information>

onInsertPixbuf:: TextBufferClass tb => tb -> (TextIter -> Pixbuf -> IO ()) -> IO (ConnectId tb)
onInsertText:: TextBufferClass tb => tb -> (TextIter -> String -> IO ()) -> IO (ConnectId tb)
onMarkDeleted:: TextBufferClass tb => tb -> (TextMark -> IO ()) -> IO (ConnectId tb)
onMarkSet:: TextBufferClass tb => tb -> (TextIter -> TextMark -> IO ()) -> IO (ConnectId tb)
onModifiedChanged:: TextBufferClass tb => tb -> IO () -> IO (ConnectId tb)
onRemoveTag:: TextBufferClass tb => tb -> (TextTag -> TextIter -> TextIter -> IO ()) -> IO (ConnectId tb)

Introduction

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

Constructors

textBufferNew

Create a new text buffer, possibly taking a table of TextTag.

textBufferNew:: Maybe TextTagTable:: IO TextBuffer
tt

Methods

textBufferApplyTag

Tag a range of text.

textBufferApplyTag:: tb:: TextTag:: TextIter:: TextIter:: IO ()
tbtagstartend

textBufferApplyTagByName

Apply a tag that is specified by name.

textBufferApplyTagByName:: tb:: TagName:: TextIter:: TextIter:: IO ()
tbtnamestartend

textBufferBeginUserAction

Start a new atomic user action.

textBufferBeginUserAction:: tb:: 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 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.

textBufferCreateMark

Create a TextMark from an iterator.

textBufferCreateMark:: tb:: Maybe MarkName:: TextIter:: Bool:: IO TextMark
tb(Just name)itergravity
tbNothingitergravity

Pass Nothing as mark name for an anonymous TextMark.

Set gravity to True if the mark should keep left.

textBufferDelete

Delete some text.

textBufferDelete:: tb:: TextIter:: TextIter:: IO ()
tbstartend

textBufferDeleteInteractive

Delete some text but obey editable and non-editable tags.

textBufferDeleteInteractive:: tb:: TextIter:: TextIter:: Bool:: IO Bool
tbstartenddef

textBufferDeleteMark

Delete a mark.

textBufferDeleteMark:: tb:: TextMark:: IO ()
tbtm

This renders the TextMark tm unusable forever.

textBufferDeleteMarkByName

Delete a mark by name.

textBufferDeleteMarkByName:: tb:: MarkName:: IO ()
tbname

The mark should exist (otherwise a nasty warning is generated).

textBufferDeleteSelection

Delete the current selection.

textBufferDeleteSelection:: tb:: Bool:: Bool:: IO Bool
tbinteractivedef

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.

textBufferEndUserAction

End an atomic user action.

textBufferEndUserAction:: tb:: IO ()

textBufferGetCharCount

Obtain the number of characters in the buffer.

textBufferGetCharCount:: tb:: IO Int
tb

Note that the comment in the Gtk+ documentation about bytes and chars does not hold because Haskell uses 31-bit characters and not UTF8.

textBufferGetEndIter

Create an iterator at the end of the buffer.

textBufferGetEndIter:: tb:: IO TextIter
tb

The iterator represents the position after the last character in the buffer.

textBufferGetInsert

Get the current cursor position.

textBufferGetInsert:: tb:: IO TextMark
tb

This is equivalent to liftM unJust $ textBufferGetMark "insert"

textBufferGetIterAtLine

Create an iterator at a specific line.

textBufferGetIterAtLine:: Int:: tb:: IO TextIter
linetb

The line arguments must be valid.

textBufferGetIterAtLineOffset

Create an iterator at a specific line and offset.

textBufferGetIterAtLineOffset:: tb:: Int:: Int:: IO TextIter
tblineoffset

The line and offset arguments must be valid.

textBufferGetIterAtMark

Create an iterator from a mark.

textBufferGetIterAtMark:: tb:: TextMark:: IO TextIter
tbtm

textBufferGetIterAtOffset

Create an iterator at a specific offset.

textBufferGetIterAtOffset:: tb:: Int:: IO TextIter
tboffset

The offset arguments must be valid, starting from the first character in the buffer.

textBufferGetLineCount

Obtain the number of lines in the buffer.

textBufferGetLineCount:: tb:: IO Int
tb

textBufferGetMark

Retrieve a TextMark by name.

textBufferGetMark:: tb:: MarkName:: IO (Maybe TextMark)
tbname

textBufferGetModified

Query if the buffer was modified.

textBufferGetModified:: tb:: IO Bool
tb

This flag is reset by calling textBufferSetModified.

It is usually more convenient to use onModifiedChanged.

textBufferGetSelectionBound

Get a TextMark for the other side of a selection.

textBufferGetSelectionBound:: tb:: IO TextMark
tb

textBufferGetSlice

Extract text and special characters between start and end.

textBufferGetSlice:: tb:: TextIter:: TextIter:: Bool:: IO String
tbstartendincl

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.

textBufferGetStartIter

Create an iterator at the beginning of the buffer.

textBufferGetStartIter:: tb:: IO TextIter
tb

textBufferGetTagTable

Extract the tag table that is associated with this text buffer.

textBufferGetTagTable:: tb:: IO TextTagTable
tb

textBufferGetText

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

textBufferGetText:: tb:: TextIter:: TextIter:: Bool:: IO String
tbstartendincl

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

textBufferHasSelection

Check if a selection exists.

textBufferHasSelection:: tb:: IO Bool
tb

textBufferInsert

Insert text at the position specified by the TextIter.

textBufferInsert:: tb:: TextIter:: String:: IO ()
tbiterstr

textBufferInsertAtCursor

Insert text at the cursor.

textBufferInsertAtCursor:: tb:: String:: IO ()
tbstr

textBufferInsertInteractive

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

textBufferInsertInteractive:: tb:: TextIter:: String:: Bool:: IO Bool
tbiterstrdef

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

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

textBufferInsertInteractiveAtCursor:: tb:: String:: Bool:: IO Bool
tbstrdef

textBufferInsertPixbuf

Insert an image into the TextBuffer.

textBufferInsertPixbuf:: tb:: TextIter:: Pixbuf:: IO ()
tbposimg

See textBufferGetSlice and textBufferGetText.

textBufferInsertRange

Copy text between the two TextIter start and end to another location ins.

textBufferInsertRange:: tb:: TextIter:: TextIter:: TextIter:: IO ()
tbinsstartend

textBufferInsertRangeInteractive

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

textBufferInsertRangeInteractive:: tb:: TextIter:: TextIter:: TextIter:: Bool:: IO Bool
tbinsstartenddef

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.

textBufferMoveMark

Move a mark.

textBufferMoveMark:: tb:: TextMark:: TextIter:: IO ()
tbtmiter

Emits "mark_set".

textBufferMoveMarkByName

Move a named mark.

textBufferMoveMarkByName:: tb:: MarkName:: TextIter:: IO ()
tbnameiter

The mark should exist (otherwise a nasty warning is generated).

textBufferPlaceCursor

Place the cursor.

textBufferPlaceCursor:: tb:: TextIter:: IO ()
tbiter

This is faster than moving the "insert" and the "selection_bound" marks in sequence since it avoids generating a transient selection.

textBufferRemoveAllTags

Remove all tags within a range.

textBufferRemoveAllTags:: tb:: TextIter:: TextIter:: IO ()
tbstartend

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.

textBufferRemoveTag

Remove a tag from a range of text.

textBufferRemoveTag:: tb:: TextTag:: TextIter:: TextIter:: IO ()
tbtagstartend

textBufferRemoveTagByName

Remove a tag from a range of text.

textBufferRemoveTagByName:: tb:: TagName:: TextIter:: TextIter:: IO ()
tbtnamestartend

textBufferSetModified

Set the "buffer-is-modified" flag.

textBufferSetModified:: tb:: Bool:: IO ()
tbisModified

textBufferSetText

Replace the text in the current TextBuffer.

textBufferSetText:: tb:: String:: IO ()
tbstr

Signals

onApplyTag

A TextTag was applied to a region of text.

onApplyTag:: tb:: (TextTag -> TextIter -> TextIter -> IO ()):: IO (ConnectId tb)

onBeginUserAction

A new atomic user action is started.

onBeginUserAction:: tb:: IO ():: IO (ConnectId tb)

Together with connectToEndUserAction these signals can be used to build an undo stack.

no type info on symbol onChanged

onDeleteRange

A range of text is about to be deleted.

onDeleteRange:: tb:: (TextIter -> TextIter -> IO ()):: IO (ConnectId tb)

onEndUserAction

An atomic action has ended.

onEndUserAction:: tb:: IO ():: IO (ConnectId tb)

see connectToBeginUserAction

no type info on symbol onInsertChildAnchor

onInsertPixbuf

A Pixbuf is inserted into the buffer.

onInsertPixbuf:: tb:: (TextIter -> Pixbuf -> IO ()):: IO (ConnectId tb)

onInsertText

Some text was inserted.

onInsertText:: tb:: (TextIter -> String -> IO ()):: IO (ConnectId tb)
tbuser

onMarkDeleted

A TextMark within the buffer was deleted.

onMarkDeleted:: tb:: (TextMark -> IO ()):: IO (ConnectId tb)

onMarkSet

A TextMark was inserted into the buffer.

onMarkSet:: tb:: (TextIter -> TextMark -> IO ()):: IO (ConnectId tb)

onModifiedChanged

The textbuffer has changed.

onModifiedChanged:: tb:: IO ():: IO (ConnectId tb)

onRemoveTag

A TextTag was removed.

onRemoveTag:: tb:: (TextTag -> TextIter -> TextIter -> IO ()):: IO (ConnectId tb)