]> Repositorios git - scryer-prolog.git/commitdiff
Removed $raw_input_read_char
authornotoria <[email protected]>
Sat, 18 Apr 2020 11:54:18 +0000 (13:54 +0200)
committernotoria <[email protected]>
Sat, 18 Apr 2020 11:54:18 +0000 (13:54 +0200)
src/prolog/clause_types.rs
src/prolog/machine/system_calls.rs
src/prolog/toplevel.pl

index 37c8f612f52d197ce6e59dc90e055f4d5f79e916..660de341c8d92179fa920460349321b01fb356eb 100644 (file)
@@ -242,7 +242,6 @@ pub enum SystemClauseType {
     InstallNewBlock,
     Maybe,
     QuotedToken,
-    RawInputReadChar,
     ReadTermFromChars,
     ResetBlock,
     ReturnFromVerifyAttr,
@@ -366,7 +365,6 @@ impl SystemClauseType {
             &SystemClauseType::QuotedToken => {
                 clause_name!("$quoted_token")
             }
-            &SystemClauseType::RawInputReadChar => clause_name!("$raw_input_read_char"),
             &SystemClauseType::RedoAttrVarBinding => clause_name!("$redo_attr_var_binding"),
             &SystemClauseType::RemoveCallPolicyCheck => clause_name!("$remove_call_policy_check"),
             &SystemClauseType::RemoveInferenceCounter => clause_name!("$remove_inference_counter"),
@@ -509,7 +507,6 @@ impl SystemClauseType {
             ("$get_cp", 1) => Some(SystemClauseType::GetCutPoint),
             ("$install_new_block", 1) => Some(SystemClauseType::InstallNewBlock),
             ("$quoted_token", 1) => Some(SystemClauseType::QuotedToken),
-            ("$raw_input_read_char", 1) => Some(SystemClauseType::RawInputReadChar),
             ("$nextEP", 3) => Some(SystemClauseType::NextEP),
             ("$read_query_term", 2) => Some(SystemClauseType::ReadQueryTerm),
             ("$read_term", 2) => Some(SystemClauseType::ReadTerm),
index 1a783ac95f4c6b19d93a2d3384d260676c9b65fd..e2cad96a21b05aaf880717c86fb27852e1ab2a7e 100644 (file)
@@ -31,42 +31,6 @@ use std::rc::Rc;
 use crate::crossterm::event::{read, Event, KeyCode, KeyEvent};
 use crate::crossterm::terminal::{enable_raw_mode, disable_raw_mode};
 
-pub enum ContinueResult {
-    ContinueQuery,
-    Conclude,
-    Help,
-    PrintWithoutMaxDepth,
-    PrintWithMaxDepth
-}
-
-pub fn next_keypress() -> ContinueResult {
-    loop {
-        match read() {
-            Ok(Event::Key(KeyEvent { code, .. })) => {
-                match code {
-                    KeyCode::Char('w') => {
-                        return ContinueResult::PrintWithoutMaxDepth;
-                    }
-                    KeyCode::Char('p') => {
-                        return ContinueResult::PrintWithMaxDepth;
-                    }
-                    KeyCode::Char(' ') | KeyCode::Char(';') | KeyCode::Char('n') => {
-                        return ContinueResult::ContinueQuery;
-                    }
-                    KeyCode::Char('.') => {
-                        return ContinueResult::Conclude;
-                    }
-                    KeyCode::Char('h') => {
-                        return ContinueResult::Help;
-                    }
-                    _ => {}
-                }
-            }
-            _ => {}
-        }
-    }
-}
-
 pub fn get_single_char() -> char {
     let c;
     enable_raw_mode().expect("failed to enable raw mode");
@@ -2913,26 +2877,6 @@ impl MachineState {
             &SystemClauseType::InstallNewBlock => {
                 self.install_new_block(temp_v!(1));
             }
-            &SystemClauseType::RawInputReadChar => {
-               let keypress = {
-                    enable_raw_mode().expect("failed to transition into raw mode");
-                   let result = next_keypress();
-                    disable_raw_mode().expect("failed to transition out of raw mode");
-
-                    result
-               };
-
-                let c = match keypress {
-                    ContinueResult::ContinueQuery => ';',
-                    ContinueResult::Conclude => '.',
-                    ContinueResult::Help => 'h',
-                    ContinueResult::PrintWithoutMaxDepth => 'w',
-                    ContinueResult::PrintWithMaxDepth => 'p',
-                };
-
-                let target = self[temp_v!(1)];
-                self.unify(Addr::Char(c), target);
-            }
             &SystemClauseType::NextEP => {
                 let first_arg = self.store(self.deref(self[temp_v!(1)]));
 
index 27bf71f5ff2b44a00e354df0294915ef3d074ac5..e7eb3b7a4e3f58ffc1d4b3bb62e9e01c56f308d2 100644 (file)
     ).
 
 '$read_input'(ThreadedGoals, NewVarList) :-
-    '$raw_input_read_char'(C),
+    '$get_single_char'(C),
     (  C == w ->
        nl,
        write('   '),
     ;  C == h ->
        '$help_message',
        '$read_input'(ThreadedGoals, NewVarList)
-    ;  C == '.',
+    ;  C == '.' ->
        nl, write(';  ...'), nl
+    ; '$read_input'(ThreadedGoals, NewVarList)
     ).
 
 '$help_message' :-