terminal_rb 0.16.2 → 0.17.0
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/lib/terminal/ansi.rb +43 -2
- data/lib/terminal/input.rb +1 -1
- data/lib/terminal/shell.rb +4 -0
- data/lib/terminal/version.rb +1 -1
- data/lib/terminal.rb +2 -0
- 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: 4a91661bad1d2b3b3d432dd5ae4e0e0101b3a006773d30c58a39a75c703ab03e
|
|
4
|
+
data.tar.gz: 533349101fb9890e0bf0e73a407f9302ac881eeb9376aca78aba1e76486544ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39c6527ea4d97ff28e1fc11408297057ee537b44c945be71814cc7b99b4e2759863c063b023d1c7d9d4bb4b9c0ae8172bbb3ceb9166c93b54301119fb0443e9d
|
|
7
|
+
data.tar.gz: f068bf0ffbc3952260cae2a5e56506063b5bc566c66b4cac8f138732a1bd748a17c9d165ffa29a22a4ca85a12e4c78ba88d3e722a349c0de70d899892f5c7e06
|
data/lib/terminal/ansi.rb
CHANGED
|
@@ -467,7 +467,7 @@ module Terminal
|
|
|
467
467
|
|
|
468
468
|
# Create a hyperlink.
|
|
469
469
|
# This is not widely supported; works for
|
|
470
|
-
#
|
|
470
|
+
# Ghostty,
|
|
471
471
|
# iTerm2,
|
|
472
472
|
# Kitty,
|
|
473
473
|
# Rio,
|
|
@@ -481,7 +481,7 @@ module Terminal
|
|
|
481
481
|
|
|
482
482
|
# Show a simple notification.
|
|
483
483
|
# This is not widely supported; works for
|
|
484
|
-
#
|
|
484
|
+
# Ghostty,
|
|
485
485
|
# iTerm2,
|
|
486
486
|
# Kitty,
|
|
487
487
|
# WezTerm.
|
|
@@ -490,6 +490,42 @@ module Terminal
|
|
|
490
490
|
# @return (see cursor_up)
|
|
491
491
|
def notify(text) = "\e]9;#{text}\a"
|
|
492
492
|
|
|
493
|
+
# Set task progress state.
|
|
494
|
+
# This is not widely supported; works for
|
|
495
|
+
# Ghostty,
|
|
496
|
+
# iTerm2,
|
|
497
|
+
# Kitty.
|
|
498
|
+
#
|
|
499
|
+
# @param state [:show, :warning, :error, :indeterminate, :hide]
|
|
500
|
+
# - `:show`
|
|
501
|
+
# show progress indicator with given percent value in default mode
|
|
502
|
+
# - `:warning`
|
|
503
|
+
# show progress with given percent value in warning mode
|
|
504
|
+
# - `:error`
|
|
505
|
+
# show progress with given percent value in error mode
|
|
506
|
+
# - `:indeterminate`
|
|
507
|
+
# show progress in indeterminate state (percent value is ignored)
|
|
508
|
+
# - `:hide`
|
|
509
|
+
# hide progress indicator (percent value is ignored)
|
|
510
|
+
# @return (see cursor_up)
|
|
511
|
+
def progress(state, percent = 0)
|
|
512
|
+
case state
|
|
513
|
+
when :show, true
|
|
514
|
+
state = 1
|
|
515
|
+
when :err, :error
|
|
516
|
+
state = 2
|
|
517
|
+
when :warn, :warning
|
|
518
|
+
state = 4
|
|
519
|
+
when Numeric
|
|
520
|
+
percent, state = state, 1
|
|
521
|
+
when :indeterminate
|
|
522
|
+
return +PROGRESS_SHOW_INDETERMINATE
|
|
523
|
+
else
|
|
524
|
+
return +PROGRESS_HIDE
|
|
525
|
+
end
|
|
526
|
+
"\e]9;4;#{state};#{percent.to_i.clamp(0, 100)}\a"
|
|
527
|
+
end
|
|
528
|
+
|
|
493
529
|
# Create scaled text.
|
|
494
530
|
# It uses the
|
|
495
531
|
# [text sizing protocol](https://sw.kovidgoyal.net/kitty/text-sizing-protocol).
|
|
@@ -857,6 +893,11 @@ module Terminal
|
|
|
857
893
|
# @private
|
|
858
894
|
LINE_ERASE_PREV = -"#{cursor_prev_line(nil)}#{LINE_ERASE}"
|
|
859
895
|
|
|
896
|
+
# @private
|
|
897
|
+
PROGRESS_HIDE = "\e]9;4;0;0\a"
|
|
898
|
+
# @private
|
|
899
|
+
PROGRESS_SHOW_INDETERMINATE = "\e]9;4;3;0\a"
|
|
900
|
+
|
|
860
901
|
# @comment seems not widely supported:
|
|
861
902
|
# doubled: def cursor_column(column = 1) = "\e[#{column}`"
|
|
862
903
|
# doubled: def cursor_row(row = 1) = "\e[#{row}d"
|
data/lib/terminal/input.rb
CHANGED
|
@@ -109,7 +109,7 @@ module Terminal
|
|
|
109
109
|
|
|
110
110
|
def on_tty_key_event(opts)
|
|
111
111
|
STDIN.noecho do |stdin|
|
|
112
|
-
opts
|
|
112
|
+
opts &&= raw_write("#{opts}h") ? "#{opts}l" : nil
|
|
113
113
|
while (raw = stdin.getch)
|
|
114
114
|
(yield(KeyEvent[raw]) ? next : break) if raw != "\e"
|
|
115
115
|
lesci = 0
|
data/lib/terminal/shell.rb
CHANGED
|
@@ -120,7 +120,11 @@ module Terminal
|
|
|
120
120
|
@enum = Enumerator.new { |y| enum.each { y << _1 } }
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
|
+
|
|
124
|
+
private_constant :Writer, :CopyWriter, :ArrayWriter, :EnumerableWriter
|
|
123
125
|
end
|
|
126
|
+
|
|
127
|
+
private_constant :Input
|
|
124
128
|
end
|
|
125
129
|
|
|
126
130
|
private_constant :Shell
|
data/lib/terminal/version.rb
CHANGED
data/lib/terminal.rb
CHANGED
|
@@ -301,7 +301,9 @@ module Terminal
|
|
|
301
301
|
# whether to create a seperate shell or not
|
|
302
302
|
# @option options [#readpartial, #to_io, Array, #each, #to_a, #to_s] :input
|
|
303
303
|
# piped to the command as input
|
|
304
|
+
# @raise [ArgumentError] when command is missing
|
|
304
305
|
def sh(*cmd, **options, &block)
|
|
306
|
+
raise(ArgumentError, 'command expected') if cmd.empty?
|
|
305
307
|
return Shell.exec(cmd, **options, &block) if block_given?
|
|
306
308
|
out = []
|
|
307
309
|
err = []
|