From a7ff1eb6583a8a8ae15eff939899ccd3ab20fbd0 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 5 Oct 2021 20:13:37 -0700 Subject: [PATCH] more work on glug; new `g` and `G` commands --- sh/glug | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/sh/glug b/sh/glug index 633ed34..def92d7 100644 --- a/sh/glug +++ b/sh/glug @@ -45,6 +45,7 @@ glug() ( # note the subshell syntax. this allows us to abuse globals like crazy. err= alt_on() { + # globals: $alt printf '\033[?1049h' # alt screen on (smcup) alt=1 printf '\033[?1h\033=' # no idea but less does it so it must be important (smkx) @@ -53,24 +54,28 @@ glug() ( # note the subshell syntax. this allows us to abuse globals like crazy. } alt_off() { + # globals: $alt printf '\r' # move cursor to start of line (carriage return) - #printf '\033[K' # erase everything before the cursor (el) + #printf '\033[K' # erase everything after the cursor (el) printf '\033[?1l\033>' # no idea but less does it so it must be important (rmkx) printf '\033[?1049l' # alt screen off (rmcup) alt=0 } glug_enter() { + # globals: $alt [ $alt = 1 ] || alt_on } glug_exit() { + # globals: $alt, $err, $ret [ $alt = 0 ] || alt_off [ -z "$err" ] || printf '%s\n' "$err" >&2 exit $ret } die() { + # globals: $ret, $err ret=$? err="$@" [ $? = 0 ] && exit 1 || exit $? @@ -86,13 +91,14 @@ glug() ( # note the subshell syntax. this allows us to abuse globals like crazy. }