From 3f950490f96b3918582073a5cf4bf54a875e3f34 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Sat, 6 Feb 2021 13:47:26 -0700 Subject: [PATCH] set rustyline to check the cursor position (#802), don't add .pl extension to files in loader.pl (#800) --- src/loader.pl | 5 +---- src/machine/system_calls.rs | 4 ++++ src/read.rs | 8 ++++++-- src/toplevel.pl | 5 +++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/loader.pl b/src/loader.pl index 0ac97ac6..ca157855 100644 --- a/src/loader.pl +++ b/src/loader.pl @@ -35,7 +35,6 @@ expand_term(Term, ExpandedTerm) :- ; Term = ExpandedTerm ). - term_expansion_list([], ExpandedTerms, ExpandedTerms). term_expansion_list([Term|Terms], ExpandedTermsHead, ExpandedTermsTail) :- expand_term(Term, ExpandedTerm0), @@ -310,9 +309,7 @@ use_module(Module, Exports) :- load_context_path(Module, Path) :- ( prolog_load_context(directory, CurrentDir) -> atom_concat(CurrentDir, Path, Module) - ; atom_concat(_, '.pl', Module) -> - Module = Path - ; atom_concat(Module, '.pl', Path) + ; Module = Path ). diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 6990ed40..03aa1244 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -3349,6 +3349,10 @@ impl MachineState { } } } + Addr::Char(c) => { + let atom = clause_name!(c.to_string(), self.atom_tbl); + self.stream_from_file_spec(atom, indices, &options)? + } Addr::PStrLocation(h, n) => { match &self.heap[h] { &HeapCellValue::PartialString(_, true) => { diff --git a/src/read.rs b/src/read.rs index ba975201..4ed74fbf 100644 --- a/src/read.rs +++ b/src/read.rs @@ -17,7 +17,7 @@ pub type PrologStream = ParsingStream; pub mod readline { use crate::machine::streams::Stream; use crate::rustyline::error::ReadlineError; - use crate::rustyline::{Cmd, Editor, KeyEvent}; + use crate::rustyline::{Cmd, Config, Editor, KeyEvent}; use std::io::{Cursor, Error, ErrorKind, Read}; static mut PROMPT: bool = false; @@ -46,7 +46,11 @@ pub mod readline { impl ReadlineStream { #[inline] pub fn new(pending_input: String) -> Self { - let mut rl = Editor::<()>::new(); + let config = Config::builder() + .check_cursor_position(true) + .build(); + + let mut rl = Editor::<()>::with_config(config); //Editor::<()>::new(); if let Some(mut path) = dirs_next::home_dir() { path.push(HISTORY_FILE); if path.exists() { diff --git a/src/toplevel.pl b/src/toplevel.pl index 09f28545..8ff02242 100644 --- a/src/toplevel.pl +++ b/src/toplevel.pl @@ -37,7 +37,8 @@ delegate_task([Arg0|Args], Goals0) :- ; member(Arg0, ["-v", "--version"]) -> print_version ; member(Arg0, ["-g", "--goal"]) -> gather_goal(g, Args, Goals0) ; atom_chars(Mod, Arg0), - catch(use_module(Mod), E, print_exception(E)) + catch(use_module(Mod), E, print_exception(E)), + nl ), delegate_task(Args, Goals0). @@ -122,7 +123,7 @@ instruction_match(Term, VarList) :- ( Item == user -> catch(load(user_input), E, print_exception_with_check(E)) ; - consult(Item) + submit_query_and_print_results(consult(Item), []) ) ; catch(type_error(atom, Item, repl/0), -- 2.54.0