cat / 012
clone

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

cat/module-path
012 / internal / sheet / historyrecord.go
historyrecord.go 1.5K
1package sheet23import "slices"45// The before-images a step keeps of what it changes besides cells6// (record, in history.go), each taken the first time the step changes it.78// recordWidth saves column c's width before its first change in the open9// step.10func (s *Sheet) recordWidth(c int) {11 st := s.wb.hist.open12 if st == nil {13 return14 }15 k := colKey{s, c}16 if _, seen := st.widths[k]; !seen {17 st.widths[k] = s.widths[c]18 }19}2021// recordName saves the named range with key k before its first change in22// the open step.23func (w *Workbook) recordName(k string) {24 st := w.hist.open25 if st == nil {26 return27 }28 if _, seen := st.names[k]; !seen {29 st.names[k] = w.namePtr(k)30 }31}3233// recordCharts saves the sheet's charts before their first change in the34// open step. Charts are few, so the step keeps them all.35func (s *Sheet) recordCharts() {36 if st := s.wb.hist.open; st != nil {37 if _, seen := st.charts[s]; !seen {38 st.charts[s] = slices.Clone(s.charts)39 }40 }41}4243// recordSheets saves the sheet list before its first change in the open44// step, and has the step recalculate everything when it ends.45func (w *Workbook) recordSheets() {46 w.structural = true47 if st := w.hist.open; st != nil && st.sheets == nil {48 st.sheets = w.sheetList()49 }50}5152// recordSettings saves the workbook's settings before their first change53// in the open step.54func (w *Workbook) recordSettings() {55 if st := w.hist.open; st != nil && st.settings == nil {56 cur := w.settings57 st.settings = &cur58 }59}