diff options
| -rw-r--r-- | docs/site/media/captions.txt | 2 | ||||
| -rw-r--r-- | docs/site/media/clips.toml | 12 | ||||
| -rw-r--r-- | docs/site/media/edit-via-ctl.mp4 | bin | 0 -> 140021 bytes | |||
| -rw-r--r-- | docs/site/media/edit-via-ctl.png | bin | 0 -> 59240 bytes | |||
| -rw-r--r-- | docs/site/media/edit-via-ctl.webm | bin | 0 -> 134014 bytes | |||
| -rw-r--r-- | docs/site/media/wait-editor.mp4 | bin | 0 -> 165106 bytes | |||
| -rw-r--r-- | docs/site/media/wait-editor.png | bin | 0 -> 70946 bytes | |||
| -rw-r--r-- | docs/site/media/wait-editor.webm | bin | 0 -> 165519 bytes | |||
| -rw-r--r-- | test/record_demos.py | 83 |
9 files changed, 97 insertions, 0 deletions
diff --git a/docs/site/media/captions.txt b/docs/site/media/captions.txt index c8b59699..4879cb12 100644 --- a/docs/site/media/captions.txt +++ b/docs/site/media/captions.txt @@ -9,3 +9,5 @@ chords: Hold left, click middle to cut; click right to paste. columns: Newcol adds a column; a look opens there; Alt-c moves a pane. search: Grep lists the hits; n and N walk them; right-click opens one. where-commands-run: A file's tag runs in its directory; the column tag, in the session's. +edit-via-ctl: An Edit written to ctl changes every sum; one Undo restores. +wait-editor: git commit's message opens in a pane; Del returns it to git. diff --git a/docs/site/media/clips.toml b/docs/site/media/clips.toml index 0ad8b173..f2406396 100644 --- a/docs/site/media/clips.toml +++ b/docs/site/media/clips.toml @@ -63,3 +63,15 @@ name = "where-commands-run" caption = "File tags run in their directory; column tags, in the session's." ready = true landing = false + +[[clip]] +name = "edit-via-ctl" +caption = "An Edit written to ctl changes every sum; one Undo restores." +ready = true +landing = false + +[[clip]] +name = "wait-editor" +caption = "git commit's message opens in a pane; Del returns it to git." +ready = true +landing = false diff --git a/docs/site/media/edit-via-ctl.mp4 b/docs/site/media/edit-via-ctl.mp4 Binary files differnew file mode 100644 index 00000000..d63f6e7f --- /dev/null +++ b/docs/site/media/edit-via-ctl.mp4 diff --git a/docs/site/media/edit-via-ctl.png b/docs/site/media/edit-via-ctl.png Binary files differnew file mode 100644 index 00000000..7a21d734 --- /dev/null +++ b/docs/site/media/edit-via-ctl.png diff --git a/docs/site/media/edit-via-ctl.webm b/docs/site/media/edit-via-ctl.webm Binary files differnew file mode 100644 index 00000000..77639d34 --- /dev/null +++ b/docs/site/media/edit-via-ctl.webm diff --git a/docs/site/media/wait-editor.mp4 b/docs/site/media/wait-editor.mp4 Binary files differnew file mode 100644 index 00000000..49adadd6 --- /dev/null +++ b/docs/site/media/wait-editor.mp4 diff --git a/docs/site/media/wait-editor.png b/docs/site/media/wait-editor.png Binary files differnew file mode 100644 index 00000000..1d029f4c --- /dev/null +++ b/docs/site/media/wait-editor.png diff --git a/docs/site/media/wait-editor.webm b/docs/site/media/wait-editor.webm Binary files differnew file mode 100644 index 00000000..5afda502 --- /dev/null +++ b/docs/site/media/wait-editor.webm diff --git a/test/record_demos.py b/test/record_demos.py index 9ee5ba53..3c64f55c 100644 --- a/test/record_demos.py +++ b/test/record_demos.py @@ -1063,6 +1063,83 @@ def where_commands_run(s): s.shots[-1]['poster'] = True +GIT_ID = dict(GIT_AUTHOR_NAME='demo', GIT_AUTHOR_EMAIL='[email protected]', + GIT_COMMITTER_NAME='demo', GIT_COMMITTER_EMAIL='[email protected]') + + +def edit_setup(s): + """main.c over a shell that sees the session as files ($m, as in the + scripting chapter: 9ns mounts the pane's $PARDES_9P), and Undo in + main.c's tag.""" + shell_setup(s) + mount = HOME / 'n' + mount.mkdir() + s.write('/pane/2/pty/data', f'exec 9ns --unix "$PARDES_9P" --mount {mount} -- /bin/sh\r') + time.sleep(1.5) # 9ns mounts and starts the shell that reads the next line + s.write('/pane/2/pty/data', f"m=$NINE_MOUNT; cd {PROJECT}; PS1='$ '; clear\r") + s.wait(lambda: [line.rstrip() for line in s.terminal_rows() if line.strip()] == [' $'], 'the mounted shell') + s.write('/pane/1/tag', ' Undo') + s.write('/pane/1/dot', '$\n') + s.mouse('motion', 0, *s.cell_px(COLS - 2, 1)) + + +def edit_via_ctl(s): + """An Edit written to the pane's ctl changes every sum; one Undo puts + them all back.""" + s.pointer = s.cell_px(44, 7) + s.shot(1.0) + command = "echo 'Edit ,x/sum/c/total/' > $m/pane/1/ctl" + s.type(command, lambda typed: at_prompt(s, typed)(), per_key=.055) + s.keys('\r') + s.wait(lambda: 'sum' not in s.read('/pane/1/body'), 'the edit') + s.shot(1.6, poster=True) + s.click(2, *s.tag_word(1, 'Undo'), done=lambda: s.read('/pane/1/body').count('sum') == 4, what='Undo', + after=2.0) + + +def wait_setup(s): + """A git repo with a change staged, and a lone shell whose EDITOR is + pardes --wait (a `pardes` on its PATH: this pardes-gui).""" + env = dict(clean_env(), HOME=str(HOME), **GIT_ID) + for args in (['init', '-q'], ['add', '.'], ['commit', '-qm', 'hello']): + subprocess.run(['git', '-C', str(PROJECT), *args], check=True, env=env, capture_output=True) + main = PROJECT / 'src/main.c' + main.write_text(main.read_text().replace('pritnf', 'printf')) + (HOME / 'bin').mkdir() + (HOME / 'bin/pardes').symlink_to(s.binary) + shell_setup(s) + ids = ' '.join(f'{k}={v}' for k, v in GIT_ID.items()) + s.write('/pane/2/pty/data', f"export PATH=$HOME/bin:$PATH EDITOR='pardes --wait' {ids}; git add -A; clear\r") + s.write('/pane/1/exec', 'Del\n') + s.wait(lambda: list(s.panes()) == [2], 'the README to close') + s.wait(lambda: [line.rstrip() for line in s.terminal_rows() if line.strip()] == [' $'], 'the prompt') + + +def wait_editor(s): + """git commit opens its message in a pane of this session; Save and + Del, and git commit returns.""" + s.pointer = s.cell_px(44, 9) + s.shot(1.0) + s.type('git commit', lambda typed: at_prompt(s, typed)(), per_key=.07) + s.keys('\r') + s.wait(lambda: len(s.panes()) == 2, 'the message pane') + msg = next(n for n in s.panes() if n != 2) + s.shot(1.0) + s.press([('i', 'i')], per_key=.3) + s.badge = 'i' + s.type('Fix the printf typo', lambda typed: typed in s.read(f'/pane/{msg}/body'), per_key=.05) + # Esc as a CSI u sequence: a bare ESC byte waits in the stdin feed's + # parser for what follows, and the next mouse event would join it. + s.press([('\x1b[27u', 'Esc')], per_key=.4) + s.shots[-1]['poster'] = True # git waiting, its message typed in the pane + s.click(2, *s.tag_word(msg, 'Save'), done=lambda: s.read(f'/pane/{msg}/dirty').strip() == '0', what='Save', + after=.6) + s.click(2, *s.tag_word(msg, 'Del'), done=lambda: list(s.panes()) == [2], what='Del', after=.3) + s.wait(lambda: any('Fix the printf typo' in line for line in s.terminal_rows()), 'git commit') + s.wait(lambda: [line.rstrip() for line in s.terminal_rows() if line.strip()][-1] == ' $', 'the prompt') + s.shot(2.4) + + CLIPS = { 'pdf-navigation': dict( setup=pdf_setup, run=pdf_navigation, args=pdf_args, @@ -1097,6 +1174,12 @@ CLIPS = { 'where-commands-run': dict( setup=where_setup, run=where_commands_run, args=[PROJECT / 'src/main.c'], caption="A file's tag runs in its directory; the column tag, in the session's."), + 'edit-via-ctl': dict( + setup=edit_setup, run=edit_via_ctl, args=[PROJECT / 'src/main.c'], + caption='An Edit written to ctl changes every sum; one Undo restores.'), + 'wait-editor': dict( + setup=wait_setup, run=wait_editor, args=[PROJECT / 'README'], + caption="git commit's message opens in a pane; Del returns it to git."), } |
