summaryrefslogtreecommitdiff
path: root/docs/typ/cheatsheet.typ
blob: a9152709d2a02a41c8b637f18b3732a68ac50963 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// The pardes cheatsheet: the facts only, an index into the docs, not a copy.
// cheatsheet-a4.typ lays it out; style.typ says how each element looks.
// config.zig's "docs/typ" test checks every #word, #key and #tag here
// against the registry, the keymap and the default tags.
#import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs

== The mouse
#pairs(
  btn("B1"), [select, and focus the pane. On a tag: type there.],
  btn("B2"), [*execute* the word or selection: a builtin, else a shell line.],
  btn("B3"), [*look*: open the file, address, directory or URL, else find the word's next place. Resting the pointer tints what B3 would take.],
  [sweep], [drag B2 or B3 to run or look at exactly what you swept.],
  [grip], [drag the box left of a tag: up/down resizes, onto another column moves the pane. A column's right edge drags its width.],
)
=== Chords: hold the first, click the next
#pairs(
  chord("B1", "B2"), [cut the B1 selection],
  chord("B1", "B3"), [paste over it],
  chord("B1", "B2", "B3"), [copy: cut, then paste back, B1 still down],
  chord("B2", "B1"), [execute the word with the B1 selection as argument (#word("Grep") on a selected name)],
  chord("B2", "B3"), [cancel the sweep (#chord("B3", "B2") too)],
)
A program that takes the mouse (htop, vim `mouse=a`) gets #btn("B1") and the wheel; #btn("B2")#btn("B3") stay pardes's. Hold Shift to swap: #btn("B1", shift: true) selects, #btn("B2", shift: true) goes to the program.

== Tags
Three levels of command text, every word live: the workspace tag, a tag per column, a tag per pane (file, terminal, PDF).
#tag("Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit")
#tag("New Tty Find Grep Joincol Delcol")
#tag("Save Tty Collapse Del", path: "/home/me/notes.txt")
#tag("Tty+bash Save Mode Filter Collapse Del", path: "/home/me/src")
#tag("Tty PdfSections PdfTint Collapse Del", path: "manual.pdf [1/12]")
- Type anything into a tag and click it: tags are text, with undo.
- A pane's words run in its directory; workspace and column tags in the session's.
- #word("Del") closes, rows to the pane above (`Del j`: below); #key("SPC d") asks #key("k") or #key("j"). Unsaved text (marked on the grip) is refused once: #word("Del") again discards.
- #word("Collapse") folds a pane to its tag; again unfolds.
- Click the path to rename (Enter confirms); #word("Save") writes.
- #word("Undo") #word("Redo") #word("Edit") #word("Mode") work typed anywhere.
- New panes: #word("Placement") `acme` (default) or `pardes`. #doc("tags")

== Look addresses
Typed anywhere, then #btn("B3") or #key("Enter"):
#pairs(
  addr("file:12"), [line 12],
  addr("file:12:5"), [line 12, byte column 5],
  addr("file:/re/"), [next match after the selection (`file:0/re/`: first)],
  addr(":40"), [the pane looked from, line 40 (`:40:5`, any address after `:`)],
  addr("~/x"), [home; also in `Save`, `Restore`, `pardes ~/x`],
  addr("@p3:12"), [pane 3 by serial, a terminal's lines too],
  addr("src/"), [a directory: `ls` in an idle terminal there, else a new one],
)
Addresses are sam's: `#n`, `/re/`, `?re?`, `$`, `a,b`. #doc("fs", section: "look-and-exec")

== Keys: normal mode
Helix-style: motions *select*, then an edit acts on the selection. Mode box: blank normal, `^` insert, `$` raw terminal.
#pairs(
  [#keys("h", "j", "k", "l") #keys("w", "b", "e")], [move; words select],
  [#keys("g g", "g e")], [first line, last line],
  [#keys("g h", "g l", "^")], [line start, end, first non-blank],
  [#keys("x", "v", "%")], [line, character select, all],
  [#key(";")], [collapse to the cursor],
  [#keys("d", "c", "y")], [delete, change, yank],
  [#keys("p", "P", "R")], [paste after, before, replace],
  [#keys("u", "U")], [undo, redo],
  [#keys("i", "a", "I", "A", "o", "O")], [insert; #key("Esc") back to normal],
  [#keys("s", "S")], [regex: a cursor per match, split],
  [#keys("C", ",")], [cursor on next line; keep primary],
  [#keys("/", "n", "N")], [search, next, previous],
  [#keys("m i", "m m")], [textobject, matching bracket],
  [#key("|")], [pipe each selection through the shell],
  [#keys("g d", "g r")], [definition, references (language server)],
  [#keys("Ctrl-d", "Ctrl-u")], [half page down, up],
  [#keys("Enter", "Tab")], [look, execute the selection (like #btn("B3") #btn("B2"))],
  [#key(":")], [to the pane's tag and back],
)
#doc("keys")

== Keys: panes
#pairs(
  [#key("Ctrl-w") #keys("h", "j", "k", "l")], [then a direction: focus a neighbour (not in insert or raw `$`)],
  [#key("Esc")], [back to the previous pane (raw: only at a prompt with nothing typed; insert: to normal)],
  [#key("Shift-Esc")], [As Esc, but always back to the previous pane from raw `$` or a PDF, and into raw from a terminal's normal or insert mode.],
  [#keys("Ctrl-o", "Ctrl-i")], [jump history back, forward],
  [#key("Alt-n")], [new terminal below],
  [#key("Alt-c")], [move the pane to a new column],
)

== The leader: #key("SPC") in normal mode
#pairs(split: 2,
  key("SPC ?"), [every path],
  key("SPC f s"), word("Save"),
  key("SPC f n"), word("New"),
  key("SPC f f"), word("Find"),
  key("SPC f g"), word("Grep"),
  key("SPC f r"), word("Recent"),
  key("SPC f c"), word("Config"),
  key("SPC d"), word("Del"),
  key("SPC n t"), word("Tty"),
  key("SPC n 9"), word("Tty9p"),
  key("SPC w h"), [focus left],
  key("SPC j j"), word("Last"),
  key("SPC j l"), word("Jumplist"),
  key("SPC y"), [clip yank],
  key("SPC p"), [clip paste],
  key("SPC t t"), word("Themes"),
  key("SPC t n"), word("NextColor"),
  key("SPC t w"), word("Wrap"),
  key("SPC c n"), word("Newcol"),
  key("SPC c p"), word("Placement"),
  key("SPC s d"), word("Dump"),
  key("SPC s r"), word("Restore"),
  key("SPC s a"), word("Attach"),
  key("SPC s D"), word("Detach"),
  key("SPC h t"), word("Tutor"),
  key("SPC h m"), word("Messages"),
)

== Terminals and commands
- A terminal is a pane. #key("Ctrl-b") switches it between raw (`$`) and normal mode, where the same keys move over its text, prompts hidden.
- Raw: keys go to the program; #key("Esc") at a prompt with nothing typed goes back to the previous pane, #key("Shift-Esc") always.
- #word("Mode") cycles raw, normal, insert. #word("Filter") maps its colours to the theme. #word("Tty+bash") opens another on that shell.
- #btn("B2") on any non-builtin line (`make`, `git log`) runs it with #word("Shell") `-c` in the pane's directory, in a *command pane*: #tag("Kill Save Collapse Del", path: "/home/me/src (make) exit 0")
- #word("Kill") stops what pardes started (`Kill make`: those lines); #word("Exit") quits.
- `Repl python` in a terminal tag: clicks in a `.py` pane go to it.

== Reviewing diffs
Run `git diff` (or open a `.patch`): it shows as a coloured diff. #btn("B3") on a `diff --git`, `---` or `+++` line opens the file; on `@@` the hunk's new line; on a hunk line's `+`/`-`/space, that line in the new file. #doc("tags", section: "reviewing-diffs")

== Finding things
- #word("Find") `name`: files below this pane's directory; #word("Grep") `text`: lines holding it, literally, under every pane's directory. Bare, they ask; results land in `+Search`, a place per line for #btn("B3").
- #word("Recent"): files opened lately, closed ones too, each reopened where you left it.
- #word("Help"): every key and builtin. #word("Tutor"): the tutorial.

== Sessions
- `pardes --detach=work` runs a core with no screen; `pardes --attach=work` (or #word("Attach") `work`) shows it; #word("Detach") leaves it running, shells and all. #doc("detached")

== Config
- #word("Config") (#key("SPC f c")) opens `~/.config/pardes/init`; a line per builtin, run at start; `#` comments.
```
Theme atelier
Shell zsh
Placement pardes
```
- #word("DumpConfig"): every live setting as a word to click; it pastes back into `init` as is.
- Keys are compile-time, in `src/config.zig`.
- #word("Dump") / #word("Restore"): save and reload the workspace (`pardes -l dump.zon`). #doc("config")

== Themes
#word("Themes") lists them, a word each; #word("Theme") `name` sets one; #word("NextColor") walks the ring. `orchard` is the default, `atelier` this page's. #word("DumpThemes") writes them as `.zon`; #word("ThemeFile") `x.zon` loads one, live on save. #doc("themes")

== 9P control filesystem
Every session serves its panes as files. Pane shells get `$PARDES_9P` (socket), `$PARDES_PANE` (serial).
#cmd("9ns --mntgen   # m=$NINE_MOUNT/pardes/<pid|name>")
#cmd("9p -a \"unix!$PARDES_9P\" read index")
#pairs(
  file("index"), [a line per pane: serial, kind, name],
  file("look exec"), [write a line: a #btn("B3") or #btn("B2")],
  file("log"), [events; write `follow` to wait],
  file("pane/new"), [open to make a pane],
  file("pane/N/addr"), [an address; `data` reads/replaces it],
  file("pane/N/ctl"), [builtins: `Save`, `Edit ...`],
  file("pane/N/body tag"), [its text (`>>` appends)],
)
#cmd("echo notes.txt:12 > $m/look")
#cmd("echo /foo/ > $m/pane/$n/addr; printf bar > $m/pane/$n/data")
#cmd("echo 'Edit ,x/foo/c/bar/' > $m/pane/$n/ctl")
#cmd("exec 3<>$m/log; echo follow >&3; cat <&3")
`pardes FILE` in a pane opens it here; `EDITOR='pardes --wait'` returns when its pane closes. `cat $m/README`. #doc("fs")