summaryrefslogtreecommitdiff
path: root/docs/typ/cheatsheet.typ
blob: c4be1641e38301321317591517a565364814edd2 (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
// 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"), [#word("Exec") the word or selection: a builtin, else a shell line.],
  btn("B3"), [#word("Look"): open the file, address, directory or URL, else find the word's next place. Resting the pointer tints what #btn("B3") would take.],
  [sweep], [drag #btn("B2") or #btn("B3") to #word("Exec") or #word("Look") 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 #btn("B1") selection],
  chord("B1", "B3"), [paste over it],
  chord("B1", "B2", "B3"), [copy: cut, then paste back, #btn("B1") still down],
  chord("B2", "B1"), [#word("Exec") the word with the #btn("B1") selection as argument (#word("Grep") on a selected name)],
  chord("B2", "B3"), [cancel the sweep (#chord("B3", "B2") too)],
)
Over a program that takes the mouse, Shift swaps: #btn("B1", shift: true) selects, #btn("B2", shift: true) goes to the program.
One button: Alt/Option-click is #btn("B2"), Cmd/Super-click #btn("B3"), sweeps too (a terminal passes only Alt); Ctrl-click is a definition; a program that takes the mouse gets the plain click.

== Tags
#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]")
- #word("Del") over unsaved text refuses once; again discards. #word("Del") `j`: rows below.
- #word("Undo") #word("Redo") #word("Edit") #word("Mode") work typed anywhere. #doc("tags")

== #word("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 #word("Save"), #word("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")], [#word("Look"), #word("Exec") 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")], [back to the previous pane from any mode, with the kitty keyboard protocol or in the GUI; elsewhere a plain Esc],
  [#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"),
  key("SPC q"), word("Exit"),
)

== Terminals and commands
- #key("Ctrl-b"): raw (`$`) or normal. #word("Mode") cycles raw, normal, insert. #word("Filter"), #word("Tty+bash").
- #btn("B2") on a non-builtin line runs it in a *command pane*: #tag("Kill Save Collapse Del", path: "/home/me/src (make) exit 0")
- #word("Kill") `make` stops it; #word("Exit") quits. #word("Repl") `python`: `.py` clicks go to it.

== Reviewing diffs
`git diff` output is a diff: #btn("B3") on a file line, an `@@` or a line's `+`/`-` jumps there. #doc("tags", section: "reviewing-diffs")

== Finding things
- #word("Find") `name`, #word("Grep") `text` (literal): a `+Search` listing. #word("Recent"): files lately. #word("Help"), #word("Tutor").

== Sessions
`pardes --detach=work`; `--attach=work` or #word("Attach") `work`; #word("Detach") leaves it running. #doc("detached")

== Config
#word("Config") (#key("SPC f c")): `~/.config/pardes/init`, a builtin a line (#word("Theme") `atelier`). #word("DumpConfig"): every setting. #word("Dump") / #word("Restore"): the workspace. #doc("config")

== Themes
#word("Themes") lists them; #word("Theme") `name`; #word("NextColor"); #word("ThemeFile") `x.zon`. #doc("themes")

== The virtual filesystem (9P)
Pane shells get `$PARDES_9P` (the socket) and `$PARDES_PANE` (their own pane); a command clicked in a pane also gets `$winid`, the pane it was clicked in.
#cmd("9ns --mntgen   # then m=$PARDES_MOUNT in every pane")
#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: #word("Save"), #word("Edit") `...`],
  file("pane/N/body tag"), [its text (`>>` appends)],
)
#cmd("echo notes.txt:12 > $m/pane/$n/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` opens it here; `EDITOR='pardes --wait'`. #doc("fs")