@kecan0406/ttheme 0.1.3 → 0.1.5

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": "0.1.3",
2
+ "version": "0.1.5",
3
3
  "gate": [
4
4
  {
5
5
  "rule": "foreground",
@@ -1,13 +1,13 @@
1
1
  # Generated by `mise run build` — do not edit.
2
2
  # Source of truth: themes/*.toml in the ttheme repo.
3
3
 
4
- typeset -g TTHEME_VERSION=0.1.3
4
+ typeset -g TTHEME_VERSION=0.1.5
5
5
 
6
6
  # seed for `ttheme config` when no config.zsh exists yet
7
7
  typeset -g TTHEME_CONFIG_TEMPLATE='# ttheme settings — exported variables win over this file
8
8
 
9
- # new tabs: seq rotates through the palettes, off keeps the configured terminal theme (default seq)
10
- : ${TTHEME_TAB_PALETTE:=seq}
9
+ # new tabs: off keeps the configured terminal theme, seq rotates through the palettes (default off)
10
+ : ${TTHEME_TAB_PALETTE:=off}
11
11
 
12
12
  # the palette notice under "Last login:": 1 shows it, 0 silences it (default 1)
13
13
  : ${TTHEME_ANNOUNCE:=1}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kecan0406/ttheme",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "ttheme": "bin/ttheme.js"
@@ -30,6 +30,10 @@ __tt_pv_bg_findable() { return 1 }
30
30
 
31
31
  __tt_pv_bg_find() { return 1 }
32
32
 
33
+ __tt_pv_bg_images() { REPLY=1 }
34
+
35
+ __tt_pv_bg_image() { : }
36
+
33
37
  __tt_pv_bg_panel() { : }
34
38
 
35
39
  __tt_pv_bg_close() { : }
@@ -420,6 +420,32 @@ __tt_pv_bg_find() {
420
420
  return 0
421
421
  }
422
422
 
423
+ __tt_pv_bg_images() {
424
+ local -a shelf=(${TTHEME_CONFIG:h}/backgrounds/shelf/$1/*(N/))
425
+ REPLY=$(( ${#shelf} + 1 ))
426
+ }
427
+
428
+ __tt_pv_bg_image() {
429
+ local name=$tune act=$1 err REPLY
430
+ local -i rc
431
+ if [[ $act != drop ]]; then
432
+ __tt_pv_bg_images $name
433
+ (( REPLY > 1 )) || { msg="$name has one image" msgt=200; return 0 }
434
+ fi
435
+ __tt_pv_untune
436
+ __tt_pv_bg_close
437
+ err=$(__tt_cli image $name $act 2>&1)
438
+ rc=$?
439
+ err=${${err//$'\n'/ }## #}
440
+ resized=1 bgname="" bgshown="" bgsent=() bgdim=()
441
+ unset "bgsrc[$name]"
442
+ __tt_bg_load $name
443
+ bgload[$name]="" bgedit[$name]=1
444
+ msg=${err:-"background · $name"} msgt=$(( rc ? 300 : 200 ))
445
+ [[ -r ${TTHEME_CONFIG:h}/backgrounds/$name.conf ]] || return 0
446
+ tune=$name tf=1 tsnap="${bgsize[$name]} ${bgpos[$name]} ${bgop[$name]} ${bgoff[$name]}"
447
+ }
448
+
423
449
  __tt_pv_bg_panel() {
424
450
  local name=$1 z=$'\e[0m' b=$'\e[1m' d=$'\e[2m' c=$ac val sty REPLY
425
451
  local -a labs=(size position opacity) at=(0 3 6)
@@ -2,7 +2,7 @@
2
2
 
3
3
  source ${0:A:h}/ttheme.zsh
4
4
 
5
- if [[ ${TTHEME_TAB_PALETTE:-seq} != off ]]; then
5
+ if [[ ${TTHEME_TAB_PALETTE:-off} != off ]]; then
6
6
  __tt_next
7
7
  __tt_apply "$REPLY"
8
8
  export TTHEME_SPEC=$REPLY
package/shell/ttheme.zsh CHANGED
@@ -36,7 +36,7 @@ __tt_pins_load() {
36
36
 
37
37
  __tt_pins_load
38
38
 
39
- : ${TTHEME_TAB_PALETTE:=seq}
39
+ : ${TTHEME_TAB_PALETTE:=off}
40
40
 
41
41
  : ${TTHEME_ANNOUNCE:=1}
42
42
 
@@ -143,6 +143,7 @@ __tt_dir_sync() {
143
143
  spec=${TTHEME_PALETTE[$TTHEME_PINS[$REPLY]]}
144
144
  elif [[ $TTHEME_SPEC == "$TTHEME_PIN_SPEC" ]]; then
145
145
  spec=$TTHEME_BASE_SPEC
146
+ [[ -n $spec ]] || { __tt_osc_reset; TTHEME_SPEC= }
146
147
  fi
147
148
  TTHEME_PIN=$REPLY TTHEME_PIN_SPEC=$spec
148
149
  [[ -n $spec && $spec != "$TTHEME_SPEC" ]] || return 0
@@ -225,11 +226,16 @@ __tt_unpin() {
225
226
 
226
227
  __tt_keep() {
227
228
  __tt_cli default "$1" > /dev/null || return 1
228
- __tt_reload
229
+ local note="default · new tabs open with $1"
230
+ if (( $+functions[__tt_reload] )); then
231
+ __tt_reload
232
+ else
233
+ note+=" — reload your terminal config to pick it up"
234
+ fi
229
235
  if __tt_color; then
230
- printf '\033[2mdefault · new tabs open with %s\033[0m\n' "$1"
236
+ printf '\033[2m%s\033[0m\n' "$note"
231
237
  else
232
- print -r -- "default · new tabs open with $1"
238
+ print -r -- "$note"
233
239
  fi
234
240
  }
235
241
 
@@ -281,6 +287,7 @@ __tt_help() {
281
287
  ttheme homura paint this tab (a unique prefix works: ttheme ho)
282
288
  ttheme preview browse live — focus repaints, enter keeps (this tab or default), esc restores, ? lists keys
283
289
  ttheme next advance this tab to the next palette
290
+ ttheme default make a palette the one new tabs open with
284
291
  ttheme pin pick a palette for this directory — cd into it repaints, cd out restores
285
292
  ttheme unpin drop the palette pinned to this directory
286
293
  ttheme config edit settings in $EDITOR — they apply in new tabs
@@ -383,10 +390,6 @@ __tt_next() {
383
390
  }
384
391
 
385
392
  __tt_rotate() {
386
- if [[ $TTHEME_TAB_PALETTE == off ]]; then
387
- print -u2 "ttheme next: TTHEME_TAB_PALETTE is off"
388
- return 1
389
- fi
390
393
  local REPLY
391
394
  __tt_next
392
395
  __tt_apply "$REPLY"
@@ -583,9 +586,9 @@ __tt_pv_head() {
583
586
 
584
587
  __tt_pv_foot() {
585
588
  setopt localoptions extendedglob
586
- local b=$'\e[1m' d=$'\e[2m' z=$'\e[0m' y=$'\e[33m' on=$'\e[7;1m'$ac badge="" lead="" note="" right="" line plain
589
+ local b=$'\e[1m' d=$'\e[2m' z=$'\e[0m' y=$'\e[33m' on=$'\e[7;1m'$ac badge="" lead="" note="" right="" text line plain
587
590
  local -a kk=() kl=() seg=()
588
- local -i end=$1 i lwid rwid
591
+ local -i end=$1 i lwid rwid room
589
592
  (( color )) || b= d= z= y= on=
590
593
  if (( help )); then
591
594
  badge=KEYS right=$b"? esc"$z$d" close"$z
@@ -617,6 +620,8 @@ __tt_pv_foot() {
617
620
  fi
618
621
  kk+=(space '=' enter)
619
622
  if (( bgoff[$tune] )); then kl+=(show default keep); else kl+=(hide default keep); fi
623
+ __tt_pv_bg_images $tune
624
+ (( REPLY > 1 )) && { kk+=(', .' D); kl+=("image ×$REPLY" remove) }
620
625
  __tt_pv_bg_findable $tune && { kk+=(f); kl+=(find) }
621
626
  right=$b"esc"$z$d" undo"$z
622
627
  elif (( conf )); then
@@ -651,7 +656,13 @@ __tt_pv_foot() {
651
656
  fi
652
657
  fi
653
658
  if (( msgt > 0 )) && [[ -z $pick ]]; then
654
- lead=$y$msg$z note="" kk=() kl=()
659
+ text=$msg
660
+ room=$(( end - (${#badge} ? ${#badge} + 4 : 0) ))
661
+ if (( ${(m)#text} > room )); then
662
+ while [[ -n $text ]] && (( ${(m)#text} > room - 1 )); do text=${text[1,-2]}; done
663
+ text+=…
664
+ fi
665
+ lead=$y$text$z note="" kk=() kl=()
655
666
  fi
656
667
  while :; do
657
668
  seg=()
@@ -700,8 +711,8 @@ __tt_pv_help() {
700
711
  "enter · esc restores $back"
701
712
  )
702
713
  if (( bgcw )); then
703
- hk+=("tune bg" "" "" "")
704
- hv+=("tab · finds one on the boorus if none" "↑↓ field ←→ step ⇧←→ ×10 1-9 place" "space hides · = default · f replaces" "enter keeps · esc undoes")
714
+ hk+=("tune bg" "" "" "" "")
715
+ hv+=("tab · finds one on the boorus if none" "↑↓ field ←→ step ⇧←→ ×10 1-9 place" "space hides · = default · f adds one" "enter keeps · esc undoes" ", . other saved images · D removes this one")
705
716
  fi
706
717
  hk+=(config "")
707
718
  hv+=("alt-c · ↑↓ setting ←→ value" "enter saves · esc undoes")
@@ -782,6 +793,9 @@ __tt_pv_tune() {
782
793
  ;;
783
794
  ' ') __tt_pv_bg_adjust on ;;
784
795
  '=') __tt_pv_bg_adjust def ;;
796
+ ',') __tt_pv_bg_image prev ;;
797
+ '.') __tt_pv_bg_image next ;;
798
+ D) __tt_pv_bg_image drop ;;
785
799
  f)
786
800
  __tt_pv_bg_findable $tune || return 0
787
801
  name=$tune
@@ -1344,7 +1358,7 @@ __tt_preview() {
1344
1358
  local conf=0 cf=1
1345
1359
  local -a plabel=(" this tab " " default ") csnap=()
1346
1360
  local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT) clabel=("new tabs" announce "search fx" sort)
1347
- local -a cchoice=("seq off" "1 0" "typewriter decode glitch" "abc series") cshow=("seq off" "on off" "typewriter decode glitch" "abc series")
1361
+ local -a cchoice=("off seq" "1 0" "typewriter decode glitch" "abc series") cshow=("off seq" "on off" "typewriter decode glitch" "abc series")
1348
1362
  local -A cnote=(
1349
1363
  seq "new tabs rotate through palettes" off "new tabs keep the terminal theme"
1350
1364
  1 "shows the palette notice" 0 "silences the palette notice"
@@ -1421,6 +1435,12 @@ ttheme() {
1421
1435
 
1422
1436
  case $1 in
1423
1437
  next) __tt_rotate; return ;;
1438
+ default)
1439
+ [[ -n $2 ]] || { print -u2 "ttheme default: name a palette — see \`ttheme help\`"; return 1 }
1440
+ local REPLY
1441
+ __tt_resolve "$2" || return 1
1442
+ __tt_keep "$REPLY"
1443
+ return ;;
1424
1444
  preview) __tt_preview; return ;;
1425
1445
  pin) __tt_preview pin; return ;;
1426
1446
  unpin) __tt_unpin; return ;;
@@ -1437,7 +1457,7 @@ ttheme() {
1437
1457
 
1438
1458
  if (( $+functions[compdef] )); then
1439
1459
  __tt_complete() {
1440
- (( CURRENT == 2 )) && compadd -- preview next pin unpin config help browse list add remove update
1460
+ (( CURRENT == 2 )) && compadd -- preview next default pin unpin config help browse list add remove update
1441
1461
  compadd -- $TTHEME_ORDER
1442
1462
  }
1443
1463
  compdef __tt_complete ttheme
@@ -1453,9 +1473,6 @@ if __tt_active; then
1453
1473
  for k in ${(k)TTHEME_PALETTE}; do
1454
1474
  [[ ${TTHEME_PALETTE[$k]%% *} == "$REPLY" ]] && { TTHEME_SPEC=$TTHEME_PALETTE[$k]; break }
1455
1475
  done
1456
- [[ -n $TTHEME_SPEC ]] || TTHEME_SPEC="$REPLY ${TTHEME_PALETTE[neutral]#* }"
1457
- else
1458
- TTHEME_SPEC="- ${TTHEME_PALETTE[neutral]#* }"
1459
1476
  fi
1460
1477
  else
1461
1478
  __tt_next