Skip to content

Commit

Permalink
update to more texteditor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoreilly committed Jul 14, 2024
1 parent 40ce3fc commit a6ce441
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion code/appbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (cv *Code) AddChooserFiles(ac *core.Chooser) {
func (cv *Code) AddChooserSymbols(ac *core.Chooser) {
ac.AddItemsFunc(func() {
tv := cv.ActiveTextEditor()
if tv == nil || tv.Buffer == nil || !tv.Buffer.Hi.UsingParse() {
if tv == nil || tv.Buffer == nil || !tv.Buffer.Highlighting.UsingParse() {

Check failure on line 342 in code/appbar.go

View workflow job for this annotation

GitHub Actions / build

tv.Buffer.Highlighting undefined (type *texteditor.Buffer has no field or method Highlighting)
return
}
pfs := tv.Buffer.ParseState.Done()
Expand Down
16 changes: 8 additions & 8 deletions code/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (cv *Code) LookupFun(data any, text string, posLine, posChar int) (ld compl
title := "Lookup: " + text

tb := texteditor.NewBuffer().SetText(txt).SetFilename(ld.Filename)
tb.Hi.Style = core.AppearanceSettings.HiStyle
tb.Highlighting.Style = core.AppearanceSettings.Highlighting

Check failure on line 96 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

tb.Highlighting undefined (type *texteditor.Buffer has no field or method Highlighting)

Check failure on line 96 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

core.AppearanceSettings.Highlighting undefined (type *"cogentcore.org/core/core".AppearanceSettingsData has no field or method Highlighting)
tb.Options.LineNumbers = cv.Settings.Editor.LineNumbers

d := core.NewBody().AddTitle(title).AddText(prmpt).SetData(&ld)
Expand Down Expand Up @@ -262,9 +262,9 @@ func (cv *Code) TabsToSpaces() { //types:add
return
}
if tv.HasSelection() {
tv.Buffer.TabsToSpacesRegion(tv.SelectRegion.Start.Ln, tv.SelectRegion.End.Ln)
tv.Buffer.TabsToSpaces(tv.SelectRegion.Start.Ln, tv.SelectRegion.End.Ln)

Check failure on line 265 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

tv.Buffer.TabsToSpaces undefined (type *texteditor.Buffer has no field or method TabsToSpaces)
} else {
tv.Buffer.TabsToSpacesRegion(0, tv.NumLines-1)
tv.Buffer.TabsToSpaces(0, tv.NumLines-1)

Check failure on line 267 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

tv.Buffer.TabsToSpaces undefined (type *texteditor.Buffer has no field or method TabsToSpaces)

Check failure on line 267 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

tv.NumLines undefined (type *TextEditor has no field or method NumLines)
}
}

Expand All @@ -276,9 +276,9 @@ func (cv *Code) SpacesToTabs() { //types:add
return
}
if tv.HasSelection() {
tv.Buffer.SpacesToTabsRegion(tv.SelectRegion.Start.Ln, tv.SelectRegion.End.Ln)
tv.Buffer.SpacesToTabs(tv.SelectRegion.Start.Ln, tv.SelectRegion.End.Ln)

Check failure on line 279 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

tv.Buffer.SpacesToTabs undefined (type *texteditor.Buffer has no field or method SpacesToTabs)
} else {
tv.Buffer.SpacesToTabsRegion(0, tv.NumLines-1)
tv.Buffer.SpacesToTabs(0, tv.NumLines-1)

Check failure on line 281 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

tv.Buffer.SpacesToTabs undefined (type *texteditor.Buffer has no field or method SpacesToTabs)

Check failure on line 281 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

tv.NumLines undefined (type *TextEditor has no field or method NumLines)
}
}

Expand Down Expand Up @@ -329,12 +329,12 @@ func (cv *Code) DiffFileNode(fna *filetree.Node, fnmB core.Filename) { //types:a
// returns a string report thereof.
func (cv *Code) CountWords() string { //types:add
av := cv.ActiveTextEditor()
if av.Buffer == nil || av.Buffer.NLines <= 0 {
if av.Buffer == nil || av.Buffer.NumLines <= 0 {
return "empty"
}
av.Buffer.LinesMu.RLock()
defer av.Buffer.LinesMu.RUnlock()
ll := av.Buffer.NLines - 1
ll := av.Buffer.NumLines - 1
reg := textbuf.NewRegion(0, 0, ll, len(av.Buffer.Lines[ll]))
words, lines := textbuf.CountWordsLinesRegion(av.Buffer.Lines, reg)
return fmt.Sprintf("File: %s Words: %d Lines: %d\n", fsx.DirAndFile(string(av.Buffer.Filename)), words, lines)
Expand All @@ -344,7 +344,7 @@ func (cv *Code) CountWords() string { //types:add
// if no selection, returns numbers for entire file.
func (cv *Code) CountWordsRegion() string { //types:add
av := cv.ActiveTextEditor()
if av.Buffer == nil || av.Buffer.NLines <= 0 {
if av.Buffer == nil || av.Buffer.NumLines <= 0 {
return "empty"
}
if !av.HasSelection() {
Expand Down
2 changes: 1 addition & 1 deletion code/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (cv *Code) OpenFileNode(fn *filetree.Node) (bool, error) {
if fn.IsDir() {
return false, fmt.Errorf("cannot open directory: %v", fn.Filepath)
}
filetree.NodeHiStyle = core.AppearanceSettings.HiStyle // must be set prior to OpenBuf
filetree.NodeHiStyle = core.AppearanceSettings.Highlighting // must be set prior to OpenBuf
nw, err := fn.OpenBuf()
if err == nil {
cv.ConfigTextBuffer(fn.Buffer)
Expand Down
4 changes: 2 additions & 2 deletions code/symbolspanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func SelectSymbol(cv *Code, ssym syms.Symbol) {
func (sv *SymbolsPanel) OpenPackage() {
cv := sv.Code
tv := cv.ActiveTextEditor()
if sv.Syms == nil || tv == nil || tv.Buffer == nil || !tv.Buffer.Hi.UsingParse() {
if sv.Syms == nil || tv == nil || tv.Buffer == nil || !tv.Buffer.Highlighting.UsingParse() {
return
}
pfs := tv.Buffer.ParseState.Done()
Expand All @@ -214,7 +214,7 @@ func (sv *SymbolsPanel) OpenPackage() {
func (sv *SymbolsPanel) OpenFile() {
cv := sv.Code
tv := cv.ActiveTextEditor()
if sv.Syms == nil || tv == nil || tv.Buffer == nil || !tv.Buffer.Hi.UsingParse() {
if sv.Syms == nil || tv == nil || tv.Buffer == nil || !tv.Buffer.Highlighting.UsingParse() {
return
}
pfs := tv.Buffer.ParseState.Done()
Expand Down
2 changes: 1 addition & 1 deletion code/texteditors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

// ConfigTextBuffer configures the text buffer according to the settings.
func (cv *Code) ConfigTextBuffer(tb *texteditor.Buffer) {
tb.SetHiStyle(core.AppearanceSettings.HiStyle)
tb.SetHighlighting(core.AppearanceSettings.Highlighting)
tb.Options.EditorSettings = cv.Settings.Editor
tb.ConfigKnown()
if tb.Complete != nil {
Expand Down

0 comments on commit a6ce441

Please sign in to comment.