From: Mark Thom Date: Mon, 11 May 2020 21:29:28 +0000 (-0600) Subject: reset current input in ReadQueryTerm X-Git-Tag: v0.8.123~40 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=c70b873397e1fa1d8ead1d7161cdfbdcde214748;p=scryer-prolog.git reset current input in ReadQueryTerm --- diff --git a/src/prolog/machine/streams.rs b/src/prolog/machine/streams.rs index 1eefe581..84abb488 100644 --- a/src/prolog/machine/streams.rs +++ b/src/prolog/machine/streams.rs @@ -540,7 +540,10 @@ impl Stream { // returns true on success. #[inline] + pub(super) fn reset(&mut self) -> bool { + self.stream_inst.0.borrow_mut().0 = false; + match self.stream_inst.0.borrow_mut().1 { StreamInstance::Bytes(ref mut cursor) => { cursor.set_position(0); @@ -550,8 +553,7 @@ impl Stream { file.seek(SeekFrom::Start(0)).unwrap(); true } - StreamInstance::ReadlineStream(ref mut stream) => { - *stream = ReadlineStream::new(String::new()); + StreamInstance::ReadlineStream(_) => { true } _ => { diff --git a/src/prolog/machine/system_calls.rs b/src/prolog/machine/system_calls.rs index 02599716..86f32fcb 100644 --- a/src/prolog/machine/system_calls.rs +++ b/src/prolog/machine/system_calls.rs @@ -4235,6 +4235,8 @@ impl MachineState { } } &SystemClauseType::ReadQueryTerm => { + current_input_stream.reset(); + readline::set_prompt(true); let result = self.read_term(current_input_stream.clone(), indices); readline::set_prompt(false); diff --git a/src/prolog/read.rs b/src/prolog/read.rs index 4751759e..61065b80 100644 --- a/src/prolog/read.rs +++ b/src/prolog/read.rs @@ -42,11 +42,6 @@ pub mod readline { } impl ReadlineStream { - pub fn new(pending_input: String) -> Self { - let rl = Editor::<()>::new(); - ReadlineStream { rl, pending_input: Cursor::new(pending_input) } - } - pub fn input_stream(pending_input: String) -> Stream { let mut rl = Editor::<()>::new(); rl.bind_sequence(KeyPress::Tab, Cmd::Insert(1, "\t".to_string()));