ext/io/console/console.c File Reference

#include "ruby.h"
#include "rubyio.h"
#include <winioctl.h>

Go to the source code of this file.

Data Structures

struct  rawmode_arg_t

Defines

#define LAST_ERROR   EBADF
#define SET_LAST_ERROR   (errno = LAST_ERROR, 0)
#define InitVM(ext)   {void InitVM_##ext(void);InitVM_##ext();}
#define GetReadFD(fptr)   ((fptr)->fd)
#define GetWriteFD(fptr)   get_write_fd(fptr)
#define FD_PER_IO   2
#define getwinsize(fd, buf)
#define winsize_row(buf)   ((buf)->srWindow.Bottom - (buf)->srWindow.Top + 1)
#define winsize_col(buf)   (buf)->dwSize.X
#define USE_CONSOLE_GETSIZE   1
#define CONSOLE_DEVICE   "con$"
#define CONSOLE_DEVICE_FOR_READING   "conin$"
#define CONSOLE_DEVICE_FOR_WRITING   "conout$"

Typedefs

typedef OpenFile rb_io_t
typedef DWORD conmode
typedef CONSOLE_SCREEN_BUFFER_INFO rb_console_size_t

Functions

static int setattr (int fd, conmode *t)
static int getattr (int fd, conmode *t)
static rawmode_arg_trawmode_opt (int argc, VALUE *argv, rawmode_arg_t *opts)
static void set_rawmode (conmode *t, void *arg)
static void set_cookedmode (conmode *t, void *arg)
static void set_noecho (conmode *t, void *arg)
static void set_echo (conmode *t, void *arg)
static int echo_p (conmode *t)
static int set_ttymode (int fd, conmode *t, void(*setter)(conmode *, void *), void *arg)
static int get_write_fd (const rb_io_t *fptr)
static VALUE ttymode (VALUE io, VALUE(*func)(VALUE), void(*setter)(conmode *, void *), void *arg)
static VALUE console_raw (int argc, VALUE *argv, VALUE io)
static VALUE console_set_raw (int argc, VALUE *argv, VALUE io)
static VALUE console_cooked (VALUE io)
static VALUE console_set_cooked (VALUE io)
static VALUE getc_call (VALUE io)
static VALUE console_getch (int argc, VALUE *argv, VALUE io)
static VALUE console_noecho (VALUE io)
static VALUE console_set_echo (VALUE io, VALUE f)
static VALUE console_echo_p (VALUE io)
static VALUE console_winsize (VALUE io)
static VALUE console_set_winsize (VALUE io, VALUE size)
static VALUE console_iflush (VALUE io)
static VALUE console_oflush (VALUE io)
static VALUE console_ioflush (VALUE io)
static VALUE console_dev (VALUE klass)
static VALUE io_getch (int argc, VALUE *argv, VALUE io)
void Init_console (void)
void InitVM_console (void)

Variables

static ID id_getc
static ID id_console

Define Documentation

#define CONSOLE_DEVICE   "con$"

Referenced by console_dev().

#define CONSOLE_DEVICE_FOR_READING   "conin$"

Referenced by console_dev().

#define CONSOLE_DEVICE_FOR_WRITING   "conout$"

Referenced by console_dev().

#define FD_PER_IO   2

Definition at line 232 of file console.c.

Referenced by ttymode().

#define GetReadFD ( fptr   )     ((fptr)->fd)
#define getwinsize ( fd,
buf   ) 
Value:
( \
    GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), (buf)) || \
    SET_LAST_ERROR)

Definition at line 475 of file console.c.

Referenced by console_set_winsize(), and console_winsize().

#define GetWriteFD ( fptr   )     get_write_fd(fptr)
#define InitVM ( ext   )     {void InitVM_##ext(void);InitVM_##ext();}

Definition at line 89 of file console.c.

Referenced by Init_console(), and Init_ripper().

#define LAST_ERROR   EBADF

Definition at line 64 of file console.c.

Referenced by getattr(), and setattr().

#define SET_LAST_ERROR   (errno = LAST_ERROR, 0)

Definition at line 66 of file console.c.

Referenced by console_set_winsize().

#define USE_CONSOLE_GETSIZE   1

Definition at line 483 of file console.c.

#define winsize_col ( buf   )     (buf)->dwSize.X

Definition at line 479 of file console.c.

Referenced by console_winsize().

#define winsize_row ( buf   )     ((buf)->srWindow.Bottom - (buf)->srWindow.Top + 1)

Definition at line 478 of file console.c.

Referenced by console_winsize().


Typedef Documentation

typedef DWORD conmode

Definition at line 59 of file console.c.

typedef CONSOLE_SCREEN_BUFFER_INFO rb_console_size_t

Definition at line 474 of file console.c.

typedef OpenFile rb_io_t

Definition at line 13 of file console.c.


Function Documentation

static VALUE console_cooked ( VALUE  io  )  [static]

Definition at line 349 of file console.c.

References NULL, rb_yield(), set_cookedmode(), and ttymode().

Referenced by InitVM_console().

static VALUE console_dev ( VALUE  klass  )  [static]
static VALUE console_echo_p ( VALUE  io  )  [static]

Definition at line 455 of file console.c.

References echo_p(), getattr(), GetOpenFile, GetReadFD, Qfalse, Qtrue, and rb_sys_fail.

Referenced by InitVM_console().

static VALUE console_getch ( int  argc,
VALUE argv,
VALUE  io 
) [static]

Definition at line 394 of file console.c.

References getc_call(), rawmode_opt(), set_rawmode(), and ttymode().

Referenced by InitVM_console().

static VALUE console_iflush ( VALUE  io  )  [static]

Definition at line 579 of file console.c.

References GetOpenFile, GetReadFD, and rb_sys_fail.

Referenced by InitVM_console().

static VALUE console_ioflush ( VALUE  io  )  [static]

Definition at line 623 of file console.c.

References GetOpenFile, GetReadFD, GetWriteFD, and rb_sys_fail.

Referenced by InitVM_console().

static VALUE console_noecho ( VALUE  io  )  [static]

Definition at line 413 of file console.c.

References NULL, rb_yield(), set_noecho(), and ttymode().

Referenced by InitVM_console().

static VALUE console_oflush ( VALUE  io  )  [static]

Definition at line 601 of file console.c.

References GetOpenFile, GetWriteFD, and rb_sys_fail.

Referenced by InitVM_console().

static VALUE console_raw ( int  argc,
VALUE argv,
VALUE  io 
) [static]

Definition at line 304 of file console.c.

References rawmode_opt(), rb_yield(), set_rawmode(), and ttymode().

Referenced by InitVM_console().

static VALUE console_set_cooked ( VALUE  io  )  [static]

Definition at line 365 of file console.c.

References getattr(), GetOpenFile, GetReadFD, NULL, rb_sys_fail, set_cookedmode(), and setattr().

Referenced by InitVM_console().

static VALUE console_set_echo ( VALUE  io,
VALUE  f 
) [static]

Definition at line 429 of file console.c.

References getattr(), GetOpenFile, GetReadFD, NULL, rb_sys_fail, RTEST, set_echo(), set_noecho(), and setattr().

Referenced by InitVM_console().

static VALUE console_set_raw ( int  argc,
VALUE argv,
VALUE  io 
) [static]

Definition at line 321 of file console.c.

References getattr(), GetOpenFile, GetReadFD, rawmode_opt(), rb_sys_fail, set_rawmode(), and setattr().

Referenced by InitVM_console().

static VALUE console_set_winsize ( VALUE  io,
VALUE  size 
) [static]
static VALUE console_winsize ( VALUE  io  )  [static]

Definition at line 496 of file console.c.

References GetOpenFile, getwinsize, GetWriteFD, INT2NUM(), rb_assoc_new(), rb_sys_fail, winsize_col, and winsize_row.

Referenced by InitVM_console().

static int echo_p ( conmode t  )  [static]

Definition at line 190 of file console.c.

Referenced by console_echo_p().

static int get_write_fd ( const rb_io_t fptr  )  [inline, static]

Definition at line 221 of file console.c.

References rb_io_t::fd, GetOpenFile, and rb_io_t::tied_io_for_writing.

static int getattr ( int  fd,
conmode t 
) [static]
static VALUE getc_call ( VALUE  io  )  [static]

Definition at line 380 of file console.c.

References rb_funcall2().

Referenced by console_getch().

void Init_console ( void   ) 

Definition at line 734 of file console.c.

References InitVM, and rb_intern.

void InitVM_console ( void   ) 
static VALUE io_getch ( int  argc,
VALUE argv,
VALUE  io 
) [static]

Definition at line 725 of file console.c.

References rb_funcall2(), and rb_intern.

Referenced by InitVM_console().

static rawmode_arg_t* rawmode_opt ( int  argc,
VALUE argv,
rawmode_arg_t opts 
) [static]
static void set_cookedmode ( conmode t,
void *  arg 
) [static]

Definition at line 151 of file console.c.

Referenced by console_cooked(), and console_set_cooked().

static void set_echo ( conmode t,
void *  arg 
) [static]

Definition at line 178 of file console.c.

Referenced by console_set_echo().

static void set_noecho ( conmode t,
void *  arg 
) [static]

Definition at line 166 of file console.c.

Referenced by console_noecho(), and console_set_echo().

static void set_rawmode ( conmode t,
void *  arg 
) [static]

Definition at line 124 of file console.c.

References rawmode_arg_t::vmin, and rawmode_arg_t::vtime.

Referenced by console_getch(), console_raw(), and console_set_raw().

static int set_ttymode ( int  fd,
conmode t,
void(*)(conmode *, void *)  setter,
void *  arg 
) [static]

Definition at line 202 of file console.c.

References getattr(), and setattr().

Referenced by ttymode().

static int setattr ( int  fd,
conmode t 
) [static]
static VALUE ttymode ( VALUE  io,
VALUE(*)(VALUE func,
void(*)(conmode *, void *)  setter,
void *  arg 
) [static]

Variable Documentation

ID id_console [static]

Definition at line 92 of file console.c.

ID id_getc [static]

Definition at line 92 of file console.c.


Generated on 1 Aug 2012 for Ruby by  doxygen 1.6.1