Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

initial mouse support #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pxltrm
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ cursor() {
# Drawing Cells.
d) print_color;: "${print_col}${brush_char:=█}" ;;
e) printf "%${#brush_char}s" "" ;;
M)
IFS=\; read -rsa pos <<< "${1/'^['}"
printf '\e[%sH' "${pos[2]/M};${pos[1]}"
print_color;: "${print_col}${brush_char:=█}\\e[1D"
;;

# Brushes
b) prompt "${1: -1}"; status_line; return ;;
Expand All @@ -135,10 +140,13 @@ main() {
get_term_size
status_line

trap 'clear_screen; printf \\e[?7h' EXIT
# Enable mouse tracking.
printf '\e[?1000h\e[?1006h'

trap 'clear_screen; printf \\e[?7h\\e[?1000l' EXIT
trap 'status_line_clean; get_term_size; status_line' SIGWINCH

for ((;;)); { read -rs -n 1 key; cursor "$key"; }
for ((;;)); { read -p $'\e[38;5;0m' -d "" -t 0.010 -rs key; cursor "$key"; }
}

main "$@"