-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsixel_display_mode.sh
executable file
·72 lines (56 loc) · 1.29 KB
/
sixel_display_mode.sh
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
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Test of DECSDM (Sixel Display Mode).
# On a genuine VT340,
# when DECSDM is reset, ${CSI}?80l, sixel scrolling is enabled and
# images start drawing at the text cursor (default);
# when DECSDM is set, ${CSI}?80h, sixel scrolling is disabled and
# images start drawing at the upper left hand corner.
CSI=$'\e[' # Control Sequence Introducer
DCS=$'\eP' # Device Control String
ST=$'\e\\' # String Terminator
echo -n ${CSI}'H'
echo -n ${CSI}'J'
echo -n ${CSI}'?7h'
yes E | tr -d '\n' | head -c 1920
set_cursor_pos() {
echo -n ${CSI}${1}';'${2}'H'
}
cursor_home() {
echo ${CSI}'H'
}
cursor_down() {
echo -n ${CSI}${1}'B'
}
cursor_right() {
echo -n ${CSI}${1}'C'
}
test_pattern() {
local row=${1}
local col=${2}
local color=${3}
local suffix=${4}
local prefix=${5}
local padding=${6}
set_cursor_pos ${row} ${col}
echo ${DCS}'2;1q'${color}
echo ${prefix}
echo ${padding}'!120~-'
echo ${padding}'!120~-'
echo ${padding}'!120~-'
echo ${padding}'!120~-'
echo ${suffix}
echo -n ${ST}
}
test_pattern 22 57 '#1' '--'
echo -e '\n'
cursor_home
# Set DECSDM
echo ${CSI}'?80h'
test_pattern 3 34 '#2' '----' '--------' '!120?'
cursor_down 6
cursor_right 3
echo ' DECSDM '
# Reset DECSDM
echo ${CSI}'?80l'
test_pattern 13 35 '#3' '-----'
set_cursor_pos 22 1