Skip to content

Commit

Permalink
Add a console cast as a demo
Browse files Browse the repository at this point in the history
  • Loading branch information
lpenz committed Dec 26, 2023
1 parent b2ba012 commit 97c253e
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/dist/
/.coverage
/result
*.cast
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
Vertical menu widget for the excellent [prompt-toolkit], with optional
fzf-inspired search

This is a demo of the included [ptvertmenu-man](src/bin/ptvertmenu-man) utility:

![demo-man](demos/demo-man.gif)


## Getting started

Expand Down
15 changes: 15 additions & 0 deletions demos/build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e -x

for demofile in ./demos/*.exp; do
name="${demofile##*/}"
name="${name//.exp/}"
asciinema rec --overwrite \
--rows 25 --cols 100 \
-c "$demofile" "demos/${name}.cast"
agg \
--speed 3 \
--theme asciinema \
"demos/${name}.cast" "demos/${name}.gif"
done
66 changes: 66 additions & 0 deletions demos/demo-man.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env expect

proc exp_prompt {} {
expect -re {[$] $} {};
}

proc exp_sleep { t } {
expect {
-timeout "$t"
timeout {}
-re {.} { exp_continue; }
}
}

proc send_sleep { s { t 1 } } {
exp_send "$s";
exp_sleep "$t";
}

spawn -noecho /bin/bash -i;
exp_prompt;

exp_send "source venv/bin/activate\r";
exp_prompt;

exp_send "src/bin/ptvertmenu-man --section 1 --menu-max-width=20\r";
expect {>} {};

set BACKSPACE "\010";
set TAB "\011";
set UP "\033\[A";
set DOWN "\033\[B";
set PGDN "\033\[6~";

exp_sleep 1;
send_sleep "$DOWN";
send_sleep "$DOWN";

send_sleep "b";
send_sleep "a";
send_sleep "s";
send_sleep "h";
send_sleep "$DOWN";
send_sleep "$DOWN";

send_sleep "\011";
send_sleep "$PGDN";
send_sleep "$PGDN";

send_sleep "$TAB";
send_sleep "$UP";
send_sleep "$BACKSPACE";
send_sleep "$BACKSPACE";
send_sleep "$BACKSPACE";
send_sleep "$BACKSPACE";
send_sleep "$DOWN";
send_sleep "$DOWN";
send_sleep "$UP";
send_sleep "$UP";

exp_send "\033q";
exp_prompt;
exp_send "exit\r";
expect eof
wait

Binary file added demos/demo-man.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 97c253e

Please sign in to comment.