Removed $raw_input_read_char

This commit is contained in:
notoria
2020-04-18 13:54:18 +02:00
committed by Mark Thom
parent fb5ee5e190
commit 3f578e24b5
3 changed files with 3 additions and 61 deletions

View File

@@ -242,7 +242,6 @@ pub enum SystemClauseType {
InstallNewBlock, InstallNewBlock,
Maybe, Maybe,
QuotedToken, QuotedToken,
RawInputReadChar,
ReadTermFromChars, ReadTermFromChars,
ResetBlock, ResetBlock,
ReturnFromVerifyAttr, ReturnFromVerifyAttr,
@@ -366,7 +365,6 @@ impl SystemClauseType {
&SystemClauseType::QuotedToken => { &SystemClauseType::QuotedToken => {
clause_name!("$quoted_token") clause_name!("$quoted_token")
} }
&SystemClauseType::RawInputReadChar => clause_name!("$raw_input_read_char"),
&SystemClauseType::RedoAttrVarBinding => clause_name!("$redo_attr_var_binding"), &SystemClauseType::RedoAttrVarBinding => clause_name!("$redo_attr_var_binding"),
&SystemClauseType::RemoveCallPolicyCheck => clause_name!("$remove_call_policy_check"), &SystemClauseType::RemoveCallPolicyCheck => clause_name!("$remove_call_policy_check"),
&SystemClauseType::RemoveInferenceCounter => clause_name!("$remove_inference_counter"), &SystemClauseType::RemoveInferenceCounter => clause_name!("$remove_inference_counter"),
@@ -509,7 +507,6 @@ impl SystemClauseType {
("$get_cp", 1) => Some(SystemClauseType::GetCutPoint), ("$get_cp", 1) => Some(SystemClauseType::GetCutPoint),
("$install_new_block", 1) => Some(SystemClauseType::InstallNewBlock), ("$install_new_block", 1) => Some(SystemClauseType::InstallNewBlock),
("$quoted_token", 1) => Some(SystemClauseType::QuotedToken), ("$quoted_token", 1) => Some(SystemClauseType::QuotedToken),
("$raw_input_read_char", 1) => Some(SystemClauseType::RawInputReadChar),
("$nextEP", 3) => Some(SystemClauseType::NextEP), ("$nextEP", 3) => Some(SystemClauseType::NextEP),
("$read_query_term", 2) => Some(SystemClauseType::ReadQueryTerm), ("$read_query_term", 2) => Some(SystemClauseType::ReadQueryTerm),
("$read_term", 2) => Some(SystemClauseType::ReadTerm), ("$read_term", 2) => Some(SystemClauseType::ReadTerm),

View File

@@ -31,42 +31,6 @@ use std::rc::Rc;
use crate::crossterm::event::{read, Event, KeyCode, KeyEvent}; use crate::crossterm::event::{read, Event, KeyCode, KeyEvent};
use crate::crossterm::terminal::{enable_raw_mode, disable_raw_mode}; 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 { pub fn get_single_char() -> char {
let c; let c;
enable_raw_mode().expect("failed to enable raw mode"); enable_raw_mode().expect("failed to enable raw mode");
@@ -2913,26 +2877,6 @@ impl MachineState {
&SystemClauseType::InstallNewBlock => { &SystemClauseType::InstallNewBlock => {
self.install_new_block(temp_v!(1)); 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 => { &SystemClauseType::NextEP => {
let first_arg = self.store(self.deref(self[temp_v!(1)])); let first_arg = self.store(self.deref(self[temp_v!(1)]));

View File

@@ -146,7 +146,7 @@
). ).
'$read_input'(ThreadedGoals, NewVarList) :- '$read_input'(ThreadedGoals, NewVarList) :-
'$raw_input_read_char'(C), '$get_single_char'(C),
( C == w -> ( C == w ->
nl, nl,
write(' '), write(' '),
@@ -162,8 +162,9 @@
; C == h -> ; C == h ->
'$help_message', '$help_message',
'$read_input'(ThreadedGoals, NewVarList) '$read_input'(ThreadedGoals, NewVarList)
; C == '.', ; C == '.' ->
nl, write('; ...'), nl nl, write('; ...'), nl
; '$read_input'(ThreadedGoals, NewVarList)
). ).
'$help_message' :- '$help_message' :-