From aa223368e25380ae10768e457277a3b082a4bc06 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Tue, 23 Jul 2024 14:34:51 -0700 Subject: [PATCH] rename textbuf -> text --- filetree/search.go | 16 ++++---- filetree/vcs.go | 4 +- texteditor/buffer.go | 42 ++++++++++---------- texteditor/complete.go | 12 +++--- texteditor/diffeditor.go | 18 ++++----- texteditor/editor.go | 16 ++++---- texteditor/enumgen.go | 2 +- texteditor/events.go | 16 ++++---- texteditor/find.go | 14 +++---- texteditor/nav.go | 18 ++++----- texteditor/render.go | 8 ++-- texteditor/select.go | 36 ++++++++--------- texteditor/spell.go | 4 +- texteditor/{textbuf => text}/diff.go | 2 +- texteditor/{textbuf => text}/diff_test.go | 2 +- texteditor/{textbuf => text}/diffsel.go | 2 +- texteditor/{textbuf => text}/diffsel_test.go | 2 +- texteditor/{textbuf => text}/edit.go | 2 +- texteditor/{textbuf => text}/lines.go | 6 +-- texteditor/{textbuf => text}/options.go | 2 +- texteditor/{textbuf => text}/region.go | 2 +- texteditor/{textbuf => text}/search.go | 6 +-- texteditor/{textbuf => text}/undo.go | 2 +- texteditor/{textbuf => text}/util.go | 2 +- undo/undo.go | 6 +-- 25 files changed, 121 insertions(+), 121 deletions(-) rename texteditor/{textbuf => text}/diff.go (99%) rename texteditor/{textbuf => text}/diff_test.go (98%) rename texteditor/{textbuf => text}/diffsel.go (99%) rename texteditor/{textbuf => text}/diffsel_test.go (99%) rename texteditor/{textbuf => text}/edit.go (99%) rename texteditor/{textbuf => text}/lines.go (99%) rename texteditor/{textbuf => text}/options.go (99%) rename texteditor/{textbuf => text}/region.go (99%) rename texteditor/{textbuf => text}/search.go (98%) rename texteditor/{textbuf => text}/undo.go (99%) rename texteditor/{textbuf => text}/util.go (99%) diff --git a/filetree/search.go b/filetree/search.go index 659b97774e..911b646139 100644 --- a/filetree/search.go +++ b/filetree/search.go @@ -15,7 +15,7 @@ import ( "cogentcore.org/core/base/fileinfo" "cogentcore.org/core/core" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" "cogentcore.org/core/tree" ) @@ -43,7 +43,7 @@ const ( type SearchResults struct { Node *Node Count int - Matches []textbuf.Match + Matches []text.Match } // Search returns list of all nodes starting at given node of given @@ -101,7 +101,7 @@ func Search(start *Node, find string, ignoreCase, regExp bool, loc FindLocation, // } } var cnt int - var matches []textbuf.Match + var matches []text.Match if sfn.isOpen() && sfn.Buffer != nil { if regExp { cnt, matches = sfn.Buffer.SearchRegexp(re) @@ -110,9 +110,9 @@ func Search(start *Node, find string, ignoreCase, regExp bool, loc FindLocation, } } else { if regExp { - cnt, matches = textbuf.SearchFileRegexp(string(sfn.Filepath), re) + cnt, matches = text.SearchFileRegexp(string(sfn.Filepath), re) } else { - cnt, matches = textbuf.SearchFile(string(sfn.Filepath), fb, ignoreCase) + cnt, matches = text.SearchFile(string(sfn.Filepath), fb, ignoreCase) } } if cnt > 0 { @@ -175,7 +175,7 @@ func findAll(start *Node, find string, ignoreCase, regExp bool, langs []fileinfo } ofn := openPath(path) var cnt int - var matches []textbuf.Match + var matches []text.Match if ofn != nil && ofn.Buffer != nil { if regExp { cnt, matches = ofn.Buffer.SearchRegexp(re) @@ -184,9 +184,9 @@ func findAll(start *Node, find string, ignoreCase, regExp bool, langs []fileinfo } } else { if regExp { - cnt, matches = textbuf.SearchFileRegexp(path, re) + cnt, matches = text.SearchFileRegexp(path, re) } else { - cnt, matches = textbuf.SearchFile(path, fb, ignoreCase) + cnt, matches = text.SearchFile(path, fb, ignoreCase) } } if cnt > 0 { diff --git a/filetree/vcs.go b/filetree/vcs.go index 856f629ff1..02120140a7 100644 --- a/filetree/vcs.go +++ b/filetree/vcs.go @@ -16,7 +16,7 @@ import ( "cogentcore.org/core/core" "cogentcore.org/core/styles" "cogentcore.org/core/texteditor" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" "cogentcore.org/core/tree" ) @@ -333,7 +333,7 @@ func (fn *Node) blameVCS() ([]byte, error) { return nil, errors.New("file not in vcs repo: " + string(fn.Filepath)) } fnm := string(fn.Filepath) - fb, err := textbuf.FileBytes(fnm) + fb, err := text.FileBytes(fnm) if err != nil { return nil, err } diff --git a/texteditor/buffer.go b/texteditor/buffer.go index efc7ff59bd..c8ebdcaaf2 100644 --- a/texteditor/buffer.go +++ b/texteditor/buffer.go @@ -25,7 +25,7 @@ import ( "cogentcore.org/core/parse/token" "cogentcore.org/core/spell" "cogentcore.org/core/texteditor/highlighting" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) // Buffer is a buffer of text, which can be viewed by [Editor](s). @@ -40,7 +40,7 @@ import ( // Internally, the buffer represents new lines using \n = LF, but saving // and loading can deal with Windows/DOS CRLF format. type Buffer struct { //types:add - textbuf.Lines + text.Lines // Filename is the filename of the file that was last loaded or saved. // It is used when highlighting code. @@ -124,12 +124,12 @@ const ( bufferMods // bufferInsert signals that some text was inserted. - // data is textbuf.Edit describing change. + // data is text.Edit describing change. // The Buf always reflects the current state *after* the edit. bufferInsert // bufferDelete signals that some text was deleted. - // data is textbuf.Edit describing change. + // data is text.Edit describing change. // The Buf always reflects the current state *after* the edit. bufferDelete @@ -138,13 +138,13 @@ const ( // so should be used with a mutex bufferMarkupUpdated - // bufferClosed signals that the textbuf was closed. + // bufferClosed signals that the text was closed. bufferClosed ) // signalEditors sends the given signal and optional edit info // to all the [Editor]s for this [Buffer] -func (tb *Buffer) signalEditors(sig bufferSignals, edit *textbuf.Edit) { +func (tb *Buffer) signalEditors(sig bufferSignals, edit *text.Edit) { for _, vw := range tb.editors { vw.bufferSignal(sig, edit) } @@ -603,7 +603,7 @@ func (tb *Buffer) AutoSaveCheck() bool { // AppendTextMarkup appends new text to end of buffer, using insert, returns // edit, and uses supplied markup to render it. -func (tb *Buffer) AppendTextMarkup(text []byte, markup []byte, signal bool) *textbuf.Edit { +func (tb *Buffer) AppendTextMarkup(text []byte, markup []byte, signal bool) *text.Edit { tbe := tb.Lines.AppendTextMarkup(text, markup) if tbe != nil && signal { tb.signalEditors(bufferInsert, tbe) @@ -614,7 +614,7 @@ func (tb *Buffer) AppendTextMarkup(text []byte, markup []byte, signal bool) *tex // 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 (tb *Buffer) AppendTextLineMarkup(text []byte, markup []byte, signal bool) *textbuf.Edit { +func (tb *Buffer) AppendTextLineMarkup(text []byte, markup []byte, signal bool) *text.Edit { tbe := tb.Lines.AppendTextLineMarkup(text, markup) if tbe != nil && signal { tb.signalEditors(bufferInsert, tbe) @@ -690,7 +690,7 @@ const ( // 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 (tb *Buffer) DeleteText(st, ed lexer.Pos, signal bool) *textbuf.Edit { +func (tb *Buffer) DeleteText(st, ed lexer.Pos, signal bool) *text.Edit { tb.FileModCheck() tb.setChanged() tbe := tb.Lines.DeleteText(st, ed) @@ -708,9 +708,9 @@ func (tb *Buffer) DeleteText(st, ed lexer.Pos, signal bool) *textbuf.Edit { // deleteTextRect deletes rectangular region of text between start, end // defining the upper-left and lower-right corners of a rectangle. -// Fails if st.Ch >= ed.Ch. Sets the timestamp on resulting textbuf.Edit to now. +// Fails if st.Ch >= ed.Ch. Sets the timestamp on resulting text.Edit to now. // An Undo record is automatically saved depending on Undo.Off setting. -func (tb *Buffer) deleteTextRect(st, ed lexer.Pos, signal bool) *textbuf.Edit { +func (tb *Buffer) deleteTextRect(st, ed lexer.Pos, signal bool) *text.Edit { tb.FileModCheck() tb.setChanged() tbe := tb.Lines.DeleteTextRect(st, ed) @@ -730,7 +730,7 @@ func (tb *Buffer) deleteTextRect(st, ed lexer.Pos, signal bool) *textbuf.Edit { // It inserts new text at given starting position, optionally signaling // views after text has been inserted. Sets the timestamp on resulting Edit to now. // An Undo record is automatically saved depending on Undo.Off setting. -func (tb *Buffer) insertText(st lexer.Pos, text []byte, signal bool) *textbuf.Edit { +func (tb *Buffer) insertText(st lexer.Pos, text []byte, signal bool) *text.Edit { tb.FileModCheck() // will just revert changes if shouldn't have changed tb.setChanged() tbe := tb.Lines.InsertText(st, text) @@ -746,12 +746,12 @@ func (tb *Buffer) insertText(st lexer.Pos, text []byte, signal bool) *textbuf.Ed return tbe } -// insertTextRect inserts a rectangle of text defined in given textbuf.Edit record, +// insertTextRect inserts a rectangle of text defined in given text.Edit record, // (e.g., from RegionRect or DeleteRect), optionally signaling // views after text has been inserted. // Returns a copy of the Edit record with an updated timestamp. // An Undo record is automatically saved depending on Undo.Off setting. -func (tb *Buffer) insertTextRect(tbe *textbuf.Edit, signal bool) *textbuf.Edit { +func (tb *Buffer) insertTextRect(tbe *text.Edit, signal bool) *text.Edit { tb.FileModCheck() // will just revert changes if shouldn't have changed tb.setChanged() nln := tb.NumLines() @@ -761,7 +761,7 @@ func (tb *Buffer) insertTextRect(tbe *textbuf.Edit, signal bool) *textbuf.Edit { } if signal { if re.Reg.End.Ln >= nln { - ie := &textbuf.Edit{} + ie := &text.Edit{} ie.Reg.Start.Ln = nln - 1 ie.Reg.End.Ln = re.Reg.End.Ln tb.signalEditors(bufferInsert, ie) @@ -779,8 +779,8 @@ func (tb *Buffer) insertTextRect(tbe *textbuf.Edit, signal bool) *textbuf.Edit { // (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 (tb *Buffer) ReplaceText(delSt, delEd, insPos lexer.Pos, insTxt string, signal, matchCase bool) *textbuf.Edit { +// returns the text.Edit for the inserted text. +func (tb *Buffer) ReplaceText(delSt, delEd, insPos lexer.Pos, insTxt string, signal, matchCase bool) *text.Edit { tbe := tb.Lines.ReplaceText(delSt, delEd, insPos, insTxt, matchCase) if tbe == nil { return tbe @@ -815,7 +815,7 @@ func (tb *Buffer) savePosHistory(pos lexer.Pos) bool { // Undo // undo undoes next group of items on the undo stack -func (tb *Buffer) undo() []*textbuf.Edit { +func (tb *Buffer) undo() []*text.Edit { autoSave := tb.batchUpdateStart() defer tb.batchUpdateEnd(autoSave) tbe := tb.Lines.Undo() @@ -829,7 +829,7 @@ func (tb *Buffer) undo() []*textbuf.Edit { // redo redoes next group of items on the undo stack, // and returns the last record, nil if no more -func (tb *Buffer) redo() []*textbuf.Edit { +func (tb *Buffer) redo() []*text.Edit { autoSave := tb.batchUpdateStart() defer tb.batchUpdateEnd(autoSave) tbe := tb.Lines.Redo() @@ -883,7 +883,7 @@ func (tb *Buffer) DeleteLineColor(ln int) { // indentLine indents line by given number of tab stops, using tabs or spaces, // for given tab size (if using spaces) -- either inserts or deletes to reach target. // Returns edit record for any change. -func (tb *Buffer) indentLine(ln, ind int) *textbuf.Edit { +func (tb *Buffer) indentLine(ln, ind int) *text.Edit { autoSave := tb.batchUpdateStart() defer tb.batchUpdateEnd(autoSave) tbe := tb.Lines.IndentLine(ln, ind) @@ -940,7 +940,7 @@ func (tb *Buffer) DiffBuffersUnified(ob *Buffer, context int) []byte { astr := tb.Strings(true) // needs newlines for some reason bstr := ob.Strings(true) - return textbuf.DiffLinesUnified(astr, bstr, context, string(tb.Filename), tb.Info.ModTime.String(), + return text.DiffLinesUnified(astr, bstr, context, string(tb.Filename), tb.Info.ModTime.String(), string(ob.Filename), ob.Info.ModTime.String()) } diff --git a/texteditor/complete.go b/texteditor/complete.go index 23933e7d19..437dc062c6 100644 --- a/texteditor/complete.go +++ b/texteditor/complete.go @@ -11,7 +11,7 @@ import ( "cogentcore.org/core/parse/complete" "cogentcore.org/core/parse/lexer" "cogentcore.org/core/parse/parser" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) // completeParse uses [parse] symbols and language; the string is a line of text @@ -61,7 +61,7 @@ func completeEditParse(data any, text string, cursorPos int, comp complete.Compl // 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 lookupParse(data any, text string, posLine, posChar int) (ld complete.Lookup) { +func lookupParse(data any, txt string, posLine, posChar int) (ld complete.Lookup) { sfs := data.(*parse.FileStates) if sfs == nil { // log.Printf("LookupPi: data is nil not FileStates or is nil - can't lookup\n") @@ -80,15 +80,15 @@ func lookupParse(data any, text string, posLine, posChar int) (ld complete.Looku // must set it in pi/parse directly -- so it is changed in the fileparse too parser.GUIActive = true // note: this is key for debugging -- runs slower but makes the tree unique - ld = lp.Lang.Lookup(sfs, text, lexer.Pos{posLine, posChar}) + ld = lp.Lang.Lookup(sfs, txt, lexer.Pos{posLine, posChar}) if len(ld.Text) > 0 { - TextDialog(nil, "Lookup: "+text, string(ld.Text)) + TextDialog(nil, "Lookup: "+txt, string(ld.Text)) return ld } if ld.Filename != "" { - txt := textbuf.FileRegionBytes(ld.Filename, ld.StLine, ld.EdLine, true, 10) // comments, 10 lines back max + tx := text.FileRegionBytes(ld.Filename, ld.StLine, ld.EdLine, true, 10) // comments, 10 lines back max prmpt := fmt.Sprintf("%v [%d:%d]", ld.Filename, ld.StLine, ld.EdLine) - TextDialog(nil, "Lookup: "+text+": "+prmpt, string(txt)) + TextDialog(nil, "Lookup: "+txt+": "+prmpt, string(tx)) return ld } diff --git a/texteditor/diffeditor.go b/texteditor/diffeditor.go index 43bb902af2..61efe091b1 100644 --- a/texteditor/diffeditor.go +++ b/texteditor/diffeditor.go @@ -25,7 +25,7 @@ import ( "cogentcore.org/core/parse/token" "cogentcore.org/core/styles" "cogentcore.org/core/styles/states" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" "cogentcore.org/core/tree" ) @@ -58,12 +58,12 @@ func DiffEditorDialogFromRevs(ctx core.Widget, repo vcs.Repo, file string, fbuf if fbuf != nil { bstr = fbuf.Strings(false) } else { - fb, err := textbuf.FileBytes(file) + fb, err := text.FileBytes(file) if err != nil { core.ErrorDialog(ctx, err) return nil, err } - bstr = textbuf.BytesToLineStrings(fb, false) // don't add new lines + bstr = text.BytesToLineStrings(fb, false) // don't add new lines } } else { fb, err := repo.FileContents(file, rev_b) @@ -71,14 +71,14 @@ func DiffEditorDialogFromRevs(ctx core.Widget, repo vcs.Repo, file string, fbuf core.ErrorDialog(ctx, err) return nil, err } - bstr = textbuf.BytesToLineStrings(fb, false) // don't add new lines + bstr = text.BytesToLineStrings(fb, false) // don't add new lines } fb, err := repo.FileContents(file, rev_a) if err != nil { core.ErrorDialog(ctx, err) return nil, err } - astr = textbuf.BytesToLineStrings(fb, false) // don't add new lines + astr = text.BytesToLineStrings(fb, false) // don't add new lines if rev_a == "" { rev_a = "HEAD" } @@ -141,10 +141,10 @@ type DiffEditor struct { bufferB *Buffer // aligned diffs records diff for aligned lines - alignD textbuf.Diffs + alignD text.Diffs // diffs applied - diffs textbuf.DiffSelected + diffs text.DiffSelected inInputEvent bool } @@ -330,7 +330,7 @@ func (dv *DiffEditor) DiffStrings(astr, bstr []string) { chg := colors.Scheme.Primary.Base nd := len(dv.diffs.Diffs) - dv.alignD = make(textbuf.Diffs, nd) + dv.alignD = make(text.Diffs, nd) var ab, bb [][]byte absln := 0 bspc := []byte(" ") @@ -444,7 +444,7 @@ func (dv *DiffEditor) tagWordDiffs() { fla := lna.RuneStrings(ra) flb := lnb.RuneStrings(rb) nab := max(len(fla), len(flb)) - ldif := textbuf.DiffLines(fla, flb) + ldif := text.DiffLines(fla, flb) ndif := len(ldif) if nab > 25 && ndif > nab/2 { // more than half of big diff -- skip continue diff --git a/texteditor/editor.go b/texteditor/editor.go index a9ba9f1a63..f9134c19ef 100644 --- a/texteditor/editor.go +++ b/texteditor/editor.go @@ -24,7 +24,7 @@ import ( "cogentcore.org/core/styles/states" "cogentcore.org/core/styles/units" "cogentcore.org/core/texteditor/highlighting" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) // TODO: move these into an editor settings object @@ -118,17 +118,17 @@ type Editor struct { //core:embedder selectStart lexer.Pos // SelectRegion is the current selection region. - SelectRegion textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"` + SelectRegion text.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 + previousSelectRegion text.Region // Highlights is a slice of regions representing the highlighted regions, e.g., for search results. - Highlights []textbuf.Region `set:"-" edit:"-" json:"-" xml:"-"` + Highlights []text.Region `set:"-" edit:"-" json:"-" xml:"-"` // scopelights is a slice of regions representing the highlighted regions specific to scope markers. - scopelights []textbuf.Region + scopelights []text.Region // LinkHandler handles link clicks. // If it is nil, they are sent to the standard web URL handler. @@ -351,7 +351,7 @@ func (ed *Editor) SetBuffer(buf *Buffer) *Editor { } // linesInserted inserts new lines of text and reformats them -func (ed *Editor) linesInserted(tbe *textbuf.Edit) { +func (ed *Editor) linesInserted(tbe *text.Edit) { stln := tbe.Reg.Start.Ln + 1 nsz := (tbe.Reg.End.Ln - tbe.Reg.Start.Ln) if stln > len(ed.renders) { // invalid @@ -377,7 +377,7 @@ func (ed *Editor) linesInserted(tbe *textbuf.Edit) { } // linesDeleted deletes lines of text and reformats remaining one -func (ed *Editor) linesDeleted(tbe *textbuf.Edit) { +func (ed *Editor) linesDeleted(tbe *text.Edit) { stln := tbe.Reg.Start.Ln edln := tbe.Reg.End.Ln dsz := edln - stln @@ -391,7 +391,7 @@ func (ed *Editor) linesDeleted(tbe *textbuf.Edit) { // bufferSignal receives a signal from the Buffer when the underlying text // is changed. -func (ed *Editor) bufferSignal(sig bufferSignals, tbe *textbuf.Edit) { +func (ed *Editor) bufferSignal(sig bufferSignals, tbe *text.Edit) { switch sig { case bufferDone: case bufferNew: diff --git a/texteditor/enumgen.go b/texteditor/enumgen.go index 1b6613fa3d..e97be5f83c 100644 --- a/texteditor/enumgen.go +++ b/texteditor/enumgen.go @@ -13,7 +13,7 @@ const bufferSignalsN bufferSignals = 7 var _bufferSignalsValueMap = map[string]bufferSignals{`Done`: 0, `New`: 1, `Mods`: 2, `Insert`: 3, `Delete`: 4, `MarkupUpdated`: 5, `Closed`: 6} -var _bufferSignalsDescMap = map[bufferSignals]string{0: `bufferDone means that editing was completed and applied to Txt field -- data is Txt bytes`, 1: `bufferNew signals that entirely new text is present. All views should do full layout update.`, 2: `bufferMods signals that potentially diffuse modifications have been made. Views should do a Layout and Render.`, 3: `bufferInsert signals that some text was inserted. data is textbuf.Edit describing change. The Buf always reflects the current state *after* the edit.`, 4: `bufferDelete signals that some text was deleted. data is textbuf.Edit describing change. The Buf always reflects the current state *after* the edit.`, 5: `bufferMarkupUpdated signals that the Markup text has been updated This signal is typically sent from a separate goroutine, so should be used with a mutex`, 6: `bufferClosed signals that the textbuf was closed.`} +var _bufferSignalsDescMap = map[bufferSignals]string{0: `bufferDone means that editing was completed and applied to Txt field -- data is Txt bytes`, 1: `bufferNew signals that entirely new text is present. All views should do full layout update.`, 2: `bufferMods signals that potentially diffuse modifications have been made. Views should do a Layout and Render.`, 3: `bufferInsert signals that some text was inserted. data is text.Edit describing change. The Buf always reflects the current state *after* the edit.`, 4: `bufferDelete signals that some text was deleted. data is text.Edit describing change. The Buf always reflects the current state *after* the edit.`, 5: `bufferMarkupUpdated signals that the Markup text has been updated This signal is typically sent from a separate goroutine, so should be used with a mutex`, 6: `bufferClosed signals that the text was closed.`} var _bufferSignalsMap = map[bufferSignals]string{0: `Done`, 1: `New`, 2: `Mods`, 3: `Insert`, 4: `Delete`, 5: `MarkupUpdated`, 6: `Closed`} diff --git a/texteditor/events.go b/texteditor/events.go index efc314c3eb..5ccd833971 100644 --- a/texteditor/events.go +++ b/texteditor/events.go @@ -23,7 +23,7 @@ import ( "cogentcore.org/core/styles/abilities" "cogentcore.org/core/styles/states" "cogentcore.org/core/system" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) func (ed *Editor) handleFocus() { @@ -46,15 +46,15 @@ func (ed *Editor) handleKeyChord() { } // 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 +// If the shift key has been released the select region is set to text.RegionNil func (ed *Editor) shiftSelect(kt events.Event) { hasShift := kt.HasAnyModifier(key.Shift) if hasShift { - if ed.SelectRegion == textbuf.RegionNil { + if ed.SelectRegion == text.RegionNil { ed.selectStart = ed.CursorPos } } else { - ed.SelectRegion = textbuf.RegionNil + ed.SelectRegion = text.RegionNil } } @@ -479,8 +479,8 @@ func (ed *Editor) keyInputInsertRune(kt events.Event) { np.Ch-- tp, found := ed.Buffer.BraceMatch(kt.KeyRune(), np) if found { - ed.scopelights = append(ed.scopelights, textbuf.NewRegionPos(tp, lexer.Pos{tp.Ln, tp.Ch + 1})) - ed.scopelights = append(ed.scopelights, textbuf.NewRegionPos(np, lexer.Pos{cp.Ln, cp.Ch})) + ed.scopelights = append(ed.scopelights, text.NewRegionPos(tp, lexer.Pos{tp.Ln, tp.Ch + 1})) + ed.scopelights = append(ed.scopelights, text.NewRegionPos(np, lexer.Pos{cp.Ln, cp.Ch})) } } } @@ -527,7 +527,7 @@ func (ed *Editor) OpenLinkAt(pos lexer.Pos) (*paint.TextLink, bool) { rend := &ed.renders[pos.Ln] st, _ := rend.SpanPosToRuneIndex(tl.StartSpan, tl.StartIndex) end, _ := rend.SpanPosToRuneIndex(tl.EndSpan, tl.EndIndex) - reg := textbuf.NewRegion(pos.Ln, st, pos.Ln, end) + reg := text.NewRegion(pos.Ln, st, pos.Ln, end) _ = reg ed.HighlightRegion(reg) ed.SetCursorTarget(pos) @@ -647,7 +647,7 @@ func (ed *Editor) setCursorFromMouse(pt image.Point, newPos lexer.Pos, selMode e defer ed.NeedsRender() if !ed.selectMode && selMode == events.ExtendContinuous { - if ed.SelectRegion == textbuf.RegionNil { + if ed.SelectRegion == text.RegionNil { ed.selectStart = ed.CursorPos } ed.setCursor(newPos) diff --git a/texteditor/find.go b/texteditor/find.go index 705f26836c..9a96e1677f 100644 --- a/texteditor/find.go +++ b/texteditor/find.go @@ -12,13 +12,13 @@ import ( "cogentcore.org/core/events" "cogentcore.org/core/parse/lexer" "cogentcore.org/core/styles" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) // findMatches finds the matches with given search string (literal, not regex) // and case sensitivity, updates highlights for all. returns false if none // found -func (ed *Editor) findMatches(find string, useCase, lexItems bool) ([]textbuf.Match, bool) { +func (ed *Editor) findMatches(find string, useCase, lexItems bool) ([]text.Match, bool) { fsz := len(find) if fsz == 0 { ed.Highlights = nil @@ -29,7 +29,7 @@ func (ed *Editor) findMatches(find string, useCase, lexItems bool) ([]textbuf.Ma ed.Highlights = nil return matches, false } - hi := make([]textbuf.Region, len(matches)) + hi := make([]text.Region, len(matches)) for i, m := range matches { hi[i] = m.Reg if i > viewMaxFindHighlights { @@ -41,7 +41,7 @@ func (ed *Editor) findMatches(find string, useCase, lexItems bool) ([]textbuf.Ma } // matchFromPos finds the match at or after the given text position -- returns 0, false if none -func (ed *Editor) matchFromPos(matches []textbuf.Match, cpos lexer.Pos) (int, bool) { +func (ed *Editor) matchFromPos(matches []text.Match, cpos lexer.Pos) (int, bool) { for i, m := range matches { reg := ed.Buffer.AdjustRegion(m.Reg) if reg.Start == cpos || cpos.IsLess(reg.Start) { @@ -64,7 +64,7 @@ type ISearch struct { useCase bool // current search matches - Matches []textbuf.Match `json:"-" xml:"-"` + Matches []text.Match `json:"-" xml:"-"` // position within isearch matches pos int @@ -252,7 +252,7 @@ type QReplace struct { lexItems bool // current search matches - Matches []textbuf.Match `json:"-" xml:"-"` + Matches []text.Match `json:"-" xml:"-"` // position within isearch matches pos int `json:"-" xml:"-"` @@ -391,7 +391,7 @@ func (ed *Editor) qReplaceReplace(midx int) { // last arg is matchCase, only if not using case to match and rep is also lower case matchCase := !ed.QReplace.useCase && !lexer.HasUpperCase(rep) ed.Buffer.ReplaceText(reg.Start, reg.End, pos, rep, EditSignal, matchCase) - ed.Highlights[midx] = textbuf.RegionNil + ed.Highlights[midx] = text.RegionNil ed.setCursor(pos) ed.savePosHistory(ed.CursorPos) ed.scrollCursorToCenterIfHidden() diff --git a/texteditor/nav.go b/texteditor/nav.go index a5948c11ae..686ca1055e 100644 --- a/texteditor/nav.go +++ b/texteditor/nav.go @@ -12,7 +12,7 @@ import ( "cogentcore.org/core/events" "cogentcore.org/core/math32" "cogentcore.org/core/parse/lexer" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) /////////////////////////////////////////////////////////////////////////////// @@ -68,8 +68,8 @@ func (ed *Editor) setCursor(pos lexer.Pos) { if r == '{' || r == '}' || r == '(' || r == ')' || r == '[' || r == ']' { tp, found := ed.Buffer.BraceMatch(txt[ch], ed.CursorPos) if found { - ed.scopelights = append(ed.scopelights, textbuf.NewRegionPos(ed.CursorPos, lexer.Pos{ed.CursorPos.Ln, ed.CursorPos.Ch + 1})) - ed.scopelights = append(ed.scopelights, textbuf.NewRegionPos(tp, lexer.Pos{tp.Ln, tp.Ch + 1})) + ed.scopelights = append(ed.scopelights, text.NewRegionPos(ed.CursorPos, lexer.Pos{ed.CursorPos.Ln, ed.CursorPos.Ch + 1})) + ed.scopelights = append(ed.scopelights, text.NewRegionPos(tp, lexer.Pos{tp.Ln, tp.Ch + 1})) } } } @@ -729,7 +729,7 @@ func (ed *Editor) jumpToLine(ln int) { } // findNextLink finds next link after given position, returns false if no such links -func (ed *Editor) findNextLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool) { +func (ed *Editor) findNextLink(pos lexer.Pos) (lexer.Pos, text.Region, bool) { for ln := pos.Ln; ln < ed.NumLines; ln++ { if len(ed.renders[ln].Links) == 0 { pos.Ch = 0 @@ -743,7 +743,7 @@ func (ed *Editor) findNextLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool) if tl.StartSpan >= si && tl.StartIndex >= ri { st, _ := rend.SpanPosToRuneIndex(tl.StartSpan, tl.StartIndex) ed, _ := rend.SpanPosToRuneIndex(tl.EndSpan, tl.EndIndex) - reg := textbuf.NewRegion(ln, st, ln, ed) + reg := text.NewRegion(ln, st, ln, ed) pos.Ch = st + 1 // get into it so next one will go after.. return pos, reg, true } @@ -751,11 +751,11 @@ func (ed *Editor) findNextLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool) pos.Ln = ln + 1 pos.Ch = 0 } - return pos, textbuf.RegionNil, false + return pos, text.RegionNil, false } // findPrevLink finds previous link before given position, returns false if no such links -func (ed *Editor) findPrevLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool) { +func (ed *Editor) findPrevLink(pos lexer.Pos) (lexer.Pos, text.Region, bool) { for ln := pos.Ln - 1; ln >= 0; ln-- { if len(ed.renders[ln].Links) == 0 { if ln-1 >= 0 { @@ -774,14 +774,14 @@ func (ed *Editor) findPrevLink(pos lexer.Pos) (lexer.Pos, textbuf.Region, bool) if tl.StartSpan <= si && tl.StartIndex < ri { st, _ := rend.SpanPosToRuneIndex(tl.StartSpan, tl.StartIndex) ed, _ := rend.SpanPosToRuneIndex(tl.EndSpan, tl.EndIndex) - reg := textbuf.NewRegion(ln, st, ln, ed) + reg := text.NewRegion(ln, st, ln, ed) pos.Ln = ln pos.Ch = st + 1 return pos, reg, true } } } - return pos, textbuf.RegionNil, false + return pos, text.RegionNil, false } // CursorNextLink moves cursor to next link. wraparound wraps around to top of diff --git a/texteditor/render.go b/texteditor/render.go index 54626b30d5..39e9e2fdd3 100644 --- a/texteditor/render.go +++ b/texteditor/render.go @@ -17,7 +17,7 @@ import ( "cogentcore.org/core/parse/lexer" "cogentcore.org/core/styles" "cogentcore.org/core/styles/states" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) // Rendering Notes: all rendering is done in Render call. @@ -245,7 +245,7 @@ func (ed *Editor) renderDepthBackground(stln, edln int) { }) st := min(lsted, lx.St) - reg := textbuf.Region{Start: lexer.Pos{Ln: ln, Ch: st}, End: lexer.Pos{Ln: ln, Ch: lx.Ed}} + reg := text.Region{Start: lexer.Pos{Ln: ln, Ch: st}, End: lexer.Pos{Ln: ln, Ch: lx.Ed}} lsted = lx.Ed lstdp = lx.Token.Depth ed.renderRegionBoxStyle(reg, sty, bg, true) // full width alway @@ -290,12 +290,12 @@ func (ed *Editor) renderScopelights(stln, edln int) { } // renderRegionBox renders a region in background according to given background -func (ed *Editor) renderRegionBox(reg textbuf.Region, bg image.Image) { +func (ed *Editor) renderRegionBox(reg text.Region, bg image.Image) { ed.renderRegionBoxStyle(reg, &ed.Styles, bg, false) } // renderRegionBoxStyle renders a region in given style and background -func (ed *Editor) renderRegionBoxStyle(reg textbuf.Region, sty *styles.Style, bg image.Image, fullWidth bool) { +func (ed *Editor) renderRegionBoxStyle(reg text.Region, sty *styles.Style, bg image.Image, fullWidth bool) { st := reg.Start end := reg.End spos := ed.charStartPosVisible(st) diff --git a/texteditor/select.go b/texteditor/select.go index 7361f31338..76dcec8ccd 100644 --- a/texteditor/select.go +++ b/texteditor/select.go @@ -10,7 +10,7 @@ import ( "cogentcore.org/core/base/strcase" "cogentcore.org/core/core" "cogentcore.org/core/parse/lexer" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) ////////////////////////////////////////////////////////// @@ -18,8 +18,8 @@ import ( // HighlightRegion creates a new highlighted region, // triggers updating. -func (ed *Editor) HighlightRegion(reg textbuf.Region) { - ed.Highlights = []textbuf.Region{reg} +func (ed *Editor) HighlightRegion(reg text.Region) { + ed.Highlights = []text.Region{reg} ed.NeedsRender() } @@ -37,7 +37,7 @@ func (ed *Editor) clearScopelights() { if len(ed.scopelights) == 0 { return } - sl := make([]textbuf.Region, len(ed.scopelights)) + sl := make([]text.Region, len(ed.scopelights)) copy(sl, ed.scopelights) ed.scopelights = ed.scopelights[:0] ed.NeedsRender() @@ -57,9 +57,9 @@ func (ed *Editor) HasSelection() bool { return ed.SelectRegion.Start.IsLess(ed.SelectRegion.End) } -// Selection returns the currently selected text as a textbuf.Edit, which +// Selection returns the currently selected text as a text.Edit, which // captures start, end, and full lines in between -- nil if no selection -func (ed *Editor) Selection() *textbuf.Edit { +func (ed *Editor) Selection() *text.Edit { if ed.HasSelection() { return ed.Buffer.Region(ed.SelectRegion.Start, ed.SelectRegion.End) } @@ -87,7 +87,7 @@ func (ed *Editor) selectAll() { // wordBefore returns the word before the lexer.Pos // uses IsWordBreak to determine the bounds of the word -func (ed *Editor) wordBefore(tp lexer.Pos) *textbuf.Edit { +func (ed *Editor) wordBefore(tp lexer.Pos) *text.Edit { txt := ed.Buffer.Line(tp.Ln) ch := tp.Ch ch = min(ch, len(txt)) @@ -169,7 +169,7 @@ func (ed *Editor) selectWord() bool { } // wordAt finds the region of the word at the current cursor position -func (ed *Editor) wordAt() (reg textbuf.Region) { +func (ed *Editor) wordAt() (reg text.Region) { reg.Start = ed.CursorPos reg.End = ed.CursorPos txt := ed.Buffer.Line(ed.CursorPos.Ln) @@ -231,8 +231,8 @@ func (ed *Editor) SelectReset() { if !ed.HasSelection() { return } - ed.SelectRegion = textbuf.RegionNil - ed.previousSelectRegion = textbuf.RegionNil + ed.SelectRegion = text.RegionNil + ed.previousSelectRegion = text.RegionNil } /////////////////////////////////////////////////////////////////////////////// @@ -302,7 +302,7 @@ func (ed *Editor) pasteHistory() { } // Cut cuts any selected text and adds it to the clipboard, also returns cut text -func (ed *Editor) Cut() *textbuf.Edit { +func (ed *Editor) Cut() *text.Edit { if !ed.HasSelection() { return nil } @@ -320,8 +320,8 @@ func (ed *Editor) Cut() *textbuf.Edit { } // deleteSelection deletes any selected text, without adding to clipboard -- -// returns text deleted as textbuf.Edit (nil if none) -func (ed *Editor) deleteSelection() *textbuf.Edit { +// returns text deleted as text.Edit (nil if none) +func (ed *Editor) deleteSelection() *text.Edit { tbe := ed.Buffer.DeleteText(ed.SelectRegion.Start, ed.SelectRegion.End, EditSignal) ed.SelectReset() return tbe @@ -329,7 +329,7 @@ func (ed *Editor) deleteSelection() *textbuf.Edit { // Copy copies any selected text to the clipboard, and returns that text, // optionally resetting the current selection -func (ed *Editor) Copy(reset bool) *textbuf.Edit { +func (ed *Editor) Copy(reset bool) *text.Edit { tbe := ed.Selection() if tbe == nil { return nil @@ -359,7 +359,7 @@ func (ed *Editor) Paste() { func (ed *Editor) InsertAtCursor(txt []byte) { if ed.HasSelection() { tbe := ed.deleteSelection() - ed.CursorPos = tbe.AdjustPos(ed.CursorPos, textbuf.AdjustPosDelStart) // move to start if in reg + ed.CursorPos = tbe.AdjustPos(ed.CursorPos, text.AdjustPosDelStart) // move to start if in reg } tbe := ed.Buffer.insertText(ed.CursorPos, txt, EditSignal) if tbe == nil { @@ -380,11 +380,11 @@ func (ed *Editor) InsertAtCursor(txt []byte) { // editorClipboardRect 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 editorClipboardRect *textbuf.Edit +var editorClipboardRect *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 (ed *Editor) CutRect() *textbuf.Edit { +func (ed *Editor) CutRect() *text.Edit { if !ed.HasSelection() { return nil } @@ -403,7 +403,7 @@ func (ed *Editor) CutRect() *textbuf.Edit { // CopyRect copies any selected text to the clipboard, and returns that text, // optionally resetting the current selection -func (ed *Editor) CopyRect(reset bool) *textbuf.Edit { +func (ed *Editor) CopyRect(reset bool) *text.Edit { tbe := ed.Buffer.RegionRect(ed.SelectRegion.Start, ed.SelectRegion.End) if tbe == nil { return nil diff --git a/texteditor/spell.go b/texteditor/spell.go index 7e97a62dec..7a9544ac79 100644 --- a/texteditor/spell.go +++ b/texteditor/spell.go @@ -14,7 +14,7 @@ import ( "cogentcore.org/core/keymap" "cogentcore.org/core/parse/lexer" "cogentcore.org/core/parse/token" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) /////////////////////////////////////////////////////////////////////////////// @@ -201,7 +201,7 @@ func (ed *Editor) iSpellKeyInput(kt events.Event) { // 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 (ed *Editor) spellCheck(reg *textbuf.Edit) bool { +func (ed *Editor) spellCheck(reg *text.Edit) bool { if ed.Buffer.spell == nil { return false } diff --git a/texteditor/textbuf/diff.go b/texteditor/text/diff.go similarity index 99% rename from texteditor/textbuf/diff.go rename to texteditor/text/diff.go index 785dbd02e5..62ba814eb3 100644 --- a/texteditor/textbuf/diff.go +++ b/texteditor/text/diff.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "bytes" diff --git a/texteditor/textbuf/diff_test.go b/texteditor/text/diff_test.go similarity index 98% rename from texteditor/textbuf/diff_test.go rename to texteditor/text/diff_test.go index eb21a008ce..cae147bf8f 100644 --- a/texteditor/textbuf/diff_test.go +++ b/texteditor/text/diff_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "testing" diff --git a/texteditor/textbuf/diffsel.go b/texteditor/text/diffsel.go similarity index 99% rename from texteditor/textbuf/diffsel.go rename to texteditor/text/diffsel.go index 0ce3b379e0..790f705774 100644 --- a/texteditor/textbuf/diffsel.go +++ b/texteditor/text/diffsel.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "slices" diff --git a/texteditor/textbuf/diffsel_test.go b/texteditor/text/diffsel_test.go similarity index 99% rename from texteditor/textbuf/diffsel_test.go rename to texteditor/text/diffsel_test.go index 11f41ef9f3..6c87a08b88 100644 --- a/texteditor/textbuf/diffsel_test.go +++ b/texteditor/text/diffsel_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text // TODO: fix this /* diff --git a/texteditor/textbuf/edit.go b/texteditor/text/edit.go similarity index 99% rename from texteditor/textbuf/edit.go rename to texteditor/text/edit.go index 2e5a3950f1..f1e4fd0735 100644 --- a/texteditor/textbuf/edit.go +++ b/texteditor/text/edit.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "slices" diff --git a/texteditor/textbuf/lines.go b/texteditor/text/lines.go similarity index 99% rename from texteditor/textbuf/lines.go rename to texteditor/text/lines.go index 33c4346dfa..31cdd3d55c 100644 --- a/texteditor/textbuf/lines.go +++ b/texteditor/text/lines.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "bytes" @@ -753,7 +753,7 @@ func (ls *Lines) region(st, ed lexer.Pos) *Edit { return nil } if !st.IsLess(ed) { - log.Printf("textbuf.region: starting position must be less than ending!: st: %v, ed: %v\n", st, ed) + log.Printf("text.region: starting position must be less than ending!: st: %v, ed: %v\n", st, ed) return nil } tbe := &Edit{Reg: NewRegionPos(st, ed)} @@ -1638,7 +1638,7 @@ func (ls *Lines) commentRegion(start, end int) { comst, comed := ls.Options.CommentStrings() if comst == "" { - log.Printf("textbuf.Lines: attempt to comment region without any comment syntax defined") + log.Printf("text.Lines: attempt to comment region without any comment syntax defined") return } diff --git a/texteditor/textbuf/options.go b/texteditor/text/options.go similarity index 99% rename from texteditor/textbuf/options.go rename to texteditor/text/options.go index aba41291a8..1563e64602 100644 --- a/texteditor/textbuf/options.go +++ b/texteditor/text/options.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "cogentcore.org/core/base/fileinfo" diff --git a/texteditor/textbuf/region.go b/texteditor/text/region.go similarity index 99% rename from texteditor/textbuf/region.go rename to texteditor/text/region.go index 2edb4ead63..0a85fb43c0 100644 --- a/texteditor/textbuf/region.go +++ b/texteditor/text/region.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "fmt" diff --git a/texteditor/textbuf/search.go b/texteditor/text/search.go similarity index 98% rename from texteditor/textbuf/search.go rename to texteditor/text/search.go index 605b612d75..b052e7ffec 100644 --- a/texteditor/textbuf/search.go +++ b/texteditor/text/search.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "bufio" @@ -190,7 +190,7 @@ func Search(reader io.Reader, find []byte, ignoreCase bool) (int, []Match) { func SearchFile(filename string, find []byte, ignoreCase bool) (int, []Match) { fp, err := os.Open(filename) if err != nil { - log.Printf("textbuf.SearchFile: open error: %v\n", err) + log.Printf("text.SearchFile: open error: %v\n", err) return 0, nil } defer fp.Close() @@ -245,7 +245,7 @@ func SearchRegexp(reader io.Reader, re *regexp.Regexp) (int, []Match) { func SearchFileRegexp(filename string, re *regexp.Regexp) (int, []Match) { fp, err := os.Open(filename) if err != nil { - log.Printf("textbuf.SearchFile: open error: %v\n", err) + log.Printf("text.SearchFile: open error: %v\n", err) return 0, nil } defer fp.Close() diff --git a/texteditor/textbuf/undo.go b/texteditor/text/undo.go similarity index 99% rename from texteditor/textbuf/undo.go rename to texteditor/text/undo.go index c04f949003..5239c52297 100644 --- a/texteditor/textbuf/undo.go +++ b/texteditor/text/undo.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "fmt" diff --git a/texteditor/textbuf/util.go b/texteditor/text/util.go similarity index 99% rename from texteditor/textbuf/util.go rename to texteditor/text/util.go index 811c726704..81111836fa 100644 --- a/texteditor/textbuf/util.go +++ b/texteditor/text/util.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package textbuf +package text import ( "bufio" diff --git a/undo/undo.go b/undo/undo.go index a0fa03839d..fee94dcc4a 100644 --- a/undo/undo.go +++ b/undo/undo.go @@ -33,7 +33,7 @@ import ( "strings" "sync" - "cogentcore.org/core/texteditor/textbuf" + "cogentcore.org/core/texteditor/text" ) // DefaultRawInterval is interval for saving raw state -- need to do this @@ -56,7 +56,7 @@ type Record struct { Raw []string // patch to get from previous record to this one - Patch textbuf.Patch + Patch text.Patch // this record is an UndoSave, when Undo first called from end of stack UndoSave bool @@ -187,7 +187,7 @@ func (us *Stack) SaveState(nr *Record, idx int, state []string) { return } prv := us.RecState(idx - 1) - dif := textbuf.DiffLines(prv, state) + dif := text.DiffLines(prv, state) nr.Patch = dif.ToPatch(state) us.Mu.Unlock() }