-
Notifications
You must be signed in to change notification settings - Fork 9
Proof highlighting #204
base: main
Are you sure you want to change the base?
Proof highlighting #204
Conversation
Literals will be the same colour as the user's terminal's directories.
Thanks, @sudoPom! @thevirtuoso1973, can you please review it? |
As I remember, star dependencies are not allowed if we want to publish our library on crates.io: |
Will do! |
* Ansi term version * Itertools re added (whoops)
modus-lib/src/sld.rs
Outdated
fn get_color(color_of: &str) -> ansi_term::Style{ | ||
let colors = LsColors::from_env().unwrap_or_default(); | ||
let mut style: std::option::Option<&lscolors::Style>; | ||
match color_of{ | ||
"Directory" => style = colors.style_for_indicator(lscolors::Indicator::Directory), | ||
"Normal" => style = colors.style_for_indicator(lscolors::Indicator::Normal), | ||
_ => panic!("The only used LSColours are 'Directory' and 'Normal'") | ||
}; | ||
style.map(Style::to_ansi_term_style).unwrap_or_default() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a nice place to define a mapping from nodes to colors.
But for now, I suggest changing the match to something like
"ImagePred" => blah blah directory...
_ => blah blah normal...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we probably don't need to unwrap/panic over a missing color env, so pick some default if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I'll add this soon :)
I like the idea of using directory color. Also generally use |
/// Returns a normalized version of a resolution error --- should be better for hash equality. | ||
/// Without this, may get a lot of resolution errors, for example, that are identical except for a different | ||
/// auxiliary variable index. | ||
fn normalize(self) -> ResolutionError { | ||
match self { | ||
ResolutionError::UnknownPredicate(l) => { | ||
ResolutionError::UnknownPredicate(l.normalized_terms()) | ||
} | ||
ResolutionError::InsufficientGroundness(ls) => ResolutionError::InsufficientGroundness( | ||
ls.into_iter().map(|x| x.normalized_terms()).collect(), | ||
), | ||
ResolutionError::MaximumDepthExceeded(ls, s) => ResolutionError::MaximumDepthExceeded( | ||
ls.into_iter().map(|x| x.normalized_terms()).collect(), | ||
s, | ||
), | ||
ResolutionError::BuiltinFailure(l, s) => { | ||
ResolutionError::BuiltinFailure(l.normalized_terms(), s) | ||
} | ||
ResolutionError::InsufficientRules(l) => { | ||
ResolutionError::InsufficientRules(l.normalized_terms()) | ||
} | ||
ResolutionError::InconsistentGroundnessSignature(sigs) => { | ||
ResolutionError::InconsistentGroundnessSignature(sigs.to_vec()) | ||
} | ||
ResolutionError::NegationProof(l) => { | ||
ResolutionError::NegationProof(l.normalized_terms()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, you're probably aware but this (and another change) shouldn't be removed
Proofs produced by the
modus proof
command will now contain literals that are coloured the same way that the user's terminal colours directories, so it is guaranteed to be easily visible to the user. This PR should close #185 .Before fix:
After fix: