From c800d20c9d1ed895cb01d9464f36be6108979771 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Sat, 24 Aug 2024 23:45:46 -0700 Subject: [PATCH 1/2] core.Tabs.NewTab returns the tab, to allow for customization --- canvas/canvas.go | 6 +- clock/clock.go | 8 +- code/debugpanel.go | 17 +-- code/piv/piview.go | 2 +- numbers/cmd/numbers/numbers.go | 4 +- .../cogentcore_org-core-tensor-stats-simat.go | 1 + .../cogentcore_org-core-tensor-stats-split.go | 2 - .../cogentcore_org-core-tensor-stats-stats.go | 2 - .../cogentcore_org-core-tensor-tensorcore.go | 14 +-- numbers/imports/cogentcore_org-core-tensor.go | 104 +++++------------- 10 files changed, 53 insertions(+), 107 deletions(-) diff --git a/canvas/canvas.go b/canvas/canvas.go index 3ea71d9c..82e492e8 100644 --- a/canvas/canvas.go +++ b/canvas/canvas.go @@ -122,12 +122,12 @@ func (cv *Canvas) Init() { }) tree.AddChildAt(w, "tabs", func(w *core.Tabs) { w.SetType(core.FunctionalTabs) - pt := w.NewTab("Paint") + pt, _ := w.NewTab("Paint") NewPaintView(pt).SetCanvas(cv) - at := w.NewTab("Align") + at, _ := w.NewTab("Align") NewAlignView(at).SetCanvas(cv) cv.EditState.Text.Defaults() - tt := w.NewTab("Text") + tt, _ := w.NewTab("Text") core.NewForm(tt).SetStruct(&cv.EditState.Text) }) }) diff --git a/clock/clock.go b/clock/clock.go index 7bd4b7f6..ffdeaa50 100644 --- a/clock/clock.go +++ b/clock/clock.go @@ -26,7 +26,7 @@ func main() { } func clock(ts *core.Tabs) { - cl := ts.NewTab("Clock") + cl, _ := ts.NewTab("Clock") cl.Styler(func(s *styles.Style) { s.CenterAll() }) @@ -41,7 +41,7 @@ type timer struct { } func timers(ts *core.Tabs) { - tr := ts.NewTab("Timers") + tr, _ := ts.NewTab("Timers") trd := 15 * time.Minute trv := core.NewValue(&trd, "") tr.AddChild(trv) @@ -49,11 +49,11 @@ func timers(ts *core.Tabs) { } func stopwatches(ts *core.Tabs) { - sw := ts.NewTab("Stopwatches") + sw, _ := ts.NewTab("Stopwatches") core.NewButton(sw).SetText("Start") } func alarms(ts *core.Tabs) { - al := ts.NewTab("Alarms") + al, _ := ts.NewTab("Alarms") core.NewButton(al).SetText("Create") } diff --git a/code/debugpanel.go b/code/debugpanel.go index bbe63ba6..70f77e8e 100644 --- a/code/debugpanel.go +++ b/code/debugpanel.go @@ -137,7 +137,8 @@ func (dv *DebugPanel) InitTabs() { if w.NumTabs() > 0 { return } - ctv := texteditor.NewEditor(w.NewTab(DebugTabConsole)) + dtab, _ := w.NewTab(DebugTabConsole) + ctv := texteditor.NewEditor(dtab) ctv.SetName("dbg-console") ConfigOutputTextEditor(ctv) dv.State.BlankState() @@ -147,7 +148,7 @@ func (dv *DebugPanel) InitTabs() { dv.OutputBuffer.Options.LineNumbers = false ctv.SetBuffer(dv.OutputBuffer) - bv := w.NewTab(DebugTabBreaks) + bv, _ := w.NewTab(DebugTabBreaks) tree.AddChild(bv, func(w *core.Table) { w.SetSlice(&dv.State.Breaks) w.OnDoubleClick(func(e events.Event) { @@ -168,7 +169,7 @@ func (dv *DebugPanel) InitTabs() { }) }) - sv := w.NewTab(DebugTabStack) + sv, _ := w.NewTab(DebugTabStack) tree.AddChild(sv, func(w *core.Table) { w.SetReadOnly(true) w.SetSlice(&dv.State.Stack) @@ -181,7 +182,7 @@ func (dv *DebugPanel) InitTabs() { }) if dv.Known == fileinfo.Go { // dv.Dbg.HasTasks() { // todo: not avail here yet - tv := w.NewTab(DebugTabTasks) + tv, _ := w.NewTab(DebugTabTasks) tree.AddChild(tv, func(w *core.Table) { w.SetReadOnly(true) w.SetSlice(&dv.State.Tasks) @@ -199,7 +200,7 @@ func (dv *DebugPanel) InitTabs() { }) } - tv := w.NewTab(DebugTabThreads) + tv, _ := w.NewTab(DebugTabThreads) tree.AddChild(tv, func(w *core.Table) { w.SetReadOnly(true) w.SetSlice(&dv.State.Threads) @@ -216,7 +217,7 @@ func (dv *DebugPanel) InitTabs() { }) }) - vv := w.NewTab(DebugTabVars) + vv, _ := w.NewTab(DebugTabVars) tree.AddChild(vv, func(w *core.Table) { w.SetReadOnly(true) w.SetSlice(&dv.State.Vars) @@ -226,7 +227,7 @@ func (dv *DebugPanel) InitTabs() { }) }) - ff := w.NewTab(DebugTabFrames) + ff, _ := w.NewTab(DebugTabFrames) tree.AddChild(ff, func(w *core.Table) { w.SetReadOnly(true) w.SetSlice(&dv.State.FindFrames) @@ -239,7 +240,7 @@ func (dv *DebugPanel) InitTabs() { }) }) - gv := w.NewTab(DebugTabGlobals) + gv, _ := w.NewTab(DebugTabGlobals) tree.AddChild(gv, func(w *core.Table) { w.SetReadOnly(true) w.SetSlice(&dv.State.GlobalVars) diff --git a/code/piv/piview.go b/code/piv/piview.go index 6b406f05..90afe104 100644 --- a/code/piv/piview.go +++ b/code/piv/piview.go @@ -617,7 +617,7 @@ func (pv *PiView) RecycleMainTab(label string, typ reflect.Type, sel bool) core. } return widg } - widg = tv.NewTab(typ, label) + widg, _ = tv.NewTab(typ, label) if sel { tv.SelectTabByName(label) } diff --git a/numbers/cmd/numbers/numbers.go b/numbers/cmd/numbers/numbers.go index 811b5bcd..3fa5ce63 100644 --- a/numbers/cmd/numbers/numbers.go +++ b/numbers/cmd/numbers/numbers.go @@ -96,10 +96,10 @@ func Interactive(c *Config) error { ts := core.NewTabs(b) - db := ts.NewTab("Data browser") + db, _ := ts.NewTab("Data browser") core.NewText(db).SetType(core.TextTitleLarge).SetText("Use your terminal to enter data browser commands.") - rt := ts.NewTab("Random") + rt, _ := ts.NewTab("Random") tb := core.NewToolbar(rt) rd := random.NewRandom(rt) tb.Maker(rd.MakeToolbar) diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-simat.go b/numbers/imports/cogentcore_org-core-tensor-stats-simat.go index aa852801..209ca695 100644 --- a/numbers/imports/cogentcore_org-core-tensor-stats-simat.go +++ b/numbers/imports/cogentcore_org-core-tensor-stats-simat.go @@ -11,6 +11,7 @@ func init() { Symbols["cogentcore.org/core/tensor/stats/simat/simat"] = map[string]reflect.Value{ // function, constant and variable definitions "BlankRepeat": reflect.ValueOf(simat.BlankRepeat), + "NewSimMat": reflect.ValueOf(simat.NewSimMat), "Tensor": reflect.ValueOf(simat.Tensor), "TensorStd": reflect.ValueOf(simat.TensorStd), "Tensors": reflect.ValueOf(simat.Tensors), diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-split.go b/numbers/imports/cogentcore_org-core-tensor-stats-split.go index 69b33a07..781baf57 100644 --- a/numbers/imports/cogentcore_org-core-tensor-stats-split.go +++ b/numbers/imports/cogentcore_org-core-tensor-stats-split.go @@ -12,11 +12,9 @@ func init() { // function, constant and variable definitions "AggAllNumericCols": reflect.ValueOf(split.AggAllNumericCols), "AggColumn": reflect.ValueOf(split.AggColumn), - "AggColumnTry": reflect.ValueOf(split.AggColumnTry), "AggIndex": reflect.ValueOf(split.AggIndex), "All": reflect.ValueOf(split.All), "DescColumn": reflect.ValueOf(split.DescColumn), - "DescColumnTry": reflect.ValueOf(split.DescColumnTry), "DescIndex": reflect.ValueOf(split.DescIndex), "GroupBy": reflect.ValueOf(split.GroupBy), "GroupByFunc": reflect.ValueOf(split.GroupByFunc), diff --git a/numbers/imports/cogentcore_org-core-tensor-stats-stats.go b/numbers/imports/cogentcore_org-core-tensor-stats-stats.go index fbe6abfe..b1613632 100644 --- a/numbers/imports/cogentcore_org-core-tensor-stats-stats.go +++ b/numbers/imports/cogentcore_org-core-tensor-stats-stats.go @@ -21,7 +21,6 @@ func init() { "CountTensor": reflect.ValueOf(stats.CountTensor), "DescAll": reflect.ValueOf(stats.DescAll), "DescColumn": reflect.ValueOf(stats.DescColumn), - "DescColumnTry": reflect.ValueOf(stats.DescColumnTry), "DescIndex": reflect.ValueOf(stats.DescIndex), "DescStats": reflect.ValueOf(&stats.DescStats).Elem(), "DescStatsND": reflect.ValueOf(&stats.DescStatsND).Elem(), @@ -114,7 +113,6 @@ func init() { "Stat32": reflect.ValueOf(stats.Stat32), "Stat64": reflect.ValueOf(stats.Stat64), "StatColumn": reflect.ValueOf(stats.StatColumn), - "StatColumnTry": reflect.ValueOf(stats.StatColumnTry), "StatIndex": reflect.ValueOf(stats.StatIndex), "StatIndexFunc": reflect.ValueOf(stats.StatIndexFunc), "StatTensor": reflect.ValueOf(stats.StatTensor), diff --git a/numbers/imports/cogentcore_org-core-tensor-tensorcore.go b/numbers/imports/cogentcore_org-core-tensor-tensorcore.go index 3b7a030c..79a50b03 100644 --- a/numbers/imports/cogentcore_org-core-tensor-tensorcore.go +++ b/numbers/imports/cogentcore_org-core-tensor-tensorcore.go @@ -10,13 +10,13 @@ import ( func init() { Symbols["cogentcore.org/core/tensor/tensorcore/tensorcore"] = map[string]reflect.Value{ // function, constant and variable definitions - "LabelSpace": reflect.ValueOf(tensorcore.LabelSpace), - "NewSimMatButton": reflect.ValueOf(tensorcore.NewSimMatButton), - "NewSimMatGrid": reflect.ValueOf(tensorcore.NewSimMatGrid), - "NewTable": reflect.ValueOf(tensorcore.NewTable), - "NewTableButton": reflect.ValueOf(tensorcore.NewTableButton), - "NewTensorButton": reflect.ValueOf(tensorcore.NewTensorButton), - "NewTensorGrid": reflect.ValueOf(tensorcore.NewTensorGrid), + "LabelSpace": reflect.ValueOf(tensorcore.LabelSpace), + "NewSimMatButton": reflect.ValueOf(tensorcore.NewSimMatButton), + "NewSimMatGrid": reflect.ValueOf(tensorcore.NewSimMatGrid), + "NewTable": reflect.ValueOf(tensorcore.NewTable), + "NewTableButton": reflect.ValueOf(tensorcore.NewTableButton), + "NewTensorButton": reflect.ValueOf(tensorcore.NewTensorButton), + "NewTensorGrid": reflect.ValueOf(tensorcore.NewTensorGrid), // type definitions "SimMatButton": reflect.ValueOf((*tensorcore.SimMatButton)(nil)), diff --git a/numbers/imports/cogentcore_org-core-tensor.go b/numbers/imports/cogentcore_org-core-tensor.go index 75db309f..c7c42d73 100644 --- a/numbers/imports/cogentcore_org-core-tensor.go +++ b/numbers/imports/cogentcore_org-core-tensor.go @@ -95,120 +95,68 @@ type _cogentcore_org_core_tensor_Tensor struct { WT func() mat.Matrix } -func (W _cogentcore_org_core_tensor_Tensor) At(i int, j int) float64 { - return W.WAt(i, j) -} -func (W _cogentcore_org_core_tensor_Tensor) Clone() tensor.Tensor { - return W.WClone() -} +func (W _cogentcore_org_core_tensor_Tensor) At(i int, j int) float64 { return W.WAt(i, j) } +func (W _cogentcore_org_core_tensor_Tensor) Clone() tensor.Tensor { return W.WClone() } func (W _cogentcore_org_core_tensor_Tensor) CopyCellsFrom(from tensor.Tensor, to int, start int, n int) { W.WCopyCellsFrom(from, to, start, n) } -func (W _cogentcore_org_core_tensor_Tensor) CopyFrom(from tensor.Tensor) { - W.WCopyFrom(from) -} -func (W _cogentcore_org_core_tensor_Tensor) CopyMetaData(from tensor.Tensor) { - W.WCopyMetaData(from) -} -func (W _cogentcore_org_core_tensor_Tensor) CopyShapeFrom(from tensor.Tensor) { - W.WCopyShapeFrom(from) -} -func (W _cogentcore_org_core_tensor_Tensor) DataType() reflect.Kind { - return W.WDataType() -} -func (W _cogentcore_org_core_tensor_Tensor) DimSize(dim int) int { - return W.WDimSize(dim) -} -func (W _cogentcore_org_core_tensor_Tensor) Dims() (r int, c int) { - return W.WDims() -} -func (W _cogentcore_org_core_tensor_Tensor) Float(i []int) float64 { - return W.WFloat(i) -} -func (W _cogentcore_org_core_tensor_Tensor) Float1D(i int) float64 { - return W.WFloat1D(i) -} +func (W _cogentcore_org_core_tensor_Tensor) CopyFrom(from tensor.Tensor) { W.WCopyFrom(from) } +func (W _cogentcore_org_core_tensor_Tensor) CopyMetaData(from tensor.Tensor) { W.WCopyMetaData(from) } +func (W _cogentcore_org_core_tensor_Tensor) CopyShapeFrom(from tensor.Tensor) { W.WCopyShapeFrom(from) } +func (W _cogentcore_org_core_tensor_Tensor) DataType() reflect.Kind { return W.WDataType() } +func (W _cogentcore_org_core_tensor_Tensor) DimSize(dim int) int { return W.WDimSize(dim) } +func (W _cogentcore_org_core_tensor_Tensor) Dims() (r int, c int) { return W.WDims() } +func (W _cogentcore_org_core_tensor_Tensor) Float(i []int) float64 { return W.WFloat(i) } +func (W _cogentcore_org_core_tensor_Tensor) Float1D(i int) float64 { return W.WFloat1D(i) } func (W _cogentcore_org_core_tensor_Tensor) FloatRowCell(row int, cell int) float64 { return W.WFloatRowCell(row, cell) } -func (W _cogentcore_org_core_tensor_Tensor) Floats(flt *[]float64) { - W.WFloats(flt) -} -func (W _cogentcore_org_core_tensor_Tensor) IsString() bool { - return W.WIsString() -} -func (W _cogentcore_org_core_tensor_Tensor) Len() int { - return W.WLen() -} +func (W _cogentcore_org_core_tensor_Tensor) Floats(flt *[]float64) { W.WFloats(flt) } +func (W _cogentcore_org_core_tensor_Tensor) IsString() bool { return W.WIsString() } +func (W _cogentcore_org_core_tensor_Tensor) Len() int { return W.WLen() } func (W _cogentcore_org_core_tensor_Tensor) MetaData(key string) (string, bool) { return W.WMetaData(key) } -func (W _cogentcore_org_core_tensor_Tensor) MetaDataMap() map[string]string { - return W.WMetaDataMap() -} -func (W _cogentcore_org_core_tensor_Tensor) NumDims() int { - return W.WNumDims() -} +func (W _cogentcore_org_core_tensor_Tensor) MetaDataMap() map[string]string { return W.WMetaDataMap() } +func (W _cogentcore_org_core_tensor_Tensor) NumDims() int { return W.WNumDims() } func (W _cogentcore_org_core_tensor_Tensor) Range() (min float64, max float64, minIndex int, maxIndex int) { return W.WRange() } func (W _cogentcore_org_core_tensor_Tensor) RowCellSize() (rows int, cells int) { return W.WRowCellSize() } -func (W _cogentcore_org_core_tensor_Tensor) SetFloat(i []int, val float64) { - W.WSetFloat(i, val) -} -func (W _cogentcore_org_core_tensor_Tensor) SetFloat1D(i int, val float64) { - W.WSetFloat1D(i, val) -} +func (W _cogentcore_org_core_tensor_Tensor) SetFloat(i []int, val float64) { W.WSetFloat(i, val) } +func (W _cogentcore_org_core_tensor_Tensor) SetFloat1D(i int, val float64) { W.WSetFloat1D(i, val) } func (W _cogentcore_org_core_tensor_Tensor) SetFloatRowCell(row int, cell int, val float64) { W.WSetFloatRowCell(row, cell, val) } -func (W _cogentcore_org_core_tensor_Tensor) SetFloats(vals []float64) { - W.WSetFloats(vals) -} +func (W _cogentcore_org_core_tensor_Tensor) SetFloats(vals []float64) { W.WSetFloats(vals) } func (W _cogentcore_org_core_tensor_Tensor) SetMetaData(key string, val string) { W.WSetMetaData(key, val) } -func (W _cogentcore_org_core_tensor_Tensor) SetNumRows(rows int) { - W.WSetNumRows(rows) -} +func (W _cogentcore_org_core_tensor_Tensor) SetNumRows(rows int) { W.WSetNumRows(rows) } func (W _cogentcore_org_core_tensor_Tensor) SetShape(sizes []int, names ...string) { W.WSetShape(sizes, names...) } -func (W _cogentcore_org_core_tensor_Tensor) SetString(i []int, val string) { - W.WSetString(i, val) -} -func (W _cogentcore_org_core_tensor_Tensor) SetString1D(i int, val string) { - W.WSetString1D(i, val) -} +func (W _cogentcore_org_core_tensor_Tensor) SetString(i []int, val string) { W.WSetString(i, val) } +func (W _cogentcore_org_core_tensor_Tensor) SetString1D(i int, val string) { W.WSetString1D(i, val) } func (W _cogentcore_org_core_tensor_Tensor) SetStringRowCell(row int, cell int, val string) { W.WSetStringRowCell(row, cell, val) } -func (W _cogentcore_org_core_tensor_Tensor) SetZeros() { - W.WSetZeros() -} -func (W _cogentcore_org_core_tensor_Tensor) Shape() *tensor.Shape { - return W.WShape() -} +func (W _cogentcore_org_core_tensor_Tensor) SetZeros() { W.WSetZeros() } +func (W _cogentcore_org_core_tensor_Tensor) Shape() *tensor.Shape { return W.WShape() } func (W _cogentcore_org_core_tensor_Tensor) String() string { if W.WString == nil { return "" } return W.WString() } -func (W _cogentcore_org_core_tensor_Tensor) String1D(i int) string { - return W.WString1D(i) -} +func (W _cogentcore_org_core_tensor_Tensor) String1D(i int) string { return W.WString1D(i) } func (W _cogentcore_org_core_tensor_Tensor) StringRowCell(row int, cell int) string { return W.WStringRowCell(row, cell) } -func (W _cogentcore_org_core_tensor_Tensor) StringValue(i []int) string { - return W.WStringValue(i) -} +func (W _cogentcore_org_core_tensor_Tensor) StringValue(i []int) string { return W.WStringValue(i) } func (W _cogentcore_org_core_tensor_Tensor) SubSpace(offs []int) tensor.Tensor { return W.WSubSpace(offs) } -func (W _cogentcore_org_core_tensor_Tensor) T() mat.Matrix { - return W.WT() -} +func (W _cogentcore_org_core_tensor_Tensor) T() mat.Matrix { return W.WT() } From 02d95dbf645edc4b23cf3240efb8aab1ff883fca Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Sun, 25 Aug 2024 11:47:48 -0700 Subject: [PATCH 2/2] update go.mod --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9e729017..f6004883 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module cogentcore.org/cogent go 1.22 require ( - cogentcore.org/core v0.3.3-0.20240822231726-6385e4c9fc1f + cogentcore.org/core v0.3.3-0.20240825182959-fe4840922a21 github.com/aandrew-me/tgpt/v2 v2.7.2 github.com/alecthomas/chroma/v2 v2.13.0 github.com/bogdanfinn/fhttp v0.5.27 diff --git a/go.sum b/go.sum index 1cedca7e..9b2e525e 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -cogentcore.org/core v0.3.3-0.20240822231726-6385e4c9fc1f h1:ia/D6kJ5nhFzyYyRZHe7LmXTPpIh+dDO+Jm8GQzUmGQ= -cogentcore.org/core v0.3.3-0.20240822231726-6385e4c9fc1f/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4= +cogentcore.org/core v0.3.3-0.20240825182959-fe4840922a21 h1:tffR0tewNHVE36GpZE7ZjTSE4KYoRfbdeL9btV8UmbU= +cogentcore.org/core v0.3.3-0.20240825182959-fe4840922a21/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4= github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4 h1:6lx9xzJAhdjq0LvVfbITeC3IH9Fzvo1aBahyPu2FuG8= github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4/go.mod h1:FChzXi1izqzdPb6BiNZmcZLGyTYiT61iGx9Rxx9GNeI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=