@kecan0406/ttheme 1.2.19 → 1.2.20
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 +7 -4
- package/bin/ttheme.js +205 -205
- package/bin/ttheme.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/package.json +3 -1
- package/shell/adapters/_bg.zsh +7 -4
- package/shell/preview.zsh +99 -17
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kecan0406/ttheme",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ttheme": "bin/ttheme.js"
|
|
@@ -37,10 +37,12 @@
|
|
|
37
37
|
"@clack/prompts": "^1.8.1",
|
|
38
38
|
"@jsquash/jpeg": "^1.6.0",
|
|
39
39
|
"@material/material-color-utilities": "^0.4.0",
|
|
40
|
+
"@oxlint/plugins": "1.87.0",
|
|
40
41
|
"@types/bun": "^1.4.2",
|
|
41
42
|
"@types/pngjs": "6.0.5",
|
|
42
43
|
"@xterm/headless": "6.0.0",
|
|
43
44
|
"fast-string-width": "^3.0.2",
|
|
45
|
+
"oxlint": "1.87.0",
|
|
44
46
|
"pngjs": "7.0.0",
|
|
45
47
|
"smol-toml": "^1.9.0",
|
|
46
48
|
"typescript": "^7.0.2",
|
package/shell/adapters/_bg.zsh
CHANGED
|
@@ -77,8 +77,8 @@ __tt_bg_load() {
|
|
|
77
77
|
bgimages[$name]=${bgimages[$pal]:-1}
|
|
78
78
|
elif [[ -r $dir/$file.conf ]]; then
|
|
79
79
|
lines=("${(@f)$(<$dir/$file.conf)}")
|
|
80
|
-
for line in ${(k)bgcolors[(I)${(b)pal}:*]}; do
|
|
81
|
-
unset "bgcolors[$line]"
|
|
80
|
+
for line in ${(k)bgcolors[(I)${(b)pal}:*]} ${(k)bgcred[(I)${(b)pal}:*]} ${(k)bgpage[(I)${(b)pal}:*]} ${(k)bgprof[(I)${(b)pal}:*]}; do
|
|
81
|
+
unset "bgcolors[$line]" "bgcred[$line]" "bgpage[$line]" "bgprof[$line]"
|
|
82
82
|
done
|
|
83
83
|
fi
|
|
84
84
|
for line in $lines; do
|
|
@@ -87,6 +87,9 @@ __tt_bg_load() {
|
|
|
87
87
|
'config-file = ?'*.off.conf) bgofff[$name]=${line#config-file = \?} ;;
|
|
88
88
|
'# image '*/<->) bgimages[$name]=${line##*/} bgact[$pal]=${${line#\# image }%% *} ;;
|
|
89
89
|
'# colors '*) pd=(${=line#\# colors }); [[ -n $key ]] || bgcolors[$pal:$pd[1]]=$pd[2] ;;
|
|
90
|
+
'# credit '*) [[ -n $key ]] || { line=${line#\# credit }; bgcred[$pal:${line%% *}]=${line#* } } ;;
|
|
91
|
+
'# source '*) [[ -n $key ]] || { line=${line#\# source }; bgpage[$pal:${line%% *}]="${line##* } ${${line#* }% *}" } ;;
|
|
92
|
+
'# profile '*) [[ -n $key ]] || { line=${line#\# profile }; bgprof[$pal:${line%% *}]+=${bgprof[$pal:${line%% *}]:+$'\n'}${line#* } } ;;
|
|
90
93
|
'# picture '*)
|
|
91
94
|
pd=(${=line#\# picture })
|
|
92
95
|
bgpic[$pal:$pd[1]]=${(j: :)pd[2,-1]}
|
|
@@ -509,8 +512,8 @@ __tt_pv_bg_reset() {
|
|
|
509
512
|
for img in ${(k)bgsrc[(I)${(b)1}(|:*)]}; do
|
|
510
513
|
unset "bgsrc[$img]"
|
|
511
514
|
done
|
|
512
|
-
for img in ${(k)bgcolors[(I)${(b)1}:*]}; do
|
|
513
|
-
unset "bgcolors[$img]"
|
|
515
|
+
for img in ${(k)bgcolors[(I)${(b)1}:*]} ${(k)bgcred[(I)${(b)1}:*]} ${(k)bgpage[(I)${(b)1}:*]} ${(k)bgprof[(I)${(b)1}:*]}; do
|
|
516
|
+
unset "bgcolors[$img]" "bgcred[$img]" "bgpage[$img]" "bgprof[$img]"
|
|
514
517
|
done
|
|
515
518
|
unset "bgview[$1]" "bgswap[$1]"
|
|
516
519
|
}
|
package/shell/preview.zsh
CHANGED
|
@@ -313,16 +313,91 @@ __tt_pv_row() {
|
|
|
313
313
|
fi
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
__tt_pv_bg_pickkey() {
|
|
317
|
+
REPLY=${tpick#*:}
|
|
318
|
+
[[ $tpick == *:* ]] || REPLY=${bgact[$tune]}
|
|
319
|
+
}
|
|
320
|
+
|
|
316
321
|
__tt_pv_bg_credit() {
|
|
317
|
-
local by=${bgby[$tpick]} ref=${bgfrom[$tpick]} url=${bgurl[$tpick]}
|
|
322
|
+
local by=${bgby[$tpick]} ref=${bgfrom[$tpick]} url=${bgurl[$tpick]} page lab pu pmark="" smark="" sgr="" acc=""
|
|
318
323
|
local -i room=$1
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
[[
|
|
324
|
+
local -a items
|
|
325
|
+
__tt_pv_bg_pickkey
|
|
326
|
+
page=${bgpage[$tune:$REPLY]}
|
|
327
|
+
pu=${page%% *} lab=${page#* }
|
|
328
|
+
[[ $url == http(s|)://* ]] || url=""
|
|
329
|
+
if __tt_links; then
|
|
330
|
+
[[ -n $url ]] && pmark="⧉ "
|
|
331
|
+
[[ -n $pu ]] && smark="⧉ "
|
|
332
|
+
fi
|
|
333
|
+
items=(${by:+"by $by"} ${lab:+"$smark$lab"} ${ref:+"$pmark$ref"})
|
|
334
|
+
while (( ${#items} )) && (( ${#${(j: · :)items}} > room )); do
|
|
335
|
+
items[-1]=()
|
|
336
|
+
done
|
|
337
|
+
REPLY=${(j: · :)items}
|
|
338
|
+
if [[ -n $smark && $REPLY == *"$smark$lab"* ]]; then
|
|
339
|
+
(( color )) && acc=$ac
|
|
340
|
+
REPLY=${REPLY/"$smark$lab"/$acc⧉${acc:+$TTHEME_SGR[/accent]} $'\e]8;;'$pu$'\e\\'$lab$'\e]8;;\e\\'}
|
|
341
|
+
fi
|
|
342
|
+
[[ -n $pmark && $REPLY == *"$pmark$ref"* ]] || return 0
|
|
324
343
|
(( color )) && [[ -n ${TTHEME_SITE_ANSI[${ref%% *}]} ]] && sgr=$TTHEME_SGR[fg${TTHEME_SITE_ANSI[${ref%% *}]}]
|
|
325
|
-
REPLY=${REPLY/"$
|
|
344
|
+
REPLY=${REPLY/"$pmark$ref"/$sgr⧉${sgr:+$TTHEME_SGR[/fg]} $'\e]8;;'$url$'\e\\'$ref$'\e]8;;\e\\'}
|
|
345
|
+
return 0
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
__tt_pv_copy() {
|
|
349
|
+
if (( $+commands[pbcopy] )); then
|
|
350
|
+
print -rn -- $1 | LC_CTYPE=UTF-8 pbcopy
|
|
351
|
+
elif [[ -n $WAYLAND_DISPLAY ]] && (( $+commands[wl-copy] )); then
|
|
352
|
+
print -rn -- $1 | wl-copy
|
|
353
|
+
elif [[ -n $DISPLAY ]] && (( $+commands[xclip] )); then
|
|
354
|
+
print -rn -- $1 | xclip -selection clipboard
|
|
355
|
+
else
|
|
356
|
+
return 1
|
|
357
|
+
fi
|
|
358
|
+
} >/dev/null 2>&1
|
|
359
|
+
|
|
360
|
+
__tt_pv_bg_copy() {
|
|
361
|
+
local text
|
|
362
|
+
__tt_pv_bg_pickkey
|
|
363
|
+
text=${bgcred[$tune:$REPLY]}
|
|
364
|
+
if [[ -z $text ]]; then
|
|
365
|
+
msg="This picture names no artist and no page" msgt=300
|
|
366
|
+
return 0
|
|
367
|
+
fi
|
|
368
|
+
if [[ -n $SSH_CONNECTION$SSH_TTY ]] || ! __tt_pv_copy $text; then
|
|
369
|
+
__tt_b64s $text
|
|
370
|
+
__tt_out $'\e]52;c;'$REPLY$'\a'
|
|
371
|
+
fi
|
|
372
|
+
msg="Copied · $text" msgt=200
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
__tt_pv_bg_profiles() {
|
|
376
|
+
local k entry plain="" step piece acc="" lead
|
|
377
|
+
local -a ents e
|
|
378
|
+
local -i room=$1 i many
|
|
379
|
+
REPLY=""
|
|
380
|
+
__tt_links || return 0
|
|
381
|
+
__tt_pv_bg_pickkey
|
|
382
|
+
k=$REPLY REPLY=""
|
|
383
|
+
ents=(${(f)bgprof[$tune:$k]})
|
|
384
|
+
many=$(( ${#ents} > 1 ))
|
|
385
|
+
(( color )) && acc=$ac
|
|
386
|
+
for entry in $ents; do
|
|
387
|
+
e=(${=entry})
|
|
388
|
+
lead=""
|
|
389
|
+
[[ -n $plain ]] && lead=" · "
|
|
390
|
+
if (( many )); then
|
|
391
|
+
(( ${#plain} + ${#lead} + ${#e[1]} > room )) && return 0
|
|
392
|
+
plain+=$lead$e[1] REPLY+=$lead$e[1] lead=" "
|
|
393
|
+
fi
|
|
394
|
+
for (( i = 2; i < ${#e}; i += 2 )); do
|
|
395
|
+
step="⧉ $e[i]"
|
|
396
|
+
(( ${#plain} + ${#lead} + ${#step} > room )) && return 0
|
|
397
|
+
piece=$acc⧉${acc:+$TTHEME_SGR[/accent]}" "$'\e]8;;'$e[i+1]$'\e\\'$e[i]$'\e]8;;\e\\'
|
|
398
|
+
plain+=$lead$step REPLY+=$lead$piece lead=" "
|
|
399
|
+
done
|
|
400
|
+
done
|
|
326
401
|
return 0
|
|
327
402
|
}
|
|
328
403
|
|
|
@@ -424,6 +499,8 @@ __tt_pv_foot() {
|
|
|
424
499
|
kl[2]="image ×$REPLY"
|
|
425
500
|
(( REPLY > 1 )) || { kk[2]=() kl[2]=() }
|
|
426
501
|
__tt_pv_bg_findable $tune && { kk+=(f); kl+=(find) }
|
|
502
|
+
__tt_pv_bg_pickkey
|
|
503
|
+
[[ -n ${bgcred[$tune:$REPLY]} ]] && { kk+=(y); kl+=(credit) }
|
|
427
504
|
kk+=(D) kl+=(remove)
|
|
428
505
|
elif [[ -n $tune ]]; then
|
|
429
506
|
__tt_pv_bg_findable $tune && { kk+=(f); kl+=(find) }
|
|
@@ -435,6 +512,8 @@ __tt_pv_foot() {
|
|
|
435
512
|
kk+=('=' + ⇧←→) kl+=(reset "reset all" ×10)
|
|
436
513
|
fi
|
|
437
514
|
(( bgoff[$tpick] )) && { kk+=(space); kl+=(show) } || { kk+=(c space); kl+=(colors hide) }
|
|
515
|
+
__tt_pv_bg_pickkey
|
|
516
|
+
[[ -n ${bgcred[$tune:$REPLY]} ]] && { kk+=(y); kl+=(credit) }
|
|
438
517
|
__tt_pv_bg_images $tune
|
|
439
518
|
(( REPLY > 1 )) && { kk+=(', .' D); kl+=("image ×$REPLY" remove) }
|
|
440
519
|
else
|
|
@@ -553,7 +632,7 @@ __tt_pv_help() {
|
|
|
553
632
|
"Images ←→ , . pick one · D removes it · f finds one"
|
|
554
633
|
"enter on the empty frame · finds the first one"
|
|
555
634
|
"←→ step ⇧←→ ×10 1-9 place · = resets · + all"
|
|
556
|
-
"space hides · c colors"
|
|
635
|
+
"space hides · c colors · y copies who drew it"
|
|
557
636
|
"enter · tunes its colors full screen, keeps its own tone"
|
|
558
637
|
"? there lists its keys · esc leaves it"
|
|
559
638
|
"enter on Apply, or ⇧enter anywhere · saves, asks where"
|
|
@@ -723,6 +802,7 @@ __tt_pv_tune() {
|
|
|
723
802
|
',') __tt_pv_bg_pick -1 ;;
|
|
724
803
|
'.') __tt_pv_bg_pick 1 ;;
|
|
725
804
|
D) __tt_pv_bg_drop ;;
|
|
805
|
+
y) __tt_pv_bg_copy ;;
|
|
726
806
|
esac
|
|
727
807
|
return 0
|
|
728
808
|
}
|
|
@@ -2020,7 +2100,7 @@ __tt_pv_te_panel() {
|
|
|
2020
2100
|
(( tewide == W )) || __tt_te_read $W
|
|
2021
2101
|
T=${#teframe} P=$(( ${#teframe} + 2 ))
|
|
2022
2102
|
__tt_te_image && pics=1
|
|
2023
|
-
(( pics &&
|
|
2103
|
+
(( pics && 19 <= R && (tfocus == 1 || 19 + P + 1 <= R) )) && I=19
|
|
2024
2104
|
V=$(( I + P + 1 ))
|
|
2025
2105
|
if (( V <= R || tfocus == 1 )); then
|
|
2026
2106
|
tetop=0
|
|
@@ -2041,23 +2121,25 @@ __tt_pv_te_panel() {
|
|
|
2041
2121
|
pvz+=("$(( y + i )) $col $end teimg")
|
|
2042
2122
|
done
|
|
2043
2123
|
fi
|
|
2044
|
-
if (( I ==
|
|
2124
|
+
if (( I == 19 )); then
|
|
2045
2125
|
if [[ -n $tune ]]; then
|
|
2046
2126
|
__tt_pv_bg_credit $(( ie - ix + 1 ))
|
|
2047
2127
|
[[ -n $REPLY ]] && out+=$'\e['$(( y + 1 ))';'$ix'H'$d$REPLY$z
|
|
2128
|
+
__tt_pv_bg_profiles $(( ie - ix + 1 ))
|
|
2129
|
+
[[ -n $REPLY ]] && out+=$'\e['$(( y + 2 ))';'$ix'H'$d$REPLY$z
|
|
2048
2130
|
fi
|
|
2049
|
-
__tt_pv_te_images $(( y +
|
|
2131
|
+
__tt_pv_te_images $(( y + 3 )) $ix $ie
|
|
2050
2132
|
if [[ -n $tune ]]; then
|
|
2051
|
-
bgstrip="$(( y +
|
|
2133
|
+
bgstrip="$(( y + 3 )) $ix $ie"
|
|
2052
2134
|
(( tfocus == 1 )) || tf=0
|
|
2053
|
-
__tt_pv_bg_panel $tpick $(( y +
|
|
2135
|
+
__tt_pv_bg_panel $tpick $(( y + 10 )) $ix $ie
|
|
2054
2136
|
tf=$tfs
|
|
2055
2137
|
else
|
|
2056
|
-
__tt_pv_te_tile $(( y +
|
|
2057
|
-
for (( i =
|
|
2138
|
+
__tt_pv_te_tile $(( y + 4 )) $ix
|
|
2139
|
+
for (( i = 4; i <= 8; i++ )); do
|
|
2058
2140
|
pvz+=("$(( y + i )) $ix $(( ix + 30 )) tefind")
|
|
2059
2141
|
done
|
|
2060
|
-
__tt_pv_te_ghost $(( y +
|
|
2142
|
+
__tt_pv_te_ghost $(( y + 10 )) $ix $ie
|
|
2061
2143
|
fi
|
|
2062
2144
|
elif (( pics )); then
|
|
2063
2145
|
__tt_pv_te_images $(( y + 1 )) $ix $ie
|
|
@@ -2302,7 +2384,7 @@ __tt_preview() {
|
|
|
2302
2384
|
local -i scene=0
|
|
2303
2385
|
local -a bgorder=()
|
|
2304
2386
|
local -A bgfrom=() bgurl=() bgby=() bgsent=() bgcost=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=() bgtunef=() bgofff=() bgimages=()
|
|
2305
|
-
local -A bgpic=() bgpics=() bgact=() bgview=() bgswap=() bgthumb=() tsnaps=() pvseek=() bgcolors=() bgprep=() TTHEME_ALIASES=()
|
|
2387
|
+
local -A bgpic=() bgpics=() bgact=() bgview=() bgswap=() bgthumb=() tsnaps=() pvseek=() bgcolors=() bgcred=() bgpage=() bgprof=() bgprep=() TTHEME_ALIASES=()
|
|
2306
2388
|
local conf=0 cf=1
|
|
2307
2389
|
local -a plabel=(" Default " " This tab ") pkeys=() reach=() csnap=() teframe=()
|
|
2308
2390
|
local te=0 tfocus=0 tetop=0 tewide=0 tbtn=0 tearm=0 tename=""
|