diff --git a/.gitignore b/.gitignore index 9f47317..da31b9a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /dist/ /.coverage /result +*.cast diff --git a/README.md b/README.md index 6a84398..533194d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/demos/build-all.sh b/demos/build-all.sh new file mode 100755 index 0000000..4152763 --- /dev/null +++ b/demos/build-all.sh @@ -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 diff --git a/demos/demo-man.exp b/demos/demo-man.exp new file mode 100755 index 0000000..5c1a86e --- /dev/null +++ b/demos/demo-man.exp @@ -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 + diff --git a/demos/demo-man.gif b/demos/demo-man.gif new file mode 100644 index 0000000..a203a92 Binary files /dev/null and b/demos/demo-man.gif differ