U:RDoc::AnyMethod[iI" readline:ETI"Readline::readline;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GShows the +prompt+ and reads the inputted line with line editing. ;TI"EThe inputted line is added to the history if +add_hist+ is true.;To:RDoc::Markup::BlankLineo; ; [I"EReturns nil when the inputted line is empty and user inputs EOF ;TI"(Presses ^D on UNIX).;T@o; ; [I"GRaises IOError exception if one of below conditions are satisfied.;To:RDoc::Markup::List: @type: NUMBER: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"stdin was closed.;To;;0; [o; ; [I"stdout was closed.;T@o; ; [I"IThis method supports thread. Switches the thread context when waits ;TI"inputting line.;T@o; ; [I"NSupports line edit when inputs line. Provides VI and Emacs editing mode. ;TI"#Default is Emacs editing mode.;T@o; ; [I"HNOTE: Terminates ruby interpreter and does not return the terminal ;TI">status after user pressed '^C' when wait inputting line. ;TI"#Give 3 examples that avoid it.;T@o; ; : BULLET;[o;;0; [o; ; [I"ACatches the Interrupt exception by pressed ^C after returns ;TI"terminal status:;T@o:RDoc::Markup::Verbatim; [I"require "readline" ;TI" ;TI"!stty_save = `stty -g`.chomp ;TI" begin ;TI"% while buf = Readline.readline ;TI" p buf ;TI" end ;TI" rescue Interrupt ;TI"% system("stty", stty_save) ;TI" exit ;TI" end ;TI" end ;TI" end ;T: @format0o;;0; [o; ; [I"ACatches the INT signal by pressed ^C after returns terminal ;TI" status:;T@o;; [ I"require "readline" ;TI" ;TI"!stty_save = `stty -g`.chomp ;TI"4trap("INT") { system "stty", stty_save; exit } ;TI" ;TI"#while buf = Readline.readline ;TI" p buf ;TI" end ;T;0o;;0; [o; ; [I"Ignores pressing ^C:;T@o;; [ I"require "readline" ;TI" ;TI"trap("INT", "SIG_IGN") ;TI" ;TI"#while buf = Readline.readline ;TI" p buf ;TI" end ;T;0o; ; [I":Can make as follows with Readline::HISTORY constant. ;TI"HIt does not record to the history if the inputted line is empty or ;TI"the same it as last one.;T@o;; [I"require "readline" ;TI" ;TI"/while buf = Readline.readline("> ", true) ;TI"" # p Readline::HISTORY.to_a ;TI"/ Readline::HISTORY.pop if /^\s*$/ =~ buf ;TI" ;TI" begin ;TI"A if Readline::HISTORY[Readline::HISTORY.length-2] == buf ;TI"! Readline::HISTORY.pop ;TI" end ;TI" rescue IndexError ;TI" end ;TI" ;TI"" # p Readline::HISTORY.to_a ;TI" print "-> ", buf, "\n" ;TI"end;T;0: @fileI"ext/readline/readline.c;T:0@omit_headings_from_table_of_contents_below0I"GReadline.readline(prompt = "", add_hist = false) -> string or nil ;T0[I"(p1 = v1, p2 = v2);T@|FI" Readline;TcRDoc::NormalModule00