summaryrefslogtreecommitdiff
path: root/docs/next-winmode.md
blob: c2a01da8c83b8a640c5148407c1b6d53c8655aef (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
# winmode: d and c in window mode, the Del question as a hint

> The window mode should have d for deleting and c for collapsing too, the
> deletion should keep that j/k movement. The current spc d j/k should only
> show the message after a timeout so that a user that does this fast won't
> even see it, it will be more like a hint for users that tried to delete
> and nothing happenend.

## As built

- `layout.windowKey`: `c` runs `Collapse` on the outlined pane; `d` makes
  the outlined pane active and runs `Del` on it, exactly the keyboard Del
  (`can_ask` is set: it is a key). With panes above and below, Del asks
  and the next key is its answer (`Pardes.answerQuestion`, which already
  runs before window mode sees keys); with one neighbour it closes at once.
  Either way, once the pane is gone the outline moves to `p.active`, which
  `removePane` already sets to the pane that grew into the rows. The mode
  stays on: `Ctrl-w d j d` closes two panes. A refused Del (unsaved text)
  leaves the outline where it is, the refusal on the message row.
- Keys: `config.window_delete` (`d`) and `config.window_collapse` (`c`),
  apart from `window_keys`, because those are also the header walk under
  `Ctrl-w` on a tag, where `d`/`c` mean nothing.
- Labels: `layout.window_labels` loses `d` and `c` (22 -> 20 letters).
- The hint: Del sets `Pane.question_due_ns = clock + 400 ms` when it asks;
  `Messages.collectNotices` leaves the prompt band out while
  `question_due_ns > now_ns`; `nextWake` wakes once at that time (while
  `question_due_ns > stepped_ns`, so stepping past it ends the wake and a
  tick draws the frame). Same pattern as the REPL's `repl_enter_due_ns`.
  The question exists from the first moment: keys answer it, the 9P log
  says `ask` at once, a script's `answer` works; only the band waits.

## Why 400 ms

Typed in one go, the `j` after `SPC d` lands 100-250 ms after the `d`
(a leader sequence's inter-key gap). Above ~300 ms it is a pause, the hand
waiting to see something happen. 400 ms clears a relaxed typist with margin
and is still quick enough to read as "it is asking", not "it is broken".
Key-hint popups elsewhere (which-key) wait a few hundred ms for the same reason. It is a compile-time
constant beside `del_question` (keys are compiled in); a Runtime setting
would be one line in config if the author wants to tune it live.

## Tests

- `window mode d deletes the outlined pane and asks k or j, c collapses
  it, and the mode stays` (pardes.zig): c twice restores the height; d asks,
  Esc keeps it, d j gives the rows below and the outline follows; d with one
  neighbour closes at once onto it; labels hold none of h j k l d c.
- `the Del question shows only once its delay is up: a quick SPC d j never
  sees it`: no prompt band before the due time, nextWake at it and not
  past one frame, the band after, no wake once stepped past; a fast
  `SPC d j` closes with the band never showing it.
- The old Del test moves the clock to the due time before looking at the
  band. `test/snapshots/delask.snap` waits out the delay (`settle 700`)
  before `snap asked`; its golden is unchanged (it raced otherwise: the
  first `stable 400` saw no change and captured the band empty).

## Open questions, positions

- Should `d` leave window mode after closing? Position: no. The point of a
  mode is a run of layout edits (`Ctrl-w d j d c`), and the outline landing
  on the pane that grew says where you are; Enter/Esc end it as ever.
- `d`/`c` taken from the labels: the 21st and 22nd panes lose a letter.
  Position: fine; past 20 panes you move anyway. The alternative (labels
  only after a prefix) costs a key on every jump.
- Del's question from a click or 9P never asks, so the delay touches only
  the keyboard paths that ask today.
- Pushback: the hint could be the message row's own lingering text instead
  of the prompt band, but the band is where the answer's keys are named and
  the caret logic already knows it; kept.