Class View
- All Implemented Interfaces:
Proxy
,Accessible
,AccessibleText
,Buildable
,ConstraintTarget
,Scrollable
- Direct Known Subclasses:
Map
TextView
.
GtkSourceView
is the main class of the GtkSourceView library.
Use a Buffer
to display text with a GtkSourceView
.
This class provides:
- Show the line numbers;
- Show a right margin;
- Highlight the current line;
- Indentation settings;
- Configuration for the Home and End keyboard keys;
- Configure and show line marks;
- And a few other things.
An easy way to test all these features is to use the test-widget mini-program provided in the GtkSourceView repository, in the tests/ directory.
GtkSourceView as GtkBuildable
The GtkSourceView implementation of the Buildable
interface exposes the
View:completion
object with the internal-child "completion".
An example of a UI definition fragment with GtkSourceView:
<object class="GtkSourceView" id="source_view">
<property name="tab-width">4</property>
<property name="auto-indent">True</property>
<child internal-child="completion">
<object class="GtkSourceCompletion">
<property name="select-on-show">False</property>
</object>
</child>
</object>
Changing the Font
Gtk CSS provides the best way to change the font for a GtkSourceView
in a
manner that allows for components like Map
to scale the desired
font.
GtkCssProvider *provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"textview { font-family: Monospace; font-size: 8pt; }",
-1,
NULL);
gtk_style_context_add_provider (gtk_widget_get_style_context (view),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
If you need to adjust the font or size of font within a portion of the
document only, you should use a TextTag
with the Gtk.TextTag:family
or
Gtk.TextTag:scale
set so that the font size may be scaled relative to
the default font set in CSS.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
View.Builder<B extends View.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theChangeCaseCallback
callback.static interface
Functional interface declaration of theChangeNumberCallback
callback.static interface
Functional interface declaration of theJoinLinesCallback
callback.static interface
Functional interface declaration of theLineMarkActivatedCallback
callback.static interface
Functional interface declaration of theMoveLinesCallback
callback.static interface
Functional interface declaration of theMoveToMatchingBracketCallback
callback.static interface
Functional interface declaration of theMoveWordsCallback
callback.static interface
Functional interface declaration of thePushSnippetCallback
callback.static interface
Functional interface declaration of theShowCompletionCallback
callback.static interface
Functional interface declaration of theSmartHomeEndCallback
callback.static class
Nested classes/interfaces inherited from class org.gnome.gtk.TextView
TextView.BackspaceCallback, TextView.CopyClipboardCallback, TextView.CutClipboardCallback, TextView.DeleteFromCursorCallback, TextView.ExtendSelectionCallback, TextView.InsertAtCursorCallback, TextView.InsertEmojiCallback, TextView.MoveCursorCallback, TextView.MoveViewportCallback, TextView.PasteClipboardCallback, TextView.PreeditChangedCallback, TextView.SelectAllCallback, TextView.SetAnchorCallback, TextView.TextViewClass, TextView.ToggleCursorVisibleCallback, TextView.ToggleOverwriteCallback
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.AccessibleText
AccessibleText.AccessibleTextImpl, AccessibleText.AccessibleTextInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Scrollable
Scrollable.ScrollableImpl, Scrollable.ScrollableInterface
-
Constructor Summary
ConstructorDescriptionView()
Creates a newGtkSourceView
.View
(MemorySegment address) Create a View proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected View
asParent()
Returns this instance as if it were its parent type.static View.Builder
<? extends View.Builder> builder()
AView.Builder
object constructs aView
with the specified properties.void
emitChangeCase
(ChangeCaseType caseType) Emits the "change-case" signal.void
emitChangeNumber
(int count) Emits the "change-number" signal.void
Emits the "join-lines" signal.void
emitLineMarkActivated
(TextIter iter, int button, Set<ModifierType> state, int nPresses) Emits the "line-mark-activated" signal.void
emitMoveLines
(boolean down) Emits the "move-lines" signal.void
emitMoveToMatchingBracket
(boolean extendSelection) Emits the "move-to-matching-bracket" signal.void
emitMoveWords
(int count) Emits the "move-words" signal.void
emitPushSnippet
(Snippet snippet, TextIter location) Emits the "push-snippet" signal.void
Emits the "show-completion" signal.void
emitSmartHomeEnd
(TextIter iter, int count) Emits the "smart-home-end" signal.boolean
Returns whether auto-indentation of text is enabled.Returns theGtkSourceBackgroundPatternType
specifying if and how the background pattern should be displayed for this this View.Gets theCompletion
associated with this View.boolean
Gets theView:enable-snippets
property.getGutter
(TextWindowType windowType) Returns theGutter
object associated withwindowType
for this View.boolean
Returns whether the current line is highlighted.getHover()
Gets theHover
associated with this View.Gets theView:indenter
property.boolean
Returns whether when the tab key is pressed the current selection should get indented instead of replaced with the\\t
character.int
Returns the number of spaces to use for each step of indent.boolean
Returns whether when inserting a tabulator character it should be replaced by a group of space characters.getMarkAttributes
(String category, MemorySegment priority) Gets attributes and priority for thecategory
.static MemoryLayout
The memory layout of the native struct.int
Gets the position of the right margin in the given this View.boolean
Returns whether line marks are displayed beside the text.boolean
Returns whether line numbers are displayed beside the text.boolean
Returns whether a right margin is displayed.boolean
Returnstrue
if pressing the Backspace key will try to delete spaces up to the previous tab stop.Returns aSmartHomeEndType
end value specifying how the cursor will move when HOME and END keys are pressed.Gets theSpaceDrawer
associated with this View.int
Returns the width of tabulation in characters.static Type
getType()
Get the GType of the View classint
getVisualColumn
(TextIter iter) Determines the visual column atiter
taking into consideration theView:tab-width
of this View.void
indentLines
(TextIter start, TextIter end) Inserts one indentation level at the beginning of the specified lines.protected void
lineMarkActivated
(TextIter iter, int button, Set<ModifierType> state, int nPresses) protected void
moveLines
(boolean down) protected void
moveWords
(int step) onChangeCase
(View.ChangeCaseCallback handler) Keybinding signal to change case of the text at the current cursor position.onChangeNumber
(View.ChangeNumberCallback handler) Keybinding signal to edit a number at the current cursor position.onJoinLines
(View.JoinLinesCallback handler) Keybinding signal to join the lines currently selected.Emitted when a line mark has been activated (for instance when there was a button press in the line marks gutter).onMoveLines
(View.MoveLinesCallback handler) The signal is a keybinding which gets emitted when the user initiates moving a line.Keybinding signal to move the cursor to the matching bracket.onMoveWords
(View.MoveWordsCallback handler) The signal is a keybinding which gets emitted when the user initiates moving a word.onPushSnippet
(View.PushSnippetCallback handler) The signal is emitted to insert a new snippet into the view.The signal is a key binding signal which gets emitted when the user requests a completion, by pressing <keycombo><keycap>Control</keycap><keycap>space</keycap></keycombo>.onSmartHomeEnd
(View.SmartHomeEndCallback handler) Emitted when a the cursor was moved according to the smart home end setting.void
pushSnippet
(Snippet snippet, @Nullable TextIter location) Inserts a new snippet atlocation
void
setAutoIndent
(boolean enable) Iftrue
auto-indentation of text is enabled.void
setBackgroundPattern
(BackgroundPatternType backgroundPattern) Set if and how the background pattern should be displayed.void
setEnableSnippets
(boolean enableSnippets) Sets theView:enable-snippets
property.void
setHighlightCurrentLine
(boolean highlight) Ifhighlight
istrue
the current line will be highlighted.void
setIndenter
(@Nullable Indenter indenter) Sets the indenter for this View toindenter
.void
setIndentOnTab
(boolean enable) Iftrue
, when the tab key is pressed when several lines are selected, the selected lines are indented of one level instead of being replaced with a\\t
character.void
setIndentWidth
(int width) Sets the number of spaces to use for each step of indent when the tab key is pressed.void
setInsertSpacesInsteadOfTabs
(boolean enable) Iftrue
a tab key pressed is replaced by a group of space characters.void
setMarkAttributes
(String category, MarkAttributes attributes, int priority) Sets attributes and priority for thecategory
.void
setRightMarginPosition
(int pos) Sets the position of the right margin in the given this View.void
setShowLineMarks
(boolean show) Iftrue
line marks will be displayed beside the text.void
setShowLineNumbers
(boolean show) Iftrue
line numbers will be displayed beside the text.void
setShowRightMargin
(boolean show) Iftrue
a right margin is displayed.void
setSmartBackspace
(boolean smartBackspace) When set totrue
, pressing the Backspace key will try to delete spaces up to the previous tab stop.void
setSmartHomeEnd
(SmartHomeEndType smartHomeEnd) Set the desired movement of the cursor when HOME and END keys are pressed.void
setTabWidth
(int width) Sets the width of tabulation in characters.protected void
void
unindentLines
(TextIter start, TextIter end) Removes one indentation level at the beginning of the specified lines.static View
withBuffer
(Buffer buffer) Creates a newGtkSourceView
widget displaying the bufferbuffer
.Methods inherited from class org.gnome.gtk.TextView
addChildAtAnchor, addOverlay, backspace, backwardDisplayLine, backwardDisplayLineStart, bufferToWindowCoords, copyClipboard, createBuffer, cutClipboard, deleteFromCursor, emitBackspace, emitCopyClipboard, emitCutClipboard, emitDeleteFromCursor, emitExtendSelection, emitInsertAtCursor, emitInsertEmoji, emitMoveCursor, emitMoveViewport, emitPasteClipboard, emitPreeditChanged, emitSelectAll, emitSetAnchor, emitToggleCursorVisible, emitToggleOverwrite, extendSelection, forwardDisplayLine, forwardDisplayLineEnd, getAcceptsTab, getBottomMargin, getBuffer, getCursorLocations, getCursorVisible, getEditable, getExtraMenu, getIndent, getInputHints, getInputPurpose, getIterAtLocation, getIterAtPosition, getIterLocation, getJustification, getLeftMargin, getLineAtY, getLineYrange, getLtrContext, getMonospace, getOverwrite, getPixelsAboveLines, getPixelsBelowLines, getPixelsInsideWrap, getRightMargin, getRtlContext, getTabs, getTopMargin, getVisibleRect, getWrapMode, imContextFilterKeypress, insertAtCursor, insertEmoji, moveCursor, moveMarkOnscreen, moveOverlay, moveVisually, onBackspace, onCopyClipboard, onCutClipboard, onDeleteFromCursor, onExtendSelection, onInsertAtCursor, onInsertEmoji, onMoveCursor, onMoveViewport, onPasteClipboard, onPreeditChanged, onSelectAll, onSetAnchor, onToggleCursorVisible, onToggleOverwrite, pasteClipboard, placeCursorOnscreen, remove, resetCursorBlink, resetImContext, scrollMarkOnscreen, scrollToIter, scrollToMark, setAcceptsTab, setAnchor, setBottomMargin, setBuffer, setCursorVisible, setEditable, setExtraMenu, setGutter, setIndent, setInputHints, setInputHints, setInputPurpose, setJustification, setLeftMargin, setMonospace, setOverwrite, setPixelsAboveLines, setPixelsBelowLines, setPixelsInsideWrap, setRightMargin, setTabs, setTopMargin, setWrapMode, snapshotLayer, startsDisplayLine, toggleOverwrite, windowToBufferCoords, withBuffer
Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.AccessibleText
updateCaretPosition, updateContents, updateSelectionBound
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.gtk.Scrollable
getBorder, getHadjustment, getHscrollPolicy, getVadjustment, getVscrollPolicy, setHadjustment, setHscrollPolicy, setVadjustment, setVscrollPolicy
-
Constructor Details
-
View
Create a View proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
View
public View()Creates a newGtkSourceView
.By default, an empty
Buffer
will be lazily created and can be retrieved withTextView.getBuffer()
.If you want to specify your own buffer, either override the
TextView.createBuffer()
factory method, or usewithBuffer(org.gnome.gtksourceview.Buffer)
.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
withBuffer
-
getAutoIndent
public boolean getAutoIndent()Returns whether auto-indentation of text is enabled.- Returns:
true
if auto indentation is enabled.
-
getBackgroundPattern
Returns theGtkSourceBackgroundPatternType
specifying if and how the background pattern should be displayed for this this View.- Returns:
- the
GtkSourceBackgroundPatternType
.
-
getCompletion
Gets theCompletion
associated with this View.The returned object is guaranteed to be the same for the lifetime of this View. Each
GtkSourceView
object has a differentCompletion
.- Returns:
- the
GtkSourceCompletion
associated with this View.
-
getEnableSnippets
public boolean getEnableSnippets()Gets theView:enable-snippets
property.If
true
, matching snippets found in theSnippetManager
may be expanded when the user presses Tab after a word in theView
.- Returns:
true
if enabled
-
getGutter
Returns theGutter
object associated withwindowType
for this View.Only
TextWindowType.LEFT
andTextWindowType.RIGHT
are supported, respectively corresponding to the left and right gutter. The line numbers and mark category icons are rendered in the left gutter. -
getHighlightCurrentLine
public boolean getHighlightCurrentLine()Returns whether the current line is highlighted.- Returns:
true
if the current line is highlighted.
-
getHover
-
getIndentOnTab
public boolean getIndentOnTab()Returns whether when the tab key is pressed the current selection should get indented instead of replaced with the\\t
character.- Returns:
true
if the selection is indented when tab is pressed.
-
getIndentWidth
public int getIndentWidth()Returns the number of spaces to use for each step of indent.See
setIndentWidth(int)
for details.- Returns:
- indent width.
-
getIndenter
-
getInsertSpacesInsteadOfTabs
public boolean getInsertSpacesInsteadOfTabs()Returns whether when inserting a tabulator character it should be replaced by a group of space characters.- Returns:
true
if spaces are inserted instead of tabs.
-
getMarkAttributes
Gets attributes and priority for thecategory
.- Parameters:
category
- the category.priority
- place where priority of the category will be stored.- Returns:
GtkSourceMarkAttributes
for thecategory
. The object belongs to this View, so it must not be unreffed.
-
getRightMarginPosition
public int getRightMarginPosition()Gets the position of the right margin in the given this View.- Returns:
- the position of the right margin.
-
getShowLineMarks
public boolean getShowLineMarks()Returns whether line marks are displayed beside the text.- Returns:
true
if the line marks are displayed.
-
getShowLineNumbers
public boolean getShowLineNumbers()Returns whether line numbers are displayed beside the text.- Returns:
true
if the line numbers are displayed.
-
getShowRightMargin
public boolean getShowRightMargin()Returns whether a right margin is displayed.- Returns:
true
if the right margin is shown.
-
getSmartBackspace
public boolean getSmartBackspace()Returnstrue
if pressing the Backspace key will try to delete spaces up to the previous tab stop.- Returns:
true
if smart Backspace handling is enabled.
-
getSmartHomeEnd
Returns aSmartHomeEndType
end value specifying how the cursor will move when HOME and END keys are pressed.- Returns:
- a
GtkSourceSmartHomeEndType
value.
-
getSpaceDrawer
Gets theSpaceDrawer
associated with this View.The returned object is guaranteed to be the same for the lifetime of this View. Each
View
object has a differentSpaceDrawer
.- Returns:
- the
GtkSourceSpaceDrawer
associated with this View.
-
getTabWidth
public int getTabWidth()Returns the width of tabulation in characters.- Returns:
- width of tab.
-
getVisualColumn
Determines the visual column atiter
taking into consideration theView:tab-width
of this View.- Parameters:
iter
- a position in this View.- Returns:
- the visual column at
iter
.
-
indentLines
-
pushSnippet
Inserts a new snippet atlocation
If another snippet was already active, it will be paused and the new snippet will become active. Once the focus positions of
snippet
have been exhausted, editing will return to the previous snippet.- Parameters:
snippet
- aGtkSourceSnippet
location
- aGtkTextIter
ornull
for the cursor position
-
setAutoIndent
public void setAutoIndent(boolean enable) Iftrue
auto-indentation of text is enabled.When Enter is pressed to create a new line, the auto-indentation inserts the same indentation as the previous line. This is not a "smart indentation" where an indentation level is added or removed depending on the context.
- Parameters:
enable
- whether to enable auto indentation.
-
setBackgroundPattern
Set if and how the background pattern should be displayed.- Parameters:
backgroundPattern
- theGtkSourceBackgroundPatternType
.
-
setEnableSnippets
public void setEnableSnippets(boolean enableSnippets) Sets theView:enable-snippets
property.If
enableSnippets
istrue
, matching snippets found in theSnippetManager
may be expanded when the user presses Tab after a word in theView
.- Parameters:
enableSnippets
- if snippets should be enabled
-
setHighlightCurrentLine
public void setHighlightCurrentLine(boolean highlight) Ifhighlight
istrue
the current line will be highlighted.- Parameters:
highlight
- whether to highlight the current line.
-
setIndentOnTab
public void setIndentOnTab(boolean enable) Iftrue
, when the tab key is pressed when several lines are selected, the selected lines are indented of one level instead of being replaced with a\\t
character. Shift+Tab unindents the selection.If the first or last line is not selected completely, it is also indented or unindented.
When the selection doesn't span several lines, the tab key always replaces the selection with a normal
\\t
character.- Parameters:
enable
- whether to indent a block when tab is pressed.
-
setIndentWidth
public void setIndentWidth(int width) Sets the number of spaces to use for each step of indent when the tab key is pressed.If
width
is -1, the value of theView:tab-width
property will be used.The
View:indent-width
interacts with theView:insert-spaces-instead-of-tabs
property andView:tab-width
. An example will be clearer:If the
View:indent-width
is 4 andView:tab-width
is 8 andView:insert-spaces-instead-of-tabs
isfalse
, then pressing the tab key at the beginning of a line will insert 4 spaces. So far so good. Pressing the tab key a second time will remove the 4 spaces and insert a\\t
character instead (sinceView:tab-width
is 8). On the other hand, ifView:insert-spaces-instead-of-tabs
istrue
, the second tab key pressed will insert 4 more spaces for a total of 8 spaces in theTextBuffer
.The test-widget program (available in the GtkSourceView repository) may be useful to better understand the indentation settings (enable the space drawing!).
- Parameters:
width
- indent width in characters.
-
setIndenter
Sets the indenter for this View toindenter
.Note that the indenter will not be used unless
GtkSourceView
:auto-indent has been set totrue
.- Parameters:
indenter
- aGtkSourceIndenter
ornull
-
setInsertSpacesInsteadOfTabs
public void setInsertSpacesInsteadOfTabs(boolean enable) Iftrue
a tab key pressed is replaced by a group of space characters.Of course it is still possible to insert a real
\\t
programmatically with theTextBuffer
API.- Parameters:
enable
- whether to insert spaces instead of tabs.
-
setMarkAttributes
Sets attributes and priority for thecategory
.- Parameters:
category
- the category.attributes
- mark attributes.priority
- priority of the category.
-
setRightMarginPosition
public void setRightMarginPosition(int pos) Sets the position of the right margin in the given this View.- Parameters:
pos
- the width in characters where to position the right margin.
-
setShowLineMarks
public void setShowLineMarks(boolean show) Iftrue
line marks will be displayed beside the text.- Parameters:
show
- whether line marks should be displayed.
-
setShowLineNumbers
public void setShowLineNumbers(boolean show) Iftrue
line numbers will be displayed beside the text.- Parameters:
show
- whether line numbers should be displayed.
-
setShowRightMargin
public void setShowRightMargin(boolean show) Iftrue
a right margin is displayed.- Parameters:
show
- whether to show a right margin.
-
setSmartBackspace
public void setSmartBackspace(boolean smartBackspace) When set totrue
, pressing the Backspace key will try to delete spaces up to the previous tab stop.- Parameters:
smartBackspace
- whether to enable smart Backspace handling.
-
setSmartHomeEnd
Set the desired movement of the cursor when HOME and END keys are pressed.- Parameters:
smartHomeEnd
- the desired behavior amongGtkSourceSmartHomeEndType
.
-
setTabWidth
public void setTabWidth(int width) Sets the width of tabulation in characters.The
GtkTextBuffer
still contains\\t
characters, but they can take a different visual width in aView
widget.- Parameters:
width
- width of tab in characters.
-
unindentLines
-
lineMarkActivated
-
moveLines
protected void moveLines(boolean down) -
moveWords
protected void moveWords(int step) -
showCompletion
protected void showCompletion() -
onChangeCase
Keybinding signal to change case of the text at the current cursor position.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitChangeCase
Emits the "change-case" signal. SeeonChangeCase(org.gnome.gtksourceview.View.ChangeCaseCallback)
. -
onChangeNumber
public SignalConnection<View.ChangeNumberCallback> onChangeNumber(View.ChangeNumberCallback handler) Keybinding signal to edit a number at the current cursor position.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitChangeNumber
public void emitChangeNumber(int count) Emits the "change-number" signal. SeeonChangeNumber(org.gnome.gtksourceview.View.ChangeNumberCallback)
. -
onJoinLines
Keybinding signal to join the lines currently selected.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitJoinLines
public void emitJoinLines()Emits the "join-lines" signal. SeeonJoinLines(org.gnome.gtksourceview.View.JoinLinesCallback)
. -
onLineMarkActivated
public SignalConnection<View.LineMarkActivatedCallback> onLineMarkActivated(View.LineMarkActivatedCallback handler) Emitted when a line mark has been activated (for instance when there was a button press in the line marks gutter).You can use
iter
to determine on which line the activation took place.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitLineMarkActivated
Emits the "line-mark-activated" signal. SeeonLineMarkActivated(org.gnome.gtksourceview.View.LineMarkActivatedCallback)
. -
onMoveLines
The signal is a keybinding which gets emitted when the user initiates moving a line.The default binding key is Alt+Up/Down arrow. And moves the currently selected lines, or the current line up or down by one line.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMoveLines
public void emitMoveLines(boolean down) Emits the "move-lines" signal. SeeonMoveLines(org.gnome.gtksourceview.View.MoveLinesCallback)
. -
onMoveToMatchingBracket
public SignalConnection<View.MoveToMatchingBracketCallback> onMoveToMatchingBracket(View.MoveToMatchingBracketCallback handler) Keybinding signal to move the cursor to the matching bracket.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMoveToMatchingBracket
public void emitMoveToMatchingBracket(boolean extendSelection) Emits the "move-to-matching-bracket" signal. SeeonMoveToMatchingBracket(org.gnome.gtksourceview.View.MoveToMatchingBracketCallback)
. -
onMoveWords
The signal is a keybinding which gets emitted when the user initiates moving a word.The default binding key is Alt+Left/Right Arrow and moves the current selection, or the current word by one word.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMoveWords
public void emitMoveWords(int count) Emits the "move-words" signal. SeeonMoveWords(org.gnome.gtksourceview.View.MoveWordsCallback)
. -
onPushSnippet
The signal is emitted to insert a new snippet into the view.If another snippet was active, it will be paused until all focus positions of
snippet
have been exhausted.location
will be updated to point at the end of the snippet.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPushSnippet
Emits the "push-snippet" signal. SeeonPushSnippet(org.gnome.gtksourceview.View.PushSnippetCallback)
. -
onShowCompletion
public SignalConnection<View.ShowCompletionCallback> onShowCompletion(View.ShowCompletionCallback handler) The signal is a key binding signal which gets emitted when the user requests a completion, by pressing <keycombo><keycap>Control</keycap><keycap>space</keycap></keycombo>.This will create a
CompletionContext
with the activation type asCompletionActivation.USER_REQUESTED
.Applications should not connect to it, but may emit it with
GObjects.signalEmitByName(org.gnome.gobject.GObject, java.lang.String, java.lang.Object...)
if they need to activate the completion by another means, for example with another key binding or a menu entry.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitShowCompletion
public void emitShowCompletion()Emits the "show-completion" signal. SeeonShowCompletion(org.gnome.gtksourceview.View.ShowCompletionCallback)
. -
onSmartHomeEnd
public SignalConnection<View.SmartHomeEndCallback> onSmartHomeEnd(View.SmartHomeEndCallback handler) Emitted when a the cursor was moved according to the smart home end setting.The signal is emitted after the cursor is moved, but during the
Gtk.TextView::move-cursor
action. This can be used to find out whether the cursor was moved by a normal home/end or by a smart home/end.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitSmartHomeEnd
Emits the "smart-home-end" signal. SeeonSmartHomeEnd(org.gnome.gtksourceview.View.SmartHomeEndCallback)
. -
builder
AView.Builder
object constructs aView
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withView.Builder.build()
.
-