texteditor

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2024 License: BSD-3-Clause Imports: 61 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// EditSignal is used as an arg for edit methods with a signal arg, indicating
	// that a signal should be emitted.
	EditSignal = true

	// EditNoSignal is used as an arg for edit methods with a signal arg, indicating
	// that a signal should NOT be emitted.
	EditNoSignal = false

	// ReplaceMatchCase is used for MatchCase arg in ReplaceText method
	ReplaceMatchCase = true

	// ReplaceNoMatchCase is used for MatchCase arg in ReplaceText method
	ReplaceNoMatchCase = false
)
View Source
const (
	MaxLineLen = 64 * 1024 * 1024
	MaxNTags   = 1024
)

MaxLineLen prevents overflow in allocating line length

Variables

View Source
var (
	// EditorBlinker manages cursor blinking
	EditorBlinker = core.Blinker{}

	// EditorSpriteName is the name of the window sprite used for the cursor
	EditorSpriteName = "texteditor.Editor.Cursor"
)
View Source
var (
	// Maximum amount of clipboard history to retain
	ClipHistMax = 100 // `default:"100" min:"0" max:"1000" step:"5"`

	// maximum number of lines to look for matching scope syntax (parens, brackets)
	MaxScopeLines = 100 // `default:"100" min:"10" step:"10"`

	// text buffer max lines to use diff-based revert to more quickly update e.g., after file has been reformatted
	DiffRevertLines = 10000 // `default:"10000" min:"0" step:"1000"`

	// text buffer max diffs to use diff-based revert to more quickly update e.g., after file has been reformatted -- if too many differences, just revert
	DiffRevertDiffs = 20 // `default:"20" min:"0" step:"1"`

	// amount of time to wait before starting a new background markup process, after text changes within a single line (always does after line insertion / deletion)
	MarkupDelay = 1000 * time.Millisecond // `default:"1000" min:"100" step:"100"`
)
View Source
var (
	// PrevQReplaceFinds are the previous QReplace strings
	PrevQReplaceFinds []string

	// PrevQReplaceRepls are the previous QReplace strings
	PrevQReplaceRepls []string
)
View Source
var DiffTextEditorType = types.AddType(&types.Type{Name: "cogentcore.org/core/texteditor.DiffTextEditor", IDName: "diff-text-editor", Doc: "DiffTextEditor supports double-click based application of edits from one\nbuffer to the other.", Embeds: []types.Field{{Name: "Editor"}}, Instance: &DiffTextEditor{}})

DiffTextEditorType is the types.Type for DiffTextEditor

View Source
var DiffViewType = types.AddType(&types.Type{Name: "cogentcore.org/core/texteditor.DiffView", IDName: "diff-view", Doc: "DiffView presents two side-by-side TextEditor windows showing the differences\nbetween two files (represented as lines of strings).", Methods: []types.Method{{Name: "SaveFileA", Doc: "SaveFileA saves the current state of file A to given filename", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"fname"}}, {Name: "SaveFileB", Doc: "SaveFileB saves the current state of file B to given filename", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"fname"}}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "FileA", Doc: "first file name being compared"}, {Name: "FileB", Doc: "second file name being compared"}, {Name: "RevA", Doc: "revision for first file, if relevant"}, {Name: "RevB", Doc: "revision for second file, if relevant"}, {Name: "BufA", Doc: "textbuf for A showing the aligned edit view"}, {Name: "BufB", Doc: "textbuf for B showing the aligned edit view"}, {Name: "AlignD", Doc: "aligned diffs records diff for aligned lines"}, {Name: "Diffs", Doc: "Diffs applied"}}, Instance: &DiffView{}})

DiffViewType is the types.Type for DiffView

View Source
var EditorType = types.AddType(&types.Type{Name: "cogentcore.org/core/texteditor.Editor", IDName: "editor", Doc: "Editor is a widget for editing multiple lines of complicated text (as compared to\n[core.TextField] for a single line of simple text).  The Editor is driven by a [Buffer]\nbuffer which contains all the text, and manages all the edits,\nsending update events out to the editors.\n\nUse NeedsRender to drive an render update for any change that does\nnot change the line-level layout of the text.\nUse NeedsLayout whenever there are changes across lines that require\nre-layout of the text.  This sets the Widget NeedsRender flag and triggers\nlayout during that render.\n\nMultiple editors can be attached to a given buffer.  All updating in the\nEditor should be within a single goroutine, as it would require\nextensive protections throughout code otherwise.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Methods: []types.Method{{Name: "Lookup", Doc: "Lookup attempts to lookup symbol at current location, popping up a window\nif something is found.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "Layout"}}, Fields: []types.Field{{Name: "Buffer", Doc: "Buffer is the text buffer being edited."}, {Name: "CursorWidth", Doc: "width of cursor -- set from cursor-width property (inherited)"}, {Name: "LineNumberColor", Doc: "the color used for the side bar containing the line numbers; this should be set in Stylers like all other style properties"}, {Name: "SelectColor", Doc: "the color used for the user text selection background color; this should be set in Stylers like all other style properties"}, {Name: "HighlightColor", Doc: "the color used for the text highlight background color (like in find); this should be set in Stylers like all other style properties"}, {Name: "CursorColor", Doc: "the color used for the text field cursor (caret); this should be set in Stylers like all other style properties"}, {Name: "NLines", Doc: "number of lines in the view -- sync'd with the Buf after edits, but always reflects storage size of Renders etc"}, {Name: "Renders", Doc: "renders of the text lines, with one render per line (each line could visibly wrap-around, so these are logical lines, not display lines)"}, {Name: "Offs", Doc: "starting render offsets for top of each line"}, {Name: "LineNoDigs", Doc: "number of line number digits needed"}, {Name: "LineNoOff", Doc: "horizontal offset for start of text after line numbers"}, {Name: "LineNoRender", Doc: "render for line numbers"}, {Name: "CursorPos", Doc: "current cursor position"}, {Name: "CursorTarg", Doc: "target cursor position for externally-set targets: ensures that it is visible"}, {Name: "CursorCol", Doc: "desired cursor column -- where the cursor was last when moved using left / right arrows -- used when doing up / down to not always go to short line columns"}, {Name: "PosHistIndex", Doc: "current index within PosHistory"}, {Name: "SelectStart", Doc: "starting point for selection -- will either be the start or end of selected region depending on subsequent selection."}, {Name: "SelectRegion", Doc: "current selection region"}, {Name: "PreviousSelectRegion", Doc: "previous selection region, that was actually rendered -- needed to update render"}, {Name: "Highlights", Doc: "highlighted regions, e.g., for search results"}, {Name: "Scopelights", Doc: "highlighted regions, specific to scope markers"}, {Name: "SelectMode", Doc: "if true, select text as cursor moves"}, {Name: "ISearch", Doc: "interactive search data"}, {Name: "QReplace", Doc: "query replace data"}, {Name: "FontHeight", Doc: "font height, cached during styling"}, {Name: "LineHeight", Doc: "line height, cached during styling"}, {Name: "FontAscent", Doc: "font ascent, cached during styling"}, {Name: "FontDescent", Doc: "font descent, cached during styling"}, {Name: "NLinesChars", Doc: "height in lines and width in chars of the visible area"}, {Name: "LinesSize", Doc: "total size of all lines as rendered"}, {Name: "TotalSize", Doc: "the LinesSize plus extra space and line numbers etc"}, {Name: "LineLayoutSize", Doc: "the Geom.Size.Actual.Total subtracting\nextra space and line numbers -- this is what\nLayoutStdLR sees for laying out each line"}, {Name: "lastlineLayoutSize", Doc: "the last LineLayoutSize used in laying out lines.\nUsed to trigger a new layout only when needed."}, {Name: "BlinkOn", Doc: "oscillates between on and off for blinking"}, {Name: "CursorMu", Doc: "mutex protecting cursor rendering -- shared between blink and main code"}, {Name: "HasLinks", Doc: "at least one of the renders has links -- determines if we set the cursor for hand movements"}, {Name: "LinkHandler", Doc: "handles link clicks -- if nil, they are sent to the standard web URL handler"}, {Name: "lastRecenter"}, {Name: "lastAutoInsert"}, {Name: "lastFilename"}}, Instance: &Editor{}})

EditorType is the types.Type for Editor

View Source
var PrevISearchString string

PrevISearchString is the previous ISearch string

View Source
var TwinEditorsType = types.AddType(&types.Type{Name: "cogentcore.org/core/texteditor.TwinEditors", IDName: "twin-editors", Doc: "TwinEditors presents two side-by-side [Editor]s in [core.Splits]\nthat scroll in sync with each other.", Embeds: []types.Field{{Name: "Splits"}}, Fields: []types.Field{{Name: "BufA", Doc: "textbuf for A"}, {Name: "BufB", Doc: "textbuf for B"}}, Instance: &TwinEditors{}})

TwinEditorsType is the types.Type for TwinEditors

View Source
var ViewClipHistChooseLen = 40

ViewClipHistChooseLen is the max length of clip history to show in chooser

View Source
var ViewClipHistory [][]byte

ViewClipHistory is the text view clipboard history -- everything that has been copied

View Source
var ViewClipRect *textbuf.Edit

ViewClipRect is the internal clipboard for Rect rectangle-based regions -- the raw text is posted on the system clipboard but the rect information is in a special format.

View Source
var ViewDepthColors = []color.RGBA{
	{0, 0, 0, 0},
	{5, 5, 0, 0},
	{15, 15, 0, 0},
	{5, 15, 0, 0},
	{0, 15, 5, 0},
	{0, 15, 15, 0},
	{0, 5, 15, 0},
	{5, 0, 15, 0},
	{5, 0, 5, 0},
}

ViewDepthOffsets are changes in color values from default background for different depths. For dark mode, these are increments, for light mode they are decrements.

View Source
var ViewMaxFindHighlights = 1000

ViewMaxFindHighlights is the maximum number of regions to highlight on find

Functions

func AddToSpellModel added in v0.0.5

func AddToSpellModel(filepath string) error

AddToSpellModel trains on additional text - extends model

func ChromaTagsForLine

func ChromaTagsForLine(tags *lexer.Line, toks []chroma.Token)

ChromaTagsForLine generates the chroma tags for one line of chroma tokens

func ChromaTagsLine

func ChromaTagsLine(clex chroma.Lexer, txt []rune) (lexer.Line, error)

ChromaTagsLine returns tags for one line according to current syntax highlighting settings

func CompleteEditParse added in v0.0.10

func CompleteEditParse(data any, text string, cursorPos int, comp complete.Completion, seed string) (ed complete.Edit)

CompleteEditParse uses the selected completion to edit the text.

func CompleteParse added in v0.0.10

func CompleteParse(data any, text string, posLn, posCh int) (md complete.Matches)

CompleteParse uses parse symbols and language; the string is a line of text up to point where user has typed. The data must be the *FileState from which the language type is obtained.

func CompleteText

func CompleteText(data any, text string, posLn, posCh int) (md complete.Matches)

CompleteText does completion for text files.

func CompleteTextEdit

func CompleteTextEdit(data any, text string, cursorPos int, completion complete.Completion, seed string) (ed complete.Edit)

CompleteTextEdit uses the selected completion to edit the text

func HTMLEscapeBytes

func HTMLEscapeBytes(b []byte) []byte

HTMLEscapeBytes escapes special characters like "<" to become "&lt;". It escapes only five such characters: <, >, &, ' and ". It operates on a *copy* of the byte string and does not modify the input! otherwise it causes major problems..

func HTMLEscapeRunes

func HTMLEscapeRunes(r []rune) []byte

HTMLEscapeRunes escapes special characters like "<" to become "&lt;". It escapes only five such characters: <, >, &, ' and ". It operates on a *copy* of the byte string and does not modify the input! otherwise it causes major problems..

func InitSpell added in v0.0.5

func InitSpell() error

InitSpell tries to load the saved fuzzy.spell model. If unsuccessful tries to create a new model from a text file used as input

func LookupParse added in v0.0.10

func LookupParse(data any, text string, posLn, posCh int) (ld complete.Lookup)

LookupParse uses parse symbols and language; the string is a line of text up to point where user has typed. The data must be the *FileState from which the language type is obtained.

func NewSpellModelFromText added in v0.0.5

func NewSpellModelFromText() error

NewSpellModelFromText builds a NEW spelling model from text

func OpenSpellModel added in v0.0.5

func OpenSpellModel() error

OpenSpellModel loads a saved spelling model

func SaveSpellModel added in v0.0.5

func SaveSpellModel() error

SaveSpellModel saves the spelling model which includes the data and parameters

func ViewClipHistAdd

func ViewClipHistAdd(clip []byte)

ViewClipHistAdd adds the given clipboard bytes to top of history stack

func ViewClipHistChooseList

func ViewClipHistChooseList() []string

ViewClipHistChooseList returns a string slice of length-limited clip history, for chooser

Types

type Buffer added in v0.0.10

type Buffer struct {

	// Filename is the filename of file last loaded or saved,
	// which is used when highlighting code.
	Filename core.Filename `json:"-" xml:"-"`

	// Flags are key state flags
	Flags BufferFlags

	// Txt is the current value of the entire text being edited,
	// as a byte slice for greater efficiency.
	Txt []byte `json:"-" xml:"text"`

	// if true, auto-save file after changes (in a separate routine)
	Autosave bool

	// options for how text editing / viewing works
	Opts textbuf.Opts

	// full info about file
	Info fileinfo.FileInfo

	// Parsing state info for file
	ParseState parse.FileStates

	// syntax highlighting markup parameters (language, style, etc)
	Hi HiMarkup

	// number of lines
	NLines int `json:"-" xml:"-"`

	// icons for given lines -- use SetLineIcon and DeleteLineIcon
	LineIcons map[int]icons.Icon

	// LineColors are special line number background colors
	// for certain lines; use SetLineColor and DeleteLineColor.
	LineColors map[int]image.Image

	// icons for each LineIcons being used
	Icons map[icons.Icon]*core.Icon `json:"-" xml:"-"`

	// the live lines of text being edited, with latest modifications -- encoded as runes per line, which is necessary for one-to-one rune / glyph rendering correspondence -- all TextPos positions etc are in *rune* indexes, not byte indexes!
	Lines [][]rune `json:"-" xml:"-"`

	// the live lines of text being edited, with latest modifications -- encoded in bytes per line translated from Lines, and used for input to markup -- essential to use Lines and not LineBytes when dealing with TextPos positions, which are in runes
	LineBytes [][]byte `json:"-" xml:"-"`

	// extra custom tagged regions for each line
	Tags []lexer.Line `json:"-" xml:"-"`

	// syntax highlighting tags -- auto-generated
	HiTags []lexer.Line `json:"-" xml:"-"`

	// marked-up version of the edit text lines, after being run through the syntax highlighting process etc -- this is what is actually rendered
	Markup [][]byte `json:"-" xml:"-"`

	// edits that have been made since last full markup
	MarkupEdits []*textbuf.Edit `json:"-" xml:"-"`

	// offsets for start of each line in Txt byte slice -- this is NOT updated with edits -- call SetByteOffs to set it when needed -- used for re-generating the Txt in LinesToBytes, and set on initial open in BytesToLines
	ByteOffs []int `json:"-" xml:"-"`

	// total bytes in document -- see ByteOffs for when it is updated
	TotalBytes int `json:"-" xml:"-"`

	// mutex for updating lines
	LinesMu sync.RWMutex `json:"-" xml:"-"`

	// mutex for updating markup
	MarkupMu sync.RWMutex `json:"-" xml:"-"`

	// markup delay timer
	MarkupDelayTimer *time.Timer `json:"-" xml:"-"`

	// mutex for updating markup delay timer
	MarkupDelayMu sync.Mutex `json:"-" xml:"-"`

	// the [Editor]s that are currently viewing this buffer
	Editors []*Editor `json:"-" xml:"-"`

	// undo manager
	Undos textbuf.Undo `json:"-" xml:"-"`

	// history of cursor positions -- can move back through them
	PosHistory []lexer.Pos `json:"-" xml:"-"`

	// functions and data for text completion
	Complete *core.Complete `json:"-" xml:"-"`

	// functions and data for spelling correction
	Spell *Spell `json:"-" xml:"-"`

	// current text editor -- e.g., the one that initiated Complete or Correct process -- update cursor position in this view -- is reset to nil after usage always
	CurView *Editor `json:"-" xml:"-"`

	// supports standard system events sending: Change is sent for BufDone, BufInsert, BufDelete
	Listeners events.Listeners
}

Buffer is a buffer of text, which can be viewed by Editor(s). It holds the raw text lines (in original string and rune formats, and marked-up from syntax highlighting), and sends signals for making edits to the text and coordinating those edits across multiple views. Views always only view a single buffer, so they directly call methods on the buffer to drive updates, which are then broadcast. It also has methods for loading and saving buffers to files. Unlike GUI Widgets, its methods generally send events, without an explicit Action suffix. Internally, the buffer represents new lines using \n = LF, but saving and loading can deal with Windows/DOS CRLF format.

func NewBuffer added in v0.0.10

func NewBuffer() *Buffer

NewBuffer makes a new Buffer with default settings and initializes it.

func (*Buffer) AddTag added in v0.0.10

func (tb *Buffer) AddTag(ln, st, ed int, tag token.Tokens)

AddTag adds a new custom tag for given line, at given position

func (*Buffer) AddTagEdit added in v0.0.10

func (tb *Buffer) AddTagEdit(tbe *textbuf.Edit, tag token.Tokens)

AddTagEdit adds a new custom tag for given line, using textbuf.Edit for location

func (*Buffer) AddView added in v0.0.10

func (tb *Buffer) AddView(vw *Editor)

AddView adds a viewer of this buffer -- connects our signals to the viewer

func (*Buffer) AdjustPos added in v0.0.10

func (tb *Buffer) AdjustPos(pos lexer.Pos, t time.Time, del textbuf.AdjustPosDel) lexer.Pos

AdjustPos adjusts given text position, which was recorded at given time for any edits that have taken place since that time (using the Undo stack). del determines what to do with positions within a deleted region -- either move to start or end of the region, or return an error

func (*Buffer) AdjustReg added in v0.0.10

func (tb *Buffer) AdjustReg(reg textbuf.Region) textbuf.Region

AdjustReg adjusts given text region for any edits that have taken place since time stamp on region (using the Undo stack). If region was wholly within a deleted region, then RegionNil will be returned -- otherwise it is clipped appropriately as function of deletes.

func (*Buffer) AdjustedTags added in v0.0.10

func (tb *Buffer) AdjustedTags(ln int) lexer.Line

AdjustedTags updates tag positions for edits must be called under MarkupMu lock

func (*Buffer) AdjustedTagsImpl added in v0.0.10

func (tb *Buffer) AdjustedTagsImpl(tags lexer.Line, ln int) lexer.Line

AdjustedTagsImpl updates tag positions for edits, for given list of tags

func (*Buffer) AppendText added in v0.0.10

func (tb *Buffer) AppendText(text []byte, signal bool) *textbuf.Edit

AppendText appends new text to end of buffer, using insert, returns edit

func (*Buffer) AppendTextLine added in v0.0.10

func (tb *Buffer) AppendTextLine(text []byte, signal bool) *textbuf.Edit

AppendTextLine appends one line of new text to end of buffer, using insert, and appending a LF at the end of the line if it doesn't already have one. Returns the edit region.

func (*Buffer) AppendTextLineMarkup added in v0.0.10

func (tb *Buffer) AppendTextLineMarkup(text []byte, markup []byte, signal bool) *textbuf.Edit

AppendTextLineMarkup appends one line of new text to end of buffer, using insert, and appending a LF at the end of the line if it doesn't already have one. user-supplied markup is used. Returns the edit region.

func (*Buffer) AppendTextMarkup added in v0.0.10

func (tb *Buffer) AppendTextMarkup(text []byte, markup []byte, signal bool) *textbuf.Edit

AppendTextMarkup appends new text to end of buffer, using insert, returns edit, and uses supplied markup to render it

func (*Buffer) AutoIndent added in v0.0.10

func (tb *Buffer) AutoIndent(ln int) (tbe *textbuf.Edit, indLev, chPos int)

AutoIndent indents given line to the level of the prior line, adjusted appropriately if the current line starts with one of the given un-indent strings, or the prior line ends with one of the given indent strings. Returns any edit that took place (could be nil), along with the auto-indented level and character position for the indent of the current line.

func (*Buffer) AutoIndentRegion added in v0.0.10

func (tb *Buffer) AutoIndentRegion(st, ed int)

AutoIndentRegion does auto-indent over given region -- end is *exclusive*

func (*Buffer) AutoSave added in v0.0.10

func (tb *Buffer) AutoSave() error

AutoSave does the autosave -- safe to call in a separate goroutine

func (*Buffer) AutoSaveCheck added in v0.0.10

func (tb *Buffer) AutoSaveCheck() bool

AutoSaveCheck checks if an autosave file exists -- logic for dealing with it is left to larger app -- call this before opening a file

func (*Buffer) AutoSaveDelete added in v0.0.10

func (tb *Buffer) AutoSaveDelete()

AutoSaveDelete deletes any existing autosave file

func (*Buffer) AutoSaveFilename added in v0.0.10

func (tb *Buffer) AutoSaveFilename() string

AutoSaveFilename returns the autosave filename

func (*Buffer) AutoSaveOff added in v0.0.10

func (tb *Buffer) AutoSaveOff() bool

AutoSaveOff turns off autosave and returns the prior state of Autosave flag. Call AutoSaveRestore with rval when done. See BatchUpdate methods for auto-use of this.

func (*Buffer) AutoSaveRestore added in v0.0.10

func (tb *Buffer) AutoSaveRestore(asv bool)

AutoSaveRestore restores prior Autosave setting, from AutoSaveOff

func (*Buffer) AutoScrollViews added in v0.0.10

func (tb *Buffer) AutoScrollViews()

AutoscrollViews ensures that views are always viewing the end of the buffer

func (*Buffer) BatchUpdateEnd added in v0.0.10

func (tb *Buffer) BatchUpdateEnd(autoSave bool)

BatchUpdateEnd call to complete BatchUpdateStart

func (*Buffer) BatchUpdateStart added in v0.0.10

func (tb *Buffer) BatchUpdateStart() (autoSave bool)

BatchUpdateStart call this when starting a batch of updates. It calls AutoSaveOff and returns the prior state of that flag which must be restored using BatchUpdateEnd.

func (*Buffer) BraceMatch added in v0.0.10

func (tb *Buffer) BraceMatch(r rune, st lexer.Pos) (en lexer.Pos, found bool)

BraceMatch finds the brace, bracket, or parens that is the partner of the one passed to function.

func (*Buffer) BytesLine added in v0.0.10

func (tb *Buffer) BytesLine(ln int) []byte

BytesLine is the concurrent-safe accessor to specific Line of LineBytes

func (*Buffer) BytesToLines added in v0.0.10

func (tb *Buffer) BytesToLines()

BytesToLines converts current Txt bytes into lines, and initializes markup with raw text

func (*Buffer) ClearChanged added in v0.0.10

func (tb *Buffer) ClearChanged()

ClearChanged marks buffer as un-changed

func (*Buffer) ClearNotSaved added in v0.0.10

func (tb *Buffer) ClearNotSaved()

ClearNotSaved resets the BufNotSaved flag, and also calls ClearChanged

func (*Buffer) Close added in v0.0.10

func (tb *Buffer) Close(afterFun func(canceled bool)) bool

Close closes the buffer -- prompts to save if changes, and disconnects from views if afterFun is non-nil, then it is called with the status of the user action

func (*Buffer) CommentRegion added in v0.0.10

func (tb *Buffer) CommentRegion(st, ed int)

CommentRegion inserts comment marker on given lines -- end is *exclusive*

func (*Buffer) CommentStart added in v0.0.10

func (tb *Buffer) CommentStart(ln int) int

CommentStart returns the char index where the comment starts on given line, -1 if no comment

func (*Buffer) CompleteExtend added in v0.0.10

func (tb *Buffer) CompleteExtend(s string)

CompleteExtend inserts the extended seed at the current cursor position

func (*Buffer) CompleteText added in v0.0.10

func (tb *Buffer) CompleteText(s string)

CompleteText edits the text using the string chosen from the completion menu

func (*Buffer) ConfigKnown added in v0.0.10

func (tb *Buffer) ConfigKnown() bool

ConfigKnown configures options based on the supported language info in parse. Returns true if supported.

func (*Buffer) CorrectClear added in v0.0.10

func (tb *Buffer) CorrectClear(s string)

CorrectClear clears the TextSpellErr tag for given word

func (*Buffer) CorrectText added in v0.0.10

func (tb *Buffer) CorrectText(s string)

CorrectText edits the text using the string chosen from the correction menu

func (*Buffer) DeleteCompleter added in v0.0.10

func (tb *Buffer) DeleteCompleter()

func (*Buffer) DeleteLineColor added in v0.0.10

func (tb *Buffer) DeleteLineColor(ln int)

HasLineColor

func (*Buffer) DeleteLineIcon added in v0.0.10

func (tb *Buffer) DeleteLineIcon(ln int)

DeleteLineIcon deletes any icon at given line (0 starting) if ln = -1 then delete all line icons.

func (*Buffer) DeleteSpell added in v0.0.10

func (tb *Buffer) DeleteSpell()

DeleteSpell deletes any existing spell object

func (*Buffer) DeleteText added in v0.0.10

func (tb *Buffer) DeleteText(st, ed lexer.Pos, signal bool) *textbuf.Edit

DeleteText is the primary method for deleting text from the buffer. It deletes region of text between start and end positions, optionally signaling views after text lines have been updated. Sets the timestamp on resulting Edit to now. An Undo record is automatically saved depending on Undo.Off setting.

func (*Buffer) DeleteTextImpl added in v0.0.10

func (tb *Buffer) DeleteTextImpl(st, ed lexer.Pos) *textbuf.Edit

DeleteTextImpl deletes region of text between start and end positions. Sets the timestamp on resulting textbuf.Edit to now. Must be called under LinesMu.Lock.

func (*Buffer) DeleteTextRect added in v0.0.10

func (tb *Buffer) DeleteTextRect(st, ed lexer.Pos, signal bool) *textbuf.Edit

DeleteTextRect deletes rectangular region of text between start, end defining the upper-left and lower-right corners of a rectangle. Fails if st.Ch >= ed.Ch. Sets the timestamp on resulting textbuf.Edit to now. An Undo record is automatically saved depending on Undo.Off setting.

func (*Buffer) DeleteTextRectImpl added in v0.0.10

func (tb *Buffer) DeleteTextRectImpl(st, ed lexer.Pos) *textbuf.Edit

DeleteTextRectImpl deletes rectangular region of text between start, end defining the upper-left and lower-right corners of a rectangle. Fails if st.Ch >= ed.Ch. Sets the timestamp on resulting textbuf.Edit to now. Must be called under LinesMu.Lock.

func (*Buffer) DeleteView added in v0.0.10

func (tb *Buffer) DeleteView(vw *Editor)

DeleteView removes given viewer from our buffer

func (*Buffer) DiffBuffers added in v0.0.10

func (tb *Buffer) DiffBuffers(ob *Buffer) textbuf.Diffs

DiffBuffers computes the diff between this buffer and the other buffer, reporting a sequence of operations that would convert this buffer (a) into the other buffer (b). Each operation is either an 'r' (replace), 'd' (delete), 'i' (insert) or 'e' (equal). Everything is line-based (0, offset).

func (*Buffer) DiffBuffersUnified added in v0.0.10

func (tb *Buffer) DiffBuffersUnified(ob *Buffer, context int) []byte

DiffBuffersUnified computes the diff between this buffer and the other buffer, returning a unified diff with given amount of context (default of 3 will be used if -1)

func (*Buffer) EditDone added in v0.0.10

func (tb *Buffer) EditDone()

EditDone finalizes any current editing, sends signal

func (*Buffer) EmacsUndoSave added in v0.0.10

func (tb *Buffer) EmacsUndoSave()

EmacsUndoSave is called by View at end of latest set of undo commands. If EmacsUndo mode is active, saves the current UndoStack to the regular Undo stack at the end, and moves undo to the very end -- undo is a constant stream.

func (*Buffer) EndPos added in v0.0.10

func (tb *Buffer) EndPos() lexer.Pos

EndPos returns the ending position at end of buffer

func (*Buffer) FileModCheck added in v0.0.10

func (tb *Buffer) FileModCheck() bool

FileModCheck checks if the underlying file has been modified since last Stat (open, save) -- if haven't yet prompted, user is prompted to ensure that this is OK. returns true if file was modified

func (*Buffer) HasLineColor added in v0.0.10

func (tb *Buffer) HasLineColor(ln int) bool

HasLineColor checks if given line has a line color set

func (*Buffer) HiTagAtPos added in v0.0.10

func (tb *Buffer) HiTagAtPos(pos lexer.Pos) (*lexer.Lex, int)

HiTagAtPos returns the highlighting (markup) lexical tag at given position using current Markup tags, and index, -- could be nil if none or out of range

func (*Buffer) InComment added in v0.0.10

func (tb *Buffer) InComment(pos lexer.Pos) bool

InComment returns true if the given text position is within a commented region

func (*Buffer) InLitString added in v0.0.10

func (tb *Buffer) InLitString(pos lexer.Pos) bool

InLitString returns true if position is in a string literal

func (*Buffer) InTokenCode added in v0.0.10

func (tb *Buffer) InTokenCode(pos lexer.Pos) bool

InTokenCode returns true if position is in a Keyword, Name, Operator, or Punctuation. This is useful for turning off spell checking in docs

func (*Buffer) InTokenSubCat added in v0.0.10

func (tb *Buffer) InTokenSubCat(pos lexer.Pos, subCat token.Tokens) bool

InTokenSubCat returns true if the given text position is marked with lexical type in given SubCat sub-category

func (*Buffer) IndentLine added in v0.0.10

func (tb *Buffer) IndentLine(ln, ind int) *textbuf.Edit

IndentLine indents line by given number of tab stops, using tabs or spaces, for given tab size (if using spaces) -- either inserts or deletes to reach target. Returns edit record for any change.

func (*Buffer) InitialMarkup added in v0.0.10

func (tb *Buffer) InitialMarkup()

InitialMarkup does the first-pass markup on the file

func (*Buffer) InsertText added in v0.0.10

func (tb *Buffer) InsertText(st lexer.Pos, text []byte, signal bool) *textbuf.Edit

InsertText is the primary method for inserting text into the buffer. It inserts new text at given starting position, optionally signaling views after text has been inserted. Sets the timestamp on resulting Edit to now. An Undo record is automatically saved depending on Undo.Off setting.

func (*Buffer) InsertTextImpl added in v0.0.10

func (tb *Buffer) InsertTextImpl(st lexer.Pos, text []byte) *textbuf.Edit

InsertTextImpl does the raw insert of new text at given starting position, returning a new Edit with timestamp of Now. LinesMu must be locked surrounding this call.

func (*Buffer) InsertTextRect added in v0.0.10

func (tb *Buffer) InsertTextRect(tbe *textbuf.Edit, signal bool) *textbuf.Edit

InsertTextRect inserts a rectangle of text defined in given textbuf.Edit record, (e.g., from RegionRect or DeleteRect), optionally signaling views after text has been inserted. Returns a copy of the Edit record with an updated timestamp. An Undo record is automatically saved depending on Undo.Off setting.

func (*Buffer) InsertTextRectImpl added in v0.0.10

func (tb *Buffer) InsertTextRectImpl(tbe *textbuf.Edit) *textbuf.Edit

InsertTextRectImpl does the raw insert of new text at given starting position, using a Rect textbuf.Edit (e.g., from RegionRect or DeleteRect). Returns a copy of the Edit record with an updated timestamp.

func (*Buffer) Is added in v0.0.10

func (tb *Buffer) Is(flag enums.BitFlag) bool

Is returns true if given flag is set

func (*Buffer) IsChanged added in v0.0.10

func (tb *Buffer) IsChanged() bool

IsChanged indicates if the text has been changed (edited) relative to the original, since last EditDone

func (*Buffer) IsMarkingUp added in v0.0.10

func (tb *Buffer) IsMarkingUp() bool

IsMarkingUp is true if the MarkupAllLines process is currently running

func (*Buffer) IsNotSaved added in v0.0.10

func (tb *Buffer) IsNotSaved() bool

IsNotSaved indicates if the text has been changed (edited) relative to the original, since last Save

func (*Buffer) IsSpellEnabled added in v0.0.10

func (tb *Buffer) IsSpellEnabled(pos lexer.Pos) bool

IsSpellEnabled returns true if spelling correction is enabled, taking into account given position in text if it is relevant for cases where it is only conditionally enabled

func (*Buffer) IsValidLine added in v0.0.10

func (tb *Buffer) IsValidLine(ln int) bool

IsValidLine returns true if given line is in range

func (*Buffer) JoinParaLines added in v0.0.10

func (tb *Buffer) JoinParaLines(stLn, edLn int)

JoinParaLines merges sequences of lines with hard returns forming paragraphs, separated by blank lines, into a single line per paragraph, within the given line regions -- edLn is *inclusive*

func (*Buffer) LexObjPathString added in v0.0.10

func (tb *Buffer) LexObjPathString(ln int, lx *lexer.Lex) string

LexObjPathString returns the string at given lex, and including prior lex-tagged regions that include sequences of PunctSepPeriod and NameTag which are used for object paths -- used for e.g., debugger to pull out variable expressions that can be evaluated.

func (*Buffer) LexString added in v0.0.10

func (tb *Buffer) LexString(ln int, lx *lexer.Lex) string

LexString returns the string associated with given Lex (Tag) at given line

func (*Buffer) Line added in v0.0.10

func (tb *Buffer) Line(ln int) []rune

Line is the concurrent-safe accessor to specific Line of Lines runes

func (*Buffer) LineCommented added in v0.0.10

func (tb *Buffer) LineCommented(ln int) bool

LineCommented returns true if the given line is a full-comment line (i.e., starts with a comment)

func (*Buffer) LineLen added in v0.0.10

func (tb *Buffer) LineLen(ln int) int

LineLen is the concurrent-safe accessor to length of specific Line of Lines runes

func (*Buffer) LinesDeleted added in v0.0.10

func (tb *Buffer) LinesDeleted(tbe *textbuf.Edit)

LinesDeleted deletes lines in Markup corresponding to lines deleted in Lines text. Locks and unlocks the Markup mutex, and must be called under lines mutex.

func (*Buffer) LinesEdited added in v0.0.10

func (tb *Buffer) LinesEdited(tbe *textbuf.Edit)

LinesEdited re-marks-up lines in edit (typically only 1). Locks and unlocks the Markup mutex. Must be called under Lines mutex lock.

func (*Buffer) LinesInserted added in v0.0.10

func (tb *Buffer) LinesInserted(tbe *textbuf.Edit)

LinesInserted inserts new lines in Markup corresponding to lines inserted in Lines text. Locks and unlocks the Markup mutex, and must be called under lines mutex

func (*Buffer) LinesToBytes added in v0.0.10

func (tb *Buffer) LinesToBytes()

LinesToBytes converts current Lines back to the Txt slice of bytes.

func (*Buffer) LinesToBytesCopy added in v0.0.10

func (tb *Buffer) LinesToBytesCopy() []byte

LinesToBytesCopy converts current Lines into a separate text byte copy -- e.g., for autosave or other "offline" uses of the text -- doesn't affect byte offsets etc

func (*Buffer) MarkupAllLines added in v0.0.10

func (tb *Buffer) MarkupAllLines(maxLines int)

MarkupAllLines does syntax highlighting markup for all lines in buffer, calling MarkupMu mutex when setting the marked-up lines with the result -- designed to be called in a separate goroutine. if maxLines > 0 then it specifies a maximum number of lines (for InitialMarkup)

func (*Buffer) MarkupFromTags added in v0.0.10

func (tb *Buffer) MarkupFromTags()

MarkupFromTags does syntax highlighting markup using existing HiTags without running new tagging -- for special case where tagging is under external control

func (*Buffer) MarkupLine added in v0.0.10

func (tb *Buffer) MarkupLine(ln int)

MarkupLine does markup on a single line

func (*Buffer) MarkupLines added in v0.0.10

func (tb *Buffer) MarkupLines(st, ed int) bool

MarkupLines generates markup of given range of lines. end is *inclusive* line. returns true if all lines were marked up successfully. This does NOT lock the MarkupMu mutex (done at outer loop)

func (*Buffer) MarkupLinesLock added in v0.0.10

func (tb *Buffer) MarkupLinesLock(st, ed int) bool

MarkupLinesLock does MarkupLines and gets the mutex lock first

func (*Buffer) NewBuffer added in v0.0.10

func (tb *Buffer) NewBuffer(nlines int)

New initializes a new buffer with n blank lines

func (*Buffer) NumLines added in v0.0.10

func (tb *Buffer) NumLines() int

NumLines is the concurrent-safe accessor to NLines

func (*Buffer) OnChange added in v0.0.10

func (tb *Buffer) OnChange(fun func(e events.Event))

OnChange adds an event listener function for the events.Change event

func (*Buffer) OnInput added in v0.0.10

func (tb *Buffer) OnInput(fun func(e events.Event))

OnInput adds an event listener function for the events.Input event

func (*Buffer) Open added in v0.0.10

func (tb *Buffer) Open(filename core.Filename) error

Open loads the given file into the buffer.

func (*Buffer) OpenFS added in v0.0.10

func (tb *Buffer) OpenFS(fsys fs.FS, filename string) error

OpenFS loads the given file in the given filesystem into the buffer.

func (*Buffer) OpenFile added in v0.0.10

func (tb *Buffer) OpenFile(filename core.Filename) error

OpenFile just loads the given file into the buffer, without doing any markup or signaling. It is typically used in other functions or for temporary buffers.

func (*Buffer) PatchFromBuffer added in v0.0.10

func (tb *Buffer) PatchFromBuffer(ob *Buffer, diffs textbuf.Diffs, signal bool) bool

PatchFromBuffer patches (edits) this buffer using content from other buffer, according to diff operations (e.g., as generated from DiffBufs). signal determines whether each patch is signaled -- if an overall signal will be sent at the end, then that would not be necessary (typical)

func (*Buffer) ReMarkup added in v0.0.10

func (tb *Buffer) ReMarkup()

ReMarkup runs re-markup on text in background

func (*Buffer) Redo added in v0.0.10

func (tb *Buffer) Redo() *textbuf.Edit

Redo redoes next group of items on the undo stack, and returns the last record, nil if no more

func (*Buffer) Region added in v0.0.10

func (tb *Buffer) Region(st, ed lexer.Pos) *textbuf.Edit

Region returns a textbuf.Edit representation of text between start and end positions returns nil if not a valid region. sets the timestamp on the textbuf.Edit to now

func (*Buffer) RegionImpl added in v0.0.10

func (tb *Buffer) RegionImpl(st, ed lexer.Pos) *textbuf.Edit

RegionImpl returns a textbuf.Edit representation of text between start and end positions. Returns nil if not a valid region. Sets the timestamp on the textbuf.Edit to now. Impl version must be called under LinesMu.RLock or Lock

func (*Buffer) RegionRect added in v0.0.10

func (tb *Buffer) RegionRect(st, ed lexer.Pos) *textbuf.Edit

RegionRect returns a textbuf.Edit representation of text between start and end positions as a rectangle, returns nil if not a valid region. sets the timestamp on the textbuf.Edit to now

func (*Buffer) RegionRectImpl added in v0.0.10

func (tb *Buffer) RegionRectImpl(st, ed lexer.Pos) *textbuf.Edit

RegionRectImpl returns a textbuf.Edit representation of rectangle of text between start (upper left) and end (bottom right) positions. Returns nil if not a valid region. All lines in Text are guaranteed to be of the same size, even if line had fewer chars. Sets the timestamp on the textbuf.Edit to now. Impl version must be called under LinesMu.RLock or Lock

func (*Buffer) RemoveTag added in v0.0.10

func (tb *Buffer) RemoveTag(pos lexer.Pos, tag token.Tokens) (reg lexer.Lex, ok bool)

RemoveTag removes tag (optionally only given tag if non-zero) at given position if it exists -- returns tag

func (*Buffer) ReplaceText added in v0.0.10

func (tb *Buffer) ReplaceText(delSt, delEd, insPos lexer.Pos, insTxt string, signal, matchCase bool) *textbuf.Edit

ReplaceText does DeleteText for given region, and then InsertText at given position (typically same as delSt but not necessarily), optionally emitting a signal after the insert. if matchCase is true, then the lexer.MatchCase function is called to match the case (upper / lower) of the new inserted text to that of the text being replaced. returns the textbuf.Edit for the inserted text.

func (*Buffer) Revert added in v0.0.10

func (tb *Buffer) Revert() bool

Revert re-opens text from current file, if filename set -- returns false if not -- uses an optimized diff-based update to preserve existing formatting -- very fast if not very different

func (*Buffer) Save added in v0.0.10

func (tb *Buffer) Save() error

Save saves the current text into current Filename associated with this buffer

func (*Buffer) SaveAs added in v0.0.10

func (tb *Buffer) SaveAs(filename core.Filename)

SaveAs saves the current text into given file -- does an EditDone first to save edits and checks for an existing file -- if it does exist then prompts to overwrite or not.

func (*Buffer) SaveAsFunc added in v0.0.10

func (tb *Buffer) SaveAsFunc(filename core.Filename, afterFunc func(canceled bool))

SaveAsFunc saves the current text into given file. Does an EditDone first to save edits and checks for an existing file. If it does exist then prompts to overwrite or not. If afterFunc is non-nil, then it is called with the status of the user action.

func (*Buffer) SaveFile added in v0.0.10

func (tb *Buffer) SaveFile(filename core.Filename) error

SaveFile writes current buffer to file, with no prompting, etc

func (*Buffer) SavePosHistory added in v0.0.10

func (tb *Buffer) SavePosHistory(pos lexer.Pos) bool

SavePosHistory saves the cursor position in history stack of cursor positions -- tracks across views -- returns false if position was on same line as last one saved

func (*Buffer) SaveUndo added in v0.0.10

func (tb *Buffer) SaveUndo(tbe *textbuf.Edit)

SaveUndo saves given edit to undo stack

func (*Buffer) SceneFromView added in v0.0.10

func (tb *Buffer) SceneFromView() *core.Scene

SceneFromView returns Scene from text editor, if avail

func (*Buffer) Search added in v0.0.10

func (tb *Buffer) Search(find []byte, ignoreCase, lexItems bool) (int, []textbuf.Match)

Search looks for a string (no regexp) within buffer, with given case-sensitivity, returning number of occurrences and specific match position list. column positions are in runes.

func (*Buffer) SearchRegexp added in v0.0.10

func (tb *Buffer) SearchRegexp(re *regexp.Regexp) (int, []textbuf.Match)

SearchRegexp looks for a string (regexp) within buffer, returning number of occurrences and specific match position list. Column positions are in runes.

func (*Buffer) SetByteOffs added in v0.0.10

func (tb *Buffer) SetByteOffs()

SetByteOffs sets the byte offsets for each line into the raw text

func (*Buffer) SetChanged added in v0.0.10

func (tb *Buffer) SetChanged()

SetChanged marks buffer as changed

func (*Buffer) SetCompleter added in v0.0.10

func (tb *Buffer) SetCompleter(data any, matchFun complete.MatchFunc, editFun complete.EditFunc,
	lookupFun complete.LookupFunc)

SetCompleter sets completion functions so that completions will automatically be offered as the user types

func (*Buffer) SetFilename added in v0.0.10

func (tb *Buffer) SetFilename(fn string) *Buffer

SetFilename sets the filename associated with the buffer and updates the code highlighting information accordingly.

func (*Buffer) SetFlag added in v0.0.10

func (tb *Buffer) SetFlag(on bool, flag ...enums.BitFlag)

SetFlag sets value of given flag(s)

func (*Buffer) SetHiStyle added in v0.0.10

func (tb *Buffer) SetHiStyle(style core.HiStyleName) *Buffer

SetHiStyle sets the highlighting style -- needs to be protected by mutex

func (*Buffer) SetLang added in v0.0.10

func (tb *Buffer) SetLang(lang string) *Buffer

SetLang sets the language for highlighting and updates the highlighting style and buffer accordingly.

func (*Buffer) SetLineColor added in v0.0.10

func (tb *Buffer) SetLineColor(ln int, clr image.Image)

SetLineColor sets given color at given line (0 starting)

func (*Buffer) SetLineIcon added in v0.0.10

func (tb *Buffer) SetLineIcon(ln int, icon icons.Icon)

SetLineIcon sets given icon at given line (0 starting)

func (*Buffer) SetReadOnly added in v0.0.10

func (tb *Buffer) SetReadOnly(readonly bool) *Buffer

SetReadOnly sets the buffer in a ReadOnly state if readonly = true otherwise is in editable state.

func (*Buffer) SetSpell added in v0.0.10

func (tb *Buffer) SetSpell()

SetSpell sets spell correct functions so that spell correct will automatically be offered as the user types

func (*Buffer) SetText added in v0.0.10

func (tb *Buffer) SetText(txt []byte) *Buffer

SetText sets the text to the given bytes.

func (*Buffer) SetTextLines added in v0.0.10

func (tb *Buffer) SetTextLines(lns [][]byte, cpy bool)

SetTextLines sets the text to given lines of bytes if cpy is true, make a copy of bytes -- otherwise use

func (*Buffer) SetTextString added in v0.0.10

func (tb *Buffer) SetTextString(txt string) *Buffer

SetTextString sets the text to the given string.

func (*Buffer) SignalEditors added in v0.0.10

func (tb *Buffer) SignalEditors(sig BufferSignals, edit *textbuf.Edit)

SignalEditors sends the given signal and optional edit info to all the [Editor]s for this Buffer

func (*Buffer) SignalMods added in v0.0.10

func (tb *Buffer) SignalMods()

SignalMods sends the BufMods signal for misc, potentially widespread modifications to buffer.

func (*Buffer) SpacesToTabs added in v0.0.10

func (tb *Buffer) SpacesToTabs(ln int)

SpacesToTabs replaces spaces with tabs in given line.

func (*Buffer) SpacesToTabsRegion added in v0.0.10

func (tb *Buffer) SpacesToTabsRegion(st, ed int)

SpacesToTabsRegion replaces tabs with spaces over given region -- end is *exclusive*

func (*Buffer) SpellCheckLineErrs added in v0.0.10

func (tb *Buffer) SpellCheckLineErrs(ln int) lexer.Line

SpellCheckLineErrs runs spell check on given line, and returns Lex tags with token.TextSpellErr for any misspelled words

func (*Buffer) SpellCheckLineTag added in v0.0.10

func (tb *Buffer) SpellCheckLineTag(ln int)

SpellCheckLineTag runs spell check on given line, and sets Tags for any misspelled words and updates markup for that line.

func (*Buffer) StartDelayedReMarkup added in v0.0.10

func (tb *Buffer) StartDelayedReMarkup()

StartDelayedReMarkup starts a timer for doing markup after an interval

func (*Buffer) Stat added in v0.0.10

func (tb *Buffer) Stat() error

Stat gets info about the file, including highlighting language

func (*Buffer) StopDelayedReMarkup added in v0.0.10

func (tb *Buffer) StopDelayedReMarkup()

StopDelayedReMarkup stops timer for doing markup after an interval

func (*Buffer) Strings added in v0.0.10

func (tb *Buffer) Strings(addNewLn bool) []string

Strings returns the current text as []string array. If addNewLn is true, each string line has a \n appended at end.

func (*Buffer) TabsToSpaces added in v0.0.10

func (tb *Buffer) TabsToSpaces(ln int)

TabsToSpaces replaces tabs with spaces in given line.

func (*Buffer) TabsToSpacesRegion added in v0.0.10

func (tb *Buffer) TabsToSpacesRegion(st, ed int)

TabsToSpacesRegion replaces tabs with spaces over given region -- end is *exclusive*

func (*Buffer) TagAt added in v0.0.10

func (tb *Buffer) TagAt(pos lexer.Pos) (reg lexer.Lex, ok bool)

TagAt returns tag at given text position, if one exists -- returns false if not

func (*Buffer) Text added in v0.0.10

func (tb *Buffer) Text() []byte

Text returns the current text as a []byte array, applying all current changes -- calls EditDone and will generate that signal if there have been changes

func (*Buffer) Undo added in v0.0.10

func (tb *Buffer) Undo() *textbuf.Edit

Undo undoes next group of items on the undo stack

func (*Buffer) Update added in v0.0.10

func (tb *Buffer) Update()

func (*Buffer) ValidPos added in v0.0.10

func (tb *Buffer) ValidPos(pos lexer.Pos) lexer.Pos

ValidPos returns a position that is in a valid range

type BufferFlags added in v0.0.10

type BufferFlags core.WidgetFlags //enums:bitflag -trim-prefix Buffer

BufferFlags hold key Buf state

const (
	// BufferAutoSaving is used in atomically safe way to protect autosaving
	BufferAutoSaving BufferFlags = BufferFlags(core.WidgetFlagsN) + iota

	// BufferMarkingUp indicates current markup operation in progress -- don't redo
	BufferMarkingUp

	// BufferChanged indicates if the text has been changed (edited) relative to the
	// original, since last EditDone
	BufferChanged

	// BufferNotSaved indicates if the text has been changed (edited) relative to the
	// original, since last Save
	BufferNotSaved

	// BufferFileModOK have already asked about fact that file has changed since being
	// opened, user is ok
	BufferFileModOK
)
const BufferFlagsN BufferFlags = 7

BufferFlagsN is the highest valid value for type BufferFlags, plus one.

func BufferFlagsValues added in v0.0.10

func BufferFlagsValues() []BufferFlags

BufferFlagsValues returns all possible values for the type BufferFlags.

func (BufferFlags) BitIndexString added in v0.0.10

func (i BufferFlags) BitIndexString() string

BitIndexString returns the string representation of this BufferFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.

func (BufferFlags) Desc added in v0.0.10

func (i BufferFlags) Desc() string

Desc returns the description of the BufferFlags value.

func (BufferFlags) HasFlag added in v0.0.10

func (i BufferFlags) HasFlag(f enums.BitFlag) bool

HasFlag returns whether these bit flags have the given bit flag set.

func (BufferFlags) Int64 added in v0.0.10

func (i BufferFlags) Int64() int64

Int64 returns the BufferFlags value as an int64.

func (BufferFlags) MarshalText added in v0.0.10

func (i BufferFlags) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*BufferFlags) SetFlag added in v0.0.10

func (i *BufferFlags) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the value of the given flags in these flags to the given value.

func (*BufferFlags) SetInt64 added in v0.0.10

func (i *BufferFlags) SetInt64(in int64)

SetInt64 sets the BufferFlags value from an int64.

func (*BufferFlags) SetString added in v0.0.10

func (i *BufferFlags) SetString(s string) error

SetString sets the BufferFlags value from its string representation, and returns an error if the string is invalid.

func (*BufferFlags) SetStringOr added in v0.0.10

func (i *BufferFlags) SetStringOr(s string) error

SetStringOr sets the BufferFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.

func (BufferFlags) String added in v0.0.10

func (i BufferFlags) String() string

String returns the string representation of this BufferFlags value.

func (*BufferFlags) UnmarshalText added in v0.0.10

func (i *BufferFlags) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (BufferFlags) Values added in v0.0.10

func (i BufferFlags) Values() []enums.Enum

Values returns all possible values for the type BufferFlags.

type BufferSignals added in v0.0.10

type BufferSignals int32 //enums:enum -trim-prefix Buffer

BufferSignals are signals that text buffer can send to View

const (
	// BufferDone means that editing was completed and applied to Txt field
	// -- data is Txt bytes
	BufferDone BufferSignals = iota

	// BufferNew signals that entirely new text is present.
	// All views should do full layout update.
	BufferNew

	// BufferMods signals that potentially diffuse modifications
	// have been made.  Views should do a Layout and Render.
	BufferMods

	// BufferInsert signals that some text was inserted.
	// data is textbuf.Edit describing change.
	// The Buf always reflects the current state *after* the edit.
	BufferInsert

	// BufferDelete signals that some text was deleted.
	// data is textbuf.Edit describing change.
	// The Buf always reflects the current state *after* the edit.
	BufferDelete

	// BufferMarkupUpdated signals that the Markup text has been updated
	// This signal is typically sent from a separate goroutine,
	// so should be used with a mutex
	BufferMarkupUpdated

	// BufferClosed signals that the textbuf was closed.
	BufferClosed
)
const BufferSignalsN BufferSignals = 7

BufferSignalsN is the highest valid value for type BufferSignals, plus one.

func BufferSignalsValues added in v0.0.10

func BufferSignalsValues() []BufferSignals

BufferSignalsValues returns all possible values for the type BufferSignals.

func (BufferSignals) Desc added in v0.0.10

func (i BufferSignals) Desc() string

Desc returns the description of the BufferSignals value.

func (BufferSignals) Int64 added in v0.0.10

func (i BufferSignals) Int64() int64

Int64 returns the BufferSignals value as an int64.

func (BufferSignals) MarshalText added in v0.0.10

func (i BufferSignals) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*BufferSignals) SetInt64 added in v0.0.10

func (i *BufferSignals) SetInt64(in int64)

SetInt64 sets the BufferSignals value from an int64.

func (*BufferSignals) SetString added in v0.0.10

func (i *BufferSignals) SetString(s string) error

SetString sets the BufferSignals value from its string representation, and returns an error if the string is invalid.

func (BufferSignals) String added in v0.0.10

func (i BufferSignals) String() string

String returns the string representation of this BufferSignals value.

func (*BufferSignals) UnmarshalText added in v0.0.10

func (i *BufferSignals) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (BufferSignals) Values added in v0.0.10

func (i BufferSignals) Values() []enums.Enum

Values returns all possible values for the type BufferSignals.

type DiffTextEditor

type DiffTextEditor struct {
	Editor
}

DiffTextEditor supports double-click based application of edits from one buffer to the other.

func NewDiffTextEditor

func NewDiffTextEditor(parent tree.Node, name ...string) *DiffTextEditor

NewDiffTextEditor adds a new DiffTextEditor with the given name to the given parent: DiffTextEditor supports double-click based application of edits from one buffer to the other.

func (*DiffTextEditor) DiffView

func (tv *DiffTextEditor) DiffView() *DiffView

func (*DiffTextEditor) HandleDoubleClick

func (tv *DiffTextEditor) HandleDoubleClick()

func (*DiffTextEditor) New

func (t *DiffTextEditor) New() tree.Node

New returns a new *DiffTextEditor value

func (*DiffTextEditor) NodeType added in v0.0.10

func (t *DiffTextEditor) NodeType() *types.Type

NodeType returns the *types.Type of DiffTextEditor

func (*DiffTextEditor) OnInit

func (tv *DiffTextEditor) OnInit()

func (*DiffTextEditor) SetCursorColor

func (t *DiffTextEditor) SetCursorColor(v image.Image) *DiffTextEditor

SetCursorColor sets the [DiffTextEditor.CursorColor]

func (*DiffTextEditor) SetCursorWidth

func (t *DiffTextEditor) SetCursorWidth(v units.Value) *DiffTextEditor

SetCursorWidth sets the [DiffTextEditor.CursorWidth]

func (*DiffTextEditor) SetHighlightColor

func (t *DiffTextEditor) SetHighlightColor(v image.Image) *DiffTextEditor

SetHighlightColor sets the [DiffTextEditor.HighlightColor]

func (*DiffTextEditor) SetLineNumberColor

func (t *DiffTextEditor) SetLineNumberColor(v image.Image) *DiffTextEditor

SetLineNumberColor sets the [DiffTextEditor.LineNumberColor]

func (*DiffTextEditor) SetLinkHandler

func (t *DiffTextEditor) SetLinkHandler(v func(tl *paint.TextLink)) *DiffTextEditor

SetLinkHandler sets the [DiffTextEditor.LinkHandler]

func (*DiffTextEditor) SetSelectColor

func (t *DiffTextEditor) SetSelectColor(v image.Image) *DiffTextEditor

SetSelectColor sets the [DiffTextEditor.SelectColor]

func (*DiffTextEditor) SetTooltip

func (t *DiffTextEditor) SetTooltip(v string) *DiffTextEditor

SetTooltip sets the [DiffTextEditor.Tooltip]

type DiffView

type DiffView struct {
	core.Frame

	// first file name being compared
	FileA string

	// second file name being compared
	FileB string

	// revision for first file, if relevant
	RevA string

	// revision for second file, if relevant
	RevB string

	// textbuf for A showing the aligned edit view
	BufA *Buffer `json:"-" xml:"-" set:"-"`

	// textbuf for B showing the aligned edit view
	BufB *Buffer `json:"-" xml:"-" set:"-"`

	// aligned diffs records diff for aligned lines
	AlignD textbuf.Diffs `json:"-" xml:"-" set:"-"`

	// Diffs applied
	Diffs textbuf.DiffSelected
}

DiffView presents two side-by-side TextEditor windows showing the differences between two files (represented as lines of strings).

func DiffFiles

func DiffFiles(ctx core.Widget, afile, bfile string) (*DiffView, error)

DiffFiles shows the diffs between this file as the A file, and other file as B file, in a DiffViewDialog

func DiffViewDialog

func DiffViewDialog(ctx core.Widget, title string, astr, bstr []string, afile, bfile, arev, brev string) *DiffView

DiffViewDialog opens a dialog for displaying diff between two files as line-strings

func DiffViewDialogFromRevs

func DiffViewDialogFromRevs(ctx core.Widget, repo vcs.Repo, file string, fbuf *Buffer, rev_a, rev_b string) (*DiffView, error)

DiffViewDialogFromRevs opens a dialog for displaying diff between file at two different revisions from given repository if empty, defaults to: A = current HEAD, B = current WC file. -1, -2 etc also work as universal ways of specifying prior revisions.

func NewDiffView

func NewDiffView(parent tree.Node, name ...string) *DiffView

NewDiffView adds a new DiffView with the given name to the given parent: DiffView presents two side-by-side TextEditor windows showing the differences between two files (represented as lines of strings).

func (*DiffView) ApplyDiff

func (dv *DiffView) ApplyDiff(ab int, line int) bool

ApplyDiff applies change from the other buffer to the buffer for given file name, from diff that includes given line.

func (*DiffView) Config added in v0.0.8

func (dv *DiffView) Config()

func (*DiffView) ConfigDiffView

func (dv *DiffView) ConfigDiffView()

func (*DiffView) ConfigToolbar

func (dv *DiffView) ConfigToolbar(tb *core.Toolbar)

ConfigToolbar configures a core.Toolbar for this view

func (*DiffView) DiffStrings

func (dv *DiffView) DiffStrings(astr, bstr []string)

DiffStrings computes differences between two lines-of-strings and displays in DiffView.

func (*DiffView) New

func (t *DiffView) New() tree.Node

New returns a new *DiffView value

func (*DiffView) NextDiff

func (dv *DiffView) NextDiff(ab int) bool

NextDiff moves to next diff region

func (*DiffView) NodeType added in v0.0.10

func (t *DiffView) NodeType() *types.Type

NodeType returns the *types.Type of DiffView

func (*DiffView) OnInit

func (dv *DiffView) OnInit()

func (*DiffView) PrevDiff

func (dv *DiffView) PrevDiff(ab int) bool

PrevDiff moves to previous diff region

func (*DiffView) SaveAs

func (dv *DiffView) SaveAs(ab bool, filename core.Filename)

SaveAs saves A or B edits into given file. It checks for an existing file, prompts to overwrite or not.

func (*DiffView) SaveFile

func (dv *DiffView) SaveFile(ab bool, filename core.Filename) error

SaveFile writes A or B edits to file, with no prompting, etc

func (*DiffView) SaveFileA

func (dv *DiffView) SaveFileA(fname core.Filename)

SaveFileA saves the current state of file A to given filename

func (*DiffView) SaveFileB

func (dv *DiffView) SaveFileB(fname core.Filename)

SaveFileB saves the current state of file B to given filename

func (*DiffView) SetDiffs

func (t *DiffView) SetDiffs(v textbuf.DiffSelected) *DiffView

SetDiffs sets the [DiffView.Diffs]: Diffs applied

func (*DiffView) SetFileA

func (t *DiffView) SetFileA(v string) *DiffView

SetFileA sets the [DiffView.FileA]: first file name being compared

func (*DiffView) SetFileB

func (t *DiffView) SetFileB(v string) *DiffView

SetFileB sets the [DiffView.FileB]: second file name being compared

func (*DiffView) SetRevA

func (t *DiffView) SetRevA(v string) *DiffView

SetRevA sets the [DiffView.RevA]: revision for first file, if relevant

func (*DiffView) SetRevB

func (t *DiffView) SetRevB(v string) *DiffView

SetRevB sets the [DiffView.RevB]: revision for second file, if relevant

func (*DiffView) SetStyles

func (dv *DiffView) SetStyles()

func (*DiffView) SetTooltip

func (t *DiffView) SetTooltip(v string) *DiffView

SetTooltip sets the [DiffView.Tooltip]

func (*DiffView) TagWordDiffs

func (dv *DiffView) TagWordDiffs()

TagWordDiffs goes through replace diffs and tags differences at the word level between the two regions.

func (*DiffView) TextEditors

func (dv *DiffView) TextEditors() (*DiffTextEditor, *DiffTextEditor)

func (*DiffView) UndoDiff

func (dv *DiffView) UndoDiff(ab int) error

UndoDiff undoes last applied change, if any.

type Editor

type Editor struct {
	core.Layout

	// Buffer is the text buffer being edited.
	Buffer *Buffer `set:"-" json:"-" xml:"-"`

	// width of cursor -- set from cursor-width property (inherited)
	CursorWidth units.Value `xml:"cursor-width"`

	// the color used for the side bar containing the line numbers; this should be set in Stylers like all other style properties
	LineNumberColor image.Image

	// the color used for the user text selection background color; this should be set in Stylers like all other style properties
	SelectColor image.Image

	// the color used for the text highlight background color (like in find); this should be set in Stylers like all other style properties
	HighlightColor image.Image

	// the color used for the text field cursor (caret); this should be set in Stylers like all other style properties
	CursorColor image.Image

	// number of lines in the view -- sync'd with the Buf after edits, but always reflects storage size of Renders etc
	NLines int `set:"-" view:"-" json:"-" xml:"-"`

	// renders of the text lines, with one render per line (each line could visibly wrap-around, so these are logical lines, not display lines)
	Renders []paint.Text `set:"-" json:"-" xml:"-"`

	// starting render offsets for top of each line
	Offs []float32 `set:"-" view:"-" json:"-" xml:"-"`

	// number of line number digits needed
	LineNoDigs int `set:"-" view:"-" json:"-" xml:"-"`

	// horizontal offset for start of text after line numbers
	LineNoOff float32 `set:"-" view:"-" json:"-" xml:"-"`

	// render for line numbers
	LineNoRender paint.Text `set:"-" view:"-" json:"-" xml:"-"`

	// current cursor position
	CursorPos lexer.Pos `set:"-" edit:"-" json:"-" xml:"-"`

	// target cursor position for externally-set targets: ensures that it is visible
	CursorTarg lexer.Pos `set:"-" edit:"-" json:"-" xml:"-"`

	// desired cursor column -- where the cursor was last when moved using left / right arrows -- used when doing up / down to not always go to short line columns
	CursorCol int `set:"-" edit:"-" json:"-" xml:"-"`

	// current index within PosHistory
	PosHistIndex int `set:"-" edit:"-" json:"-" xml:"-"`

	// starting point for selection -- will either be the start or end of selected region depending on subsequent selection.
	SelectStart lexer.Pos `set:"-" edit:"-" json:"-" xml:"-"`

	// current selection region
	SelectRegion textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"`

	// previous selection region, that was actually rendered -- needed to update render
	PreviousSelectRegion textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"`

	// highlighted regions, e.g., for search results
	Highlights []textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"`

	// highlighted regions, specific to scope markers
	Scopelights []textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"`

	// if true, select text as cursor moves
	SelectMode bool `set:"-" edit:"-" json:"-" xml:"-"`

	// interactive search data
	ISearch ISearch `set:"-" edit:"-" json:"-" xml:"-"`

	// query replace data
	QReplace QReplace `set:"-" edit:"-" json:"-" xml:"-"`

	// font height, cached during styling
	FontHeight float32 `set:"-" edit:"-" json:"-" xml:"-"`

	// line height, cached during styling
	LineHeight float32 `set:"-" edit:"-" json:"-" xml:"-"`

	// font ascent, cached during styling
	FontAscent float32 `set:"-" edit:"-" json:"-" xml:"-"`

	// font descent, cached during styling
	FontDescent float32 `set:"-" edit:"-" json:"-" xml:"-"`

	// height in lines and width in chars of the visible area
	NLinesChars image.Point `set:"-" edit:"-" json:"-" xml:"-"`

	// total size of all lines as rendered
	LinesSize math32.Vector2 `set:"-" edit:"-" json:"-" xml:"-"`

	// the LinesSize plus extra space and line numbers etc
	TotalSize math32.Vector2 `set:"-" edit:"-" json:"-" xml:"-"`

	// the Geom.Size.Actual.Total subtracting
	// extra space and line numbers -- this is what
	// LayoutStdLR sees for laying out each line
	LineLayoutSize math32.Vector2 `set:"-" edit:"-" json:"-" xml:"-"`

	// oscillates between on and off for blinking
	BlinkOn bool `set:"-" edit:"-" json:"-" xml:"-"`

	// mutex protecting cursor rendering -- shared between blink and main code
	CursorMu sync.Mutex `set:"-" json:"-" xml:"-" view:"-"`

	// at least one of the renders has links -- determines if we set the cursor for hand movements
	HasLinks bool `set:"-" edit:"-" json:"-" xml:"-"`

	// handles link clicks -- if nil, they are sent to the standard web URL handler
	LinkHandler func(tl *paint.TextLink)
	// contains filtered or unexported fields
}

Editor is a widget for editing multiple lines of complicated text (as compared to core.TextField for a single line of simple text). The Editor is driven by a Buffer buffer which contains all the text, and manages all the edits, sending update events out to the editors.

Use NeedsRender to drive an render update for any change that does not change the line-level layout of the text. Use NeedsLayout whenever there are changes across lines that require re-layout of the text. This sets the Widget NeedsRender flag and triggers layout during that render.

Multiple editors can be attached to a given buffer. All updating in the Editor should be within a single goroutine, as it would require extensive protections throughout code otherwise.

func AsEditor

func AsEditor(k tree.Node) *Editor

AsEditor returns the given value as a value of type Editor if the type of the given value embeds Editor, or nil otherwise

func NewEditor

func NewEditor(parent tree.Node, name ...string) *Editor

NewEditor adds a new Editor with the given name to the given parent: Editor is a widget for editing multiple lines of complicated text (as compared to core.TextField for a single line of simple text). The Editor is driven by a Buffer buffer which contains all the text, and manages all the edits, sending update events out to the editors.

Use NeedsRender to drive an render update for any change that does not change the line-level layout of the text. Use NeedsLayout whenever there are changes across lines that require re-layout of the text. This sets the Widget NeedsRender flag and triggers layout during that render.

Multiple editors can be attached to a given buffer. All updating in the Editor should be within a single goroutine, as it would require extensive protections throughout code otherwise.

func NewSoloEditor added in v0.0.10

func NewSoloEditor(parent tree.Node, name ...string) *Editor

NewSoloEditor returns a new Editor with an associated Buffer. This is appropriate for making a standalone editor in which there is there is one editor per buffer.

func TextDialog

func TextDialog(ctx core.Widget, title, text string) *Editor

TextDialog opens a dialog for displaying text string

func (*Editor) ApplyStyle

func (ed *Editor) ApplyStyle()

ApplyStyle calls StyleView and sets the style

func (*Editor) AsEditor

func (t *Editor) AsEditor() *Editor

AsEditor satisfies the EditorEmbedder interface

func (*Editor) BufferSignal added in v0.0.10

func (ed *Editor) BufferSignal(sig BufferSignals, tbe *textbuf.Edit)

BufferSignal receives a signal from the Buffer when the underlying text is changed.

func (*Editor) CancelComplete

func (ed *Editor) CancelComplete()

CancelComplete cancels any pending completion. Call this when new events have moved beyond any prior completion scenario.

func (*Editor) CancelCorrect

func (ed *Editor) CancelCorrect()

CancelCorrect cancels any pending spell correction. Call this when new events have moved beyond any prior correction scenario.

func (*Editor) CharEndPos

func (ed *Editor) CharEndPos(pos lexer.Pos) math32.Vector2

CharEndPos returns the ending (bottom right) render coords for the given position -- makes no attempt to rationalize that pos (i.e., if not in visible range, position will be out of range too)

func (*Editor) CharStartPos

func (ed *Editor) CharStartPos(pos lexer.Pos) math32.Vector2

CharStartPos returns the starting (top left) render coords for the given position -- makes no attempt to rationalize that pos (i.e., if not in visible range, position will be out of range too)

func (*Editor) CharStartPosVis

func (ed *Editor) CharStartPosVis(pos lexer.Pos) math32.Vector2

CharStartPosVis returns the starting pos for given position that is currently visible, based on bounding boxes.

func (*Editor) Clear

func (ed *Editor) Clear()

Clear resets all the text in the buffer for this view

func (*Editor) ClearCursor added in v0.0.3

func (ed *Editor) ClearCursor()

ClearCursor turns off cursor and stops it from blinking

func (*Editor) ClearHighlights

func (ed *Editor) ClearHighlights()

ClearHighlights clears the Highlights slice of all regions

func (*Editor) ClearScopelights

func (ed *Editor) ClearScopelights()

ClearScopelights clears the Highlights slice of all regions

func (*Editor) ClearSelected

func (ed *Editor) ClearSelected()

ClearSelected resets both the global selected flag and any current selection

func (*Editor) Config added in v0.0.8

func (ed *Editor) Config()

func (*Editor) ContextMenu

func (ed *Editor) ContextMenu(m *core.Scene)

ContextMenu builds the text editor context menu

func (*Editor) Copy

func (ed *Editor) Copy(reset bool) *textbuf.Edit

Copy copies any selected text to the clipboard, and returns that text, optionally resetting the current selection

func (*Editor) CopyRect

func (ed *Editor) CopyRect(reset bool) *textbuf.Edit

CopyRect copies any selected text to the clipboard, and returns that text, optionally resetting the current selection

func (*Editor) CursorBBox

func (ed *Editor) CursorBBox(pos lexer.Pos) image.Rectangle

CursorBBox returns a bounding-box for a cursor at given position

func (*Editor) CursorBackspace

func (ed *Editor) CursorBackspace(steps int)

CursorBackspace deletes character(s) immediately before cursor

func (*Editor) CursorBackspaceWord

func (ed *Editor) CursorBackspaceWord(steps int)

CursorBackspaceWord deletes words(s) immediately before cursor

func (*Editor) CursorBackward

func (ed *Editor) CursorBackward(steps int)

CursorBackward moves the cursor backward

func (*Editor) CursorBackwardWord

func (ed *Editor) CursorBackwardWord(steps int)

CursorBackwardWord moves the cursor backward by words

func (*Editor) CursorDelete

func (ed *Editor) CursorDelete(steps int)

CursorDelete deletes character(s) immediately after the cursor

func (*Editor) CursorDeleteWord

func (ed *Editor) CursorDeleteWord(steps int)

CursorDeleteWord deletes word(s) immediately after the cursor

func (*Editor) CursorDown

func (ed *Editor) CursorDown(steps int)

CursorDown moves the cursor down line(s)

func (*Editor) CursorEndDoc

func (ed *Editor) CursorEndDoc()

CursorEndDoc moves the cursor to the end of the text, updating selection if select mode is active

func (*Editor) CursorEndLine

func (ed *Editor) CursorEndLine()

CursorEndLine moves the cursor to the end of the text

func (*Editor) CursorForward

func (ed *Editor) CursorForward(steps int)

CursorForward moves the cursor forward

func (*Editor) CursorForwardWord

func (ed *Editor) CursorForwardWord(steps int)

CursorForwardWord moves the cursor forward by words

func (*Editor) CursorKill

func (ed *Editor) CursorKill()

CursorKill deletes text from cursor to end of text

func (*Editor) CursorMovedSig

func (ed *Editor) CursorMovedSig()

CursorMovedSig sends the signal that cursor has moved

func (ed *Editor) CursorNextLink(wraparound bool) bool

CursorNextLink moves cursor to next link. wraparound wraps around to top of buffer if none found -- returns true if found

func (*Editor) CursorPageDown

func (ed *Editor) CursorPageDown(steps int)

CursorPageDown moves the cursor down page(s), where a page is defined abcdef dynamically as just moving the cursor off the screen

func (*Editor) CursorPageUp

func (ed *Editor) CursorPageUp(steps int)

CursorPageUp moves the cursor up page(s), where a page is defined dynamically as just moving the cursor off the screen

func (ed *Editor) CursorPrevLink(wraparound bool) bool

CursorPrevLink moves cursor to previous link. wraparound wraps around to bottom of buffer if none found. returns true if found

func (*Editor) CursorRecenter

func (ed *Editor) CursorRecenter()

CursorRecenter re-centers the view around the cursor position, toggling between putting cursor in middle, top, and bottom of view

func (*Editor) CursorSelect

func (ed *Editor) CursorSelect(org lexer.Pos)

CursorSelect updates selection based on cursor movements, given starting cursor position and ed.CursorPos is current

func (*Editor) CursorSprite

func (ed *Editor) CursorSprite(on bool) *core.Sprite

CursorSprite returns the sprite for the cursor, which is only rendered once with a vertical bar, and just activated and inactivated depending on render status.

func (*Editor) CursorSpriteName

func (ed *Editor) CursorSpriteName() string

CursorSpriteName returns the name of the cursor sprite

func (*Editor) CursorStartDoc

func (ed *Editor) CursorStartDoc()

CursorStartDoc moves the cursor to the start of the text, updating selection if select mode is active

func (*Editor) CursorStartLine

func (ed *Editor) CursorStartLine()

CursorStartLine moves the cursor to the start of the line, updating selection if select mode is active

func (*Editor) CursorToHistNext

func (ed *Editor) CursorToHistNext() bool

CursorToHistNext moves cursor to previous position on history list -- returns true if moved

func (*Editor) CursorToHistPrev

func (ed *Editor) CursorToHistPrev() bool

CursorToHistPrev moves cursor to previous position on history list -- returns true if moved

func (*Editor) CursorTranspose

func (ed *Editor) CursorTranspose()

CursorTranspose swaps the character at the cursor with the one before it

func (*Editor) CursorTransposeWord

func (ed *Editor) CursorTransposeWord()

CursorTranspose swaps the word at the cursor with the one before it

func (*Editor) CursorUp

func (ed *Editor) CursorUp(steps int)

CursorUp moves the cursor up line(s)

func (*Editor) Cut

func (ed *Editor) Cut() *textbuf.Edit

Cut cuts any selected text and adds it to the clipboard, also returns cut text

func (*Editor) CutRect

func (ed *Editor) CutRect() *textbuf.Edit

CutRect cuts rectangle defined by selected text (upper left to lower right) and adds it to the clipboard, also returns cut text.

func (*Editor) DeleteSelection

func (ed *Editor) DeleteSelection() *textbuf.Edit

DeleteSelection deletes any selected text, without adding to clipboard -- returns text deleted as textbuf.Edit (nil if none)

func (*Editor) Destroy

func (ed *Editor) Destroy()

func (*Editor) EditDone

func (ed *Editor) EditDone()

EditDone completes editing and copies the active edited text to the text -- called when the return key is pressed or goes out of focus

func (*Editor) EscPressed

func (ed *Editor) EscPressed()

EscPressed emitted for keymap.Abort or keymap.CancelSelect; effect depends on state.

func (*Editor) FindMatches

func (ed *Editor) FindMatches(find string, useCase, lexItems bool) ([]textbuf.Match, bool)

FindMatches finds the matches with given search string (literal, not regex) and case sensitivity, updates highlights for all. returns false if none found

func (ed *Editor) FindNextLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool)

FindNextLink finds next link after given position, returns false if no such links

func (ed *Editor) FindPrevLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool)

FindPrevLink finds previous link before given position, returns false if no such links

func (*Editor) FirstVisibleLine

func (ed *Editor) FirstVisibleLine(stln int) int

FirstVisibleLine finds the first visible line, starting at given line (typically cursor -- if zero, a visible line is first found) -- returns stln if nothing found above it.

func (*Editor) FlagType

func (ed *Editor) FlagType() enums.BitFlagSetter

func (*Editor) HandleClose

func (ed *Editor) HandleClose()

func (*Editor) HandleEvents

func (ed *Editor) HandleEvents()

func (*Editor) HandleFocus

func (ed *Editor) HandleFocus()

func (*Editor) HandleKeyChord

func (ed *Editor) HandleKeyChord()

func (*Editor) HandleLinkCursor

func (ed *Editor) HandleLinkCursor()

func (*Editor) HandleMouse

func (ed *Editor) HandleMouse()

HandleMouse handles mouse events.Event

func (*Editor) HasLineNos

func (ed *Editor) HasLineNos() bool

HasLineNos returns true if view is showing line numbers (per textbuf option, cached here)

func (*Editor) HasSelection

func (ed *Editor) HasSelection() bool

HasSelection returns whether there is a selected region of text

func (*Editor) HighlightRegion

func (ed *Editor) HighlightRegion(reg textbuf.Region)

HighlightRegion creates a new highlighted region, triggers updating.

func (*Editor) ISearchBackspace

func (ed *Editor) ISearchBackspace()

ISearchBackspace gets rid of one item in search string

func (*Editor) ISearchCancel

func (ed *Editor) ISearchCancel()

ISearchCancel cancels ISearch mode

func (*Editor) ISearchKeyInput

func (ed *Editor) ISearchKeyInput(kt events.Event)

ISearchKeyInput is an emacs-style interactive search mode -- this is called when keys are typed while in search mode

func (*Editor) ISearchMatches

func (ed *Editor) ISearchMatches() bool

ISearchMatches finds ISearch matches -- returns true if there are any

func (*Editor) ISearchNextMatch

func (ed *Editor) ISearchNextMatch(cpos lexer.Pos) bool

ISearchNextMatch finds next match after given cursor position, and highlights it, etc

func (*Editor) ISearchSelectMatch

func (ed *Editor) ISearchSelectMatch(midx int)

ISearchSelectMatch selects match at given match index (e.g., ed.ISearch.Pos)

func (*Editor) ISearchSig

func (ed *Editor) ISearchSig()

ISearchSig sends the signal that ISearch is updated

func (*Editor) ISearchStart

func (ed *Editor) ISearchStart()

ISearchStart is an emacs-style interactive search mode -- this is called when the search command itself is entered

func (*Editor) ISpellKeyInput

func (ed *Editor) ISpellKeyInput(kt events.Event)

ISpellKeyInput locates the word to spell check based on cursor position and the key input, then passes the text region to SpellCheck

func (*Editor) InsertAtCursor

func (ed *Editor) InsertAtCursor(txt []byte)

InsertAtCursor inserts given text at current cursor position

func (*Editor) InternalSizeFromLines added in v0.0.6

func (ed *Editor) InternalSizeFromLines()

func (*Editor) IsChanged

func (ed *Editor) IsChanged() bool

IsChanged returns true if buffer was changed (edited) since last EditDone

func (*Editor) IsNotSaved

func (ed *Editor) IsNotSaved() bool

IsNotSaved returns true if buffer was changed (edited) since last Save

func (*Editor) IsWordEnd

func (ed *Editor) IsWordEnd(tp lexer.Pos) bool

IsWordEnd returns true if the cursor is just past the last letter of a word word is a string of characters none of which are classified as a word break

func (*Editor) IsWordMiddle

func (ed *Editor) IsWordMiddle(tp lexer.Pos) bool

IsWordMiddle - returns true if the cursor is anywhere inside a word, i.e. the character before the cursor and the one after the cursor are not classified as word break characters

func (*Editor) IsWordStart

func (ed *Editor) IsWordStart(tp lexer.Pos) bool

IsWordStart returns true if the cursor is just before the start of a word word is a string of characters none of which are classified as a word break

func (*Editor) JumpToLine

func (ed *Editor) JumpToLine(ln int)

JumpToLine jumps to given line number (minus 1)

func (*Editor) JumpToLinePrompt added in v0.0.7

func (ed *Editor) JumpToLinePrompt()

JumpToLinePrompt jumps to given line number (minus 1) from prompt

func (*Editor) KeyInput

func (ed *Editor) KeyInput(kt events.Event)

KeyInput handles keyboard input into the text field and from the completion menu

func (*Editor) KeyInputInsertBra

func (ed *Editor) KeyInputInsertBra(kt events.Event)

KeyInputInsertBra handle input of opening bracket-like entity (paren, brace, bracket)

func (*Editor) KeyInputInsertRune

func (ed *Editor) KeyInputInsertRune(kt events.Event)

KeyInputInsertRune handles the insertion of a typed character

func (*Editor) LastVisibleLine

func (ed *Editor) LastVisibleLine(stln int) int

LastVisibleLine finds the last visible line, starting at given line (typically cursor) -- returns stln if nothing found beyond it.

func (*Editor) LayoutAllLines

func (ed *Editor) LayoutAllLines()

LayoutAllLines generates TextRenders of lines from the Markup version of the source in Buf. It computes the total LinesSize and TotalSize.

func (*Editor) LayoutLine

func (ed *Editor) LayoutLine(ln int) bool

LayoutLine generates render of given line (including highlighting). If the line with exceeds the current maximum, or the number of effective lines (e.g., from word-wrap) is different, then NeedsLayout is called and it returns true.

func (*Editor) LinesDeleted

func (ed *Editor) LinesDeleted(tbe *textbuf.Edit)

LinesDeleted deletes lines of text and reformats remaining one

func (*Editor) LinesInserted

func (ed *Editor) LinesInserted(tbe *textbuf.Edit)

LinesInserted inserts new lines of text and reformats them

func (*Editor) LinkAt

func (ed *Editor) LinkAt(pos lexer.Pos) (*paint.TextLink, bool)

LinkAt returns link at given cursor position, if one exists there -- returns true and the link if there is a link, and false otherwise

func (*Editor) Lookup

func (ed *Editor) Lookup()

Lookup attempts to lookup symbol at current location, popping up a window if something is found.

func (*Editor) MatchFromPos

func (ed *Editor) MatchFromPos(matches []textbuf.Match, cpos lexer.Pos) (int, bool)

MatchFromPos finds the match at or after the given text position -- returns 0, false if none

func (*Editor) NeedsLayout added in v0.0.8

func (ed *Editor) NeedsLayout()

func (*Editor) New

func (t *Editor) New() tree.Node

New returns a new *Editor value

func (*Editor) NodeType added in v0.0.10

func (t *Editor) NodeType() *types.Type

NodeType returns the *types.Type of Editor

func (*Editor) OfferComplete

func (ed *Editor) OfferComplete()

OfferComplete pops up a menu of possible completions

func (*Editor) OfferCorrect

func (ed *Editor) OfferCorrect() bool

OfferCorrect pops up a menu of possible spelling corrections for word at current CursorPos. If no misspelling there or not in spellcorrect mode returns false

func (*Editor) OnAdd

func (ed *Editor) OnAdd()

func (*Editor) OnInit

func (ed *Editor) OnInit()
func (ed *Editor) OpenLink(tl *paint.TextLink)

OpenLink opens given link, either by sending LinkSig signal if there are receivers, or by calling the TextLinkHandler if non-nil, or URLHandler if non-nil (which by default opens user's default browser via system/App.OpenURL())

func (*Editor) OpenLinkAt

func (ed *Editor) OpenLinkAt(pos lexer.Pos) (*paint.TextLink, bool)

OpenLinkAt opens a link at given cursor position, if one exists there -- returns true and the link if there is a link, and false otherwise -- highlights selected link

func (*Editor) Paste

func (ed *Editor) Paste()

Paste inserts text from the clipboard at current cursor position

func (*Editor) PasteHist

func (ed *Editor) PasteHist()

PasteHist presents a chooser of clip history items, pastes into text if selected

func (*Editor) PasteRect

func (ed *Editor) PasteRect()

PasteRect inserts text from the clipboard at current cursor position

func (*Editor) PixelToCursor

func (ed *Editor) PixelToCursor(pt image.Point) lexer.Pos

PixelToCursor finds the cursor position that corresponds to the given pixel location (e.g., from mouse click) which has had ScBBox.Min subtracted from it (i.e, relative to upper left of text area)

func (*Editor) Position

func (ed *Editor) Position()

func (*Editor) QReplaceCancel

func (ed *Editor) QReplaceCancel()

QReplaceCancel cancels QReplace mode

func (*Editor) QReplaceKeyInput

func (ed *Editor) QReplaceKeyInput(kt events.Event)

QReplaceKeyInput is an emacs-style interactive search mode -- this is called when keys are typed while in search mode

func (*Editor) QReplaceMatches

func (ed *Editor) QReplaceMatches() bool

QReplaceMatches finds QReplace matches -- returns true if there are any

func (*Editor) QReplaceNextMatch

func (ed *Editor) QReplaceNextMatch() bool

QReplaceNextMatch finds next match using, QReplace.Pos and highlights it, etc

func (*Editor) QReplacePrompt added in v0.0.7

func (ed *Editor) QReplacePrompt()

QReplacePrompt is an emacs-style query-replace mode -- this starts the process, prompting user for items to search etc

func (*Editor) QReplaceReplace

func (ed *Editor) QReplaceReplace(midx int)

QReplaceReplace replaces at given match index (e.g., ed.QReplace.Pos)

func (*Editor) QReplaceReplaceAll

func (ed *Editor) QReplaceReplaceAll(midx int)

QReplaceReplaceAll replaces all remaining from index

func (*Editor) QReplaceSelectMatch

func (ed *Editor) QReplaceSelectMatch(midx int)

QReplaceSelectMatch selects match at given match index (e.g., ed.QReplace.Pos)

func (*Editor) QReplaceSig

func (ed *Editor) QReplaceSig()

QReplaceSig sends the signal that QReplace is updated

func (*Editor) QReplaceStart

func (ed *Editor) QReplaceStart(find, repl string, lexItems bool)

QReplaceStart starts query-replace using given find, replace strings

func (*Editor) ReCaseSelection

func (ed *Editor) ReCaseSelection(c strcase.Cases) string

ReCaseSelection changes the case of the currently-selected text. Returns the new text -- empty if nothing selected.

func (*Editor) ReLayoutAllLines added in v0.0.6

func (ed *Editor) ReLayoutAllLines()

ReLayoutAllLines updates the Renders Layout given current size, if changed

func (*Editor) ReMarkup

func (ed *Editor) ReMarkup()

Remarkup triggers a complete re-markup of the entire text -- can do this when needed if the markup gets off due to multi-line formatting issues -- via Recenter key

func (*Editor) Redo

func (ed *Editor) Redo()

Redo redoes previously undone action

func (*Editor) RenderAllLines

func (ed *Editor) RenderAllLines()

RenderAllLines displays all the visible lines on the screen, after PushBounds has already been called.

func (*Editor) RenderCursor

func (ed *Editor) RenderCursor(on bool)

RenderCursor renders the cursor on or off, as a sprite that is either on or off

func (*Editor) RenderDepthBackground added in v0.0.10

func (ed *Editor) RenderDepthBackground(stln, edln int)

RenderDepthBackground renders the depth background color.

func (*Editor) RenderHighlights

func (ed *Editor) RenderHighlights(stln, edln int)

RenderHighlights renders the highlight regions as a highlighted background color.

func (*Editor) RenderLayout added in v0.0.6

func (ed *Editor) RenderLayout()

func (*Editor) RenderLineNo

func (ed *Editor) RenderLineNo(ln int, defFill bool)

RenderLineNo renders given line number -- called within context of other render if defFill is true, it fills box color for default background color (use false for batch mode)

func (*Editor) RenderLineNosBox

func (ed *Editor) RenderLineNosBox(st, end int)

RenderLineNosBox renders the background for the line numbers in given range, in the LineNumberColor

func (*Editor) RenderLineNosBoxAll

func (ed *Editor) RenderLineNosBoxAll()

RenderLineNosBoxAll renders the background for the line numbers in the LineNumberColor

func (*Editor) RenderRegionBox

func (ed *Editor) RenderRegionBox(reg textbuf.Region, bg image.Image)

RenderRegionBox renders a region in background according to given background

func (*Editor) RenderRegionBoxSty

func (ed *Editor) RenderRegionBoxSty(reg textbuf.Region, sty *styles.Style, bg image.Image, fullWidth bool)

RenderRegionBoxSty renders a region in given style and background

func (*Editor) RenderRegionToEnd

func (ed *Editor) RenderRegionToEnd(st lexer.Pos, sty *styles.Style, bg image.Image)

RenderRegionToEnd renders a region in given style and background, to end of line from start

func (*Editor) RenderScopelights

func (ed *Editor) RenderScopelights(stln, edln int)

RenderScopelights renders a highlight background color for regions in the Scopelights list.

func (*Editor) RenderSelect

func (ed *Editor) RenderSelect()

RenderSelect renders the selection region as a selected background color.

func (*Editor) RenderSelectLines

func (ed *Editor) RenderSelectLines()

RenderSelectLines renders the lines within the current selection region

func (*Editor) RenderStartPos

func (ed *Editor) RenderStartPos() math32.Vector2

RenderStartPos is absolute rendering start position from our content pos with scroll This can be offscreen (left, up) based on scrolling.

func (*Editor) RenderWidget added in v0.0.10

func (ed *Editor) RenderWidget()

func (*Editor) ResetState

func (ed *Editor) ResetState()

ResetState resets all the random state variables, when opening a new buffer etc

func (*Editor) SavePosHistory

func (ed *Editor) SavePosHistory(pos lexer.Pos)

SavePosHistory saves the cursor position in history stack of cursor positions

func (*Editor) ScenePos

func (ed *Editor) ScenePos()

func (*Editor) ScrollCursorInView

func (ed *Editor) ScrollCursorInView() bool

ScrollCursorInView tells any parent scroll layout to scroll to get cursor in view -- returns true if scrolled

func (*Editor) ScrollCursorToBottom

func (ed *Editor) ScrollCursorToBottom() bool

ScrollCursorToBottom tells any parent scroll layout to scroll to get cursor at bottom of view to extent possible -- returns true if scrolled.

func (*Editor) ScrollCursorToCenterIfHidden

func (ed *Editor) ScrollCursorToCenterIfHidden() bool

ScrollCursorToCenterIfHidden checks if the cursor is not visible, and if so, scrolls to the center, along both dimensions.

func (*Editor) ScrollCursorToHorizCenter

func (ed *Editor) ScrollCursorToHorizCenter() bool

ScrollCursorToHorizCenter tells any parent scroll layout to scroll to get cursor at horiz center of view to extent possible -- returns true if scrolled.

func (*Editor) ScrollCursorToLeft

func (ed *Editor) ScrollCursorToLeft() bool

ScrollCursorToLeft tells any parent scroll layout to scroll to get cursor at left of view to extent possible -- returns true if scrolled.

func (*Editor) ScrollCursorToRight

func (ed *Editor) ScrollCursorToRight() bool

ScrollCursorToRight tells any parent scroll layout to scroll to get cursor at right of view to extent possible -- returns true if scrolled.

func (*Editor) ScrollCursorToTarget

func (ed *Editor) ScrollCursorToTarget()

func (*Editor) ScrollCursorToTop

func (ed *Editor) ScrollCursorToTop() bool

ScrollCursorToTop tells any parent scroll layout to scroll to get cursor at top of view to extent possible -- returns true if scrolled.

func (*Editor) ScrollCursorToVertCenter

func (ed *Editor) ScrollCursorToVertCenter() bool

ScrollCursorToVertCenter tells any parent scroll layout to scroll to get cursor at vert center of view to extent possible -- returns true if scrolled.

func (*Editor) ScrollInView

func (ed *Editor) ScrollInView(bbox image.Rectangle) bool

ScrollInView tells any parent scroll layout to scroll to get given box (e.g., cursor BBox) in view -- returns true if scrolled

func (*Editor) ScrollToBottom

func (ed *Editor) ScrollToBottom(pos int) bool

ScrollToBottom tells any parent scroll layout to scroll to get given vertical coordinate at bottom of view to extent possible -- returns true if scrolled

func (*Editor) ScrollToHorizCenter

func (ed *Editor) ScrollToHorizCenter(pos int) bool

ScrollToHorizCenter tells any parent scroll layout to scroll to get given horizontal coordinate to center of view to extent possible -- returns true if scrolled

func (*Editor) ScrollToLeft

func (ed *Editor) ScrollToLeft(pos int) bool

ScrollToLeft tells any parent scroll layout to scroll to get given horizontal coordinate at left of view to extent possible -- returns true if scrolled

func (*Editor) ScrollToRight

func (ed *Editor) ScrollToRight(pos int) bool

ScrollToRight tells any parent scroll layout to scroll to get given horizontal coordinate at right of view to extent possible -- returns true if scrolled

func (*Editor) ScrollToTop

func (ed *Editor) ScrollToTop(pos int) bool

ScrollToTop tells any parent scroll layout to scroll to get given vertical coordinate at top of view to extent possible -- returns true if scrolled

func (*Editor) ScrollToVertCenter

func (ed *Editor) ScrollToVertCenter(pos int) bool

ScrollToVertCenter tells any parent scroll layout to scroll to get given vertical coordinate to center of view to extent possible -- returns true if scrolled

func (*Editor) SelectAll

func (ed *Editor) SelectAll()

SelectAll selects all the text

func (*Editor) SelectModeToggle

func (ed *Editor) SelectModeToggle()

SelectModeToggle toggles the SelectMode, updating selection with cursor movement

func (*Editor) SelectRegUpdate

func (ed *Editor) SelectRegUpdate(pos lexer.Pos)

SelectRegUpdate updates current select region based on given cursor position relative to SelectStart position

func (*Editor) SelectReset

func (ed *Editor) SelectReset()

SelectReset resets the selection

func (*Editor) SelectWord

func (ed *Editor) SelectWord() bool

SelectWord selects the word (whitespace, punctuation delimited) that the cursor is on returns true if word selected

func (*Editor) Selection

func (ed *Editor) Selection() *textbuf.Edit

Selection returns the currently selected text as a textbuf.Edit, which captures start, end, and full lines in between -- nil if no selection

func (*Editor) SetBuffer added in v0.0.10

func (ed *Editor) SetBuffer(buf *Buffer) *Editor

SetBuffer sets the Buffer that this is a view of, and interconnects their events.

func (*Editor) SetCursor

func (ed *Editor) SetCursor(pos lexer.Pos)

SetCursor sets a new cursor position, enforcing it in range. This is the main final pathway for all cursor movement.

func (*Editor) SetCursorCol

func (ed *Editor) SetCursorCol(pos lexer.Pos)

SetCursorCol sets the current target cursor column (CursorCol) to that of the given position

func (*Editor) SetCursorColor

func (t *Editor) SetCursorColor(v image.Image) *Editor

SetCursorColor sets the [Editor.CursorColor]: the color used for the text field cursor (caret); this should be set in Stylers like all other style properties

func (*Editor) SetCursorFromMouse

func (ed *Editor) SetCursorFromMouse(pt image.Point, newPos lexer.Pos, selMode events.SelectModes)

SetCursorFromMouse sets cursor position from mouse mouse action -- handles the selection updating etc.

func (*Editor) SetCursorShow

func (ed *Editor) SetCursorShow(pos lexer.Pos)

SetCursorShow sets a new cursor position, enforcing it in range, and shows the cursor (scroll to if hidden, render)

func (*Editor) SetCursorTarget

func (ed *Editor) SetCursorTarget(pos lexer.Pos)

SetCursorTarget sets a new cursor target position, ensures that it is visible

func (*Editor) SetCursorWidth

func (t *Editor) SetCursorWidth(v units.Value) *Editor

SetCursorWidth sets the [Editor.CursorWidth]: width of cursor -- set from cursor-width property (inherited)

func (*Editor) SetHighlightColor

func (t *Editor) SetHighlightColor(v image.Image) *Editor

SetHighlightColor sets the [Editor.HighlightColor]: the color used for the text highlight background color (like in find); this should be set in Stylers like all other style properties

func (*Editor) SetLineNumberColor

func (t *Editor) SetLineNumberColor(v image.Image) *Editor

SetLineNumberColor sets the [Editor.LineNumberColor]: the color used for the side bar containing the line numbers; this should be set in Stylers like all other style properties

func (*Editor) SetLinkHandler

func (t *Editor) SetLinkHandler(v func(tl *paint.TextLink)) *Editor

SetLinkHandler sets the [Editor.LinkHandler]: handles link clicks -- if nil, they are sent to the standard web URL handler

func (*Editor) SetSelectColor

func (t *Editor) SetSelectColor(v image.Image) *Editor

SetSelectColor sets the [Editor.SelectColor]: the color used for the user text selection background color; this should be set in Stylers like all other style properties

func (*Editor) SetStyles

func (ed *Editor) SetStyles()

func (*Editor) SetTooltip

func (t *Editor) SetTooltip(v string) *Editor

SetTooltip sets the [Editor.Tooltip]

func (*Editor) ShiftSelect

func (ed *Editor) ShiftSelect(kt events.Event)

ShiftSelect sets the selection start if the shift key is down but wasn't on the last key move. If the shift key has been released the select region is set to textbuf.RegionNil

func (*Editor) ShiftSelectExtend

func (ed *Editor) ShiftSelectExtend(kt events.Event)

ShiftSelectExtend updates the select region if the shift key is down and renders the selected text. If the shift key is not down the previously selected text is rerendered to clear the highlight

func (*Editor) ShowContextMenu

func (ed *Editor) ShowContextMenu(e events.Event)

ShowContextMenu displays the context menu with options dependent on situation

func (*Editor) SizeDown added in v0.0.6

func (ed *Editor) SizeDown(iter int) bool

func (*Editor) SizeFinal

func (ed *Editor) SizeFinal()

func (*Editor) SizeUp added in v0.0.6

func (ed *Editor) SizeUp()

func (*Editor) SpellCheck

func (ed *Editor) SpellCheck(reg *textbuf.Edit) bool

SpellCheck offers spelling corrections if we are at a word break or other word termination and the word before the break is unknown -- returns true if misspelled word found

func (*Editor) StartCursor

func (ed *Editor) StartCursor()

StartCursor starts the cursor blinking and renders it

func (*Editor) StopCursor

func (ed *Editor) StopCursor()

StopCursor stops the cursor from blinking

func (*Editor) StyleSizes

func (ed *Editor) StyleSizes()

StyleSizes gets the size info based on Style settings.

func (*Editor) StyleView

func (ed *Editor) StyleView()

StyleView sets the style of widget

func (*Editor) TextStyleProperties added in v0.0.10

func (ed *Editor) TextStyleProperties() map[string]any

TextStyleProperties returns the styling properties for text based on HiStyle Markup

func (*Editor) Undo

func (ed *Editor) Undo()

Undo undoes previous action

func (*Editor) UpdateFromAlloc

func (ed *Editor) UpdateFromAlloc()

UpdateFromAlloc updates size info based on allocated size: NLinesChars, LineNoOff, LineLayoutSize

func (*Editor) ValidateCursor

func (ed *Editor) ValidateCursor()

ValidateCursor sets current cursor to a valid cursor position

func (*Editor) WordAt

func (ed *Editor) WordAt() (reg textbuf.Region)

WordAt finds the region of the word at the current cursor position

func (*Editor) WordBefore

func (ed *Editor) WordBefore(tp lexer.Pos) *textbuf.Edit

WordBefore returns the word before the lexer.Pos uses IsWordBreak to determine the bounds of the word

func (*Editor) WrappedLineNo

func (ed *Editor) WrappedLineNo(pos lexer.Pos) (si, ri int, ok bool)

WrappedLineNo returns the wrapped line number (span index) and rune index within that span of the given character position within line in position, and false if out of range (last valid position returned in that case -- still usable).

func (*Editor) WrappedLines

func (ed *Editor) WrappedLines(ln int) int

WrappedLines returns the number of wrapped lines (spans) for given line number

type EditorEmbedder

type EditorEmbedder interface {
	AsEditor() *Editor
}

EditorEmbedder is an interface that all types that embed Editor satisfy

type EditorFlags

type EditorFlags core.WidgetFlags //enums:bitflag -trim-prefix View

EditorFlags extend WidgetFlags to hold Editor state

const (
	// EditorHasLineNos indicates that this editor has line numbers (per Buf option)
	EditorHasLineNos EditorFlags = EditorFlags(core.WidgetFlagsN) + iota

	// EditorNeedsLayout is set by NeedsLayout: Editor does significant
	// internal layout in LayoutAllLines, and its layout is simply based
	// on what it gets allocated, so it does not affect the rest
	// of the Scene.
	EditorNeedsLayout

	// EditorLastWasTabAI indicates that last key was a Tab auto-indent
	EditorLastWasTabAI

	// EditorLastWasUndo indicates that last key was an undo
	EditorLastWasUndo

	// EditorTargetSet indicates that the CursorTarget is set
	EditorTargetSet
)
const EditorFlagsN EditorFlags = 7

EditorFlagsN is the highest valid value for type EditorFlags, plus one.

func EditorFlagsValues

func EditorFlagsValues() []EditorFlags

EditorFlagsValues returns all possible values for the type EditorFlags.

func (EditorFlags) BitIndexString

func (i EditorFlags) BitIndexString() string

BitIndexString returns the string representation of this EditorFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.

func (EditorFlags) Desc

func (i EditorFlags) Desc() string

Desc returns the description of the EditorFlags value.

func (EditorFlags) HasFlag

func (i EditorFlags) HasFlag(f enums.BitFlag) bool

HasFlag returns whether these bit flags have the given bit flag set.

func (EditorFlags) Int64

func (i EditorFlags) Int64() int64

Int64 returns the EditorFlags value as an int64.

func (EditorFlags) MarshalText

func (i EditorFlags) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*EditorFlags) SetFlag

func (i *EditorFlags) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the value of the given flags in these flags to the given value.

func (*EditorFlags) SetInt64

func (i *EditorFlags) SetInt64(in int64)

SetInt64 sets the EditorFlags value from an int64.

func (*EditorFlags) SetString

func (i *EditorFlags) SetString(s string) error

SetString sets the EditorFlags value from its string representation, and returns an error if the string is invalid.

func (*EditorFlags) SetStringOr

func (i *EditorFlags) SetStringOr(s string) error

SetStringOr sets the EditorFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.

func (EditorFlags) String

func (i EditorFlags) String() string

String returns the string representation of this EditorFlags value.

func (*EditorFlags) UnmarshalText

func (i *EditorFlags) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (EditorFlags) Values

func (i EditorFlags) Values() []enums.Enum

Values returns all possible values for the type EditorFlags.

type HiMarkup

type HiMarkup struct {

	// full info about the file including category etc
	Info *fileinfo.FileInfo

	// syntax highlighting style
	Style core.HiStyleName

	// chroma-based language name for syntax highlighting the code
	Lang string

	// true if both lang and style are set
	Has bool

	// tab size, in chars
	TabSize int

	// Commpiled CSS properties for given highlighting style
	CSSProperties map[string]any `json:"-" xml:"-"`

	// parser state info
	ParseState *parse.FileStates

	// if supported, this is the [parse.Lang] support for parsing
	ParseLang parse.Lang

	// current highlighting style
	HiStyle *histyle.Style

	// external toggle to turn off automatic highlighting
	Off bool
	// contains filtered or unexported fields
}

HiMarkup manages the syntax highlighting state for Buffer. It uses parse if available, otherwise falls back on chroma.

func (*HiMarkup) ChromaTagsAll

func (hm *HiMarkup) ChromaTagsAll(txt []byte) ([]lexer.Line, error)

ChromaTagsAll returns all the markup tags according to current syntax highlighting settings

func (*HiMarkup) ChromaTagsLine

func (hm *HiMarkup) ChromaTagsLine(txt []rune) (lexer.Line, error)

ChromaTagsLine returns tags for one line according to current syntax highlighting settings

func (*HiMarkup) HasHi

func (hm *HiMarkup) HasHi() bool

HasHi returns true if there are highlighting parameters set (only valid after Init)

func (*HiMarkup) Init

func (hm *HiMarkup) Init(info *fileinfo.FileInfo, pist *parse.FileStates)

Init initializes the syntax highlighting for current params

func (*HiMarkup) MarkupLine

func (hm *HiMarkup) MarkupLine(txt []rune, hitags, tags lexer.Line) []byte

MarkupLine returns the line with html class tags added for each tag takes both the hi tags and extra tags. Only fully nested tags are supported -- any dangling ends are truncated.

func (*HiMarkup) MarkupTagsAll

func (hm *HiMarkup) MarkupTagsAll(txt []byte) ([]lexer.Line, error)

MarkupTagsAll returns all the markup tags according to current syntax highlighting settings

func (*HiMarkup) MarkupTagsLine

func (hm *HiMarkup) MarkupTagsLine(ln int, txt []rune) (lexer.Line, error)

MarkupTagsLine returns tags for one line according to current syntax highlighting settings

func (*HiMarkup) SetHiStyle

func (hm *HiMarkup) SetHiStyle(style core.HiStyleName)

SetHiStyle sets the highlighting style and updates corresponding settings

func (*HiMarkup) UsingParse added in v0.0.10

func (hm *HiMarkup) UsingParse() bool

UsingParse returns true if markup is using parse lexer / parser, which affects use of results

type ISearch

type ISearch struct {

	// if true, in interactive search mode
	On bool `json:"-" xml:"-"`

	// current interactive search string
	Find string `json:"-" xml:"-"`

	// pay attention to case in isearch -- triggered by typing an upper-case letter
	UseCase bool `json:"-" xml:"-"`

	// current search matches
	Matches []textbuf.Match `json:"-" xml:"-"`

	// position within isearch matches
	Pos int `json:"-" xml:"-"`

	// position in search list from previous search
	PrevPos int `json:"-" xml:"-"`

	// starting position for search -- returns there after on cancel
	StartPos lexer.Pos `json:"-" xml:"-"`
}

ISearch holds all the interactive search data

type OutputBuffer added in v0.0.10

type OutputBuffer struct {

	// the output that we are reading from, as an io.Reader
	Output io.Reader

	// the [Buffer] that we output to
	Buffer *Buffer

	// how much time to wait while batching output (default: 200ms)
	Batch time.Duration

	// optional markup function that adds html tags to given line of output -- essential that it ONLY adds tags, and otherwise has the exact same visible bytes as the input
	MarkupFun OutputBufferMarkupFunc

	// current buffered output raw lines, which are not yet sent to the Buffer
	CurrentOutputLines [][]byte

	// current buffered output markup lines, which are not yet sent to the Buffer
	CurrentOutputMarkupLines [][]byte

	// mutex protecting updating of CurrentOutputLines and Buffer, and timer
	Mu sync.Mutex

	// time when last output was sent to buffer
	LastOut time.Time

	// time.AfterFunc that is started after new input is received and not immediately output -- ensures that it will get output if no further burst happens
	AfterTimer *time.Timer
}

OutputBuffer is a Buffer that records the output from an io.Reader using bufio.Scanner -- optimized to combine fast chunks of output into large blocks of updating. Also supports arbitrary markup function that operates on each line of output bytes.

func (*OutputBuffer) Init added in v0.0.10

func (ob *OutputBuffer) Init(out io.Reader, buf *Buffer, batch time.Duration, markup OutputBufferMarkupFunc)

Init sets the various params and prepares for running.

func (*OutputBuffer) MonitorOutput added in v0.0.10

func (ob *OutputBuffer) MonitorOutput()

MonitorOutput monitors the output and updates the Buffer.

func (*OutputBuffer) OutputToBuffer added in v0.0.10

func (ob *OutputBuffer) OutputToBuffer()

OutputToBuffer sends the current output to Buf. MUST be called under mutex protection

type OutputBufferMarkupFunc added in v0.0.10

type OutputBufferMarkupFunc func(line []byte) []byte

OutputBufferMarkupFunc is a function that returns a marked-up version of a given line of output text by adding html tags. It is essential that it ONLY adds tags, and otherwise has the exact same visible bytes as the input

type QReplace

type QReplace struct {

	// if true, in interactive search mode
	On bool `json:"-" xml:"-"`

	// current interactive search string
	Find string `json:"-" xml:"-"`

	// current interactive search string
	Replace string `json:"-" xml:"-"`

	// pay attention to case in isearch -- triggered by typing an upper-case letter
	UseCase bool `json:"-" xml:"-"`

	// search only as entire lexically-tagged item boundaries -- key for replacing short local variables like i
	LexItems bool `json:"-" xml:"-"`

	// current search matches
	Matches []textbuf.Match `json:"-" xml:"-"`

	// position within isearch matches
	Pos int `json:"-" xml:"-"`

	// position in search list from previous search
	PrevPos int `json:"-" xml:"-"`

	// starting position for search -- returns there after on cancel
	StartPos lexer.Pos `json:"-" xml:"-"`
}

QReplace holds all the query-replace data

type Spell added in v0.0.5

type Spell struct {
	// line number in source that spelling is operating on, if relevant
	SrcLn int

	// character position in source that spelling is operating on (start of word to be corrected)
	SrcCh int

	// list of suggested corrections
	Suggest []string

	// word being checked
	Word string `set:"-"`

	// last word learned -- can be undone -- stored in lowercase format
	LastLearned string `set:"-"`

	// the user's correction selection
	Correction string `set:"-"`

	// the event listeners for the spell (it sends Select events)
	Listeners events.Listeners `set:"-" view:"-"`

	// Stage is the [PopupStage] associated with the [Spell]
	Stage *core.Stage

	ShowMu sync.Mutex `set:"-"`
}

Spell

func NewSpell added in v0.0.5

func NewSpell() *Spell

NewSpell returns a new Spell

func (*Spell) Cancel added in v0.0.5

func (sp *Spell) Cancel() bool

Cancel cancels any pending spell correction. call when new events nullify prior correction. returns true if canceled

func (*Spell) CheckWord added in v0.0.5

func (sp *Spell) CheckWord(word string) ([]string, bool)

CheckWord checks the model to determine if the word is known. automatically checks the Ignore list first.

func (*Spell) IgnoreWord added in v0.0.5

func (sp *Spell) IgnoreWord()

IgnoreWord adds the word to the ignore list

func (*Spell) IsLastLearned added in v0.0.5

func (sp *Spell) IsLastLearned(wrd string) bool

IsLastLearned returns true if given word was the last one learned

func (*Spell) LearnWord added in v0.0.5

func (sp *Spell) LearnWord()

LearnWord gets the misspelled/unknown word and passes to LearnWord

func (*Spell) On added in v0.0.5

func (sp *Spell) On(etype events.Types, fun func(e events.Event))

On adds an event listener function for the given event type

func (*Spell) OnSelect added in v0.0.5

func (sp *Spell) OnSelect(fun func(e events.Event))

OnSelect registers given listener function for Select events on Value. This is the primary notification event for all Complete elements.

func (*Spell) SetSrcCh added in v0.0.5

func (t *Spell) SetSrcCh(v int) *Spell

SetSrcCh sets the [Spell.SrcCh]: character position in source that spelling is operating on (start of word to be corrected)

func (*Spell) SetSrcLn added in v0.0.5

func (t *Spell) SetSrcLn(v int) *Spell

SetSrcLn sets the [Spell.SrcLn]: line number in source that spelling is operating on, if relevant

func (*Spell) SetStage added in v0.0.5

func (t *Spell) SetStage(v *core.Stage) *Spell

SetStage sets the [Spell.Stage]: Stage is the [PopupStage] associated with the Spell

func (*Spell) SetSuggest added in v0.0.5

func (t *Spell) SetSuggest(v ...string) *Spell

SetSuggest sets the [Spell.Suggest]: list of suggested corrections

func (*Spell) SetWord added in v0.0.5

func (sp *Spell) SetWord(word string, sugs []string, srcLn, srcCh int) *Spell

SetWord sets the word to spell and other associated info

func (*Spell) Show added in v0.0.5

func (sp *Spell) Show(text string, ctx core.Widget, pos image.Point)

Show is the main call for listing spelling corrections. Calls ShowNow which builds the correction popup menu Similar to completion.Show but does not use a timer Displays popup immediately for any unknown word

func (*Spell) ShowNow added in v0.0.5

func (sp *Spell) ShowNow(word string, ctx core.Widget, pos image.Point)

ShowNow actually builds the correction popup menu

func (*Spell) Spell added in v0.0.5

func (sp *Spell) Spell(s string)

Spell sends a Select event to Listeners indicating that the user has made a selection from the list of possible corrections

func (*Spell) UnLearnLast added in v0.0.5

func (sp *Spell) UnLearnLast()

UnLearnLast unlearns the last learned word -- in case accidental

type SpellSignals added in v0.0.5

type SpellSignals int32 //enums:enum -trim-prefix Spell

SpellSignals are signals that are sent by Spell

const (
	// SpellSelect means the user chose one of the possible corrections
	SpellSelect SpellSignals = iota

	// SpellIgnore signals the user chose ignore so clear the tag
	SpellIgnore
)
const SpellSignalsN SpellSignals = 2

SpellSignalsN is the highest valid value for type SpellSignals, plus one.

func SpellSignalsValues added in v0.0.5

func SpellSignalsValues() []SpellSignals

SpellSignalsValues returns all possible values for the type SpellSignals.

func (SpellSignals) Desc added in v0.0.5

func (i SpellSignals) Desc() string

Desc returns the description of the SpellSignals value.

func (SpellSignals) Int64 added in v0.0.5

func (i SpellSignals) Int64() int64

Int64 returns the SpellSignals value as an int64.

func (SpellSignals) MarshalText added in v0.0.5

func (i SpellSignals) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*SpellSignals) SetInt64 added in v0.0.5

func (i *SpellSignals) SetInt64(in int64)

SetInt64 sets the SpellSignals value from an int64.

func (*SpellSignals) SetString added in v0.0.5

func (i *SpellSignals) SetString(s string) error

SetString sets the SpellSignals value from its string representation, and returns an error if the string is invalid.

func (SpellSignals) String added in v0.0.5

func (i SpellSignals) String() string

String returns the string representation of this SpellSignals value.

func (*SpellSignals) UnmarshalText added in v0.0.5

func (i *SpellSignals) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SpellSignals) Values added in v0.0.5

func (i SpellSignals) Values() []enums.Enum

Values returns all possible values for the type SpellSignals.

type TwinEditors

type TwinEditors struct {
	core.Splits

	// textbuf for A
	BufA *Buffer `json:"-" xml:"-"`

	// textbuf for B
	BufB *Buffer `json:"-" xml:"-"`
}

TwinEditors presents two side-by-side [Editor]s in core.Splits that scroll in sync with each other.

func NewTwinEditors

func NewTwinEditors(parent tree.Node, name ...string) *TwinEditors

NewTwinEditors adds a new TwinEditors with the given name to the given parent: TwinEditors presents two side-by-side [Editor]s in core.Splits that scroll in sync with each other.

func (*TwinEditors) ConfigTexts

func (te *TwinEditors) ConfigTexts()

func (*TwinEditors) Editors

func (te *TwinEditors) Editors() (*Editor, *Editor)

Editors returns the two text Editors

func (*TwinEditors) MakeBufs

func (te *TwinEditors) MakeBufs()

MakeBufs ensures that the Bufs are made, if nil

func (*TwinEditors) New

func (t *TwinEditors) New() tree.Node

New returns a new *TwinEditors value

func (*TwinEditors) NodeType added in v0.0.10

func (t *TwinEditors) NodeType() *types.Type

NodeType returns the *types.Type of TwinEditors

func (*TwinEditors) OnInit

func (te *TwinEditors) OnInit()

func (*TwinEditors) SetBufA

func (t *TwinEditors) SetBufA(v *Buffer) *TwinEditors

SetBufA sets the [TwinEditors.BufA]: textbuf for A

func (*TwinEditors) SetBufB

func (t *TwinEditors) SetBufB(v *Buffer) *TwinEditors

SetBufB sets the [TwinEditors.BufB]: textbuf for B

func (*TwinEditors) SetFiles

func (te *TwinEditors) SetFiles(fileA, fileB string, lineNos bool)

SetFiles sets files for each text buf

func (*TwinEditors) SetStyles

func (te *TwinEditors) SetStyles()

func (*TwinEditors) SetTooltip

func (t *TwinEditors) SetTooltip(v string) *TwinEditors

SetTooltip sets the [TwinEditors.Tooltip]

type Value

type Value struct {
	views.ValueBase[*Editor]
}

Value represents a string with an Editor.

func (*Value) Config added in v0.0.8

func (v *Value) Config()

func (*Value) Update added in v0.0.8

func (v *Value) Update()

Directories

Path Synopsis
Package histyle provides syntax highlighting styles; it is based on github.com/alecthomas/chroma, which in turn was based on the python pygments package.
Package histyle provides syntax highlighting styles; it is based on github.com/alecthomas/chroma, which in turn was based on the python pygments package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL