Class: RubyAnything::TextWindow
Constant Summary
Constants inherited
from BaseWindow
BaseWindow::KEYS
Instance Attribute Summary collapse
Attributes inherited from BaseWindow
#cursor, #top
Instance Method Summary
collapse
Methods inherited from BaseWindow
#before_down, #before_left, #before_right, #before_up, #change_focus_line, #collection, #down, #draw_at, #draw_at!, #enhansive_line, #in_color, #in_pos, #left, #method_missing, #normalize_line, #refresh, #right, #up
Constructor Details
#initialize(parent, opt = {}) ⇒ TextWindow
Returns a new instance of TextWindow.
7
8
9
|
# File 'lib/ruby-anything/windows/text_window.rb', line 7
def initialize(parent, opt = {})
super(parent, opt)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class RubyAnything::BaseWindow
Instance Attribute Details
#items_window ⇒ Object
Returns the value of attribute items_window.
5
6
7
|
# File 'lib/ruby-anything/windows/text_window.rb', line 5
def items_window
@items_window
end
|
Instance Method Details
#backspace ⇒ Object
35
36
37
38
39
40
|
# File 'lib/ruby-anything/windows/text_window.rb', line 35
def backspace
cursor.left
text.delete cursor.x
@parent.filter text.to_s
update
end
|
#insert(ch) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/ruby-anything/windows/text_window.rb', line 42
def insert(ch)
text.insert cursor.x, ch
cursor.right
@parent.filter text.to_s
update
end
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/ruby-anything/windows/text_window.rb', line 18
def on_input(ch)
case ch
when *KEYS[:left]
left
when *KEYS[:right]
right
when *KEYS[:backspace]
backspace
when String
insert ch
end
end
|
#text ⇒ Object
11
12
13
|
# File 'lib/ruby-anything/windows/text_window.rb', line 11
def text
@text ||= Text.new
end
|
#update ⇒ Object
15
|
# File 'lib/ruby-anything/windows/text_window.rb', line 15
def update; draw_at! 0 end
|
#view_collection ⇒ Object
16
|
# File 'lib/ruby-anything/windows/text_window.rb', line 16
def view_collection; [ text.to_s ] end
|