terminal_rb 1.0.6 → 1.0.9

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.
@@ -43,6 +43,8 @@ module Terminal
43
43
 
44
44
  def raw_write(object)
45
45
  @out.syswrite(object)
46
+ rescue Errno::EINTR
47
+ retry # fixes rare condition found on MacOS Terminal.app
46
48
  rescue IOError, SystemCallError
47
49
  __output_error(nil)
48
50
  end
@@ -86,19 +88,13 @@ module Terminal
86
88
  objects.flatten!
87
89
  return @out.puts if objects.empty?
88
90
  @out.puts(
89
- Text::Formatter.format(
91
+ Text::Formatter.new(
90
92
  *objects,
91
93
  ansi: true,
92
94
  bbcode:,
93
95
  spaces:,
94
- eol:,
95
- align:,
96
- width:,
97
- height:,
98
- padding:,
99
- prefix:,
100
- suffix:
101
- )
96
+ eol:
97
+ ).format(align:, width:, height:, padding:, prefix:, suffix:)
102
98
  )
103
99
  rescue IOError, SystemCallError
104
100
  __output_error(nil)
@@ -137,16 +133,17 @@ module Terminal
137
133
  require('io/console')
138
134
  @con = IO.console
139
135
  return unless Signal.list.key?('WINCH')
140
- Signal.trap('WINCH') do
141
- @size = nil
142
- @on_resize&.call
143
- end
136
+ prev_winch =
137
+ Signal.trap('WINCH') do
138
+ @size = nil
139
+ @on_resize&.call
140
+ prev_winch.call if prev_winch.respond_to?(:call)
141
+ end
144
142
  end
145
143
 
146
144
  private_class_method def self.extended(mod)
147
145
  mod.instance_variable_set(:@cc, 0)
148
146
  mod.instance_variable_set(:@as, 0)
149
- # at_exit { raw_write("#{Ansi::CURSOR_SHOW}#{Ansi::SCREEN_ALTERNATE_OFF}") }
150
147
  end
151
148
  end
152
149
 
@@ -69,19 +69,13 @@ module Terminal
69
69
  objects.flatten!
70
70
  return @out.puts if objects.empty?
71
71
  @out.puts(
72
- Text::Formatter.format(
72
+ Text::Formatter.new(
73
73
  *objects,
74
74
  ansi: false,
75
75
  bbcode:,
76
76
  spaces:,
77
- eol:,
78
- align:,
79
- width:,
80
- height:,
81
- padding:,
82
- prefix:,
83
- suffix:
84
- )
77
+ eol:
78
+ ).format(align:, width:, height:, padding:, prefix:, suffix:)
85
79
  )
86
80
  rescue IOError, SystemCallError
87
81
  __output_error(nil)
@@ -27,7 +27,7 @@ module Terminal
27
27
  # @!group Output Attributes
28
28
  #
29
29
 
30
- # @!attribute [r] tui?
30
+ # @attribute [r] tui?
31
31
  #
32
32
  # Whether the terminal supports full TUI interaction (ANSI output
33
33
  # with CSI-u or legacy keyboard input).
@@ -36,7 +36,7 @@ module Terminal
36
36
  #
37
37
  # @return [true, false]
38
38
 
39
- # @!attribute [r] ansi?
39
+ # @attribute [r] ansi?
40
40
  #
41
41
  # Whether ANSI escape codes are supported.
42
42
  #
@@ -181,7 +181,6 @@ module Terminal
181
181
  # @!method show_cursor
182
182
  # Show the cursor.
183
183
  #
184
- #
185
184
  # @note Reference-counted; safe for nested use.
186
185
  #
187
186
  # @see .hide_cursor
@@ -4,9 +4,10 @@ require 'stringio'
4
4
 
5
5
  # RSpec shared context for testing code that uses Terminal.rb.
6
6
  #
7
- # Stubs all Terminal I/O methods and provides `stdout`, `stdin`, and
8
- # `stdoutstr` test helpers. Output is captured into the `stdout` array;
9
- # input is read from the `stdin` array.
7
+ # Stubs all Terminal I/O methods and provides the `stdout`, `stdout_lines`,
8
+ # and `stdin` test helpers. Output is captured in the `stdout` StringIO;
9
+ # `stdout_lines` returns its lines without line endings. Input is read from
10
+ # the `stdin` array of raw key sequences.
10
11
  #
11
12
  # @example Basic usage
12
13
  # RSpec.describe MyClass do
@@ -14,7 +15,7 @@ require 'stringio'
14
15
  #
15
16
  # it 'prints a greeting' do
16
17
  # my_object.greet
17
- # expect(stdoutstr).to include('Hello')
18
+ # expect(stdout.string).to include('Hello')
18
19
  # end
19
20
  # end
20
21
  #