diff --git a/goal/builtins.go b/goal/builtins.go index 8f3abd0..dc57014 100644 --- a/goal/builtins.go +++ b/goal/builtins.go @@ -84,7 +84,7 @@ func (gl *Goal) Set(cmdIO *exec.CmdIO, args ...string) error { } val := args[1] if strings.Count(val, ":") > 1 || strings.Contains(val, "~") { - vl := stringsx.DedupeList(strings.Split(val, ":")) + vl := stringsx.UniqueList(strings.Split(val, ":")) vl = AddHomeExpand([]string{}, vl...) val = strings.Join(vl, ":") } @@ -175,7 +175,7 @@ func (gl *Goal) AddPath(cmdIO *exec.CmdIO, args ...string) error { } path := os.Getenv("PATH") ps := strings.Split(path, ":") - ps = stringsx.DedupeList(ps) + ps = stringsx.UniqueList(ps) ps = AddHomeExpand(ps, args...) path = strings.Join(ps, ":") err := os.Setenv("PATH", path) diff --git a/lab/filetree.go b/lab/filetree.go index 232f586..3ded3b0 100644 --- a/lab/filetree.go +++ b/lab/filetree.go @@ -144,12 +144,12 @@ func (fn *FileNode) OpenFile() error { case fn.IsDir(): d := TensorFS(ofn) dt := tensorfs.DirTable(d, nil) - ts.TensorTable(df, dt) + ts.AsLab().TensorTable(df, dt) case fn.Info.Cat == fileinfo.Data: switch fn.Info.Known { case fileinfo.Tensor: d := TensorFS(ofn) - ts.TensorEditor(df, d.Tensor) + ts.AsLab().TensorEditor(df, d.Tensor) case fileinfo.Number: dv := TensorFS(ofn) v := dv.Tensor.Float1D(0) @@ -183,7 +183,7 @@ func (fn *FileNode) OpenFile() error { if err != nil { core.ErrorSnackbar(fn, err) } else { - ts.TensorTable(df, dt) + ts.AsLab().TensorTable(df, dt) } } case fn.IsExec(): // todo: use exec? @@ -203,7 +203,7 @@ func (fn *FileNode) OpenFile() error { case fn.Info.Cat == fileinfo.Archive || fn.Info.Cat == fileinfo.Backup: // don't edit fn.OpenFilesDefault() default: - ts.EditorString(df, string(fn.Filepath)) + ts.AsLab().EditorString(df, string(fn.Filepath)) } return nil } @@ -230,7 +230,7 @@ func (fn *FileNode) EditFile() { return } df := fsx.DirAndFile(string(fn.Filepath)) - ts.EditorString(df, string(fn.Filepath)) + ts.AsLab().EditorString(df, string(fn.Filepath)) } // PlotFiles calls PlotFile on selected files @@ -250,7 +250,7 @@ func (fn *FileNode) PlotFile() { } d := TensorFS(fn.AsNode()) if d != nil { - ts.PlotTensorFS(d) + ts.AsLab().PlotTensorFS(d) return } if fn.Info.Cat != fileinfo.Data { @@ -264,7 +264,7 @@ func (fn *FileNode) PlotFile() { core.ErrorSnackbar(fn, err) return } - ts.PlotTable(ptab, dt) + ts.AsLab().PlotTable(ptab, dt) } // DiffDirs displays a browser with differences between two selected directories diff --git a/lab/tabs.go b/lab/tabs.go index db56a7a..7024f17 100644 --- a/lab/tabs.go +++ b/lab/tabs.go @@ -27,47 +27,8 @@ var CurTabber Tabber type Tabber interface { core.Tabber - // AsDataTabs returns the underlying [databrowser.Tabs] widget. - AsDataTabs() *Tabs - - // TensorTable recycles a tab with a [tensorcore.Table] widget - // to view given [table.Table], using its own table.Table. - TensorTable(label string, dt *table.Table) *tensorcore.Table - - // TensorEditor recycles a tab with a [tensorcore.TensorEditor] widget - // to view given Tensor. - TensorEditor(label string, tsr tensor.Tensor) *tensorcore.TensorEditor - - // TensorGrid recycles a tab with a [tensorcore.TensorGrid] widget - // to view given Tensor. - TensorGrid(label string, tsr tensor.Tensor) *tensorcore.TensorGrid - - // PlotTable recycles a tab with a Plot of given [table.Table]. - PlotTable(label string, dt *table.Table) *plotcore.PlotEditor - - // PlotTensorFS recycles a tab with a Plot of given [tensorfs.Node], - // automatically using the Dir/File name of the data node for the label. - PlotTensorFS(dfs *tensorfs.Node) *plotcore.PlotEditor - - // GoUpdatePlot calls GoUpdatePlot on plot at tab with given name. - // Does nothing if tab name doesn't exist (returns nil). - GoUpdatePlot(label string) *plotcore.PlotEditor - - // UpdatePlot calls UpdatePlot on plot at tab with given name. - // Does nothing if tab name doesn't exist (returns nil). - UpdatePlot(label string) *plotcore.PlotEditor - - // todo: PlotData of plot.Node - - // SliceTable recycles a tab with a [core.Table] widget - // to view the given slice of structs. - SliceTable(label string, slc any) *core.Table - - // EditorString recycles a [texteditor.Editor] tab, displaying given string. - EditorString(label, content string) *texteditor.Editor - - // EditorFile opens an editor tab for given file. - EditorFile(label, filename string) *texteditor.Editor + // AsLab returns the [lab.Tabs] widget with all the tabs methods. + AsLab() *Tabs } // NewTab recycles a tab with given label, or returns the existing one @@ -76,7 +37,7 @@ type Tabber interface { // mkfun function is called to create and configure a new widget // if not already existing. func NewTab[T any](tb Tabber, label string, mkfun func(tab *core.Frame) T) T { - tab := tb.RecycleTab(label) + tab := tb.AsLab().RecycleTab(label) var zv T if tab.HasChildren() { nc := tab.NumChildren() @@ -85,7 +46,7 @@ func NewTab[T any](tb Tabber, label string, mkfun func(tab *core.Frame) T) T { return tt } err := fmt.Errorf("Name / Type conflict: tab %q does not have the expected type of content: is %T", label, lc) - core.ErrorSnackbar(tb.AsDataTabs(), err) + core.ErrorSnackbar(tb.AsLab(), err) return zv } w := mkfun(tab) @@ -95,7 +56,7 @@ func NewTab[T any](tb Tabber, label string, mkfun func(tab *core.Frame) T) T { // TabAt returns widget of given type at tab of given name, nil if tab not found. func TabAt[T any](tb Tabber, label string) T { var zv T - tab := tb.TabByName(label) + tab := tb.AsLab().TabByName(label) if tab == nil { return zv } @@ -109,7 +70,7 @@ func TabAt[T any](tb Tabber, label string) T { } err := fmt.Errorf("Name / Type conflict: tab %q does not have the expected type of content: %T", label, lc) - core.ErrorSnackbar(tb.AsDataTabs(), err) + core.ErrorSnackbar(tb.AsLab(), err) return zv } @@ -123,7 +84,7 @@ func (ts *Tabs) Init() { ts.Type = core.FunctionalTabs } -func (ts *Tabs) AsDataTabs() *Tabs { +func (ts *Tabs) AsLab() *Tabs { return ts }