Skip to content

Commit

Permalink
more renaming of lang to language
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoreilly committed Jul 14, 2024
1 parent 96e3b31 commit be6a6ee
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion code/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 51 in code/editor.go

View workflow job for this annotation

GitHub Actions / build

undefined: parse.LanguageSupport
if err != nil {
log.Printf("LookupFun: %v\n", err)
return ld
Expand Down
2 changes: 1 addition & 1 deletion code/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions code/findpanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
})
}
66 changes: 33 additions & 33 deletions code/langs.go → code/languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -48,66 +48,66 @@ 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
}
}

// 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"}},
}
8 changes: 4 additions & 4 deletions code/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (se *SettingsData) Save() error {
return err
}
if se.SaveLangOpts {
AvailableLangs.SaveSettings()
AvailableLanguages.SaveSettings()
}
if se.SaveCmds {
CustomCommands.SaveSettings()
Expand All @@ -113,7 +113,7 @@ func (se *SettingsData) Open() error {
return err
}
if se.SaveLangOpts {
AvailableLangs.OpenSettings()
AvailableLanguages.OpenSettings()
}
if se.SaveCmds {
CustomCommands.OpenSettings()
Expand All @@ -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()
}

Expand Down Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions code/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions code/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand Down

0 comments on commit be6a6ee

Please sign in to comment.