Class: TerminalLayout::InputBox
- Inherits:
-
Box
- Object
- Box
- TerminalLayout::InputBox
show all
- Defined in:
- lib/terminal_layout.rb
Instance Attribute Summary collapse
-
#cursor_position ⇒ Object
cursor_position is the actual coordinates on the screen of where then cursor is rendered.
-
#position ⇒ Object
position is the desired X-position of the cursor if everything was displayed on a single line.
Attributes inherited from Box
#children, #computed, #content, #name, #style
Instance Method Summary
collapse
Methods inherited from Box
#find_child_of_type, #height, #inspect, #size, #to_s, #to_str, #width
#_callbacks, #emit, #on, #unsubscribe
Constructor Details
#initialize(*args) ⇒ InputBox
Returns a new instance of InputBox.
473
474
475
476
477
478
479
|
# File 'lib/terminal_layout.rb', line 473
def initialize(*args)
super
@computed = { x: 0, y: 0 }
@cursor_position = OpenStruct.new(x: 0, y: 0)
@position = 0
@focused = false
end
|
Instance Attribute Details
#cursor_position ⇒ Object
cursor_position is the actual coordinates on the screen of where then cursor is rendered
453
454
455
|
# File 'lib/terminal_layout.rb', line 453
def cursor_position
@cursor_position
end
|
#position ⇒ Object
position is the desired X-position of the cursor if everything was displayed on a single line
457
458
459
|
# File 'lib/terminal_layout.rb', line 457
def position
@position
end
|
Instance Method Details
#content=(str) ⇒ Object
489
490
491
492
493
494
495
496
|
# File 'lib/terminal_layout.rb', line 489
def content=(str)
new_content = ANSIString.new(str)
if @content != new_content
old_content = @content
@content = new_content
emit :content_changed, old_content, @content
end
end
|
#cursor_off ⇒ Object
481
482
483
|
# File 'lib/terminal_layout.rb', line 481
def cursor_off
@style.update(cursor: 'none')
end
|
#cursor_on ⇒ Object
485
486
487
|
# File 'lib/terminal_layout.rb', line 485
def cursor_on
@style.update(cursor: 'auto')
end
|
#focus! ⇒ Object
459
460
461
462
463
|
# File 'lib/terminal_layout.rb', line 459
def focus!
return if @focused
@focused = true
emit :focus_changed, !@focused, @focused
end
|
#focused? ⇒ Boolean
471
|
# File 'lib/terminal_layout.rb', line 471
def focused? ; !!@focused ; end
|
#remove_focus! ⇒ Object
465
466
467
468
469
|
# File 'lib/terminal_layout.rb', line 465
def remove_focus!
return unless @focused
@focused = false
emit :focus_changed, !@focused, @focused
end
|
#update_computed(style) ⇒ Object
504
505
506
507
508
509
510
511
512
513
514
|
# File 'lib/terminal_layout.rb', line 504
def update_computed(style)
if style[:y] && style[:y] > 0
Treefell['render'].puts "update_computed received a y > 0. Removing Y from update."
style = style.dup.delete_if { |k,_| [:x, :y].include?(k) }
end
@computed.merge!(style)
end
|