texteditor

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: BSD-3-Clause Imports: 54 Imported by: 12

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
)

Variables

View Source
var PrevISearchString string

PrevISearchString is the previous ISearch string

Functions

This section is empty.

Types

type Buffer added in v0.0.10

type Buffer struct {
	text.Lines

	// 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

	// Info is the full information about the current file.
	Info fileinfo.FileInfo

	// LineColors are the colors to use for rendering circles
	// next to the line numbers of certain lines.
	LineColors map[int]image.Image

	// Complete is the functions and data for text completion.
	Complete *core.Complete `json:"-" xml:"-"`
	// 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) AppendTextLineMarkup added in v0.0.10

func (tb *Buffer) AppendTextLineMarkup(text []byte, markup []byte, signal bool) *text.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) *text.Edit

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

func (tb *Buffer) AutoIndentRegion(start, end int)

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

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) 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) Close added in v0.0.10

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

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

func (tb *Buffer) CommentRegion(start, end int)

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

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) DeleteLineColor added in v0.0.10

func (tb *Buffer) DeleteLineColor(ln int)

DeleteLineColor deletes the line color at the given line.

func (*Buffer) DeleteText added in v0.0.10

func (tb *Buffer) DeleteText(st, ed lexer.Pos, signal bool) *text.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) 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) 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. It returns true if the 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) Init added in v0.3.0

func (tb *Buffer) Init()

Init initializes the buffer. Called automatically in SetText.

func (*Buffer) IsNotSaved added in v0.0.10

func (tb *Buffer) IsNotSaved() bool

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

func (*Buffer) JoinParaLines added in v0.0.10

func (tb *Buffer) JoinParaLines(startLine, endLine 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; endLine is *inclusive*

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) ReplaceText added in v0.0.10

func (tb *Buffer) ReplaceText(delSt, delEd, insPos lexer.Pos, insTxt string, signal, matchCase bool) *text.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 text.Edit for the inserted text.

func (*Buffer) Revert added in v0.0.10

func (tb *Buffer) Revert() bool

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

func (tb *Buffer) Save() error

Save saves the current text into the 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 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) SetFileExt added in v0.3.0

func (tb *Buffer) SetFileExt(ext string) *Buffer

SetFileExt sets syntax highlighting and other parameters based on the given file extension (without the . prefix), for cases where an actual file with fileinfo.FileInfo is not available.

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) SetLanguage added in v0.2.3

func (tb *Buffer) SetLanguage(ftyp fileinfo.Known) *Buffer

SetFileType sets the syntax highlighting and other parameters based on the given fileinfo.Known file type

func (*Buffer) SetLineColor added in v0.0.10

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

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

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

SetReadOnly sets whether the buffer is read-only.

func (*Buffer) SetString added in v0.2.3

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

SetString sets the text to the given string.

func (*Buffer) SetText added in v0.0.10

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

SetText sets the text to the given bytes. Pass nil to initialize an empty buffer.

func (*Buffer) SpacesToTabs added in v0.0.10

func (tb *Buffer) SpacesToTabs(start, end int)

SpacesToTabs replaces tabs with spaces over given region; end is *exclusive*

func (*Buffer) SpellCheckLineErrors added in v0.2.1

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

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

func (*Buffer) Stat added in v0.0.10

func (tb *Buffer) Stat() error

Stat gets info about the file, including the highlighting language.

func (*Buffer) String added in v0.1.1

func (tb *Buffer) String() string

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) TabsToSpaces added in v0.0.10

func (tb *Buffer) TabsToSpaces(start, end int)

TabsToSpaces replaces tabs with spaces over given region; end is *exclusive*

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 by calling editDone, which will generate a signal if there have been changes.

func (*Buffer) Update added in v0.0.10

func (tb *Buffer) Update()

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
	RevisionA string

	// revision for second file, if relevant
	RevisionB string
	// 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) 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) 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) SetRevisionA added in v0.2.3

func (t *DiffEditor) SetRevisionA(v string) *DiffEditor

SetRevisionA sets the [DiffEditor.RevisionA]: revision for first file, if relevant

func (*DiffEditor) SetRevisionB added in v0.2.3

func (t *DiffEditor) SetRevisionB(v string) *DiffEditor

SetRevisionB sets the [DiffEditor.RevisionB]: revision for second file, if relevant

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) Init added in v0.2.0

func (ed *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.
	// This should be set in Stylers like all other style properties.
	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

	// NumLines is the number of lines in the view, synced with the [Buffer] after edits,
	// but always reflects the storage size of renders etc.
	NumLines int `set:"-" display:"-" json:"-" xml:"-"`

	// LineNumberOffset is the horizontal offset for the start of text after line numbers.
	LineNumberOffset float32 `set:"-" display:"-" json:"-" xml:"-"`

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

	// SelectRegion is the current selection region.
	SelectRegion text.Region `set:"-" edit:"-" json:"-" xml:"-"`

	// Highlights is a slice of regions representing the highlighted regions, e.g., for search results.
	Highlights []text.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

func AsEditor(n 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) *Editor

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 TextDialog

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

TextDialog opens a dialog for displaying text string

func (*Editor) ApplyScenePos added in v0.2.1

func (ed *Editor) ApplyScenePos()

func (*Editor) AsEditor

func (t *Editor) AsEditor() *Editor

AsEditor satisfies the EditorEmbedder interface

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) Clear

func (ed *Editor) Clear()

Clear resets all the text in the buffer for this editor.

func (*Editor) ClearHighlights

func (ed *Editor) ClearHighlights()

ClearHighlights clears the Highlights slice of all regions

func (*Editor) Copy

func (ed *Editor) Copy(reset bool) *text.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) *text.Edit

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

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 (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) CursorStartDoc

func (ed *Editor) CursorStartDoc()

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

func (*Editor) CursorToHistoryNext added in v0.2.3

func (ed *Editor) CursorToHistoryNext() bool

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

func (*Editor) CursorToHistoryPrev added in v0.2.3

func (ed *Editor) CursorToHistoryPrev() bool

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

func (*Editor) Cut

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

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

func (*Editor) CutRect

func (ed *Editor) CutRect() *text.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) Destroy

func (ed *Editor) Destroy()

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 text.Region)

HighlightRegion creates a new highlighted region, triggers updating.

func (*Editor) Init added in v0.2.0

func (ed *Editor) Init()

func (*Editor) InsertAtCursor

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

InsertAtCursor inserts given text at current cursor position

func (*Editor) IsNotSaved

func (ed *Editor) IsNotSaved() bool

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

func (*Editor) JumpToLinePrompt added in v0.0.7

func (ed *Editor) JumpToLinePrompt()

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

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) NeedsLayout added in v0.0.8

func (ed *Editor) NeedsLayout()

NeedsLayout indicates that the Editor needs a new layout pass.

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) 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) 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) QReplaceReplaceAll

func (ed *Editor) QReplaceReplaceAll(midx int)

QReplaceReplaceAll replaces all remaining from index

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) RenderWidget added in v0.0.10

func (ed *Editor) RenderWidget()

func (*Editor) SelectReset

func (ed *Editor) SelectReset()

SelectReset resets the selection

func (*Editor) Selection

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

Selection returns the currently selected text as a text.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 an editor of, and interconnects their events.

func (*Editor) SetCursorColor

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

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) 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]: CursorWidth is the width of the cursor. This should be set in Stylers like all other style properties.

func (*Editor) SetHighlightColor

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

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

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

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

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

SetLinkHandler sets the [Editor.LinkHandler]: LinkHandler handles link clicks. If it is 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]: 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) SetWidgetValue added in v0.3.0

func (ed *Editor) SetWidgetValue(value any) error

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) Style added in v0.2.0

func (ed *Editor) Style()

func (*Editor) WidgetValue added in v0.2.0

func (ed *Editor) WidgetValue() any

type EditorEmbedder

type EditorEmbedder interface {
	AsEditor() *Editor
}

EditorEmbedder is an interface that all types that embed Editor satisfy

type ISearch

type ISearch struct {

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

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

	// current search matches
	Matches []text.Match `json:"-" xml:"-"`
	// contains filtered or unexported fields
}

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
	MarkupFunc OutputBufferMarkupFunc
	// contains filtered or unexported fields
}

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

func (*OutputBuffer) MonitorOutput added in v0.0.10

func (ob *OutputBuffer) MonitorOutput()

MonitorOutput monitors the output and updates the Buffer.

func (*OutputBuffer) SetBatch added in v0.2.3

func (t *OutputBuffer) SetBatch(v time.Duration) *OutputBuffer

SetBatch sets the [OutputBuffer.Batch]: how much time to wait while batching output (default: 200ms)

func (*OutputBuffer) SetBuffer added in v0.2.3

func (t *OutputBuffer) SetBuffer(v *Buffer) *OutputBuffer

SetBuffer sets the [OutputBuffer.Buffer]: the Buffer that we output to

func (*OutputBuffer) SetMarkupFunc added in v0.2.3

func (t *OutputBuffer) SetMarkupFunc(v OutputBufferMarkupFunc) *OutputBuffer

SetMarkupFunc sets the [OutputBuffer.MarkupFunc]: 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

func (*OutputBuffer) SetOutput added in v0.2.3

func (t *OutputBuffer) SetOutput(v io.Reader) *OutputBuffer

SetOutput sets the [OutputBuffer.Output]: the output that we are reading from, as an io.Reader

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:"-"`

	// current search matches
	Matches []text.Match `json:"-" xml:"-"`
	// contains filtered or unexported fields
}

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

func (*TwinEditors) SetFiles

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

SetFiles sets the files for each Buffer.

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 highlighting provides syntax highlighting styles; it is based on github.com/alecthomas/chroma, which in turn was based on the python pygments package.
Package highlighting 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