]> Repositorios git - scryer-prolog.git/commitdiff
support 'h' to print help message during toplevel interaction
authorMarkus Triska <[email protected]>
Sun, 15 Mar 2020 12:24:28 +0000 (13:24 +0100)
committerMarkus Triska <[email protected]>
Sun, 15 Mar 2020 12:42:51 +0000 (13:42 +0100)
src/prolog/machine/system_calls.rs
src/prolog/toplevel.pl

index 9e4262279754995c3c128bc97af1a45b6b483371..03ec8311d9bab552c2894fc92c77879acb178e71 100644 (file)
@@ -33,6 +33,7 @@ use crate::crossterm::terminal::{enable_raw_mode, disable_raw_mode};
 pub enum ContinueResult {
     ContinueQuery,
     Conclude,
+    Help,
     PrintWithoutMaxDepth,
     PrintWithMaxDepth
 }
@@ -54,6 +55,9 @@ pub fn next_keypress() -> ContinueResult {
                     KeyCode::Char('.') => {
                         return ContinueResult::Conclude;
                     }
+                    KeyCode::Char('h') => {
+                        return ContinueResult::Help;
+                    }
                     _ => {}
                 }
             }
@@ -2351,6 +2355,7 @@ impl MachineState {
                 let c = match keypress {
                     ContinueResult::ContinueQuery => ';',
                     ContinueResult::Conclude => '.',
+                    ContinueResult::Help => 'h',
                     ContinueResult::PrintWithoutMaxDepth => 'w',
                     ContinueResult::PrintWithMaxDepth => 'p',
                 };
index be7b255acb81693ffd8cbecf017ea8da4a63e34c..3abadd7cf278b3d352fff080ffdc6e708ac2fef8 100644 (file)
        '$read_input'(ThreadedGoals, NewVarList)
     ;  C == (';') ->
        nl, write(';  '), false
+    ;  C == h ->
+       '$help_message',
+       '$read_input'(ThreadedGoals, NewVarList)
     ;  C == '.',
        nl, write('   ...'), nl
     ).
 
+'$help_message' :-
+    nl, nl,
+    write('SPACE, "n" or ";": next solution, if any\n'),
+    write('".": stop enumeration\n'),
+    write('"h": display this help message\n'),
+    write('"w": write terms without depth limit\n'),
+    write('"p": print terms with depth limit\n\n').
+
 '$gather_query_vars'([_ = Var | Vars], QueryVars) :-
     (  var(Var) ->
        QueryVars = [Var | QueryVars1],