-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
init-cmap.sh
235 lines (218 loc) · 7.66 KB
/
init-cmap.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
#
# 以下は ble-decode.sh にて既定で定義される特殊キー
#
# 制御文字
#
# TAB RET
#
# NUL SOH STX ETX EOT ENQ ACK BEL
# BS HT LF VT FF CR SO SI
# DLE DC1 DC2 DC3 DC4 NAK SYN ETB
# CAN EM SUB ESC FS GS RS US
#
# SP DEL
#
# PAD HOP BPH NBH IND NEL SSA ESA
# HTS HTJ VTS PLD PLU RI SS2 SS3
# DCS PU1 PU2 STS CCH MW SPA EPA
# SOS SGCI SCI CSI ST OSC PM APC
#
# 特殊キーバインディング
#
# __batch_char__
# __defchar__
# __default__
# __before_widget__
# __after_widget__
# __attach__
#
# 修飾キー
#
# shift alter control meta super hyper
#
# 端末の応答を処理した時
#
# __ignore__
#
# Note: ble-decode.sh における特殊キーの変更に際して、
# この一覧を更新することでキャッシュの更新が起こるようにしている。
#
# 2019-05-06 ble-update 関連でバグがあったのを潰したので更新。
function ble/init:cmap/bind-keypad-key {
local Ft=$1 name=$2
ble-bind --csi "$Ft" "$name"
(($3&1)) && ble-bind -k "ESC O $Ft" "$name"
(($3&2)) && ble-bind -k "ESC ? $Ft" "$name"
}
function ble/init:cmap/initialize {
# Synonyms
# paste = S-insert [rxvt]
# scroll_up = S-prior [rxvt]
# scroll_down = S-next [rxvt]
# help = f15 [rxvt]
# menu = f16 [rxvt]
# print = f16 [xterm]
# deleteline = A-delete
ble-edit/info/immediate-show text "ble/lib/init-cmap.sh: updating key sequences..."
# pc-style keys
# # vt52, xterm, rxvt
# ble-bind --csi '1~' find
# ble-bind --csi '2~' insert
# ble-bind --csi '3~' delete # execute
# ble-bind --csi '4~' select
# ble-bind --csi '5~' prior
# ble-bind --csi '6~' next
# ble-bind --csi '7~' home
# ble-bind --csi '8~' end
# # cygwin, screen, rosaterm
# ble-bind --csi '1~' home
# ble-bind --csi '2~' insert
# ble-bind --csi '3~' delete
# ble-bind --csi '4~' end
# ble-bind --csi '5~' prior
# ble-bind --csi '6~' next
# # vt100 (seems minority)
# ble-bind --csi '1~' insert
# ble-bind --csi '2~' home
# ble-bind --csi '3~' prior
# ble-bind --csi '4~' delete
# ble-bind --csi '5~' end
# ble-bind --csi '6~' next
# 順番を固定
ble-decode-kbd/generate-keycode insert
ble-decode-kbd/generate-keycode home
ble-decode-kbd/generate-keycode prior
ble-decode-kbd/generate-keycode delete
ble-decode-kbd/generate-keycode end
ble-decode-kbd/generate-keycode next
local kend; ble/util/assign kend 'tput @7 2>/dev/null || tput kend 2>/dev/null'
if [[ $kend == $'\e[5~' ]]; then
# vt100
ble-bind --csi '1~' insert
ble-bind --csi '2~' home
ble-bind --csi '3~' prior
ble-bind --csi '4~' delete
ble-bind --csi '5~' end
ble-bind --csi '6~' next
else
ble-bind --csi '1~' home
ble-bind --csi '2~' insert
ble-bind --csi '3~' delete
ble-bind --csi '4~' end
ble-bind --csi '5~' prior
ble-bind --csi '6~' next
fi
ble-bind --csi '7~' home
ble-bind --csi '8~' end
# vt220, xterm, rxvt
ble-bind --csi '11~' f1
ble-bind --csi '12~' f2
ble-bind --csi '13~' f3
ble-bind --csi '14~' f4
ble-bind --csi '15~' f5
ble-bind --csi '17~' f6
ble-bind --csi '18~' f7
ble-bind --csi '19~' f8
ble-bind --csi '20~' f9
ble-bind --csi '21~' f10
ble-bind --csi '23~' f11
ble-bind --csi '24~' f12
ble-bind --csi '25~' f13
ble-bind --csi '26~' f14
ble-bind --csi '28~' f15
ble-bind --csi '29~' f16
ble-bind --csi '31~' f17
ble-bind --csi '32~' f18
ble-bind --csi '33~' f19
ble-bind --csi '34~' f20
ble-bind --csi '200~' paste_begin
ble-bind --csi '201~' paste_end
# keypad
# vt100, xterm, application mode
# ESC ? は vt52 由来
#
# Note: kp~ と通常のキーを区別しても binding が大変なだけで
# 余り利点もないので取り敢えずこの設定では区別しない。
ble-bind -k 'ESC ? SP' SP # kpspace
ble-bind -k 'ESC O SP' SP # kpspace
ble/init:cmap/bind-keypad-key 'A' up 1
ble/init:cmap/bind-keypad-key 'B' down 1
ble/init:cmap/bind-keypad-key 'C' right 1
ble/init:cmap/bind-keypad-key 'D' left 1
ble/init:cmap/bind-keypad-key 'E' begin 1
ble/init:cmap/bind-keypad-key 'F' end 1
ble/init:cmap/bind-keypad-key 'H' home 1
ble/init:cmap/bind-keypad-key 'I' TAB 3 # kptab
ble/init:cmap/bind-keypad-key 'M' RET 3 # kpent
ble/init:cmap/bind-keypad-key 'P' f1 1 # kpf1 # Note: 普通の f1-f4
ble/init:cmap/bind-keypad-key 'Q' f2 1 # kpf2 # に対してこれらの
ble/init:cmap/bind-keypad-key 'R' f3 1 # kpf3 # シーケンスを送る
ble/init:cmap/bind-keypad-key 'S' f4 1 # kpf4 # 端末もある。
ble/init:cmap/bind-keypad-key 'j' '*' 3 # kpmul
ble/init:cmap/bind-keypad-key 'k' '+' 3 # kpadd
ble/init:cmap/bind-keypad-key 'l' ',' 3 # kpsep
ble/init:cmap/bind-keypad-key 'm' '-' 3 # kpsub
ble/init:cmap/bind-keypad-key 'n' '.' 3 # kpdec
ble/init:cmap/bind-keypad-key 'o' '/' 3 # kpdiv
ble/init:cmap/bind-keypad-key 'p' '0' 3 # kp0
ble/init:cmap/bind-keypad-key 'q' '1' 3 # kp1
ble/init:cmap/bind-keypad-key 'r' '2' 3 # kp2
ble/init:cmap/bind-keypad-key 's' '3' 3 # kp3
ble/init:cmap/bind-keypad-key 't' '4' 3 # kp4
ble/init:cmap/bind-keypad-key 'u' '5' 3 # kp5
ble/init:cmap/bind-keypad-key 'v' '6' 3 # kp6
ble/init:cmap/bind-keypad-key 'w' '7' 3 # kp7
ble/init:cmap/bind-keypad-key 'x' '8' 3 # kp8
ble/init:cmap/bind-keypad-key 'y' '9' 3 # kp9
ble/init:cmap/bind-keypad-key 'X' '=' 3 # kpeq
# rxvt
# Note: "CSI code @", "CSI code ^" は本体側で特別に処理している。
ble-bind -k 'ESC [ Z' S-TAB
ble-bind -k 'ESC O a' C-up
ble-bind -k 'ESC [ a' S-up
ble-bind -k 'ESC O b' C-down
ble-bind -k 'ESC [ b' S-down
ble-bind -k 'ESC O c' C-right
ble-bind -k 'ESC [ c' S-right
ble-bind -k 'ESC O d' C-left
ble-bind -k 'ESC [ d' S-left
ble-bind -k 'ESC [ 2 $' S-insert # ECMA-48 違反
ble-bind -k 'ESC [ 3 $' S-delete # ECMA-48 違反
ble-bind -k 'ESC [ 5 $' S-prior # ECMA-48 違反
ble-bind -k 'ESC [ 6 $' S-next # ECMA-48 違反
ble-bind -k 'ESC [ 7 $' S-home # ECMA-48 違反
ble-bind -k 'ESC [ 8 $' S-end # ECMA-48 違反
ble-bind -k 'ESC [ 2 3 $' S-f11 # ECMA-48 違反
ble-bind -k 'ESC [ 2 4 $' S-f12 # ECMA-48 違反
ble-bind -k 'ESC [ 2 5 $' S-f13 # ECMA-48 違反
ble-bind -k 'ESC [ 2 6 $' S-f14 # ECMA-48 違反
ble-bind -k 'ESC [ 2 8 $' S-f15 # ECMA-48 違反
ble-bind -k 'ESC [ 2 9 $' S-f16 # ECMA-48 違反
ble-bind -k 'ESC [ 3 1 $' S-f17 # ECMA-48 違反
ble-bind -k 'ESC [ 3 2 $' S-f18 # ECMA-48 違反
ble-bind -k 'ESC [ 3 3 $' S-f19 # ECMA-48 違反
ble-bind -k 'ESC [ 3 4 $' S-f20 # ECMA-48 違反
# cygwin specific
ble-bind -k 'ESC [ [ A' f1
ble-bind -k 'ESC [ [ B' f2
ble-bind -k 'ESC [ [ C' f3
ble-bind -k 'ESC [ [ D' f4
ble-bind -k 'ESC [ [ E' f5
# 修飾キー 'CAN @ ?'
#
# 取り敢えず CAN で始まる修飾キーは無効にしておく。何故なら、
# CAN (C-x) で始まるシーケンスをキーに当てはめてしまうと、
# C-x で終わるコマンド (exchange-point-and-mark) が曖昧になってしまう。
# 結果として、次に非 @ の文字が来るまで確定しないので実行が遅れる。
# また C-x C-x の後で @h 等を入力したい場合に別の解釈になってしまう。
#
# ble-bind -k "CAN @ S" shift
# ble-bind -k "CAN @ a" alter
# ble-bind -k "CAN @ c" control
# ble-bind -k "CAN @ h" hyper
# ble-bind -k "CAN @ m" meta
# ble-bind -k "CAN @ s" super
ble-edit/info/immediate-show text "ble/lib/init-cmap.sh: updating key sequences... done"
}
ble/init:cmap/initialize