In Files

  • curses/curses.c
  • curses/view2.rb

Class/Module Index [+]

Quicksearch

Curses

————————- Initialization ————————-

Constants

ALL_MOUSE_EVENTS
A_ALTCHARSET
A_ATTRIBUTES
A_BLINK
A_BOLD
A_CHARTEXT
A_COLOR
A_DIM
A_HORIZONTAL
A_INVIS
A_LEFT
A_LOW
A_NORMAL
A_PROTECT
A_REVERSE
A_RIGHT
A_STANDOUT
A_TOP
A_UNDERLINE
A_VERTICAL
BUTTON1_CLICKED
BUTTON1_DOUBLE_CLICKED
BUTTON1_PRESSED
BUTTON1_RELEASED
BUTTON1_TRIPLE_CLICKED
BUTTON2_CLICKED
BUTTON2_DOUBLE_CLICKED
BUTTON2_PRESSED
BUTTON2_RELEASED
BUTTON2_TRIPLE_CLICKED
BUTTON3_CLICKED
BUTTON3_DOUBLE_CLICKED
BUTTON3_PRESSED
BUTTON3_RELEASED
BUTTON3_TRIPLE_CLICKED
BUTTON4_CLICKED
BUTTON4_DOUBLE_CLICKED
BUTTON4_PRESSED
BUTTON4_RELEASED
BUTTON4_TRIPLE_CLICKED
BUTTON_ALT
BUTTON_CTRL
BUTTON_SHIFT
COLORS
COLOR_BLACK
COLOR_BLUE
COLOR_CYAN
COLOR_GREEN
COLOR_MAGENTA
COLOR_RED
COLOR_WHITE
COLOR_YELLOW
KEY_A1
KEY_A3
KEY_B2
KEY_BACKSPACE
KEY_BEG
KEY_BREAK
KEY_BTAB
KEY_C1
KEY_C3
KEY_CANCEL
KEY_CATAB
KEY_CLEAR
KEY_CLOSE
KEY_COMMAND
KEY_COPY
KEY_CREATE
KEY_CTAB
KEY_DC
KEY_DL
KEY_DOWN
KEY_EIC
KEY_END
KEY_ENTER
KEY_EOL
KEY_EOS
KEY_EXIT
KEY_FIND
KEY_HELP
KEY_HOME
KEY_IC
KEY_IL
KEY_LEFT
KEY_LL
KEY_MARK
KEY_MAX
KEY_MESSAGE
KEY_MIN
KEY_MOUSE
KEY_MOVE
KEY_NEXT
KEY_NPAGE
KEY_OPEN
KEY_OPTIONS
KEY_PPAGE
KEY_PREVIOUS
KEY_PRINT
KEY_REDO
KEY_REFERENCE
KEY_REFRESH
KEY_REPLACE
KEY_RESET
KEY_RESIZE
KEY_RESTART
KEY_RESUME
KEY_RIGHT
KEY_SAVE
KEY_SBEG
KEY_SCANCEL
KEY_SCOMMAND
KEY_SCOPY
KEY_SCREATE
KEY_SDC
KEY_SDL
KEY_SELECT
KEY_SEND
KEY_SEOL
KEY_SEXIT
KEY_SF
KEY_SFIND
KEY_SHELP
KEY_SHOME
KEY_SIC
KEY_SLEFT
KEY_SMESSAGE
KEY_SMOVE
KEY_SNEXT
KEY_SOPTIONS
KEY_SPREVIOUS
KEY_SPRINT
KEY_SR
KEY_SREDO
KEY_SREPLACE
KEY_SRESET
KEY_SRIGHT
KEY_SRSUME
KEY_SSAVE
KEY_SSUSPEND
KEY_STAB
KEY_SUNDO
KEY_SUSPEND
KEY_UNDO
KEY_UP
REPORT_MOUSE_POSITION

Public Class Methods

addch(p1) click to toggle source

def addch(ch)

 
               static VALUE
curses_addch(obj, ch)
    VALUE obj;
    VALUE ch;
{
    curses_stdscr();
    addch(NUM2CH(ch));
    return Qnil;
}
            
addstr(p1) click to toggle source

def addstr(str)

 
               static VALUE
curses_addstr(obj, str)
    VALUE obj;
    VALUE str;
{
    curses_stdscr();
    if (!NIL_P(str)) {
        addstr(STR2CSTR(str));
    }
    return Qnil;
}
            
attroff(p1) click to toggle source
 
               static VALUE
curses_attroff(VALUE obj, VALUE attrs)
{
  curses_stdscr();
  return window_attroff(rb_stdscr,attrs);  
  /* return INT2FIX(attroff(NUM2INT(attrs))); */
}
            
attron(p1) click to toggle source
 
               static VALUE
curses_attron(VALUE obj, VALUE attrs)
{
  curses_stdscr();
  return window_attron(rb_stdscr,attrs);
  /* return INT2FIX(attroff(NUM2INT(attrs))); */
}
            
attrset(p1) click to toggle source
 
               static VALUE
curses_attrset(VALUE obj, VALUE attrs)
{
  curses_stdscr();
  return window_attrset(rb_stdscr,attrs);
  /* return INT2FIX(attroff(NUM2INT(attrs))); */
}
            
beep() click to toggle source

def beep

 
               static VALUE
curses_beep(obj)
    VALUE obj;
{
#ifdef HAVE_BEEP
    curses_stdscr();
    beep();
#endif
    return Qnil;
}
            
bkgd(p1) click to toggle source
 
               static VALUE
curses_bkgd(VALUE obj, VALUE ch)
{
#ifdef HAVE_BKGD
  curses_stdscr();
  return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
#else
  return Qfalse;
#endif
}
            
bkgdset(p1) click to toggle source
 
               static VALUE
curses_bkgdset(VALUE obj, VALUE ch)
{
#ifdef HAVE_BKGDSET
  curses_stdscr();
  bkgdset(NUM2CH(ch));
#endif
  return Qnil;
}
            
can_change_color?() click to toggle source
 
               static VALUE
curses_can_change_color(VALUE obj)
{
  curses_stdscr();
  return can_change_color() ? Qtrue : Qfalse;
}
            
cbreak() click to toggle source

def cbreak

 
               static VALUE
curses_cbreak(obj)
    VALUE obj;
{
    curses_stdscr();
    cbreak();
    return Qnil;
}
            
clear() click to toggle source

def clear

 
               static VALUE
curses_clear(obj)
    VALUE obj;
{
    curses_stdscr();
    wclear(stdscr);
    return Qnil;
}
            
close_screen() click to toggle source

def ::close_screen

 
               static VALUE
curses_close_screen()
{
    curses_stdscr();
#ifdef HAVE_ISENDWIN
    if (!isendwin())
#endif
        endwin();
    rb_stdscr = 0;
    return Qnil;
}
            
closed?() click to toggle source

def closed?

 
               static VALUE
curses_closed()
{
#ifdef HAVE_ISENDWIN
    curses_stdscr();
    if (isendwin()) {
        return Qtrue;
    }
    return Qfalse;
#else
    rb_notimplement();
#endif
}
            
clrtoeol() click to toggle source

def clrtoeol

 
               static VALUE
curses_clrtoeol()
{
    curses_stdscr();
    clrtoeol();
    return Qnil;
}
            
color_content(p1) click to toggle source
 
               static VALUE
curses_color_content(VALUE obj, VALUE color)
{
  short r,g,b;

  curses_stdscr();
  color_content(NUM2INT(color),&r,&g,&b);
  return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b));
}
            
color_pair(p1) click to toggle source
 
               static VALUE
curses_color_pair(VALUE obj, VALUE attrs)
{
  return INT2FIX(COLOR_PAIR(NUM2INT(attrs)));
}
            
cols() click to toggle source
 
               static VALUE
curses_cols()
{
    return INT2FIX(COLS);
}
            
curs_set(p1) click to toggle source
 
               static VALUE
curses_curs_set(VALUE obj, VALUE visibility)
{
#ifdef HAVE_CURS_SET
  int n;
  curses_stdscr();
  return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil;
#else
  return Qnil;
#endif
}
            
def_prog_mode() click to toggle source
 
               static VALUE
curses_def_prog_mode(VALUE obj)
{
#ifdef HAVE_DEF_PROG_MODE
  curses_stdscr();
  return def_prog_mode() == OK ? Qtrue : Qfalse;
#else
    rb_notimplement();
#endif
}
            
delch() click to toggle source

def delch

 
               static VALUE
curses_delch(obj)
    VALUE obj;
{
    curses_stdscr();
    delch();
    return Qnil;
}
            
deleteln() click to toggle source

def delelteln

 
               static VALUE
curses_deleteln(obj)
    VALUE obj;
{
    curses_stdscr();
#if defined(HAVE_DELETELN) || defined(deleteln)
    deleteln();
#endif
    return Qnil;
}
            
doupdate() click to toggle source

def doupdate

 
               static VALUE
curses_doupdate(obj)
    VALUE obj;
{
    curses_stdscr();
#ifdef HAVE_DOUPDATE
    doupdate();
#else
    refresh();
#endif
    return Qnil;
}
            
echo() click to toggle source

def echo

 
               static VALUE
curses_echo(obj)
    VALUE obj;
{
    curses_stdscr();
    echo();
    return Qnil;
}
            
flash() click to toggle source

def flash

 
               static VALUE
curses_flash(obj)
    VALUE obj;
{
#ifdef HAVE_FLASH
    curses_stdscr();
    flash();
#endif
    return Qnil;
}
            
getch() click to toggle source

def getch

 
               static VALUE
curses_getch(obj)
    VALUE obj;
{
    rb_read_check(stdin);
    curses_stdscr();
    return UINT2NUM(getch());
}
            
getmouse() click to toggle source
 
               static VALUE
curses_getmouse(VALUE obj)
{
  struct mousedata *mdata;
  VALUE val;

  curses_stdscr();
  val = Data_Make_Struct(cMouseEvent,struct mousedata,
                         0,curses_mousedata_free,mdata);
  mdata->mevent = (MEVENT*)xmalloc(sizeof(MEVENT));
  return (getmouse(mdata->mevent) == OK) ? val : Qnil;
}
            
getstr() click to toggle source

def getstr

 
               static VALUE
curses_getstr(obj)
    VALUE obj;
{
    char rtn[1024]; /* This should be big enough.. I hope */

    curses_stdscr();
    rb_read_check(stdin);
#if defined(HAVE_GETNSTR)
    getnstr(rtn,1023);
#else
    getstr(rtn);
#endif
    return rb_tainted_str_new2(rtn);
}
            
has_colors?() click to toggle source
 
               static VALUE
curses_has_colors(VALUE obj)
{
  curses_stdscr();
  return has_colors() ? Qtrue : Qfalse;
}
            
inch() click to toggle source

def inch

 
               static VALUE
curses_inch(obj)
    VALUE obj;
{
    curses_stdscr();
    return CH2FIX(inch());
}
            
init_color(p1, p2, p3, p4) click to toggle source
 
               static VALUE
curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b)
{
  /* may have to raise exception on ERR */
  curses_stdscr();
  return (init_color(NUM2INT(color),NUM2INT(r),
                     NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
}
            
init_pair(p1, p2, p3) click to toggle source
 
               static VALUE
curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b)
{
  /* may have to raise exception on ERR */
  curses_stdscr();
  return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
}
            
init_screen() click to toggle source

def ::init_screen

 
               static VALUE
curses_init_screen()
{
    rb_secure(4);
    if (rb_stdscr) return rb_stdscr;
    initscr();
    if (stdscr == 0) {
        rb_raise(rb_eRuntimeError, "can't initialize curses");
    }
    clear();
    rb_stdscr = prep_window(cWindow, stdscr);
    return rb_stdscr;
}
            
insch(p1) click to toggle source

def insch(ch)

 
               static VALUE
curses_insch(obj, ch)
    VALUE obj;
    VALUE ch;
{
    curses_stdscr();
    insch(NUM2CH(ch));
    return Qnil;
}
            
insertln() click to toggle source

def insertln

 
               static VALUE
curses_insertln(obj)
    VALUE obj;
{
    curses_stdscr();
#if defined(HAVE_INSERTLN) || defined(insertln)
    insertln();
#endif
    return Qnil;
}
            
keyname(p1) click to toggle source

def keyname

 
               static VALUE
curses_keyname(obj, c)
    VALUE obj;
    VALUE c;
{
#ifdef HAVE_KEYNAME
  const char *name;

  curses_stdscr();
  name = keyname(NUM2INT(c));
  if (name) {
    return rb_str_new2(name);
  } else {
    return Qnil;
  }
#else
  return Qnil;
#endif
}
            
lines() click to toggle source
 
               static VALUE
curses_lines()
{
    return INT2FIX(LINES);
}
            
mouseinterval(p1) click to toggle source
 
               static VALUE
curses_mouseinterval(VALUE obj, VALUE interval)
{
  curses_stdscr();
  return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse;
}
            
mousemask(p1) click to toggle source
 
               static VALUE
curses_mousemask(VALUE obj, VALUE mask)
{
  curses_stdscr();
  return INT2NUM(mousemask(NUM2UINT(mask),NULL));
}
            
nl() click to toggle source

def nl

 
               static VALUE
curses_nl(obj)
    VALUE obj;
{
    curses_stdscr();
    nl();
    return Qnil;
}
            
nocbreak() click to toggle source

def nocbreak

 
               static VALUE
curses_nocbreak(obj)
    VALUE obj;
{
    curses_stdscr();
    nocbreak();
    return Qnil;
}
            
noecho() click to toggle source

def noecho

 
               static VALUE
curses_noecho(obj)
    VALUE obj;
{
    curses_stdscr();
    noecho();
    return Qnil;
}
            
nonl() click to toggle source

def nonl

 
               static VALUE
curses_nonl(obj)
    VALUE obj;
{
    curses_stdscr();
    nonl();
    return Qnil;
}
            
noraw() click to toggle source

def noraw

 
               static VALUE
curses_noraw(obj)
    VALUE obj;
{
    curses_stdscr();
    noraw();
    return Qnil;
}
            
pair_content(p1) click to toggle source
 
               static VALUE
curses_pair_content(VALUE obj, VALUE pair)
{
  short f,b;

  curses_stdscr();
  pair_content(NUM2INT(pair),&f,&b);
  return rb_ary_new3(2,INT2FIX(f),INT2FIX(b));
}
            
pair_number(p1) click to toggle source
 
               static VALUE
curses_pair_number(VALUE obj, VALUE attrs)
{
  curses_stdscr();
  return INT2FIX(PAIR_NUMBER(NUM2INT(attrs)));
}
            
raw() click to toggle source

def raw

 
               static VALUE
curses_raw(obj)
    VALUE obj;
{
    curses_stdscr();
    raw();
    return Qnil;
}
            
refresh() click to toggle source

def refresh

 
               static VALUE
curses_refresh(obj)
    VALUE obj;
{
    curses_stdscr();
    refresh();
    return Qnil;
}
            
reset_prog_mode() click to toggle source
 
               static VALUE
curses_reset_prog_mode(VALUE obj)
{
#ifdef HAVE_RESET_PROG_MODE
  curses_stdscr();
  return reset_prog_mode() == OK ? Qtrue : Qfalse;
#else
    rb_notimplement();
#endif
}
            
resize(p1, p2) click to toggle source
 
               static VALUE
curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
{
#if defined(HAVE_RESIZETERM)
  curses_stdscr();
  return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse;
#else
  return Qnil;
#endif
}
            
resizeterm(p1, p2) click to toggle source
 
               static VALUE
curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
{
#if defined(HAVE_RESIZETERM)
  curses_stdscr();
  return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse;
#else
  return Qnil;
#endif
}
            
scrl(p1) click to toggle source
 
               static VALUE
curses_scrl(VALUE obj, VALUE n)
{
  /* may have to raise exception on ERR */
#ifdef HAVE_SCRL
  curses_stdscr();
  return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse;
#else
  return Qfalse;
#endif
}
            
setpos(p1, p2) click to toggle source

def setpos(y, x)

 
               static VALUE
curses_setpos(obj, y, x)
    VALUE obj;
    VALUE y;
    VALUE x;
{
    curses_stdscr();
    move(NUM2INT(y), NUM2INT(x));
    return Qnil;
}
            
setscrreg(p1, p2) click to toggle source
 
               static VALUE
curses_setscrreg(VALUE obj, VALUE top, VALUE bottom)
{
  /* may have to raise exception on ERR */
#ifdef HAVE_SETSCRREG
  curses_stdscr();
  return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse;
#else
  return Qfalse;
#endif
}
            
standend() click to toggle source

def standend

 
               static VALUE
curses_standend(obj)
    VALUE obj;
{
    curses_stdscr();
    standend();
    return Qnil;
}
            
standout() click to toggle source

def standout

 
               static VALUE
curses_standout(obj)
    VALUE obj;
{
    curses_stdscr();
    standout();
    return Qnil;
}
            
start_color() click to toggle source
 
               static VALUE
curses_start_color(VALUE obj)
{
  /* may have to raise exception on ERR */
  curses_stdscr();
  return (start_color() == OK) ? Qtrue : Qfalse;
}
            
stdscr() click to toggle source

def stdscr

 
               #define curses_stdscr curses_init_screen
            
timeout=(p1) click to toggle source

USE_MOUSE

 
               static VALUE
curses_timeout(VALUE obj, VALUE delay)
{
#ifdef HAVE_TIMEOUT
  curses_stdscr();
  timeout(NUM2INT(delay));
  return Qnil;
#else
    rb_notimplement();
#endif
}
            
ungetch(p1) click to toggle source

def ungetch

 
               static VALUE
curses_ungetch(obj, ch)
    VALUE obj;
    VALUE ch;
{
#ifdef HAVE_UNGETCH
    curses_stdscr();
    ungetch(NUM2INT(ch));
#else
    rb_notimplement();
#endif
    return Qnil;
}
            
ungetmouse(p1) click to toggle source
 
               static VALUE
curses_ungetmouse(VALUE obj, VALUE mevent)
{
  struct mousedata *mdata;

  curses_stdscr();
  GetMOUSE(mevent,mdata);
  return (ungetmouse(mdata->mevent) == OK) ? Qtrue : Qfalse;
}
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus