module Ncurses

Constants

GETSTR_LIMIT
KEY_CANCEL
KEY_ENTER
KEY_TAB

Public Class Methods

_ENDLINE() click to toggle source
# File lib/ncurses.rb, line 31
def Ncurses._ENDLINE 
  Ncurses::ENDLINE
end
_FULLWIN() click to toggle source
# File lib/ncurses.rb, line 34
def Ncurses._FULLWIN 
  Ncurses::FULLWIN
end
_HASMOVED() click to toggle source
# File lib/ncurses.rb, line 43
def Ncurses._HASMOVED
  Ncurses::HASMOVED
end
_ISPAD() click to toggle source
# File lib/ncurses.rb, line 40
def Ncurses._ISPAD   
  Ncurses::ISPAD
end
_NEWINDEX() click to toggle source
# File lib/ncurses.rb, line 52
def Ncurses._NEWINDEX
  Ncurses::NEWINDEX
end
_NOCHANGE() click to toggle source
# File lib/ncurses.rb, line 49
def Ncurses._NOCHANGE
  Ncurses::NOCHANGE
end
_SCROLLWIN() click to toggle source
# File lib/ncurses.rb, line 37
def Ncurses._SCROLLWIN
  Ncurses::SCROLLWIN
end
_SUBWIN() click to toggle source
# File lib/ncurses.rb, line 28
def Ncurses._SUBWIN  
  Ncurses::SUBWIN
end
_WRAPPED() click to toggle source
# File lib/ncurses.rb, line 46
def Ncurses._WRAPPED 
  Ncurses::WRAPPED
end
_XOPEN_CURSES() click to toggle source

Ncurses constants with leading underscore

# File lib/ncurses.rb, line 25
def Ncurses._XOPEN_CURSES
  Ncurses::XOPEN_CURSES
end
cols() click to toggle source
# File lib/sup/buffer.rb, line 18
def cols
  lame, lamer = [], []
  stdscr.getmaxyx lame, lamer
  lamer.first
end
curx() click to toggle source
# File lib/sup/buffer.rb, line 24
def curx
  lame, lamer = [], []
  stdscr.getyx lame, lamer
  lamer.first
end
erase() click to toggle source
# File lib/ncurses.rb, line 232
def Ncurses.erase
  Ncurses.werase(Ncurses.stdscr)
end
getbegx(win) click to toggle source
# File lib/ncurses.rb, line 214
def Ncurses.getbegx(win)
  x = []; y = []; Ncurses.getbegyx(win, y,x); x[0]
end
getbegy(win) click to toggle source
# File lib/ncurses.rb, line 217
def Ncurses.getbegy(win)
  x = []; y = []; Ncurses.getbegyx(win, y,x); y[0]
end
getcurx(win) click to toggle source
# File lib/ncurses.rb, line 208
def Ncurses.getcurx(win)
  x = []; y = []; Ncurses.getyx(win, y,x); x[0]
end
getcury(win) click to toggle source
# File lib/ncurses.rb, line 211
def Ncurses.getcury(win)
  x = []; y = []; Ncurses.getyx(win, y,x); y[0]
end
getmaxx(win) click to toggle source
# File lib/ncurses.rb, line 220
def Ncurses.getmaxx(win)
  x = []; y = []; Ncurses.getmaxyx(win, y,x); x[0]
end
getmaxy(win) click to toggle source
# File lib/ncurses.rb, line 223
def Ncurses.getmaxy(win)
  x = []; y = []; Ncurses.getmaxyx(win, y,x); y[0]
end
getnstr(str,n) click to toggle source
# File lib/ncurses.rb, line 160
def Ncurses.getnstr(str,n)
  Ncurses.wgetnstr(Ncurses.stdscr, str, n)
end
getparx(win) click to toggle source
# File lib/ncurses.rb, line 226
def Ncurses.getparx(win)
  x = []; y = []; Ncurses.getparyx(win, y,x); x[0]
end
getpary(win) click to toggle source
# File lib/ncurses.rb, line 229
def Ncurses.getpary(win)
  x = []; y = []; Ncurses.getparyx(win, y,x); y[0]
end
getstr(str) click to toggle source
# File lib/ncurses.rb, line 235
def Ncurses.getstr(str)
  Ncurses.getnstr(str, Ncurses::GETSTR_LIMIT)
end
inchnstr(str,n) click to toggle source
# File lib/ncurses.rb, line 130
def Ncurses.inchnstr(str,n)
  Ncurses.winchnstr(Ncurses.stdscr, str, n)
end
inchstr(str) click to toggle source
# File lib/ncurses.rb, line 133
def Ncurses.inchstr(str)
  Ncurses.winchstr(Ncurses.stdscr, str)
end
innstr(str,n) click to toggle source
# File lib/ncurses.rb, line 174
def Ncurses.innstr(str,n)
  Ncurses.winnstr(Ncurses.stdscr, str, n)
end
instr(str) click to toggle source
# File lib/ncurses.rb, line 177
def Ncurses.instr(str)
  Ncurses.winstr(Ncurses.stdscr, str)
end
mouse_trafo(pY, pX, to_screen) click to toggle source
# File lib/ncurses.rb, line 204
def Ncurses.mouse_trafo(pY, pX, to_screen)
  Ncurses.wmouse_trafo(Ncurses.stdscr, pY, pX, to_screen)
end
mutex() click to toggle source
# File lib/sup/buffer.rb, line 30
def mutex; @mutex ||= Mutex.new; end
mvgetnstr(y,x, str, n) click to toggle source
# File lib/ncurses.rb, line 163
def Ncurses.mvgetnstr(y,x, str, n)
  Ncurses.mvwgetnstr(Ncurses.stdscr, y,x, str, n)
end
mvgetstr(y,x, str) click to toggle source
# File lib/ncurses.rb, line 238
def Ncurses.mvgetstr(y,x, str)
  Ncurses.mvgetnstr(y,x, str, Ncurses::GETSTR_LIMIT)
end
mvinchnstr(y,x, str, n) click to toggle source
# File lib/ncurses.rb, line 136
def Ncurses.mvinchnstr(y,x, str, n)
  Ncurses.mvwinchnstr(Ncurses.stdscr, y,x, str, n)
end
mvinchstr(y,x, str) click to toggle source
# File lib/ncurses.rb, line 139
def Ncurses.mvinchstr(y,x, str)
  Ncurses.mvwinchstr(Ncurses.stdscr, y,x, str)
end
mvinnstr(y,x, str, n) click to toggle source
# File lib/ncurses.rb, line 180
def Ncurses.mvinnstr(y,x, str, n)
  Ncurses.mvwinnstr(Ncurses.stdscr, y,x, str, n)
end
mvinstr(y,x, str) click to toggle source
# File lib/ncurses.rb, line 183
def Ncurses.mvinstr(y,x, str)
  Ncurses.mvwinstr(Ncurses.stdscr, y,x, str)
end
mvprintw(*args) click to toggle source
# File lib/ncurses.rb, line 271
def Ncurses.mvprintw(*args)
  Ncurses.mvwprintw(Ncurses.stdscr, *args)
end
mvscanw(y,x, format, result) click to toggle source
# File lib/ncurses.rb, line 251
def Ncurses.mvscanw(y,x, format, result)
  Ncurses.mvwscanw(Ncurses.stdscr, y,x, format, result)
end
mvwgetnstr(win, y,x, str, n) click to toggle source
# File lib/ncurses.rb, line 166
def Ncurses.mvwgetnstr(win, y,x, str, n)
  if (Ncurses.wmove(win,y,x) == Ncurses::ERR) 
    Ncurses::ERR
  else
    Ncurses.wgetnstr(win,str,n)
  end
end
mvwgetstr(win, y,x, str) click to toggle source
# File lib/ncurses.rb, line 241
def Ncurses.mvwgetstr(win, y,x, str)
  Ncurses.mvwgetnstr(win, y,x, str, Ncurses::GETSTR_LIMIT)
end
mvwinchnstr(win, y,x, str, n) click to toggle source
# File lib/ncurses.rb, line 142
def Ncurses.mvwinchnstr(win, y,x, str, n)
  if (Ncurses.wmove(win,y,x) == Ncurses::ERR) 
    Ncurses::ERR
  else
    Ncurses.winchnstr(win,str,n)
  end
end
mvwinchstr(win, y,x, str) click to toggle source
# File lib/ncurses.rb, line 149
def Ncurses.mvwinchstr(win, y,x, str)
  maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
  return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
  Ncurses.mvwinchnstr(win, y,x, str, maxx[0]+1)
end
mvwinnstr(win, y,x, str, n) click to toggle source
# File lib/ncurses.rb, line 186
def Ncurses.mvwinnstr(win, y,x, str, n)
  if (Ncurses.wmove(win,y,x) == Ncurses::ERR) 
    Ncurses::ERR
  else
    Ncurses.winnstr(win,str,n)
  end
end
mvwinstr(win, y,x, str) click to toggle source
# File lib/ncurses.rb, line 193
def Ncurses.mvwinstr(win, y,x, str)
  maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
  return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
  Ncurses.mvwinnstr(win, y,x, str, maxx[0]+1)
end
mvwprintw(win, y,x, *args) click to toggle source
# File lib/ncurses.rb, line 274
def Ncurses.mvwprintw(win, y,x, *args)
  if (Ncurses.wmove(win,y,x) == Ncurses::ERR) 
    Ncurses::ERR
  else
    wprintw(win, *args)
  end
end
mvwscanw(win, y,x, format, result) click to toggle source
# File lib/ncurses.rb, line 254
def Ncurses.mvwscanw(win, y,x, format, result)
  if (Ncurses.wmove(win, y,x) == Ncurses::ERR) 
    Ncurses::ERR
  else
    Ncurses.wscanw(win, format, result)
  end
end
nonblocking_getch() click to toggle source
# File lib/sup/buffer.rb, line 33
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)
    c = Ncurses.getch
  end
end
printw(*args) click to toggle source
# File lib/ncurses.rb, line 281
def Ncurses.printw(*args)
  Ncurses.wprintw(Ncurses.stdscr, *args)
end
rows() click to toggle source
# File lib/sup/buffer.rb, line 12
def rows
  lame, lamer = [], []
  stdscr.getmaxyx lame, lamer
  lame.first
end
safe_nonblocking_getch() click to toggle source

pretends ctrl-c's are ctrl-g's

# File lib/sup/buffer.rb, line 44
def safe_nonblocking_getch
  nonblocking_getch
rescue Interrupt
  KEY_CANCEL
end
scanw(format, result) click to toggle source
# File lib/ncurses.rb, line 248
def Ncurses.scanw(format, result)
  Ncurses.wscanw(Ncurses.stdscr, format, result)
end
sync(&b;) click to toggle source
# File lib/sup/buffer.rb, line 31
def sync &b; mutex.synchronize(&b); end
touchline(win, start, count) click to toggle source
# File lib/ncurses.rb, line 284
def Ncurses.touchline(win, start, count)
  Ncurses.wtouchln(win, start, count, 1)
end
touchwin(win) click to toggle source
# File lib/ncurses.rb, line 287
def Ncurses.touchwin(win)
  wtouchln(win, 0, getmaxy(win), 1)
end
wgetstr(win, str) click to toggle source
# File lib/ncurses.rb, line 244
def Ncurses.wgetstr(win, str)
  Ncurses.wgetnstr(win, str, Ncurses::GETSTR_LIMIT)
end
winchstr(win, str) click to toggle source
# File lib/ncurses.rb, line 154
def Ncurses.winchstr(win, str)
  maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
  return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
  Ncurses.winchnstr(win, str, maxx[0]+1)
end
winstr(win, str) click to toggle source
# File lib/ncurses.rb, line 198
def Ncurses.winstr(win, str)
  maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
  return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
  Ncurses.winnstr(win, str, maxx[0]+1)
end
wscanw(win, format, result) click to toggle source
# File lib/ncurses.rb, line 261
def Ncurses.wscanw(win, format, result)
  str = ""
  if (Ncurses.wgetstr(win, str) == Ncurses::ERR) 
    Ncurses::ERR
  else
    require "scanf.rb" # Use ruby's implementation of scanf
    result.replace(str.scanf(format))
  end
end

Private Instance Methods

cols() click to toggle source
# File lib/sup/buffer.rb, line 18
def cols
  lame, lamer = [], []
  stdscr.getmaxyx lame, lamer
  lamer.first
end
curx() click to toggle source
# File lib/sup/buffer.rb, line 24
def curx
  lame, lamer = [], []
  stdscr.getyx lame, lamer
  lamer.first
end
mutex() click to toggle source
# File lib/sup/buffer.rb, line 30
def mutex; @mutex ||= Mutex.new; end
nonblocking_getch() click to toggle source
# File lib/sup/buffer.rb, line 33
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)
    c = Ncurses.getch
  end
end
rows() click to toggle source
# File lib/sup/buffer.rb, line 12
def rows
  lame, lamer = [], []
  stdscr.getmaxyx lame, lamer
  lame.first
end
safe_nonblocking_getch() click to toggle source

pretends ctrl-c's are ctrl-g's

# File lib/sup/buffer.rb, line 44
def safe_nonblocking_getch
  nonblocking_getch
rescue Interrupt
  KEY_CANCEL
end
sync(&b;) click to toggle source
# File lib/sup/buffer.rb, line 31
def sync &b; mutex.synchronize(&b); end