Class: RubyTUI::Frame
- Inherits:
-
Object
- Object
- RubyTUI::Frame
- Defined in:
- lib/rubytui/frame.rb
Overview
Rendering context yielded by Terminal#draw and render_once.
Frame wraps a Buffer and provides methods for rendering widgets. It is the primary interface for placing widgets during a draw call.
Instance Attribute Summary collapse
-
#area ⇒ Rect
readonly
The total renderable area.
-
#buffer ⇒ Buffer
readonly
The buffer to render into.
Instance Method Summary collapse
-
#cursor_position ⇒ Array(Integer, Integer)?
Get the requested cursor position.
-
#initialize(buffer, area) ⇒ Frame
constructor
A new instance of Frame.
-
#render_stateful_widget(widget, area, state) ⇒ void
Render a stateful widget with its state object.
-
#render_widget(widget, area) ⇒ void
Render a widget into a specific area of this frame.
-
#set_cursor_position(x, y) ⇒ void
Request cursor placement at a specific position.
-
#size ⇒ Rect
The total renderable area (alias for #area).
Constructor Details
#initialize(buffer, area) ⇒ Frame
Returns a new instance of Frame.
22 23 24 25 26 |
# File 'lib/rubytui/frame.rb', line 22 def initialize(buffer, area) @buffer = buffer @area = area @cursor_position = nil end |
Instance Attribute Details
#area ⇒ Rect (readonly)
Returns the total renderable area.
18 19 20 |
# File 'lib/rubytui/frame.rb', line 18 def area @area end |
#buffer ⇒ Buffer (readonly)
Returns the buffer to render into.
16 17 18 |
# File 'lib/rubytui/frame.rb', line 16 def buffer @buffer end |
Instance Method Details
#cursor_position ⇒ Array(Integer, Integer)?
Get the requested cursor position.
65 |
# File 'lib/rubytui/frame.rb', line 65 def cursor_position = @cursor_position |
#render_stateful_widget(widget, area, state) ⇒ void
This method returns an undefined value.
Render a stateful widget with its state object.
The widget must implement render(area, buf, state) (the StatefulWidget protocol).
47 48 49 |
# File 'lib/rubytui/frame.rb', line 47 def (, area, state) .render(area, @buffer, state) end |
#render_widget(widget, area) ⇒ void
This method returns an undefined value.
Render a widget into a specific area of this frame.
The widget must implement render(area, buf) (the Widget protocol).
35 36 37 |
# File 'lib/rubytui/frame.rb', line 35 def (, area) .render(area, @buffer) end |
#set_cursor_position(x, y) ⇒ void
This method returns an undefined value.
Request cursor placement at a specific position.
Used by widgets like Widgets::InputField to position the terminal cursor.
58 59 60 |
# File 'lib/rubytui/frame.rb', line 58 def set_cursor_position(x, y) @cursor_position = [x, y] end |