cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

Note rule edits in macro recordings, and list Clear conditional formats

Dami committed a26fb6b
Rules edited, removed or moved in the panel have no command a macro
could replay, so a recording notes them as comments, as dialogs are.
Format > Clear conditional formats sits beside Conditional formatting.
commit
a26fb6bba29ac5f301feaef9a85c4b854e334d09
parent
c1ab15fa2e7c81c58a1f613e70b970da4a1ed46d
author
Dami <dami.etoile@gmail.com>
6 files changed, +41 -11
Minternal/ui/hosts.go2++
Minternal/ui/menubar.go2+-
Minternal/ui/rules.go20++++++++++++++++++++
Minternal/ui/rules/editor.go9+++++----
Minternal/ui/rules/editor_test.go2+-
Minternal/ui/rules_test.go17++++++++++++-----
M internal/ui/hosts.go +2 -0
M internal/ui/menubar.go +1 -1
M internal/ui/rules.go +20 -0
M internal/ui/rules/editor.go +5 -4
M internal/ui/rules/editor_test.go +1 -1
M internal/ui/rules_test.go +12 -5
@@ -46,13 +46,16 @@ func TestConditionalFormattingPanel(t *testing.T) {
4646 }4747 // A2 is drawn on the green fill, A1 isn't.4848 sp := rowtext.Span{Text: "150", Owner: 0}49- base, colored, _ := m.ruleSpan(addr("A2"), &sp, m.th.Cell, false, m.slotColor)50- if !colored || base.GetBackground() != m.th.RuleFill[sheet.ColorGreen].GetBackground() {51- t.Errorf("A2 base %v colored %v", base.GetBackground(), colored)49+ _, shade, shaded := m.ruleSpan(addr("A2"), &sp, false, m.slotColor)50+ if !shaded || shade.Style.GetBackground() != m.th.RuleFill[sheet.ColorGreen].GetBackground() {51+ t.Errorf("A2 shade %v shaded %v", shade.Style.GetBackground(), shaded)5252 }53- if _, colored, _ := m.ruleSpan(addr("A1"), &sp, m.th.Cell, false, m.slotColor); colored {53+ if _, _, shaded := m.ruleSpan(addr("A1"), &sp, false, m.slotColor); shaded {5454 t.Error("A1 formatted")5555 }56+ if _, _, shaded := m.ruleSpan(addr("A2"), &sp, true, m.slotColor); shaded {57+ t.Error("the pointer's colors gave way to a rule's")58+ }5659 press(t, m, "<ctrl+z>")5760 if len(m.sheet.CondFormats()) != 0 {5861 t.Error("undo kept the rule")
@@ -158,6 +161,7 @@ func TestRuleMacros(t *testing.T) {
158161 press(t, m, "<shift+down>")159162 src := recordRules(t, m)160163 for _, want := range []string{`run("format.conditional_add", answer="{\"ranges\":\"A1:A2\",\"condition\":\"not_empty\",\"fill\":\"green\"}")`,164+ `# Not recorded: remove conditional format A1:A2`,161165 `run("insert.checkbox")`, `run("data.validation_add", answer="{\"ranges\":\"C1:C2\",\"criteria\":\"list\",\"items\":[\"a\",\"b\"]}")`} {162166 if !strings.Contains(src, want) {163167 t.Errorf("script lacks %s:\n%s", want, src)
@@ -165,7 +169,7 @@ func TestRuleMacros(t *testing.T) {
165169 }166170 fresh := newModel()167171 script(t, fresh, src)168- if len(fresh.sheet.CondFormats()) != 1 || len(fresh.sheet.Validations()) != 2 {172+ if len(fresh.sheet.CondFormats()) != 2 || len(fresh.sheet.Validations()) != 2 { // the removal is only noted169173 t.Errorf("replay: %+v %+v %q", fresh.sheet.CondFormats(), fresh.sheet.Validations(), fresh.warn)170174 }171175 }
@@ -177,6 +181,9 @@ func recordRules(t *testing.T, m *Model) string {
177181 send(m, nil)178182 run(m, m.runCommand("macro.record"))179183 run(m, m.runCommand("format.conditional"))184+ press(t, m, "<enter>", "<enter>") // add the rule the form starts with185+ press(t, m, "<down>", "<delete>", "<esc>") // removed, and noted186+ run(m, m.runCommand("format.conditional"))180187 press(t, m, "<enter>", "<enter>", "<esc>", "<right>")181188 run(m, m.runCommand("insert.checkbox"))182189 press(t, m, "<right>")