4 ms·
How about bash? :p r() { read -n1 -r c; [ "$c" = "$1" ]; }; b=2; stty -echo -icanon; printf '\033[H\033[0m\033[J\033[?1003h'; while true; do r $'\033' || { pri
by tripflag 3y ago
How about bash? :p
r() { read -n1 -r c; [ "$c" = "$1" ]; }; b=2; stty -echo -icanon; printf '\033[H\033[0m\033[J\033[?1003h'; while true; do r $'\033' || { printf '%s\n' "$c" | grep -qE '[0-7]' && b=$c; continue; }; r \[ || continue; r "M" || continue; r "@" && d=y || d=; read z x y z < <(head -c 2 | hexdump -C); [ $d ] || continue; printf '\033[%d;%dH\033[1;4%dm \033[0m\033[D' $((0x${y}-32)) $((0x${x}-32)) $b; done
(you can change colour with digits 1..7 btw!)
- balou23 3y agois there a name/page/nonobfuscated version/git repo for that script?
- tripflag 3y agoit's not intentionally obfuscated, it just happened like that :-) The only place I've posted it until now is on my oneliners collection, https://ocv.me/doc/unix/oneliners/#c58b5be6 https://ocv.me/doc/unix/oneliners/#c58b5be6
- balou23 3y agoOk, so I was a bit bored... - no external grep anymore - smaller (303 instead of 400 bytes) - cleanup of mouse mode on exit p(){ for i;do printf "\e[$i";done;};r(){ read -rn1 c;[[ $c = $1 ]];};stty -echo cbreak;p H m J ?1003h;trap 'p ?1003l' 0;while d=;do r $'\e'||{ [[ $c =~ [0-7] ]]&&b=$c;continue;};r \[||continue;r M||continue;r @&&d=y;read _ x y _< <(head -c2|od -tu1);[ $d ]&&p "$((y-32));$((x-32))H" "4${b-2}m " m D;done