/src/wrappers/readline/library/read_line.e
Specman e | 74 lines | 44 code | 12 blank | 18 comment | 1 complexity | 41f8db4b53cb5cf560d363df099e080d MD5 | raw file
1deferred class READ_LINE 2-- Interface to the GNU readline library 3 4-- Insert this class to get access to library interface. 5 6insert 7 WRAPPER_HANDLER 8 READLINE_EXTERNALS 9 STRING_HANDLER 10 undefine 11 is_equal, copy 12 end 13 14feature {ANY} -- Read line 15 prompt: ABSTRACT_STRING 16 -- The prompt presented to the user 17 18 last_line: STRING -- The last line read by `read_line' 19 20 read_line 21 -- Print `prompt' and read a line, put into `last_line' 22 local 23 p: POINTER 24 do 25 p := readline(null_or_string(prompt)) 26 if p.is_not_null then 27 create last_line.from_external(p) 28 else 29 -- if ^D is pressed 30 last_line := Void 31 end 32 end 33 34 buffer: FIXED_STRING 35 do 36 Result := buffer_ 37 Result.from_external(rl_line_buffer) 38 end 39 40 completion: READ_LINE_COMPLETION 41 local 42 c: READLINE_CECIL -- we need that indirection to force Liberty Eiffel to "see" the assignment READLINE_CECIL -> READ_LINE_COMPLETION 43 once 44 create {READ_LINE_COMPLETION} c.make 45 Result ::= c 46 end 47 48 history: READ_LINE_HISTORY 49 once 50 create Result.using_history 51 end 52 53feature {} 54 buffer_: FIXED_STRING 55 once 56 create Result.make_from_string("deadstring") 57 end 58 59end -- class READ_LINE 60 61-- Copyright (C) 2010-2017: Paolo Redaelli, 2012 Cyril Adrian 62 63-- This library is free software: you can redistribute it and/or modify 64-- it under the terms of the GNU General Public License as published by 65-- the Free Software Foundation, either version 3 of the License, or 66-- (at your option) any later version. 67-- 68-- This package is distributed in the hope that it will be useful, 69-- but WITHOUT ANY WARRANTY; without even the implied warranty of 70-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 71-- GNU General Public License for more details. 72-- 73-- You should have received a copy of the GNU General Public License 74-- along with Readline. If not, see <http://www.gnu.org/licenses/>.