Removed $raw_input_read_char

This commit is contained in:
notoria
2020-04-18 13:54:18 +02:00
parent b35b49f7b3
commit 99e1a5f117
3 changed files with 3 additions and 61 deletions

View 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),

View 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)]));

View File

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