Browse Source

more POSIX

main
deicidus 2 years ago
parent
commit
50a2f51737
  1. 16
      spells/cantrips/fathom-cursor

16
spells/cantrips/fathom-cursor

@ -17,7 +17,21 @@ fathom_cursor() {
done
# Get the position of the cursor
position=$(stty -echo; printf "\033[6n"; (trap 'exit 142' ALRM; sh -c 'sleep 0.1; kill -ALRM $$' &) IFS=';' read -r ROW COL; stty echo; printf "%s;%s" "${ROW#*[}" "${COL}")
# 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"
if [ $x = true ] && [ $y = true ]; then
if [ $verbose = true ]; then

Loading…
Cancel
Save