Class: Curtis::View
Instance Attribute Summary collapse
-
#column ⇒ Object
writeonly
Sets the attribute column.
-
#columns ⇒ Object
writeonly
Sets the attribute columns.
-
#line ⇒ Object
writeonly
Sets the attribute line.
-
#lines ⇒ Object
writeonly
Sets the attribute lines.
Attributes inherited from BaseView
#cursor, #position, #size, #window
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(**opts) {|_self| ... } ⇒ View
constructor
A new instance of View.
- #parent ⇒ Object
- #render(every: 0.04) ⇒ Object
- #reposition(line: nil, column: nil) ⇒ Object
- #resize(lines: nil, columns: nil) ⇒ Object
Methods inherited from BaseView
instance, #method_missing, #move_cursor, #respond_to_missing?, #setup
Methods included from Helpers::Border
Methods included from Helpers::Text
Constructor Details
#initialize(**opts) {|_self| ... } ⇒ View
Returns a new instance of View.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/curtis/view.rb', line 7 def initialize(**opts) @lines = opts[:lines] || -> { parent.size.lines } @columns = opts[:columns] || -> { parent.size.columns } @line = opts[:line] || 0 @column = opts[:column] || 0 yield self if block_given? super Ncurses::WINDOW.new(*computed_dimensions, *computed_coordinates) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Curtis::BaseView
Instance Attribute Details
#column=(value) ⇒ Object (writeonly)
Sets the attribute column
5 6 7 |
# File 'lib/curtis/view.rb', line 5 def column=(value) @column = value end |
#columns=(value) ⇒ Object (writeonly)
Sets the attribute columns
5 6 7 |
# File 'lib/curtis/view.rb', line 5 def columns=(value) @columns = value end |
#line=(value) ⇒ Object (writeonly)
Sets the attribute line
5 6 7 |
# File 'lib/curtis/view.rb', line 5 def line=(value) @line = value end |
#lines=(value) ⇒ Object (writeonly)
Sets the attribute lines
5 6 7 |
# File 'lib/curtis/view.rb', line 5 def lines=(value) @lines = value end |
Instance Method Details
#clear ⇒ Object
39 40 41 42 |
# File 'lib/curtis/view.rb', line 39 def clear clear_thread! window.clear end |
#parent ⇒ Object
18 19 20 |
# File 'lib/curtis/view.rb', line 18 def parent BaseView.instance end |
#render(every: 0.04) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/curtis/view.rb', line 22 def render(every: 0.04) clear_thread! if block_given? @thread = Thread.new do loop do yield self window.refresh sleep every end end else setup window.refresh end end |
#reposition(line: nil, column: nil) ⇒ Object
50 51 52 53 54 |
# File 'lib/curtis/view.rb', line 50 def reposition(line: nil, column: nil) @line = line if line @column = column if column window.mvwin(*computed_coordinates) end |
#resize(lines: nil, columns: nil) ⇒ Object
44 45 46 47 48 |
# File 'lib/curtis/view.rb', line 44 def resize(lines: nil, columns: nil) @lines = lines if lines @columns = columns if columns window.resize(*computed_dimensions) end |