Maintainer | gtk2hs-users@lists.sourceforge.net |
---|---|
Stability | provisional |
Portability | portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell98 |
An iterator is an abstract datatype representing a pointer into a
TextBuffer
.
- data TextIter
- data TextSearchFlags
- textIterCopy :: TextIter -> IO TextIter
- textIterGetBuffer :: TextIter -> IO TextBuffer
- textIterGetOffset :: TextIter -> IO Int
- textIterGetLine :: TextIter -> IO Int
- textIterGetLineOffset :: TextIter -> IO Int
- textIterGetVisibleLineOffset :: TextIter -> IO Int
- textIterGetChar :: TextIter -> IO (Maybe Char)
- textIterGetSlice :: GlibString string => TextIter -> TextIter -> IO string
- textIterGetText :: GlibString string => TextIter -> TextIter -> IO string
- textIterGetVisibleSlice :: GlibString string => TextIter -> TextIter -> IO string
- textIterGetVisibleText :: GlibString string => TextIter -> TextIter -> IO string
- textIterGetPixbuf :: TextIter -> IO (Maybe Pixbuf)
- textIterGetChildAnchor :: TextIter -> IO (Maybe TextChildAnchor)
- textIterGetMarks :: TextIter -> IO [TextMark]
- textIterGetToggledTags :: TextIter -> Bool -> IO [TextTag]
- textIterBeginsTag :: TextIter -> Maybe TextTag -> IO Bool
- textIterEndsTag :: TextIter -> Maybe TextTag -> IO Bool
- textIterTogglesTag :: TextIter -> Maybe TextTag -> IO Bool
- textIterHasTag :: TextIter -> Maybe TextTag -> IO Bool
- textIterGetTags :: TextIter -> IO [TextTag]
- textIterEditable :: TextIter -> Bool -> IO Bool
- textIterCanInsert :: TextIter -> Bool -> IO Bool
- textIterStartsWord :: TextIter -> IO Bool
- textIterEndsWord :: TextIter -> IO Bool
- textIterInsideWord :: TextIter -> IO Bool
- textIterStartsLine :: TextIter -> IO Bool
- textIterEndsLine :: TextIter -> IO Bool
- textIterStartsSentence :: TextIter -> IO Bool
- textIterEndsSentence :: TextIter -> IO Bool
- textIterInsideSentence :: TextIter -> IO Bool
- textIterIsCursorPosition :: TextIter -> IO Bool
- textIterGetCharsInLine :: TextIter -> IO Int
- textIterGetAttributes :: TextIter -> TextAttributes -> IO Bool
- textIterGetLanguage :: TextIter -> IO Language
- textIterIsEnd :: TextIter -> IO Bool
- textIterIsStart :: TextIter -> IO Bool
- textIterForwardChar :: TextIter -> IO Bool
- textIterBackwardChar :: TextIter -> IO Bool
- textIterForwardChars :: TextIter -> Int -> IO Bool
- textIterBackwardChars :: TextIter -> Int -> IO Bool
- textIterForwardLine :: TextIter -> IO Bool
- textIterBackwardLine :: TextIter -> IO Bool
- textIterForwardLines :: TextIter -> Int -> IO Bool
- textIterBackwardLines :: TextIter -> Int -> IO Bool
- textIterForwardWordEnds :: TextIter -> Int -> IO Bool
- textIterBackwardWordStarts :: TextIter -> Int -> IO Bool
- textIterForwardWordEnd :: TextIter -> IO Bool
- textIterBackwardWordStart :: TextIter -> IO Bool
- textIterForwardCursorPosition :: TextIter -> IO Bool
- textIterBackwardCursorPosition :: TextIter -> IO Bool
- textIterForwardCursorPositions :: TextIter -> Int -> IO Bool
- textIterBackwardCursorPositions :: TextIter -> Int -> IO Bool
- textIterForwardSentenceEnds :: TextIter -> Int -> IO Bool
- textIterBackwardSentenceStarts :: TextIter -> Int -> IO Bool
- textIterForwardSentenceEnd :: TextIter -> IO Bool
- textIterBackwardSentenceStart :: TextIter -> IO Bool
- textIterSetOffset :: TextIter -> Int -> IO ()
- textIterSetLine :: TextIter -> Int -> IO ()
- textIterSetLineOffset :: TextIter -> Int -> IO ()
- textIterSetVisibleLineOffset :: TextIter -> Int -> IO ()
- textIterForwardToEnd :: TextIter -> IO ()
- textIterForwardToLineEnd :: TextIter -> IO Bool
- textIterForwardToTagToggle :: TextIter -> Maybe TextTag -> IO Bool
- textIterBackwardToTagToggle :: TextIter -> Maybe TextTag -> IO Bool
- textIterForwardFindChar :: TextIter -> (Char -> Bool) -> Maybe TextIter -> IO Bool
- textIterBackwardFindChar :: TextIter -> (Char -> Bool) -> Maybe TextIter -> IO Bool
- textIterForwardSearch :: GlibString string => TextIter -> string -> [TextSearchFlags] -> Maybe TextIter -> IO (Maybe (TextIter, TextIter))
- textIterBackwardSearch :: GlibString string => TextIter -> string -> [TextSearchFlags] -> Maybe TextIter -> IO (Maybe (TextIter, TextIter))
- textIterEqual :: TextIter -> TextIter -> IO Bool
- textIterCompare :: TextIter -> TextIter -> IO Ordering
- textIterInRange :: TextIter -> TextIter -> TextIter -> IO Bool
- textIterOrder :: TextIter -> TextIter -> IO ()
- textIterForwardVisibleLine :: TextIter -> IO Bool
- textIterBackwardVisibleLine :: TextIter -> IO Bool
- textIterForwardVisibleLines :: TextIter -> Int -> IO Bool
- textIterBackwardVisibleLines :: TextIter -> Int -> IO Bool
- textIterForwardVisibleWordEnds :: TextIter -> Int -> IO Bool
- textIterBackwardVisibleWordStarts :: TextIter -> Int -> IO Bool
- textIterForwardVisibleWordEnd :: TextIter -> IO Bool
- textIterBackwardVisibleWordStart :: TextIter -> IO Bool
- textIterForwardVisibleCursorPosition :: TextIter -> IO Bool
- textIterBackwardVisibleCursorPosition :: TextIter -> IO Bool
- textIterForwardVisibleCursorPositions :: TextIter -> Int -> IO Bool
- textIterBackwardVisibleCursorPositions :: TextIter -> Int -> IO Bool
- textIterVisibleLineOffset :: Attr TextIter Int
- textIterOffset :: Attr TextIter Int
- textIterLineOffset :: Attr TextIter Int
- textIterLine :: Attr TextIter Int
Types
data TextSearchFlags Source
Specify the way the search function for
TextBuffer
works.
Methods
textIterCopy :: TextIter -> IO TextIter Source
Copy the iterator.
textIterGetBuffer :: TextIter -> IO TextBuffer Source
Return the TextBuffer
this iterator
is associated with.
textIterGetOffset :: TextIter -> IO Int Source
Returns the character offset of an iterator. Each character in a
TextBuffer
has an offset, starting with 0 for the first character in the
buffer. Use textBufferGetIterAtOffset
to convert an offset back into an iterator.
textIterGetLine :: TextIter -> IO Int Source
Returns the line number containing the iterator. Lines in a TextBuffer
are numbered beginning with 0 for the first line in the buffer.
textIterGetLineOffset :: TextIter -> IO Int Source
Returns the character offset of the iterator, counting from the start of a newline-terminated line. The first character on the line has offset 0.
textIterGetVisibleLineOffset :: TextIter -> IO Int Source
Returns the offset in characters from the start of the line to the given
iter
, not counting characters that are invisible due to tags with the
"invisible" flag toggled on.
textIterGetChar :: TextIter -> IO (Maybe Char) Source
Returns the Unicode character at this iterator.
If the element at this iterator is a non-character
element, such as an image embedded in the buffer, the Unicode "unknown"
character 0xFFFC is returned. If invoked on the end iterator,
Nothigng
is returned.
textIterGetSlice :: GlibString string => TextIter -> TextIter -> IO string Source
Returns the text in the given range. A "slice" is a list of characters, including the Unicode "unknown" character 0xFFFC for iterable non-character elements in the buffer, such as images. Because images are encoded in the slice, offsets in the returned array will correspond to offsets in the text buffer. Note that 0xFFFC can occur in normal text as well, so it is not a reliable indicator that a pixbuf or widget is in the buffer.
textIterGetText :: GlibString string => TextIter -> TextIter -> IO string Source
Return the text in a given range.
- Pictures (and other objects) are stripped form the output. Thus, this function does not preserve offsets.
textIterGetVisibleSlice :: GlibString string => TextIter -> TextIter -> IO string Source
Like textIterGetSlice
, but invisible text is not included. Invisible
text is usually invisible because a TextTag
with the "invisible"
attribute turned on has been applied to it.
textIterGetVisibleText :: GlibString string => TextIter -> TextIter -> IO string Source
Like textIterGetText
, but invisible text is not included. Invisible
text is usually invisible because a TextTag
with the "invisible"
attribute turned on has been applied to it.
textIterGetChildAnchor :: TextIter -> IO (Maybe TextChildAnchor) Source
If the location at iter
contains a child anchor,
the anchor is returned (with no new reference count added).
Otherwise, Nothing
is returned.
Returns a list of all TextMark
at this location. Because marks are not
iterable (they don't take up any "space" in the buffer, they are just
marks in between iterable locations), multiple marks can exist in the same
place. The returned list is not in any meaningful order.
:: TextIter | |
-> Bool |
|
-> IO [TextTag] | returns tags toggled at this point |
Returns a list of TextTag
that are toggled on or off at this point. (If
toggledOn
is True
, the list contains tags that are toggled on.) If a tag
is toggled on at iter
, then some non-empty range of characters following
iter
has that tag applied to it. If a tag is toggled off, then some
non-empty range following iter
does not have the tag applied to it.
textIterBeginsTag :: TextIter -> Maybe TextTag -> IO Bool Source
Returns True
if tag
is toggled on at exactly this point. If tag
is
Nothing
,
returns True
if any tag is toggled on at this point. Note that the
textIterBeginsTag
returns True
if iter
is the start of the tagged
range; textIterHasTag
tells you whether an iterator is within a tagged
range.
textIterEndsTag :: TextIter -> Maybe TextTag -> IO Bool Source
Returns True
if tag
is toggled off at exactly this point. If tag
is
Notihng
,
returns True
if any tag is toggled off at this point. Note that the
textIterEndsTag
returns True
if iter
is the end of the tagged range;
textIterHasTag
tells you whether an iterator is within a tagged range.
textIterTogglesTag :: TextIter -> Maybe TextTag -> IO Bool Source
Query if the TextIter
is at the
beginning or the end of a TextTag
. This is equivalent to
(textIterBeginsTag
|| textIterEndsTag
), i.e. it
tells you whether a range with tag
applied to it begins or ends at
iter
.
textIterHasTag :: TextIter -> Maybe TextTag -> IO Bool Source
Check if TextIter
is within a range
tagged with tag.
Returns a list of tags that apply to iter
, in ascending order of
priority (highest-priority tags are last).
textIterEditable :: TextIter -> Bool -> IO Bool Source
Returns whether the character at iter
is within an editable region of
text. Non-editable text is "locked" and can't be changed by the user via
TextView
. This function is simply a convenience wrapper around
textIterGetAttributes
. If no tags applied to this text affect editability,
defaultSetting
will be returned.
You don't want to use this function to decide whether text can be
inserted at iter
, because for insertion you don't want to know whether the
char at iter
is inside an editable range, you want to know whether a new
character inserted at iter
would be inside an editable range. Use
textIterCanInsert
to handle this case.
textIterCanInsert :: TextIter -> Bool -> IO Bool Source
Check if new text can be inserted at TextIter
.
- Considering the default editability of the buffer, and tags that affect
editability, determines whether text inserted at
iter
would be editable. If text inserted atiter
would be editable then the user should be allowed to insert text atiter
.textBufferInsertInteractive
uses this function to decide whether insertions are allowed at a given position. - Use
textBufferInsertInteractive
if you want to insert text depending on the current editable status.
textIterStartsWord :: TextIter -> IO Bool Source
Determine if TextIter
begins a new
natural-language word.
textIterEndsWord :: TextIter -> IO Bool Source
Determine if TextIter
ends a new
natural-language word.
textIterEndsLine :: TextIter -> IO Bool Source
Returns True
if iter
points to the start of the paragraph delimiter
characters for a line (delimiters will be either a newline, a carriage
return, a carriage return followed by a newline, or a Unicode paragraph
separator character). Note that an iterator pointing to the n of a rn
pair will not be counted as the end of a line, the line ends before the r.
The end iterator is considered to be at the end of a line, even though there
are no paragraph delimiter chars there.
textIterIsCursorPosition :: TextIter -> IO Bool Source
Determine if TextIter
is at a
cursor position.
textIterGetCharsInLine :: TextIter -> IO Int Source
Return number of characters in this line.
- The return value includes delimiters.
textIterGetAttributes :: TextIter -> TextAttributes -> IO Bool Source
Computes the effect of any tags applied to this spot in the text.
The values parameter should be initialized to the default settings you wish to use if no tags are in effect.
You'd typically obtain the defaults from textViewGetDefaultAttributes
.
textIterGetAttributes
will modify values, applying the effects of any tags present at iter.
If any tags affected values, the function returns True
.
textIterGetLanguage :: TextIter -> IO Language Source
A convenience wrapper around textIterGetAttributes
, which returns the language in effect at iter.
If no tags affecting language apply to iter, the return value is identical to that of getDefaultLanguage
.
textIterIsStart :: TextIter -> IO Bool Source
Determine if TextIter
is at the
beginning of the buffer.
textIterForwardChar :: TextIter -> IO Bool Source
Move TextIter
forwards.
- Retuns True if the iterator is pointing to a character.
textIterBackwardChar :: TextIter -> IO Bool Source
Move TextIter
backwards.
- Retuns True if the movement was possible.
textIterForwardChars :: TextIter -> Int -> IO Bool Source
Move TextIter
forwards by
n
characters.
- Retuns
True
if the iterator is pointing to a new character (andFalse
if the iterator points to a picture or has not moved). - Note that images embedded
in the buffer occupy 1 character slot, so
textIterForwardChar
may actually move onto an image instead of a character.
textIterBackwardChars :: TextIter -> Int -> IO Bool Source
Move TextIter
backwards by
n
characters.
- Retuns
True
if the iterator is pointing to a new character (andFalse
if the iterator points to a picture or has not moved).
textIterForwardLine :: TextIter -> IO Bool Source
textIterBackwardLine :: TextIter -> IO Bool Source
textIterForwardWordEnds :: TextIter -> Int -> IO Bool Source
Move TextIter
forwards by
n
word ends.
- Retuns True if the iterator is pointing to a new word end.
textIterBackwardWordStarts :: TextIter -> Int -> IO Bool Source
Move TextIter
backwards by
n
word beginnings.
- Retuns True if the iterator is pointing to a new word start.
textIterForwardWordEnd :: TextIter -> IO Bool Source
Move TextIter
forwards to the
next word end.
- Retuns True if the iterator has moved to a new word end.
textIterBackwardWordStart :: TextIter -> IO Bool Source
Move TextIter
backwards to
the next word beginning.
- Retuns True if the iterator has moved to a new word beginning.
textIterForwardSentenceEnds :: TextIter -> Int -> IO Bool Source
Move TextIter
forwards by
n
sentence ends.
- Retuns True if the iterator is pointing to a new sentence end.
textIterBackwardSentenceStarts :: TextIter -> Int -> IO Bool Source
Move TextIter
backwards
by n
sentence beginnings.
- Retuns True if the iterator is pointing to a new sentence start.
textIterForwardSentenceEnd :: TextIter -> IO Bool Source
Move TextIter
forwards to
the next sentence end.
- Retuns True if the iterator has moved to a new sentence end.
textIterBackwardSentenceStart :: TextIter -> IO Bool Source
Move TextIter
backwards
to the next sentence beginning.
- Retuns True if the iterator has moved to a new sentence beginning.
textIterSetLine :: TextIter -> Int -> IO () Source
Set TextIter
to a line within the
buffer.
- If number is negative or larger than the number of lines in the buffer,
moves
iter
to the start of the last line in the buffer.
textIterSetLineOffset :: TextIter -> Int -> IO () Source
Set TextIter
to an offset within the line.
- The given character offset must be less than or equal to the number of characters in the line; if equal, the iterator moves to the start of the next line.
textIterSetVisibleLineOffset :: TextIter -> Int -> IO () Source
Like textIterSetLineOffset
, but the offset is in visible characters,
i.e. text with a tag making it invisible is not counted in the offset.
textIterForwardToEnd :: TextIter -> IO () Source
Moves iter
forward to the "end iterator," which points one past the
last valid character in the buffer.
textIterForwardToLineEnd :: TextIter -> IO Bool Source
Moves the iterator to point to the paragraph delimiter characters, which
will be either a newline, a carriage return, a carriage return/newline in
sequence, or the Unicode paragraph separator character. If the iterator is
already at the paragraph delimiter characters, moves to the paragraph
delimiter characters for the next line. If iter
is on the last line in the
buffer, which does not end in paragraph delimiters, moves to the end
iterator (end of the last line), and returns False
.
textIterForwardFindChar :: TextIter -> (Char -> Bool) -> Maybe TextIter -> IO Bool Source
Move TextIter
forward until a
predicate function returns True.
- If
pred
returns True beforelimit
is reached, the search is stopped and the return value is True. - If
limit
is Nothing, the search stops at the end of the buffer.
textIterBackwardFindChar :: TextIter -> (Char -> Bool) -> Maybe TextIter -> IO Bool Source
Move TextIter
backward until a
predicate function returns True.
- If
pred
returns True beforelimit
is reached, the search is stopped and the return value is True. - If
limit
is Nothing, the search stops at the end of the buffer.
textIterForwardSearch :: GlibString string => TextIter -> string -> [TextSearchFlags] -> Maybe TextIter -> IO (Maybe (TextIter, TextIter)) Source
Search forward for a specific string.
- If specified, the last character which is tested against that start of
the search pattern will be
limit
. TextSearchFlags
may be empty.- Returns the start and end position of the string found.
textIterBackwardSearch :: GlibString string => TextIter -> string -> [TextSearchFlags] -> Maybe TextIter -> IO (Maybe (TextIter, TextIter)) Source
Search backward for a specific string.
- If specified, the last character which is tested against that start of
the search pattern will be
limit
. TextSearchFlags
my be empty.- Returns the start and end position of the string found.
:: TextIter | |
-> TextIter |
|
-> TextIter |
|
-> IO Bool |
|
Checks whether iter falls in the range [start, end). start and end must be in ascending order.
textIterOrder :: TextIter -> TextIter -> IO () Source
Swaps the value of first and second if second comes before first in the buffer.
That is, ensures that first and second are in sequence.
Most text buffer functions that take a range call this automatically on your behalf, so there's no real reason to call it yourself in those cases.
There are some exceptions, such as textIterInRange
, that expect a pre-sorted range.
textIterForwardVisibleLine Source
Moves iter
to the start of the next visible line. Returns True
if
there was a next line to move to, and False
if iter
was simply moved to
the end of the buffer and is now not dereferenceable, or if iter
was
already at the end of the buffer.
- Available since Gtk+ version 2.8
textIterBackwardVisibleLine Source
Moves iter
to the start of the previous visible line. Returns True
if
iter
could be moved; i.e. if iter
was at character offset 0, this
function returns False
. Therefore if iter
was already on line 0, but not
at the start of the line, iter
is snapped to the start of the line and the
function returns True
. (Note that this implies that in a loop calling this
function, the line number may not change on every iteration, if your first
iteration is on line 0.)
- Available since Gtk+ version 2.8
textIterForwardVisibleLines Source
:: TextIter | |
-> Int |
|
-> IO Bool | returns whether |
Moves count
visible lines forward, if possible (if count
would move
past the start or end of the buffer, moves to the start or end of the
buffer). The return value indicates whether the iterator moved onto a
dereferenceable position; if the iterator didn't move, or moved onto the end
iterator, then False
is returned. If count
is 0, the function does
nothing and returns False
. If count
is negative, moves backward by 0 -
count
lines.
- Available since Gtk+ version 2.8
textIterBackwardVisibleLines Source
:: TextIter | |
-> Int |
|
-> IO Bool | returns whether |
Moves count
visible lines backward, if possible (if count
would move
past the start or end of the buffer, moves to the start or end of the
buffer). The return value indicates whether the iterator moved onto a
dereferenceable position; if the iterator didn't move, or moved onto the end
iterator, then False
is returned. If count
is 0, the function does
nothing and returns False
. If count
is negative, moves forward by 0 -
count
lines.
- Available since Gtk+ version 2.8
textIterForwardVisibleWordEnds Source
:: TextIter | |
-> Int |
|
-> IO Bool | return |
Calls textIterForwardVisibleWordEnd
up to count times.
textIterBackwardVisibleWordStarts Source
:: TextIter | |
-> Int |
|
-> IO Bool | return |
Calls textIterBackwardVisibleWordStart
up to count times.
textIterForwardVisibleWordEnd Source
Moves forward to the next visible word end. (If iter is currently on a word end, moves forward to the next one after that.) Word breaks are determined by Pango and should be correct for nearly any language (if not, the correct fix would be to the Pango word break algorithms).
textIterBackwardVisibleWordStart Source
Moves backward to the previous visible word start. (If iter is currently on a word start, moves backward to the next one after that.) Word breaks are determined by Pango and should be correct for nearly any language (if not, the correct fix would be to the Pango word break algorithms).
textIterForwardVisibleCursorPosition Source
Moves iter forward to the next visible cursor position.
See textIterForwardCursorPosition
for details.
textIterBackwardVisibleCursorPosition Source
Moves iter forward to the previous visible cursor position.
See textIterBackwardCursorPosition
for details.
textIterForwardVisibleCursorPositions Source
:: TextIter | |
-> Int |
|
-> IO Bool | return |
Moves up to count visible cursor positions.
See textIterForwardCursorPosition
for details.
textIterBackwardVisibleCursorPositions Source
:: TextIter | |
-> Int |
|
-> IO Bool | return |
Moves up to count visible cursor positions.
See textIterBackwardCursorPosition
for details.
Attributes
textIterVisibleLineOffset :: Attr TextIter Int Source
'visibleLineOffset' property. See textIterGetVisibleLineOffset
and
textIterSetVisibleLineOffset
textIterOffset :: Attr TextIter Int Source
'offset' property. See textIterGetOffset
and textIterSetOffset
textIterLineOffset :: Attr TextIter Int Source
'lineOffset' property. See textIterGetLineOffset
and
textIterSetLineOffset
textIterLine :: Attr TextIter Int Source
'line' property. See textIterGetLine
and textIterSetLine