This commit is contained in:
ge
2023-03-21 02:48:44 +03:00
commit ed521e2e3c
9 changed files with 567 additions and 0 deletions

6
examples/curpos Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
. ../tui.sh
pos="$(tui_curpos)"
printf 'Cursor position: COLUMN=%s LINE=%s\n' "${pos% *}" "${pos#* }"

9
examples/readchar Normal file
View File

@ -0,0 +1,9 @@
#!/bin/sh
. ../tui.sh
num="${1:-1}"
printf 'Usage: readchar NUMBER\n'
printf 'Input characters (number=%s):\n' "$num"
tui_readchar -n "$num" VAR
echo Characters: $VAR

7
examples/readkey Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
. ../tui.sh
printf 'Press any key. Key will printed below.\n'
tui_readkey KEY
printf 'Key pressed: %s\n' "$KEY"

17
examples/readkey_2 Normal file
View File

@ -0,0 +1,17 @@
#!/bin/sh
. ../tui.sh
printf 'Press arrow keys, q to quit.\n'
while true; do
tui_readkey KEY
case "$KEY" in
Up) printf 'Move UP\n';;
Down) printf 'Move DOWN\n';;
Left) printf 'Move LEFT\n';;
Right) printf 'Move RIGHT\n';;
q|Q) break;;
*) :
esac
done

5
examples/select Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
. ../tui.sh
tui_select First Second 'Another one'

18
examples/spin Normal file
View File

@ -0,0 +1,18 @@
#!/bin/sh
. ../tui.sh
tui_spin \
-t 'Sleeping...' \
-m '\033[32;1m✓ Waked up!\033[0m' \
-- sleep 3
tui_spin -r \
-t 'Ping Google...' \
-m '\033[32;1m✓ Ping Google OK!\033[0m' \
-- ping -c 3 google.com
tui_spin \
-t 'Search *bash* files...' \
-m '\033[32;1m✓ Search *bash* files OK!\033[0m' \
-- find ~ -name "*bash*"