@kecan0406/ttheme 1.0.48 → 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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.48",
2
+ "version": "1.0.49",
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.48",
3
+ "version": "1.0.49",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "ttheme": "bin/ttheme.js"
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
  }
@@ -1638,13 +1673,16 @@ __tt_preview() {
1638
1673
  local -A bgfrom=() bgsent=() bgcost=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=() bgtunef=() bgofff=() bgimages=()
1639
1674
  local conf=0 cf=1
1640
1675
  local -a plabel=(" this tab " " default ") csnap=()
1641
- local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT) clabel=("new tabs" announce "search fx" sort)
1642
- 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")
1643
1678
  local -A cnote=(
1644
- seq "new tabs rotate through palettes" off "new tabs keep the terminal theme"
1645
- 1 "shows the palette notice" 0 "silences the palette notice"
1646
- typewriter "the search hint types itself" decode "the search hint decodes" glitch "the search hint glitches in"
1647
- 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"
1648
1686
  )
1649
1687
  [[ $mode == pin ]] && pkdef=2 plabel=(" this directory " " and below ")
1650
1688
  [[ $mode == init ]] && pkdef=2