InstallNewBlock,
Maybe,
QuotedToken,
- RawInputReadChar,
ReadTermFromChars,
ResetBlock,
ReturnFromVerifyAttr,
&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"),
("$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),
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");
&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)]));