Class: LessCurse::Widgets::TextArea
- Inherits:
-
Base
- Object
- Base
- LessCurse::Widgets::TextArea
show all
- Defined in:
- lib/less_curse/widgets/text_area.rb
Instance Attribute Summary
Attributes inherited from Base
#actions, #data, #title
Instance Method Summary
collapse
Methods inherited from Base
#focused?, #initialize, #set_default_actions, #unfocus
Instance Method Details
#draw(window) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/less_curse/widgets/text_area.rb', line 4
def draw window
LessCurse::Renderer::bold_if(focused?, window) do
LessCurse::Renderer::box_with_title window, @title
end
FFI::NCurses.wmove window, 1, 1
@data.to_s.split("\n").each_with_index do |line, idx|
FFI::NCurses.mvwaddstr window, idx + 1, 1, line
end
end
|
#focus ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/less_curse/widgets/text_area.rb', line 25
def focus
@focus = true
refresh
end
|
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/less_curse/widgets/text_area.rb', line 14
def handle_input key
if key == FFI::NCurses::KEY_BACKSPACE
@data = @data[0..-2]
else
@data += key.chr rescue false
end
end
|