class TextEditor::Terminal
Public Instance Methods
columns()
click to toggle source
# File lib/text_editor/terminal.rb 8 def columns 9 cols 10 end
input()
click to toggle source
# File lib/text_editor/terminal.rb 19 def input 20 getch 21 end
keys()
click to toggle source
# File lib/text_editor/terminal.rb 12 def keys 13 self.class.constants.sort.grep(/^KEY/).reduce({}) do |hash, constant| 14 value = self.class.const_get(constant) 15 hash.update(constant => value) 16 end 17 end
render() { || ... }
click to toggle source
# File lib/text_editor/terminal.rb 23 def render 24 noecho # hide typed characters 25 nonl # disable newline translation 26 stdscr.keypad(true) # enable arrow keys 27 raw # enable all other keys 28 init_screen 29 start_color 30 yield 31 ensure 32 clear 33 close_screen 34 end
window(lines, columns, y, x)
click to toggle source
# File lib/text_editor/terminal.rb 36 def window(lines, columns, y, x) 37 stdscr.subwin(lines, columns, y, x) 38 end