@kecan0406/ttheme 1.2.0 → 1.2.1
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 +2 -2
- package/bin/ttheme.js +163 -162
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/shell/adapters/_bg.zsh +67 -4
- package/shell/ttheme.zsh +28 -14
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
package/shell/adapters/_bg.zsh
CHANGED
|
@@ -75,12 +75,16 @@ __tt_bg_load() {
|
|
|
75
75
|
bgimages[$name]=${bgimages[$pal]:-1}
|
|
76
76
|
elif [[ -r $dir/$file.conf ]]; then
|
|
77
77
|
lines=("${(@f)$(<$dir/$file.conf)}")
|
|
78
|
+
for line in ${(k)bgcolors[(I)${(b)pal}:*]}; do
|
|
79
|
+
unset "bgcolors[$line]"
|
|
80
|
+
done
|
|
78
81
|
fi
|
|
79
82
|
for line in $lines; do
|
|
80
83
|
case $line in
|
|
81
84
|
'config-file = ?'*.tune.conf) bgtunef[$name]=${line#config-file = \?} ;;
|
|
82
85
|
'config-file = ?'*.off.conf) bgofff[$name]=${line#config-file = \?} ;;
|
|
83
86
|
'# image '*/<->) bgimages[$name]=${line##*/} bgact[$pal]=${${line#\# image }%% *} ;;
|
|
87
|
+
'# colors '*) pd=(${=line#\# colors }); [[ -n $key ]] || bgcolors[$pal:$pd[1]]=$pd[2] ;;
|
|
84
88
|
'# picture '*)
|
|
85
89
|
pd=(${=line#\# picture })
|
|
86
90
|
bgpic[$pal:$pd[1]]=${(j: :)pd[2,-1]}
|
|
@@ -131,6 +135,12 @@ __tt_bg_load() {
|
|
|
131
135
|
fi
|
|
132
136
|
}
|
|
133
137
|
|
|
138
|
+
__tt_bg_coloring() {
|
|
139
|
+
local key=${1##*:}
|
|
140
|
+
[[ $1 == *:* ]] || key=${bgact[$1]}
|
|
141
|
+
REPLY=${bgcolors[${1%:*}:$key]:-tone}
|
|
142
|
+
}
|
|
143
|
+
|
|
134
144
|
__tt_bg_image() {
|
|
135
145
|
REPLY=${bgsrc[$1]}
|
|
136
146
|
[[ ${bgsize[$1]} == fill ]] && REPLY=${bgfill[$1]}
|
|
@@ -472,6 +482,9 @@ __tt_pv_bg_reset() {
|
|
|
472
482
|
for img in ${(k)bgsrc[(I)${(b)1}(|:*)]}; do
|
|
473
483
|
unset "bgsrc[$img]"
|
|
474
484
|
done
|
|
485
|
+
for img in ${(k)bgcolors[(I)${(b)1}:*]}; do
|
|
486
|
+
unset "bgcolors[$img]"
|
|
487
|
+
done
|
|
475
488
|
unset "bgview[$1]" "bgswap[$1]"
|
|
476
489
|
}
|
|
477
490
|
|
|
@@ -532,15 +545,48 @@ __tt_pv_bg_drop() {
|
|
|
532
545
|
__tt_pv_tune_open $name
|
|
533
546
|
}
|
|
534
547
|
|
|
548
|
+
__tt_pv_bg_recolor() {
|
|
549
|
+
local name=$tune was=$tpick key=${tpick##*:} want err REPLY
|
|
550
|
+
local -i rc row=$tf
|
|
551
|
+
[[ $tpick == *:* ]] || key=${bgact[$name]}
|
|
552
|
+
__tt_bg_coloring $tpick
|
|
553
|
+
want=original
|
|
554
|
+
[[ $REPLY == original ]] && want=tone
|
|
555
|
+
__tt_pv_tune_keep
|
|
556
|
+
__tt_pv_bg_commit $name
|
|
557
|
+
msg="Drawing in its own colors"
|
|
558
|
+
[[ $want == tone ]] && msg="Drawing in the palette's tone"
|
|
559
|
+
msgt=300
|
|
560
|
+
printf '\e[?2026h'
|
|
561
|
+
__tt_pv_draw
|
|
562
|
+
__tt_pv_bg_close
|
|
563
|
+
err=$(__tt_cli image $name $want $key 2>&1)
|
|
564
|
+
rc=$?
|
|
565
|
+
err=${${err//$'\n'/ }## #}
|
|
566
|
+
resized=1 bgname="" bgshown="" bgdim=()
|
|
567
|
+
__tt_pv_bg_reset $name
|
|
568
|
+
__tt_bg_load $name
|
|
569
|
+
bgload[$name]="" bgedit[$name]=1
|
|
570
|
+
msg=${err:-"Background · $name"} msgt=$(( rc ? 300 : 200 ))
|
|
571
|
+
[[ -r ${TTHEME_CONFIG:h}/backgrounds/${${name/@/--}/\//--}.conf ]] || return 0
|
|
572
|
+
__tt_pv_tune_open $name
|
|
573
|
+
if [[ $was != "$tpick" ]]; then
|
|
574
|
+
tpick=$was
|
|
575
|
+
__tt_bg_load $tpick
|
|
576
|
+
tsnaps[$tpick]="${bgsize[$tpick]} ${bgpos[$tpick]} ${bgop[$tpick]} ${bgoff[$tpick]}"
|
|
577
|
+
fi
|
|
578
|
+
tf=$row
|
|
579
|
+
}
|
|
580
|
+
|
|
535
581
|
__tt_pv_bg_panel() {
|
|
536
|
-
local name=$1 z=$'\e[0m' b=$'\e[1m' d=$'\e[2m' c=$ac val sty mark REPLY
|
|
537
|
-
local -a labs=(Size Position Opacity) at=(0 3 6) def=(${=bgdef[$1]})
|
|
582
|
+
local name=$1 z=$'\e[0m' b=$'\e[1m' d=$'\e[2m' c=$ac val sty mark choice REPLY
|
|
583
|
+
local -a labs=(Size Position Opacity Colors) at=(0 3 6 7) def=(${=bgdef[$1]})
|
|
538
584
|
local -i r0=$2 col=$3 end=$4 off=${bgoff[$1]} T=$(( $4 - $3 - 21 )) lo=100 hi=100 k i r knob pos=${bgpos[$1]} o tuned
|
|
539
585
|
(( color )) || z= b= d= c=
|
|
540
586
|
(( T < 8 )) && T=8
|
|
541
587
|
(( $+commands[sips] )) && lo=20
|
|
542
588
|
__tt_pv_bg_fs $name && (( REPLY > hi )) && hi=$REPLY
|
|
543
|
-
for k in 1 2 3; do
|
|
589
|
+
for k in 1 2 3 4; do
|
|
544
590
|
r=$(( r0 + at[k] ))
|
|
545
591
|
sty=$d
|
|
546
592
|
(( tf == k && ! off )) && sty=$b
|
|
@@ -551,6 +597,23 @@ __tt_pv_bg_panel() {
|
|
|
551
597
|
out+=" "
|
|
552
598
|
fi
|
|
553
599
|
out+=$sty$labs[k]$z
|
|
600
|
+
if (( k == 4 )); then
|
|
601
|
+
__tt_bg_coloring $name
|
|
602
|
+
val=$REPLY
|
|
603
|
+
out+=$'\e['$r';'$(( col + 12 ))'H'
|
|
604
|
+
for choice in tone original; do
|
|
605
|
+
if (( ! color )); then
|
|
606
|
+
if [[ $choice == $val ]]; then out+="[$choice] "; else out+=" $choice "; fi
|
|
607
|
+
elif [[ $choice != $val ]]; then
|
|
608
|
+
out+=$d" $choice "$z" "
|
|
609
|
+
elif (( tf == k && ! off )); then
|
|
610
|
+
out+=$'\e[7;1m'$c" $choice "$z" "
|
|
611
|
+
else
|
|
612
|
+
out+=$sty" $choice "$z" "
|
|
613
|
+
fi
|
|
614
|
+
done
|
|
615
|
+
continue
|
|
616
|
+
fi
|
|
554
617
|
if (( k == 2 )); then
|
|
555
618
|
for (( i = 1; i <= 9; i++ )); do
|
|
556
619
|
out+=$'\e['$(( r0 + 2 + (i - 1) / 3 ))';'$(( col + 12 + (i - 1) % 3 * 3 ))'H'
|
|
@@ -598,7 +661,7 @@ __tt_pv_bg_panel() {
|
|
|
598
661
|
out+=$'\e['$r';'$end'H'$mark"↺"$z
|
|
599
662
|
fi
|
|
600
663
|
done
|
|
601
|
-
(( split )) && bgstrip="$(( r0 +
|
|
664
|
+
(( split )) && bgstrip="$(( r0 + 9 )) $col $end"
|
|
602
665
|
}
|
|
603
666
|
|
|
604
667
|
__tt_pv_bg_strip() {
|
package/shell/ttheme.zsh
CHANGED
|
@@ -95,6 +95,8 @@ __tt_pins_load
|
|
|
95
95
|
|
|
96
96
|
: ${TTHEME_BG_BLUR:=0}
|
|
97
97
|
|
|
98
|
+
: ${TTHEME_BG_COLORS:=tone}
|
|
99
|
+
|
|
98
100
|
typeset -g TTHEME_STATE_DIR=${XDG_STATE_HOME:-$HOME/.local/state}/ttheme
|
|
99
101
|
|
|
100
102
|
() {
|
|
@@ -1673,11 +1675,16 @@ __tt_pv_foot() {
|
|
|
1673
1675
|
badge='IMAGE EDIT' kk=(↑↓ ←→ '=' +) kl=(field step reset "reset all")
|
|
1674
1676
|
if (( tf == 2 )); then
|
|
1675
1677
|
kl[2]=move kk+=(1-9) kl+=(place)
|
|
1678
|
+
elif (( tf == 4 )); then
|
|
1679
|
+
kl[2]=switch kk=(${kk:#'='}) kl=("${(@)kl[1,2]}" "reset all")
|
|
1676
1680
|
else
|
|
1677
1681
|
kk+=(⇧←→) kl+=(×10)
|
|
1678
1682
|
fi
|
|
1679
|
-
|
|
1680
|
-
|
|
1683
|
+
if (( bgoff[$tpick] )); then
|
|
1684
|
+
kk+=(space enter) kl+=(show keep)
|
|
1685
|
+
else
|
|
1686
|
+
kk+=(c space enter) kl+=(colors hide keep)
|
|
1687
|
+
fi
|
|
1681
1688
|
__tt_pv_bg_images $tune
|
|
1682
1689
|
(( REPLY > 1 )) && { kk+=(', .' D); kl+=("image ×$REPLY" remove) }
|
|
1683
1690
|
__tt_pv_bg_findable $tune && { kk+=(f); kl+=(find) }
|
|
@@ -1773,8 +1780,8 @@ __tt_pv_help() {
|
|
|
1773
1780
|
"enter · esc restores $back"
|
|
1774
1781
|
)
|
|
1775
1782
|
if (( bgcw )); then
|
|
1776
|
-
hk+=("Tune bg" "" "" "" "" "")
|
|
1777
|
-
hv+=("tab · finds one on the boorus, or takes your own, if none" "↑↓ field ←→ step ⇧←→ ×10 1-9 place" "= resets a field · + resets all" "space hides · enter keeps · esc undoes" ", . other pictures · D removes one" "f adds one from the boorus or your own")
|
|
1783
|
+
hk+=("Tune bg" "" "" "" "" "" "")
|
|
1784
|
+
hv+=("tab · finds one on the boorus, or takes your own, if none" "↑↓ field ←→ step ⇧←→ ×10 1-9 place" "= resets a field · + resets all" "space hides · enter keeps · esc undoes" "c tone ↔ the picture's own colors" ", . other pictures · D removes one" "f adds one from the boorus or your own")
|
|
1778
1785
|
fi
|
|
1779
1786
|
hk+=(Config "")
|
|
1780
1787
|
hv+=("alt-c · ↑↓ setting ←→ value" "enter saves · esc undoes")
|
|
@@ -1890,9 +1897,14 @@ __tt_pv_tune() {
|
|
|
1890
1897
|
local name
|
|
1891
1898
|
case $key in
|
|
1892
1899
|
$'\x03') return 1 ;;
|
|
1893
|
-
up) tf=$(( tf > 1 ? tf - 1 :
|
|
1894
|
-
down) tf=$(( tf <
|
|
1900
|
+
up) tf=$(( tf > 1 ? tf - 1 : 4 )) ;;
|
|
1901
|
+
down) tf=$(( tf < 4 ? tf + 1 : 1 )) ;;
|
|
1902
|
+
c) (( bgoff[$tpick] )) || __tt_pv_bg_recolor ;;
|
|
1895
1903
|
left|right|sleft|sright)
|
|
1904
|
+
if (( tf == 4 )); then
|
|
1905
|
+
(( bgoff[$tpick] )) || __tt_pv_bg_recolor
|
|
1906
|
+
return 0
|
|
1907
|
+
fi
|
|
1896
1908
|
[[ $key == *left ]] && n=-1
|
|
1897
1909
|
[[ $key == s* ]] && (( tf != 2 )) && n=$(( n * 10 ))
|
|
1898
1910
|
__tt_pv_bg_adjust ${fields[tf]} $n
|
|
@@ -1902,7 +1914,7 @@ __tt_pv_tune() {
|
|
|
1902
1914
|
__tt_pv_bg_adjust at $key
|
|
1903
1915
|
;;
|
|
1904
1916
|
' ') __tt_pv_bg_adjust on ;;
|
|
1905
|
-
'=') __tt_pv_bg_adjust def $tf ;;
|
|
1917
|
+
'=') (( tf == 4 )) || __tt_pv_bg_adjust def $tf ;;
|
|
1906
1918
|
'+') __tt_pv_bg_adjust def ;;
|
|
1907
1919
|
',') __tt_pv_bg_pick -1 ;;
|
|
1908
1920
|
'.') __tt_pv_bg_pick 1 ;;
|
|
@@ -2312,11 +2324,11 @@ __tt_pv_draw() {
|
|
|
2312
2324
|
src=" · $k/${#held}"
|
|
2313
2325
|
fi
|
|
2314
2326
|
__tt_pv_bg_title $(( lw - ${#tune} - 6 )) "$src"
|
|
2315
|
-
__tt_pv_head $(( ph -
|
|
2316
|
-
__tt_pv_bg_panel $tpick $(( ph -
|
|
2327
|
+
__tt_pv_head $(( ph - 10 )) 1 $lw $tune "$REPLY" $state
|
|
2328
|
+
__tt_pv_bg_panel $tpick $(( ph - 9 )) 1 $lw
|
|
2317
2329
|
elif (( conf )); then
|
|
2318
|
-
__tt_pv_head $(( ph -
|
|
2319
|
-
__tt_pv_conf_panel $(( ph -
|
|
2330
|
+
__tt_pv_head $(( ph - 8 )) 1 $lw Config
|
|
2331
|
+
__tt_pv_conf_panel $(( ph - 7 )) 1 $lw
|
|
2320
2332
|
fi
|
|
2321
2333
|
(( help )) && __tt_pv_help
|
|
2322
2334
|
fi
|
|
@@ -2611,11 +2623,11 @@ __tt_preview() {
|
|
|
2611
2623
|
local -i scene=0
|
|
2612
2624
|
local -a bgorder=()
|
|
2613
2625
|
local -A bgfrom=() bgurl=() bgby=() bgsent=() bgcost=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=() bgtunef=() bgofff=() bgimages=()
|
|
2614
|
-
local -A bgpic=() bgpics=() bgact=() bgview=() bgswap=() bgthumb=() tsnaps=() pvseek=()
|
|
2626
|
+
local -A bgpic=() bgpics=() bgact=() bgview=() bgswap=() bgthumb=() tsnaps=() pvseek=() bgcolors=()
|
|
2615
2627
|
local conf=0 cf=1
|
|
2616
2628
|
local -a plabel=(" This tab " " Default ") pkeys=() reach=() csnap=()
|
|
2617
|
-
local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT TTHEME_BG_BLUR) clabel=("New tabs" Announce "Search fx" Sort Blur)
|
|
2618
|
-
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")
|
|
2629
|
+
local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT TTHEME_BG_BLUR TTHEME_BG_COLORS) clabel=("New tabs" Announce "Search fx" Sort Blur Colors)
|
|
2630
|
+
local -a cchoice=("off seq" "1 0" "typewriter decode glitch" "abc series" "0 1 2 3 4" "tone original") cshow=("off seq" "on off" "typewriter decode glitch" "abc series" "off 1px 2px 3px 4px" "tone original")
|
|
2619
2631
|
local -A cnote=(
|
|
2620
2632
|
TTHEME_TAB_PALETTE:seq "New tabs rotate through palettes" TTHEME_TAB_PALETTE:off "New tabs keep the terminal theme"
|
|
2621
2633
|
TTHEME_ANNOUNCE:1 "Shows the palette notice" TTHEME_ANNOUNCE:0 "Silences the palette notice"
|
|
@@ -2624,6 +2636,8 @@ __tt_preview() {
|
|
|
2624
2636
|
TTHEME_BG_BLUR:0 "Pictures stay sharp" TTHEME_BG_BLUR:1 "Pictures soften a little behind the text"
|
|
2625
2637
|
TTHEME_BG_BLUR:2 "Pictures soften behind the text" TTHEME_BG_BLUR:3 "Pictures blur behind the text"
|
|
2626
2638
|
TTHEME_BG_BLUR:4 "Pictures blur well behind the text"
|
|
2639
|
+
TTHEME_BG_COLORS:tone "New pictures are tinted in one color of the palette"
|
|
2640
|
+
TTHEME_BG_COLORS:original "New pictures keep their own colors"
|
|
2627
2641
|
)
|
|
2628
2642
|
[[ $mode == pin ]] && __tt_pin_scopes "$pdir"
|
|
2629
2643
|
[[ $mode == init ]] && pkdef=2
|