0
}
-unsafe extern "C" fn bind_cr(_: i32, _: i32) -> i32 {
+unsafe extern "C" fn bind_cr(_: i32, _: i32) -> i32 {
if END_OF_LINE {
if let Some(buf) = rl_line_buffer_as_str() {
if is_directive(buf) {
return 0;
}
}
-
+
println!("");
rl_done = 1;
- } else {
+ } else {
insert_text_rl("\n");
}
}
pub fn read_batch(prompt: &str) -> Result<&'static str, SessionError> {
- unsafe {
- use std::ptr::null;
- use std::mem;
-
- // deactivate the startup hook that emits a "?- " to the
- // beginning of the readline buffer.
- let p: *const i8 = null();
- rl_startup_hook = mem::transmute(p);
- }
-
match readline_rl(prompt) {
Some(input) => Ok(input),
None => Err(SessionError::UserPrompt)
}
}
-fn read_line(prompt: &str) -> Result<&'static str, SessionError> {
+fn read_line(prompt: &str) -> Result<&'static str, SessionError> {
match readline_rl(prompt) {
Some(input) => Ok(input),
None => Err(SessionError::UserPrompt)
}
unsafe extern "C" fn insert_query_prompt() -> i32 {
- insert_text_rl("?- ");
+ if let LineMode::Single = LINE_MODE {
+ insert_text_rl("?- ");
+ }
+
0
}
unsafe {
rl_startup_hook = insert_query_prompt;
}
-
+
let buffer = read_line("")?;
-
+
Ok(match &*buffer.trim() {
"?- [clear]." => Input::Clear,
"?- [user]." => {