-
Notifications
You must be signed in to change notification settings - Fork 0
/
pxltrm.patch
63 lines (54 loc) · 1.85 KB
/
pxltrm.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --git a/pxltrm b/pxltrm
index 54da9b2..e81512a 100755
--- a/pxltrm
+++ b/pxltrm
@@ -72,7 +72,9 @@ hex_to_rgb() {
}
get_pos() {
- IFS='[;' read -p $'\e[6n' -d R -rs _ y x _
+ printf $'\e[6n'
+ #IFS='[;' read -p $'\e[6n' -d R -rs _ y x _
+ IFS='[;' read -d R -rs _ y x _
}
print_color() {
@@ -86,19 +88,22 @@ print_color() {
paint() {
get_pos
- printf '%b' "\\e[${y};${x}H${2}${1}\\b"
- hist+=("$_")
+ local a="\\e[${y};${x}H${2}${1}\\b"
+ #printf '%b' "\\e[${y};${x}H${2}${1}\\b"
+ #hist+=("$_")
+ printf %b "$a"
+ hist+=("$a")
}
prompt() {
printf '\e[s\e[%s;H\e[m' "$((LINES-1))"
case "$1" in
- s) read -rp "save file: " f; save_file > "${f:-/dev/null}" ;;
- o) read -rp "load file: " f; [[ -f "$f" ]] && load_file "$f" ;;
- c) read -rp "input color: " color ;;
- b) read -rp "input brush: " brush_char ;;
- a) read -n 1 -rp "clear? [y/n]: " y; [[ "$y" == y ]] && clear_screen ;;
+ s)printf "save file: "; read -r f; save_file > "${f:-/dev/null}" ;;
+ o) printf "load file: "; read -r f; [[ -f "$f" ]] && load_file "$f" ;;
+ c)printf "input color: "; read -r color ;;
+ b)printf "input brush: "; read -r brush_char ;;
+ a) printf "clear? [y/n]: "; read -n 1 -r y; [[ "$y" == y ]] && clear_screen ;;
esac
printf '\e[u'
@@ -119,14 +124,15 @@ cursor() {
e) paint " " ;;
d) print_color; paint "${brush_char:=█}" "$print_col" ;;
- u) (("${#hist}">0)) && undo; status_line ;;
- r) (("${#undos}">1)) && redo; status_line ;;
+ u) (("${#hist[0]}">0)) && undo; status_line ;;
+ r) (("${#undos[0]}">1)) && redo; status_line ;;
a|b|c|o|s) prompt "${1: -1}" ;;
esac
}
main() {
+ shopt -s eval_unsafe_arith 2>/dev/null
clear_screen
get_term_size
status_line