Ruby  2.1.10p492(2016-04-01revision54464)
Macros | Functions | Variables
readline.c File Reference
#include "ruby/config.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "ruby/ruby.h"
#include "ruby/io.h"
#include "ruby/thread.h"

Go to the source code of this file.

Macros

#define EDIT_LINE_LIBRARY_VERSION   "EditLine wrapper"
 
#define USE_INSERT_IGNORE_ESCAPE   0
 
#define COMPLETION_PROC   "completion_proc"
 
#define COMPLETION_CASE_FOLD   "completion_case_fold"
 
#define rl_filename_completion_function   filename_completion_function
 
#define rl_username_completion_function   username_completion_function
 
#define rl_completion_matches   completion_matches
 
#define OutputStringValue(str)
 
#define readline_s_set_pre_input_hook   rb_f_notimplement
 
#define readline_s_get_pre_input_hook   rb_f_notimplement
 
#define readline_s_insert_text   rb_f_notimplement
 
#define readline_s_delete_text   rb_f_notimplement
 
#define readline_s_redisplay   rb_f_notimplement
 
#define readline_s_get_line_buffer   rb_f_notimplement
 
#define readline_s_get_point   rb_f_notimplement
 
#define readline_s_set_point   rb_f_notimplement
 
#define readline_s_set_screen_size   rb_f_notimplement
 
#define readline_s_get_screen_size   rb_f_notimplement
 
#define readline_s_vi_editing_mode   rb_f_notimplement
 
#define readline_s_vi_editing_mode_p   rb_f_notimplement
 
#define readline_s_emacs_editing_mode   rb_f_notimplement
 
#define readline_s_emacs_editing_mode_p   rb_f_notimplement
 
#define readline_s_set_completion_append_character   rb_f_notimplement
 
#define readline_s_get_completion_append_character   rb_f_notimplement
 
#define readline_s_set_basic_word_break_characters   rb_f_notimplement
 
#define readline_s_get_basic_word_break_characters   rb_f_notimplement
 
#define readline_s_set_completer_word_break_characters   rb_f_notimplement
 
#define readline_s_get_completer_word_break_characters   rb_f_notimplement
 
#define readline_s_set_special_prefixes   rb_f_notimplement
 
#define readline_s_get_special_prefixes   rb_f_notimplement
 
#define readline_s_set_basic_quote_characters   rb_f_notimplement
 
#define readline_s_get_basic_quote_characters   rb_f_notimplement
 
#define readline_s_set_completer_quote_characters   rb_f_notimplement
 
#define readline_s_get_completer_quote_characters   rb_f_notimplement
 
#define readline_s_set_filename_quote_characters   rb_f_notimplement
 
#define readline_s_get_filename_quote_characters   rb_f_notimplement
 
#define readline_s_refresh_line   rb_f_notimplement
 
#define hist_set   rb_f_notimplement
 
#define hist_clear   rb_f_notimplement
 

Functions

static char ** readline_attempted_completion_function (const char *text, int start, int end)
 
static VALUE readline_get (VALUE prompt)
 
static void clear_rl_instream (void)
 
static void clear_rl_outstream (void)
 
static VALUE readline_readline (int argc, VALUE *argv, VALUE self)
 
static VALUE readline_s_set_input (VALUE self, VALUE input)
 
static VALUE readline_s_set_output (VALUE self, VALUE output)
 
static VALUE readline_s_set_completion_proc (VALUE self, VALUE proc)
 
static VALUE readline_s_get_completion_proc (VALUE self)
 
static VALUE readline_s_set_completion_case_fold (VALUE self, VALUE val)
 
static VALUE readline_s_get_completion_case_fold (VALUE self)
 
static VALUE hist_to_s (VALUE self)
 
static int history_get_offset_history_base (int offset)
 
static int history_get_offset_0 (int offset)
 
static VALUE hist_get (VALUE self, VALUE index)
 
static VALUE hist_push (VALUE self, VALUE str)
 
static VALUE hist_push_method (int argc, VALUE *argv, VALUE self)
 
static VALUE rb_remove_history (int index)
 
static VALUE hist_pop (VALUE self)
 
static VALUE hist_shift (VALUE self)
 
static VALUE hist_each (VALUE self)
 
static VALUE hist_length (VALUE self)
 
static VALUE hist_empty_p (VALUE self)
 
static VALUE hist_delete_at (VALUE self, VALUE index)
 
static VALUE filename_completion_proc_call (VALUE self, VALUE str)
 
static VALUE username_completion_proc_call (VALUE self, VALUE str)
 
void Init_readline ()
 

Variables

static VALUE mReadline
 
static ID completion_proc
 
static ID completion_case_fold
 
static int(* history_get_offset_func )(int)
 
static int(* history_replace_offset_func )(int)
 
static VALUE readline_instream
 
static VALUE readline_outstream
 
static FILEreadline_rl_instream
 
static FILEreadline_rl_outstream
 

Macro Definition Documentation

◆ COMPLETION_CASE_FOLD

#define COMPLETION_CASE_FOLD   "completion_case_fold"

Definition at line 60 of file readline.c.

Referenced by Init_readline().

◆ COMPLETION_PROC

#define COMPLETION_PROC   "completion_proc"

Definition at line 59 of file readline.c.

Referenced by Init_readline().

◆ EDIT_LINE_LIBRARY_VERSION

#define EDIT_LINE_LIBRARY_VERSION   "EditLine wrapper"

Definition at line 50 of file readline.c.

Referenced by Init_readline().

◆ hist_clear

#define hist_clear   rb_f_notimplement

Definition at line 1739 of file readline.c.

Referenced by Init_readline().

◆ hist_set

#define hist_set   rb_f_notimplement

Definition at line 1622 of file readline.c.

Referenced by Init_readline().

◆ OutputStringValue

#define OutputStringValue (   str)
Value:
do {\
SafeStringValue(str);\
(str) = rb_str_conv_enc((str), rb_enc_get(str), rb_locale_encoding());\
} while (0)\
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
Definition: string.c:680
rb_encoding * rb_locale_encoding(void)
Definition: encoding.c:1309
rb_encoding * rb_enc_get(VALUE obj)
Definition: encoding.c:832

Definition at line 91 of file readline.c.

Referenced by hist_push(), hist_push_method(), and readline_readline().

◆ readline_s_delete_text

#define readline_s_delete_text   rb_f_notimplement

Definition at line 718 of file readline.c.

Referenced by Init_readline().

◆ readline_s_emacs_editing_mode

#define readline_s_emacs_editing_mode   rb_f_notimplement

Definition at line 1109 of file readline.c.

Referenced by Init_readline().

◆ readline_s_emacs_editing_mode_p

#define readline_s_emacs_editing_mode_p   rb_f_notimplement

Definition at line 1127 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_basic_quote_characters

#define readline_s_get_basic_quote_characters   rb_f_notimplement

Definition at line 1434 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_basic_word_break_characters

#define readline_s_get_basic_word_break_characters   rb_f_notimplement

Definition at line 1264 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_completer_quote_characters

#define readline_s_get_completer_quote_characters   rb_f_notimplement

Definition at line 1490 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_completer_word_break_characters

#define readline_s_get_completer_word_break_characters   rb_f_notimplement

Definition at line 1319 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_completion_append_character

#define readline_s_get_completion_append_character   rb_f_notimplement

Definition at line 1209 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_filename_quote_characters

#define readline_s_get_filename_quote_characters   rb_f_notimplement

Definition at line 1544 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_line_buffer

#define readline_s_get_line_buffer   rb_f_notimplement

Definition at line 885 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_point

#define readline_s_get_point   rb_f_notimplement

Definition at line 928 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_pre_input_hook

#define readline_s_get_pre_input_hook   rb_f_notimplement

Definition at line 645 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_screen_size

#define readline_s_get_screen_size   rb_f_notimplement

Definition at line 1051 of file readline.c.

Referenced by Init_readline().

◆ readline_s_get_special_prefixes

#define readline_s_get_special_prefixes   rb_f_notimplement

Definition at line 1381 of file readline.c.

Referenced by Init_readline().

◆ readline_s_insert_text

#define readline_s_insert_text   rb_f_notimplement

Definition at line 667 of file readline.c.

Referenced by Init_readline().

◆ readline_s_redisplay

#define readline_s_redisplay   rb_f_notimplement

Definition at line 740 of file readline.c.

Referenced by Init_readline().

◆ readline_s_refresh_line

#define readline_s_refresh_line   rb_f_notimplement

Definition at line 1561 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_basic_quote_characters

#define readline_s_set_basic_quote_characters   rb_f_notimplement

Definition at line 1414 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_basic_word_break_characters

#define readline_s_set_basic_word_break_characters   rb_f_notimplement

Definition at line 1243 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_completer_quote_characters

#define readline_s_set_completer_quote_characters   rb_f_notimplement

Definition at line 1469 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_completer_word_break_characters

#define readline_s_set_completer_word_break_characters   rb_f_notimplement

Definition at line 1298 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_completion_append_character

#define readline_s_set_completion_append_character   rb_f_notimplement

Definition at line 1184 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_filename_quote_characters

#define readline_s_set_filename_quote_characters   rb_f_notimplement

Definition at line 1523 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_point

#define readline_s_set_point   rb_f_notimplement

Definition at line 929 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_pre_input_hook

#define readline_s_set_pre_input_hook   rb_f_notimplement

Definition at line 644 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_screen_size

#define readline_s_set_screen_size   rb_f_notimplement

Definition at line 1024 of file readline.c.

Referenced by Init_readline().

◆ readline_s_set_special_prefixes

#define readline_s_set_special_prefixes   rb_f_notimplement

Definition at line 1380 of file readline.c.

Referenced by Init_readline().

◆ readline_s_vi_editing_mode

#define readline_s_vi_editing_mode   rb_f_notimplement

Definition at line 1071 of file readline.c.

Referenced by Init_readline().

◆ readline_s_vi_editing_mode_p

#define readline_s_vi_editing_mode_p   rb_f_notimplement

Definition at line 1089 of file readline.c.

Referenced by Init_readline().

◆ rl_completion_matches

#define rl_completion_matches   completion_matches

Definition at line 79 of file readline.c.

Referenced by filename_completion_proc_call(), and username_completion_proc_call().

◆ rl_filename_completion_function

#define rl_filename_completion_function   filename_completion_function

Definition at line 73 of file readline.c.

Referenced by filename_completion_proc_call().

◆ rl_username_completion_function

#define rl_username_completion_function   username_completion_function

Definition at line 76 of file readline.c.

Referenced by username_completion_proc_call().

◆ USE_INSERT_IGNORE_ESCAPE

#define USE_INSERT_IGNORE_ESCAPE   0

Definition at line 55 of file readline.c.

Function Documentation

◆ clear_rl_instream()

static void clear_rl_instream ( void  )
static

Definition at line 339 of file readline.c.

References NULL, Qfalse, readline_instream, and readline_rl_instream.

Referenced by readline_readline(), and readline_s_set_input().

◆ clear_rl_outstream()

static void clear_rl_outstream ( void  )
static

Definition at line 351 of file readline.c.

References NULL, Qfalse, readline_outstream, and readline_rl_outstream.

Referenced by readline_readline(), and readline_s_set_output().

◆ filename_completion_proc_call()

static VALUE filename_completion_proc_call ( VALUE  self,
VALUE  str 
)
static

◆ hist_delete_at()

static VALUE hist_delete_at ( VALUE  self,
VALUE  index 
)
static

Definition at line 1718 of file readline.c.

References NUM2INT, rb_eIndexError, rb_raise(), and rb_remove_history().

Referenced by Init_readline().

◆ hist_each()

static VALUE hist_each ( VALUE  self)
static

Definition at line 1689 of file readline.c.

References history_get_offset_func, NULL, rb_locale_str_new_cstr(), rb_yield(), and RETURN_ENUMERATOR.

Referenced by Init_readline().

◆ hist_empty_p()

static VALUE hist_empty_p ( VALUE  self)
static

Definition at line 1712 of file readline.c.

References Qfalse, and Qtrue.

Referenced by Init_readline().

◆ hist_get()

static VALUE hist_get ( VALUE  self,
VALUE  index 
)
static

Definition at line 1583 of file readline.c.

References history_get_offset_func, NULL, NUM2INT, rb_eIndexError, rb_locale_str_new_cstr(), and rb_raise().

Referenced by Init_readline().

◆ hist_length()

static VALUE hist_length ( VALUE  self)
static

Definition at line 1706 of file readline.c.

References INT2NUM.

Referenced by Init_readline().

◆ hist_pop()

static VALUE hist_pop ( VALUE  self)
static

Definition at line 1669 of file readline.c.

References Qnil, and rb_remove_history().

Referenced by Init_readline().

◆ hist_push()

static VALUE hist_push ( VALUE  self,
VALUE  str 
)
static

Definition at line 1626 of file readline.c.

References OutputStringValue, and RSTRING_PTR.

Referenced by Init_readline().

◆ hist_push_method()

static VALUE hist_push_method ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 1634 of file readline.c.

References argc, argv, OutputStringValue, and RSTRING_PTR.

Referenced by Init_readline().

◆ hist_shift()

static VALUE hist_shift ( VALUE  self)
static

Definition at line 1679 of file readline.c.

References Qnil, and rb_remove_history().

Referenced by Init_readline().

◆ hist_to_s()

static VALUE hist_to_s ( VALUE  self)
static

Definition at line 1565 of file readline.c.

References rb_str_new_cstr().

Referenced by Init_readline().

◆ history_get_offset_0()

static int history_get_offset_0 ( int  offset)
static

Definition at line 1577 of file readline.c.

Referenced by Init_readline().

◆ history_get_offset_history_base()

static int history_get_offset_history_base ( int  offset)
static

Definition at line 1571 of file readline.c.

Referenced by Init_readline().

◆ Init_readline()

void Init_readline ( )

Definition at line 1793 of file readline.c.

References COMPLETION_CASE_FOLD, completion_case_fold, COMPLETION_PROC, completion_proc, CONST_ID, EDIT_LINE_LIBRARY_VERSION, filename_completion_proc_call(), free(), hist_clear, hist_delete_at(), hist_each(), hist_empty_p(), hist_get(), hist_length(), hist_pop(), hist_push(), hist_push_method(), hist_set, hist_shift(), hist_to_s(), history_get_offset_0(), history_get_offset_func, history_get_offset_history_base(), history_replace_offset_func, mReadline, NULL, rb_cObject, rb_define_const(), rb_define_module(), rb_define_module_function(), rb_define_singleton_method(), rb_extend_object(), rb_gc_register_address(), rb_intern, rb_mEnumerable, rb_obj_alloc(), rb_str_new_cstr(), readline_attempted_completion_function(), readline_instream, readline_outstream, readline_readline(), readline_s_delete_text, readline_s_emacs_editing_mode, readline_s_emacs_editing_mode_p, readline_s_get_basic_quote_characters, readline_s_get_basic_word_break_characters, readline_s_get_completer_quote_characters, readline_s_get_completer_word_break_characters, readline_s_get_completion_append_character, readline_s_get_completion_case_fold(), readline_s_get_completion_proc(), readline_s_get_filename_quote_characters, readline_s_get_line_buffer, readline_s_get_point, readline_s_get_pre_input_hook, readline_s_get_screen_size, readline_s_get_special_prefixes, readline_s_insert_text, readline_s_redisplay, readline_s_refresh_line, readline_s_set_basic_quote_characters, readline_s_set_basic_word_break_characters, readline_s_set_completer_quote_characters, readline_s_set_completer_word_break_characters, readline_s_set_completion_append_character, readline_s_set_completion_case_fold(), readline_s_set_completion_proc(), readline_s_set_filename_quote_characters, readline_s_set_input(), readline_s_set_output(), readline_s_set_point, readline_s_set_pre_input_hook, readline_s_set_screen_size, readline_s_set_special_prefixes, readline_s_vi_editing_mode, readline_s_vi_editing_mode_p, strlen(), username_completion_proc_call(), and version().

◆ rb_remove_history()

static VALUE rb_remove_history ( int  index)
static

Definition at line 1647 of file readline.c.

References free(), Qnil, rb_locale_str_new_cstr(), rb_notimplement(), UNREACHABLE, and val.

Referenced by hist_delete_at(), hist_pop(), and hist_shift().

◆ readline_attempted_completion_function()

static char ** readline_attempted_completion_function ( const char *  text,
int  start,
int  end 
)
static

◆ readline_get()

static VALUE readline_get ( VALUE  prompt)
static

Definition at line 330 of file readline.c.

Referenced by readline_readline().

◆ readline_readline()

static VALUE readline_readline ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ readline_s_get_completion_case_fold()

static VALUE readline_s_get_completion_case_fold ( VALUE  self)
static

Definition at line 858 of file readline.c.

References completion_case_fold, mReadline, and rb_attr_get().

Referenced by Init_readline().

◆ readline_s_get_completion_proc()

static VALUE readline_s_get_completion_proc ( VALUE  self)
static

Definition at line 826 of file readline.c.

References completion_proc, mReadline, and rb_attr_get().

Referenced by Init_readline().

◆ readline_s_set_completion_case_fold()

static VALUE readline_s_set_completion_case_fold ( VALUE  self,
VALUE  val 
)
static

Definition at line 838 of file readline.c.

References completion_case_fold, mReadline, rb_ivar_set(), and val.

Referenced by Init_readline().

◆ readline_s_set_completion_proc()

static VALUE readline_s_set_completion_proc ( VALUE  self,
VALUE  proc 
)
static

Definition at line 812 of file readline.c.

References completion_proc, mReadline, NIL_P, rb_eArgError, rb_intern, rb_ivar_set(), rb_raise(), and rb_respond_to().

Referenced by Init_readline().

◆ readline_s_set_input()

static VALUE readline_s_set_input ( VALUE  self,
VALUE  input 
)
static

◆ readline_s_set_output()

static VALUE readline_s_set_output ( VALUE  self,
VALUE  output 
)
static

◆ username_completion_proc_call()

static VALUE username_completion_proc_call ( VALUE  self,
VALUE  str 
)
static

Variable Documentation

◆ completion_case_fold

ID completion_case_fold
static

◆ completion_proc

ID completion_proc
static

◆ history_get_offset_func

int(* history_get_offset_func) (int)
static

Definition at line 82 of file readline.c.

Referenced by hist_each(), hist_get(), and Init_readline().

◆ history_replace_offset_func

int(* history_replace_offset_func) (int)
static

Definition at line 83 of file readline.c.

Referenced by Init_readline().

◆ mReadline

VALUE mReadline
static

◆ readline_instream

VALUE readline_instream
static

◆ readline_outstream

VALUE readline_outstream
static

◆ readline_rl_instream

FILE* readline_rl_instream
static

Definition at line 132 of file readline.c.

Referenced by clear_rl_instream(), and readline_s_set_input().

◆ readline_rl_outstream

FILE* readline_rl_outstream
static

Definition at line 133 of file readline.c.

Referenced by clear_rl_outstream(), and readline_s_set_output().