Module: Rurses
- Defined in:
- lib/terminal-notes/rurses.rb,
lib/terminal-notes/rurses/window.rb,
lib/terminal-notes/rurses/version.rb,
lib/terminal-notes/rurses/panel_stack.rb
Defined Under Namespace
Classes: PanelStack, Window
Constant Summary
collapse
- SPECIAL_KEYS =
Hash[
FFI::NCurses::KeyDefs
.constants
.select { |name| name.to_s.start_with?("KEY_") }
.map { |name|
[ FFI::NCurses::KeyDefs.const_get(name),
name.to_s.sub(/\AKEY_/, "").to_sym ]
}
]
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
.curses ⇒ Object
20
21
22
|
# File 'lib/terminal-notes/rurses.rb', line 20
def curses
FFI::NCurses
end
|
.get_key ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/terminal-notes/rurses.rb', line 36
def get_key
case (char = curses.getch)
when curses::KeyDefs::KEY_CODE_YES..curses::KeyDefs::KEY_MAX
SPECIAL_KEYS[char]
when curses::ERR
nil
when 1
:CTRL_A
when 5
:CTRL_E
when 10
:ENTER
when 11
:CTRL_K
when 14
:CTRL_N
when 23
:CTRL_W
when 24
:CTRL_X
when 127
:BACKSPACE
else
char.chr
end
end
|
.program(modes: [ ]) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/terminal-notes/rurses.rb', line 24
def program(modes: [ ])
@stdscr = Window.new(curses_ref: curses.initscr, standard_screen: true)
@stdscr.change_modes(modes)
yield(@stdscr)
ensure
curses.endwin
end
|
.stdscr ⇒ Object
32
33
34
|
# File 'lib/terminal-notes/rurses.rb', line 32
def stdscr
@stdscr
end
|
.update_screen ⇒ Object
63
64
65
|
# File 'lib/terminal-notes/rurses.rb', line 63
def update_screen
curses.doupdate
end
|