@kecan0406/ttheme 1.0.47 → 1.0.49
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/bin/ttheme.js +181 -177
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/shell/adapters/_bg.zsh +28 -8
- package/shell/ttheme.zsh +48 -9
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
package/shell/adapters/_bg.zsh
CHANGED
|
@@ -265,12 +265,12 @@ __tt_pv_bg_show() {
|
|
|
265
265
|
local -a p=(${=TTHEME_PALETTE[$name]}) wh at
|
|
266
266
|
local -i cols=$(( pw + 2 * bgmx )) rows=$(( ph + 2 * bgmy ))
|
|
267
267
|
(( ${#p} >= 20 )) || return 0
|
|
268
|
-
(( $2 )) && {
|
|
268
|
+
(( $2 )) && { __tt_bg_forget; bgshown="" bganchor=0 }
|
|
269
269
|
bgname=$name
|
|
270
270
|
__tt_bg_load $name
|
|
271
271
|
if (( ! bgrel )) && [[ $name == "$bginc" && "${bgsize[$name]} ${bgpos[$name]} ${bgop[$name]} ${bgoff[$name]}" == "${bgload[$name]}" ]]; then
|
|
272
272
|
printf '\e_Ga=d,d=i,i=1,q=2\e\\\e_Ga=d,d=i,i=2,q=2\e\\'
|
|
273
|
-
[[ -n $bgshown ]] && printf '\e_Ga=d,d=i,i=%d,q=2\e\\' $bgshown
|
|
273
|
+
[[ -n $bgshown ]] && printf '\e_Ga=d,d=i,i=%d,p=%d,q=2\e\\' $bgshown $bgshown
|
|
274
274
|
bgshown=""
|
|
275
275
|
return 0
|
|
276
276
|
fi
|
|
@@ -304,21 +304,41 @@ __tt_pv_bg_show() {
|
|
|
304
304
|
__tt_bg_crop $img $wh[1] $wh[2] $at[6] $at[8] && id=${REPLY% *} at[6]=${REPLY##* }
|
|
305
305
|
fi
|
|
306
306
|
fi
|
|
307
|
-
[[ -n $bgshown && $bgshown != "$id" ]] && printf '\e_Ga=d,d=i,i=%d,q=2\e\\' $bgshown
|
|
307
|
+
[[ -n $bgshown && $bgshown != "$id" ]] && printf '\e_Ga=d,d=i,i=%d,p=%d,q=2\e\\' $bgshown $bgshown
|
|
308
308
|
bgshown=$id
|
|
309
309
|
[[ -n $id ]] || return 0
|
|
310
310
|
__tt_bg_at $id -1073741826 $(( at[1] - 1 )) $(( at[2] - 1 )) $at[3] $at[4] $at[5] $at[6] $at[7] $at[8]
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
__tt_bg_send() {
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
local -i cost=0
|
|
315
|
+
if [[ -n ${bgsent[$1]} ]]; then
|
|
316
|
+
bgorder=("${(@)bgorder:#${(b)1}}" "$1")
|
|
317
|
+
else
|
|
318
|
+
__tt_bg_dim "$1" && cost=$(( ${bgdim[$1]% *} * ${bgdim[$1]#* } * 4 ))
|
|
319
|
+
bgsent[$1]=$(( ++bgnext + 2 )) bgcost[$1]=$cost
|
|
320
|
+
(( bgbytes += cost ))
|
|
321
|
+
bgorder+=("$1")
|
|
316
322
|
__tt_b64s "$1"
|
|
317
323
|
printf '\e_Ga=t,t=f,f=100,i=%d,q=2;%s\e\\' ${bgsent[$1]} "$REPLY"
|
|
324
|
+
while (( ${#bgorder} > 1 && bgbytes > 134217728 )); do
|
|
325
|
+
printf '\e_Ga=d,d=I,i=%d,q=2\e\\' ${bgsent[$bgorder[1]]}
|
|
326
|
+
(( bgbytes -= bgcost[$bgorder[1]] ))
|
|
327
|
+
unset "bgsent[$bgorder[1]]" "bgcost[$bgorder[1]]"
|
|
328
|
+
shift bgorder
|
|
329
|
+
done
|
|
318
330
|
fi
|
|
319
331
|
REPLY=${bgsent[$1]}
|
|
320
332
|
}
|
|
321
333
|
|
|
334
|
+
__tt_bg_forget() {
|
|
335
|
+
local id
|
|
336
|
+
for id in $bgsent; do
|
|
337
|
+
printf '\e_Ga=d,d=I,i=%d,q=2\e\\' $id
|
|
338
|
+
done
|
|
339
|
+
bgsent=() bgcost=() bgorder=() bgbytes=0
|
|
340
|
+
}
|
|
341
|
+
|
|
322
342
|
__tt_pv_bg_fs() {
|
|
323
343
|
local name=$1
|
|
324
344
|
local -a wh fwh
|
|
@@ -415,7 +435,7 @@ __tt_pv_bg_find() {
|
|
|
415
435
|
done
|
|
416
436
|
[[ -r $TTHEME_CONFIG ]] && source $TTHEME_CONFIG
|
|
417
437
|
err=${${err//$'\n'/ }## #}
|
|
418
|
-
resized=1 bgname="" bgshown=""
|
|
438
|
+
resized=1 bgname="" bgshown="" bgdim=()
|
|
419
439
|
if (( rc == 1 )); then
|
|
420
440
|
msg=${err:-"find failed for $name"} msgt=300
|
|
421
441
|
fi
|
|
@@ -445,7 +465,7 @@ __tt_pv_bg_image() {
|
|
|
445
465
|
err=$(__tt_cli image $name $act 2>&1)
|
|
446
466
|
rc=$?
|
|
447
467
|
err=${${err//$'\n'/ }## #}
|
|
448
|
-
resized=1 bgname="" bgshown=""
|
|
468
|
+
resized=1 bgname="" bgshown="" bgdim=()
|
|
449
469
|
unset "bgsrc[$name]"
|
|
450
470
|
__tt_bg_load $name
|
|
451
471
|
bgload[$name]="" bgedit[$name]=1
|
|
@@ -514,7 +534,7 @@ __tt_pv_bg_panel() {
|
|
|
514
534
|
}
|
|
515
535
|
|
|
516
536
|
__tt_pv_bg_close() {
|
|
517
|
-
(( bgcw )) && printf '\e_Ga=d,d=A,q=2\e\\'
|
|
537
|
+
(( bgcw )) && { printf '\e_Ga=d,d=A,q=2\e\\'; __tt_bg_forget }
|
|
518
538
|
[[ -z $bgcut ]] || { rm -rf -- $bgcut; bgcut="" }
|
|
519
539
|
}
|
|
520
540
|
|
package/shell/ttheme.zsh
CHANGED
|
@@ -89,6 +89,8 @@ __tt_pins_load
|
|
|
89
89
|
|
|
90
90
|
: ${TTHEME_SORT:=abc}
|
|
91
91
|
|
|
92
|
+
: ${TTHEME_BG_BLUR:=0}
|
|
93
|
+
|
|
92
94
|
typeset -g TTHEME_STATE_DIR=${XDG_STATE_HOME:-$HOME/.local/state}/ttheme
|
|
93
95
|
|
|
94
96
|
if [[ $TERM_PROGRAM == WarpTerminal ]]; then
|
|
@@ -562,14 +564,27 @@ __tt_switch() {
|
|
|
562
564
|
}
|
|
563
565
|
|
|
564
566
|
__tt_config() {
|
|
567
|
+
local blur
|
|
565
568
|
if [[ ! -e $TTHEME_CONFIG ]]; then
|
|
566
569
|
mkdir -p ${TTHEME_CONFIG:h} || return 1
|
|
567
570
|
print -r -- "$TTHEME_CONFIG_TEMPLATE" > $TTHEME_CONFIG
|
|
568
571
|
fi
|
|
572
|
+
blur=${(M)${(@f)"$(<$TTHEME_CONFIG)"}:#': ${TTHEME_BG_BLUR:='*}
|
|
569
573
|
${=${VISUAL:-${EDITOR:-vi}}} $TTHEME_CONFIG || return
|
|
574
|
+
[[ ${(M)${(@f)"$(<$TTHEME_CONFIG)"}:#': ${TTHEME_BG_BLUR:='*} == "$blur" ]] || __tt_redraw
|
|
570
575
|
print -r -- "settings apply in new tabs — $TTHEME_CONFIG"
|
|
571
576
|
}
|
|
572
577
|
|
|
578
|
+
__tt_redraw() {
|
|
579
|
+
local out
|
|
580
|
+
out=$(__tt_cli redraw 2>&1) || { [[ -n $out ]] && print -ru2 -- "$out"; return 1 }
|
|
581
|
+
[[ -n $out ]] || return 0
|
|
582
|
+
print -r -- "$out"
|
|
583
|
+
__tt_reload
|
|
584
|
+
(( $+functions[__tt_bg_refresh] )) && __tt_bg_refresh $TTHEME_ORDER
|
|
585
|
+
return 0
|
|
586
|
+
}
|
|
587
|
+
|
|
573
588
|
__tt_config_line() {
|
|
574
589
|
REPLY=": \${$1:=$2}"
|
|
575
590
|
[[ -n ${(M)${(@f)TTHEME_CONFIG_TEMPLATE}:#"# $REPLY"} ]] && REPLY="# $REPLY"
|
|
@@ -1170,12 +1185,32 @@ __tt_pv_conf_save() {
|
|
|
1170
1185
|
__tt_tilde "$TTHEME_CONFIG"
|
|
1171
1186
|
if __tt_config_write "${pairs[@]}"; then
|
|
1172
1187
|
conf=0 msg="saved · $REPLY" msgt=200
|
|
1188
|
+
(( ${pairs[(Ie)TTHEME_BG_BLUR]} )) && __tt_pv_redraw
|
|
1173
1189
|
else
|
|
1174
1190
|
__tt_pv_unconf
|
|
1175
1191
|
msg="could not write $REPLY" msgt=200
|
|
1176
1192
|
fi
|
|
1177
1193
|
}
|
|
1178
1194
|
|
|
1195
|
+
__tt_pv_redraw() {
|
|
1196
|
+
local name out
|
|
1197
|
+
if (( $+functions[__tt_bg_write] )); then
|
|
1198
|
+
for name in ${(k)bgedit}; do
|
|
1199
|
+
__tt_bg_write $name
|
|
1200
|
+
done
|
|
1201
|
+
fi
|
|
1202
|
+
bgedit=()
|
|
1203
|
+
msg="drawing the background pictures again" msgt=300
|
|
1204
|
+
printf '\e[?2026h'
|
|
1205
|
+
__tt_pv_draw
|
|
1206
|
+
__tt_pv_bg_close
|
|
1207
|
+
out=$(__tt_cli redraw 2>&1)
|
|
1208
|
+
bgsrc=() resized=1 bgname="" bgshown="" bgdim=()
|
|
1209
|
+
__tt_reload
|
|
1210
|
+
(( $+functions[__tt_bg_refresh] )) && __tt_bg_refresh $TTHEME_ORDER
|
|
1211
|
+
msg=${${out//$'\n'/ }:-"saved · no background pictures to draw"} msgt=300
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1179
1214
|
__tt_pv_conf_panel() {
|
|
1180
1215
|
local z=$'\e[0m' b=$'\e[1m' d=$'\e[2m' c=$ac on=$'\e[7;1m'$ac var v note
|
|
1181
1216
|
local -a ch sh
|
|
@@ -1219,7 +1254,7 @@ __tt_pv_conf_panel() {
|
|
|
1219
1254
|
done
|
|
1220
1255
|
done
|
|
1221
1256
|
var=${cvars[cf]}
|
|
1222
|
-
note=${cnote[${(P)var}]}
|
|
1257
|
+
note=${cnote[$var:${(P)var}]}
|
|
1223
1258
|
[[ -n $note ]] && out+=$'\e['$(( r0 + ${#cvars} + 1 ))';'$col'H'$d${note[1,end-col+1]}$z
|
|
1224
1259
|
return 0
|
|
1225
1260
|
}
|
|
@@ -1633,17 +1668,21 @@ __tt_preview() {
|
|
|
1633
1668
|
fi
|
|
1634
1669
|
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
|
|
1635
1670
|
local pick="" pk=1 pkdef=1 picked=0 canpick=0 bgcw=0 bgch=0 bgname="" bgshown="" bginc="" osd="" osdt=0
|
|
1636
|
-
local tune="" tsnap="" tf=1 help=0 msg="" msgt=0 an="" bgrel=0 bgmx=0 bgmy=0 bganchor=0 bgcut=""
|
|
1637
|
-
local -
|
|
1671
|
+
local tune="" tsnap="" tf=1 help=0 msg="" msgt=0 an="" bgrel=0 bgmx=0 bgmy=0 bganchor=0 bgcut="" bgnext=0 bgbytes=0
|
|
1672
|
+
local -a bgorder=()
|
|
1673
|
+
local -A bgfrom=() bgsent=() bgcost=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=() bgtunef=() bgofff=() bgimages=()
|
|
1638
1674
|
local conf=0 cf=1
|
|
1639
1675
|
local -a plabel=(" this tab " " default ") csnap=()
|
|
1640
|
-
local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT) clabel=("new tabs" announce "search fx" sort)
|
|
1641
|
-
local -a cchoice=("off seq" "1 0" "typewriter decode glitch" "abc series") cshow=("off seq" "on off" "typewriter decode glitch" "abc series")
|
|
1676
|
+
local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT TTHEME_BG_BLUR) clabel=("new tabs" announce "search fx" sort blur)
|
|
1677
|
+
local -a cchoice=("off seq" "1 0" "typewriter decode glitch" "abc series" "0 1 2 3 4") cshow=("off seq" "on off" "typewriter decode glitch" "abc series" "off 1px 2px 3px 4px")
|
|
1642
1678
|
local -A cnote=(
|
|
1643
|
-
seq "new tabs rotate through palettes" off "new tabs keep the terminal theme"
|
|
1644
|
-
1 "shows the palette notice" 0 "silences the palette notice"
|
|
1645
|
-
typewriter "the search hint types itself" decode "the search hint decodes" glitch "the search hint glitches in"
|
|
1646
|
-
abc "series and palettes by name" series "series in the order added"
|
|
1679
|
+
TTHEME_TAB_PALETTE:seq "new tabs rotate through palettes" TTHEME_TAB_PALETTE:off "new tabs keep the terminal theme"
|
|
1680
|
+
TTHEME_ANNOUNCE:1 "shows the palette notice" TTHEME_ANNOUNCE:0 "silences the palette notice"
|
|
1681
|
+
TTHEME_FX:typewriter "the search hint types itself" TTHEME_FX:decode "the search hint decodes" TTHEME_FX:glitch "the search hint glitches in"
|
|
1682
|
+
TTHEME_SORT:abc "series and palettes by name" TTHEME_SORT:series "series in the order added"
|
|
1683
|
+
TTHEME_BG_BLUR:0 "pictures stay sharp" TTHEME_BG_BLUR:1 "pictures soften a little behind the text"
|
|
1684
|
+
TTHEME_BG_BLUR:2 "pictures soften behind the text" TTHEME_BG_BLUR:3 "pictures blur behind the text"
|
|
1685
|
+
TTHEME_BG_BLUR:4 "pictures blur well behind the text"
|
|
1647
1686
|
)
|
|
1648
1687
|
[[ $mode == pin ]] && pkdef=2 plabel=(" this directory " " and below ")
|
|
1649
1688
|
[[ $mode == init ]] && pkdef=2
|