Documentation
¶
Index ¶
- Constants
- Variables
- func BufferSignalsValues() []bufferSignals
- func ChromaTagsForLine(tags *lexer.Line, toks []chroma.Token)
- func ChromaTagsLine(clex chroma.Lexer, txt []rune) (lexer.Line, error)
- func CompleteEditParse(data any, text string, cursorPos int, comp complete.Completion, seed string) (ed complete.Edit)
- func CompleteParse(data any, text string, posLine, posChar int) (md complete.Matches)
- func CompleteText(data any, text string, posLine, posChar int) (md complete.Matches)
- func CompleteTextEdit(data any, text string, cursorPos int, completion complete.Completion, ...) (ed complete.Edit)
- func HTMLEscapeBytes(b []byte) []byte
- func HTMLEscapeRunes(r []rune) []byte
- func LookupParse(data any, text string, posLine, posChar int) (ld complete.Lookup)
- func ViewClipHistAdd(clip []byte)
- func ViewClipHistChooseList() []string
- type Buffer
- func (tb *Buffer) AdjustRegion(reg textbuf.Region) textbuf.Region
- func (tb *Buffer) AdjustedTagsImpl(tags lexer.Line, ln int) lexer.Line
- func (tb *Buffer) AppendTextLineMarkup(text []byte, markup []byte, signal bool) *textbuf.Edit
- func (tb *Buffer) AppendTextMarkup(text []byte, markup []byte, signal bool) *textbuf.Edit
- func (tb *Buffer) AutoIndentRegion(start, end int)
- func (tb *Buffer) AutoSaveCheck() bool
- func (tb *Buffer) AutoSaveDelete()
- func (tb *Buffer) AutoSaveFilename() string
- func (tb *Buffer) AutoScrollEditors()
- func (tb *Buffer) BytesLine(ln int) []byte
- func (tb *Buffer) Close(afterFun func(canceled bool)) bool
- func (tb *Buffer) CommentRegion(start, end int)
- func (tb *Buffer) ConfigKnown() bool
- func (tb *Buffer) DeleteLineColor(ln int)
- func (tb *Buffer) DeleteText(st, ed lexer.Pos, signal bool) *textbuf.Edit
- func (tb *Buffer) DiffBuffersUnified(ob *Buffer, context int) []byte
- func (tb *Buffer) FileModCheck() bool
- func (tb *Buffer) HasLineColor(ln int) bool
- func (tb *Buffer) HiTagAtPos(pos lexer.Pos) (*lexer.Lex, int)
- func (tb *Buffer) IsValidLine(ln int) bool
- func (tb *Buffer) JoinParaLines(startLine, endLine int)
- func (tb *Buffer) LexObjPathString(ln int, lx *lexer.Lex) string
- func (tb *Buffer) NewBuffer(nlines int)
- func (tb *Buffer) OnChange(fun func(e events.Event))
- func (tb *Buffer) OnInput(fun func(e events.Event))
- func (tb *Buffer) Open(filename core.Filename) error
- func (tb *Buffer) OpenFS(fsys fs.FS, filename string) error
- func (tb *Buffer) Region(st, ed lexer.Pos) *textbuf.Edit
- func (tb *Buffer) ReplaceText(delSt, delEd, insPos lexer.Pos, insTxt string, signal, matchCase bool) *textbuf.Edit
- func (tb *Buffer) Revert() bool
- func (tb *Buffer) Save() error
- func (tb *Buffer) SaveAs(filename core.Filename)
- func (tb *Buffer) SaveAsFunc(filename core.Filename, afterFunc func(canceled bool))
- func (tb *Buffer) Search(find []byte, ignoreCase, lexItems bool) (int, []textbuf.Match)
- func (tb *Buffer) SearchRegexp(re *regexp.Regexp) (int, []textbuf.Match)
- func (tb *Buffer) SetFilename(fn string) *Buffer
- func (tb *Buffer) SetHiStyle(style core.HiStyleName) *Buffer
- func (tb *Buffer) SetLang(lang string) *Buffer
- func (tb *Buffer) SetLineColor(ln int, color image.Image)
- func (tb *Buffer) SetReadOnly(readonly bool) *Buffer
- func (tb *Buffer) SetText(text []byte) *Buffer
- func (tb *Buffer) SetTextString(txt string) *Buffer
- func (tb *Buffer) SpacesToTabsRegion(st, ed int)
- func (tb *Buffer) SpellCheckLineErrors(ln int) lexer.Line
- func (tb *Buffer) StartDelayedReMarkup()
- func (tb *Buffer) Stat() error
- func (tb *Buffer) String() string
- func (tb *Buffer) Strings(addNewLine bool) []string
- func (tb *Buffer) TabsToSpacesRegion(st, ed int)
- func (tb *Buffer) Text() []byte
- func (tb *Buffer) Update()
- type DiffEditor
- func DiffEditorDialog(ctx core.Widget, title string, astr, bstr []string, ...) *DiffEditor
- func DiffEditorDialogFromRevs(ctx core.Widget, repo vcs.Repo, file string, fbuf *Buffer, rev_a, rev_b string) (*DiffEditor, error)
- func DiffFiles(ctx core.Widget, afile, bfile string) (*DiffEditor, error)
- func NewDiffEditor(parent ...tree.Node) *DiffEditor
- func (dv *DiffEditor) ApplyDiff(ab int, line int) bool
- func (dv *DiffEditor) DiffStrings(astr, bstr []string)
- func (dv *DiffEditor) Init()
- func (dv *DiffEditor) MakeToolbar(p *tree.Plan)
- func (dv *DiffEditor) NextDiff(ab int) bool
- func (dv *DiffEditor) PrevDiff(ab int) bool
- func (dv *DiffEditor) SaveAs(ab bool, filename core.Filename)
- func (dv *DiffEditor) SaveFile(ab bool, filename core.Filename) error
- func (dv *DiffEditor) SaveFileA(fname core.Filename)
- func (dv *DiffEditor) SaveFileB(fname core.Filename)
- func (t *DiffEditor) SetDiffs(v textbuf.DiffSelected) *DiffEditor
- func (t *DiffEditor) SetFileA(v string) *DiffEditor
- func (t *DiffEditor) SetFileB(v string) *DiffEditor
- func (dv *DiffEditor) SetFilenames()
- func (t *DiffEditor) SetRevA(v string) *DiffEditor
- func (t *DiffEditor) SetRevB(v string) *DiffEditor
- func (dv *DiffEditor) SyncViews(typ events.Types, e events.Event, name string)
- func (dv *DiffEditor) TagWordDiffs()
- func (dv *DiffEditor) TextEditors() (*DiffTextEditor, *DiffTextEditor)
- func (dv *DiffEditor) UndoDiff(ab int) error
- type DiffTextEditor
- type Editor
- func (ed *Editor) ApplyScenePos()
- func (t *Editor) AsEditor() *Editor
- func (ed *Editor) BufferSignal(sig bufferSignals, tbe *textbuf.Edit)
- func (ed *Editor) CancelComplete()
- func (ed *Editor) CancelCorrect()
- func (ed *Editor) CharEndPos(pos lexer.Pos) math32.Vector2
- func (ed *Editor) CharStartPos(pos lexer.Pos) math32.Vector2
- func (ed *Editor) CharStartPosVis(pos lexer.Pos) math32.Vector2
- func (ed *Editor) Clear()
- func (ed *Editor) ClearCursor()
- func (ed *Editor) ClearHighlights()
- func (ed *Editor) ClearScopelights()
- func (ed *Editor) ClearSelected()
- func (ed *Editor) ContextMenu(m *core.Scene)
- func (ed *Editor) Copy(reset bool) *textbuf.Edit
- func (ed *Editor) CopyRect(reset bool) *textbuf.Edit
- func (ed *Editor) CursorBBox(pos lexer.Pos) image.Rectangle
- func (ed *Editor) CursorBackspace(steps int)
- func (ed *Editor) CursorBackspaceWord(steps int)
- func (ed *Editor) CursorBackward(steps int)
- func (ed *Editor) CursorBackwardWord(steps int)
- func (ed *Editor) CursorDelete(steps int)
- func (ed *Editor) CursorDeleteWord(steps int)
- func (ed *Editor) CursorDown(steps int)
- func (ed *Editor) CursorEndDoc()
- func (ed *Editor) CursorEndLine()
- func (ed *Editor) CursorForward(steps int)
- func (ed *Editor) CursorForwardWord(steps int)
- func (ed *Editor) CursorKill()
- func (ed *Editor) CursorMovedSig()
- func (ed *Editor) CursorNextLink(wraparound bool) bool
- func (ed *Editor) CursorPageDown(steps int)
- func (ed *Editor) CursorPageUp(steps int)
- func (ed *Editor) CursorPrevLink(wraparound bool) bool
- func (ed *Editor) CursorRecenter()
- func (ed *Editor) CursorSelect(org lexer.Pos)
- func (ed *Editor) CursorSprite(on bool) *core.Sprite
- func (ed *Editor) CursorSpriteName() string
- func (ed *Editor) CursorStartDoc()
- func (ed *Editor) CursorStartLine()
- func (ed *Editor) CursorToHistNext() bool
- func (ed *Editor) CursorToHistPrev() bool
- func (ed *Editor) CursorTranspose()
- func (ed *Editor) CursorTransposeWord()
- func (ed *Editor) CursorUp(steps int)
- func (ed *Editor) Cut() *textbuf.Edit
- func (ed *Editor) CutRect() *textbuf.Edit
- func (ed *Editor) DeleteSelection() *textbuf.Edit
- func (ed *Editor) Destroy()
- func (ed *Editor) EditDone()
- func (ed *Editor) EscPressed()
- func (ed *Editor) FindMatches(find string, useCase, lexItems bool) ([]textbuf.Match, bool)
- func (ed *Editor) FindNextLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool)
- func (ed *Editor) FindPrevLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool)
- func (ed *Editor) FirstVisibleLine(stln int) int
- func (ed *Editor) HandleFocus()
- func (ed *Editor) HandleKeyChord()
- func (ed *Editor) HandleLinkCursor()
- func (ed *Editor) HandleMouse()
- func (ed *Editor) HasSelection() bool
- func (ed *Editor) HighlightRegion(reg textbuf.Region)
- func (ed *Editor) ISearchBackspace()
- func (ed *Editor) ISearchCancel()
- func (ed *Editor) ISearchKeyInput(kt events.Event)
- func (ed *Editor) ISearchMatches() bool
- func (ed *Editor) ISearchNextMatch(cpos lexer.Pos) bool
- func (ed *Editor) ISearchSelectMatch(midx int)
- func (ed *Editor) ISearchSig()
- func (ed *Editor) ISearchStart()
- func (ed *Editor) ISpellKeyInput(kt events.Event)
- func (ed *Editor) Init()
- func (ed *Editor) InsertAtCursor(txt []byte)
- func (ed *Editor) InternalSizeFromLines()
- func (ed *Editor) IsChanged() bool
- func (ed *Editor) IsNotSaved() bool
- func (ed *Editor) IsWordEnd(tp lexer.Pos) bool
- func (ed *Editor) IsWordMiddle(tp lexer.Pos) bool
- func (ed *Editor) IsWordStart(tp lexer.Pos) bool
- func (ed *Editor) JumpToLine(ln int)
- func (ed *Editor) JumpToLinePrompt()
- func (ed *Editor) KeyInput(kt events.Event)
- func (ed *Editor) KeyInputInsertBra(kt events.Event)
- func (ed *Editor) KeyInputInsertRune(kt events.Event)
- func (ed *Editor) LastVisibleLine(stln int) int
- func (ed *Editor) LayoutAllLines()
- func (ed *Editor) LayoutLine(ln int) bool
- func (ed *Editor) LineBBox(ln int) math32.Box2
- func (ed *Editor) LinesDeleted(tbe *textbuf.Edit)
- func (ed *Editor) LinesInserted(tbe *textbuf.Edit)
- func (ed *Editor) LinkAt(pos lexer.Pos) (*paint.TextLink, bool)
- func (ed *Editor) Lookup()
- func (ed *Editor) MatchFromPos(matches []textbuf.Match, cpos lexer.Pos) (int, bool)
- func (ed *Editor) NeedsLayout()
- func (ed *Editor) OfferComplete()
- func (ed *Editor) OfferCorrect() bool
- func (ed *Editor) OpenLink(tl *paint.TextLink)
- func (ed *Editor) OpenLinkAt(pos lexer.Pos) (*paint.TextLink, bool)
- func (ed *Editor) Paste()
- func (ed *Editor) PasteHist()
- func (ed *Editor) PasteRect()
- func (ed *Editor) PixelToCursor(pt image.Point) lexer.Pos
- func (ed *Editor) Position()
- func (ed *Editor) QReplaceCancel()
- func (ed *Editor) QReplaceKeyInput(kt events.Event)
- func (ed *Editor) QReplaceMatches() bool
- func (ed *Editor) QReplaceNextMatch() bool
- func (ed *Editor) QReplacePrompt()
- func (ed *Editor) QReplaceReplace(midx int)
- func (ed *Editor) QReplaceReplaceAll(midx int)
- func (ed *Editor) QReplaceSelectMatch(midx int)
- func (ed *Editor) QReplaceSig()
- func (ed *Editor) QReplaceStart(find, repl string, lexItems bool)
- func (ed *Editor) ReCaseSelection(c strcase.Cases) string
- func (ed *Editor) ReLayoutAllLines()
- func (ed *Editor) ReMarkup()
- func (ed *Editor) Redo()
- func (ed *Editor) RenderAllLines()
- func (ed *Editor) RenderBBox() image.Rectangle
- func (ed *Editor) RenderCursor(on bool)
- func (ed *Editor) RenderDepthBackground(stln, edln int)
- func (ed *Editor) RenderHighlights(stln, edln int)
- func (ed *Editor) RenderLayout()
- func (ed *Editor) RenderLineNumber(ln int, defFill bool)
- func (ed *Editor) RenderLineNumbersBoxAll()
- func (ed *Editor) RenderRegionBox(reg textbuf.Region, bg image.Image)
- func (ed *Editor) RenderRegionBoxSty(reg textbuf.Region, sty *styles.Style, bg image.Image, fullWidth bool)
- func (ed *Editor) RenderRegionToEnd(st lexer.Pos, sty *styles.Style, bg image.Image)
- func (ed *Editor) RenderScopelights(stln, edln int)
- func (ed *Editor) RenderSelect()
- func (ed *Editor) RenderSelectLines()
- func (ed *Editor) RenderStartPos() math32.Vector2
- func (ed *Editor) RenderWidget()
- func (ed *Editor) ResetState()
- func (ed *Editor) SavePosHistory(pos lexer.Pos)
- func (ed *Editor) ScrollCursorInView() bool
- func (ed *Editor) ScrollCursorToBottom() bool
- func (ed *Editor) ScrollCursorToCenterIfHidden() bool
- func (ed *Editor) ScrollCursorToHorizCenter() bool
- func (ed *Editor) ScrollCursorToLeft() bool
- func (ed *Editor) ScrollCursorToRight() bool
- func (ed *Editor) ScrollCursorToTarget()
- func (ed *Editor) ScrollCursorToTop() bool
- func (ed *Editor) ScrollCursorToVertCenter() bool
- func (ed *Editor) ScrollInView(bbox image.Rectangle) bool
- func (ed *Editor) ScrollToBottom(pos int) bool
- func (ed *Editor) ScrollToHorizCenter(pos int) bool
- func (ed *Editor) ScrollToLeft(pos int) bool
- func (ed *Editor) ScrollToRight(pos int) bool
- func (ed *Editor) ScrollToTop(pos int) bool
- func (ed *Editor) ScrollToVertCenter(pos int) bool
- func (ed *Editor) SelectAll()
- func (ed *Editor) SelectModeToggle()
- func (ed *Editor) SelectRegUpdate(pos lexer.Pos)
- func (ed *Editor) SelectReset()
- func (ed *Editor) SelectWord() bool
- func (ed *Editor) Selection() *textbuf.Edit
- func (ed *Editor) SetBuffer(buf *Buffer) *Editor
- func (ed *Editor) SetCursor(pos lexer.Pos)
- func (ed *Editor) SetCursorCol(pos lexer.Pos)
- func (t *Editor) SetCursorColor(v image.Image) *Editor
- func (ed *Editor) SetCursorFromMouse(pt image.Point, newPos lexer.Pos, selMode events.SelectModes)
- func (ed *Editor) SetCursorShow(pos lexer.Pos)
- func (ed *Editor) SetCursorTarget(pos lexer.Pos)
- func (t *Editor) SetCursorWidth(v units.Value) *Editor
- func (t *Editor) SetHighlightColor(v image.Image) *Editor
- func (t *Editor) SetLineNumberColor(v image.Image) *Editor
- func (t *Editor) SetLinkHandler(v func(tl *paint.TextLink)) *Editor
- func (ed *Editor) SetNewBuffer() *Editor
- func (t *Editor) SetSelectColor(v image.Image) *Editor
- func (ed *Editor) ShiftSelect(kt events.Event)
- func (ed *Editor) ShiftSelectExtend(kt events.Event)
- func (ed *Editor) ShowContextMenu(e events.Event)
- func (ed *Editor) SizeDown(iter int) bool
- func (ed *Editor) SizeFinal()
- func (ed *Editor) SizeUp()
- func (ed *Editor) SpellCheck(reg *textbuf.Edit) bool
- func (ed *Editor) StartCursor()
- func (ed *Editor) StopCursor()
- func (ed *Editor) Style()
- func (ed *Editor) StyleSizes()
- func (ed *Editor) StyleView()
- func (ed *Editor) TextStyleProperties() map[string]any
- func (ed *Editor) Undo()
- func (ed *Editor) UpdateFromAlloc()
- func (ed *Editor) ValidateCursor()
- func (ed *Editor) WidgetValue() any
- func (ed *Editor) WordAt() (reg textbuf.Region)
- func (ed *Editor) WordBefore(tp lexer.Pos) *textbuf.Edit
- func (ed *Editor) WrappedLineNumber(pos lexer.Pos) (si, ri int, ok bool)
- func (ed *Editor) WrappedLines(ln int) int
- type EditorEmbedder
- type HiMarkup
- func (hm *HiMarkup) ChromaTagsAll(txt []byte) ([]lexer.Line, error)
- func (hm *HiMarkup) ChromaTagsLine(txt []rune) (lexer.Line, error)
- func (hm *HiMarkup) HasHi() bool
- func (hm *HiMarkup) Init(info *fileinfo.FileInfo, pist *parse.FileStates)
- func (hm *HiMarkup) MarkupLine(txt []rune, hitags, tags lexer.Line) []byte
- func (hm *HiMarkup) MarkupTagsAll(txt []byte) ([]lexer.Line, error)
- func (hm *HiMarkup) MarkupTagsLine(ln int, txt []rune) (lexer.Line, error)
- func (hm *HiMarkup) SetHiStyle(style core.HiStyleName)
- func (hm *HiMarkup) UsingParse() bool
- type ISearch
- type OutputBuffer
- type OutputBufferMarkupFunc
- type QReplace
- type TwinEditors
- func (te *TwinEditors) Editors() (*Editor, *Editor)
- func (te *TwinEditors) Init()
- func (t *TwinEditors) SetBufferA(v *Buffer) *TwinEditors
- func (t *TwinEditors) SetBufferB(v *Buffer) *TwinEditors
- func (te *TwinEditors) SetFiles(fileA, fileB string, lineNumbers bool)
- func (te *TwinEditors) SyncViews(typ events.Types, e events.Event, name string)
Constants ¶
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 )
const ( MaxLineLen = 64 * 1024 * 1024 MaxNTags = 1024 )
MaxLineLen prevents overflow in allocating line length
const BufferSignalsN bufferSignals = 7
BufferSignalsN is the highest valid value for type BufferSignals, plus one.
Variables ¶
var ( // EditorBlinker manages cursor blinking EditorBlinker = core.Blinker{} // EditorSpriteName is the name of the window sprite used for the cursor EditorSpriteName = "texteditor.Editor.Cursor" )
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"` )
var ( // PrevQReplaceFinds are the previous QReplace strings PrevQReplaceFinds []string // PrevQReplaceRepls are the previous QReplace strings PrevQReplaceRepls []string )
var PrevISearchString string
PrevISearchString is the previous ISearch string
var ViewClipHistChooseLen = 40
ViewClipHistChooseLen is the max length of clip history to show in chooser
var ViewClipHistory [][]byte
ViewClipHistory is the text view clipboard history -- everything that has been copied
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.
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.
var ViewMaxFindHighlights = 1000
ViewMaxFindHighlights is the maximum number of regions to highlight on find
Functions ¶
func BufferSignalsValues ¶ added in v0.0.10
func BufferSignalsValues() []bufferSignals
BufferSignalsValues returns all possible values for the type BufferSignals.
func ChromaTagsForLine ¶
ChromaTagsForLine generates the chroma tags for one line of chroma tokens
func ChromaTagsLine ¶
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
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 ¶
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 ¶
HTMLEscapeBytes escapes special characters like "<" to become "<". 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 ¶
HTMLEscapeRunes escapes special characters like "<" to become "<". 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 LookupParse ¶ added in v0.0.10
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 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 the file that was last loaded or saved.
// It is used when highlighting code.
Filename core.Filename `json:"-" xml:"-"`
// Autosave specifies whether the file should be automatically
// saved after changes are made.
Autosave bool
// Options are the options for how text editing and viewing works.
Options textbuf.Options
// Info is the full information about the current file.
Info fileinfo.FileInfo
// ParseState is the parsing state information for the file.
ParseState parse.FileStates
// Hi is the syntax highlighting markup parameters, such as the language and style.
Hi HiMarkup
// NLines is the number of lines in the buffer.
NLines int `json:"-" xml:"-"`
// LineColors are the colors to use for rendering circles
// next to the line numbers of certain lines.
LineColors map[int]image.Image
// Lines are the live lines of text being edited, with the latest modifications.
// They are encoded as runes per line, which is necessary for one-to-one rune/glyph
// rendering correspondence. All TextPos positions are in rune indexes, not byte
// indexes.
Lines [][]rune `json:"-" xml:"-"`
// Markup is the marked-up version of the edited text lines, after being run
// through the syntax highlighting process. This is what is actually rendered.
Markup [][]byte `json:"-" xml:"-"`
// LinesMu is the mutex for updating lines.
LinesMu sync.RWMutex `json:"-" xml:"-"`
// Undos is the undo manager.
Undos textbuf.Undo `json:"-" xml:"-"`
// Complete is the functions and data for text completion.
Complete *core.Complete `json:"-" xml:"-"`
// Changed indicates if the text has been Changed (edited) relative to the
// original, since last EditDone
Changed bool
// NotSaved indicates if the text has been changed (edited) relative to the
// original, since last Save
NotSaved bool
// contains filtered or unexported fields
}
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. Editors 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 Event 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) AdjustRegion ¶ added in v0.2.1
AdjustRegion 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) AdjustedTagsImpl ¶ added in v0.0.10
AdjustedTagsImpl updates tag positions for edits, for given list of tags
func (*Buffer) AppendTextLineMarkup ¶ added in v0.0.10
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
AppendTextMarkup appends new text to end of buffer, using insert, returns edit, and uses supplied markup to render it.
func (*Buffer) AutoIndentRegion ¶ added in v0.0.10
AutoIndentRegion does auto-indent over given region; end is *exclusive*
func (*Buffer) AutoSaveCheck ¶ added in v0.0.10
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
AutoSaveFilename returns the autosave filename.
func (*Buffer) AutoScrollEditors ¶ added in v0.2.1
func (tb *Buffer) AutoScrollEditors()
AutoScrollEditors ensures that our editors are always viewing the end of the buffer
func (*Buffer) BytesLine ¶ added in v0.0.10
BytesLine is the concurrent-safe accessor to specific Line of lineBytes.
func (*Buffer) Close ¶ added in v0.0.10
Close closes the buffer, prompting to save if there are changes, and disconnects from editors. If afterFun is non-nil, then it is called with the status of the user action.
func (*Buffer) CommentRegion ¶ added in v0.0.10
CommentRegion inserts comment marker on given lines; end is *exclusive*
func (*Buffer) ConfigKnown ¶ added in v0.0.10
ConfigKnown configures options based on the supported language info in parse. Returns true if supported.
func (*Buffer) DeleteLineColor ¶ added in v0.0.10
DeleteLineColor deletes the line color at the given line.
func (*Buffer) DeleteText ¶ added in v0.0.10
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) DiffBuffersUnified ¶ added in v0.0.10
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) FileModCheck ¶ added in v0.0.10
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. It returns true if the file was modified.
func (*Buffer) HasLineColor ¶ added in v0.0.10
HasLineColor checks if given line has a line color set
func (*Buffer) HiTagAtPos ¶ added in v0.0.10
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) IsValidLine ¶ added in v0.0.10
IsValidLine returns true if given line is in range
func (*Buffer) JoinParaLines ¶ added in v0.0.10
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; endLine is *inclusive*
func (*Buffer) LexObjPathString ¶ added in v0.0.10
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) OnChange ¶ added in v0.0.10
OnChange adds an event listener function for the events.Change event.
func (*Buffer) OnInput ¶ added in v0.0.10
OnInput adds an event listener function for the events.Input event.
func (*Buffer) OpenFS ¶ added in v0.0.10
OpenFS loads the given file in the given filesystem into the buffer.
func (*Buffer) Region ¶ added in v0.0.10
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) 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
Revert re-opens text from the current file, if the filename is set; returns false if not. It uses an optimized diff-based update to preserve existing formatting, making it very fast if not very different.
func (*Buffer) Save ¶ added in v0.0.10
Save saves the current text into the current filename associated with this buffer.
func (*Buffer) SaveAs ¶ added in v0.0.10
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
SaveAsFunc saves the current text into the 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) Search ¶ added in v0.0.10
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
SearchRegexp looks for a string (regexp) within buffer, returning number of occurrences and specific match position list. Column positions are in runes.
func (*Buffer) SetFilename ¶ added in v0.0.10
SetFilename sets the filename associated with the buffer and updates the code highlighting information accordingly.
func (*Buffer) SetHiStyle ¶ added in v0.0.10
func (tb *Buffer) SetHiStyle(style core.HiStyleName) *Buffer
SetHiStyle sets the highlighting style of the buffer.
func (*Buffer) SetLang ¶ added in v0.0.10
SetLang sets the language for highlighting and updates the highlighting style and buffer accordingly.
func (*Buffer) SetLineColor ¶ added in v0.0.10
SetLineColor sets the color to use for rendering a circle next to the line number at the given line.
func (*Buffer) SetReadOnly ¶ added in v0.0.10
SetReadOnly sets whether the buffer is read-only.
func (*Buffer) SetTextString ¶ added in v0.0.10
SetTextString sets the text to the given string.
func (*Buffer) SpacesToTabsRegion ¶ added in v0.0.10
SpacesToTabsRegion replaces tabs with spaces over given region; end is *exclusive*
func (*Buffer) SpellCheckLineErrors ¶ added in v0.2.1
SpellCheckLineErrors runs spell check on given line, and returns Lex tags with token.TextSpellErr for any misspelled words
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
Stat gets info about the file, including the highlighting language.
func (*Buffer) String ¶ added in v0.1.1
String returns the current text as a string, applying all current changes by calling editDone, which will generate a signal if there have been changes.
func (*Buffer) Strings ¶ added in v0.0.10
Strings returns the current text as []string array. If addNewLine is true, each string line has a \n appended at end.
func (*Buffer) TabsToSpacesRegion ¶ added in v0.0.10
TabsToSpacesRegion replaces tabs with spaces over given region; end is *exclusive*
type DiffEditor ¶ added in v0.2.0
type DiffEditor 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
// contains filtered or unexported fields
}
DiffEditor presents two side-by-side [Editor]s showing the differences between two files (represented as lines of strings).
func DiffEditorDialog ¶ added in v0.2.0
func DiffEditorDialog(ctx core.Widget, title string, astr, bstr []string, afile, bfile, arev, brev string) *DiffEditor
DiffEditorDialog opens a dialog for displaying diff between two files as line-strings
func DiffEditorDialogFromRevs ¶ added in v0.2.0
func DiffEditorDialogFromRevs(ctx core.Widget, repo vcs.Repo, file string, fbuf *Buffer, rev_a, rev_b string) (*DiffEditor, error)
DiffEditorDialogFromRevs 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 DiffFiles ¶
func DiffFiles(ctx core.Widget, afile, bfile string) (*DiffEditor, error)
DiffFiles shows the diffs between this file as the A file, and other file as B file, in a DiffEditorDialog
func NewDiffEditor ¶ added in v0.2.0
func NewDiffEditor(parent ...tree.Node) *DiffEditor
NewDiffEditor returns a new DiffEditor with the given optional parent: DiffEditor presents two side-by-side [Editor]s showing the differences between two files (represented as lines of strings).
func (*DiffEditor) ApplyDiff ¶ added in v0.2.0
func (dv *DiffEditor) 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 (*DiffEditor) DiffStrings ¶ added in v0.2.0
func (dv *DiffEditor) DiffStrings(astr, bstr []string)
DiffStrings computes differences between two lines-of-strings and displays in DiffEditor.
func (*DiffEditor) Init ¶ added in v0.2.0
func (dv *DiffEditor) Init()
func (*DiffEditor) MakeToolbar ¶ added in v0.2.0
func (dv *DiffEditor) MakeToolbar(p *tree.Plan)
func (*DiffEditor) NextDiff ¶ added in v0.2.0
func (dv *DiffEditor) NextDiff(ab int) bool
NextDiff moves to next diff region
func (*DiffEditor) PrevDiff ¶ added in v0.2.0
func (dv *DiffEditor) PrevDiff(ab int) bool
PrevDiff moves to previous diff region
func (*DiffEditor) SaveAs ¶ added in v0.2.0
func (dv *DiffEditor) 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 (*DiffEditor) SaveFile ¶ added in v0.2.0
func (dv *DiffEditor) SaveFile(ab bool, filename core.Filename) error
SaveFile writes A or B edits to file, with no prompting, etc
func (*DiffEditor) SaveFileA ¶ added in v0.2.0
func (dv *DiffEditor) SaveFileA(fname core.Filename)
SaveFileA saves the current state of file A to given filename
func (*DiffEditor) SaveFileB ¶ added in v0.2.0
func (dv *DiffEditor) SaveFileB(fname core.Filename)
SaveFileB saves the current state of file B to given filename
func (*DiffEditor) SetDiffs ¶ added in v0.2.0
func (t *DiffEditor) SetDiffs(v textbuf.DiffSelected) *DiffEditor
SetDiffs sets the [DiffEditor.Diffs]: Diffs applied
func (*DiffEditor) SetFileA ¶ added in v0.2.0
func (t *DiffEditor) SetFileA(v string) *DiffEditor
SetFileA sets the [DiffEditor.FileA]: first file name being compared
func (*DiffEditor) SetFileB ¶ added in v0.2.0
func (t *DiffEditor) SetFileB(v string) *DiffEditor
SetFileB sets the [DiffEditor.FileB]: second file name being compared
func (*DiffEditor) SetFilenames ¶ added in v0.2.1
func (dv *DiffEditor) SetFilenames()
SetFilenames sets the filenames and updates markup accordingly. Called in DiffStrings
func (*DiffEditor) SetRevA ¶ added in v0.2.0
func (t *DiffEditor) SetRevA(v string) *DiffEditor
SetRevA sets the [DiffEditor.RevA]: revision for first file, if relevant
func (*DiffEditor) SetRevB ¶ added in v0.2.0
func (t *DiffEditor) SetRevB(v string) *DiffEditor
SetRevB sets the [DiffEditor.RevB]: revision for second file, if relevant
func (*DiffEditor) SyncViews ¶ added in v0.2.0
SyncViews synchronizes the text view scrolling and cursor positions
func (*DiffEditor) TagWordDiffs ¶ added in v0.2.0
func (dv *DiffEditor) TagWordDiffs()
TagWordDiffs goes through replace diffs and tags differences at the word level between the two regions.
func (*DiffEditor) TextEditors ¶ added in v0.2.0
func (dv *DiffEditor) TextEditors() (*DiffTextEditor, *DiffTextEditor)
func (*DiffEditor) UndoDiff ¶ added in v0.2.0
func (dv *DiffEditor) UndoDiff(ab int) error
UndoDiff undoes last applied change, if any.
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) *DiffTextEditor
NewDiffTextEditor returns a new DiffTextEditor with the given optional parent: DiffTextEditor supports double-click based application of edits from one buffer to the other.
func (*DiffTextEditor) DiffEditor ¶ added in v0.2.0
func (tv *DiffTextEditor) DiffEditor() *DiffEditor
func (*DiffTextEditor) HandleDoubleClick ¶
func (tv *DiffTextEditor) HandleDoubleClick()
func (*DiffTextEditor) Init ¶ added in v0.2.0
func (tv *DiffTextEditor) Init()
type Editor ¶
type Editor struct {
core.Frame
// Buffer is the text buffer being edited.
Buffer *Buffer `set:"-" json:"-" xml:"-"`
// CursorWidth is the width of the cursor.
CursorWidth units.Value
// LineNumberColor is 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
// SelectColor is the color used for the user text selection background color.
// This should be set in Stylers like all other style properties.
SelectColor image.Image
// HighlightColor is 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
// CursorColor is the color used for the text editor cursor bar.
// This should be set in Stylers like all other style properties.
CursorColor image.Image
// NLines is the number of lines in the view, synced with the Buf after edits,
// but always reflects the storage size of Renders etc.
NLines int `set:"-" display:"-" json:"-" xml:"-"`
// Renders is a slice of paint.Text representing the 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:"-"`
// Offsets is a slice of float32 representing the starting render offsets for the top of each line.
Offsets []float32 `set:"-" display:"-" json:"-" xml:"-"`
// LineNumberDigits is the number of line number digits needed.
LineNumberDigits int `set:"-" display:"-" json:"-" xml:"-"`
// LineNumberOffset is the horizontal offset for the start of text after line numbers.
LineNumberOffset float32 `set:"-" display:"-" json:"-" xml:"-"`
// LineNumberRender is the render for line numbers.
LineNumberRender paint.Text `set:"-" display:"-" json:"-" xml:"-"`
// CursorPos is the current cursor position.
CursorPos lexer.Pos `set:"-" edit:"-" json:"-" xml:"-"`
// CursorTarget is the target cursor position for externally set targets.
// It ensures that the target position is visible.
CursorTarget lexer.Pos `set:"-" edit:"-" json:"-" xml:"-"`
// CursorCol is the desired cursor column, where the cursor was last when moved using left / right arrows.
// It is used when doing up / down to not always go to short line columns.
CursorCol int `set:"-" edit:"-" json:"-" xml:"-"`
// PosHistIndex is the current index within PosHistory.
PosHistIndex int `set:"-" edit:"-" json:"-" xml:"-"`
// SelectStart is the starting point for selection, which will either be the start or end of selected region
// depending on subsequent selection.
SelectStart lexer.Pos `set:"-" edit:"-" json:"-" xml:"-"`
// SelectRegion is the current selection region.
SelectRegion textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"`
// PreviousSelectRegion is the previous selection region that was actually rendered.
// It is needed to update the render.
PreviousSelectRegion textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"`
// Highlights is a slice of regions representing the highlighted regions, e.g., for search results.
Highlights []textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"`
// Scopelights is a slice of regions representing the highlighted regions specific to scope markers.
Scopelights []textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"`
// LinkHandler handles link clicks.
// If it is nil, they are sent to the standard web URL handler.
LinkHandler func(tl *paint.TextLink)
// ISearch is the interactive search data.
ISearch ISearch `set:"-" edit:"-" json:"-" xml:"-"`
// QReplace is the query replace data.
QReplace QReplace `set:"-" edit:"-" json:"-" xml:"-"`
// 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 ¶
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 ¶
NewEditor returns a new Editor with the given optional 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
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 ¶
TextDialog opens a dialog for displaying text string
func (*Editor) ApplyScenePos ¶ added in v0.2.1
func (ed *Editor) ApplyScenePos()
func (*Editor) AsEditor ¶
AsEditor satisfies the EditorEmbedder interface
func (*Editor) BufferSignal ¶ added in v0.0.10
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 ¶
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 ¶
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 ¶
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) ContextMenu ¶
ContextMenu builds the text editor context menu
func (*Editor) Copy ¶
Copy copies any selected text to the clipboard, and returns that text, optionally resetting the current selection
func (*Editor) CopyRect ¶
CopyRect copies any selected text to the clipboard, and returns that text, optionally resetting the current selection
func (*Editor) CursorBBox ¶
CursorBBox returns a bounding-box for a cursor at given position
func (*Editor) CursorBackspace ¶
CursorBackspace deletes character(s) immediately before cursor
func (*Editor) CursorBackspaceWord ¶
CursorBackspaceWord deletes words(s) immediately before cursor
func (*Editor) CursorBackward ¶
CursorBackward moves the cursor backward
func (*Editor) CursorBackwardWord ¶
CursorBackwardWord moves the cursor backward by words
func (*Editor) CursorDelete ¶
CursorDelete deletes character(s) immediately after the cursor
func (*Editor) CursorDeleteWord ¶
CursorDeleteWord deletes word(s) immediately after the cursor
func (*Editor) CursorDown ¶
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 ¶
CursorForward moves the cursor forward
func (*Editor) CursorForwardWord ¶
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 (*Editor) CursorNextLink ¶
CursorNextLink moves cursor to next link. wraparound wraps around to top of buffer if none found -- returns true if found
func (*Editor) CursorPageDown ¶
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 ¶
CursorPageUp moves the cursor up page(s), where a page is defined dynamically as just moving the cursor off the screen
func (*Editor) CursorPrevLink ¶
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 ¶
CursorSelect updates selection based on cursor movements, given starting cursor position and ed.CursorPos is current
func (*Editor) CursorSprite ¶
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 ¶
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 ¶
CursorToHistNext moves cursor to previous position on history list -- returns true if moved
func (*Editor) CursorToHistPrev ¶
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) CutRect ¶
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 ¶
DeleteSelection deletes any selected text, without adding to clipboard -- returns text deleted as textbuf.Edit (nil if none)
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 ¶
FindMatches finds the matches with given search string (literal, not regex) and case sensitivity, updates highlights for all. returns false if none found
func (*Editor) FindNextLink ¶
FindNextLink finds next link after given position, returns false if no such links
func (*Editor) FindPrevLink ¶
FindPrevLink finds previous link before given position, returns false if no such links
func (*Editor) FirstVisibleLine ¶
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) HandleFocus ¶
func (ed *Editor) HandleFocus()
func (*Editor) HandleKeyChord ¶
func (ed *Editor) HandleKeyChord()
func (*Editor) HandleLinkCursor ¶
func (ed *Editor) HandleLinkCursor()
func (*Editor) HasSelection ¶
HasSelection returns whether there is a selected region of text
func (*Editor) HighlightRegion ¶
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) ISearchKeyInput ¶
ISearchKeyInput is an emacs-style interactive search mode -- this is called when keys are typed while in search mode
func (*Editor) ISearchMatches ¶
ISearchMatches finds ISearch matches -- returns true if there are any
func (*Editor) ISearchNextMatch ¶
ISearchNextMatch finds next match after given cursor position, and highlights it, etc
func (*Editor) ISearchSelectMatch ¶
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 ¶
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 ¶
InsertAtCursor inserts given text at current cursor position
func (*Editor) InternalSizeFromLines ¶ added in v0.0.6
func (ed *Editor) InternalSizeFromLines()
func (*Editor) IsChanged ¶
IsChanged returns true if buffer was changed (edited) since last EditDone
func (*Editor) IsNotSaved ¶
IsNotSaved returns true if buffer was changed (edited) since last Save
func (*Editor) IsWordEnd ¶
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 ¶
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 ¶
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 ¶
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 ¶
KeyInput handles keyboard input into the text field and from the completion menu
func (*Editor) KeyInputInsertBra ¶
KeyInputInsertBra handle input of opening bracket-like entity (paren, brace, bracket)
func (*Editor) KeyInputInsertRune ¶
KeyInputInsertRune handles the insertion of a typed character
func (*Editor) LastVisibleLine ¶
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 paint.Text Renders of lines from the Markup version of the source in Buf. It computes the total LinesSize and TotalSize.
func (*Editor) LayoutLine ¶
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 ¶
LinesDeleted deletes lines of text and reformats remaining one
func (*Editor) LinesInserted ¶
LinesInserted inserts new lines of text and reformats them
func (*Editor) LinkAt ¶
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 ¶
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) OfferComplete ¶
func (ed *Editor) OfferComplete()
OfferComplete pops up a menu of possible completions
func (*Editor) OfferCorrect ¶
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) OpenLink ¶
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 ¶
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 ¶
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) QReplaceCancel ¶
func (ed *Editor) QReplaceCancel()
QReplaceCancel cancels QReplace mode
func (*Editor) QReplaceKeyInput ¶
QReplaceKeyInput is an emacs-style interactive search mode -- this is called when keys are typed while in search mode
func (*Editor) QReplaceMatches ¶
QReplaceMatches finds QReplace matches -- returns true if there are any
func (*Editor) QReplaceNextMatch ¶
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 ¶
QReplaceReplace replaces at given match index (e.g., ed.QReplace.Pos)
func (*Editor) QReplaceReplaceAll ¶
QReplaceReplaceAll replaces all remaining from index
func (*Editor) QReplaceSelectMatch ¶
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 ¶
QReplaceStart starts query-replace using given find, replace strings
func (*Editor) ReCaseSelection ¶
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) RenderAllLines ¶
func (ed *Editor) RenderAllLines()
RenderAllLines displays all the visible lines on the screen, after PushBounds has already been called.
func (*Editor) RenderBBox ¶ added in v0.1.4
RenderBBox is the render region
func (*Editor) RenderCursor ¶
RenderCursor renders the cursor on or off, as a sprite that is either on or off
func (*Editor) RenderDepthBackground ¶ added in v0.0.10
RenderDepthBackground renders the depth background color.
func (*Editor) RenderHighlights ¶
RenderHighlights renders the highlight regions as a highlighted background color.
func (*Editor) RenderLayout ¶ added in v0.0.6
func (ed *Editor) RenderLayout()
func (*Editor) RenderLineNumber ¶ added in v0.1.4
RenderLineNumber 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) RenderLineNumbersBoxAll ¶ added in v0.1.4
func (ed *Editor) RenderLineNumbersBoxAll()
RenderLineNumbersBoxAll renders the background for the line numbers in the LineNumberColor
func (*Editor) RenderRegionBox ¶
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 ¶
RenderRegionToEnd renders a region in given style and background, to end of line from start
func (*Editor) RenderScopelights ¶
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 ¶
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 ¶
SavePosHistory saves the cursor position in history stack of cursor positions
func (*Editor) ScrollCursorInView ¶
ScrollCursorInView tells any parent scroll layout to scroll to get cursor in view -- returns true if scrolled
func (*Editor) ScrollCursorToBottom ¶
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 ¶
ScrollCursorToCenterIfHidden checks if the cursor is not visible, and if so, scrolls to the center, along both dimensions.
func (*Editor) ScrollCursorToHorizCenter ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) SelectModeToggle ¶
func (ed *Editor) SelectModeToggle()
SelectModeToggle toggles the SelectMode, updating selection with cursor movement
func (*Editor) SelectRegUpdate ¶
SelectRegUpdate updates current select region based on given cursor position relative to SelectStart position
func (*Editor) SelectWord ¶
SelectWord selects the word (whitespace, punctuation delimited) that the cursor is on returns true if word selected
func (*Editor) Selection ¶
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
SetBuffer sets the Buffer that this is a view of, and interconnects their events.
func (*Editor) SetCursor ¶
SetCursor sets a new cursor position, enforcing it in range. This is the main final pathway for all cursor movement.
func (*Editor) SetCursorCol ¶
SetCursorCol sets the current target cursor column (CursorCol) to that of the given position
func (*Editor) SetCursorColor ¶
SetCursorColor sets the [Editor.CursorColor]: CursorColor is the color used for the text editor cursor bar. This should be set in Stylers like all other style properties.
func (*Editor) SetCursorFromMouse ¶
SetCursorFromMouse sets cursor position from mouse mouse action -- handles the selection updating etc.
func (*Editor) SetCursorShow ¶
SetCursorShow sets a new cursor position, enforcing it in range, and shows the cursor (scroll to if hidden, render)
func (*Editor) SetCursorTarget ¶
SetCursorTarget sets a new cursor target position, ensures that it is visible
func (*Editor) SetCursorWidth ¶
SetCursorWidth sets the [Editor.CursorWidth]: CursorWidth is the width of the cursor.
func (*Editor) SetHighlightColor ¶
SetHighlightColor sets the [Editor.HighlightColor]: HighlightColor is 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 ¶
SetLineNumberColor sets the [Editor.LineNumberColor]: LineNumberColor is 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 ¶
SetLinkHandler sets the [Editor.LinkHandler]: LinkHandler handles link clicks. If it is nil, they are sent to the standard web URL handler.
func (*Editor) SetNewBuffer ¶ added in v0.2.1
SetNewBuffer sets the Buffer for this Editor to a NewBuffer.
func (*Editor) SetSelectColor ¶
SetSelectColor sets the [Editor.SelectColor]: SelectColor is the color used for the user text selection background color. This should be set in Stylers like all other style properties.
func (*Editor) ShiftSelect ¶
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 ¶
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 ¶
ShowContextMenu displays the context menu with options dependent on situation
func (*Editor) SpellCheck ¶
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) Style ¶ added in v0.2.0
func (ed *Editor) Style()
Style calls StyleView and sets the style
func (*Editor) StyleSizes ¶
func (ed *Editor) StyleSizes()
StyleSizes gets the size info based on Style settings.
func (*Editor) TextStyleProperties ¶ added in v0.0.10
TextStyleProperties returns the styling properties for text based on HiStyle Markup
func (*Editor) UpdateFromAlloc ¶
func (ed *Editor) UpdateFromAlloc()
UpdateFromAlloc updates size info based on allocated size: NLinesChars, LineNumberOff, LineLayoutSize
func (*Editor) ValidateCursor ¶
func (ed *Editor) ValidateCursor()
ValidateCursor sets current cursor to a valid cursor position
func (*Editor) WidgetValue ¶ added in v0.2.0
func (*Editor) WordBefore ¶
WordBefore returns the word before the lexer.Pos uses IsWordBreak to determine the bounds of the word
func (*Editor) WrappedLineNumber ¶ added in v0.1.4
WrappedLineNumber 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 ¶
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 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 ¶
ChromaTagsAll returns all the markup tags according to current syntax highlighting settings
func (*HiMarkup) ChromaTagsLine ¶
ChromaTagsLine returns tags for one line according to current syntax highlighting settings
func (*HiMarkup) HasHi ¶
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 ¶
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 ¶
MarkupTagsAll returns all the markup tags according to current syntax highlighting settings
func (*HiMarkup) MarkupTagsLine ¶
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
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
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 TwinEditors ¶
type TwinEditors struct {
core.Splits
// [Buffer] for A
BufferA *Buffer `json:"-" xml:"-"`
// [Buffer] for B
BufferB *Buffer `json:"-" xml:"-"`
// contains filtered or unexported fields
}
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) *TwinEditors
NewTwinEditors returns a new TwinEditors with the given optional parent: TwinEditors presents two side-by-side [Editor]s in core.Splits that scroll in sync with each other.
func (*TwinEditors) Editors ¶
func (te *TwinEditors) Editors() (*Editor, *Editor)
Editors returns the two text [Editor]s.
func (*TwinEditors) Init ¶ added in v0.2.0
func (te *TwinEditors) Init()
func (*TwinEditors) SetBufferA ¶ added in v0.2.0
func (t *TwinEditors) SetBufferA(v *Buffer) *TwinEditors
SetBufferA sets the [TwinEditors.BufferA]: Buffer for A
func (*TwinEditors) SetBufferB ¶ added in v0.2.0
func (t *TwinEditors) SetBufferB(v *Buffer) *TwinEditors
SetBufferB sets the [TwinEditors.BufferB]: Buffer for B
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package difflib is a partial port of Python difflib module.
|
Package difflib is a partial port of Python difflib module. |
|
bytes
Package bytes is a partial port of Python difflib module for bytes.
|
Package bytes is a partial port of Python difflib module for bytes. |
|
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. |