]> Repositorios git - scryer-prolog.git/commitdiff
add EMIT_NEWLINE to add newlines to readline input only after query terms begin to...
authorMark <[email protected]>
Thu, 20 Jul 2023 15:39:06 +0000 (09:39 -0600)
committerMark <[email protected]>
Thu, 20 Jul 2023 15:39:06 +0000 (09:39 -0600)
src/machine/system_calls.rs
src/read.rs

index 0d4b5e927203cd313b037b53959a0d307f5c436c..f996966913360f460950481fa8980cd0f7d814dc 100644 (file)
@@ -5797,6 +5797,7 @@ impl Machine {
     pub(crate) fn read_query_term(&mut self) -> CallResult {
         self.user_input.reset();
 
+        set_emit_newline(true);
         set_prompt(true);
         // let result = self.machine_st.read_term(self.user_input, &mut self.indices);
         let result = self.machine_st.read_term_from_user_input(self.user_input, &mut self.indices);
index 3afb4bf910694dc77223775843044ede6d37759e..c21c3016ad9b1a908ce7a9d998167f3ea8bf3efe 100644 (file)
@@ -80,9 +80,16 @@ impl MachineState {
 }
 
 static mut PROMPT: bool = false;
+static mut EMIT_NEWLINE: bool = false;
 
 const HISTORY_FILE: &'static str = ".scryer_history";
 
+pub(crate) fn set_emit_newline(value: bool) {
+    unsafe {
+        EMIT_NEWLINE = value;
+    }
+}
+
 pub(crate) fn set_prompt(value: bool) {
     unsafe {
         PROMPT = value;
@@ -161,10 +168,12 @@ impl ReadlineStream {
                         self.save_history();
                         PROMPT = false;
                     }
-                }
 
-                if self.pending_input.get_ref().get_ref().chars().last() != Some('\n') {
-                    *self.pending_input.get_mut().get_mut() += "\n";
+                    if EMIT_NEWLINE {
+                        if self.pending_input.get_ref().get_ref().chars().last() != Some('\n') {
+                            *self.pending_input.get_mut().get_mut() += "\n";
+                        }
+                    }
                 }
 
                 Ok(self.pending_input.get_ref().get_ref().len())