@kecan0406/ttheme 1.0.36 → 1.0.38

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.36",
2
+ "version": "1.0.38",
3
3
  "gate": [
4
4
  {
5
5
  "rule": "foreground",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kecan0406/ttheme",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "ttheme": "bin/ttheme.js"
@@ -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
- for f in $dir/$name.conf $dir/$name.tune.conf; do
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.off.conf ]] && bgoff[$name]=1
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} && print -rl -- "${lines[@]}" "${add[@]}" > $conf
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/$name.tune.conf
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
- print -rl -- "background-image = $REPLY" "background-image-fit = $fit" "background-image-position = $pos" "background-image-opacity = ${bgop[$1]}" > $dir/$name.tune.conf || return 1
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
- print -r -- "background-image =" > $dir/$name.off.conf || return 1
242
+ __tt_put $dir/${bgofff[$1]} "background-image =" || return 1
227
243
  else
228
- rm -f -- $dir/$name.off.conf
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
@@ -409,8 +425,8 @@ __tt_pv_bg_find() {
409
425
  }
410
426
 
411
427
  __tt_pv_bg_images() {
412
- local -a shelf=(${TTHEME_CONFIG:h}/backgrounds/shelf/$1/*(N/))
413
- REPLY=$(( ${#shelf} + 1 ))
428
+ __tt_bg_load $1
429
+ REPLY=${bgimages[$1]:-1}
414
430
  }
415
431
 
416
432
  __tt_pv_bg_image() {
@@ -24,7 +24,7 @@ __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
- print -r -- "config-file = ?$1.conf" > $dir/shown.conf
27
+ __tt_put $dir/shown.conf "config-file = ?$1.conf"
28
28
  }
29
29
 
30
30
  __tt_bg_cells() {
@@ -1,8 +1,10 @@
1
1
  #!/bin/zsh -f
2
2
 
3
- source ${0:A:h}/ttheme.zsh
3
+ config=${XDG_CONFIG_HOME:-$HOME/.config}/ttheme/config.zsh
4
+ [[ -r $config ]] && source $config
4
5
 
5
6
  if [[ ${TTHEME_TAB_PALETTE:-off} != off ]]; then
7
+ source ${0:A:h}/ttheme.zsh
6
8
  __tt_next
7
9
  __tt_apply "$REPLY"
8
10
  export TTHEME_SPEC=$REPLY
package/shell/ttheme.zsh CHANGED
@@ -31,6 +31,7 @@ __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] )) && add-zle-hook-widget -d line-init __tt_focus_on
34
35
  unfunction ttheme
35
36
  }
36
37
 
@@ -243,10 +244,9 @@ __tt_sync() {
243
244
  __tt_shown "$REPLY" && __tt_reload
244
245
  }
245
246
 
246
- __tt_precmd() {
247
- printf '\e[?1004h'
248
- __tt_sync
249
- }
247
+ __tt_precmd() { __tt_sync }
248
+
249
+ __tt_focus_on() { printf '\e[?1004h' }
250
250
 
251
251
  __tt_preexec() { printf '\e[?1004l' }
252
252
 
@@ -282,6 +282,9 @@ __tt_bind_focus() {
282
282
  local k
283
283
  zle -N __tt_focus
284
284
  zle -N __tt_blur
285
+ zle -N __tt_focus_on
286
+ autoload -Uz add-zle-hook-widget
287
+ add-zle-hook-widget line-init __tt_focus_on
285
288
  for k in emacs viins vicmd; do
286
289
  bindkey -M $k '^[[I' __tt_focus
287
290
  bindkey -M $k '^[[O' __tt_blur
@@ -1543,7 +1546,7 @@ __tt_preview() {
1543
1546
  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
1544
1547
  local pick="" pk=1 pkdef=1 picked=0 canpick=0 bgcw=0 bgch=0 bgname="" bgshown="" bginc="" osd="" osdt=0
1545
1548
  local tune="" tsnap="" tf=1 help=0 msg="" msgt=0 an="" bgrel=0 bgmx=0 bgmy=0 bganchor=0 bgcut=""
1546
- local -A bgfrom=() bgsent=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=()
1549
+ local -A bgfrom=() bgsent=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=() bgtunef=() bgofff=() bgimages=()
1547
1550
  local conf=0 cf=1
1548
1551
  local -a plabel=(" this tab " " default ") csnap=()
1549
1552
  local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT) clabel=("new tabs" announce "search fx" sort)