diff --git a/code/editor.go b/code/editor.go index a4a11ac9..9b779b29 100644 --- a/code/editor.go +++ b/code/editor.go @@ -48,7 +48,7 @@ func (cv *Code) LookupFun(data any, text string, posLine, posChar int) (ld compl log.Printf("LookupFun: data is nil not FileStates or is nil - can't lookup\n") return ld } - lp, err := parse.LangSupport.Properties(sfs.Sup) + lp, err := parse.LanguageSupport.Properties(sfs.Sup) if err != nil { log.Printf("LookupFun: %v\n", err) return ld diff --git a/code/files.go b/code/files.go index eef9e431..295af3a9 100644 --- a/code/files.go +++ b/code/files.go @@ -122,7 +122,7 @@ func (cv *Code) RunPostCmdsActiveView() bool { // uses MainLang to disambiguate if multiple languages associated with extension. func (cv *Code) RunPostCmdsFileNode(fn *filetree.Node) bool { lang := fn.Info.Known - if lopt, has := AvailableLangs[lang]; has { + if lopt, has := AvailableLanguages[lang]; has { if len(lopt.PostSaveCmds) > 0 { _, ptab := cv.Tabs().CurrentTab() cv.ExecCmdsFileNode(fn, lopt.PostSaveCmds) diff --git a/code/findpanel.go b/code/findpanel.go index 0eead652..5afa6bc8 100644 --- a/code/findpanel.go +++ b/code/findpanel.go @@ -47,7 +47,7 @@ type FindParams struct { Loc filetree.FindLoc // languages for files to search - Langs []fileinfo.Known + Languages []fileinfo.Known // history of finds FindHist []string @@ -159,7 +159,7 @@ func (fv *FindPanel) FindAction() { if !fv.CompileRegexp() { return } - fv.Code.Find(fp.Find, fp.Replace, fp.IgnoreCase, fp.Regexp, fp.Loc, fp.Langs) + fv.Code.Find(fp.Find, fp.Replace, fp.IgnoreCase, fp.Regexp, fp.Loc, fp.Languages) } // CheckValidRegexp returns false if using regexp and it is not valid @@ -503,8 +503,8 @@ func (fv *FindPanel) makeReplToolbar(p *tree.Plan) { w.SetText("Lang:").SetTooltip("Language(s) to restrict search / replace to") }) - tree.AddAt(p, "langs", func(w *core.InlineList) { - w.SetSlice(&fv.Params().Langs) + tree.AddAt(p, "languages", func(w *core.InlineList) { + w.SetSlice(&fv.Params().Languages) w.SetTooltip("Language(s) to restrict search / replace to") }) } diff --git a/code/langs.go b/code/languages.go similarity index 52% rename from code/langs.go rename to code/languages.go index be5f4369..0af0ce5f 100644 --- a/code/langs.go +++ b/code/languages.go @@ -21,21 +21,21 @@ type LangOpts struct { PostSaveCmds CmdNames } -// Langs is a map of language options -type Langs map[fileinfo.Known]*LangOpts +// Languages is a map of language options +type Languages map[fileinfo.Known]*LangOpts -// AvailableLangs is the current set of language options -- can be -// loaded / saved / edited with settings. This is set to StandardLangs at +// AvailableLanguages is the current set of language options -- can be +// loaded / saved / edited with settings. This is set to [StandardLanguages] at // startup. -var AvailableLangs Langs +var AvailableLanguages Languages func init() { - AvailableLangs.CopyFrom(StandardLangs) + AvailableLanguages.CopyFrom(StandardLanguages) } // Validate checks to make sure post save command names exist, issuing // warnings to log for those that don't -func (lt Langs) Validate() bool { +func (lt Languages) Validate() bool { ok := true for _, lr := range lt { for _, cmdnm := range lr.PostSaveCmds { @@ -48,42 +48,42 @@ func (lt Langs) Validate() bool { return ok } -// LangSettingsFilename is the name of the settings file in the app settings -// directory for saving / loading the default AvailableLangs languages list -var LangSettingsFilename = "lang-settings.toml" +// LanguageSettingsFilename is the name of the settings file in the app settings +// directory for saving / loading the default [AvailableLanguages] languages list +var LanguageSettingsFilename = "language-settings.toml" // Open opens languages from a toml-formatted file. -func (lt *Langs) Open(filename core.Filename) error { - *lt = make(Langs) // reset +func (lt *Languages) Open(filename core.Filename) error { + *lt = make(Languages) // reset return tomlx.Open(lt, string(filename)) } // Save saves languages to a toml-formatted file. -func (lt *Langs) Save(filename core.Filename) error { //types:add +func (lt *Languages) Save(filename core.Filename) error { //types:add return tomlx.Save(lt, string(filename)) } // OpenSettings opens the Langs from the app settings directory, -// using LangSettingsFilename. -func (lt *Langs) OpenSettings() error { //types:add +// using [LanguageSettingsFilename]. +func (lt *Languages) OpenSettings() error { //types:add pdir := core.TheApp.AppDataDir() - pnm := filepath.Join(pdir, LangSettingsFilename) - AvailableLangsChanged = false + pnm := filepath.Join(pdir, LanguageSettingsFilename) + AvailableLanguagesChanged = false return lt.Open(core.Filename(pnm)) } // SaveSettings saves the Langs to the app settings directory, -// using LangSettingsFilename. -func (lt *Langs) SaveSettings() error { //types:add +// using [LanguageSettingsFilename]. +func (lt *Languages) SaveSettings() error { //types:add pdir := core.TheApp.AppDataDir() - pnm := filepath.Join(pdir, LangSettingsFilename) - AvailableLangsChanged = false + pnm := filepath.Join(pdir, LanguageSettingsFilename) + AvailableLanguagesChanged = false return lt.Save(core.Filename(pnm)) } // CopyFrom copies languages from given other map -func (lt *Langs) CopyFrom(cp Langs) { - *lt = make(Langs, len(cp)) // reset +func (lt *Languages) CopyFrom(cp Languages) { + *lt = make(Languages, len(cp)) // reset for ky, val := range cp { (*lt)[ky] = val } @@ -91,23 +91,23 @@ func (lt *Langs) CopyFrom(cp Langs) { // RevertToStandard reverts this map to using the StdLangs that are compiled into // the program and have all the lastest standards. -func (lt *Langs) RevertToStandard() { //types:add - lt.CopyFrom(StandardLangs) - AvailableLangsChanged = true +func (lt *Languages) RevertToStandard() { //types:add + lt.CopyFrom(StandardLanguages) + AvailableLanguagesChanged = true } -// ViewStandard shows the standard langs that are compiled into the program and have +// ViewStandard shows the standard languages that are compiled into the program and have // all the lastest standards. Useful for comparing against custom lists. -func (lt *Langs) ViewStandard() { //types:add - LangsView(&StandardLangs) +func (lt *Languages) ViewStandard() { //types:add + LanguagesView(&StandardLanguages) } -// AvailableLangsChanged is used to update core.LangsView toolbars via +// AvailableLanguagesChanged is used to update core.LangsView toolbars via // following menu, toolbar properties update methods -- not accurate if editing any // other map but works for now.. -var AvailableLangsChanged = false +var AvailableLanguagesChanged = false -// StandardLangs is the original compiled-in set of standard language options. -var StandardLangs = Langs{ +// StandardLanguages is the original compiled-in set of standard language options. +var StandardLanguages = Languages{ fileinfo.Go: {CmdNames{"Go: Imports File"}}, } diff --git a/code/settings.go b/code/settings.go index c3bd0993..1ad45182 100644 --- a/code/settings.go +++ b/code/settings.go @@ -97,7 +97,7 @@ func (se *SettingsData) Save() error { return err } if se.SaveLangOpts { - AvailableLangs.SaveSettings() + AvailableLanguages.SaveSettings() } if se.SaveCmds { CustomCommands.SaveSettings() @@ -113,7 +113,7 @@ func (se *SettingsData) Open() error { return err } if se.SaveLangOpts { - AvailableLangs.OpenSettings() + AvailableLanguages.OpenSettings() } if se.SaveCmds { CustomCommands.OpenSettings() @@ -126,7 +126,7 @@ func (se *SettingsData) Open() error { // Apply settings updates things according with settings func (se *SettingsData) Apply() { //types:add MergeAvailableCmds() - AvailableLangs.Validate() + AvailableLanguages.Validate() se.ApplyEnvVars() } @@ -165,7 +165,7 @@ func (se *SettingsData) MakeToolbar(p *tree.Plan) { // language / data / file type. func (se *SettingsData) EditLangOpts() { //types:add se.SaveLangOpts = true - LangsView(&AvailableLangs) + LanguagesView(&AvailableLanguages) } // EditCmds opens the CmdsView editor to customize commands you can run. diff --git a/code/values.go b/code/values.go index 7891089f..6b260170 100644 --- a/code/values.go +++ b/code/values.go @@ -44,23 +44,23 @@ func DebugSettingsEditor(pf *cdebug.Params) *core.Form { return tv } -// LangsView opens a view of a languages options map -func LangsView(pt *Langs) { +// LanguagesView opens a view of a languages options map +func LanguagesView(pt *Languages) { if core.RecycleMainWindow(pt) { return } d := core.NewBody().SetTitle("Available Language Opts: add or modify entries to customize options for language / file types").SetData(pt) tv := core.NewKeyedList(d).SetMap(pt) - AvailableLangsChanged = false + AvailableLanguagesChanged = false tv.OnChange(func(e events.Event) { - AvailableLangsChanged = true + AvailableLanguagesChanged = true }) d.AddAppBar(func(p *tree.Plan) { tree.Add(p, func(w *core.FuncButton) { w.SetFunc(pt.SaveSettings). SetText("Save to settings").SetIcon(icons.Save).SetKey(keymap.Save). - FirstStyler(func(s *styles.Style) { s.SetEnabled(AvailableLangsChanged && pt == &AvailableLangs) }) + FirstStyler(func(s *styles.Style) { s.SetEnabled(AvailableLanguagesChanged && pt == &AvailableLanguages) }) }) tree.Add(p, func(w *core.FuncButton) { w.SetFunc(pt.Open).SetText("Open").SetIcon(icons.Open).SetKey(keymap.Open) @@ -74,12 +74,12 @@ func LangsView(pt *Langs) { tree.Add(p, func(w *core.FuncButton) { w.SetFunc(pt.ViewStandard).SetConfirm(true). SetText("View standard").SetIcon(icons.Visibility). - FirstStyler(func(s *styles.Style) { s.SetEnabled(pt != &StandardLangs) }) + FirstStyler(func(s *styles.Style) { s.SetEnabled(pt != &StandardLanguages) }) }) tree.Add(p, func(w *core.FuncButton) { w.SetFunc(pt.RevertToStandard).SetConfirm(true). SetText("Revert to standard").SetIcon(icons.DeviceReset). - FirstStyler(func(s *styles.Style) { s.SetEnabled(pt != &StandardLangs) }) + FirstStyler(func(s *styles.Style) { s.SetEnabled(pt != &StandardLanguages) }) }) }) d.RunWindow() diff --git a/code/views.go b/code/views.go index 18f0ee46..87743b33 100644 --- a/code/views.go +++ b/code/views.go @@ -30,7 +30,7 @@ func (cv *Code) ConfigFindButton(fb *core.FuncButton) *core.FuncButton { fb.Args[2].SetValue(cv.Settings.Find.IgnoreCase) fb.Args[3].SetValue(cv.Settings.Find.Regexp) fb.Args[4].SetValue(cv.Settings.Find.Loc) - fb.Args[5].SetValue(cv.Settings.Find.Langs) + fb.Args[5].SetValue(cv.Settings.Find.Languages) return fb } @@ -46,7 +46,7 @@ func (cv *Code) Find(find string, repl string, ignoreCase bool, regExp bool, loc } cv.Settings.Find.IgnoreCase = ignoreCase cv.Settings.Find.Regexp = regExp - cv.Settings.Find.Langs = langs + cv.Settings.Find.Languages = langs cv.Settings.Find.Loc = loc cv.Settings.Find.Find = find cv.Settings.Find.Replace = repl