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

ESCDELAY() click to toggle source
 
               static VALUE
curses_escdelay_get(VALUE obj)
{
    return INT2NUM(ESCDELAY);
}
            
ESCDELAY=(p1) click to toggle source
 
               static VALUE
curses_escdelay_set(VALUE obj, VALUE val)
{
    ESCDELAY = NUM2INT(val);
    return INT2NUM(ESCDELAY);
}
            
TABSIZE() click to toggle source
 
               static VALUE
curses_tabsize_get(VALUE ojb)
{
    return INT2NUM(TABSIZE);
}
            
TABSIZE=(p1) click to toggle source
 
               static VALUE
curses_tabsize_set(VALUE obj, VALUE val)
{
    TABSIZE = NUM2INT(val);
    return INT2NUM(TABSIZE);
}
            
addch(p1) click to toggle source

def addch(ch)

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

def addstr(str)

 
               static VALUE
curses_addstr(VALUE obj, VALUE str)
{
    StringValue(str);
    str = rb_str_export_locale(str);
    curses_stdscr();
    if (!NIL_P(str)) {
        addstr(StringValueCStr(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(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(VALUE obj)
{
    curses_stdscr();
    cbreak();
    return Qnil;
}
            
clear() click to toggle source

def clear

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

def ::close_screen

 
               static VALUE
curses_close_screen(void)
{
    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(void)
{
    curses_stdscr();
    if (isendwin()) {
        return Qtrue;
    }
    return Qfalse;
}
            
clrtoeol() click to toggle source

def clrtoeol

 
               static VALUE
curses_clrtoeol(void)
{
    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)));
}
            
color_pairs() click to toggle source
 
               static VALUE
curses_color_pairs(VALUE obj)
{
    return INT2FIX(COLOR_PAIRS);
}
            
colors() click to toggle source
 
               static VALUE
curses_colors(VALUE obj)
{
    return INT2FIX(COLORS);
}
            
cols() click to toggle source
 
               static VALUE
curses_cols(void)
{
    return INT2FIX(COLS);
}
            
crmode() click to toggle source

def nocbreak

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

Sets Cursor Visibility. 0: invisible 1: visible 2: very visible

 
               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)
{
    curses_stdscr();
    return def_prog_mode() == OK ? Qtrue : Qfalse;
}
            
delch() click to toggle source

def delch

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

def delelteln

 
               static VALUE
curses_deleteln(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(VALUE obj)
{
    curses_stdscr();
#ifdef HAVE_DOUPDATE
    doupdate();
#else
    refresh();
#endif
    return Qnil;
}
            
echo() click to toggle source

def echo

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

def flash

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

def getch

 
               static VALUE
curses_getch(VALUE obj)
{
    int c;

    curses_stdscr();
    rb_thread_blocking_region(getch_func, (void *)&c, RUBY_UBF_IO, 0);
    if (c == EOF) return Qnil;
    if (rb_isprint(c)) {
        char ch = (char)c;

        return rb_locale_str_new(&ch, 1);
    }
    return UINT2NUM(c);
}
            
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(VALUE obj)
{
    char rtn[GETSTR_BUF_SIZE];

    curses_stdscr();
    rb_thread_blocking_region(getstr_func, (void *)rtn, RUBY_UBF_IO, 0);
    return rb_locale_str_new_cstr(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(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(void)
{
    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(VALUE obj, VALUE ch)
{
    curses_stdscr();
    insch(NUM2CH(ch));
    return Qnil;
}
            
insertln() click to toggle source

def insertln

 
               static VALUE
curses_insertln(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(VALUE obj, VALUE c)
{
#ifdef HAVE_KEYNAME
    int cc = curses_char(c);
    const char *name;

    curses_stdscr();
    name = keyname(cc);
    if (name) {
        return rb_str_new_cstr(name);
    }
    else {
        return Qnil;
    }
#else
    return Qnil;
#endif
}
            
lines() click to toggle source
 
               static VALUE
curses_lines(void)
{
    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(VALUE obj)
{
    curses_stdscr();
    nl();
    return Qnil;
}
            
nocbreak() click to toggle source

def nocbreak

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

def nocbreak

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

def noecho

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

def nonl

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

def noraw

 
               static VALUE
curses_noraw(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(VALUE obj)
{
    curses_stdscr();
    raw();
    return Qnil;
}
            
refresh() click to toggle source

def refresh

 
               static VALUE
curses_refresh(VALUE obj)
{
    curses_stdscr();
    refresh();
    return Qnil;
}
            
reset_prog_mode() click to toggle source
 
               static VALUE
curses_reset_prog_mode(VALUE obj)
{
    curses_stdscr();
    return reset_prog_mode() == OK ? Qtrue : Qfalse;
}
            
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(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(VALUE obj)
{
    curses_stdscr();
    standend();
    return Qnil;
}
            
standout() click to toggle source

def standout

 
               static VALUE
curses_standout(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
 
               static VALUE
curses_timeout(VALUE obj, VALUE delay)
{
    curses_stdscr();
    timeout(NUM2INT(delay));
    return Qnil;
}
            
ungetch(p1) click to toggle source

def ungetch

 
               static VALUE
curses_ungetch(VALUE obj, VALUE ch)
{
    int c = curses_char(ch);
    curses_stdscr();
    ungetch(c);
    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;
}
            
use_default_colors() click to toggle source
 
               static VALUE
curses_use_default_colors(VALUE obj)
{
    curses_stdscr();
    use_default_colors();
    return Qnil;
}