@kecan0406/ttheme 1.2.13 → 1.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -12
- package/bin/package.json +1 -0
- package/bin/ttheme.js +244 -244
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +2 -2
- package/shell/adapters/_bg.zsh +2 -26
- package/shell/adapters/_osc.zsh +30 -0
- package/shell/adapters/terminal-app.zsh +0 -2
- package/shell/adapters/warp.zsh +0 -2
- package/shell/adapters/wezterm.zsh +3 -6
- package/shell/preview.zsh +103 -177
- package/shell/ttheme.zsh +3 -11
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
package/shell/adapters/_bg.zsh
CHANGED
|
@@ -8,12 +8,8 @@ __tt_bg_saved() {
|
|
|
8
8
|
|
|
9
9
|
__tt_bg_refresh() { : }
|
|
10
10
|
|
|
11
|
-
__tt_bg_hide() { : }
|
|
12
|
-
|
|
13
11
|
__tt_bg_lasting() { : }
|
|
14
12
|
|
|
15
|
-
__tt_bg_tints() { : }
|
|
16
|
-
|
|
17
13
|
__tt_bg_wipe() { REPLY=$'\e_Ga=d,d=A,q=2\e\\' }
|
|
18
14
|
|
|
19
15
|
__tt_bg_frame() {
|
|
@@ -278,13 +274,13 @@ __tt_pv_bg_open() {
|
|
|
278
274
|
__tt_pv_bg_show() {
|
|
279
275
|
(( bgcw )) || return 0
|
|
280
276
|
local name=$1 img="" op size fit=contain focus=-1 REPLY
|
|
281
|
-
local -a p=(${=TTHEME_PALETTE[${name%:*}]}) wh at
|
|
277
|
+
local -a p=(${=TTHEME_PALETTE[${name%:*}]}) wh at
|
|
282
278
|
local -i cols=$(( pw + 2 * bgmx )) rows=$(( ph + 2 * bgmy ))
|
|
283
279
|
(( ${#p} >= 20 )) || return 0
|
|
284
280
|
(( $2 )) && { __tt_bg_forget; bgshown="" bganchor=0 }
|
|
285
281
|
bgname=$name
|
|
286
282
|
__tt_bg_load $name
|
|
287
|
-
if (( ! bgrel
|
|
283
|
+
if (( ! bgrel )) && [[ $name == "$bginc" && "${bgsize[$name]} ${bgpos[$name]} ${bgop[$name]} ${bgoff[$name]}" == "${bgload[$name]}" ]]; then
|
|
288
284
|
printf '\e_Ga=d,d=i,i=1,q=2\e\\\e_Ga=d,d=i,i=2,q=2\e\\'
|
|
289
285
|
[[ -n $bgshown ]] && printf '\e_Ga=d,d=i,i=%d,p=%d,q=2\e\\' $bgshown $bgshown
|
|
290
286
|
bgshown=""
|
|
@@ -299,9 +295,6 @@ __tt_pv_bg_show() {
|
|
|
299
295
|
img=${bgsrc[$name]} focus=${bgfocus[$name]}
|
|
300
296
|
fi
|
|
301
297
|
(( bgoff[$name] )) && img=""
|
|
302
|
-
__tt_pv_bg_draft $name "$img"
|
|
303
|
-
[[ -n $reply[1] ]] && p=(${=reply[1]})
|
|
304
|
-
img=$reply[2] op=$reply[3]
|
|
305
298
|
local bg=${p[1]#\#}
|
|
306
299
|
local -i r=$(( 16#${bg:0:2} )) g=$(( 16#${bg:2:2} )) b=$(( 16#${bg:4:2} )) a=$(( (1.0 - op) * 255 + 0.5 ))
|
|
307
300
|
(( a < 0 )) && a=0
|
|
@@ -329,22 +322,6 @@ __tt_pv_bg_show() {
|
|
|
329
322
|
__tt_bg_at $id -1073741826 $(( at[1] - 1 )) $(( at[2] - 1 )) $at[3] $at[4] $at[5] $at[6] $at[7] $at[8]
|
|
330
323
|
}
|
|
331
324
|
|
|
332
|
-
__tt_pv_bg_draft() {
|
|
333
|
-
local name=$1
|
|
334
|
-
local -a look
|
|
335
|
-
reply=("" "$2" "${bgop[$name]}")
|
|
336
|
-
(( te )) && [[ ${name%:*} == "$tename" && -n $tespec ]] || return 0
|
|
337
|
-
if [[ $2 != "$teshown" ]]; then
|
|
338
|
-
teshown=$2
|
|
339
|
-
__tt_te_ask "show $2" || return 0
|
|
340
|
-
fi
|
|
341
|
-
look=("${(@ps:\x1e:)teframe[11]}")
|
|
342
|
-
reply[1]=$tespec
|
|
343
|
-
[[ -n $2 && -n $look[1] ]] && reply[2]=$look[1]
|
|
344
|
-
[[ -n $look[2] && ${bgop[$name]} == ${${=bgdef[$name]}[3]} ]] && reply[3]=$look[2]
|
|
345
|
-
return 0
|
|
346
|
-
}
|
|
347
|
-
|
|
348
325
|
__tt_bg_transmit() {
|
|
349
326
|
local REPLY
|
|
350
327
|
__tt_b64s "$2"
|
|
@@ -708,7 +685,6 @@ __tt_pv_bg_panel() {
|
|
|
708
685
|
else
|
|
709
686
|
tuned=$(( ${bgop[$name]} * 1000 + 0.5 != ${def[3]:-1} * 1000 + 0.5 ))
|
|
710
687
|
val=${bgop[$name]}
|
|
711
|
-
(( te && ! tuned )) && [[ ${name%:*} == "$tename" && -n ${${(@ps:\x1e:)teframe[11]}[2]} ]] && val=${${(@ps:\x1e:)teframe[11]}[2]}
|
|
712
688
|
o=$(( val * 100 + 0.5 ))
|
|
713
689
|
knob=$(( o * (T - 1) / 100 ))
|
|
714
690
|
fi
|
package/shell/adapters/_osc.zsh
CHANGED
|
@@ -124,6 +124,10 @@ __tt_pv_bg_strip_off() { : }
|
|
|
124
124
|
|
|
125
125
|
__tt_pv_bg_close() { : }
|
|
126
126
|
|
|
127
|
+
__tt_pv_bg_reset() { : }
|
|
128
|
+
|
|
129
|
+
__tt_bg_hide() { : }
|
|
130
|
+
|
|
127
131
|
__tt_pv_bg_save() { : }
|
|
128
132
|
|
|
129
133
|
zmodload zsh/system
|
|
@@ -178,6 +182,7 @@ __tt_ask() {
|
|
|
178
182
|
done
|
|
179
183
|
[[ -n $saved ]] && stty "$saved" <&$fd 2>/dev/null
|
|
180
184
|
exec {fd}>&-
|
|
185
|
+
[[ $buf == *$'\e[0n'* ]] || __tt_owed
|
|
181
186
|
while [[ $buf == (#b)([^$'\e']#)(${~seqs})(*) ]]; do
|
|
182
187
|
TTHEME_TYPED+=$match[1] REPLY+=$match[2] buf=$match[-1]
|
|
183
188
|
done
|
|
@@ -185,6 +190,31 @@ __tt_ask() {
|
|
|
185
190
|
REPLY=${REPLY%$'\e[0n'}
|
|
186
191
|
}
|
|
187
192
|
|
|
193
|
+
__tt_owed() {
|
|
194
|
+
local k
|
|
195
|
+
[[ -o zle && -z $TTHEME_OWED ]] || return 0
|
|
196
|
+
typeset -g TTHEME_OWED=1
|
|
197
|
+
zle -N __tt_late
|
|
198
|
+
zle -N __tt_quiet
|
|
199
|
+
for k in emacs viins vicmd; do
|
|
200
|
+
[[ $(bindkey -M $k '^[]') == *undefined-key ]] && bindkey -M $k '^[]' __tt_late
|
|
201
|
+
[[ $(bindkey -M $k '^[[0n') == *undefined-key ]] && bindkey -M $k '^[[0n' __tt_quiet
|
|
202
|
+
done
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
__tt_late() {
|
|
206
|
+
emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace}
|
|
207
|
+
local ch prev=""
|
|
208
|
+
while read -s -k 1 -t 0.2 ch; do
|
|
209
|
+
[[ $ch == $'\a' || ( $prev == $'\e' && $ch == \\ ) ]] && return 0
|
|
210
|
+
prev=$ch
|
|
211
|
+
done
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
__tt_quiet() {
|
|
215
|
+
emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace}
|
|
216
|
+
}
|
|
217
|
+
|
|
188
218
|
__tt_typed() {
|
|
189
219
|
[[ -n $TTHEME_TYPED ]] || return 0
|
|
190
220
|
zle -U -- "$TTHEME_TYPED"
|
package/shell/adapters/warp.zsh
CHANGED
|
@@ -46,12 +46,12 @@ __tt_pv_bg_show() {
|
|
|
46
46
|
(( bgcw )) || return 0
|
|
47
47
|
local name=$1 img="" size fit=contain view="" REPLY
|
|
48
48
|
local -i W=$(( pw * bgcw )) H=$(( ph * bgch )) focus=-1
|
|
49
|
-
local -a p=(${=TTHEME_PALETTE[${name%:*}]}) wh
|
|
49
|
+
local -a p=(${=TTHEME_PALETTE[${name%:*}]}) wh
|
|
50
50
|
(( ${#p} >= 20 )) || return 0
|
|
51
51
|
(( $2 )) && TTHEME_WEZTERM_VIEW=-
|
|
52
52
|
bgname=$name
|
|
53
53
|
__tt_bg_load $name
|
|
54
|
-
if
|
|
54
|
+
if [[ $name != "$bginc" || "${bgsize[$name]} ${bgpos[$name]} ${bgop[$name]} ${bgoff[$name]}" != "${bgload[$name]}" ]]; then
|
|
55
55
|
size=${bgsize[$name]}
|
|
56
56
|
if [[ $size == fill ]]; then
|
|
57
57
|
img=${bgfill[$name]} size=100 fit=cover
|
|
@@ -61,14 +61,11 @@ __tt_pv_bg_show() {
|
|
|
61
61
|
img=${bgsrc[$name]} focus=${bgfocus[$name]}
|
|
62
62
|
fi
|
|
63
63
|
(( bgoff[$name] )) && img=""
|
|
64
|
-
__tt_pv_bg_draft $name "$img"
|
|
65
|
-
[[ -n $reply[1] ]] && p=(${=reply[1]})
|
|
66
|
-
img=$reply[2]
|
|
67
64
|
view="$p[1]||1|$W|$H|0|0|0|0|5"
|
|
68
65
|
if [[ -n $img ]] && __tt_bg_dim "$img"; then
|
|
69
66
|
wh=(${=bgdim[$img]})
|
|
70
67
|
__tt_bg_frame $wh[1] $wh[2] $W $H $size ${bgpos[$name]} $fit $focus
|
|
71
|
-
view="$p[1]|$img|$
|
|
68
|
+
view="$p[1]|$img|${bgop[$name]}|$W|$H|${REPLY// /|}|${bgpos[$name]}"
|
|
72
69
|
fi
|
|
73
70
|
fi
|
|
74
71
|
[[ $view == "$TTHEME_WEZTERM_VIEW" ]] && return 0
|
package/shell/preview.zsh
CHANGED
|
@@ -110,10 +110,7 @@ __tt_pv_shows() {
|
|
|
110
110
|
__tt_pv_focus() {
|
|
111
111
|
if (( te )); then
|
|
112
112
|
__tt_pv_shows $tename
|
|
113
|
-
|
|
114
|
-
__tt_pv_bg_show "$REPLY"
|
|
115
|
-
telook="${tespec%% *} ${teframe[11]}"
|
|
116
|
-
fi
|
|
113
|
+
(( resized )) || [[ $REPLY == "$bgname" ]] || __tt_pv_bg_show "$REPLY"
|
|
117
114
|
return 0
|
|
118
115
|
fi
|
|
119
116
|
[[ ${rtype[cur]} == thm ]] || return 0
|
|
@@ -393,20 +390,8 @@ __tt_pv_foot() {
|
|
|
393
390
|
kk=(enter) kl=(confirm)
|
|
394
391
|
right=$b"esc"$z$d" back"$z
|
|
395
392
|
elif (( te && tfocus == 0 )); then
|
|
396
|
-
badge=$tb
|
|
397
|
-
kk=("${(@ps:\x1e:)teframe[6]}") kl=("${(@ps:\x1e:)teframe[7]}")
|
|
398
|
-
i=${kk[(Ie)esc]}
|
|
399
|
-
(( i )) && kk[i]=() kl[i]=()
|
|
393
|
+
badge=$tb kk=(enter ↑↓ s ⇧enter) kl=("edit palette" move save apply)
|
|
400
394
|
right=$b"esc"$z$d" cancel"$z
|
|
401
|
-
if [[ $temode == list ]]; then
|
|
402
|
-
kk=("${kk[1]}" s "${(@)kk[2,-1]}" ⇧enter) kl=("${kl[1]}" save "${(@)kl[2,-1]}" apply)
|
|
403
|
-
elif [[ $temode == tune ]]; then
|
|
404
|
-
badge="$tb (TUNE)" right=$b"esc"$z$d" undo"$z
|
|
405
|
-
elif [[ $temode == type ]]; then
|
|
406
|
-
badge="$tb (TYPE)" right=$b"esc"$z$d" back"$z
|
|
407
|
-
elif [[ $temode == compare ]]; then
|
|
408
|
-
badge="$tb (BEFORE)" right=$b"esc"$z$d" back"$z
|
|
409
|
-
fi
|
|
410
395
|
elif (( te && tfocus == 2 )); then
|
|
411
396
|
badge=$tb kk=(enter ↑↓ s) kl=(apply move save)
|
|
412
397
|
right=$b"esc"$z$d" cancel"$z
|
|
@@ -537,22 +522,18 @@ __tt_pv_help() {
|
|
|
537
522
|
[[ -n ${TTHEME_PALETTE[$cn]} ]] && back=$cn
|
|
538
523
|
local -a hk=() hv=()
|
|
539
524
|
if (( te )); then
|
|
540
|
-
hk=(Move Image "" "" "" Palette ""
|
|
525
|
+
hk=(Move Image "" "" "" Palette "" Apply Save Cancel)
|
|
541
526
|
hv=(
|
|
542
527
|
"↑↓ j k the image, the palette, then Apply · home end"
|
|
543
528
|
"Images ←→ , . pick one · D removes it · f finds one"
|
|
544
529
|
"enter on the empty frame · finds the first one"
|
|
545
530
|
"←→ step ⇧←→ ×10 1-9 place · = resets · + all"
|
|
546
531
|
"space hides · c colors"
|
|
547
|
-
"
|
|
548
|
-
"
|
|
549
|
-
"g relations · n N the next and last miss"
|
|
550
|
-
"r resets a slot · R all · space the colors before"
|
|
551
|
-
"c copies · v pastes · = bright follows normal"
|
|
552
|
-
"f moves the colors the gate misses · u undo"
|
|
532
|
+
"enter · tunes its colors full screen, keeps its own tone"
|
|
533
|
+
"? there lists its keys · esc leaves it"
|
|
553
534
|
"enter on Apply, or ⇧enter anywhere · saves, asks where"
|
|
554
|
-
"s · keeps the picture
|
|
555
|
-
"esc · back to the list, dropping
|
|
535
|
+
"s · keeps the picture"
|
|
536
|
+
"esc · back to the list, dropping picture changes since s"
|
|
556
537
|
)
|
|
557
538
|
else
|
|
558
539
|
hk=(Move Series Filter "" Example Apply Edit)
|
|
@@ -979,10 +960,6 @@ __tt_pv_draw() {
|
|
|
979
960
|
__tt_pv_norm "$flt"
|
|
980
961
|
nflt=$REPLY
|
|
981
962
|
fi
|
|
982
|
-
if (( te )) && [[ -n $tespec && $tespec != "$applied" ]]; then
|
|
983
|
-
__tt_pv_paint "$tespec"
|
|
984
|
-
applied=$tespec
|
|
985
|
-
fi
|
|
986
963
|
__tt_pv_lw
|
|
987
964
|
lw=$reply[1] sw=$reply[2]
|
|
988
965
|
split=$(( sw > 0 )) sc=$(( pw - 1 - sw ))
|
|
@@ -1374,10 +1351,6 @@ __tt_pv_mouse() {
|
|
|
1374
1351
|
z=(${=mzone})
|
|
1375
1352
|
(( ${#z} )) || return 0
|
|
1376
1353
|
[[ $mact == release ]] && mzone=""
|
|
1377
|
-
if [[ $z[4] == tone ]]; then
|
|
1378
|
-
__tt_pv_te_mouse $z
|
|
1379
|
-
return
|
|
1380
|
-
fi
|
|
1381
1354
|
case $mact in
|
|
1382
1355
|
press) __tt_pv_press $z ;;
|
|
1383
1356
|
drag) [[ $z[4] == track ]] && __tt_pv_bg_track $z[5] $(( mcol - z[2] )) $(( z[3] - z[2] )) ;;
|
|
@@ -1395,6 +1368,7 @@ __tt_pv_press() {
|
|
|
1395
1368
|
pick) pk=$5 ;;
|
|
1396
1369
|
conf) cf=$5 ;;
|
|
1397
1370
|
teimg) (( tfocus == 1 )) || __tt_te_to_image ;;
|
|
1371
|
+
tepal|teedit) tfocus=0 ;;
|
|
1398
1372
|
tefield|track|place|colors)
|
|
1399
1373
|
(( tfocus == 1 )) || __tt_te_to_image
|
|
1400
1374
|
case $4 in
|
|
@@ -1450,6 +1424,7 @@ __tt_pv_release() {
|
|
|
1450
1424
|
__tt_pv_conf_step $6
|
|
1451
1425
|
;;
|
|
1452
1426
|
tefind) __tt_te_find ;;
|
|
1427
|
+
teedit) __tt_te_edit ;;
|
|
1453
1428
|
teapply) __tt_te_apply || return 1 ;;
|
|
1454
1429
|
place) __tt_pv_bg_adjust at $5 ;;
|
|
1455
1430
|
colors)
|
|
@@ -1460,18 +1435,6 @@ __tt_pv_release() {
|
|
|
1460
1435
|
return 0
|
|
1461
1436
|
}
|
|
1462
1437
|
|
|
1463
|
-
__tt_pv_te_mouse() {
|
|
1464
|
-
local -i li=$(( $5 + mrow - $1 )) ci=$(( mcol - $2 ))
|
|
1465
|
-
if [[ $mact == press ]] && (( tfocus != 0 )); then
|
|
1466
|
-
tfocus=0
|
|
1467
|
-
__tt_te_ask "focus 1" || return 0
|
|
1468
|
-
fi
|
|
1469
|
-
(( li < 0 )) && li=0
|
|
1470
|
-
(( ci < 0 )) && ci=0
|
|
1471
|
-
__tt_te_ask "mouse $mact $li $ci $mclick" || { __tt_te_close; return 0 }
|
|
1472
|
-
__tt_te_act
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
1438
|
__tt_pv_bg_track() {
|
|
1476
1439
|
local -i x=$2 w=$3
|
|
1477
1440
|
(( x < 0 )) && x=0
|
|
@@ -1493,14 +1456,10 @@ __tt_pv_wheel() {
|
|
|
1493
1456
|
(( cf < 1 )) && cf=1
|
|
1494
1457
|
(( cf > ${#cvars} )) && cf=${#cvars}
|
|
1495
1458
|
elif (( te )); then
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
(( mwheel < 0 )) && key=up
|
|
1501
|
-
__tt_pv_te
|
|
1502
|
-
return
|
|
1503
|
-
fi
|
|
1459
|
+
key=down
|
|
1460
|
+
(( mwheel < 0 )) && key=up
|
|
1461
|
+
__tt_pv_te
|
|
1462
|
+
return
|
|
1504
1463
|
elif [[ -z $pick && -z $tune ]] && (( ${#rval} )); then
|
|
1505
1464
|
i=$(( cur + mwheel ))
|
|
1506
1465
|
[[ ${rtype[i]} == rule ]] && (( i += mwheel ))
|
|
@@ -1555,34 +1514,7 @@ __tt_pv_screen() {
|
|
|
1555
1514
|
return 0
|
|
1556
1515
|
}
|
|
1557
1516
|
|
|
1558
|
-
|
|
1559
|
-
setopt localoptions nomonitor nonotify
|
|
1560
|
-
(( TE_IN )) && { print -r -u $TE_IN -- quit 2>/dev/null; exec {TE_IN}>&- }
|
|
1561
|
-
(( TE_OUT )) && exec {TE_OUT}<&-
|
|
1562
|
-
TE_IN=0 TE_OUT=0
|
|
1563
|
-
(( TE_PID )) && { kill $TE_PID 2>/dev/null; wait $TE_PID 2>/dev/null }
|
|
1564
|
-
TE_PID=0
|
|
1565
|
-
return 0
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
__tt_te_ask() {
|
|
1569
|
-
local line
|
|
1570
|
-
(( TE_IN && TE_OUT )) || return 1
|
|
1571
|
-
print -r -u $TE_IN -- "$1" 2>/dev/null || { __tt_te_stop; return 1 }
|
|
1572
|
-
if ! IFS= read -r -u $TE_OUT -t 5 line 2>/dev/null; then
|
|
1573
|
-
__tt_te_stop
|
|
1574
|
-
msg="The palette panel stopped" msgt=300
|
|
1575
|
-
return 1
|
|
1576
|
-
fi
|
|
1577
|
-
teframe=("${(@ps:\x1f:)line}")
|
|
1578
|
-
temode=${teframe[3]:-list}
|
|
1579
|
-
tedirty=${teframe[4]:-0}
|
|
1580
|
-
[[ ${teframe[1]} == error ]] && { msg=${teframe[8]:-"Could not save the tone"} msgt=300 }
|
|
1581
|
-
[[ -n ${teframe[5]} ]] && tespec=${teframe[5]}
|
|
1582
|
-
return 0
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
__tt_te_unsaved_image() {
|
|
1517
|
+
__tt_te_unsaved() {
|
|
1586
1518
|
local img
|
|
1587
1519
|
for img in ${(k)tsnaps}; do
|
|
1588
1520
|
[[ "${bgsize[$img]} ${bgpos[$img]} ${bgop[$img]} ${bgoff[$img]}" == "${tsnaps[$img]}" ]] || return 0
|
|
@@ -1591,13 +1523,8 @@ __tt_te_unsaved_image() {
|
|
|
1591
1523
|
return 1
|
|
1592
1524
|
}
|
|
1593
1525
|
|
|
1594
|
-
__tt_te_unsaved() {
|
|
1595
|
-
(( tedirty )) && return 0
|
|
1596
|
-
__tt_te_unsaved_image
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
1526
|
__tt_te_save_image() {
|
|
1600
|
-
|
|
1527
|
+
__tt_te_unsaved || return 0
|
|
1601
1528
|
__tt_pv_tune_keep
|
|
1602
1529
|
__tt_pv_bg_save > /dev/null 2>&1
|
|
1603
1530
|
bgedit=() bgswap=() bgview=()
|
|
@@ -1606,17 +1533,19 @@ __tt_te_save_image() {
|
|
|
1606
1533
|
__tt_pv_tune_open $tename
|
|
1607
1534
|
}
|
|
1608
1535
|
|
|
1536
|
+
__tt_te_read() {
|
|
1537
|
+
local rows
|
|
1538
|
+
rows=$(__tt_cli tone $tename show 2>/dev/null) || return 1
|
|
1539
|
+
teframe=("${(@f)rows}")
|
|
1540
|
+
return 0
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1609
1543
|
__tt_te_open() {
|
|
1610
1544
|
local name=$1
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
TE_OUT=$rfd TE_IN=$wfd TE_PID=$!
|
|
1616
|
-
tename=$name tfocus=0 tespec="" tesz="" teframe=() tedirty=0 temode=list tetop=0 msgt=0 teshown="" telook=""
|
|
1617
|
-
if ! __tt_te_ask "focus 1"; then
|
|
1618
|
-
msg="Could not start the palette panel for $name" msgt=300
|
|
1619
|
-
__tt_te_stop
|
|
1545
|
+
tename=$name tfocus=0 teframe=() tetop=0 msgt=0
|
|
1546
|
+
if ! __tt_te_read; then
|
|
1547
|
+
msg="Could not read the colors of $name" msgt=300
|
|
1548
|
+
tename=""
|
|
1620
1549
|
return 0
|
|
1621
1550
|
fi
|
|
1622
1551
|
te=1
|
|
@@ -1628,25 +1557,13 @@ __tt_te_open() {
|
|
|
1628
1557
|
|
|
1629
1558
|
__tt_te_close() {
|
|
1630
1559
|
[[ -n $tune ]] && __tt_pv_untune
|
|
1631
|
-
|
|
1632
|
-
te=0 tfocus=0 tename="" tespec="" tesz="" teframe=() tetop=0 help=0 pick="" teshown="" telook=""
|
|
1560
|
+
te=0 tfocus=0 tename="" teframe=() tetop=0 help=0 pick=""
|
|
1633
1561
|
resized=1 bgname=""
|
|
1634
1562
|
return 0
|
|
1635
1563
|
}
|
|
1636
1564
|
|
|
1637
1565
|
__tt_te_save() {
|
|
1638
1566
|
__tt_te_save_image
|
|
1639
|
-
if (( tedirty )); then
|
|
1640
|
-
__tt_te_ask save || return 1
|
|
1641
|
-
if [[ ${teframe[1]} == saved ]]; then
|
|
1642
|
-
__tt_palettes_load && __tt_reloaded
|
|
1643
|
-
__tt_reload
|
|
1644
|
-
applied=${TTHEME_PALETTE[$tename]:-$applied}
|
|
1645
|
-
tespec=$applied
|
|
1646
|
-
else
|
|
1647
|
-
return 1
|
|
1648
|
-
fi
|
|
1649
|
-
fi
|
|
1650
1567
|
msg="Saved" msgt=200
|
|
1651
1568
|
return 0
|
|
1652
1569
|
}
|
|
@@ -1670,24 +1587,22 @@ __tt_te_image() {
|
|
|
1670
1587
|
__tt_te_to_image() {
|
|
1671
1588
|
tfocus=1 tf=5
|
|
1672
1589
|
[[ $1 == last && -n $tune ]] && tf=3
|
|
1673
|
-
|
|
1590
|
+
return 0
|
|
1674
1591
|
}
|
|
1675
1592
|
|
|
1676
1593
|
__tt_te_to_palette() {
|
|
1677
1594
|
tfocus=0
|
|
1678
|
-
__tt_te_ask "focus 1" && __tt_te_ask "key $1"
|
|
1679
1595
|
}
|
|
1680
1596
|
|
|
1681
1597
|
__tt_te_to_apply() {
|
|
1682
1598
|
tfocus=2
|
|
1683
|
-
__tt_te_ask "focus 0"
|
|
1684
1599
|
}
|
|
1685
1600
|
|
|
1686
1601
|
__tt_te_to_top() {
|
|
1687
1602
|
if __tt_te_image; then
|
|
1688
1603
|
__tt_te_to_image first
|
|
1689
1604
|
else
|
|
1690
|
-
__tt_te_to_palette
|
|
1605
|
+
__tt_te_to_palette
|
|
1691
1606
|
fi
|
|
1692
1607
|
}
|
|
1693
1608
|
|
|
@@ -1702,45 +1617,65 @@ __tt_te_find() {
|
|
|
1702
1617
|
return 0
|
|
1703
1618
|
}
|
|
1704
1619
|
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1620
|
+
__tt_pv_unpaint() {
|
|
1621
|
+
if [[ $painted != "$orig" ]]; then
|
|
1622
|
+
if [[ -z $orig ]]; then
|
|
1623
|
+
__tt_osc_reset
|
|
1624
|
+
else
|
|
1625
|
+
__tt_apply "$orig"
|
|
1626
|
+
fi
|
|
1627
|
+
elif [[ $applied != "$orig" ]]; then
|
|
1628
|
+
__tt_pv_paint "${TTHEME_PAINTED:+$orig}"
|
|
1712
1629
|
fi
|
|
1713
|
-
case $key in
|
|
1714
|
-
up|down|left|right|home|end|pgup|pgdn|esc) m="key $key" ;;
|
|
1715
|
-
sleft) m="key shift-left" ;;
|
|
1716
|
-
sright) m="key shift-right" ;;
|
|
1717
|
-
stab) m="key shift-tab" ;;
|
|
1718
|
-
$'\t') m="key tab" ;;
|
|
1719
|
-
$'\r'|$'\n') m="key enter" ;;
|
|
1720
|
-
$'\x7f'|$'\x08') m="key backspace" ;;
|
|
1721
|
-
$'\x03') m="key ctrl-c" ;;
|
|
1722
|
-
nop|altc) return 0 ;;
|
|
1723
|
-
*)
|
|
1724
|
-
(( ${#key} == 1 )) || return 0
|
|
1725
|
-
m="ch $(( #key ))"
|
|
1726
|
-
;;
|
|
1727
|
-
esac
|
|
1728
|
-
__tt_te_ask "$m" || { __tt_te_close; return 0 }
|
|
1729
|
-
__tt_te_act
|
|
1730
1630
|
}
|
|
1731
1631
|
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1632
|
+
__tt_te_edit() {
|
|
1633
|
+
local name=$tename err back=$applied
|
|
1634
|
+
local -i rc
|
|
1635
|
+
__tt_te_save_image
|
|
1636
|
+
__tt_pv_untune
|
|
1637
|
+
__tt_pv_unpaint
|
|
1638
|
+
painted=$orig applied=$orig
|
|
1639
|
+
__tt_pv_bg_close
|
|
1640
|
+
__tt_bg_hide $name
|
|
1641
|
+
err=$(__tt_cli tone $name edit 2>&1 >/dev/tty)
|
|
1642
|
+
rc=$?
|
|
1643
|
+
printf %s "$pvmouse"
|
|
1644
|
+
err=${${err//$'\n'/ }## #}
|
|
1645
|
+
resized=1 bgname="" bgshown="" bgdim=()
|
|
1646
|
+
if (( rc == 0 )); then
|
|
1647
|
+
__tt_palettes_load && __tt_reloaded
|
|
1648
|
+
__tt_reload
|
|
1649
|
+
back=${TTHEME_PALETTE[$name]:-$back}
|
|
1650
|
+
fi
|
|
1651
|
+
__tt_pv_paint "$back"
|
|
1652
|
+
applied=$back
|
|
1653
|
+
if (( rc == 0 )); then
|
|
1654
|
+
__tt_pv_bg_reset $name
|
|
1655
|
+
bgload[$name]=""
|
|
1656
|
+
__tt_te_read
|
|
1657
|
+
msg=${err:-"Saved"} msgt=200
|
|
1658
|
+
elif (( rc == 1 )); then
|
|
1659
|
+
msg=${err:-"Could not tune the colors of $name"} msgt=300
|
|
1660
|
+
fi
|
|
1661
|
+
__tt_pv_bg_state $name && __tt_pv_tune_open $name
|
|
1662
|
+
return 0
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
__tt_te_palette() {
|
|
1666
|
+
case $key in
|
|
1667
|
+
$'\r'|$'\n') __tt_te_edit ;;
|
|
1668
|
+
s) __tt_te_save ;;
|
|
1669
|
+
esc) __tt_te_close ;;
|
|
1670
|
+
up|k)
|
|
1738
1671
|
if __tt_te_image; then
|
|
1739
1672
|
__tt_te_to_image last
|
|
1740
1673
|
else
|
|
1741
1674
|
__tt_te_to_apply
|
|
1742
1675
|
fi
|
|
1743
1676
|
;;
|
|
1677
|
+
down|j|end) __tt_te_to_apply ;;
|
|
1678
|
+
home) __tt_te_to_top ;;
|
|
1744
1679
|
esac
|
|
1745
1680
|
return 0
|
|
1746
1681
|
}
|
|
@@ -1765,7 +1700,7 @@ __tt_pv_te_image() {
|
|
|
1765
1700
|
if (( i < ${#order} )); then
|
|
1766
1701
|
tf=${order[i+1]}
|
|
1767
1702
|
else
|
|
1768
|
-
__tt_te_to_palette
|
|
1703
|
+
__tt_te_to_palette
|
|
1769
1704
|
fi
|
|
1770
1705
|
;;
|
|
1771
1706
|
home) tf=5 ;;
|
|
@@ -1797,7 +1732,7 @@ __tt_te_button() {
|
|
|
1797
1732
|
$'\r'|$'\n') __tt_te_apply; return $? ;;
|
|
1798
1733
|
s) __tt_te_save ;;
|
|
1799
1734
|
esc) __tt_te_close ;;
|
|
1800
|
-
up|k) __tt_te_to_palette
|
|
1735
|
+
up|k) __tt_te_to_palette ;;
|
|
1801
1736
|
down|j|home) __tt_te_to_top ;;
|
|
1802
1737
|
esac
|
|
1803
1738
|
return 0
|
|
@@ -1811,7 +1746,7 @@ __tt_pv_te() {
|
|
|
1811
1746
|
'?') help=1; return 0 ;;
|
|
1812
1747
|
esac
|
|
1813
1748
|
case $tfocus in
|
|
1814
|
-
0)
|
|
1749
|
+
0) __tt_te_palette ;;
|
|
1815
1750
|
1) __tt_pv_te_image ;;
|
|
1816
1751
|
*) __tt_te_button ;;
|
|
1817
1752
|
esac
|
|
@@ -1871,27 +1806,15 @@ __tt_pv_te_ghost() {
|
|
|
1871
1806
|
__tt_pv_te_panel() {
|
|
1872
1807
|
local z=$'\e[0m' d=$'\e[2m' b=$'\e[1m' tt st note REPLY
|
|
1873
1808
|
local -a held
|
|
1874
|
-
local -i col=$1 end=$2 r0=$3 r1=$4 R W T I=3 V
|
|
1809
|
+
local -i col=$1 end=$2 r0=$3 r1=$4 R W T=${#teframe} I=3 V i n y tfs=$tf
|
|
1875
1810
|
(( color )) || z= d= b=
|
|
1876
1811
|
R=$(( r1 - r0 + 1 )) W=$(( end - col + 1 ))
|
|
1877
1812
|
[[ -n $tune ]] || __tt_pv_bg_findable $tename && I=17
|
|
1878
|
-
|
|
1879
|
-
(( T > 26 )) && T=26
|
|
1880
|
-
(( T < 21 )) && T=15
|
|
1881
|
-
if [[ "$W $T" != "$tesz" ]]; then
|
|
1882
|
-
tesz="$W $T"
|
|
1883
|
-
__tt_te_ask "size $W $T"
|
|
1884
|
-
fi
|
|
1885
|
-
V=$(( I + T + 3 ))
|
|
1813
|
+
V=$(( I + T + 4 ))
|
|
1886
1814
|
if (( V <= R || tfocus == 1 )); then
|
|
1887
1815
|
tetop=0
|
|
1888
|
-
elif (( tfocus == 2 )); then
|
|
1889
|
-
tetop=$(( V - R ))
|
|
1890
1816
|
else
|
|
1891
|
-
|
|
1892
|
-
(( at - 2 < tetop )) && tetop=$(( at > 2 ? at - 2 : 0 ))
|
|
1893
|
-
(( at > tetop + R )) && tetop=$(( at - R ))
|
|
1894
|
-
(( tetop > V - R )) && tetop=$(( V - R ))
|
|
1817
|
+
tetop=$(( V - R ))
|
|
1895
1818
|
fi
|
|
1896
1819
|
if (( tetop == 0 && I <= R )); then
|
|
1897
1820
|
y=$r0
|
|
@@ -1901,7 +1824,6 @@ __tt_pv_te_panel() {
|
|
|
1901
1824
|
pvz+=("$y $col $end teimg")
|
|
1902
1825
|
if [[ -n $tune ]]; then
|
|
1903
1826
|
(( bgoff[$tpick] )) && st=off || st=on
|
|
1904
|
-
[[ ${teframe[10]} == 1 ]] && ! __tt_bg_tints && st="recolors on save $st"
|
|
1905
1827
|
__tt_pv_bg_title $(( W - 12 - ${#st} ))
|
|
1906
1828
|
out+=" "$d$REPLY$z$'\e['$y';'$(( end - ${#st} + 1 ))'H'$d$st$z
|
|
1907
1829
|
fi
|
|
@@ -1939,9 +1861,20 @@ __tt_pv_te_panel() {
|
|
|
1939
1861
|
for (( i = 1; i <= T; i++ )); do
|
|
1940
1862
|
y=$(( r0 + I + i - tetop ))
|
|
1941
1863
|
(( y >= r0 && y <= r1 )) || continue
|
|
1942
|
-
out+=$'\e['$y';'$col'H'${teframe[
|
|
1943
|
-
pvz+=("$y $col $end
|
|
1864
|
+
out+=$'\e['$y';'$col'H'${teframe[i]}$z
|
|
1865
|
+
pvz+=("$y $col $end tepal")
|
|
1944
1866
|
done
|
|
1867
|
+
y=$(( r0 + V - 2 - tetop ))
|
|
1868
|
+
if (( y >= r0 && y <= r1 )); then
|
|
1869
|
+
pvz+=("$y $col $end teedit")
|
|
1870
|
+
out+=$'\e['$y';'$col'H'
|
|
1871
|
+
if (( tfocus == 0 )); then
|
|
1872
|
+
(( color )) && out+=$ac"▶"$z" "$'\e[7;1m'$ac" Edit palette "$z || out+="▶ [Edit palette]"
|
|
1873
|
+
else
|
|
1874
|
+
(( color )) && out+=" "$b" Edit palette "$z || out+=" Edit palette "
|
|
1875
|
+
fi
|
|
1876
|
+
out+=" "$d"tunes its colors full screen"$z
|
|
1877
|
+
fi
|
|
1945
1878
|
y=$(( r0 + V - 1 - tetop ))
|
|
1946
1879
|
(( y >= r0 && y <= r1 )) || return 0
|
|
1947
1880
|
pvz+=("$y $col $end teapply")
|
|
@@ -2149,8 +2082,8 @@ __tt_preview() {
|
|
|
2149
2082
|
local -A bgpic=() bgpics=() bgact=() bgview=() bgswap=() bgthumb=() tsnaps=() pvseek=() bgcolors=() bgprep=() TTHEME_ALIASES=()
|
|
2150
2083
|
local conf=0 cf=1
|
|
2151
2084
|
local -a plabel=(" Default " " This tab ") pkeys=() reach=() csnap=() teframe=()
|
|
2152
|
-
local te=0 tfocus=0 tetop=0 tename=""
|
|
2153
|
-
local -i
|
|
2085
|
+
local te=0 tfocus=0 tetop=0 tename=""
|
|
2086
|
+
local -i pvgone=0 bgprepid=0 mrow=0 mcol=0 mclick=0 mwheel=0 mlwheel=0 mlrow=0 mlcol=0
|
|
2154
2087
|
local -F mlast=0
|
|
2155
2088
|
local mact="" mzone="" pvmouse=""
|
|
2156
2089
|
local -a pvz=()
|
|
@@ -2182,7 +2115,7 @@ __tt_preview() {
|
|
|
2182
2115
|
local tty=""
|
|
2183
2116
|
local -i TTHEME_RAW=0
|
|
2184
2117
|
{
|
|
2185
|
-
tty=$(stty -g 2>/dev/null) && stty -echo -icanon min 1 time 0 2>/dev/null || tty=""
|
|
2118
|
+
tty=$(stty -g 2>/dev/null) && stty -echo -icanon -ixon min 1 time 0 2>/dev/null || tty=""
|
|
2186
2119
|
TTHEME_RAW=$(( ${#tty} > 0 ))
|
|
2187
2120
|
__tt_pv_bg_open
|
|
2188
2121
|
printf '\e[?2026h\e[?1049h\e[?7l\e[?25l'
|
|
@@ -2214,14 +2147,8 @@ __tt_preview() {
|
|
|
2214
2147
|
__tt_pv_bg_close
|
|
2215
2148
|
if [[ -n $spec ]]; then
|
|
2216
2149
|
[[ $spec == "$painted" ]] || __tt_apply "$spec"
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
__tt_osc_reset
|
|
2220
|
-
else
|
|
2221
|
-
__tt_apply "$orig"
|
|
2222
|
-
fi
|
|
2223
|
-
elif [[ $applied != "$orig" ]]; then
|
|
2224
|
-
__tt_pv_paint "${TTHEME_PAINTED:+$orig}"
|
|
2150
|
+
else
|
|
2151
|
+
__tt_pv_unpaint
|
|
2225
2152
|
fi
|
|
2226
2153
|
__tt_pv_pointer off
|
|
2227
2154
|
printf '\e[?7h'
|
|
@@ -2230,7 +2157,6 @@ __tt_preview() {
|
|
|
2230
2157
|
[[ -n $tty ]] && stty "$tty" 2>/dev/null
|
|
2231
2158
|
TTHEME_RAW=0
|
|
2232
2159
|
[[ -n $tune ]] && __tt_pv_untune
|
|
2233
|
-
(( TE_IN )) && __tt_te_stop
|
|
2234
2160
|
(( conf )) && __tt_pv_unconf
|
|
2235
2161
|
__tt_pv_bg_save
|
|
2236
2162
|
if [[ -n $spec ]]; then
|