Skip to main content

Type Alias: SourceBufferProps

SourceBufferProps = object

Defined in: nodes/source-buffer.ts:28

Props for the SourceBuffer virtual element.

Used to declaratively configure the text buffer for a GtkSourceView with syntax highlighting, bracket matching, and other source code editing features.

Example

<GtkSourceView>
<x.SourceBuffer
text={sourceCode}
language="typescript"
styleScheme="Adwaita-dark"
highlightSyntax
highlightMatchingBrackets
onTextChanged={(text) => console.log("Code:", text)}
/>
</GtkSourceView>

Properties

enableUndo?

optional enableUndo: boolean

Defined in: nodes/source-buffer.ts:32

Whether to enable undo/redo


highlightMatchingBrackets?

optional highlightMatchingBrackets: boolean

Defined in: nodes/source-buffer.ts:56

Whether to highlight matching brackets when cursor is on a bracket. Defaults to true.


highlightSyntax?

optional highlightSyntax: boolean

Defined in: nodes/source-buffer.ts:53

Whether to enable syntax highlighting. Defaults to true when language is set.


implicitTrailingNewline?

optional implicitTrailingNewline: boolean

Defined in: nodes/source-buffer.ts:62

Whether the buffer has an implicit trailing newline. When true (default), trailing newlines are handled automatically during file load/save.


language?

optional language: string | GtkSource.Language

Defined in: nodes/source-buffer.ts:44

Language for syntax highlighting. Can be a language ID string (e.g., "typescript", "python", "rust") or a GtkSource.Language object.


onCanRedoChanged()?

optional onCanRedoChanged: (canRedo) => void

Defined in: nodes/source-buffer.ts:38

Callback when can-redo state changes

Parameters

ParameterType
canRedoboolean

Returns

void


onCanUndoChanged()?

optional onCanUndoChanged: (canUndo) => void

Defined in: nodes/source-buffer.ts:36

Callback when can-undo state changes

Parameters

ParameterType
canUndoboolean

Returns

void


onCursorMoved()?

optional onCursorMoved: () => void

Defined in: nodes/source-buffer.ts:65

Callback when the cursor position changes

Returns

void


onHighlightUpdated()?

optional onHighlightUpdated: (start, end) => void

Defined in: nodes/source-buffer.ts:68

Callback when syntax highlighting is updated for a region

Parameters

ParameterType
startGtk.TextIter
endGtk.TextIter

Returns

void


onTextChanged()?

optional onTextChanged: (text) => void

Defined in: nodes/source-buffer.ts:34

Callback when the text content changes

Parameters

ParameterType
textstring

Returns

void


styleScheme?

optional styleScheme: string | GtkSource.StyleScheme

Defined in: nodes/source-buffer.ts:50

Style scheme for syntax highlighting colors. Can be a scheme ID string (e.g., "Adwaita-dark", "classic") or a GtkSource.StyleScheme object.


text?

optional text: string

Defined in: nodes/source-buffer.ts:30

Text content