@kecan0406/ttheme 1.0.37 → 1.0.40
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 +114 -113
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/shell/adapters/_bg.zsh +29 -13
- package/shell/adapters/_osc.zsh +40 -17
- package/shell/adapters/ghostty.zsh +4 -12
- package/shell/adapters/iterm2.zsh +3 -11
- package/shell/adapters/kitty.zsh +3 -11
- package/shell/adapters/terminal-app.zsh +8 -13
- package/shell/ttheme.zsh +9 -4
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
package/shell/adapters/_bg.zsh
CHANGED
|
@@ -8,6 +8,14 @@ __tt_ghostty_shown() {
|
|
|
8
8
|
REPLY=${REPLY%.conf}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
__tt_put() {
|
|
12
|
+
local f=$1
|
|
13
|
+
shift
|
|
14
|
+
print -rl -- "$@" > $f.$$ && mv -f -- $f.$$ $f && return 0
|
|
15
|
+
rm -f -- $f.$$
|
|
16
|
+
return 1
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
__tt_bg_saved() {
|
|
12
20
|
local REPLY
|
|
13
21
|
(( ${TTHEME_TERMINALS[(Ie)iterm2]} )) && __tt_cli image $1 tuned
|
|
@@ -85,10 +93,18 @@ __tt_bg_path() {
|
|
|
85
93
|
__tt_bg_load() {
|
|
86
94
|
local name=$1 dir=${TTHEME_CONFIG:h}/backgrounds img="" fit=contain op=1 pos=center f line stem="" size=100 REPLY
|
|
87
95
|
local -i at=5
|
|
88
|
-
local -a fills
|
|
96
|
+
local -a fills lines
|
|
89
97
|
(( ${+bgsrc[$name]} )) && return 0
|
|
90
|
-
bgfrom[$name]=""
|
|
91
|
-
|
|
98
|
+
bgfrom[$name]="" bgtunef[$name]=$name.tune.conf bgofff[$name]=$name.off.conf bgimages[$name]=1
|
|
99
|
+
[[ -r $dir/$name.conf ]] && lines=("${(@f)$(<$dir/$name.conf)}")
|
|
100
|
+
for line in $lines; do
|
|
101
|
+
case $line in
|
|
102
|
+
'config-file = ?'*.tune.conf) bgtunef[$name]=${line#config-file = \?} ;;
|
|
103
|
+
'config-file = ?'*.off.conf) bgofff[$name]=${line#config-file = \?} ;;
|
|
104
|
+
'# image '*/<->) bgimages[$name]=${line##*/} ;;
|
|
105
|
+
esac
|
|
106
|
+
done
|
|
107
|
+
for f in $dir/$name.conf $dir/${bgtunef[$name]}; do
|
|
92
108
|
if [[ -r $f ]]; then
|
|
93
109
|
for line in "${(@f)$(<$f)}"; do
|
|
94
110
|
case $line in
|
|
@@ -114,7 +130,7 @@ __tt_bg_load() {
|
|
|
114
130
|
[[ $f == *.tune.conf ]] || bgdef[$name]="$size $at $op" bgbase[$name]=$REPLY
|
|
115
131
|
done
|
|
116
132
|
bgsize[$name]=$size bgpos[$name]=$at bgop[$name]=$op bgoff[$name]=0 bgshot[$name]="" bgshotkey[$name]="" bgfocus[$name]=50
|
|
117
|
-
[[ -e $dir/$name
|
|
133
|
+
[[ -e $dir/${bgofff[$name]} ]] && bgoff[$name]=1
|
|
118
134
|
bgload[$name]="$size $at $op ${bgoff[$name]}"
|
|
119
135
|
[[ $REPLY == *@<20-999>-*-<->x<->.png ]] && bgshot[$name]=$REPLY bgshotkey[$name]="$size $at"
|
|
120
136
|
if [[ -n $stem ]]; then
|
|
@@ -175,11 +191,11 @@ __tt_bg_include() {
|
|
|
175
191
|
local conf=${TTHEME_CONFIG:h}/backgrounds/$1.conf line
|
|
176
192
|
local -a lines=() add=()
|
|
177
193
|
[[ -r $conf ]] && lines=("${(@f)$(<$conf)}")
|
|
178
|
-
for line in "config-file = ?$1.tune.conf" "config-file = ?$1.off.conf"; do
|
|
194
|
+
for line in "config-file = ?${bgtunef[$1]:-$1.tune.conf}" "config-file = ?${bgofff[$1]:-$1.off.conf}"; do
|
|
179
195
|
(( ${lines[(Ie)$line]} )) || add+=("$line")
|
|
180
196
|
done
|
|
181
197
|
(( ${#add} )) || return 0
|
|
182
|
-
mkdir -p ${conf:h} &&
|
|
198
|
+
mkdir -p ${conf:h} && __tt_put $conf "${lines[@]}" "${add[@]}"
|
|
183
199
|
}
|
|
184
200
|
|
|
185
201
|
__tt_bg_write() {
|
|
@@ -190,7 +206,7 @@ __tt_bg_write() {
|
|
|
190
206
|
[[ -r $dir/$name.conf ]] || return 0
|
|
191
207
|
__tt_bg_include $name || return 1
|
|
192
208
|
if [[ "$size ${bgpos[$1]} ${bgop[$1]}" == "${bgdef[$1]}" ]]; then
|
|
193
|
-
rm -f -- $dir/$
|
|
209
|
+
rm -f -- $dir/${bgtunef[$1]}
|
|
194
210
|
else
|
|
195
211
|
shape=$size
|
|
196
212
|
[[ $size == <20-100> && $pos != center ]] && ! __tt_bg_aligns && shape=window
|
|
@@ -220,12 +236,12 @@ __tt_bg_write() {
|
|
|
220
236
|
;;
|
|
221
237
|
esac
|
|
222
238
|
__tt_tilde "$img"
|
|
223
|
-
|
|
239
|
+
__tt_put $dir/${bgtunef[$1]} "background-image = $REPLY" "background-image-fit = $fit" "background-image-position = $pos" "background-image-opacity = ${bgop[$1]}" || return 1
|
|
224
240
|
fi
|
|
225
241
|
if (( bgoff[$1] )); then
|
|
226
|
-
|
|
242
|
+
__tt_put $dir/${bgofff[$1]} "background-image =" || return 1
|
|
227
243
|
else
|
|
228
|
-
rm -f -- $dir/$
|
|
244
|
+
rm -f -- $dir/${bgofff[$1]}
|
|
229
245
|
fi
|
|
230
246
|
if [[ $src == /*.png ]]; then
|
|
231
247
|
for f in ${src%.png}@<20-999>-*.png(N); do
|
|
@@ -239,7 +255,7 @@ __tt_pv_bg_open() {
|
|
|
239
255
|
bgcw=0 bgch=0 bginc="" bgrel=0 bgmx=0 bgmy=0 bganchor=0
|
|
240
256
|
local REPLY
|
|
241
257
|
__tt_bg_shown && bginc=$REPLY
|
|
242
|
-
(( TTHEME_TMUX )) || __tt_bg_cells
|
|
258
|
+
(( TTHEME_TMUX )) || { __tt_bg_cells; TTHEME_TYPED= }
|
|
243
259
|
}
|
|
244
260
|
|
|
245
261
|
__tt_pv_bg_show() {
|
|
@@ -409,8 +425,8 @@ __tt_pv_bg_find() {
|
|
|
409
425
|
}
|
|
410
426
|
|
|
411
427
|
__tt_pv_bg_images() {
|
|
412
|
-
|
|
413
|
-
REPLY=$
|
|
428
|
+
__tt_bg_load $1
|
|
429
|
+
REPLY=${bgimages[$1]:-1}
|
|
414
430
|
}
|
|
415
431
|
|
|
416
432
|
__tt_pv_bg_image() {
|
package/shell/adapters/_osc.zsh
CHANGED
|
@@ -75,32 +75,55 @@ __tt_pv_bg_close() { : }
|
|
|
75
75
|
|
|
76
76
|
__tt_pv_bg_save() { : }
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (( TTHEME_TMUX )); then
|
|
82
|
-
REPLY=$(tmux show -qv @ttheme_bg 2>/dev/null)
|
|
83
|
-
[[ $REPLY == \#* ]] && return 0
|
|
84
|
-
REPLY=""
|
|
85
|
-
fi
|
|
86
|
-
exec {fd}<>/dev/tty 2>/dev/null || return 1
|
|
78
|
+
zmodload zsh/system
|
|
79
|
+
|
|
80
|
+
typeset -g TTHEME_TYPED=""
|
|
87
81
|
|
|
88
|
-
|
|
82
|
+
__tt_ask() {
|
|
83
|
+
setopt localoptions extendedglob
|
|
84
|
+
local fd saved buf="" chunk seqs=$'\e[]_P][^\a\e]#(\a|\e\\\\)|\e\\[[0-?]#[ -/]#[@-~]|\e[^][_P]'
|
|
85
|
+
local -a match mbegin mend
|
|
86
|
+
REPLY=""
|
|
87
|
+
{ exec {fd}<>/dev/tty } 2>/dev/null || return 1
|
|
88
|
+
saved=$(stty -g <&$fd 2>/dev/null && stty raw -echo min 0 time 3 <&$fd 2>/dev/null)
|
|
89
89
|
if [[ -z $saved ]]; then
|
|
90
90
|
exec {fd}>&-
|
|
91
91
|
return 1
|
|
92
92
|
fi
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
[[ $resp == *$'\e\\' || $resp == *$'\a' ]] && break
|
|
99
|
-
(( ${#resp} < 64 )) || break
|
|
93
|
+
printf '%s\e[5n' "$1" >&$fd
|
|
94
|
+
while sysread -i $fd -s 4096 chunk 2>/dev/null; do
|
|
95
|
+
buf+=$chunk
|
|
96
|
+
[[ $buf == *$'\e[0n'* ]] && break
|
|
97
|
+
(( ${#buf} < 16384 )) || break
|
|
100
98
|
done
|
|
101
99
|
stty "$saved" <&$fd 2>/dev/null
|
|
102
100
|
exec {fd}>&-
|
|
101
|
+
while [[ $buf == (#b)([^$'\e']#)(${~seqs})(*) ]]; do
|
|
102
|
+
TTHEME_TYPED+=$match[1] REPLY+=$match[2] buf=$match[-1]
|
|
103
|
+
done
|
|
104
|
+
[[ $buf == $'\e'* ]] || TTHEME_TYPED+=$buf
|
|
105
|
+
REPLY=${REPLY%$'\e[0n'}
|
|
106
|
+
}
|
|
103
107
|
|
|
108
|
+
__tt_typed() {
|
|
109
|
+
[[ -n $TTHEME_TYPED ]] || return 0
|
|
110
|
+
zle -U -- "$TTHEME_TYPED"
|
|
111
|
+
TTHEME_TYPED=
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
__tt_start_bg() { __tt_query_bg }
|
|
115
|
+
|
|
116
|
+
__tt_query_bg() {
|
|
117
|
+
local resp
|
|
118
|
+
REPLY=""
|
|
119
|
+
if (( TTHEME_TMUX )); then
|
|
120
|
+
REPLY=$(tmux show -qv @ttheme_bg 2>/dev/null)
|
|
121
|
+
[[ $REPLY == \#* ]] && return 0
|
|
122
|
+
REPLY=""
|
|
123
|
+
fi
|
|
124
|
+
__tt_ask $'\e]11;?\e\\' || return 1
|
|
125
|
+
resp=$REPLY
|
|
126
|
+
REPLY=""
|
|
104
127
|
[[ $resp == *rgb:* ]] || return 1
|
|
105
128
|
local -a parts=(${(s:/:)${${resp#*rgb:}%%[^0-9A-Fa-f/]*}})
|
|
106
129
|
(( ${#parts} >= 3 )) || return 1
|
|
@@ -24,11 +24,11 @@ __tt_shown() {
|
|
|
24
24
|
[[ $was == $1 ]] && return 1
|
|
25
25
|
[[ -r $dir/$1.conf || ( -n $was && -r $dir/$was.conf ) ]] || return 1
|
|
26
26
|
[[ -d $dir ]] || mkdir -p $dir || return 1
|
|
27
|
-
|
|
27
|
+
__tt_put $dir/shown.conf "config-file = ?$1.conf"
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
__tt_bg_cells() {
|
|
31
|
-
local
|
|
31
|
+
local REPLY resp line v f
|
|
32
32
|
local -i px=2 py=2 fs=0 sc=2
|
|
33
33
|
for f in ${XDG_CONFIG_HOME:-$HOME/.config}/ghostty/config; do
|
|
34
34
|
[[ -r $f ]] || continue
|
|
@@ -41,16 +41,8 @@ __tt_bg_cells() {
|
|
|
41
41
|
esac
|
|
42
42
|
done
|
|
43
43
|
done
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
stty raw -echo min 0 time 3 <&$fd 2>/dev/null
|
|
47
|
-
printf '\e_Ga=t,f=24,s=1,v=1,i=1,q=2;AAAA\e\\\e_Ga=p,i=1,p=9,P=999998,Q=1,C=1,q=1\e\\\e_Ga=d,d=i,i=1,p=9,q=2\e\\\e[16t' >&$fd
|
|
48
|
-
while IFS= read -r -s -k 1 -t 1 -u $fd c 2>/dev/null; do
|
|
49
|
-
resp+=$c
|
|
50
|
-
[[ $resp == *'[6;'<1->';'<1->t ]] && break
|
|
51
|
-
done
|
|
52
|
-
stty "$saved" <&$fd 2>/dev/null
|
|
53
|
-
exec {fd}>&-
|
|
44
|
+
__tt_ask $'\e_Ga=t,f=24,s=1,v=1,i=1,q=2;AAAA\e\\\e_Ga=p,i=1,p=9,P=999998,Q=1,C=1,q=1\e\\\e_Ga=d,d=i,i=1,p=9,q=2\e\\\e[16t' || return 0
|
|
45
|
+
resp=$REPLY
|
|
54
46
|
[[ $resp == *'[6;'<1->';'<1->t ]] || return 0
|
|
55
47
|
[[ $resp == *$'\e_G'*';E'* ]] && bgrel=1
|
|
56
48
|
resp=${${resp##*\[6;}%t}
|
|
@@ -39,18 +39,10 @@ __tt_unshown() {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
__tt_bg_cells() {
|
|
42
|
-
local
|
|
42
|
+
local REPLY resp
|
|
43
43
|
local -a p
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
stty raw -echo min 0 time 3 <&$fd 2>/dev/null
|
|
47
|
-
printf '\e]1337;ReportCellSize\a' >&$fd
|
|
48
|
-
while IFS= read -r -s -k 1 -t 1 -u $fd c 2>/dev/null; do
|
|
49
|
-
resp+=$c
|
|
50
|
-
[[ $resp == *ReportCellSize=*($'\a'|$'\e\\') ]] && break
|
|
51
|
-
done
|
|
52
|
-
stty "$saved" <&$fd 2>/dev/null
|
|
53
|
-
exec {fd}>&-
|
|
44
|
+
__tt_ask $'\e]1337;ReportCellSize\a' || return 0
|
|
45
|
+
resp=$REPLY
|
|
54
46
|
[[ $resp == *ReportCellSize=*($'\a'|$'\e\\') ]] || return 0
|
|
55
47
|
p=(${(s:;:)${${resp##*ReportCellSize=}%%($'\a'|$'\e\\')*}})
|
|
56
48
|
(( ${#p} == 3 )) || return 0
|
package/shell/adapters/kitty.zsh
CHANGED
|
@@ -32,17 +32,9 @@ __tt_bg_shown() { REPLY=$TTHEME_KITTY_SHOWN }
|
|
|
32
32
|
__tt_bg_refresh() { (( ${@[(Ie)$TTHEME_KITTY_SHOWN]} )) && __tt_kitty_var ttheme_shown $TTHEME_KITTY_SHOWN }
|
|
33
33
|
|
|
34
34
|
__tt_bg_cells() {
|
|
35
|
-
local
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
stty raw -echo min 0 time 3 <&$fd 2>/dev/null
|
|
39
|
-
printf '\e[16t' >&$fd
|
|
40
|
-
while IFS= read -r -s -k 1 -t 1 -u $fd c 2>/dev/null; do
|
|
41
|
-
resp+=$c
|
|
42
|
-
[[ $resp == *'[6;'<1->';'<1->t ]] && break
|
|
43
|
-
done
|
|
44
|
-
stty "$saved" <&$fd 2>/dev/null
|
|
45
|
-
exec {fd}>&-
|
|
35
|
+
local REPLY resp
|
|
36
|
+
__tt_ask $'\e[16t' || return 0
|
|
37
|
+
resp=$REPLY
|
|
46
38
|
[[ $resp == *'[6;'<1->';'<1->t ]] || return 0
|
|
47
39
|
resp=${${resp##*\[6;}%t}
|
|
48
40
|
bgch=${resp%;*} bgcw=${resp#*;}
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
typeset -g TTHEME_TERMINAL_BASE=""
|
|
2
2
|
|
|
3
3
|
__tt_terminal_base() {
|
|
4
|
-
local
|
|
4
|
+
local REPLY resp q=$'\e]11;?\e\\\e]10;?\e\\\e]12;?\e\\\e]17;?\e\\' e v i
|
|
5
5
|
local -a p
|
|
6
6
|
local -A got
|
|
7
7
|
for i in {0..15}; do q+=$'\e]4;'$i$';?\e\\'; done
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[[ -n $saved ]] || { exec {fd}>&-; return 1 }
|
|
11
|
-
stty raw -echo min 0 time 3 <&$fd 2>/dev/null
|
|
12
|
-
printf '%s\e[5n' $q >&$fd
|
|
13
|
-
while IFS= read -r -k 1 -u $fd c 2>/dev/null; do
|
|
14
|
-
resp+=$c
|
|
15
|
-
[[ $resp == *$'\e[0n' ]] && break
|
|
16
|
-
(( ${#resp} < 2048 )) || break
|
|
17
|
-
done
|
|
18
|
-
stty "$saved" <&$fd 2>/dev/null
|
|
19
|
-
exec {fd}>&-
|
|
8
|
+
__tt_ask $q || return 1
|
|
9
|
+
resp=$REPLY
|
|
20
10
|
for e in ${(ps:\e]:)resp}; do
|
|
21
11
|
[[ $e == *';rgb:'* ]] || continue
|
|
22
12
|
p=(${(s:/:)${${e#*rgb:}%%[^0-9A-Fa-f/]*}})
|
|
@@ -27,6 +17,11 @@ __tt_terminal_base() {
|
|
|
27
17
|
(( ${#${=v}} == 20 )) && TTHEME_TERMINAL_BASE=$v
|
|
28
18
|
}
|
|
29
19
|
|
|
20
|
+
__tt_start_bg() {
|
|
21
|
+
REPLY=${TTHEME_TERMINAL_BASE%% *}
|
|
22
|
+
[[ -n $REPLY ]]
|
|
23
|
+
}
|
|
24
|
+
|
|
30
25
|
__tt_osc_reset() {
|
|
31
26
|
[[ -n $TTHEME_TERMINAL_BASE ]] && __tt_osc_apply "$TTHEME_TERMINAL_BASE"
|
|
32
27
|
return 0
|
package/shell/ttheme.zsh
CHANGED
|
@@ -31,7 +31,10 @@ __tt_gone() {
|
|
|
31
31
|
for hook in precmd:__tt_fresh precmd:__tt_precmd precmd:__tt_unmux preexec:__tt_preexec preexec:__tt_mux chpwd:__tt_chpwd; do
|
|
32
32
|
add-zsh-hook -d ${hook%%:*} ${hook#*:}
|
|
33
33
|
done
|
|
34
|
-
(( $+functions[add-zle-hook-widget] ))
|
|
34
|
+
if (( $+functions[add-zle-hook-widget] )); then
|
|
35
|
+
add-zle-hook-widget -d line-init __tt_focus_on
|
|
36
|
+
add-zle-hook-widget -d line-init __tt_typed
|
|
37
|
+
fi
|
|
35
38
|
unfunction ttheme
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -1546,7 +1549,7 @@ __tt_preview() {
|
|
|
1546
1549
|
local orig=$TTHEME_SPEC applied=$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
|
|
1547
1550
|
local pick="" pk=1 pkdef=1 picked=0 canpick=0 bgcw=0 bgch=0 bgname="" bgshown="" bginc="" osd="" osdt=0
|
|
1548
1551
|
local tune="" tsnap="" tf=1 help=0 msg="" msgt=0 an="" bgrel=0 bgmx=0 bgmy=0 bganchor=0 bgcut=""
|
|
1549
|
-
local -A bgfrom=() bgsent=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=()
|
|
1552
|
+
local -A bgfrom=() bgsent=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=() bgtunef=() bgofff=() bgimages=()
|
|
1550
1553
|
local conf=0 cf=1
|
|
1551
1554
|
local -a plabel=(" this tab " " default ") csnap=()
|
|
1552
1555
|
local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT) clabel=("new tabs" announce "search fx" sort)
|
|
@@ -1691,7 +1694,7 @@ if __tt_active; then
|
|
|
1691
1694
|
if [[ -n $TTHEME_SPEC ]]; then
|
|
1692
1695
|
:
|
|
1693
1696
|
elif [[ $TTHEME_TAB_PALETTE == off ]]; then
|
|
1694
|
-
if
|
|
1697
|
+
if __tt_start_bg; then
|
|
1695
1698
|
for k in ${(k)TTHEME_PALETTE}; do
|
|
1696
1699
|
[[ ${TTHEME_PALETTE[$k]%% *} == "$REPLY" ]] && { TTHEME_SPEC=$TTHEME_PALETTE[$k]; break }
|
|
1697
1700
|
done
|
|
@@ -1703,7 +1706,9 @@ if __tt_active; then
|
|
|
1703
1706
|
fi
|
|
1704
1707
|
__tt_dir_sync
|
|
1705
1708
|
}
|
|
1706
|
-
autoload -Uz add-zsh-hook
|
|
1709
|
+
autoload -Uz add-zsh-hook add-zle-hook-widget
|
|
1710
|
+
zle -N __tt_typed
|
|
1711
|
+
add-zle-hook-widget line-init __tt_typed
|
|
1707
1712
|
add-zsh-hook chpwd __tt_chpwd
|
|
1708
1713
|
add-zsh-hook precmd __tt_fresh
|
|
1709
1714
|
if (( ! TTHEME_TMUX )); then
|