Portability | portable (depends on GHC) |
---|---|
Stability | provisional |
Maintainer | gtk2hs-users@lists.sourceforge.net |
Safe Haskell | None |
- data SourceBuffer
- class TextBufferClass o => SourceBufferClass o
- castToSourceBuffer :: GObjectClass obj => obj -> SourceBuffer
- sourceBufferNew :: Maybe TextTagTable -> IO SourceBuffer
- sourceBufferNewWithLanguage :: SourceLanguage -> IO SourceBuffer
- sourceBufferSetHighlightSyntax :: SourceBufferClass buffer => buffer -> Bool -> IO ()
- sourceBufferGetHighlightSyntax :: SourceBufferClass buffer => buffer -> IO Bool
- sourceBufferSetLanguage :: SourceBufferClass buffer => buffer -> Maybe SourceLanguage -> IO ()
- sourceBufferGetLanguage :: SourceBufferClass buffer => buffer -> IO (Maybe SourceLanguage)
- sourceBufferSetHighlightMatchingBrackets :: SourceBufferClass buffer => buffer -> Bool -> IO ()
- sourceBufferGetHighlightMatchingBrackets :: SourceBufferClass buffer => buffer -> IO Bool
- sourceBufferSetStyleScheme :: SourceBufferClass buffer => buffer -> Maybe SourceStyleScheme -> IO ()
- sourceBufferGetStyleScheme :: SourceBufferClass buffer => buffer -> IO (Maybe SourceStyleScheme)
- sourceBufferSetMaxUndoLevels :: SourceBufferClass buffer => buffer -> Int -> IO ()
- sourceBufferGetMaxUndoLevels :: SourceBufferClass buffer => buffer -> IO Int
- sourceBufferGetCanUndo :: SourceBufferClass buffer => buffer -> IO Bool
- sourceBufferGetCanRedo :: SourceBufferClass buffer => buffer -> IO Bool
- sourceBufferUndo :: SourceBufferClass buffer => buffer -> IO ()
- sourceBufferRedo :: SourceBufferClass buffer => buffer -> IO ()
- sourceBufferBeginNotUndoableAction :: SourceBufferClass buffer => buffer -> IO ()
- sourceBufferEndNotUndoableAction :: SourceBufferClass buffer => buffer -> IO ()
- sourceBufferCreateSourceMark :: SourceBufferClass buffer => buffer -> Maybe String -> String -> TextIter -> IO SourceMark
- sourceBufferGetSourceMarksAtLine :: SourceBufferClass buffer => buffer -> Int -> String -> IO [SourceMark]
- sourceBufferGetSourceMarksAtIter :: SourceBufferClass buffer => buffer -> TextIter -> String -> IO [SourceMark]
- sourceBufferRemoveSourceMarks :: SourceBufferClass buffer => buffer -> TextIter -> TextIter -> String -> IO ()
- sourceBufferForwardIterToSourceMark :: SourceBufferClass buffer => buffer -> TextIter -> String -> IO Bool
- sourceBufferBackwardIterToSourceMark :: SourceBufferClass buffer => buffer -> TextIter -> String -> IO Bool
- sourceBufferEnsureHighlight :: SourceBufferClass buffer => buffer -> TextIter -> TextIter -> IO ()
- sourceBufferCanRedo :: SourceBufferClass buffer => ReadAttr buffer Bool
- sourceBufferCanUndo :: SourceBufferClass buffer => ReadAttr buffer Bool
- sourceBufferHighlightMatchingBrackets :: SourceBufferClass buffer => Attr buffer Bool
- sourceBufferHighlightSyntax :: SourceBufferClass buffer => Attr buffer Bool
- sourceBufferLanguage :: SourceBufferClass buffer => Attr buffer (Maybe SourceLanguage)
- sourceBufferSourceStyleScheme :: SourceBufferClass buffer => Attr buffer (Maybe SourceStyleScheme)
- sourceBufferMaxUndoLevels :: SourceBufferClass buffer => Attr buffer Int
- sourceBufferUndoManager :: SourceBufferClass buffer => Attr buffer SourceUndoManager
- sourceBufferHighlightUpdated :: SourceBufferClass buffer => Signal buffer (TextIter -> TextIter -> IO ())
- sourceBufferRedoSignal :: SourceBufferClass buffer => Signal buffer (IO ())
- sourceBufferUndoSignal :: SourceBufferClass buffer => Signal buffer (IO ())
- sourceBufferSourceMarkUpdated :: SourceBufferClass buffer => Signal buffer (TextMark -> IO ())
Description
The SourceBuffer
object is the model for SourceView
widgets. It extends the TextBuffer
object by adding features useful to display and edit source code as syntax highlighting and bracket
matching. It also implements support for undo/redo operations.
To create a SourceBuffer
use sourceBufferNew
or
sourceBufferNewWithLanguage
. The second form is just a convenience function which allows
you to initially set a SourceLanguage
.
By default highlighting is enabled, but you can disable it with
sourceBufferSetHighlightSyntax
.
Types
data SourceBuffer Source
Methods
castToSourceBuffer :: GObjectClass obj => obj -> SourceBufferSource
sourceBufferNew :: Maybe TextTagTable -> IO SourceBufferSource
Create a new SourceBuffer
, possibly
taking a TextTagTable
.
sourceBufferNewWithLanguage :: SourceLanguage -> IO SourceBufferSource
Create a new SourceBuffer
with a SourceLanguage
.
sourceBufferSetHighlightSyntaxSource
:: SourceBufferClass buffer | |
=> buffer |
|
-> Bool |
|
-> IO () |
Controls whether syntax is highlighted in the buffer. If highlight is True
, the text will be
highlighted according to the syntax patterns specified in the language set with
sourceBufferSetLanguage
. If highlight is False
, syntax highlighting is disabled and all the
TextTag
objects that have been added by the syntax highlighting engine are removed from the
buffer.
sourceBufferGetHighlightSyntaxSource
:: SourceBufferClass buffer | |
=> buffer | |
-> IO Bool | returns |
Determines whether syntax highlighting is activated in the source buffer.
:: SourceBufferClass buffer | |
=> buffer | |
-> Maybe SourceLanguage |
|
-> IO () |
Associate a SourceLanguage
with the source buffer. If language is not-Nothing
and syntax
highlighting is enabled (see sourceBufferSetHighlightSyntax
, the syntax patterns defined
in language will be used to highlight the text contained in the buffer. If language is Nothing
, the
text contained in the buffer is not highlighted.
:: SourceBufferClass buffer | |
=> buffer | |
-> IO (Maybe SourceLanguage) | returns |
Returns the SourceLanguage
associated with the buffer, see sourceBufferSetLanguage
.
sourceBufferSetHighlightMatchingBracketsSource
:: SourceBufferClass buffer | |
=> buffer | |
-> Bool |
|
-> IO () |
Controls the bracket match highlighting function in the buffer. If activated, when you position your
cursor over a bracket character (a parenthesis, a square bracket, etc.) the matching opening or
closing bracket character will be highlighted. You can specify the style with the
sourceBufferSetBracketMatchStyle
function.
sourceBufferGetHighlightMatchingBracketsSource
:: SourceBufferClass buffer | |
=> buffer | |
-> IO Bool | returns |
Determines whether bracket match highlighting is activated for the source buffer.
sourceBufferSetStyleSchemeSource
:: SourceBufferClass buffer | |
=> buffer | |
-> Maybe SourceStyleScheme |
|
-> IO () |
Sets style scheme used by the buffer. If scheme is Nothing
no style scheme is used.
sourceBufferGetStyleSchemeSource
:: SourceBufferClass buffer | |
=> buffer | |
-> IO (Maybe SourceStyleScheme) | returns the |
Returns the SourceStyleScheme
currently used in buffer.
sourceBufferSetMaxUndoLevelsSource
:: SourceBufferClass buffer | |
=> buffer | |
-> Int |
|
-> IO () |
Sets the number of undo levels for user actions the buffer will track. If the number of user actions exceeds the limit set by this function, older actions will be discarded.
If maxUndoLevels
is -1, no limit is set.
A new action is started whenever the function textBufferBeginUserAction
is called. In
general, this happens whenever the user presses any key which modifies the buffer, but the undo
manager will try to merge similar consecutive actions, such as multiple character insertions into
one action. But, inserting a newline does start a new action.
sourceBufferGetMaxUndoLevelsSource
:: SourceBufferClass buffer | |
=> buffer | |
-> IO Int | returns the maximum number of possible undo levels or -1 if no limit is set. |
Determines the number of undo levels the buffer will track for buffer edits.
:: SourceBufferClass buffer | |
=> buffer | |
-> IO Bool | returns |
Determines whether a source buffer can undo the last action.
:: SourceBufferClass buffer | |
=> buffer | |
-> IO Bool | returns |
Determines whether a source buffer can redo the last action (i.e. if the last operation was an undo).
sourceBufferUndo :: SourceBufferClass buffer => buffer -> IO ()Source
Undoes the last user action which modified the buffer. Use sourceBufferCanUndo
to check
whether a call to this function will have any effect.
Actions are defined as groups of operations between a call to textBufferBeginUserAction
and textBufferEndUserAction
on the
same line.
sourceBufferRedo :: SourceBufferClass buffer => buffer -> IO ()Source
Redoes the last undo operation. Use sourceBufferCanRedo
to check whether a call to this
function will have any effect.
sourceBufferBeginNotUndoableAction :: SourceBufferClass buffer => buffer -> IO ()Source
Marks the beginning of a not undoable action on the buffer, disabling the undo manager. Typically you would call this function before initially setting the contents of the buffer (e.g. when loading a file in a text editor).
You may nest sourceBufferBeginNotUndoableAction
/
sourceBufferEndNotUndoableAction
blocks.
sourceBufferEndNotUndoableAction :: SourceBufferClass buffer => buffer -> IO ()Source
Marks the end of a not undoable action on the buffer. When the last not undoable block is closed through the call to this function, the list of undo actions is cleared and the undo manager is re-enabled.
sourceBufferCreateSourceMark :: SourceBufferClass buffer => buffer -> Maybe String -> String -> TextIter -> IO SourceMarkSource
Creates a marker in the buffer of the given type.
- A marker is
semantically very similar to a
TextMark
, except it has a type which is used by theSourceView
displaying the buffer to show a pixmap on the left margin, at the line the marker is in. Because of this, a marker is generally associated to a line and not a character position. Markers are also accessible through a position or range in the buffer. - Markers are implemented using
TextMark
, so all characteristics and restrictions to marks apply to markers too. These includes life cycle issues andonMarkSet
andonMarkDeleted
signal emissions. - Like a
TextMark
, aSourceMarker
can be anonymous if the passed name isNothing
. Also, the buffer owns the markers so you shouldn't unreference it.
sourceBufferGetSourceMarksAtLineSource
:: SourceBufferClass buffer | |
=> buffer |
|
-> Int |
|
-> String |
|
-> IO [SourceMark] |
Returns the list of marks of the given category at line. If category is empty, all marks at line are returned.
sourceBufferGetSourceMarksAtIterSource
:: SourceBufferClass buffer | |
=> buffer |
|
-> TextIter |
|
-> String |
|
-> IO [SourceMark] |
Returns the list of marks of the given category at iter. If category is empty it returns all marks at iter.
sourceBufferRemoveSourceMarksSource
:: SourceBufferClass buffer | |
=> buffer |
|
-> TextIter |
|
-> TextIter |
|
-> String |
|
-> IO () |
Remove all marks of category between start and end from the buffer. If category is empty, all marks in the range will be removed.
sourceBufferForwardIterToSourceMarkSource
:: SourceBufferClass buffer | |
=> buffer |
|
-> TextIter |
|
-> String |
|
-> IO Bool | returns whether iter moved. |
Moves iter to the position of the next SourceMark
of the given category. Returns True
if iter was
moved. If category is empty, the next source mark can be of any category.
sourceBufferBackwardIterToSourceMarkSource
:: SourceBufferClass buffer | |
=> buffer |
|
-> TextIter |
|
-> String |
|
-> IO Bool | returns whether iter moved. |
Moves iter to the position of the previous SourceMark
of the given category. Returns True
if iter
was moved. If category is empty, the previous source mark can be of any category.
sourceBufferEnsureHighlightSource
:: SourceBufferClass buffer | |
=> buffer | |
-> TextIter |
|
-> TextIter |
|
-> IO () |
Forces buffer to analyze and highlight the given area synchronously.
Note
This is a potentially slow operation and should be used only when you need to make sure that some text not currently visible is highlighted, for instance before printing.
Attributes
sourceBufferCanRedo :: SourceBufferClass buffer => ReadAttr buffer BoolSource
Whether Redo operation is possible.
Default value: False
sourceBufferCanUndo :: SourceBufferClass buffer => ReadAttr buffer BoolSource
Whether Undo operation is possible.
Default value: False
sourceBufferHighlightMatchingBrackets :: SourceBufferClass buffer => Attr buffer BoolSource
Whether to highlight matching brackets in the buffer.
Default value: True
sourceBufferHighlightSyntax :: SourceBufferClass buffer => Attr buffer BoolSource
Whether to highlight syntax in the buffer.
Default value: True
sourceBufferLanguage :: SourceBufferClass buffer => Attr buffer (Maybe SourceLanguage)Source
Language object to get highlighting patterns from.
sourceBufferSourceStyleScheme :: SourceBufferClass buffer => Attr buffer (Maybe SourceStyleScheme)Source
Style scheme. It contains styles for syntax highlighting, optionally foreground, background, cursor color, current line color, and matching brackets style.
sourceBufferMaxUndoLevels :: SourceBufferClass buffer => Attr buffer IntSource
Number of undo levels for the buffer. -1 means no limit. This property will only affect the default undo manager.
Allowed values: >= GMaxulong
Default value: 1000
sourceBufferUndoManager :: SourceBufferClass buffer => Attr buffer SourceUndoManagerSource
The buffer undo manager.
Signals
sourceBufferHighlightUpdated :: SourceBufferClass buffer => Signal buffer (TextIter -> TextIter -> IO ())Source
sourceBufferRedoSignal :: SourceBufferClass buffer => Signal buffer (IO ())Source
sourceBufferUndoSignal :: SourceBufferClass buffer => Signal buffer (IO ())Source
sourceBufferSourceMarkUpdated :: SourceBufferClass buffer => Signal buffer (TextMark -> IO ())Source
The sourceBufferMarkUpdated
signal is emitted each time a mark is added to, moved or removed from the
buffer.