try-cli 1.10.0 → 1.10.1
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/tui.rb +3 -2
- data/try.rb +30 -15
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6bc9090ddafc7354bd7d4207e5247e9afd3f52df65e43c1600e21f717c3644cb
|
|
4
|
+
data.tar.gz: cc3fbc4c3868d6d504e326702329fa14d377257d9300c468c07f929f5137c176
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21c62da72659e06ca9614d1ee82f8063f80f13b153e53af39102cdb21e083ab00c46d0d97c42a91cbbe8e0142d5030448660fd9594790bb4da753a0f8314de20
|
|
7
|
+
data.tar.gz: 83376a51f4be2be9fe9dcb4c0de857174fd53d1409ec65b1e1f6cc5d9728a4bcff5bfa800fe180e63f799aab1063c207ab8a6ab11196351715454a3f934819ab
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.10.
|
|
1
|
+
1.10.1
|
data/lib/tui.rb
CHANGED
|
@@ -90,14 +90,15 @@ module Tui
|
|
|
90
90
|
module Palette
|
|
91
91
|
HEADER = ANSI.sgr(1, "38;5;114")
|
|
92
92
|
ACCENT = ANSI.sgr(1, "38;5;214")
|
|
93
|
-
HIGHLIGHT = "\e[
|
|
93
|
+
HIGHLIGHT = "\e[1;33m" # Bold yellow remains readable on the controlled selected background
|
|
94
94
|
MUTED = ANSI.fg(245)
|
|
95
95
|
MATCH = ANSI.sgr(1, "38;5;226")
|
|
96
96
|
INPUT_HINT = ANSI.fg(244)
|
|
97
97
|
INPUT_CURSOR_ON = "\e[7m"
|
|
98
98
|
INPUT_CURSOR_OFF = "\e[27m"
|
|
99
99
|
|
|
100
|
-
SELECTED_BG =
|
|
100
|
+
SELECTED_BG = ANSI.bg(238) # Preserve the dark selected-row appearance
|
|
101
|
+
SELECTED_FG = ANSI.fg(255) # Keep selected content readable on every theme
|
|
101
102
|
DANGER_BG = ANSI.bg(52)
|
|
102
103
|
end
|
|
103
104
|
|
data/try.rb
CHANGED
|
@@ -389,15 +389,15 @@ class TrySelector
|
|
|
389
389
|
|
|
390
390
|
def render_entry_line(screen, entry, is_selected, width)
|
|
391
391
|
is_marked = @marked_for_deletion.include?(entry[:path])
|
|
392
|
-
# Marked items
|
|
392
|
+
# Marked items keep the danger background; selected rows add a readable foreground.
|
|
393
393
|
background = if is_marked
|
|
394
|
-
Tui::Palette::DANGER_BG
|
|
394
|
+
Tui::Palette::DANGER_BG + (is_selected ? Tui::Palette::SELECTED_FG : "")
|
|
395
395
|
elsif is_selected
|
|
396
|
-
Tui::Palette::SELECTED_BG
|
|
396
|
+
Tui::Palette::SELECTED_BG + Tui::Palette::SELECTED_FG
|
|
397
397
|
end
|
|
398
398
|
|
|
399
399
|
line = screen.body.add_line(background: background)
|
|
400
|
-
line.write << (is_selected ? Tui::Text.highlight("→ ") : " ")
|
|
400
|
+
line.write << (is_selected ? Tui::Text.highlight("→ ") + selected_foreground : " ")
|
|
401
401
|
icon = if is_marked
|
|
402
402
|
emoji("🗑️")
|
|
403
403
|
elsif entry[:is_symlink]
|
|
@@ -407,7 +407,7 @@ class TrySelector
|
|
|
407
407
|
end
|
|
408
408
|
line.write << icon << " "
|
|
409
409
|
|
|
410
|
-
plain_name, rendered_name = formatted_entry_name(entry)
|
|
410
|
+
plain_name, rendered_name = formatted_entry_name(entry, selected: is_selected)
|
|
411
411
|
prefix_width = 5
|
|
412
412
|
meta_text = "#{format_relative_time(entry[:mtime])}, #{format('%.1f', entry[:score])}"
|
|
413
413
|
|
|
@@ -422,13 +422,15 @@ class TrySelector
|
|
|
422
422
|
line.write << display_rendered
|
|
423
423
|
|
|
424
424
|
# Right content is lower layer - will be overwritten by left if they overlap
|
|
425
|
-
line.right.
|
|
425
|
+
line.right.write(is_selected ? meta_text : Tui::Text.dim(meta_text))
|
|
426
426
|
end
|
|
427
427
|
|
|
428
428
|
def render_create_line(screen, is_selected, width)
|
|
429
|
-
background = is_selected
|
|
429
|
+
background = if is_selected
|
|
430
|
+
Tui::Palette::SELECTED_BG + Tui::Palette::SELECTED_FG
|
|
431
|
+
end
|
|
430
432
|
line = screen.body.add_line(background: background)
|
|
431
|
-
line.write << (is_selected ? Tui::Text.highlight("→ ") : " ")
|
|
433
|
+
line.write << (is_selected ? Tui::Text.highlight("→ ") + selected_foreground : " ")
|
|
432
434
|
date_prefix = Time.now.strftime("%Y-%m-%d")
|
|
433
435
|
label = if @input_buffer.empty?
|
|
434
436
|
"📂 Create new: #{date_prefix}-"
|
|
@@ -438,7 +440,7 @@ class TrySelector
|
|
|
438
440
|
line.write << label
|
|
439
441
|
end
|
|
440
442
|
|
|
441
|
-
def formatted_entry_name(entry)
|
|
443
|
+
def formatted_entry_name(entry, selected: false)
|
|
442
444
|
basename = entry[:basename]
|
|
443
445
|
positions = entry[:highlight_positions] || []
|
|
444
446
|
|
|
@@ -447,17 +449,25 @@ class TrySelector
|
|
|
447
449
|
name_part = $2
|
|
448
450
|
date_len = date_part.length + 1 # +1 for the hyphen
|
|
449
451
|
|
|
450
|
-
rendered = Tui::Text.dim(date_part)
|
|
452
|
+
rendered = selected ? date_part : Tui::Text.dim(date_part)
|
|
451
453
|
# Highlight hyphen if it's in positions
|
|
452
|
-
|
|
453
|
-
|
|
454
|
+
hyphen = if positions.include?(10)
|
|
455
|
+
Tui::Text.highlight('-')
|
|
456
|
+
elsif selected
|
|
457
|
+
'-'
|
|
458
|
+
else
|
|
459
|
+
Tui::Text.dim('-')
|
|
460
|
+
end
|
|
461
|
+
rendered += hyphen
|
|
462
|
+
rendered += selected_foreground if selected && positions.include?(10)
|
|
463
|
+
rendered += highlight_with_positions(name_part, positions, date_len, selected: selected)
|
|
454
464
|
["#{date_part}-#{name_part}", rendered]
|
|
455
465
|
else
|
|
456
|
-
[basename, highlight_with_positions(basename, positions, 0)]
|
|
466
|
+
[basename, highlight_with_positions(basename, positions, 0, selected: selected)]
|
|
457
467
|
end
|
|
458
468
|
end
|
|
459
469
|
|
|
460
|
-
def highlight_with_positions(text, positions, offset)
|
|
470
|
+
def highlight_with_positions(text, positions, offset, selected: false)
|
|
461
471
|
pos_set = positions.is_a?(Set) ? positions : positions.to_set
|
|
462
472
|
result = String.new
|
|
463
473
|
chars = text.chars
|
|
@@ -469,6 +479,7 @@ class TrySelector
|
|
|
469
479
|
i += 1
|
|
470
480
|
i += 1 while i < chars.length && pos_set.include?(i + offset)
|
|
471
481
|
result << Tui::Text.highlight(chars[batch_start...i].join)
|
|
482
|
+
result << selected_foreground if selected
|
|
472
483
|
else
|
|
473
484
|
result << chars[i]
|
|
474
485
|
i += 1
|
|
@@ -477,6 +488,10 @@ class TrySelector
|
|
|
477
488
|
result
|
|
478
489
|
end
|
|
479
490
|
|
|
491
|
+
def selected_foreground
|
|
492
|
+
Tui.colors_enabled? ? Tui::Palette::SELECTED_FG : ""
|
|
493
|
+
end
|
|
494
|
+
|
|
480
495
|
# Find the position of the previous word boundary for Ctrl-W deletion.
|
|
481
496
|
# Skips non-alphanumeric chars, then skips alphanumeric chars.
|
|
482
497
|
def word_boundary_backward(buffer, cursor)
|
|
@@ -955,7 +970,7 @@ end
|
|
|
955
970
|
# Main execution with OptionParser subcommands
|
|
956
971
|
if __FILE__ == $0
|
|
957
972
|
|
|
958
|
-
VERSION = "1.10.
|
|
973
|
+
VERSION = "1.10.1"
|
|
959
974
|
|
|
960
975
|
def print_global_help
|
|
961
976
|
text = <<~HELP
|