From 03c6e1b4c32397b6fa5ba684dcbf1336b2f6f0df Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 12 Aug 2024 14:01:31 -0400 Subject: implement soft cursor and helpful input filter --- twopane.bash | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/twopane.bash b/twopane.bash index 2307fc1..ff1a143 100755 --- a/twopane.bash +++ b/twopane.bash @@ -95,13 +95,43 @@ sendstream() } exec 200<&${SOCAT[0]} 201>&${SOCAT[1]} socat FD:100,${stty%,}!!STDOUT STDIN!!STDOUT <&200 | - tee >(exec cat -vt >&101) >&201 + input_filter | + tee >(output_filter | soft_cursor >&101) >&201 reset -I -Q -w exec 200<&- 201>&- wait -f "$SOCAT_PID" 2>/dev/null done } +input_filter() +{ + while read -N1 + do + case "$REPLY" in + a ) echo -n "${REPLY@U}" ;; + A ) echo -n "${REPLY@L}" ;; + * ) echo -n "$REPLY" ;; + esac + done +} + +output_filter() +{ + cat -vt +} + +soft_cursor() +{ + printf $'\033[43m \b' + while read -N1 + do + printf '%s' \ + $'\033[00m \b' \ + "$REPLY" \ + $'\033[43m \b' + done +} + save_file bashrc <<. set -f set -b -- cgit v1.2.3