@kecan0406/ttheme 1.2.17 → 1.2.19

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/shell/preview.zsh CHANGED
@@ -157,7 +157,7 @@ typeset -gA TTHEME_GLYPHS=(
157
157
  )
158
158
 
159
159
  __tt_pv_osd() {
160
- local text=${(U)osd} bits line oc=$'\e[1m' blank
160
+ local text=${(U)osd} bits line oc=$TTHEME_SGR[bold] blank
161
161
  local -i s=2 n=${#text} w r c k i top left
162
162
  (( n * 16 + 4 <= pw && ph >= 14 )) || s=1
163
163
  w=$(( n * 8 * s - 2 * s + 4 ))
@@ -186,7 +186,7 @@ __tt_pv_osd() {
186
186
  done
187
187
  line+=" "
188
188
  for (( i = 0; i < s; i++ )); do
189
- out+=$'\e['$(( top + r * s + i ))';'${left}H$oc$line$'\e[0m'
189
+ out+=$'\e['$(( top + r * s + i ))';'${left}H$oc$line$TTHEME_SGR[reset]
190
190
  done
191
191
  done
192
192
  out+=$'\e['$(( top + 5 * s ))';'${left}H$blank
@@ -217,7 +217,7 @@ __tt_pv_hl() {
217
217
  REPLY=$t
218
218
  (( color )) && [[ -n $flt && $lt == *$flt* ]] || return 0
219
219
  pre=${lt%%$flt*}
220
- REPLY=${t[1,${#pre}]}$'\e[1;4m'$ac${t[${#pre}+1,${#pre}+${#flt}]}$'\e[22;24;39m'$2${t[${#pre}+${#flt}+1,-1]}
220
+ REPLY=${t[1,${#pre}]}$hm${t[${#pre}+1,${#pre}+${#flt}]}$TTHEME_SGR[/match]$2${t[${#pre}+${#flt}+1,-1]}
221
221
  }
222
222
 
223
223
  __tt_pv_fit() {
@@ -233,11 +233,11 @@ __tt_pv_fit() {
233
233
  }
234
234
 
235
235
  __tt_pv_row() {
236
- local t=${rval[$1]} b=$'\e[1m' d=$'\e[2m' r=$'\e[22;24;39m' z=$'\e[0m' on="" gut=" " base="" lead=$'\e[2m' mark=" " name arrow=▸ ind=" " hl extra part
236
+ local t=${rval[$1]} b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] r=$TTHEME_SGR[/match] z=$TTHEME_SGR[reset] on="" gut=" " base="" lead=$TTHEME_SGR[dim] mark=" " name arrow=▸ ind=" " hl extra part
237
237
  local -i w
238
238
  (( color )) || b= d= r= z= lead=
239
239
  if (( $1 == cur )); then
240
- gut=$ac"▌"$r" "
240
+ gut=$gc"▌"$r" "
241
241
  (( color )) && on=$sb
242
242
  fi
243
243
  if [[ ${rtype[$1]} == rule ]]; then
@@ -282,27 +282,34 @@ __tt_pv_row() {
282
282
  return 0
283
283
  fi
284
284
  if (( $1 == cur )); then
285
- mark=$ac"■"$r base=$b
285
+ mark=$gc"■"$r base=$b
286
286
  elif [[ -n $cdot && $t == "$cn" ]]; then
287
- mark=$cdot
287
+ mark=$ac$cdot$r
288
288
  fi
289
289
  name=${t##*/}
290
290
  [[ -n ${TTHEME_CATALOG[$t]} && ${TTHEME_GROUP[$t]} == *@* ]] && ind=" "
291
+ (( ${TTHEME_TUNED[(Ie)$t]} )) && w=-2
292
+ (( ${(m)#name} > lw - 17 - ${#ind} + w )) && name="${name[1,lw-18-${#ind}+w]}…"
291
293
  __tt_pv_hl "$name" "$base"
292
294
  hl=$REPLY
295
+ if (( w )); then
296
+ (( color )) && hl+=" "$TTHEME_SGR[warn]"●"$TTHEME_SGR[/warn] || hl+=" ●"
297
+ fi
293
298
  extra=""
294
299
  for part in "${(@s:|:)TTHEME_NATIVE_NAMES[$t]}" "${TTHEME_CHARACTER[$t]}" "${(@s:|:)TTHEME_ALIASES[$t]}"; do
295
- __tt_pv_alias "$name" "$part"
300
+ __tt_pv_alias "${t##*/}" "$part"
296
301
  [[ -n $REPLY ]] && { extra=$REPLY; break }
297
302
  done
298
303
  if (( color )); then
299
304
  [[ -n ${tstrip[$t]} ]] || __tt_pv_strip $t
300
- w=$(( lw - 16 - ${#ind} - ${#name} ))
305
+ w=$(( w + lw - 16 - ${#ind} - ${#name} ))
301
306
  __tt_pv_fit "$extra"
302
307
  (( w < 1 )) && w=1
303
308
  REPLY=$gut$on"$ind$mark $base$hl$r$REPLY${(l:w:: :)}${tstrip[$t]} "$z
304
309
  else
305
- REPLY="$gut$ind$mark $hl${extra:+ $extra}"
310
+ w=$(( w + lw - 4 - ${#ind} - ${#name} ))
311
+ __tt_pv_fit "$extra"
312
+ REPLY="$gut$ind$mark $hl$REPLY"
306
313
  fi
307
314
  }
308
315
 
@@ -314,13 +321,13 @@ __tt_pv_bg_credit() {
314
321
  (( ${#REPLY} > room )) && REPLY=${by:+by $by}
315
322
  (( ${#REPLY} > room )) && REPLY=""
316
323
  [[ -n $mark && $REPLY == *"$mark$ref"* ]] || return 0
317
- (( color )) && [[ -n ${TTHEME_SITE_ANSI[${ref%% *}]} ]] && sgr=$'\e[3'${TTHEME_SITE_ANSI[${ref%% *}]}m
318
- REPLY=${REPLY/"$mark$ref"/$sgr⧉${sgr:+$'\e[39m'} $'\e]8;;'$url$'\e\\'$ref$'\e]8;;\e\\'}
324
+ (( color )) && [[ -n ${TTHEME_SITE_ANSI[${ref%% *}]} ]] && sgr=$TTHEME_SGR[fg${TTHEME_SITE_ANSI[${ref%% *}]}]
325
+ REPLY=${REPLY/"$mark$ref"/$sgr⧉${sgr:+$TTHEME_SGR[/fg]} $'\e]8;;'$url$'\e\\'$ref$'\e]8;;\e\\'}
319
326
  return 0
320
327
  }
321
328
 
322
329
  __tt_pv_bar() {
323
- local z=$'\e[0m' d=$'\e[2m' on=$'\e[7;1m'$ac line=" " title hint="tab next"
330
+ local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] on=$pl line=" " title hint="tab next"
324
331
  local -i i at=${TTHEME_HUB_TABS[(Ie)preview]} len=${#TTHEME_HUB_TITLES}
325
332
  (( color )) || z= d= on=
326
333
  [[ ${rtype[cur]} == thm ]] && hint="⇧tab switch"
@@ -346,17 +353,26 @@ __tt_pv_bar() {
346
353
  }
347
354
 
348
355
  __tt_pv_head() {
349
- local b=$'\e[1m' d=$'\e[2m' z=$'\e[0m' right=$6
356
+ local b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] z=$TTHEME_SGR[reset] title=$4 sub=$5 right=$6
357
+ local -i room=$(( $3 - $2 + 1 )) used
350
358
  (( color )) || b= d= z=
351
- out+=$'\e['$1';'$2'H'$b$ac$4$z
352
- [[ -n $5 ]] && out+=" "$d$5$z
359
+ if (( ${(m)#title} > room )); then
360
+ while [[ -n $title ]] && (( ${(m)#title} > room - 1 )); do title=${title[1,-2]}; done
361
+ title+=…
362
+ fi
363
+ used=${(m)#title}
364
+ (( used + 2 + ${(m)#sub} <= room )) || sub=""
365
+ [[ -n $sub ]] && (( used += 2 + ${(m)#sub} ))
366
+ (( used + 2 + ${(m)#right} <= room )) || right=""
367
+ out+=$'\e['$1';'$2'H'$b$gc$title$z
368
+ [[ -n $sub ]] && out+=" "$d$sub$z
353
369
  [[ -n $right ]] && out+=$'\e['$(( $3 - ${(m)#right} + 1 ))'G'$d$right$z
354
370
  return 0
355
371
  }
356
372
 
357
373
  __tt_pv_foot() {
358
374
  setopt localoptions extendedglob
359
- 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 hex tb=EDIT
375
+ local b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] z=$TTHEME_SGR[reset] y=$TTHEME_SGR[warn] on=$pl badge="" lead="" note="" right="" text line plain hex tb=EDIT
360
376
  local -a kk=() kl=() seg=()
361
377
  local -i end=$1 i lwid rwid room
362
378
  (( color )) || b= d= z= y= on=
@@ -394,6 +410,8 @@ __tt_pv_foot() {
394
410
  right=$b"esc"$z$d" back"$z
395
411
  elif (( te && tfocus == 0 )); then
396
412
  badge=$tb kk=(enter ↑↓ s ⇧enter) kl=("edit palette" move save apply)
413
+ (( tbtn )) && kl[1]="reset palette"
414
+ (( ${TTHEME_TUNED[(Ie)$tename]} )) && kk[2]=↑↓←→
397
415
  right=$b"esc"$z$d" cancel"$z
398
416
  elif (( te && tfocus == 2 )); then
399
417
  badge=$tb kk=(enter ↑↓ s) kl=(apply move save)
@@ -448,7 +466,7 @@ __tt_pv_foot() {
448
466
  right=$b"esc"$z$d" clear filter"$z
449
467
  else
450
468
  right=$b"esc"$z$d" restore"$z
451
- [[ -n $cdot ]] && right+=" $cdot$z $cn"
469
+ [[ -n $cdot ]] && right+=" $ac$cdot$z $cn"
452
470
  fi
453
471
  fi
454
472
  if (( msgt > 0 )) && [[ -z $pick ]]; then
@@ -470,7 +488,7 @@ __tt_pv_foot() {
470
488
  line=${(j: :)seg}
471
489
  if [[ -n $badge ]]; then
472
490
  if (( color )); then
473
- line=$'\e[7;1m'$ac" $badge "$z" "$line
491
+ line=$on" $badge "$z" "$line
474
492
  else
475
493
  line="[$badge] $line"
476
494
  fi
@@ -492,6 +510,10 @@ __tt_pv_foot() {
492
510
  break
493
511
  fi
494
512
  done
513
+ if (( lwid > end )); then
514
+ __tt_clip "$line" $end
515
+ line=$REPLY
516
+ fi
495
517
  out+=$line$'\e[K'
496
518
  [[ -n $right ]] && out+=$'\e['$(( end - rwid + 1 ))'G'$right
497
519
  local -i zc=1 zw
@@ -521,7 +543,7 @@ __tt_pv_foot() {
521
543
  }
522
544
 
523
545
  __tt_pv_help() {
524
- local back="the tab" z=$'\e[0m' b=$'\e[1m' blank
546
+ local back="the tab" z=$TTHEME_SGR[reset] b=$TTHEME_SGR[bold] blank
525
547
  [[ -n ${TTHEME_PALETTE[$cn]} ]] && back=$cn
526
548
  local -a hk=() hv=()
527
549
  if (( te )); then
@@ -560,7 +582,7 @@ __tt_pv_help() {
560
582
  hv+=("? esc")
561
583
  fi
562
584
  (( color )) || z= b=
563
- local -i i r x y w hh
585
+ local -i i r x y w hh floor
564
586
  if (( split && sw >= 48 )); then
565
587
  for (( i = 1; i <= ${#hk}; i++ )); do
566
588
  r=$(( i + 3 ))
@@ -572,7 +594,10 @@ __tt_pv_help() {
572
594
  w=$(( pw - 2 < 58 ? pw - 2 : 58 )) hh=$(( ${#hk} + 4 ))
573
595
  (( te )) && w=$(( pw - 2 < 76 ? pw - 2 : 76 ))
574
596
  x=$(( (pw - w) / 2 + 1 )) y=$(( (ph - hh) / 2 ))
575
- (( y < 4 )) && y=4
597
+ floor=$(( te && ! split ? 4 : pvhd + 2 ))
598
+ (( y < floor )) && y=$floor
599
+ (( y > ph - hh )) && y=$(( ph - hh ))
600
+ (( y < 1 )) && y=1
576
601
  blank=${(l:w:: :)}
577
602
  out+=$'\e['$y';'$x'H'"╭─ Help ${(l:$(( w - 9 ))::─:)}╮"
578
603
  for (( r = y + 1; r < y + hh - 1; r++ )); do
@@ -588,9 +613,9 @@ __tt_pv_help() {
588
613
  __tt_pv_specimen() {
589
614
  local -a sp=(${=applied}) lines parts
590
615
  (( ${#sp} >= 20 )) || return 0
591
- local z=$'\e[0m' d=$'\e[2m' cell hex fore line text piece role tabs="" built="" key="$applied|$painted|$scene|$sw|$sc|$ph"
592
- local -A rs=(p "" d $'\e[2m' b $'\e[1m')
593
- local -i i r=6 cw=4 k n=${#TTHEME_SCENES} at
616
+ local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] cell hex fore line text piece role tabs="" built="" key="$applied|$painted|$scene|$sw|$sc|$ph"
617
+ local -A rs=(p "" d $TTHEME_SGR[dim] b $TTHEME_SGR[bold])
618
+ local -i i r=6 cw=4 k n=${#TTHEME_SCENES} at room
594
619
  (( n )) || return 0
595
620
  if [[ $key == "$pvscene" ]]; then
596
621
  out+=$pvscenes
@@ -624,13 +649,13 @@ __tt_pv_specimen() {
624
649
  for (( k = 1; k <= n; k++ )); do
625
650
  (( k > 1 )) && tabs+=" "
626
651
  if (( k == at )); then
627
- tabs+=$'\e[1m'$ac$TTHEME_SCENES[k]$z
652
+ tabs+=$TTHEME_SGR[bold]$ac$TTHEME_SCENES[k]$z
628
653
  else
629
654
  tabs+=$d$TTHEME_SCENES[k]$z
630
655
  fi
631
656
  done
632
657
  else
633
- tabs=$'\e[1m'$ac$TTHEME_SCENES[at]$z" "$d"$at/$n"$z
658
+ tabs=$TTHEME_SGR[bold]$ac$TTHEME_SCENES[at]$z" "$d"$at/$n"$z
634
659
  fi
635
660
  built+=$'\e[2;'$sc'H'$tabs
636
661
  (( sw < 44 )) && cw=3
@@ -639,7 +664,7 @@ __tt_pv_specimen() {
639
664
  line=""
640
665
  for (( i = 0; i < 8; i++ )); do
641
666
  fore=${sp[i+5]#\#} hex=${sp[i+13]#\#}
642
- printf -v cell '\e[38;2;%d;%d;%d;48;2;%d;%d;%dm%s\e[0m ' \
667
+ printf -v cell "\e[38;2;%d;%d;%d;48;2;%d;%d;%dm%s${TTHEME_SGR[/ink]} " \
643
668
  $((16#${fore:0:2})) $((16#${fore:2:2})) $((16#${fore:4:2})) \
644
669
  $((16#${hex:0:2})) $((16#${hex:2:2})) $((16#${hex:4:2})) "${(l:cw::▀:)}"
645
670
  line+=$cell
@@ -651,11 +676,17 @@ __tt_pv_specimen() {
651
676
  [[ $line == «n»* ]] && (( sw >= 44 )) && continue
652
677
  (( r < ph )) || break
653
678
  parts=("${(@s:«:)line}")
654
- text=$parts[1]
679
+ text=$parts[1] room=$sw
680
+ while (( ${(m)#text} > room )); do text=${text[1,-2]}; done
681
+ (( room -= ${(m)#text} ))
655
682
  for piece in "${(@)parts[2,-1]}"; do
683
+ (( room > 0 )) || break
656
684
  role=${piece%%»*}
657
685
  [[ $role == [wn] ]] && role=p
658
- text+=$z${rs[${role:-p}]}${piece#*»}
686
+ piece=${piece#*»}
687
+ while (( ${(m)#piece} > room )); do piece=${piece[1,-2]}; done
688
+ text+=$z${rs[${role:-p}]}$piece
689
+ (( room -= ${(m)#piece} ))
659
690
  done
660
691
  built+=$'\e['$r';'$sc'H'$text$z
661
692
  (( ++r ))
@@ -808,6 +839,7 @@ __tt_pv_conf_save() {
808
839
  __tt_tilde "$TTHEME_CONFIG"
809
840
  if __tt_config_write "${pairs[@]}"; then
810
841
  conf=0 msg="Saved · $REPLY" msgt=200
842
+ (( ${pairs[(Ie)TTHEME_TAB_PALETTE]} )) && __tt_cli sync > /dev/null 2>&1 && __tt_reload
811
843
  (( ${pairs[(Ie)TTHEME_BG_BLUR]} )) && __tt_pv_redraw
812
844
  else
813
845
  __tt_pv_unconf
@@ -834,7 +866,7 @@ __tt_pv_redraw() {
834
866
  }
835
867
 
836
868
  __tt_pv_conf_panel() {
837
- local z=$'\e[0m' b=$'\e[1m' d=$'\e[2m' c=$ac on=$'\e[7;1m'$ac var v note
869
+ local z=$TTHEME_SGR[reset] b=$TTHEME_SGR[bold] d=$TTHEME_SGR[dim] c=$ac on=$pl var v note
838
870
  local -a ch sh
839
871
  local -i r0=$1 col=$2 end=$3 k i j fit=1
840
872
  (( color )) || z= b= d= c= on=
@@ -904,11 +936,11 @@ __tt_pv_flush() {
904
936
  elif (( ${#bgthumb} )); then
905
937
  __tt_pv_bg_strip_off
906
938
  fi
907
- printf '\e[1;%dH\e[?2026l' $(( 4 + ${(m)#flt} ))
939
+ printf '\e[%d;%dH\e[?2026l' $pvsr $pvsc
908
940
  }
909
941
 
910
942
  __tt_pv_reach() {
911
- local key=${pkeys[pk]} base top k home=${HOME:a} here=${PWD:a} htip="" d=$'\e[2m' z=$'\e[0m' REPLY
943
+ local key=${pkeys[pk]} base top k home=${HOME:a} here=${PWD:a} htip="" d=$TTHEME_SGR[dim] z=$TTHEME_SGR[reset] REPLY
912
944
  local -A own=() below=() parent=() mark=() tstrip=()
913
945
  local -a roots=() lp=() lpw=() ll=() lat=() lpal=() lnote=() lflag=() reply was=()
914
946
  local -A TTHEME_PINS=("${(@kv)TTHEME_PINS}")
@@ -941,7 +973,7 @@ __tt_pv_reach() {
941
973
  __tt_map_build "$top"
942
974
  fi
943
975
  __tt_map_fit $1
944
- (( ${#reply} > room )) && reply=("${(@)reply[1,room-1]}" " …")
976
+ (( ${#reply} > room )) && reply=("${(@)reply[1,room-1]}" " …")
945
977
  reach=("${reply[@]}")
946
978
  [[ $key == /* || ${#was} -gt 0 ]] && reach+=("")
947
979
  __tt_pin_where "$key"
@@ -959,8 +991,8 @@ __tt_pv_reach() {
959
991
  }
960
992
 
961
993
  __tt_pv_draw() {
962
- local out line cnt ex ag="" acat="" ac="" sb="" dd="" zz="" state=on src="" nflt="" rsub="" REPLY
963
- local -i lw sw split sc se=$(( pw - 2 )) h k i N=${#rval} mt=${#TTHEME_ORDER} wiped=0
994
+ local out line cnt ex ag="" acat="" ac="" gc="" pl="" hm="" sb="" dd="" zz="" state=on src="" nflt="" rsub="" REPLY
995
+ local -i lw sw split sc se=$(( pw - 2 )) h k i N=${#rval} mt=${#TTHEME_ORDER} wiped=0 tall=$(( ph >= 22 )) hd
964
996
  local -a held
965
997
  bgstrip=""
966
998
  if [[ -n $flt ]]; then
@@ -970,15 +1002,16 @@ __tt_pv_draw() {
970
1002
  __tt_pv_lw
971
1003
  lw=$reply[1] sw=$reply[2]
972
1004
  split=$(( sw > 0 )) sc=$(( pw - 1 - sw ))
973
- h=$(( ph - 5 ))
974
- (( conf && ! split )) && h=$(( ph - 6 - ${#cvars} ))
1005
+ hd=$(( tall ? hub + 4 : 2 )) pvhd=$hd
1006
+ h=$(( ph - hd - 3 ))
1007
+ (( conf && ! split )) && h=$(( ph - hd - 4 - ${#cvars} ))
975
1008
  reach=()
976
1009
  if [[ -n $pick && $mode == pin ]]; then
977
1010
  if (( split )); then
978
1011
  __tt_pv_reach $sw $(( ph - 6 ))
979
1012
  else
980
- __tt_pv_reach $se $(( ph - 13 ))
981
- h=$(( ph - 6 - ${#reach} ))
1013
+ __tt_pv_reach $se $(( ph - hd - 11 ))
1014
+ h=$(( ph - hd - 4 - ${#reach} ))
982
1015
  fi
983
1016
  fi
984
1017
  (( h < 1 )) && h=1
@@ -987,12 +1020,16 @@ __tt_pv_draw() {
987
1020
  (( top < 1 )) && top=1
988
1021
  (( N > h && top > N - h + 1 )) && top=$(( N - h + 1 ))
989
1022
  if (( color )); then
990
- dd=$'\e[2m' zz=$'\e[0m'
1023
+ dd=$TTHEME_SGR[dim] zz=$TTHEME_SGR[reset] ac=$TTHEME_SGR[accent] pl=$TTHEME_SGR[pill] hm=$TTHEME_SGR[match]
991
1024
  if [[ -n $applied ]]; then
992
1025
  local -a ap=(${=applied})
993
- local acx=${ap[3]#\#} sbx=${ap[4]#\#}
994
- printf -v ac '\e[38;2;%d;%d;%dm' $((16#${acx:0:2})) $((16#${acx:2:2})) $((16#${acx:4:2}))
1026
+ local acx=${ap[3]#\#} sbx=${ap[4]#\#} six=${ap[11]#\#}
1027
+ printf -v gc '\e[38;2;%d;%d;%dm' $((16#${acx:0:2})) $((16#${acx:2:2})) $((16#${acx:4:2}))
995
1028
  printf -v sb '\e[48;2;%d;%d;%dm' $((16#${sbx:0:2})) $((16#${sbx:2:2})) $((16#${sbx:4:2}))
1029
+ if [[ $applied != "$painted" && -n $six ]]; then
1030
+ printf -v ac '\e[38;2;%d;%d;%dm' $((16#${six:0:2})) $((16#${six:2:2})) $((16#${six:4:2}))
1031
+ pl+=$ac hm+=$ac
1032
+ fi
996
1033
  fi
997
1034
  if [[ ${rtype[cur]} == thm ]]; then
998
1035
  ag=${TTHEME_GROUP[${rval[cur]}]:-Other}
@@ -1012,12 +1049,15 @@ __tt_pv_draw() {
1012
1049
  fi
1013
1050
  [[ $1 == hint ]] && (( ! wiped )) || pvz=()
1014
1051
  if (( pw < 40 || ph < 12 )); then
1015
- line="ttheme"
1016
- (( color )) && line=$'\e[1m'$ac$line$'\e[0m'
1017
- out+=$line$'\e[K\n'"Needs 40×12 — now ${pw}×${ph}"$'\e[K\n'
1018
- line="esc quits"
1019
- (( color )) && line=$'\e[2m'$line$'\e[0m'
1020
- out+=$line$'\e[K\e[J'
1052
+ local -a small=(ttheme "Needs 40×12 — now ${pw}×${ph}" "esc quits") paint=("" "" "")
1053
+ (( color )) && paint=($TTHEME_SGR[bold]$ac "" $TTHEME_SGR[dim])
1054
+ for (( k = 1; k <= 3 && k <= ph; k++ )); do
1055
+ line=${small[k]}
1056
+ while (( ${(m)#line} > pw )); do line=${line[1,-2]}; done
1057
+ (( k > 1 )) && out+=$'\n'
1058
+ out+=${paint[k]}$line${paint[k]:+$TTHEME_SGR[reset]}$'\e[K'
1059
+ done
1060
+ out+=$'\e[J'
1021
1061
  __tt_pv_flush
1022
1062
  return 0
1023
1063
  fi
@@ -1025,15 +1065,14 @@ __tt_pv_draw() {
1025
1065
  __tt_pv_te_draw
1026
1066
  return 0
1027
1067
  fi
1068
+ local find bd="" edge=${(l:$(( lw - 3 ))::─:)}
1069
+ (( color )) && bd=$TTHEME_SGR[bold]
1028
1070
  if [[ -n $flt ]]; then
1029
- if (( color )); then
1030
- line=" "$'\e[1m'$flt$zz$ac$'\e[7m \e[0m'
1031
- else
1032
- line=" ${flt}_"
1033
- fi
1071
+ find=$flt"_"
1034
1072
  else
1035
1073
  ex="$expal | $exgrp"
1036
- (( ${#ex} > lw - 19 - ${#cnt} )) && ex="${ex[1,lw-20-${#cnt}]}…"
1074
+ local -i room=$(( tall ? lw - 21 : lw - 19 - ${#cnt} ))
1075
+ (( ${#ex} > room )) && ex="${ex[1,room-1]}…"
1037
1076
  if (( gstep > 0 )); then
1038
1077
  local gkeep=$(( ${#ex} * (8 - gstep) / 8 ))
1039
1078
  if [[ $TTHEME_FX == (decode|glitch) ]]; then
@@ -1051,44 +1090,54 @@ __tt_pv_draw() {
1051
1090
  ex="${ex[1,gkeep]}▏"
1052
1091
  fi
1053
1092
  fi
1054
- line=" "$dd"Search… e.g. $ex"$zz
1093
+ find=$dd"Search… e.g. $ex"$zz
1094
+ fi
1095
+ if (( tall )); then
1096
+ pvsr=$(( hub + 3 )) pvsc=$(( 6 + ${(m)#flt} ))
1097
+ line=$'\e['$lw'X '$dd"│"$zz" "$dd"⌕"$zz" "$find$'\e['$lw'G'$dd"│"$zz
1098
+ else
1099
+ pvsr=$(( hub + 1 )) pvsc=$(( 4 + ${(m)#flt} ))
1100
+ line=$'\e['$lw'X '$dd"⌕"$zz" "$find$'\e['$(( lw - ${#cnt} ))'G'$dd$cnt$zz
1055
1101
  fi
1056
- local tail=$'\e['$(( lw - ${#cnt} ))'G'$dd$cnt$zz
1057
- [[ -n $flt ]] && tail=$'\e['$(( lw - ${#cnt} ))'G'$cnt
1058
1102
  if [[ $1 == hint ]] && (( ! wiped )); then
1059
- print -rn -- $'\e['$(( 1 + hub ))$'H\e[0m\e['$lw'X'$line$tail
1060
- printf '\e[%d;%dH\e[?2026l' $(( 1 + hub )) $(( 4 + ${(m)#flt} ))
1103
+ print -rn -- $'\e['$pvsr'H'$TTHEME_SGR[reset]$line
1104
+ printf '\e[%d;%dH\e[?2026l' $pvsr $pvsc
1061
1105
  return 0
1062
1106
  fi
1063
1107
  if (( hub )); then
1064
1108
  __tt_pv_bar $(( split ? sc - 2 : pw - 1 ))
1065
- out+=$REPLY$'\e[K\n'$line$'\e[K'$tail$'\n'
1109
+ out+=$REPLY$'\e[K\n'
1110
+ fi
1111
+ if (( tall )); then
1112
+ out+=" "$bd"Preview"$zz" "$dd"($cnt)"$zz$'\e[K\n'
1113
+ out+=" "$dd"╭"$edge"╮"$zz$'\e[K\n'$line$'\e[K\n'" "$dd"╰"$edge"╯"$zz$'\e[K\n'
1066
1114
  else
1067
- out+=$line$'\e[K'$tail$'\n\e[K\n'
1115
+ out+=$line$'\e[K\n'
1116
+ (( hub )) || out+=$'\e[K\n'
1068
1117
  fi
1069
1118
  if (( N > h && top > 1 )); then
1070
1119
  out+=" "$dd"…"$zz
1071
- pvz+=("3 1 $lw more -1")
1120
+ pvz+=("$(( hd + 1 )) 1 $lw more -1")
1072
1121
  fi
1073
1122
  out+=$'\e[K\n'
1074
- for (( k = 0; k < ph - 4; k++ )); do
1123
+ for (( k = 0; k < ph - hd - 2; k++ )); do
1075
1124
  i=$(( top + k ))
1076
1125
  line=""
1077
1126
  if (( k < h )); then
1078
1127
  if (( ! N )); then
1079
- (( k == 0 )) && line=" ${dd}No palettes match '$flt'$zz"
1128
+ (( k == 0 )) && { __tt_clip " ${dd}No palettes match '$flt'$zz" $lw; line=$REPLY }
1080
1129
  elif (( i <= N )); then
1081
1130
  __tt_pv_row $i
1082
1131
  line=$REPLY
1083
- pvz+=("$(( 4 + k )) 1 $lw row $i")
1132
+ pvz+=("$(( hd + 2 + k )) 1 $lw row $i")
1084
1133
  case ${rtype[i]} in
1085
- hdr) pvz+=("$(( 4 + k )) 3 5 fold $i") ;;
1086
- cat) pvz+=("$(( 4 + k )) 5 7 fold $i") ;;
1134
+ hdr) pvz+=("$(( hd + 2 + k )) 3 5 fold $i") ;;
1135
+ cat) pvz+=("$(( hd + 2 + k )) 5 7 fold $i") ;;
1087
1136
  esac
1088
1137
  fi
1089
1138
  elif (( k == h && N > h && top + h <= N )); then
1090
1139
  line=" "$dd"…"$zz
1091
- pvz+=("$(( 4 + k )) 1 $lw more 1")
1140
+ pvz+=("$(( hd + 2 + k )) 1 $lw more 1")
1092
1141
  fi
1093
1142
  out+=$line$'\e[K\n'
1094
1143
  done
@@ -1167,20 +1216,14 @@ __tt_pv_strip() {
1167
1216
  cell+=" "
1168
1217
  fi
1169
1218
  done
1170
- tstrip[$1]=$cell$'\e[39m'
1219
+ tstrip[$1]=$cell$TTHEME_SGR[/fg]
1171
1220
  }
1172
1221
 
1173
1222
  __tt_pv_init() {
1174
- local lo
1175
- local -a tp
1176
1223
  __tt_pv_group
1177
1224
  [[ -n $orig ]] && __tt_name_of "$orig" && cn=$REPLY
1178
1225
  [[ -n ${TTHEME_PALETTE[$cn]} ]] || return 0
1179
1226
  cdot="◆"
1180
- (( color )) || return 0
1181
- tp=(${=TTHEME_PALETTE[$cn]})
1182
- lo=${tp[3]#\#}
1183
- printf -v cdot '\e[38;2;%d;%d;%dm◆\e[39m' $((16#${lo:0:2})) $((16#${lo:2:2})) $((16#${lo:4:2}))
1184
1227
  }
1185
1228
 
1186
1229
  __tt_pv_roll() {
@@ -1247,6 +1290,7 @@ __tt_pv_read() {
1247
1290
  if [[ $REPLY != '[' && $REPLY != O ]]; then
1248
1291
  key=nop
1249
1292
  [[ $REPLY == c ]] && key=altc
1293
+ [[ $REPLY == [\]P_^X] ]] && __tt_pv_string
1250
1294
  return 0
1251
1295
  fi
1252
1296
  while __tt_pv_getch 0.05; do
@@ -1268,10 +1312,33 @@ __tt_pv_read() {
1268
1312
  Z) key=stab ;;
1269
1313
  '<'<->';'<->';'<->[Mm]) __tt_pv_sgr $seq ;;
1270
1314
  M) __tt_pv_x10 ;;
1315
+ "200~") __tt_pv_paste ;;
1271
1316
  *) key=nop ;;
1272
1317
  esac
1273
1318
  }
1274
1319
 
1320
+ __tt_pv_string() {
1321
+ local prev=""
1322
+ while __tt_pv_getch 0.05; do
1323
+ [[ $REPLY == $'\a' || ( $prev == $'\e' && $REPLY == \\ ) ]] && return 0
1324
+ prev=$REPLY
1325
+ done
1326
+ }
1327
+
1328
+ __tt_pv_paste() {
1329
+ setopt localoptions extendedglob
1330
+ local text=""
1331
+ key=nop
1332
+ while __tt_pv_getch 0.5; do
1333
+ text+=$REPLY
1334
+ [[ $REPLY == '~' && $text == *$'\e[201~' ]] && break
1335
+ done
1336
+ text=${${text%$'\e[201~'}//[$'\r\n\t']##/ }
1337
+ pasted=${text//[[:cntrl:]]/}
1338
+ [[ -n $pasted ]] && key=paste
1339
+ return 0
1340
+ }
1341
+
1275
1342
  __tt_pv_sgr() {
1276
1343
  local -a p=(${(s:;:)${${1#<}%[Mm]}})
1277
1344
  local -i b=$p[1]
@@ -1370,12 +1437,15 @@ __tt_pv_free() {
1370
1437
  }
1371
1438
 
1372
1439
  __tt_pv_press() {
1440
+ [[ $4 == tereset ]] || tearm=0
1373
1441
  case $4 in
1374
1442
  row|fold) __tt_pv_free && [[ ${rtype[$5]} != rule ]] && cur=$5 ;;
1375
1443
  pick) pk=$5 ;;
1376
1444
  conf) cf=$5 ;;
1377
1445
  teimg) (( tfocus == 1 )) || __tt_te_to_image ;;
1378
- tepal|teedit) tfocus=0 ;;
1446
+ tepal) tfocus=0 ;;
1447
+ teedit) tfocus=0 tbtn=0 ;;
1448
+ tereset) tfocus=0 tbtn=1 ;;
1379
1449
  tefield|track|place|colors)
1380
1450
  (( tfocus == 1 )) || __tt_te_to_image
1381
1451
  case $4 in
@@ -1432,6 +1502,7 @@ __tt_pv_release() {
1432
1502
  ;;
1433
1503
  tefind) __tt_te_find ;;
1434
1504
  teedit) __tt_te_edit ;;
1505
+ tereset) __tt_te_resetting ;;
1435
1506
  teapply) __tt_te_apply || return 1 ;;
1436
1507
  place) __tt_pv_bg_adjust at $5 ;;
1437
1508
  colors)
@@ -1512,13 +1583,14 @@ __tt_pv_screen() {
1512
1583
  to=$at
1513
1584
  fi
1514
1585
  done
1515
- printf '\e[?2026h\e[?25l%s' "$pvmouse"
1586
+ printf '\e[?2026h\e[?25l\e[?2004h%s' "$pvmouse"
1516
1587
  if [[ -n $applied ]]; then
1517
1588
  __tt_pv_paint "$applied"
1518
1589
  else
1519
1590
  __tt_osc_reset
1520
1591
  painted=""
1521
1592
  fi
1593
+ __tt_pv_size
1522
1594
  resized=1 bgname="" bgshown="" bgdim=()
1523
1595
  return 0
1524
1596
  }
@@ -1558,7 +1630,7 @@ __tt_te_read() {
1558
1630
 
1559
1631
  __tt_te_open() {
1560
1632
  local name=$1
1561
- tename=$name tfocus=0 teframe=() tetop=0 msgt=0 te=1
1633
+ tename=$name tfocus=0 teframe=() tetop=0 msgt=0 te=1 tbtn=0 tearm=0
1562
1634
  if ! __tt_te_read; then
1563
1635
  msg="Could not read the colors of $name" msgt=300
1564
1636
  tename="" te=0
@@ -1572,7 +1644,7 @@ __tt_te_open() {
1572
1644
 
1573
1645
  __tt_te_close() {
1574
1646
  [[ -n $tune ]] && __tt_pv_untune
1575
- te=0 tfocus=0 tename="" teframe=() tetop=0 help=0 pick=""
1647
+ te=0 tfocus=0 tename="" teframe=() tetop=0 tbtn=0 tearm=0 help=0 pick=""
1576
1648
  resized=1 bgname=""
1577
1649
  return 0
1578
1650
  }
@@ -1644,8 +1716,14 @@ __tt_pv_unpaint() {
1644
1716
  fi
1645
1717
  }
1646
1718
 
1719
+ __tt_te_follow() {
1720
+ [[ $orig == "$1" && -n ${TTHEME_PALETTE[$tename]} ]] || return 0
1721
+ orig=${TTHEME_PALETTE[$tename]}
1722
+ TTHEME_SPEC=$orig
1723
+ }
1724
+
1647
1725
  __tt_te_edit() {
1648
- local name=$tename err back=$applied
1726
+ local name=$tename err back=$applied was=${TTHEME_PALETTE[$tename]}
1649
1727
  local -i rc
1650
1728
  __tt_te_save_image
1651
1729
  __tt_pv_untune
@@ -1655,11 +1733,13 @@ __tt_te_edit() {
1655
1733
  __tt_bg_hide $name
1656
1734
  err=$(__tt_cli tone $name edit 2>&1 >/dev/tty)
1657
1735
  rc=$?
1658
- printf %s "$pvmouse"
1736
+ printf '\e[?2004h%s' "$pvmouse"
1737
+ __tt_pv_size
1659
1738
  err=${${err//$'\n'/ }## #}
1660
1739
  resized=1 bgname="" bgshown="" bgdim=()
1661
1740
  if (( rc == 0 )); then
1662
1741
  __tt_palettes_load && __tt_reloaded
1742
+ __tt_te_follow "$was"
1663
1743
  __tt_reload
1664
1744
  back=${TTHEME_PALETTE[$name]:-$back}
1665
1745
  fi
@@ -1677,11 +1757,56 @@ __tt_te_edit() {
1677
1757
  return 0
1678
1758
  }
1679
1759
 
1760
+ __tt_te_reset() {
1761
+ local name=$tename err was=${TTHEME_PALETTE[$tename]}
1762
+ local -i rc
1763
+ __tt_te_save_image
1764
+ __tt_pv_untune
1765
+ __tt_pv_bg_close
1766
+ err=$(__tt_cli tone $name reset 2>&1 >/dev/null)
1767
+ rc=$?
1768
+ err=${${err//$'\n'/ }## #}
1769
+ tbtn=0 tearm=0 resized=1 bgname="" bgshown="" bgdim=()
1770
+ if (( rc == 0 )); then
1771
+ __tt_palettes_load && __tt_reloaded
1772
+ __tt_te_follow "$was"
1773
+ __tt_reload
1774
+ [[ -n ${TTHEME_PALETTE[$name]} ]] && __tt_pv_paint "${TTHEME_PALETTE[$name]}" && applied=${TTHEME_PALETTE[$name]}
1775
+ __tt_pv_bg_reset $name
1776
+ bgload[$name]=""
1777
+ __tt_te_read
1778
+ msg=${err:-"Back to the original colors"} msgt=200
1779
+ elif (( rc == 1 )); then
1780
+ msg=${err:-"Could not reset the colors of $name"} msgt=300
1781
+ fi
1782
+ __tt_pv_bg_state $name && __tt_pv_tune_open $name
1783
+ return 0
1784
+ }
1785
+
1786
+ __tt_te_resetting() {
1787
+ if (( tearm )); then
1788
+ __tt_te_reset
1789
+ else
1790
+ tearm=1
1791
+ fi
1792
+ }
1793
+
1680
1794
  __tt_te_palette() {
1795
+ local -i armed=$tearm
1796
+ tearm=0
1797
+ (( ${TTHEME_TUNED[(Ie)$tename]} )) || tbtn=0
1681
1798
  case $key in
1682
- $'\r'|$'\n') __tt_te_edit ;;
1799
+ $'\r'|$'\n')
1800
+ if (( tbtn )); then
1801
+ tearm=$armed
1802
+ __tt_te_resetting
1803
+ else
1804
+ __tt_te_edit
1805
+ fi
1806
+ ;;
1807
+ left|right) (( ${TTHEME_TUNED[(Ie)$tename]} )) && tbtn=$(( ! tbtn )) ;;
1683
1808
  s) __tt_te_save ;;
1684
- esc) __tt_te_close ;;
1809
+ esc) (( armed )) || __tt_te_close ;;
1685
1810
  up|k)
1686
1811
  if __tt_te_image; then
1687
1812
  __tt_te_to_image last
@@ -1769,7 +1894,7 @@ __tt_pv_te() {
1769
1894
  }
1770
1895
 
1771
1896
  __tt_pv_te_head() {
1772
- local z=$'\e[0m' d=$'\e[2m' b=$'\e[1m' y=$'\e[33m' line REPLY
1897
+ local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] y=$TTHEME_SGR[warn] line REPLY
1773
1898
  local -i col=$1 end=$2 room=$(( $2 - $1 + 1 ))
1774
1899
  (( color )) || z= d= b= y=
1775
1900
  __tt_te_unsaved && (( room -= 11 ))
@@ -1782,7 +1907,7 @@ __tt_pv_te_head() {
1782
1907
  }
1783
1908
 
1784
1909
  __tt_pv_te_tile() {
1785
- local z=$'\e[0m' d=$'\e[2m' b=$'\e[1m' sty top side bot
1910
+ local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] sty top side bot
1786
1911
  local -i y=$1 col=$2 r tc=10
1787
1912
  (( color )) || z= d= b=
1788
1913
  if (( tfocus == 1 && tf == 5 )); then
@@ -1804,7 +1929,7 @@ __tt_pv_te_tile() {
1804
1929
  }
1805
1930
 
1806
1931
  __tt_pv_te_ghost() {
1807
- local z=$'\e[0m' d=$'\e[2m'
1932
+ local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim]
1808
1933
  local -i r0=$1 col=$2 T=$(( $3 - $2 - 21 )) i
1809
1934
  (( color )) || z= d=
1810
1935
  (( T < 8 )) && T=8
@@ -1819,7 +1944,7 @@ __tt_pv_te_ghost() {
1819
1944
  }
1820
1945
 
1821
1946
  __tt_pv_te_edge() {
1822
- local left=$4 right=$5 sty=$6 hs=$7 head=$8 tail=$9 z=$'\e[0m' line
1947
+ local left=$4 right=$5 sty=$6 hs=$7 head=$8 tail=$9 z=$TTHEME_SGR[reset] line
1823
1948
  local -i y=$1 col=$2 w=$3 n
1824
1949
  (( color )) || z=
1825
1950
  n=$(( w - 3 - (${#head} ? ${#head} + 2 : 0) - (${#tail} ? ${#tail} + 3 : 0) ))
@@ -1832,7 +1957,7 @@ __tt_pv_te_edge() {
1832
1957
  }
1833
1958
 
1834
1959
  __tt_pv_te_sides() {
1835
- local sty=$5 z=$'\e[0m'
1960
+ local sty=$5 z=$TTHEME_SGR[reset]
1836
1961
  local -i y r1=$2 col=$3 w=$4
1837
1962
  (( color )) || z=
1838
1963
  for (( y = $1; y <= r1; y++ )); do
@@ -1841,7 +1966,7 @@ __tt_pv_te_sides() {
1841
1966
  }
1842
1967
 
1843
1968
  __tt_pv_te_images() {
1844
- local z=$'\e[0m' d=$'\e[2m' b=$'\e[1m' st=" " tt note="0/0"
1969
+ local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] st=" " tt note="0/0"
1845
1970
  local -a held
1846
1971
  local -i y=$1 col=$2 end=$3 n
1847
1972
  (( color )) || z= d= b=
@@ -1858,23 +1983,37 @@ __tt_pv_te_images() {
1858
1983
  pvz+=("$y $col $end teimg")
1859
1984
  }
1860
1985
 
1861
- __tt_pv_te_editrow() {
1862
- local z=$'\e[0m' d=$'\e[2m' b=$'\e[1m' note="tunes its colors full screen"
1863
- local -i y=$1 col=$2 end=$3
1864
- (( color )) || z= d= b=
1865
- pvz+=("$y $col $end teedit")
1866
- out+=$'\e['$y';'$(( col + 2 ))'H'
1867
- if (( tfocus == 0 )); then
1868
- (( color )) && out+=$ac"▶"$z" "$'\e[7;1m'$ac" Edit palette "$z || out+="▶ [Edit palette]"
1986
+ __tt_pv_te_button() {
1987
+ if (( tfocus == 0 && tbtn == $1 )); then
1988
+ (( color )) && out+=$ac"▶"$z" "$pl" $2 "$z || out+="▶ [$2]"
1869
1989
  else
1870
- (( color )) && out+=" "$b" Edit palette "$z || out+=" Edit palette "
1990
+ (( color )) && out+=" "$b" $2 "$z || out+=" $2 "
1871
1991
  fi
1872
- (( ${#note} > end - col - 21 )) && note=${note[1,end-col-21]}
1873
- out+=" "$d$note$z
1992
+ }
1993
+
1994
+ __tt_pv_te_editrow() {
1995
+ local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] note="tunes its colors full screen"
1996
+ local -i y=$1 col=$2 end=$3 x=$(( $2 + 2 ))
1997
+ local reset="Reset palette"
1998
+ (( color )) || z= d= b=
1999
+ out+=$'\e['$y';'$x'H'
2000
+ __tt_pv_te_button 0 "Edit palette"
2001
+ pvz+=("$y $col $(( x + 15 )) teedit")
2002
+ x+=16
2003
+ if (( ${TTHEME_TUNED[(Ie)$tename]} )); then
2004
+ out+=" "
2005
+ (( tearm )) && reset="Reset? enter again"
2006
+ __tt_pv_te_button 1 "$reset"
2007
+ pvz+=("$y $(( x + 2 )) $(( x + ${#reset} + 5 )) tereset")
2008
+ x+=$(( ${#reset} + 6 ))
2009
+ (( tfocus == 0 && tbtn )) && note="back to its own colors"
2010
+ (( tearm )) && note="drops your tone"
2011
+ fi
2012
+ (( ${#note} <= end - x - 3 )) && out+=" "$d$note$z
1874
2013
  }
1875
2014
 
1876
2015
  __tt_pv_te_panel() {
1877
- local z=$'\e[0m' d=$'\e[2m' b=$'\e[1m' fs hs st note row REPLY
2016
+ local z=$TTHEME_SGR[reset] d=$TTHEME_SGR[dim] b=$TTHEME_SGR[bold] dx=$TTHEME_SGR[/dim] bx=$TTHEME_SGR[/bold] ax=$TTHEME_SGR[/accent] fs hs st note row REPLY
1878
2017
  local -i col=$1 end=$2 r0=$3 r1=$4 ix=$(( $1 + 2 )) ie=$(( $2 - 2 )) R W T P I=3 V i y pics=0 tfs=$tf
1879
2018
  (( color )) || z= d= b=
1880
2019
  R=$(( r1 - r0 + 1 )) W=$(( end - col + 1 ))
@@ -1941,8 +2080,8 @@ __tt_pv_te_panel() {
1941
2080
  else
1942
2081
  row=${teframe[i == P ? T : i]}
1943
2082
  if (( tfocus == 0 && color )); then
1944
- row=${${row//$'\e[2m'/$ac}//$'\e[22m'/$'\e[22;39m'}
1945
- (( i == 1 )) && row=${row/ Palette /$'\e[1m Palette \e[22m'}
2083
+ row=${${row//$d/$ac}//$dx/$bx$ax}
2084
+ (( i == 1 )) && row=${row/ Palette /$b" Palette "$bx}
1946
2085
  fi
1947
2086
  out+=$'\e['$y';'$col'H'$row$z
1948
2087
  pvz+=("$y $col $end tepal")
@@ -1960,11 +2099,11 @@ __tt_pv_te_panel() {
1960
2099
  fi
1961
2100
  out+=$'\e['$y';'$ix'H'
1962
2101
  if (( tfocus == 2 )); then
1963
- (( color )) && out+=$ac"▶"$z" "$'\e[7;1m'$ac" Apply "$z || out+="▶ [Apply]"
2102
+ (( color )) && out+=$ac"▶"$z" "$pl" Apply "$z || out+="▶ [Apply]"
1964
2103
  else
1965
2104
  (( color )) && out+=" "$b" Apply "$z || out+=" Apply "
1966
2105
  fi
1967
- out+=" "$d$note$z
2106
+ (( ${#note} <= end - ix - 10 )) && out+=" "$d$note$z
1968
2107
  return 0
1969
2108
  }
1970
2109
 
@@ -2084,7 +2223,7 @@ __tt_pv_handle() {
2084
2223
  if (( cur <= 1 )); then
2085
2224
  (( ${#rval} )) && cur=${#rval}
2086
2225
  else
2087
- cur=$(( cur - ph + 5 ))
2226
+ cur=$(( cur - ph + pvhd + 3 ))
2088
2227
  (( cur < 1 )) && cur=1
2089
2228
  [[ ${rtype[cur]} == rule ]] && cur=$(( cur - 1 ))
2090
2229
  fi
@@ -2093,7 +2232,7 @@ __tt_pv_handle() {
2093
2232
  if (( cur >= ${#rval} )); then
2094
2233
  cur=1
2095
2234
  else
2096
- cur=$(( cur + ph - 5 ))
2235
+ cur=$(( cur + ph - pvhd - 3 ))
2097
2236
  (( cur > ${#rval} )) && cur=${#rval}
2098
2237
  [[ ${rtype[cur]} == rule ]] && cur=$(( cur + 1 ))
2099
2238
  fi
@@ -2134,6 +2273,15 @@ __tt_pv_handle() {
2134
2273
  __tt_pv_rows
2135
2274
  __tt_pv_first "$name"
2136
2275
  ;;
2276
+ paste)
2277
+ __tt_pv_lw
2278
+ name=""
2279
+ [[ ${rtype[cur]} == thm ]] && name=${rval[cur]}
2280
+ flt+=${(L)pasted}
2281
+ while [[ -n $flt ]] && (( ${(m)#flt} > reply[1] - 12 )); do flt=${flt[1,-2]}; done
2282
+ __tt_pv_rows
2283
+ __tt_pv_first "$name"
2284
+ ;;
2137
2285
  esac
2138
2286
  return 0
2139
2287
  }
@@ -2148,7 +2296,7 @@ __tt_preview() {
2148
2296
  print -u2 "ttheme $mode: needs a terminal"
2149
2297
  return 1
2150
2298
  fi
2151
- local orig=$TTHEME_SPEC applied=$TTHEME_SPEC painted=$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 tick=0
2299
+ local orig=$TTHEME_SPEC applied=$TTHEME_SPEC painted=$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 tick=0 pvhd=2 pvsr=1 pvsc=4
2152
2300
  local pick="" pk=1 pkdef=1 picked=0 canpick=0 bgcw=0 bgch=0 bgname="" bgshown="" bginc="" osd="" osdt=0
2153
2301
  local tune="" tpick="" tf=1 help=0 msg="" msgt=0 an="" bgrel=0 bgmx=0 bgmy=0 bganchor=0 bgcut="" bgnext=0 bgbytes=0 bgstrip="" pvscene="" pvscenes=""
2154
2302
  local -i scene=0
@@ -2157,10 +2305,10 @@ __tt_preview() {
2157
2305
  local -A bgpic=() bgpics=() bgact=() bgview=() bgswap=() bgthumb=() tsnaps=() pvseek=() bgcolors=() bgprep=() TTHEME_ALIASES=()
2158
2306
  local conf=0 cf=1
2159
2307
  local -a plabel=(" Default " " This tab ") pkeys=() reach=() csnap=() teframe=()
2160
- local te=0 tfocus=0 tetop=0 tewide=0 tename=""
2308
+ local te=0 tfocus=0 tetop=0 tewide=0 tbtn=0 tearm=0 tename=""
2161
2309
  local -i pvgone=0 bgprepid=0 mrow=0 mcol=0 mclick=0 mwheel=0 mlwheel=0 mlrow=0 mlcol=0
2162
2310
  local -F mlast=0
2163
- local mact="" mzone="" pvmouse=""
2311
+ local mact="" mzone="" pvmouse="" pasted=""
2164
2312
  local -a pvz=()
2165
2313
  local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT TTHEME_MOUSE TTHEME_BG_BLUR TTHEME_BG_COLORS) clabel=("New tabs" Announce "Search fx" Sort Mouse Blur Colors)
2166
2314
  local -a cchoice=("off seq" "1 0" "typewriter decode glitch" "abc series" "on off" "0 1 2 3 4" "tone original") cshow=("off seq" "on off" "typewriter decode glitch" "abc series" "on off" "off 1px 2px 3px 4px" "tone original")
@@ -2195,7 +2343,7 @@ __tt_preview() {
2195
2343
  tty=$(stty -g 2>/dev/null) && stty -echo -icanon -ixon min 1 time 0 2>/dev/null || tty=""
2196
2344
  TTHEME_RAW=$(( ${#tty} > 0 ))
2197
2345
  __tt_pv_bg_open
2198
- printf '\e[?2026h\e[?1049h\e[?7l\e[?25l'
2346
+ printf '\e[?2026h\e[?1049h\e[?7l\e[?25l\e[?2004h'
2199
2347
  __tt_pv_pointer
2200
2348
  while :; do
2201
2349
  printf '\e[?2026h'
@@ -2228,7 +2376,7 @@ __tt_preview() {
2228
2376
  __tt_pv_unpaint
2229
2377
  fi
2230
2378
  __tt_pv_pointer off
2231
- printf '\e[?7h'
2379
+ printf '\e[?2004l\e[?7h'
2232
2380
  (( hubleft )) || printf '\e[?1049l'
2233
2381
  printf '\e[?25h\e[?2026l'
2234
2382
  [[ -n $tty ]] && stty "$tty" 2>/dev/null