Module: Ncurses
- Defined in:
- lib/sup/buffer.rb
Constant Summary collapse
- KEY_ENTER =
10
- KEY_CANCEL =
ctrl-g
7
- KEY_TAB =
9
Class Method Summary collapse
- .cols ⇒ Object
- .curx ⇒ Object
- .mutex ⇒ Object
-
.nonblocking_getch ⇒ Object
magically, this stuff seems to work now.
- .rows ⇒ Object
-
.safe_nonblocking_getch ⇒ Object
pretends ctrl-c’s are ctrl-g’s.
- .sync(&b) ⇒ Object
Class Method Details
.cols ⇒ Object
18 19 20 21 22 |
# File 'lib/sup/buffer.rb', line 18 def cols lame, lamer = [], [] stdscr.getmaxyx lame, lamer lamer.first end |
.curx ⇒ Object
24 25 26 27 28 |
# File 'lib/sup/buffer.rb', line 24 def curx lame, lamer = [], [] stdscr.getyx lame, lamer lamer.first end |
.mutex ⇒ Object
30 |
# File 'lib/sup/buffer.rb', line 30 def mutex; @mutex ||= Mutex.new; end |
.nonblocking_getch ⇒ Object
magically, this stuff seems to work now. i could swear it didn’t before. hm.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sup/buffer.rb', line 35 def nonblocking_getch ## INSANTIY ## it is NECESSARY to wrap Ncurses.getch in a select() otherwise all ## background threads will be BLOCKED. (except in very modern versions ## of libncurses-ruby. the current one on ubuntu seems to work well.) if IO.select([$stdin], nil, nil, 0.5) if Redwood::BufferManager.shelled? # If we get input while we're shelled, we'll ignore it for the # moment and use Ncurses.sync to wait until the shell_out is done. Ncurses.sync { nil } else Ncurses.getch end end end |
.rows ⇒ Object
12 13 14 15 16 |
# File 'lib/sup/buffer.rb', line 12 def rows lame, lamer = [], [] stdscr.getmaxyx lame, lamer lame.first end |
.safe_nonblocking_getch ⇒ Object
pretends ctrl-c’s are ctrl-g’s
52 53 54 55 56 |
# File 'lib/sup/buffer.rb', line 52 def safe_nonblocking_getch nonblocking_getch rescue Interrupt KEY_CANCEL end |
.sync(&b) ⇒ Object
31 |
# File 'lib/sup/buffer.rb', line 31 def sync &b; mutex.synchronize(&b); end |