@kecan0406/ttheme 1.2.16 → 1.2.18
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 +35 -24
- package/bin/ttheme.js +232 -220
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +3 -2
- package/shell/adapters/_bg.zsh +5 -5
- package/shell/adapters/_osc.zsh +2 -0
- package/shell/adapters/terminal-app.zsh +5 -0
- package/shell/preview.zsh +305 -140
- package/shell/ttheme.zsh +95 -32
package/shell/preview.zsh
CHANGED
|
@@ -157,7 +157,7 @@ typeset -gA TTHEME_GLYPHS=(
|
|
|
157
157
|
)
|
|
158
158
|
|
|
159
159
|
__tt_pv_osd() {
|
|
160
|
-
local text=${(U)osd} bits line oc=$
|
|
160
|
+
local text=${(U)osd} bits line oc=$TTHEME_SGR[bold] blank
|
|
161
161
|
local -i s=2 n=${#text} w r c k i top left
|
|
162
162
|
(( n * 16 + 4 <= pw && ph >= 14 )) || s=1
|
|
163
163
|
w=$(( n * 8 * s - 2 * s + 4 ))
|
|
@@ -186,7 +186,7 @@ __tt_pv_osd() {
|
|
|
186
186
|
done
|
|
187
187
|
line+=" "
|
|
188
188
|
for (( i = 0; i < s; i++ )); do
|
|
189
|
-
out+=$'\e['$(( top + r * s + i ))';'${left}H$oc$line$
|
|
189
|
+
out+=$'\e['$(( top + r * s + i ))';'${left}H$oc$line$TTHEME_SGR[reset]
|
|
190
190
|
done
|
|
191
191
|
done
|
|
192
192
|
out+=$'\e['$(( top + 5 * s ))';'${left}H$blank
|
|
@@ -203,6 +203,7 @@ __tt_pv_lw() {
|
|
|
203
203
|
(( l < 30 )) && l=30
|
|
204
204
|
fi
|
|
205
205
|
(( sw > pw - l - 6 )) && sw=$(( pw - l - 6 ))
|
|
206
|
+
(( te && sw < 50 )) && sw=0
|
|
206
207
|
if (( color && sw >= 32 )); then
|
|
207
208
|
lw=$l
|
|
208
209
|
else
|
|
@@ -216,7 +217,7 @@ __tt_pv_hl() {
|
|
|
216
217
|
REPLY=$t
|
|
217
218
|
(( color )) && [[ -n $flt && $lt == *$flt* ]] || return 0
|
|
218
219
|
pre=${lt%%$flt*}
|
|
219
|
-
REPLY=${t[1,${#pre}]}$
|
|
220
|
+
REPLY=${t[1,${#pre}]}$hm${t[${#pre}+1,${#pre}+${#flt}]}$TTHEME_SGR[/match]$2${t[${#pre}+${#flt}+1,-1]}
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
__tt_pv_fit() {
|
|
@@ -232,11 +233,11 @@ __tt_pv_fit() {
|
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
__tt_pv_row() {
|
|
235
|
-
local t=${rval[$1]} b=$
|
|
236
|
+
local t=${rval[$1]} b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] r=$TTHEME_SGR[/match] z=$TTHEME_SGR[reset] on="" gut=" " base="" lead=$TTHEME_SGR[dim] mark=" " name arrow=▸ ind=" " hl extra part
|
|
236
237
|
local -i w
|
|
237
238
|
(( color )) || b= d= r= z= lead=
|
|
238
239
|
if (( $1 == cur )); then
|
|
239
|
-
gut=$
|
|
240
|
+
gut=$gc"▌"$r" "
|
|
240
241
|
(( color )) && on=$sb
|
|
241
242
|
fi
|
|
242
243
|
if [[ ${rtype[$1]} == rule ]]; then
|
|
@@ -281,14 +282,18 @@ __tt_pv_row() {
|
|
|
281
282
|
return 0
|
|
282
283
|
fi
|
|
283
284
|
if (( $1 == cur )); then
|
|
284
|
-
mark=$
|
|
285
|
+
mark=$gc"■"$r base=$b
|
|
285
286
|
elif [[ -n $cdot && $t == "$cn" ]]; then
|
|
286
|
-
mark=$cdot
|
|
287
|
+
mark=$ac$cdot$r
|
|
287
288
|
fi
|
|
288
289
|
name=${t##*/}
|
|
289
290
|
[[ -n ${TTHEME_CATALOG[$t]} && ${TTHEME_GROUP[$t]} == *@* ]] && ind=" "
|
|
290
291
|
__tt_pv_hl "$name" "$base"
|
|
291
292
|
hl=$REPLY
|
|
293
|
+
if (( ${TTHEME_TUNED[(Ie)$t]} )); then
|
|
294
|
+
(( color )) && hl+=" "$TTHEME_SGR[warn]"●"$TTHEME_SGR[/warn] || hl+=" ●"
|
|
295
|
+
w=-2
|
|
296
|
+
fi
|
|
292
297
|
extra=""
|
|
293
298
|
for part in "${(@s:|:)TTHEME_NATIVE_NAMES[$t]}" "${TTHEME_CHARACTER[$t]}" "${(@s:|:)TTHEME_ALIASES[$t]}"; do
|
|
294
299
|
__tt_pv_alias "$name" "$part"
|
|
@@ -296,7 +301,7 @@ __tt_pv_row() {
|
|
|
296
301
|
done
|
|
297
302
|
if (( color )); then
|
|
298
303
|
[[ -n ${tstrip[$t]} ]] || __tt_pv_strip $t
|
|
299
|
-
w=$(( lw - 16 - ${#ind} - ${#name} ))
|
|
304
|
+
w=$(( w + lw - 16 - ${#ind} - ${#name} ))
|
|
300
305
|
__tt_pv_fit "$extra"
|
|
301
306
|
(( w < 1 )) && w=1
|
|
302
307
|
REPLY=$gut$on"$ind$mark $base$hl$r$REPLY${(l:w:: :)}${tstrip[$t]} "$z
|
|
@@ -305,21 +310,21 @@ __tt_pv_row() {
|
|
|
305
310
|
fi
|
|
306
311
|
}
|
|
307
312
|
|
|
308
|
-
|
|
313
|
+
__tt_pv_bg_credit() {
|
|
309
314
|
local by=${bgby[$tpick]} ref=${bgfrom[$tpick]} url=${bgurl[$tpick]} mark="" sgr=""
|
|
310
315
|
local -i room=$1
|
|
311
316
|
[[ -n $ref && $url == http(s|)://* ]] && __tt_links && mark="⧉ "
|
|
312
|
-
REPLY
|
|
313
|
-
(( ${#REPLY} > room )) && REPLY
|
|
314
|
-
(( ${#REPLY} > room )) && REPLY=
|
|
317
|
+
REPLY=${by:+by $by}${by:+${ref:+ · }}${ref:+$mark$ref}
|
|
318
|
+
(( ${#REPLY} > room )) && REPLY=${by:+by $by}
|
|
319
|
+
(( ${#REPLY} > room )) && REPLY=""
|
|
315
320
|
[[ -n $mark && $REPLY == *"$mark$ref"* ]] || return 0
|
|
316
|
-
(( color )) && [[ -n ${TTHEME_SITE_ANSI[${ref%% *}]} ]] && sgr=$
|
|
317
|
-
REPLY=${REPLY/"$mark$ref"/$sgr⧉${sgr:+$
|
|
321
|
+
(( color )) && [[ -n ${TTHEME_SITE_ANSI[${ref%% *}]} ]] && sgr=$TTHEME_SGR[fg${TTHEME_SITE_ANSI[${ref%% *}]}]
|
|
322
|
+
REPLY=${REPLY/"$mark$ref"/$sgr⧉${sgr:+$TTHEME_SGR[/fg]} $'\e]8;;'$url$'\e\\'$ref$'\e]8;;\e\\'}
|
|
318
323
|
return 0
|
|
319
324
|
}
|
|
320
325
|
|
|
321
326
|
__tt_pv_bar() {
|
|
322
|
-
local z=$
|
|
327
|
+
local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] on=$pl line=" " title hint="tab next"
|
|
323
328
|
local -i i at=${TTHEME_HUB_TABS[(Ie)preview]} len=${#TTHEME_HUB_TITLES}
|
|
324
329
|
(( color )) || z= d= on=
|
|
325
330
|
[[ ${rtype[cur]} == thm ]] && hint="⇧tab switch"
|
|
@@ -345,9 +350,9 @@ __tt_pv_bar() {
|
|
|
345
350
|
}
|
|
346
351
|
|
|
347
352
|
__tt_pv_head() {
|
|
348
|
-
local b=$
|
|
353
|
+
local b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] z=$TTHEME_SGR[reset] right=$6
|
|
349
354
|
(( color )) || b= d= z=
|
|
350
|
-
out+=$'\e['$1';'$2'H'$b$
|
|
355
|
+
out+=$'\e['$1';'$2'H'$b$gc$4$z
|
|
351
356
|
[[ -n $5 ]] && out+=" "$d$5$z
|
|
352
357
|
[[ -n $right ]] && out+=$'\e['$(( $3 - ${(m)#right} + 1 ))'G'$d$right$z
|
|
353
358
|
return 0
|
|
@@ -355,7 +360,7 @@ __tt_pv_head() {
|
|
|
355
360
|
|
|
356
361
|
__tt_pv_foot() {
|
|
357
362
|
setopt localoptions extendedglob
|
|
358
|
-
local b=$
|
|
363
|
+
local b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] z=$TTHEME_SGR[reset] y=$TTHEME_SGR[warn] on=$pl badge="" lead="" note="" right="" text line plain hex tb=EDIT
|
|
359
364
|
local -a kk=() kl=() seg=()
|
|
360
365
|
local -i end=$1 i lwid rwid room
|
|
361
366
|
(( color )) || b= d= z= y= on=
|
|
@@ -363,7 +368,9 @@ __tt_pv_foot() {
|
|
|
363
368
|
hex=${${=applied}[8]#\#}
|
|
364
369
|
printf -v y '\e[38;2;%d;%d;%dm' $((16#${hex:0:2})) $((16#${hex:2:2})) $((16#${hex:4:2}))
|
|
365
370
|
fi
|
|
366
|
-
if (( help )); then
|
|
371
|
+
if (( help == 2 )); then
|
|
372
|
+
badge=HELP right=$b"any key"$z$d" close"$z
|
|
373
|
+
elif (( help )); then
|
|
367
374
|
badge=HELP right=$b"? esc"$z$d" close"$z
|
|
368
375
|
elif [[ -n $pick ]]; then
|
|
369
376
|
badge='PREVIEW (APPLY)' lead="$pick →"
|
|
@@ -391,6 +398,8 @@ __tt_pv_foot() {
|
|
|
391
398
|
right=$b"esc"$z$d" back"$z
|
|
392
399
|
elif (( te && tfocus == 0 )); then
|
|
393
400
|
badge=$tb kk=(enter ↑↓ s ⇧enter) kl=("edit palette" move save apply)
|
|
401
|
+
(( tbtn )) && kl[1]="reset palette"
|
|
402
|
+
(( ${TTHEME_TUNED[(Ie)$tename]} )) && kk[2]=↑↓←→
|
|
394
403
|
right=$b"esc"$z$d" cancel"$z
|
|
395
404
|
elif (( te && tfocus == 2 )); then
|
|
396
405
|
badge=$tb kk=(enter ↑↓ s) kl=(apply move save)
|
|
@@ -445,7 +454,7 @@ __tt_pv_foot() {
|
|
|
445
454
|
right=$b"esc"$z$d" clear filter"$z
|
|
446
455
|
else
|
|
447
456
|
right=$b"esc"$z$d" restore"$z
|
|
448
|
-
[[ -n $cdot ]] && right+=" $cdot$z $cn"
|
|
457
|
+
[[ -n $cdot ]] && right+=" $ac$cdot$z $cn"
|
|
449
458
|
fi
|
|
450
459
|
fi
|
|
451
460
|
if (( msgt > 0 )) && [[ -z $pick ]]; then
|
|
@@ -467,7 +476,7 @@ __tt_pv_foot() {
|
|
|
467
476
|
line=${(j: :)seg}
|
|
468
477
|
if [[ -n $badge ]]; then
|
|
469
478
|
if (( color )); then
|
|
470
|
-
line=$
|
|
479
|
+
line=$on" $badge "$z" "$line
|
|
471
480
|
else
|
|
472
481
|
line="[$badge] $line"
|
|
473
482
|
fi
|
|
@@ -518,7 +527,7 @@ __tt_pv_foot() {
|
|
|
518
527
|
}
|
|
519
528
|
|
|
520
529
|
__tt_pv_help() {
|
|
521
|
-
local back="the tab" z=$
|
|
530
|
+
local back="the tab" z=$TTHEME_SGR[reset] b=$TTHEME_SGR[bold] blank
|
|
522
531
|
[[ -n ${TTHEME_PALETTE[$cn]} ]] && back=$cn
|
|
523
532
|
local -a hk=() hv=()
|
|
524
533
|
if (( te )); then
|
|
@@ -551,9 +560,13 @@ __tt_pv_help() {
|
|
|
551
560
|
(( hub )) && { hk+=(Screens); hv+=("shift+tab · tab on a series") }
|
|
552
561
|
fi
|
|
553
562
|
hk+=(Close)
|
|
554
|
-
|
|
563
|
+
if (( help == 2 )); then
|
|
564
|
+
hv+=("any key · ? brings this back")
|
|
565
|
+
else
|
|
566
|
+
hv+=("? esc")
|
|
567
|
+
fi
|
|
555
568
|
(( color )) || z= b=
|
|
556
|
-
local -i i r x y w hh
|
|
569
|
+
local -i i r x y w hh floor
|
|
557
570
|
if (( split && sw >= 48 )); then
|
|
558
571
|
for (( i = 1; i <= ${#hk}; i++ )); do
|
|
559
572
|
r=$(( i + 3 ))
|
|
@@ -565,7 +578,10 @@ __tt_pv_help() {
|
|
|
565
578
|
w=$(( pw - 2 < 58 ? pw - 2 : 58 )) hh=$(( ${#hk} + 4 ))
|
|
566
579
|
(( te )) && w=$(( pw - 2 < 76 ? pw - 2 : 76 ))
|
|
567
580
|
x=$(( (pw - w) / 2 + 1 )) y=$(( (ph - hh) / 2 ))
|
|
568
|
-
((
|
|
581
|
+
floor=$(( te && ! split ? 4 : pvhd + 2 ))
|
|
582
|
+
(( y < floor )) && y=$floor
|
|
583
|
+
(( y > ph - hh )) && y=$(( ph - hh ))
|
|
584
|
+
(( y < 1 )) && y=1
|
|
569
585
|
blank=${(l:w:: :)}
|
|
570
586
|
out+=$'\e['$y';'$x'H'"╭─ Help ${(l:$(( w - 9 ))::─:)}╮"
|
|
571
587
|
for (( r = y + 1; r < y + hh - 1; r++ )); do
|
|
@@ -581,8 +597,8 @@ __tt_pv_help() {
|
|
|
581
597
|
__tt_pv_specimen() {
|
|
582
598
|
local -a sp=(${=applied}) lines parts
|
|
583
599
|
(( ${#sp} >= 20 )) || return 0
|
|
584
|
-
local z=$
|
|
585
|
-
local -A rs=(p "" d $
|
|
600
|
+
local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] cell hex fore line text piece role tabs="" built="" key="$applied|$painted|$scene|$sw|$sc|$ph"
|
|
601
|
+
local -A rs=(p "" d $TTHEME_SGR[dim] b $TTHEME_SGR[bold])
|
|
586
602
|
local -i i r=6 cw=4 k n=${#TTHEME_SCENES} at
|
|
587
603
|
(( n )) || return 0
|
|
588
604
|
if [[ $key == "$pvscene" ]]; then
|
|
@@ -617,13 +633,13 @@ __tt_pv_specimen() {
|
|
|
617
633
|
for (( k = 1; k <= n; k++ )); do
|
|
618
634
|
(( k > 1 )) && tabs+=" "
|
|
619
635
|
if (( k == at )); then
|
|
620
|
-
tabs+=$
|
|
636
|
+
tabs+=$TTHEME_SGR[bold]$ac$TTHEME_SCENES[k]$z
|
|
621
637
|
else
|
|
622
638
|
tabs+=$d$TTHEME_SCENES[k]$z
|
|
623
639
|
fi
|
|
624
640
|
done
|
|
625
641
|
else
|
|
626
|
-
tabs=$
|
|
642
|
+
tabs=$TTHEME_SGR[bold]$ac$TTHEME_SCENES[at]$z" "$d"$at/$n"$z
|
|
627
643
|
fi
|
|
628
644
|
built+=$'\e[2;'$sc'H'$tabs
|
|
629
645
|
(( sw < 44 )) && cw=3
|
|
@@ -632,7 +648,7 @@ __tt_pv_specimen() {
|
|
|
632
648
|
line=""
|
|
633
649
|
for (( i = 0; i < 8; i++ )); do
|
|
634
650
|
fore=${sp[i+5]#\#} hex=${sp[i+13]#\#}
|
|
635
|
-
printf -v cell
|
|
651
|
+
printf -v cell "\e[38;2;%d;%d;%d;48;2;%d;%d;%dm%s${TTHEME_SGR[/ink]} " \
|
|
636
652
|
$((16#${fore:0:2})) $((16#${fore:2:2})) $((16#${fore:4:2})) \
|
|
637
653
|
$((16#${hex:0:2})) $((16#${hex:2:2})) $((16#${hex:4:2})) "${(l:cw::▀:)}"
|
|
638
654
|
line+=$cell
|
|
@@ -801,6 +817,7 @@ __tt_pv_conf_save() {
|
|
|
801
817
|
__tt_tilde "$TTHEME_CONFIG"
|
|
802
818
|
if __tt_config_write "${pairs[@]}"; then
|
|
803
819
|
conf=0 msg="Saved · $REPLY" msgt=200
|
|
820
|
+
(( ${pairs[(Ie)TTHEME_TAB_PALETTE]} )) && __tt_cli sync > /dev/null 2>&1 && __tt_reload
|
|
804
821
|
(( ${pairs[(Ie)TTHEME_BG_BLUR]} )) && __tt_pv_redraw
|
|
805
822
|
else
|
|
806
823
|
__tt_pv_unconf
|
|
@@ -827,7 +844,7 @@ __tt_pv_redraw() {
|
|
|
827
844
|
}
|
|
828
845
|
|
|
829
846
|
__tt_pv_conf_panel() {
|
|
830
|
-
local z=$
|
|
847
|
+
local z=$TTHEME_SGR[reset] b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] c=$ac on=$pl var v note
|
|
831
848
|
local -a ch sh
|
|
832
849
|
local -i r0=$1 col=$2 end=$3 k i j fit=1
|
|
833
850
|
(( color )) || z= b= d= c= on=
|
|
@@ -897,11 +914,11 @@ __tt_pv_flush() {
|
|
|
897
914
|
elif (( ${#bgthumb} )); then
|
|
898
915
|
__tt_pv_bg_strip_off
|
|
899
916
|
fi
|
|
900
|
-
printf '\e[
|
|
917
|
+
printf '\e[%d;%dH\e[?2026l' $pvsr $pvsc
|
|
901
918
|
}
|
|
902
919
|
|
|
903
920
|
__tt_pv_reach() {
|
|
904
|
-
local key=${pkeys[pk]} base top k home=${HOME:a} here=${PWD:a} htip="" d=$
|
|
921
|
+
local key=${pkeys[pk]} base top k home=${HOME:a} here=${PWD:a} htip="" d=$TTHEME_SGR[dim] z=$TTHEME_SGR[reset] REPLY
|
|
905
922
|
local -A own=() below=() parent=() mark=() tstrip=()
|
|
906
923
|
local -a roots=() lp=() lpw=() ll=() lat=() lpal=() lnote=() lflag=() reply was=()
|
|
907
924
|
local -A TTHEME_PINS=("${(@kv)TTHEME_PINS}")
|
|
@@ -934,7 +951,7 @@ __tt_pv_reach() {
|
|
|
934
951
|
__tt_map_build "$top"
|
|
935
952
|
fi
|
|
936
953
|
__tt_map_fit $1
|
|
937
|
-
(( ${#reply} > room )) && reply=("${(@)reply[1,room-1]}" "
|
|
954
|
+
(( ${#reply} > room )) && reply=("${(@)reply[1,room-1]}" " …")
|
|
938
955
|
reach=("${reply[@]}")
|
|
939
956
|
[[ $key == /* || ${#was} -gt 0 ]] && reach+=("")
|
|
940
957
|
__tt_pin_where "$key"
|
|
@@ -952,8 +969,8 @@ __tt_pv_reach() {
|
|
|
952
969
|
}
|
|
953
970
|
|
|
954
971
|
__tt_pv_draw() {
|
|
955
|
-
local out line cnt ex ag="" acat="" ac="" sb="" dd="" zz="" state=on src="" nflt="" rsub="" REPLY
|
|
956
|
-
local -i lw sw split sc se=$(( pw - 2 )) h k i N=${#rval} mt=${#TTHEME_ORDER} wiped=0
|
|
972
|
+
local out line cnt ex ag="" acat="" ac="" gc="" pl="" hm="" sb="" dd="" zz="" state=on src="" nflt="" rsub="" REPLY
|
|
973
|
+
local -i lw sw split sc se=$(( pw - 2 )) h k i N=${#rval} mt=${#TTHEME_ORDER} wiped=0 tall=$(( ph >= 22 )) hd
|
|
957
974
|
local -a held
|
|
958
975
|
bgstrip=""
|
|
959
976
|
if [[ -n $flt ]]; then
|
|
@@ -963,15 +980,16 @@ __tt_pv_draw() {
|
|
|
963
980
|
__tt_pv_lw
|
|
964
981
|
lw=$reply[1] sw=$reply[2]
|
|
965
982
|
split=$(( sw > 0 )) sc=$(( pw - 1 - sw ))
|
|
966
|
-
|
|
967
|
-
|
|
983
|
+
hd=$(( tall ? hub + 4 : 2 )) pvhd=$hd
|
|
984
|
+
h=$(( ph - hd - 3 ))
|
|
985
|
+
(( conf && ! split )) && h=$(( ph - hd - 4 - ${#cvars} ))
|
|
968
986
|
reach=()
|
|
969
987
|
if [[ -n $pick && $mode == pin ]]; then
|
|
970
988
|
if (( split )); then
|
|
971
989
|
__tt_pv_reach $sw $(( ph - 6 ))
|
|
972
990
|
else
|
|
973
|
-
__tt_pv_reach $se $(( ph -
|
|
974
|
-
h=$(( ph -
|
|
991
|
+
__tt_pv_reach $se $(( ph - hd - 11 ))
|
|
992
|
+
h=$(( ph - hd - 4 - ${#reach} ))
|
|
975
993
|
fi
|
|
976
994
|
fi
|
|
977
995
|
(( h < 1 )) && h=1
|
|
@@ -980,12 +998,16 @@ __tt_pv_draw() {
|
|
|
980
998
|
(( top < 1 )) && top=1
|
|
981
999
|
(( N > h && top > N - h + 1 )) && top=$(( N - h + 1 ))
|
|
982
1000
|
if (( color )); then
|
|
983
|
-
dd=$
|
|
1001
|
+
dd=$TTHEME_SGR[dim] zz=$TTHEME_SGR[reset] ac=$TTHEME_SGR[accent] pl=$TTHEME_SGR[pill] hm=$TTHEME_SGR[match]
|
|
984
1002
|
if [[ -n $applied ]]; then
|
|
985
1003
|
local -a ap=(${=applied})
|
|
986
|
-
local acx=${ap[3]#\#} sbx=${ap[4]#\#}
|
|
987
|
-
printf -v
|
|
1004
|
+
local acx=${ap[3]#\#} sbx=${ap[4]#\#} six=${ap[11]#\#}
|
|
1005
|
+
printf -v gc '\e[38;2;%d;%d;%dm' $((16#${acx:0:2})) $((16#${acx:2:2})) $((16#${acx:4:2}))
|
|
988
1006
|
printf -v sb '\e[48;2;%d;%d;%dm' $((16#${sbx:0:2})) $((16#${sbx:2:2})) $((16#${sbx:4:2}))
|
|
1007
|
+
if [[ $applied != "$painted" && -n $six ]]; then
|
|
1008
|
+
printf -v ac '\e[38;2;%d;%d;%dm' $((16#${six:0:2})) $((16#${six:2:2})) $((16#${six:4:2}))
|
|
1009
|
+
pl+=$ac hm+=$ac
|
|
1010
|
+
fi
|
|
989
1011
|
fi
|
|
990
1012
|
if [[ ${rtype[cur]} == thm ]]; then
|
|
991
1013
|
ag=${TTHEME_GROUP[${rval[cur]}]:-Other}
|
|
@@ -1005,11 +1027,11 @@ __tt_pv_draw() {
|
|
|
1005
1027
|
fi
|
|
1006
1028
|
[[ $1 == hint ]] && (( ! wiped )) || pvz=()
|
|
1007
1029
|
if (( pw < 40 || ph < 12 )); then
|
|
1008
|
-
line="ttheme
|
|
1009
|
-
(( color )) && line=$
|
|
1030
|
+
line="ttheme"
|
|
1031
|
+
(( color )) && line=$TTHEME_SGR[bold]$ac$line$TTHEME_SGR[reset]
|
|
1010
1032
|
out+=$line$'\e[K\n'"Needs 40×12 — now ${pw}×${ph}"$'\e[K\n'
|
|
1011
1033
|
line="esc quits"
|
|
1012
|
-
(( color )) && line=$
|
|
1034
|
+
(( color )) && line=$TTHEME_SGR[dim]$line$TTHEME_SGR[reset]
|
|
1013
1035
|
out+=$line$'\e[K\e[J'
|
|
1014
1036
|
__tt_pv_flush
|
|
1015
1037
|
return 0
|
|
@@ -1018,15 +1040,14 @@ __tt_pv_draw() {
|
|
|
1018
1040
|
__tt_pv_te_draw
|
|
1019
1041
|
return 0
|
|
1020
1042
|
fi
|
|
1043
|
+
local find bd="" edge=${(l:$(( lw - 3 ))::─:)}
|
|
1044
|
+
(( color )) && bd=$TTHEME_SGR[bold]
|
|
1021
1045
|
if [[ -n $flt ]]; then
|
|
1022
|
-
|
|
1023
|
-
line=" "$'\e[1m'$flt$zz$ac$'\e[7m \e[0m'
|
|
1024
|
-
else
|
|
1025
|
-
line=" ${flt}_"
|
|
1026
|
-
fi
|
|
1046
|
+
find=$flt"_"
|
|
1027
1047
|
else
|
|
1028
1048
|
ex="$expal | $exgrp"
|
|
1029
|
-
((
|
|
1049
|
+
local -i room=$(( tall ? lw - 21 : lw - 19 - ${#cnt} ))
|
|
1050
|
+
(( ${#ex} > room )) && ex="${ex[1,room-1]}…"
|
|
1030
1051
|
if (( gstep > 0 )); then
|
|
1031
1052
|
local gkeep=$(( ${#ex} * (8 - gstep) / 8 ))
|
|
1032
1053
|
if [[ $TTHEME_FX == (decode|glitch) ]]; then
|
|
@@ -1044,27 +1065,37 @@ __tt_pv_draw() {
|
|
|
1044
1065
|
ex="${ex[1,gkeep]}▏"
|
|
1045
1066
|
fi
|
|
1046
1067
|
fi
|
|
1047
|
-
|
|
1068
|
+
find=$dd"Search… e.g. $ex"$zz
|
|
1069
|
+
fi
|
|
1070
|
+
if (( tall )); then
|
|
1071
|
+
pvsr=$(( hub + 3 )) pvsc=$(( 6 + ${(m)#flt} ))
|
|
1072
|
+
line=$'\e['$lw'X '$dd"│"$zz" "$dd"⌕"$zz" "$find$'\e['$lw'G'$dd"│"$zz
|
|
1073
|
+
else
|
|
1074
|
+
pvsr=$(( hub + 1 )) pvsc=$(( 4 + ${(m)#flt} ))
|
|
1075
|
+
line=$'\e['$lw'X '$dd"⌕"$zz" "$find$'\e['$(( lw - ${#cnt} ))'G'$dd$cnt$zz
|
|
1048
1076
|
fi
|
|
1049
|
-
local tail=$'\e['$(( lw - ${#cnt} ))'G'$dd$cnt$zz
|
|
1050
|
-
[[ -n $flt ]] && tail=$'\e['$(( lw - ${#cnt} ))'G'$cnt
|
|
1051
1077
|
if [[ $1 == hint ]] && (( ! wiped )); then
|
|
1052
|
-
print -rn -- $'\e['$
|
|
1053
|
-
printf '\e[%d;%dH\e[?2026l' $
|
|
1078
|
+
print -rn -- $'\e['$pvsr'H'$TTHEME_SGR[reset]$line
|
|
1079
|
+
printf '\e[%d;%dH\e[?2026l' $pvsr $pvsc
|
|
1054
1080
|
return 0
|
|
1055
1081
|
fi
|
|
1056
1082
|
if (( hub )); then
|
|
1057
1083
|
__tt_pv_bar $(( split ? sc - 2 : pw - 1 ))
|
|
1058
|
-
out+=$REPLY$'\e[K\n'
|
|
1084
|
+
out+=$REPLY$'\e[K\n'
|
|
1085
|
+
fi
|
|
1086
|
+
if (( tall )); then
|
|
1087
|
+
out+=" "$bd"Preview"$zz" "$dd"($cnt)"$zz$'\e[K\n'
|
|
1088
|
+
out+=" "$dd"╭"$edge"╮"$zz$'\e[K\n'$line$'\e[K\n'" "$dd"╰"$edge"╯"$zz$'\e[K\n'
|
|
1059
1089
|
else
|
|
1060
|
-
out+=$line$'\e[K
|
|
1090
|
+
out+=$line$'\e[K\n'
|
|
1091
|
+
(( hub )) || out+=$'\e[K\n'
|
|
1061
1092
|
fi
|
|
1062
1093
|
if (( N > h && top > 1 )); then
|
|
1063
1094
|
out+=" "$dd"…"$zz
|
|
1064
|
-
pvz+=("
|
|
1095
|
+
pvz+=("$(( hd + 1 )) 1 $lw more -1")
|
|
1065
1096
|
fi
|
|
1066
1097
|
out+=$'\e[K\n'
|
|
1067
|
-
for (( k = 0; k < ph -
|
|
1098
|
+
for (( k = 0; k < ph - hd - 2; k++ )); do
|
|
1068
1099
|
i=$(( top + k ))
|
|
1069
1100
|
line=""
|
|
1070
1101
|
if (( k < h )); then
|
|
@@ -1073,15 +1104,15 @@ __tt_pv_draw() {
|
|
|
1073
1104
|
elif (( i <= N )); then
|
|
1074
1105
|
__tt_pv_row $i
|
|
1075
1106
|
line=$REPLY
|
|
1076
|
-
pvz+=("$((
|
|
1107
|
+
pvz+=("$(( hd + 2 + k )) 1 $lw row $i")
|
|
1077
1108
|
case ${rtype[i]} in
|
|
1078
|
-
hdr) pvz+=("$((
|
|
1079
|
-
cat) pvz+=("$((
|
|
1109
|
+
hdr) pvz+=("$(( hd + 2 + k )) 3 5 fold $i") ;;
|
|
1110
|
+
cat) pvz+=("$(( hd + 2 + k )) 5 7 fold $i") ;;
|
|
1080
1111
|
esac
|
|
1081
1112
|
fi
|
|
1082
1113
|
elif (( k == h && N > h && top + h <= N )); then
|
|
1083
1114
|
line=" "$dd"…"$zz
|
|
1084
|
-
pvz+=("$((
|
|
1115
|
+
pvz+=("$(( hd + 2 + k )) 1 $lw more 1")
|
|
1085
1116
|
fi
|
|
1086
1117
|
out+=$line$'\e[K\n'
|
|
1087
1118
|
done
|
|
@@ -1160,20 +1191,14 @@ __tt_pv_strip() {
|
|
|
1160
1191
|
cell+=" "
|
|
1161
1192
|
fi
|
|
1162
1193
|
done
|
|
1163
|
-
tstrip[$1]=$cell$
|
|
1194
|
+
tstrip[$1]=$cell$TTHEME_SGR[/fg]
|
|
1164
1195
|
}
|
|
1165
1196
|
|
|
1166
1197
|
__tt_pv_init() {
|
|
1167
|
-
local lo
|
|
1168
|
-
local -a tp
|
|
1169
1198
|
__tt_pv_group
|
|
1170
1199
|
[[ -n $orig ]] && __tt_name_of "$orig" && cn=$REPLY
|
|
1171
1200
|
[[ -n ${TTHEME_PALETTE[$cn]} ]] || return 0
|
|
1172
1201
|
cdot="◆"
|
|
1173
|
-
(( color )) || return 0
|
|
1174
|
-
tp=(${=TTHEME_PALETTE[$cn]})
|
|
1175
|
-
lo=${tp[3]#\#}
|
|
1176
|
-
printf -v cdot '\e[38;2;%d;%d;%dm◆\e[39m' $((16#${lo:0:2})) $((16#${lo:2:2})) $((16#${lo:4:2}))
|
|
1177
1202
|
}
|
|
1178
1203
|
|
|
1179
1204
|
__tt_pv_roll() {
|
|
@@ -1363,12 +1388,15 @@ __tt_pv_free() {
|
|
|
1363
1388
|
}
|
|
1364
1389
|
|
|
1365
1390
|
__tt_pv_press() {
|
|
1391
|
+
[[ $4 == tereset ]] || tearm=0
|
|
1366
1392
|
case $4 in
|
|
1367
1393
|
row|fold) __tt_pv_free && [[ ${rtype[$5]} != rule ]] && cur=$5 ;;
|
|
1368
1394
|
pick) pk=$5 ;;
|
|
1369
1395
|
conf) cf=$5 ;;
|
|
1370
1396
|
teimg) (( tfocus == 1 )) || __tt_te_to_image ;;
|
|
1371
|
-
tepal
|
|
1397
|
+
tepal) tfocus=0 ;;
|
|
1398
|
+
teedit) tfocus=0 tbtn=0 ;;
|
|
1399
|
+
tereset) tfocus=0 tbtn=1 ;;
|
|
1372
1400
|
tefield|track|place|colors)
|
|
1373
1401
|
(( tfocus == 1 )) || __tt_te_to_image
|
|
1374
1402
|
case $4 in
|
|
@@ -1425,6 +1453,7 @@ __tt_pv_release() {
|
|
|
1425
1453
|
;;
|
|
1426
1454
|
tefind) __tt_te_find ;;
|
|
1427
1455
|
teedit) __tt_te_edit ;;
|
|
1456
|
+
tereset) __tt_te_resetting ;;
|
|
1428
1457
|
teapply) __tt_te_apply || return 1 ;;
|
|
1429
1458
|
place) __tt_pv_bg_adjust at $5 ;;
|
|
1430
1459
|
colors)
|
|
@@ -1449,6 +1478,7 @@ __tt_pv_bg_track() {
|
|
|
1449
1478
|
|
|
1450
1479
|
__tt_pv_wheel() {
|
|
1451
1480
|
local -i i
|
|
1481
|
+
(( help == 2 )) && help=0
|
|
1452
1482
|
if (( help )); then
|
|
1453
1483
|
return 0
|
|
1454
1484
|
elif (( conf )); then
|
|
@@ -1493,7 +1523,8 @@ __tt_pv_screen() {
|
|
|
1493
1523
|
err=$(TTHEME_HUB=${TTHEME_HUB_TABS[to]} __tt_cli ${TTHEME_HUB_TABS[to]} 2>&1 >/dev/tty)
|
|
1494
1524
|
rc=$?
|
|
1495
1525
|
if (( rc == TTHEME_HUB_CLOSED )); then
|
|
1496
|
-
hubleft=1
|
|
1526
|
+
hubleft=1 painted=?
|
|
1527
|
+
__tt_pv_forget
|
|
1497
1528
|
return 1
|
|
1498
1529
|
elif (( rc > TTHEME_HUB_SWITCH && rc <= TTHEME_HUB_SWITCH + n )); then
|
|
1499
1530
|
to=$(( rc - TTHEME_HUB_SWITCH ))
|
|
@@ -1535,20 +1566,26 @@ __tt_te_save_image() {
|
|
|
1535
1566
|
|
|
1536
1567
|
__tt_te_read() {
|
|
1537
1568
|
local rows
|
|
1538
|
-
|
|
1569
|
+
local -i wide=${1:-0}
|
|
1570
|
+
if (( ! wide )); then
|
|
1571
|
+
__tt_pv_lw
|
|
1572
|
+
wide=${reply[2]}
|
|
1573
|
+
(( wide )) || wide=$(( pw - 2 < 66 ? pw - 3 : 65 ))
|
|
1574
|
+
fi
|
|
1575
|
+
tewide=$wide
|
|
1576
|
+
rows=$(__tt_cli tone $tename show $wide 2>/dev/null) || return 1
|
|
1539
1577
|
teframe=("${(@f)rows}")
|
|
1540
1578
|
return 0
|
|
1541
1579
|
}
|
|
1542
1580
|
|
|
1543
1581
|
__tt_te_open() {
|
|
1544
1582
|
local name=$1
|
|
1545
|
-
tename=$name tfocus=0 teframe=() tetop=0 msgt=0
|
|
1583
|
+
tename=$name tfocus=0 teframe=() tetop=0 msgt=0 te=1 tbtn=0 tearm=0
|
|
1546
1584
|
if ! __tt_te_read; then
|
|
1547
1585
|
msg="Could not read the colors of $name" msgt=300
|
|
1548
|
-
tename=""
|
|
1586
|
+
tename="" te=0
|
|
1549
1587
|
return 0
|
|
1550
1588
|
fi
|
|
1551
|
-
te=1
|
|
1552
1589
|
(( bgcw )) && __tt_pv_bg_state $name && __tt_pv_tune_open $name
|
|
1553
1590
|
__tt_te_image && __tt_te_to_image 1
|
|
1554
1591
|
resized=1
|
|
@@ -1557,7 +1594,7 @@ __tt_te_open() {
|
|
|
1557
1594
|
|
|
1558
1595
|
__tt_te_close() {
|
|
1559
1596
|
[[ -n $tune ]] && __tt_pv_untune
|
|
1560
|
-
te=0 tfocus=0 tename="" teframe=() tetop=0 help=0 pick=""
|
|
1597
|
+
te=0 tfocus=0 tename="" teframe=() tetop=0 tbtn=0 tearm=0 help=0 pick=""
|
|
1561
1598
|
resized=1 bgname=""
|
|
1562
1599
|
return 0
|
|
1563
1600
|
}
|
|
@@ -1629,8 +1666,14 @@ __tt_pv_unpaint() {
|
|
|
1629
1666
|
fi
|
|
1630
1667
|
}
|
|
1631
1668
|
|
|
1669
|
+
__tt_te_follow() {
|
|
1670
|
+
[[ $orig == "$1" && -n ${TTHEME_PALETTE[$tename]} ]] || return 0
|
|
1671
|
+
orig=${TTHEME_PALETTE[$tename]}
|
|
1672
|
+
TTHEME_SPEC=$orig
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1632
1675
|
__tt_te_edit() {
|
|
1633
|
-
local name=$tename err back=$applied
|
|
1676
|
+
local name=$tename err back=$applied was=${TTHEME_PALETTE[$tename]}
|
|
1634
1677
|
local -i rc
|
|
1635
1678
|
__tt_te_save_image
|
|
1636
1679
|
__tt_pv_untune
|
|
@@ -1645,6 +1688,7 @@ __tt_te_edit() {
|
|
|
1645
1688
|
resized=1 bgname="" bgshown="" bgdim=()
|
|
1646
1689
|
if (( rc == 0 )); then
|
|
1647
1690
|
__tt_palettes_load && __tt_reloaded
|
|
1691
|
+
__tt_te_follow "$was"
|
|
1648
1692
|
__tt_reload
|
|
1649
1693
|
back=${TTHEME_PALETTE[$name]:-$back}
|
|
1650
1694
|
fi
|
|
@@ -1662,11 +1706,56 @@ __tt_te_edit() {
|
|
|
1662
1706
|
return 0
|
|
1663
1707
|
}
|
|
1664
1708
|
|
|
1709
|
+
__tt_te_reset() {
|
|
1710
|
+
local name=$tename err was=${TTHEME_PALETTE[$tename]}
|
|
1711
|
+
local -i rc
|
|
1712
|
+
__tt_te_save_image
|
|
1713
|
+
__tt_pv_untune
|
|
1714
|
+
__tt_pv_bg_close
|
|
1715
|
+
err=$(__tt_cli tone $name reset 2>&1 >/dev/null)
|
|
1716
|
+
rc=$?
|
|
1717
|
+
err=${${err//$'\n'/ }## #}
|
|
1718
|
+
tbtn=0 tearm=0 resized=1 bgname="" bgshown="" bgdim=()
|
|
1719
|
+
if (( rc == 0 )); then
|
|
1720
|
+
__tt_palettes_load && __tt_reloaded
|
|
1721
|
+
__tt_te_follow "$was"
|
|
1722
|
+
__tt_reload
|
|
1723
|
+
[[ -n ${TTHEME_PALETTE[$name]} ]] && __tt_pv_paint "${TTHEME_PALETTE[$name]}" && applied=${TTHEME_PALETTE[$name]}
|
|
1724
|
+
__tt_pv_bg_reset $name
|
|
1725
|
+
bgload[$name]=""
|
|
1726
|
+
__tt_te_read
|
|
1727
|
+
msg=${err:-"Back to the original colors"} msgt=200
|
|
1728
|
+
elif (( rc == 1 )); then
|
|
1729
|
+
msg=${err:-"Could not reset the colors of $name"} msgt=300
|
|
1730
|
+
fi
|
|
1731
|
+
__tt_pv_bg_state $name && __tt_pv_tune_open $name
|
|
1732
|
+
return 0
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
__tt_te_resetting() {
|
|
1736
|
+
if (( tearm )); then
|
|
1737
|
+
__tt_te_reset
|
|
1738
|
+
else
|
|
1739
|
+
tearm=1
|
|
1740
|
+
fi
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1665
1743
|
__tt_te_palette() {
|
|
1744
|
+
local -i armed=$tearm
|
|
1745
|
+
tearm=0
|
|
1746
|
+
(( ${TTHEME_TUNED[(Ie)$tename]} )) || tbtn=0
|
|
1666
1747
|
case $key in
|
|
1667
|
-
$'\r'|$'\n')
|
|
1748
|
+
$'\r'|$'\n')
|
|
1749
|
+
if (( tbtn )); then
|
|
1750
|
+
tearm=$armed
|
|
1751
|
+
__tt_te_resetting
|
|
1752
|
+
else
|
|
1753
|
+
__tt_te_edit
|
|
1754
|
+
fi
|
|
1755
|
+
;;
|
|
1756
|
+
left|right) (( ${TTHEME_TUNED[(Ie)$tename]} )) && tbtn=$(( ! tbtn )) ;;
|
|
1668
1757
|
s) __tt_te_save ;;
|
|
1669
|
-
esc) __tt_te_close ;;
|
|
1758
|
+
esc) (( armed )) || __tt_te_close ;;
|
|
1670
1759
|
up|k)
|
|
1671
1760
|
if __tt_te_image; then
|
|
1672
1761
|
__tt_te_to_image last
|
|
@@ -1754,7 +1843,7 @@ __tt_pv_te() {
|
|
|
1754
1843
|
}
|
|
1755
1844
|
|
|
1756
1845
|
__tt_pv_te_head() {
|
|
1757
|
-
local z=$
|
|
1846
|
+
local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] y=$TTHEME_SGR[warn] line REPLY
|
|
1758
1847
|
local -i col=$1 end=$2 room=$(( $2 - $1 + 1 ))
|
|
1759
1848
|
(( color )) || z= d= b= y=
|
|
1760
1849
|
__tt_te_unsaved && (( room -= 11 ))
|
|
@@ -1767,7 +1856,7 @@ __tt_pv_te_head() {
|
|
|
1767
1856
|
}
|
|
1768
1857
|
|
|
1769
1858
|
__tt_pv_te_tile() {
|
|
1770
|
-
local z=$
|
|
1859
|
+
local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] sty top side bot
|
|
1771
1860
|
local -i y=$1 col=$2 r tc=10
|
|
1772
1861
|
(( color )) || z= d= b=
|
|
1773
1862
|
if (( tfocus == 1 && tf == 5 )); then
|
|
@@ -1789,7 +1878,7 @@ __tt_pv_te_tile() {
|
|
|
1789
1878
|
}
|
|
1790
1879
|
|
|
1791
1880
|
__tt_pv_te_ghost() {
|
|
1792
|
-
local z=$
|
|
1881
|
+
local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim]
|
|
1793
1882
|
local -i r0=$1 col=$2 T=$(( $3 - $2 - 21 )) i
|
|
1794
1883
|
(( color )) || z= d=
|
|
1795
1884
|
(( T < 8 )) && T=8
|
|
@@ -1803,79 +1892,151 @@ __tt_pv_te_ghost() {
|
|
|
1803
1892
|
return 0
|
|
1804
1893
|
}
|
|
1805
1894
|
|
|
1806
|
-
|
|
1807
|
-
local
|
|
1895
|
+
__tt_pv_te_edge() {
|
|
1896
|
+
local left=$4 right=$5 sty=$6 hs=$7 head=$8 tail=$9 z=$TTHEME_SGR[reset] line
|
|
1897
|
+
local -i y=$1 col=$2 w=$3 n
|
|
1898
|
+
(( color )) || z=
|
|
1899
|
+
n=$(( w - 3 - (${#head} ? ${#head} + 2 : 0) - (${#tail} ? ${#tail} + 3 : 0) ))
|
|
1900
|
+
(( n < 0 )) && n=0
|
|
1901
|
+
line=$sty$left"─"$z
|
|
1902
|
+
[[ -n $head ]] && line+=$hs" $head "$z
|
|
1903
|
+
line+=$sty${(l:n::─:)}
|
|
1904
|
+
[[ -n $tail ]] && line+=" $tail ─"
|
|
1905
|
+
out+=$'\e['$y';'$col'H'$line$right$z
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
__tt_pv_te_sides() {
|
|
1909
|
+
local sty=$5 z=$TTHEME_SGR[reset]
|
|
1910
|
+
local -i y r1=$2 col=$3 w=$4
|
|
1911
|
+
(( color )) || z=
|
|
1912
|
+
for (( y = $1; y <= r1; y++ )); do
|
|
1913
|
+
out+=$'\e['$y';'$col'H'$sty"│"$z$'\e['$y';'$(( col + w - 1 ))'H'$sty"│"$z
|
|
1914
|
+
done
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
__tt_pv_te_images() {
|
|
1918
|
+
local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] st=" " tt note="0/0"
|
|
1808
1919
|
local -a held
|
|
1809
|
-
local -i
|
|
1920
|
+
local -i y=$1 col=$2 end=$3 n
|
|
1921
|
+
(( color )) || z= d= b=
|
|
1922
|
+
tt=$d
|
|
1923
|
+
if [[ -n $tune ]]; then
|
|
1924
|
+
held=(${=bgpics[$tune]})
|
|
1925
|
+
n=${held[(Ie)${${tpick#$tune}#:}]}
|
|
1926
|
+
(( n )) || n=${held[(Ie)${bgact[$tune]}]}
|
|
1927
|
+
(( n )) || n=1
|
|
1928
|
+
note="$n/$(( ${#held} ? ${#held} : 1 ))"
|
|
1929
|
+
fi
|
|
1930
|
+
(( tfocus == 1 && tf == 5 )) && st=$ac"▶"$z" " tt=$b
|
|
1931
|
+
out+=$'\e['$y';'$col'H'$st$tt"Images"$z$'\e['$y';'$(( end - ${#note} + 1 ))'H'$d$note$z
|
|
1932
|
+
pvz+=("$y $col $end teimg")
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
__tt_pv_te_button() {
|
|
1936
|
+
if (( tfocus == 0 && tbtn == $1 )); then
|
|
1937
|
+
(( color )) && out+=$ac"▶"$z" "$pl" $2 "$z || out+="▶ [$2]"
|
|
1938
|
+
else
|
|
1939
|
+
(( color )) && out+=" "$b" $2 "$z || out+=" $2 "
|
|
1940
|
+
fi
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
__tt_pv_te_editrow() {
|
|
1944
|
+
local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] note="tunes its colors full screen"
|
|
1945
|
+
local -i y=$1 col=$2 end=$3 x=$(( $2 + 2 ))
|
|
1946
|
+
local reset="Reset palette"
|
|
1947
|
+
(( color )) || z= d= b=
|
|
1948
|
+
out+=$'\e['$y';'$x'H'
|
|
1949
|
+
__tt_pv_te_button 0 "Edit palette"
|
|
1950
|
+
pvz+=("$y $col $(( x + 15 )) teedit")
|
|
1951
|
+
x+=16
|
|
1952
|
+
if (( ${TTHEME_TUNED[(Ie)$tename]} )); then
|
|
1953
|
+
out+=" "
|
|
1954
|
+
(( tearm )) && reset="Reset? enter again"
|
|
1955
|
+
__tt_pv_te_button 1 "$reset"
|
|
1956
|
+
pvz+=("$y $(( x + 2 )) $(( x + ${#reset} + 5 )) tereset")
|
|
1957
|
+
x+=$(( ${#reset} + 6 ))
|
|
1958
|
+
(( tfocus == 0 && tbtn )) && note="back to its own colors"
|
|
1959
|
+
(( tearm )) && note="drops your tone"
|
|
1960
|
+
fi
|
|
1961
|
+
(( ${#note} <= end - x - 3 )) && out+=" "$d$note$z
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
__tt_pv_te_panel() {
|
|
1965
|
+
local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] dx=$TTHEME_SGR[/dim] bx=$TTHEME_SGR[/bold] ax=$TTHEME_SGR[/accent] fs hs st note row REPLY
|
|
1966
|
+
local -i col=$1 end=$2 r0=$3 r1=$4 ix=$(( $1 + 2 )) ie=$(( $2 - 2 )) R W T P I=3 V i y pics=0 tfs=$tf
|
|
1810
1967
|
(( color )) || z= d= b=
|
|
1811
1968
|
R=$(( r1 - r0 + 1 )) W=$(( end - col + 1 ))
|
|
1812
|
-
|
|
1813
|
-
|
|
1969
|
+
(( tewide == W )) || __tt_te_read $W
|
|
1970
|
+
T=${#teframe} P=$(( ${#teframe} + 2 ))
|
|
1971
|
+
__tt_te_image && pics=1
|
|
1972
|
+
(( pics && 18 <= R && (tfocus == 1 || 18 + P + 1 <= R) )) && I=18
|
|
1973
|
+
V=$(( I + P + 1 ))
|
|
1814
1974
|
if (( V <= R || tfocus == 1 )); then
|
|
1815
1975
|
tetop=0
|
|
1816
1976
|
else
|
|
1817
1977
|
tetop=$(( V - R ))
|
|
1818
1978
|
fi
|
|
1979
|
+
fs=$d hs=$d
|
|
1980
|
+
(( tfocus == 1 )) && fs=$ac hs=$b$ac
|
|
1819
1981
|
if (( tetop == 0 && I <= R )); then
|
|
1820
1982
|
y=$r0
|
|
1821
|
-
|
|
1822
|
-
((
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1983
|
+
st=""
|
|
1984
|
+
[[ -n $tune ]] && { (( bgoff[$tpick] )) && st=off || st=on }
|
|
1985
|
+
__tt_pv_te_edge $y $col $W ╭ ╮ "$fs" "$hs" Image "$st"
|
|
1986
|
+
__tt_pv_te_sides $(( y + 1 )) $(( y + I - 2 )) $col $W "$fs"
|
|
1987
|
+
__tt_pv_te_edge $(( y + I - 1 )) $col $W ╰ ╯ "$fs"
|
|
1988
|
+
if (( pics )); then
|
|
1989
|
+
for (( i = 0; i < I; i++ )); do
|
|
1990
|
+
pvz+=("$(( y + i )) $col $end teimg")
|
|
1991
|
+
done
|
|
1829
1992
|
fi
|
|
1830
|
-
if (( I ==
|
|
1831
|
-
held=() n=0 note="0/0"
|
|
1993
|
+
if (( I == 18 )); then
|
|
1832
1994
|
if [[ -n $tune ]]; then
|
|
1833
|
-
|
|
1834
|
-
n
|
|
1835
|
-
(( n )) || n=${held[(Ie)${bgact[$tune]}]}
|
|
1836
|
-
(( n )) || n=1
|
|
1837
|
-
note="$n/$(( ${#held} ? ${#held} : 1 ))"
|
|
1995
|
+
__tt_pv_bg_credit $(( ie - ix + 1 ))
|
|
1996
|
+
[[ -n $REPLY ]] && out+=$'\e['$(( y + 1 ))';'$ix'H'$d$REPLY$z
|
|
1838
1997
|
fi
|
|
1839
|
-
|
|
1840
|
-
(( tfocus == 1 && tf == 5 )) && st=$ac"▶"$z" " tt=$b
|
|
1841
|
-
out+=$'\e['$(( y + 2 ))';'$col'H'$st$tt"Images"$z$'\e['$(( y + 2 ))';'$(( end - ${#note} + 1 ))'H'$d$note$z
|
|
1842
|
-
pvz+=("$(( y + 2 )) $col $end teimg")
|
|
1998
|
+
__tt_pv_te_images $(( y + 2 )) $ix $ie
|
|
1843
1999
|
if [[ -n $tune ]]; then
|
|
1844
|
-
bgstrip="$(( y + 2 )) $
|
|
2000
|
+
bgstrip="$(( y + 2 )) $ix $ie"
|
|
1845
2001
|
(( tfocus == 1 )) || tf=0
|
|
1846
|
-
__tt_pv_bg_panel $tpick $(( y + 9 )) $
|
|
2002
|
+
__tt_pv_bg_panel $tpick $(( y + 9 )) $ix $ie
|
|
1847
2003
|
tf=$tfs
|
|
1848
2004
|
else
|
|
1849
|
-
__tt_pv_te_tile $(( y + 3 )) $
|
|
2005
|
+
__tt_pv_te_tile $(( y + 3 )) $ix
|
|
1850
2006
|
for (( i = 3; i <= 7; i++ )); do
|
|
1851
|
-
pvz+=("$(( y + i )) $
|
|
2007
|
+
pvz+=("$(( y + i )) $ix $(( ix + 30 )) tefind")
|
|
1852
2008
|
done
|
|
1853
|
-
__tt_pv_te_ghost $(( y + 9 )) $
|
|
2009
|
+
__tt_pv_te_ghost $(( y + 9 )) $ix $ie
|
|
1854
2010
|
fi
|
|
2011
|
+
elif (( pics )); then
|
|
2012
|
+
__tt_pv_te_images $(( y + 1 )) $ix $ie
|
|
1855
2013
|
elif (( bgcw )); then
|
|
1856
|
-
out+=$'\e['$(( y +
|
|
2014
|
+
out+=$'\e['$(( y + 1 ))';'$ix'H'$d"No picture yet"$z
|
|
1857
2015
|
else
|
|
1858
|
-
out+=$'\e['$(( y +
|
|
2016
|
+
out+=$'\e['$(( y + 1 ))';'$ix'H'$d"This terminal shows no pictures"$z
|
|
1859
2017
|
fi
|
|
1860
2018
|
fi
|
|
1861
|
-
|
|
1862
|
-
|
|
2019
|
+
fs=$d
|
|
2020
|
+
(( tfocus == 0 )) && fs=$ac
|
|
2021
|
+
for (( i = 1; i <= P; i++ )); do
|
|
2022
|
+
y=$(( r0 + I + i - 1 - tetop ))
|
|
1863
2023
|
(( y >= r0 && y <= r1 )) || continue
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
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]"
|
|
2024
|
+
if (( i == T )); then
|
|
2025
|
+
__tt_pv_te_edge $y $col $W ├ ┤ "$fs"
|
|
2026
|
+
elif (( i == T + 1 )); then
|
|
2027
|
+
__tt_pv_te_sides $y $y $col $W "$fs"
|
|
2028
|
+
__tt_pv_te_editrow $y $col $end
|
|
1873
2029
|
else
|
|
1874
|
-
|
|
2030
|
+
row=${teframe[i == P ? T : i]}
|
|
2031
|
+
if (( tfocus == 0 && color )); then
|
|
2032
|
+
row=${${row//$d/$ac}//$dx/$bx$ax}
|
|
2033
|
+
(( i == 1 )) && row=${row/ Palette /$b" Palette "$bx}
|
|
2034
|
+
fi
|
|
2035
|
+
out+=$'\e['$y';'$col'H'$row$z
|
|
2036
|
+
pvz+=("$y $col $end tepal")
|
|
1875
2037
|
fi
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
y=$(( r0 + V - 1 - tetop ))
|
|
2038
|
+
done
|
|
2039
|
+
y=$(( r0 + I + P - tetop ))
|
|
1879
2040
|
(( y >= r0 && y <= r1 )) || return 0
|
|
1880
2041
|
pvz+=("$y $col $end teapply")
|
|
1881
2042
|
if [[ $mode == pin ]]; then
|
|
@@ -1885,9 +2046,9 @@ __tt_pv_te_panel() {
|
|
|
1885
2046
|
else
|
|
1886
2047
|
note="saves and wears it in this tab"
|
|
1887
2048
|
fi
|
|
1888
|
-
out+=$'\e['$y';'$
|
|
2049
|
+
out+=$'\e['$y';'$ix'H'
|
|
1889
2050
|
if (( tfocus == 2 )); then
|
|
1890
|
-
(( color )) && out+=$ac"▶"$z" "$
|
|
2051
|
+
(( color )) && out+=$ac"▶"$z" "$pl" Apply "$z || out+="▶ [Apply]"
|
|
1891
2052
|
else
|
|
1892
2053
|
(( color )) && out+=" "$b" Apply "$z || out+=" Apply "
|
|
1893
2054
|
fi
|
|
@@ -1928,9 +2089,11 @@ __tt_pv_handle() {
|
|
|
1928
2089
|
if (( help )); then
|
|
1929
2090
|
case $key in
|
|
1930
2091
|
$'\x03') return 1 ;;
|
|
1931
|
-
'?'|esc) help=0 ;;
|
|
2092
|
+
'?'|esc) help=0; return 0 ;;
|
|
2093
|
+
nop) return 0 ;;
|
|
1932
2094
|
esac
|
|
1933
|
-
return 0
|
|
2095
|
+
(( help == 2 )) || return 0
|
|
2096
|
+
help=0
|
|
1934
2097
|
fi
|
|
1935
2098
|
if [[ -n $pick ]]; then
|
|
1936
2099
|
__tt_pv_pick
|
|
@@ -2009,7 +2172,7 @@ __tt_pv_handle() {
|
|
|
2009
2172
|
if (( cur <= 1 )); then
|
|
2010
2173
|
(( ${#rval} )) && cur=${#rval}
|
|
2011
2174
|
else
|
|
2012
|
-
cur=$(( cur - ph +
|
|
2175
|
+
cur=$(( cur - ph + pvhd + 3 ))
|
|
2013
2176
|
(( cur < 1 )) && cur=1
|
|
2014
2177
|
[[ ${rtype[cur]} == rule ]] && cur=$(( cur - 1 ))
|
|
2015
2178
|
fi
|
|
@@ -2018,7 +2181,7 @@ __tt_pv_handle() {
|
|
|
2018
2181
|
if (( cur >= ${#rval} )); then
|
|
2019
2182
|
cur=1
|
|
2020
2183
|
else
|
|
2021
|
-
cur=$(( cur + ph -
|
|
2184
|
+
cur=$(( cur + ph - pvhd - 3 ))
|
|
2022
2185
|
(( cur > ${#rval} )) && cur=${#rval}
|
|
2023
2186
|
[[ ${rtype[cur]} == rule ]] && cur=$(( cur + 1 ))
|
|
2024
2187
|
fi
|
|
@@ -2070,10 +2233,10 @@ __tt_preview() {
|
|
|
2070
2233
|
local -i hub=0 hubleft=0
|
|
2071
2234
|
[[ $mode == hub ]] && hub=1
|
|
2072
2235
|
if [[ ! -t 0 || ! -t 1 ]]; then
|
|
2073
|
-
print -u2 "ttheme $
|
|
2236
|
+
print -u2 "ttheme $mode: needs a terminal"
|
|
2074
2237
|
return 1
|
|
2075
2238
|
fi
|
|
2076
|
-
local orig=$TTHEME_SPEC applied=$TTHEME_SPEC painted=$TTHEME_SPEC flt="" sel="" cn="" cdot="" key="" REPLY="" cur=1 top=1 color=0 pw=80 ph=24 resized=1 expal="" exgrp="" exnext=0 gstep=0 gseed=0 tick=0
|
|
2239
|
+
local orig=$TTHEME_SPEC applied=$TTHEME_SPEC painted=$TTHEME_SPEC flt="" sel="" cn="" cdot="" key="" REPLY="" cur=1 top=1 color=0 pw=80 ph=24 resized=1 expal="" exgrp="" exnext=0 gstep=0 gseed=0 tick=0 pvhd=2 pvsr=1 pvsc=4
|
|
2077
2240
|
local pick="" pk=1 pkdef=1 picked=0 canpick=0 bgcw=0 bgch=0 bgname="" bgshown="" bginc="" osd="" osdt=0
|
|
2078
2241
|
local tune="" tpick="" tf=1 help=0 msg="" msgt=0 an="" bgrel=0 bgmx=0 bgmy=0 bganchor=0 bgcut="" bgnext=0 bgbytes=0 bgstrip="" pvscene="" pvscenes=""
|
|
2079
2242
|
local -i scene=0
|
|
@@ -2082,7 +2245,7 @@ __tt_preview() {
|
|
|
2082
2245
|
local -A bgpic=() bgpics=() bgact=() bgview=() bgswap=() bgthumb=() tsnaps=() pvseek=() bgcolors=() bgprep=() TTHEME_ALIASES=()
|
|
2083
2246
|
local conf=0 cf=1
|
|
2084
2247
|
local -a plabel=(" Default " " This tab ") pkeys=() reach=() csnap=() teframe=()
|
|
2085
|
-
local te=0 tfocus=0 tetop=0 tename=""
|
|
2248
|
+
local te=0 tfocus=0 tetop=0 tewide=0 tbtn=0 tearm=0 tename=""
|
|
2086
2249
|
local -i pvgone=0 bgprepid=0 mrow=0 mcol=0 mclick=0 mwheel=0 mlwheel=0 mlrow=0 mlcol=0
|
|
2087
2250
|
local -F mlast=0
|
|
2088
2251
|
local mact="" mzone="" pvmouse=""
|
|
@@ -2112,6 +2275,8 @@ __tt_preview() {
|
|
|
2112
2275
|
__tt_pv_roll
|
|
2113
2276
|
__tt_pv_rows
|
|
2114
2277
|
[[ -n ${TTHEME_PALETTE[$cn]} ]] && __tt_pv_goto "$cn"
|
|
2278
|
+
__tt_pv_lw
|
|
2279
|
+
(( reply[2] >= 48 )) && help=2
|
|
2115
2280
|
local tty=""
|
|
2116
2281
|
local -i TTHEME_RAW=0
|
|
2117
2282
|
{
|