From 842500974ded91496a5afa53ba65d11cd0a1e2d9 Mon Sep 17 00:00:00 2001 From: deicidus Date: Sat, 6 May 2023 22:40:16 -0700 Subject: [PATCH] more POSIX --- spells/cantrips/fathom-cursor | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/spells/cantrips/fathom-cursor b/spells/cantrips/fathom-cursor index 42ad24b..506827f 100755 --- a/spells/cantrips/fathom-cursor +++ b/spells/cantrips/fathom-cursor @@ -16,22 +16,12 @@ fathom_cursor() { esac done - # Get the position of the cursor - - # Save the current terminal state - old_state=$(stty -g) - - # Disable terminal echo and canonical mode - stty -echo -icanon - - # Request the cursor position - printf "\033[6n" - IFS='[;' read -r _ ROW COL - - # Restore the terminal state - stty "$old_state" - - position="$COL;$ROW" + # Get the position of the cursor + printf "\033[6n" + while IFS=';' read -r -d R ROW COL; do + break + done + position=$(printf "%s;%s" "${ROW#*[}" "${COL%%R*}") if [ $x = true ] && [ $y = true ]; then if [ $verbose = true ]; then