Documentation
¶
Overview ¶
Package sourceview provides a native GOUI code editor. All widget and document operations are sequential and, while mounted, belong on the GUI thread.
Index ¶
- Constants
- Variables
- type Command
- type Completion
- type CompletionContext
- type CompletionProvider
- type Document
- func (d *Document) ConnectLineEndingChanged(fn func(LineEnding)) signal.Handle
- func (d *Document) ID() uint64
- func (d *Document) Language() language.ID
- func (d *Document) LanguageDefinition() *language.Language
- func (d *Document) LineEnding() LineEnding
- func (d *Document) Model() *textedit.Model
- func (d *Document) SetLanguage(id language.ID) error
- func (d *Document) SetLanguageDefinition(l *language.Language)
- func (d *Document) SetLineEnding(ending LineEnding) error
- func (d *Document) WriteTo(w io.Writer) (int64, error)
- type FoldRegion
- type IndentOptions
- type KeyBindings
- type LineEnding
- type SearchQuery
- type SourceView
- func (v *SourceView) AcceptsTab() bool
- func (v *SourceView) ApplyEdits(document *Document, revision uint64, edits []textedit.Edit, ...) error
- func (v *SourceView) Arrange(rect geometry.Rectangle)
- func (v *SourceView) AutoPairs() bool
- func (v *SourceView) AutomaticCompletion() bool
- func (v *SourceView) ConnectChange(fn func(textedit.Change)) signal.Handle
- func (v *SourceView) ConnectError(fn func(error)) signal.Handle
- func (v *SourceView) ConnectFoldingChanged(fn func()) signal.Handle
- func (v *SourceView) ConnectScrollIntoView(fn func(geometry.Rectangle)) signal.Handle
- func (v *SourceView) ConnectSelection(fn func(textedit.Selection)) signal.Handle
- func (v *SourceView) ContentSize() geometry.Size
- func (v *SourceView) Copy() error
- func (v *SourceView) Cursor() gui.Cursor
- func (v *SourceView) Cut() error
- func (v *SourceView) DeleteLines() error
- func (v *SourceView) DeleteWord(forward bool) error
- func (v *SourceView) Document() *Document
- func (v *SourceView) DuplicateLines(down bool) error
- func (v *SourceView) FindNext(backward bool) (textedit.Range, bool)
- func (v *SourceView) Fold(line int) bool
- func (v *SourceView) FoldAll()
- func (v *SourceView) FoldingEnabled() bool
- func (v *SourceView) FoldingRegions() []FoldRegion
- func (v *SourceView) HidePanel()
- func (v *SourceView) HighlightOccurrences() bool
- func (v *SourceView) HighlightSearchMatches() bool
- func (v *SourceView) IMContext() gui.IMContext
- func (v *SourceView) Indent(outdent bool) error
- func (v *SourceView) IndentOptions() IndentOptions
- func (v *SourceView) InsertLine(below bool) error
- func (v *SourceView) JumpToBracket() bool
- func (v *SourceView) KeyBindings() KeyBindings
- func (v *SourceView) LayoutVisible(viewport geometry.Size, offset geometry.Point)
- func (v *SourceView) LinkedTags() bool
- func (v *SourceView) Measure(c layout.Constraint) layout.Measurement
- func (v *SourceView) MoveLines(down bool) error
- func (v *SourceView) MoveWord(forward, extend bool)
- func (v *SourceView) Paint(p gui.Painter)
- func (v *SourceView) Paste() error
- func (v *SourceView) ReadOnly() bool
- func (v *SourceView) Redo() bool
- func (v *SourceView) ReplaceAll(text string) (int, error)
- func (v *SourceView) ReplaceCurrent(text string) (bool, error)
- func (v *SourceView) ReplaceSelection(text string) error
- func (v *SourceView) RevealSelection()
- func (v *SourceView) Rulers() []int
- func (v *SourceView) Search() SearchQuery
- func (v *SourceView) SearchError() error
- func (v *SourceView) SearchRange() (textedit.Range, bool)
- func (v *SourceView) SelectLine()
- func (v *SourceView) Selection() textedit.Selection
- func (v *SourceView) SetAcceptsTab(value bool)
- func (v *SourceView) SetAutoPairs(enabled bool)
- func (v *SourceView) SetAutomaticCompletion(enabled bool)
- func (v *SourceView) SetCompletionProvider(provider *CompletionProvider)
- func (v *SourceView) SetDocument(d *Document)
- func (v *SourceView) SetFoldingEnabled(enabled bool)
- func (v *SourceView) SetHighlightOccurrences(b bool)
- func (v *SourceView) SetHighlightSearchMatches(highlight bool)
- func (v *SourceView) SetIndentOptions(o IndentOptions) error
- func (v *SourceView) SetKeyBindings(bindings KeyBindings) error
- func (v *SourceView) SetLinkedTags(b bool)
- func (v *SourceView) SetReadOnly(value bool)
- func (v *SourceView) SetRulers(columns []int) error
- func (v *SourceView) SetScheme(s *scheme.Scheme)
- func (v *SourceView) SetSearch(q SearchQuery)
- func (v *SourceView) SetSearchRange(r *textedit.Range) error
- func (v *SourceView) SetSelection(s textedit.Selection)
- func (v *SourceView) SetShowIndentGuides(b bool)
- func (v *SourceView) SetShowLineEndings(b bool)
- func (v *SourceView) SetShowLineNumbers(show bool)
- func (v *SourceView) SetSmartBackspace(b bool)
- func (v *SourceView) SetSmartHomeEnd(b bool)
- func (v *SourceView) SetWhitespaceMode(mode WhitespaceMode) error
- func (v *SourceView) SetWrapMode(w WrapMode)
- func (v *SourceView) ShowCompletion() error
- func (v *SourceView) ShowFind() error
- func (v *SourceView) ShowGoTo() error
- func (v *SourceView) ShowIndentGuides() bool
- func (v *SourceView) ShowLineEndings() bool
- func (v *SourceView) ShowLineNumbers() bool
- func (v *SourceView) ShowReplace() error
- func (v *SourceView) SmartBackspace() bool
- func (v *SourceView) SmartHomeEnd() bool
- func (v *SourceView) Snapshot() gui.WidgetInfo
- func (v *SourceView) StyleChanged()
- func (v *SourceView) ToggleBlockComment() error
- func (v *SourceView) ToggleFold(line int) bool
- func (v *SourceView) ToggleLineComment() error
- func (v *SourceView) Undo() bool
- func (v *SourceView) Unfold(line int) bool
- func (v *SourceView) UnfoldAll()
- func (v *SourceView) WhitespaceMode() WhitespaceMode
- func (v *SourceView) WrapMode() WrapMode
- type WhitespaceMode
- type WrapMode
Constants ¶
const ( WrapNone = typography.WrapNone WrapChar = typography.WrapChar WrapWordChar = typography.WrapWordChar )
Variables ¶
var ( ErrReadOnly = errors.New("sourceview: read only") ErrDisabled = errors.New("sourceview: disabled") ErrNotMounted = errors.New("sourceview: not mounted") ErrUnknownLanguage = errors.New("sourceview: unknown language") ErrOperationLimit = editor.ErrOperationLimit ErrOperationChanged = errors.New("sourceview: operation context changed") )
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command uint16
Command identifies an editor operation, not a global command registration. Zero and unknown values are invalid. Bindings do not change an operation's editing, focus, preedit or lifecycle requirements.
const ( CommandUndo Command = iota + 1 CommandRedo CommandCut CommandCopy CommandPaste CommandDeleteSelection CommandMoveLinesUp CommandMoveLinesDown CommandDuplicateLinesUp CommandDuplicateLinesDown CommandDeleteLines CommandSelectAll CommandFold CommandUnfold CommandFoldAll CommandUnfoldAll CommandComplete CommandToggleLineComment CommandToggleBlockComment CommandIndent CommandOutdent CommandInsertLineAbove CommandInsertLineBelow CommandSelectLine CommandJumpToBracket CommandMoveWordLeft CommandMoveWordRight CommandSelectWordLeft CommandSelectWordRight CommandDeleteWordLeft CommandDeleteWordRight CommandMoveLineStart CommandMoveLineEnd CommandSelectLineStart CommandSelectLineEnd CommandMoveDocumentStart CommandMoveDocumentEnd CommandSelectDocumentStart CommandSelectDocumentEnd CommandFindNext CommandFindPrevious // Find/Replace/GoTo are handled only by an attached companion bar. CommandFind CommandReplace CommandGoTo )
type Completion ¶
type Completion struct {
Label, Text, Detail string
Range *textedit.Range
AdditionalEdits []textedit.Edit
Caret *int
}
Completion is a literal edit. Nil Range uses the requested word range. Empty Text uses Label. Caret, when set, is a UTF-8 offset relative to inserted Text. AdditionalEdits use the same original document coordinates as the primary edit.
func DefaultCompletions ¶
func DefaultCompletions(c CompletionContext) []Completion
DefaultCompletions explicitly combines language suggestions and nearby words, with case-insensitive prefix filtering, de-duplication and alphabetical order.
func DocumentCompletions ¶
func DocumentCompletions(c CompletionContext) []Completion
DocumentCompletions returns whole words from the bounded nearby snapshot.
func LanguageCompletions ¶
func LanguageCompletions(c CompletionContext) []Completion
LanguageCompletions returns the definition's static suggestions in code context.
type CompletionContext ¶
type CompletionContext struct {
DocumentID, Revision uint64
Language language.ID
Definition *language.Language
Range textedit.Range
Caret int
Prefix string
Explicit bool
Trigger string
Lexical language.Context
ContextKnown bool
Before, After, NearbyText string
NearbyOffset, DocumentLength int
}
CompletionContext is an immutable, bounded snapshot, safe on a worker. It has no live Model, Document or Widget. Offsets are UTF-8 bytes. NearbyText has at most 32 KiB on either side; Before/After have at most 16 KiB of the current line. Language/Definition describe the effective language at the caret, including an explicit embedded language. DocumentID remains the outer document identity.
type CompletionProvider ¶
type CompletionProvider struct {
TriggerCharacters string
Complete func(context.Context, CompletionContext) ([]Completion, error)
}
CompletionProvider completely owns candidates, filtering and order. Treat this configuration as immutable; reuse its pointer across declarative updates. Complete runs on one worker per view, must honor cancellation, and must not touch GUI objects. Nil provider selects DefaultCompletions. Empty results stay empty. TriggerCharacters allows automatic requests even with an empty prefix.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document shares normalized text, language, history, output line endings and lexical analysis between views. It owns no native resources and needs no Destroy.
func NewDocument ¶
NewDocument detects the source line ending before normalizing the editing model to UTF-8/LF. Mixed endings use the most frequent kind; ties use the first encountered kind. A document without line breaks defaults to LF.
func NewDocumentWithModel ¶
NewDocumentWithModel borrows a normalized model and defaults to LF output. Its original line endings cannot be recovered; use SetLineEnding when known.
func (*Document) ConnectLineEndingChanged ¶ added in v0.2.0
func (d *Document) ConnectLineEndingChanged(fn func(LineEnding)) signal.Handle
ConnectLineEndingChanged observes output configuration, separately from model edits. The caller owns the returned connection and disconnects it when done.
func (*Document) LanguageDefinition ¶
LanguageDefinition returns the immutable definition shared by all views.
func (*Document) LineEnding ¶ added in v0.2.0
func (d *Document) LineEnding() LineEnding
LineEnding returns the document's serialization format. Model always uses LF.
func (*Document) SetLanguageDefinition ¶
SetLanguageDefinition binds a definition directly. Nil selects plain text. Identity matters: a different definition with the same ID invalidates analysis.
func (*Document) SetLineEnding ¶ added in v0.2.0
func (d *Document) SetLineEnding(ending LineEnding) error
SetLineEnding configures serialization only. It changes neither text, revision nor undo history, and is not an undoable format-conversion command.
func (*Document) WriteTo ¶ added in v0.2.0
WriteTo writes UTF-8 using LineEnding, preserving every logical newline, including their absence or repetition at EOF. It uses bounded chunks and returns bytes actually written. Output is not an atomic file replacement. Access is sequential like Model. If a writer callback changes the model or line-ending configuration, it stops with ErrOperationChanged after that write.
type FoldRegion ¶
FoldRegion is a detached snapshot. Lines are zero-based and EndLine inclusive.
type IndentOptions ¶
type KeyBindings ¶
type KeyBindings map[Command][]gui.KeyGesture
KeyBindings maps editor commands to alternative single-key gestures. It covers command shortcuts, not text commits or transient popup navigation.
func DefaultKeyBindings ¶
func DefaultKeyBindings() KeyBindings
DefaultKeyBindings returns a fresh, editable table for the current platform. Explicit completion has no default gesture; applications may bind it.
type LineEnding ¶ added in v0.2.0
type LineEnding uint8
LineEnding specifies the UTF-8 sequence used to serialize logical newlines. It never changes the model's normalized UTF-8/LF coordinate system.
const ( LineEndingLF LineEnding = iota LineEndingCRLF LineEndingCR )
func DetectLineEnding ¶ added in v0.2.0
func DetectLineEnding(text string) (ending LineEnding, mixed bool)
DetectLineEnding returns the most frequent line ending and whether two or more kinds occur. CRLF counts once, ties use the first encountered kind, and text without line breaks returns LF. It does not normalize or retain text.
func (LineEnding) String ¶ added in v0.2.0
func (ending LineEnding) String() string
String returns the format name for labels, not its encoded bytes.
type SearchQuery ¶
type SourceView ¶
type SourceView struct {
gui.WidgetBase
// contains filtered or unexported fields
}
SourceView is an editable code control with built-in find, replace and go-to interfaces. Put it in gui.ScrollView to add scrollbars; set that host's StyleName to "source-view" for a shared outer frame. Construction owns no model/settings/root subscriptions.
func NewSourceView ¶
func NewSourceView() *SourceView
func (*SourceView) AcceptsTab ¶
func (v *SourceView) AcceptsTab() bool
func (*SourceView) ApplyEdits ¶
func (v *SourceView) ApplyEdits(document *Document, revision uint64, edits []textedit.Edit, after textedit.Selection) error
ApplyEdits applies original-coordinate edits as one undo unit, with an explicit post-edit selection. Document identity and revision must match. All ranges and the selection are validated before mutation by textedit.
func (*SourceView) Arrange ¶
func (v *SourceView) Arrange(rect geometry.Rectangle)
func (*SourceView) AutoPairs ¶
func (v *SourceView) AutoPairs() bool
AutoPairs controls insertion, surrounding and deletion of generated pairs. It does not affect explicit ReplaceSelection, paste or composed IME commits.
func (*SourceView) AutomaticCompletion ¶
func (v *SourceView) AutomaticCompletion() bool
func (*SourceView) ConnectChange ¶
func (v *SourceView) ConnectChange(fn func(textedit.Change)) signal.Handle
func (*SourceView) ConnectError ¶
func (v *SourceView) ConnectError(fn func(error)) signal.Handle
func (*SourceView) ConnectFoldingChanged ¶
func (v *SourceView) ConnectFoldingChanged(fn func()) signal.Handle
func (*SourceView) ConnectScrollIntoView ¶
func (v *SourceView) ConnectScrollIntoView(fn func(geometry.Rectangle)) signal.Handle
func (*SourceView) ConnectSelection ¶
func (v *SourceView) ConnectSelection(fn func(textedit.Selection)) signal.Handle
func (*SourceView) ContentSize ¶
func (v *SourceView) ContentSize() geometry.Size
func (*SourceView) Copy ¶
func (v *SourceView) Copy() error
func (*SourceView) Cursor ¶ added in v0.2.0
func (v *SourceView) Cursor() gui.Cursor
Cursor resolves code, gutter and fold affordances without shaping text. A captured selection keeps the cursor chosen by its starting region.
func (*SourceView) Cut ¶
func (v *SourceView) Cut() error
func (*SourceView) DeleteLines ¶
func (v *SourceView) DeleteLines() error
DeleteLines deletes the current logical line or selected lines, placing the caret at the deletion boundary. Deleting an empty document is a no-op.
func (*SourceView) DeleteWord ¶
func (v *SourceView) DeleteWord(forward bool) error
DeleteWord deletes the selection, a whitespace run or one code word. Each invocation has its own undo item. At a document edge it is a no-op.
func (*SourceView) Document ¶
func (v *SourceView) Document() *Document
func (*SourceView) DuplicateLines ¶
func (v *SourceView) DuplicateLines(down bool) error
DuplicateLines copies the current logical line or selected lines above/below, retaining the selection in the new copy. The clipboard is not involved.
func (*SourceView) Fold ¶
func (v *SourceView) Fold(line int) bool
func (*SourceView) FoldAll ¶
func (v *SourceView) FoldAll()
func (*SourceView) FoldingEnabled ¶
func (v *SourceView) FoldingEnabled() bool
func (*SourceView) FoldingRegions ¶
func (v *SourceView) FoldingRegions() []FoldRegion
func (*SourceView) HidePanel ¶ added in v0.2.0
func (v *SourceView) HidePanel()
HidePanel hides the built-in find/replace or go-to UI. Query and replacement text survive. Focus returns to the editor only when it was inside that UI.
func (*SourceView) HighlightOccurrences ¶
func (v *SourceView) HighlightOccurrences() bool
func (*SourceView) HighlightSearchMatches ¶
func (v *SourceView) HighlightSearchMatches() bool
HighlightSearchMatches reports whether search backgrounds are drawn. New views highlight matches, including searches made without a findBar.
func (*SourceView) IMContext ¶
func (v *SourceView) IMContext() gui.IMContext
func (*SourceView) Indent ¶
func (v *SourceView) Indent(outdent bool) error
func (*SourceView) IndentOptions ¶
func (v *SourceView) IndentOptions() IndentOptions
func (*SourceView) InsertLine ¶
func (v *SourceView) InsertLine(below bool) error
InsertLine inserts an indented blank line above/below the caret's logical line. Existing text is preserved, including when there is a selection.
func (*SourceView) JumpToBracket ¶
func (v *SourceView) JumpToBracket() bool
JumpToBracket jumps between a confirmed pair adjacent to the caret. Unknown, unmatched or out-of-budget pairs leave the selection unchanged.
func (*SourceView) KeyBindings ¶
func (v *SourceView) KeyBindings() KeyBindings
KeyBindings returns a mutable deep copy, including when no keys are bound.
func (*SourceView) LayoutVisible ¶
func (v *SourceView) LayoutVisible(viewport geometry.Size, offset geometry.Point)
func (*SourceView) LinkedTags ¶
func (v *SourceView) LinkedTags() bool
LinkedTags controls typed/deleted name mirroring on confirmed markup pairs.
func (*SourceView) Measure ¶
func (v *SourceView) Measure(c layout.Constraint) layout.Measurement
func (*SourceView) MoveLines ¶
func (v *SourceView) MoveLines(down bool) error
MoveLines moves the current logical line or selected lines one row up/down. It preserves indentation and selection direction. A document edge is a no-op.
func (*SourceView) MoveWord ¶
func (v *SourceView) MoveWord(forward, extend bool)
MoveWord moves to the previous code-word start or next code-word end.
func (*SourceView) Paint ¶
func (v *SourceView) Paint(p gui.Painter)
func (*SourceView) Paste ¶
func (v *SourceView) Paste() error
Paste accepts an asynchronous request. Delayed failures are reported through ConnectError. A changed document, selection or mount cancels the request.
func (*SourceView) ReadOnly ¶
func (v *SourceView) ReadOnly() bool
func (*SourceView) Redo ¶
func (v *SourceView) Redo() bool
func (*SourceView) ReplaceAll ¶
func (v *SourceView) ReplaceAll(text string) (int, error)
func (*SourceView) ReplaceCurrent ¶
func (v *SourceView) ReplaceCurrent(text string) (bool, error)
func (*SourceView) ReplaceSelection ¶
func (v *SourceView) ReplaceSelection(text string) error
func (*SourceView) RevealSelection ¶
func (v *SourceView) RevealSelection()
func (*SourceView) Rulers ¶
func (v *SourceView) Rulers() []int
func (*SourceView) Search ¶
func (v *SourceView) Search() SearchQuery
func (*SourceView) SearchError ¶
func (v *SourceView) SearchError() error
SearchError reports a malformed regular expression. Invalid queries retain their text for editing, produce no matches and never mutate the document.
func (*SourceView) SearchRange ¶
func (v *SourceView) SearchRange() (textedit.Range, bool)
SearchRange is independent of the current selection and FindNext results.
func (*SourceView) SelectLine ¶
func (v *SourceView) SelectLine()
SelectLine expands to whole logical lines, including the following LF. Repeating the command extends the selection one more line downward.
func (*SourceView) Selection ¶
func (v *SourceView) Selection() textedit.Selection
func (*SourceView) SetAcceptsTab ¶
func (v *SourceView) SetAcceptsTab(value bool)
func (*SourceView) SetAutoPairs ¶
func (v *SourceView) SetAutoPairs(enabled bool)
func (*SourceView) SetAutomaticCompletion ¶
func (v *SourceView) SetAutomaticCompletion(enabled bool)
func (*SourceView) SetCompletionProvider ¶
func (v *SourceView) SetCompletionProvider(provider *CompletionProvider)
func (*SourceView) SetDocument ¶
func (v *SourceView) SetDocument(d *Document)
func (*SourceView) SetFoldingEnabled ¶
func (v *SourceView) SetFoldingEnabled(enabled bool)
func (*SourceView) SetHighlightOccurrences ¶
func (v *SourceView) SetHighlightOccurrences(b bool)
func (*SourceView) SetHighlightSearchMatches ¶
func (v *SourceView) SetHighlightSearchMatches(highlight bool)
SetHighlightSearchMatches changes presentation only. Query, navigation, replacement and ordinary text selection are unaffected. findBar enables it on open and disables it when closing or releasing an open search session.
func (*SourceView) SetIndentOptions ¶
func (v *SourceView) SetIndentOptions(o IndentOptions) error
func (*SourceView) SetKeyBindings ¶
func (v *SourceView) SetKeyBindings(bindings KeyBindings) error
SetKeyBindings validates and copies a complete replacement table. nil/empty removes all command shortcuts; absent commands have no fallback binding. Gestures require a non-Shift modifier or a function key. Unmodified/Shift-only text, navigation and editing keys belong to ordinary input and popup control. Invalid commands, unsupported gestures or conflicting commands return an error without changing the old table. Same-command aliases are deduplicated. It does not affect ordinary input, IME, menus or direct method calls.
func (*SourceView) SetLinkedTags ¶
func (v *SourceView) SetLinkedTags(b bool)
func (*SourceView) SetReadOnly ¶
func (v *SourceView) SetReadOnly(value bool)
func (*SourceView) SetRulers ¶
func (v *SourceView) SetRulers(columns []int) error
func (*SourceView) SetScheme ¶
func (v *SourceView) SetScheme(s *scheme.Scheme)
SetScheme overrides code-area colors only. nil uses the owning stylesheet.
func (*SourceView) SetSearch ¶
func (v *SourceView) SetSearch(q SearchQuery)
func (*SourceView) SetSearchRange ¶
func (v *SourceView) SetSearchRange(r *textedit.Range) error
SetSearchRange copies a validated byte range. nil searches the whole document. Regex anchors retain the full-document context. Empty ranges may match empty expressions; no caller-owned pointer is retained.
func (*SourceView) SetSelection ¶
func (v *SourceView) SetSelection(s textedit.Selection)
func (*SourceView) SetShowIndentGuides ¶
func (v *SourceView) SetShowIndentGuides(b bool)
func (*SourceView) SetShowLineEndings ¶
func (v *SourceView) SetShowLineEndings(b bool)
func (*SourceView) SetShowLineNumbers ¶
func (v *SourceView) SetShowLineNumbers(show bool)
func (*SourceView) SetSmartBackspace ¶
func (v *SourceView) SetSmartBackspace(b bool)
func (*SourceView) SetSmartHomeEnd ¶
func (v *SourceView) SetSmartHomeEnd(b bool)
func (*SourceView) SetWhitespaceMode ¶
func (v *SourceView) SetWhitespaceMode(mode WhitespaceMode) error
func (*SourceView) SetWrapMode ¶
func (v *SourceView) SetWrapMode(w WrapMode)
func (*SourceView) ShowCompletion ¶
func (v *SourceView) ShowCompletion() error
ShowCompletion requests suggestions at the current caret. No proposals is a normal result. Asynchronous failures are delivered once through ConnectError.
func (*SourceView) ShowFind ¶ added in v0.2.0
func (v *SourceView) ShowFind() error
ShowFind opens the built-in find UI and focuses its query. A short, single-line editor selection seeds the query. It requires a mounted view.
func (*SourceView) ShowGoTo ¶ added in v0.2.0
func (v *SourceView) ShowGoTo() error
ShowGoTo opens the built-in line/column input, initialized from the caret. It requires a mounted view and closes the find/replace UI.
func (*SourceView) ShowIndentGuides ¶
func (v *SourceView) ShowIndentGuides() bool
func (*SourceView) ShowLineEndings ¶
func (v *SourceView) ShowLineEndings() bool
func (*SourceView) ShowLineNumbers ¶
func (v *SourceView) ShowLineNumbers() bool
func (*SourceView) ShowReplace ¶ added in v0.2.0
func (v *SourceView) ShowReplace() error
ShowReplace opens the built-in find UI with replacement controls visible. It otherwise follows ShowFind's selection and focus rules.
func (*SourceView) SmartBackspace ¶
func (v *SourceView) SmartBackspace() bool
func (*SourceView) SmartHomeEnd ¶
func (v *SourceView) SmartHomeEnd() bool
func (*SourceView) Snapshot ¶
func (v *SourceView) Snapshot() gui.WidgetInfo
func (*SourceView) StyleChanged ¶
func (v *SourceView) StyleChanged()
func (*SourceView) ToggleBlockComment ¶
func (v *SourceView) ToggleBlockComment() error
ToggleBlockComment wraps the selection or removes its exact configured wrapper. Content is literal; this does not parse or nest block comments.
func (*SourceView) ToggleFold ¶
func (v *SourceView) ToggleFold(line int) bool
func (*SourceView) ToggleLineComment ¶
func (v *SourceView) ToggleLineComment() error
ToggleLineComment uses the language's line marker. Empty configuration is a normal no-op. A selection ending at the next line start excludes that line.
func (*SourceView) Undo ¶
func (v *SourceView) Undo() bool
func (*SourceView) Unfold ¶
func (v *SourceView) Unfold(line int) bool
func (*SourceView) UnfoldAll ¶
func (v *SourceView) UnfoldAll()
func (*SourceView) WhitespaceMode ¶
func (v *SourceView) WhitespaceMode() WhitespaceMode
func (*SourceView) WrapMode ¶
func (v *SourceView) WrapMode() WrapMode
type WhitespaceMode ¶
type WhitespaceMode uint8
WhitespaceMode controls decorative markers without changing source text.
const ( WhitespaceNone WhitespaceMode = iota // Hide whitespace markers. WhitespaceSelection // Mark whitespace contained in the selection. WhitespaceTrailing // Mark whitespace at the end of a logical line. WhitespaceAll // Mark all supported whitespace. WhitespaceBoundary // Mark indentation, trailing/repeated spaces, Tabs and special spaces. )
type WrapMode ¶
type WrapMode = typography.WrapMode
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
declarative
command
Run: go run ./example/declarative.
|
Run: go run ./example/declarative. |
|
editor
command
Run: go run ./example/editor [-theme system|light|dark] [file].
|
Run: go run ./example/editor [-theme system|light|dark] [file]. |
|
markdown
command
Run: go run ./example/markdown [-dark].
|
Run: go run ./example/markdown [-dark]. |
|
markdown/markdown
Package markdown demonstrates an application-owned SourceView language.
|
Package markdown demonstrates an application-owned SourceView language. |
|
internal
|
|
|
editor
Package editor plans source edits without depending on Widgets or native resources.
|
Package editor plans source edits without depending on Widgets or native resources. |
|
resource
Package resource contains SourceView-owned presentation text.
|
Package resource contains SourceView-owned presentation text. |
|
Package language describes the languages and lexical styles supported by SourceView.
|
Package language describes the languages and lexical styles supported by SourceView. |
|
Package scheme provides immutable source-code color schemes.
|
Package scheme provides immutable source-code color schemes. |
|
tests
|
|
|
window/editor
command
SourceView desktop verification.
|
SourceView desktop verification. |
|
window/editor/assistance
command
编辑辅助和空白外观的原生窗口验证,需要桌面及窗口管理器。
|
编辑辅助和空白外观的原生窗口验证,需要桌面及窗口管理器。 |
|
window/editor/brackets
command
Bracket decoration visual verification.
|
Bracket decoration visual verification. |
|
window/editor/completion
command
Completion panel verification.
|
Completion panel verification. |
|
window/editor/corpus
command
Downloaded-corpus verification.
|
Downloaded-corpus verification. |
|
window/editor/extensions
command
Public extension verification.
|
Public extension verification. |
|
window/editor/find
command
内置查找、替换和声明式生命周期验证。
|
内置查找、替换和声明式生命周期验证。 |
|
window/editor/find_appearance
command
Find overlay appearance and isolation verification.
|
Find overlay appearance and isolation verification. |
|
window/editor/folding
command
Folding integration verification.
|
Folding integration verification. |
|
window/editor/frame
command
编辑器外框与滚动条组合验证。
|
编辑器外框与滚动条组合验证。 |
|
window/editor/interaction
command
Real desktop input verification; requires a desktop and native typography.
|
Real desktop input verification; requires a desktop and native typography. |
|
window/editor/keybindings
command
Command binding integration verification.
|
Command binding integration verification. |
|
window/editor/languages
command
TOML/YAML/Shell integration verification.
|
TOML/YAML/Shell integration verification. |
|
window/editor/largefiles
command
Medium/large-file functional verification.
|
Medium/large-file functional verification. |
|
window/editor/lines
command
Logical line editing verification.
|
Logical line editing verification. |
|
window/editor/localization
command
Eight-language editor UI verification.
|
Eight-language editor UI verification. |
|
window/editor/longlines
command
Long-line rasterization regression.
|
Long-line rasterization regression. |
|
window/editor/markup
command
Native markup verification; desktop/window manager required.
|
Native markup verification; desktop/window manager required. |
|
window/editor/paragraph
command
超大单行文本交互验证,需要独立桌面、原生排版和字体,不使用 DevServer。
|
超大单行文本交互验证,需要独立桌面、原生排版和字体,不使用 DevServer。 |
|
window/editor/resize_cache
command
Recent-width layout cache verification.
|
Recent-width layout cache verification. |
|
window/editor/search
command
Native search enhancements verification; desktop/window manager required.
|
Native search enhancements verification; desktop/window manager required. |
|
window/editor/selection
command
Syntax-preserving selection verification.
|
Syntax-preserving selection verification. |
|
window/editor/shortcuts
command
Editor shortcut verification.
|
Editor shortcut verification. |
|
window/experience
command
Editor experience verification.
|
Editor experience verification. |
|
Package ui provides thin GOUI declarative bindings for SourceView.
|
Package ui provides thin GOUI declarative bindings for SourceView. |