use max_depth at toplevel, allowing full printing of terms with the 'w' keypress (#287), put disjunctions on new lines (#278)
This commit is contained in:
@@ -842,7 +842,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
return iter.next();
|
return iter.next();
|
||||||
} else {
|
} else {
|
||||||
iter.stack().pop();
|
iter.stack().pop();
|
||||||
|
|
||||||
push_space_if_amb!(self, &var, {
|
push_space_if_amb!(self, &var, {
|
||||||
self.append_str(&var);
|
self.append_str(&var);
|
||||||
});
|
});
|
||||||
@@ -1192,11 +1192,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
let cell = Rc::new(Cell::new((true, 0)));
|
let cell = Rc::new(Cell::new((true, 0)));
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::CloseList(cell.clone()));
|
self.state_stack.push(TokenOrRedirect::CloseList(cell.clone()));
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::Atom(clause_name!("...")));
|
self.state_stack.push(TokenOrRedirect::Atom(clause_name!("...")));
|
||||||
self.state_stack.push(TokenOrRedirect::HeadTailSeparator); // bar
|
|
||||||
self.state_stack.push(TokenOrRedirect::Atom(clause_name!("...")));
|
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::OpenList(cell));
|
self.state_stack.push(TokenOrRedirect::OpenList(cell));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ use crate::crossterm::terminal::{enable_raw_mode, disable_raw_mode};
|
|||||||
pub enum ContinueResult {
|
pub enum ContinueResult {
|
||||||
ContinueQuery,
|
ContinueQuery,
|
||||||
Conclude,
|
Conclude,
|
||||||
|
PrintWithoutMaxDepth,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_keypress() -> ContinueResult {
|
pub fn next_keypress() -> ContinueResult {
|
||||||
@@ -40,6 +41,9 @@ pub fn next_keypress() -> ContinueResult {
|
|||||||
match read() {
|
match read() {
|
||||||
Ok(Event::Key(KeyEvent { code, .. })) => {
|
Ok(Event::Key(KeyEvent { code, .. })) => {
|
||||||
match code {
|
match code {
|
||||||
|
KeyCode::Char('w') => {
|
||||||
|
return ContinueResult::PrintWithoutMaxDepth;
|
||||||
|
}
|
||||||
KeyCode::Char(' ') | KeyCode::Char(';') | KeyCode::Char('n') => {
|
KeyCode::Char(' ') | KeyCode::Char(';') | KeyCode::Char('n') => {
|
||||||
return ContinueResult::ContinueQuery;
|
return ContinueResult::ContinueQuery;
|
||||||
}
|
}
|
||||||
@@ -2342,7 +2346,8 @@ impl MachineState {
|
|||||||
|
|
||||||
let c = match keypress {
|
let c = match keypress {
|
||||||
ContinueResult::ContinueQuery => ';',
|
ContinueResult::ContinueQuery => ';',
|
||||||
ContinueResult::Conclude => '.'
|
ContinueResult::Conclude => '.',
|
||||||
|
ContinueResult::PrintWithoutMaxDepth => 'w',
|
||||||
};
|
};
|
||||||
|
|
||||||
let target = self[temp_v!(1)].clone();
|
let target = self[temp_v!(1)].clone();
|
||||||
@@ -2667,7 +2672,7 @@ impl MachineState {
|
|||||||
let ignore_ops = self.store(self.deref(self[temp_v!(2)].clone()));
|
let ignore_ops = self.store(self.deref(self[temp_v!(2)].clone()));
|
||||||
let numbervars = self.store(self.deref(self[temp_v!(3)].clone()));
|
let numbervars = self.store(self.deref(self[temp_v!(3)].clone()));
|
||||||
let quoted = self.store(self.deref(self[temp_v!(4)].clone()));
|
let quoted = self.store(self.deref(self[temp_v!(4)].clone()));
|
||||||
let max_depth = self.store(self.deref(self[temp_v!(6)].clone()));
|
let max_depth = self.store(self.deref(self[temp_v!(6)].clone()));
|
||||||
|
|
||||||
let mut printer = HCPrinter::new(&self, &indices.op_dir, PrinterOutputter::new());
|
let mut printer = HCPrinter::new(&self, &indices.op_dir, PrinterOutputter::new());
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
( expand_goals(Term0, Term) -> true
|
( expand_goals(Term0, Term) -> true
|
||||||
; Term0 = Term
|
; Term0 = Term
|
||||||
),
|
),
|
||||||
( '$get_b_value'(B), call(Term), '$write_eqs_and_read_input'(B, VarList),
|
( '$get_b_value'(B), write(' '), call(Term), '$write_eqs_and_read_input'(B, VarList),
|
||||||
!
|
!
|
||||||
% clear attribute goal lists, which may be populated by
|
% clear attribute goal lists, which may be populated by
|
||||||
% copy_term/3 prior to failure.
|
% copy_term/3 prior to failure.
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
; VarName = VarName0,
|
; VarName = VarName0,
|
||||||
N1 is N + 1
|
N1 is N + 1
|
||||||
).
|
).
|
||||||
|
|
||||||
'$extend_var_list'(Value, VarList, NewVarList) :-
|
'$extend_var_list'(Value, VarList, NewVarList) :-
|
||||||
term_variables(Value, Vars),
|
term_variables(Value, Vars),
|
||||||
'$extend_var_list_'(Vars, 0, VarList, NewVarList).
|
'$extend_var_list_'(Vars, 0, VarList, NewVarList).
|
||||||
@@ -108,30 +108,30 @@
|
|||||||
'$extend_var_list_'(Vs, N1, VarList, NewVarList0)
|
'$extend_var_list_'(Vs, N1, VarList, NewVarList0)
|
||||||
).
|
).
|
||||||
|
|
||||||
'$write_goal'(G, VarList) :-
|
'$write_goal'(G, VarList, MaxDepth) :-
|
||||||
( G = (Var = Value) ->
|
( G = (Var = Value) ->
|
||||||
write(Var),
|
write(Var),
|
||||||
write(' = '),
|
write(' = '),
|
||||||
( '$needs_bracketing'(Value, (=)) ->
|
( '$needs_bracketing'(Value, (=)) ->
|
||||||
write('('),
|
write('('),
|
||||||
write_term(Value, [quoted(true), variable_names(VarList), max_depth(0)]),
|
write_term(Value, [quoted(true), variable_names(VarList), max_depth(MaxDepth)]),
|
||||||
write(')')
|
write(')')
|
||||||
; write_term(Value, [quoted(true), variable_names(VarList), max_depth(0)])
|
; write_term(Value, [quoted(true), variable_names(VarList), max_depth(MaxDepth)])
|
||||||
)
|
)
|
||||||
; G == [] ->
|
; G == [] ->
|
||||||
write('true')
|
write('true')
|
||||||
; write_term(G, [quoted(true), variable_names(VarList)])
|
; write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth)])
|
||||||
).
|
).
|
||||||
|
|
||||||
'$write_last_goal'(G, VarList) :-
|
'$write_last_goal'(G, VarList, MaxDepth) :-
|
||||||
( G = (Var = Value) ->
|
( G = (Var = Value) ->
|
||||||
write(Var),
|
write(Var),
|
||||||
write(' = '),
|
write(' = '),
|
||||||
( '$needs_bracketing'(Value, (=)) ->
|
( '$needs_bracketing'(Value, (=)) ->
|
||||||
write('('),
|
write('('),
|
||||||
write_term(Value, [quoted(true), variable_names(VarList), max_depth(0)]),
|
write_term(Value, [quoted(true), variable_names(VarList), max_depth(MaxDepth)]),
|
||||||
write(')')
|
write(')')
|
||||||
; write_term(Value, [quoted(true), variable_names(VarList), max_depth(0)]),
|
; write_term(Value, [quoted(true), variable_names(VarList), max_depth(MaxDepth)]),
|
||||||
( '$trailing_period_is_ambiguous'(Value) ->
|
( '$trailing_period_is_ambiguous'(Value) ->
|
||||||
write(' ')
|
write(' ')
|
||||||
; true
|
; true
|
||||||
@@ -139,16 +139,16 @@
|
|||||||
)
|
)
|
||||||
; G == [] ->
|
; G == [] ->
|
||||||
write('true')
|
write('true')
|
||||||
; write_term(G, [quoted(true), variable_names(VarList), max_depth(0)])
|
; write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth)])
|
||||||
).
|
).
|
||||||
|
|
||||||
'$write_eq'((G1, G2), VarList) :-
|
'$write_eq'((G1, G2), VarList, MaxDepth) :-
|
||||||
!,
|
!,
|
||||||
'$write_goal'(G1, VarList),
|
'$write_goal'(G1, VarList, MaxDepth),
|
||||||
write(', '),
|
write(', '),
|
||||||
'$write_eq'(G2, VarList).
|
'$write_eq'(G2, VarList, MaxDepth).
|
||||||
'$write_eq'(G, VarList) :-
|
'$write_eq'(G, VarList, MaxDepth) :-
|
||||||
'$write_last_goal'(G, VarList).
|
'$write_last_goal'(G, VarList, MaxDepth).
|
||||||
|
|
||||||
'$graphic_token_char'(C) :-
|
'$graphic_token_char'(C) :-
|
||||||
memberchk(C, ['#', '$', '&', '*', '+', '-', '.', ('/'), ':',
|
memberchk(C, ['#', '$', '&', '*', '+', '-', '.', ('/'), ':',
|
||||||
@@ -173,18 +173,26 @@
|
|||||||
( Goals == [] ->
|
( Goals == [] ->
|
||||||
write('true.'), nl
|
write('true.'), nl
|
||||||
; thread_goals(Goals, ThreadedGoals, (',')),
|
; thread_goals(Goals, ThreadedGoals, (',')),
|
||||||
'$write_eq'(ThreadedGoals, NewVarList),
|
'$write_eq'(ThreadedGoals, NewVarList, 20),
|
||||||
write('.'),
|
write('.'),
|
||||||
nl
|
nl
|
||||||
)
|
)
|
||||||
; thread_goals(Goals, ThreadedGoals, (',')),
|
; thread_goals(Goals, ThreadedGoals, (',')),
|
||||||
'$write_eq'(ThreadedGoals, NewVarList),
|
'$write_eq'(ThreadedGoals, NewVarList, 20),
|
||||||
'$raw_input_read_char'(C),
|
'$read_input'(ThreadedGoals, NewVarList)
|
||||||
( C == (';'), !,
|
).
|
||||||
write(' ;'), nl, false
|
|
||||||
; C == ('.'), !,
|
'$read_input'(ThreadedGoals, NewVarList) :-
|
||||||
write(' ...'), nl
|
'$raw_input_read_char'(C),
|
||||||
)
|
( C == ('w'), !,
|
||||||
|
nl,
|
||||||
|
write(' '),
|
||||||
|
'$write_eq'(ThreadedGoals, NewVarList, 0),
|
||||||
|
'$read_input'(ThreadedGoals, NewVarList)
|
||||||
|
; C == (';'), !,
|
||||||
|
nl, write('; '), false
|
||||||
|
; C == ('.'), !,
|
||||||
|
nl, write(' ...'), nl
|
||||||
).
|
).
|
||||||
|
|
||||||
'$gather_query_vars'([_ = Var | Vars], QueryVars) :-
|
'$gather_query_vars'([_ = Var | Vars], QueryVars) :-
|
||||||
|
|||||||
Reference in New Issue
Block a user