- commit
- 0f199a60157acab309ef4137f534657de6fffdfc
- parent
- 9f59fd13428f87ffb12be79ac5a5400c8e173e38
- author
- Dami <dami.etoile@gmail.com>
- kind
- feat risk score 1.2 of 3, Jev's estimate
| M | docs/ | 1 | + |
| M | docs/ | 7 | ++++++ |
| M | internal/ | 6 | +++++ |
| M | internal/ | 35 | +++++++++++++++++++++++++++++- |
@@ -55,6 +55,7 @@ and as far down as they are.
5555 | Ctrl+Up, Ctrl+Down | The first or last row |5656 | Ctrl+Home, Ctrl+End | The first cell, the last |5757 | A click on the scrollbar, or dragging its thumb | Jumps there |58+| Ctrl+G, F5 | Goes to a row, or a cell such as `C5000000` |5859 | Ctrl+C | Copies the active cell |5960 6061 The rows come from the file a page (128 rows) at a time, in the@@ -140,6 +140,13 @@ its own ([Sharing a workbook](../terminal/ssh.md#sharing-a-workbook)).
140140 | Ctrl+Alt+Shift+0 to 9 | Run the macro with that shortcut ([Macros](../sheets/macros.md#running)) |141141 | Esc | Stop a macro while it runs (the mode indicator says CMD) |142142 143+## Linked sources144+145+On a [linked source's](../files/sources.md#the-tab) tab (`SOURCE`) the146+keys move and scroll as on a sheet, over every row of the source; Ctrl+G147+and F5 go to a row, the sort and filter keys order the rows the tab148+shows, and keys that would change cells say the tab is read-only.149+143150 ## Notebooks144151 145152 On a [notebook's](../nushell/notebooks.md#keys) tab, as in Jupyter:@@ -100,6 +100,12 @@ func TestSourceTab(t *testing.T) {
100100 if bar(m) != "2999" {101101 t.Errorf("formula bar %q", bar(m))102102 }103+ // Go to, a row or a cell as the tab numbers them.104+ press(t, m, "<ctrl+g>", "b2500", "<enter>")105+ pumpSources(t, m)106+ if name := strings.Fields(line(m, formulaLine))[0]; name != "B2500" || bar(m) != "East" { // row 2500 is the source's 2498th, counting from 0107+ t.Errorf("go to B2500: %q %q", name, bar(m))108+ }103109 // Typing doesn't edit.104110 press(t, m, "7", "<enter>")105111 if !m.sheet.IsSource() {@@ -4,6 +4,9 @@ import (
44 "fmt"55 "path/filepath"66 "slices"7+ "strconv"8+ "strings"9+ "unicode"710 811 tea "charm.land/bubbletea/v2"912 @@ -48,7 +51,7 @@ var sourceTakes = map[string]bool{
4851 "edit.copy": true, "data.sort_sheet_az": true, "data.sort_sheet_za": true, "data.sort_range_az": true,4952 "data.sort_range_za": true, "data.filter": true, "data.filter_column": true, "data.filter_remove": true,5053 "data.pivot": true, "data.frequency": true, "data.source_all": true, "data.source_reload": true,51- "data.link_source": true, "data.link": true,54+ "data.link_source": true, "data.link": true, "goto": true,5255 }5356 5457 // sourceCommand runs id on a source's tab, reporting whether it did:@@ -87,6 +90,9 @@ func (m *Model) sourceCommand(c *command) (tea.Cmd, bool) {
8790 return m.setSourceOrder(info, o), true8891 case "data.pivot", "data.frequency":8992 return m.sourcePivot(info, col, c.id == "data.frequency"), true93+ case "goto":94+ m.openText("Go to a row, or a cell such as C5000000:", "", (*Model).sourceGoto)95+ return nil, true9096 }9197 return nil, false9298 }@@ -238,3 +244,30 @@ func (m *Model) addSource(src sheet.LinkSource) {
238244 m.linkedHere(before)239245 m.note = "Linked " + filepath.Base(src.Path) + " as " + s.Name() + ": formulas read it as " + s.Name() + "[column]"240246 }247+248+// sourceGoto moves the active cell on a source's tab to where text249+// says: a row number, or a column's letters and a row number, as the250+// tab numbers its rows (the source's first row is 2).251+func (m *Model) sourceGoto(text string) tea.Cmd {252+ v := m.srcView()253+ if v == nil {254+ return nil255+ }256+ text = strings.ToUpper(strings.ReplaceAll(strings.TrimSpace(text), ",", ""))257+ letters := strings.TrimRightFunc(text, unicode.IsDigit)258+ row, err := strconv.ParseInt(text[len(letters):], 10, 64)259+ _, col := v.Active()260+ if letters != "" {261+ c, ok := sheet.ParseCol(letters)262+ if !ok {263+ err = strconv.ErrSyntax264+ }265+ col = c266+ }267+ if err != nil || row < 1 {268+ m.fail("Type a row, such as 5000000, or a cell, such as C5000000")269+ return nil270+ }271+ v.MoveTo(max(row-2, 0), col)272+ return nil273+}