Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Functions | Variables
console.c File Reference
#include "ruby.h"
#include "ruby/io.h"
Include dependency graph for console.c:

Go to the source code of this file.

Data Structures

struct  rawmode_arg_t
 

Macros

#define rb_funcallv   rb_funcall2
 
#define SET_LAST_ERROR   (0)
 
#define rb_sym2str(sym)   rb_id2str(SYM2ID(sym))
 
#define GetReadFD(fptr)   ((fptr)->fd)
 
#define GetWriteFD(fptr)   get_write_fd(fptr)
 
#define FD_PER_IO   2
 
#define console_goto   rb_f_notimplement
 
#define console_cursor_pos   rb_f_notimplement
 
#define console_cursor_set   rb_f_notimplement
 
#define console_key_pressed_p   rb_f_notimplement
 
#define CONSOLE_DEVICE_FOR_READING   CONSOLE_DEVICE
 

Functions

static VALUE rb_f_send (int argc, VALUE *argv, VALUE recv)
 
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_iflush (VALUE io)
 
static VALUE console_oflush (VALUE io)
 
static VALUE console_ioflush (VALUE io)
 
static VALUE console_beep (VALUE io)
 
static VALUE console_dev (int argc, VALUE *argv, 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
 
static ID id_close
 
static ID id_min
 
static ID id_time
 
static ID id___send__
 

Macro Definition Documentation

◆ console_cursor_pos

#define console_cursor_pos   rb_f_notimplement

Definition at line 754 of file console.c.

Referenced by console_beep(), and InitVM_console().

◆ console_cursor_set

#define console_cursor_set   rb_f_notimplement

Definition at line 755 of file console.c.

Referenced by console_beep(), and InitVM_console().

◆ CONSOLE_DEVICE_FOR_READING

#define CONSOLE_DEVICE_FOR_READING   CONSOLE_DEVICE

Referenced by console_dev().

◆ console_goto

#define console_goto   rb_f_notimplement

Definition at line 753 of file console.c.

Referenced by console_beep(), and InitVM_console().

◆ console_key_pressed_p

#define console_key_pressed_p   rb_f_notimplement

Definition at line 756 of file console.c.

Referenced by console_beep(), and InitVM_console().

◆ FD_PER_IO

#define FD_PER_IO   2

Definition at line 242 of file console.c.

Referenced by ttymode().

◆ GetReadFD

#define GetReadFD (   fptr)    ((fptr)->fd)

◆ GetWriteFD

#define GetWriteFD (   fptr)    get_write_fd(fptr)

Definition at line 240 of file console.c.

Referenced by console_beep(), console_echo_p(), console_ioflush(), console_oflush(), and ttymode().

◆ rb_funcallv

#define rb_funcallv   rb_funcall2

◆ rb_sym2str

#define rb_sym2str (   sym)    rb_id2str(SYM2ID(sym))

◆ SET_LAST_ERROR

#define SET_LAST_ERROR   (0)

Definition at line 79 of file console.c.

Function Documentation

◆ console_beep()

static VALUE console_beep ( VALUE  io)
static

◆ console_cooked()

static VALUE console_cooked ( VALUE  io)
static

Definition at line 358 of file console.c.

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

Referenced by InitVM_console().

◆ console_dev()

static VALUE console_dev ( int  argc,
VALUE argv,
VALUE  klass 
)
static

◆ console_echo_p()

static VALUE console_echo_p ( VALUE  io)
static

◆ console_getch()

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

Definition at line 403 of file console.c.

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

Referenced by InitVM_console().

◆ console_iflush()

static VALUE console_iflush ( VALUE  io)
static

Definition at line 598 of file console.c.

References GetOpenFile, GetReadFD, and rb_sys_fail().

Referenced by InitVM_console().

◆ console_ioflush()

static VALUE console_ioflush ( VALUE  io)
static

Definition at line 644 of file console.c.

References GetOpenFile, GetReadFD, GetWriteFD, and rb_sys_fail().

Referenced by InitVM_console().

◆ console_noecho()

static VALUE console_noecho ( VALUE  io)
static

Definition at line 422 of file console.c.

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

Referenced by InitVM_console().

◆ console_oflush()

static VALUE console_oflush ( VALUE  io)
static

Definition at line 621 of file console.c.

References GetOpenFile, GetWriteFD, and rb_sys_fail().

Referenced by InitVM_console().

◆ console_raw()

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

Definition at line 313 of file console.c.

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

Referenced by InitVM_console().

◆ console_set_cooked()

static VALUE console_set_cooked ( VALUE  io)
static

Definition at line 374 of file console.c.

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

Referenced by InitVM_console().

◆ console_set_echo()

static VALUE console_set_echo ( VALUE  io,
VALUE  f 
)
static

Definition at line 438 of file console.c.

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

Referenced by InitVM_console().

◆ console_set_raw()

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

Definition at line 330 of file console.c.

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

Referenced by InitVM_console().

◆ echo_p()

static int echo_p ( conmode *  t)
static

Definition at line 208 of file console.c.

Referenced by console_echo_p().

◆ get_write_fd()

static int get_write_fd ( const rb_io_t fptr)
inlinestatic

Definition at line 232 of file console.c.

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

◆ getc_call()

static VALUE getc_call ( VALUE  io)
static

Definition at line 389 of file console.c.

References rb_funcallv.

Referenced by console_getch().

◆ Init_console()

void Init_console ( void  )

Definition at line 946 of file console.c.

References InitVM, and rb_intern.

◆ InitVM_console()

void InitVM_console ( void  )

◆ io_getch()

static VALUE io_getch ( int  argc,
VALUE argv,
VALUE  io 
)
static

◆ rawmode_opt()

static rawmode_arg_t* rawmode_opt ( int  argc,
VALUE argv,
rawmode_arg_t opts 
)
static

◆ rb_f_send()

static VALUE rb_f_send ( int  argc,
VALUE argv,
VALUE  recv 
)
static

Definition at line 91 of file console.c.

References argc, argv, id___send__, rb_check_id(), rb_funcallv, and sym.

Referenced by console_dev(), and inject_op_i().

◆ set_cookedmode()

static void set_cookedmode ( conmode *  t,
void *  arg 
)
static

Definition at line 169 of file console.c.

Referenced by console_cooked(), and console_set_cooked().

◆ set_echo()

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

Definition at line 196 of file console.c.

Referenced by console_set_echo().

◆ set_noecho()

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

Definition at line 184 of file console.c.

Referenced by console_noecho(), console_set_echo(), and io_getch().

◆ set_rawmode()

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

Definition at line 142 of file console.c.

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

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

◆ set_ttymode()

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

Definition at line 220 of file console.c.

Referenced by ttymode().

◆ ttymode()

static VALUE ttymode ( VALUE  io,
VALUE(*)(VALUE func,
void(*)(conmode *, void *)  setter,
void *  arg 
)
static

Variable Documentation

◆ id___send__

ID id___send__
static

Definition at line 88 of file console.c.

Referenced by rb_f_send().

◆ id_close

ID id_close
static

Definition at line 82 of file console.c.

◆ id_console

ID id_console
static

Definition at line 82 of file console.c.

◆ id_getc

ID id_getc
static

Definition at line 82 of file console.c.

◆ id_min

ID id_min
static

Definition at line 82 of file console.c.

◆ id_time

ID id_time
static

Definition at line 82 of file console.c.