-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add display configuration flags (#46)
* Add display configuration flags * Fixes * Cleanup * Small changes
- Loading branch information
1 parent
7952445
commit 23741f9
Showing
36 changed files
with
2,884 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use fxhash::FxHashMap; | ||
use smt_log_parser::{display_with::{DisplayConfiguration, SymbolReplacement}, formatter::TermDisplayContext}; | ||
|
||
use crate::state::FileInfo; | ||
|
||
use super::ConfigurationProvider; | ||
|
||
impl ConfigurationProvider { | ||
pub fn reset(&self) { | ||
self.update.reset(); | ||
} | ||
pub fn update_display(&self, f: impl FnOnce(&mut DisplayConfiguration) -> bool + 'static) { | ||
self.update.update(|cfg| f(&mut cfg.display)); | ||
} | ||
pub fn update_term_display(&self, file: Option<FileInfo>, new: TermDisplayContext) { | ||
self.update.update(move |cfg| { | ||
if let Some(file) = file { | ||
if new.is_empty() { | ||
cfg.term_display.per_file.remove(&file.name).is_some() | ||
} else { | ||
let is_same = cfg.term_display.per_file.get(&file.name).is_some_and(|old| old == &new); | ||
if !is_same { | ||
cfg.term_display.per_file.insert(file.name, new); | ||
} | ||
!is_same | ||
} | ||
} else { | ||
let is_same = cfg.term_display.general == new; | ||
if !is_same { | ||
cfg.term_display.general = new; | ||
} | ||
!is_same | ||
} | ||
}); | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] | ||
pub struct Configuration { | ||
pub display: DisplayConfiguration, | ||
pub term_display: TermDisplayContextFiles, | ||
} | ||
impl Configuration { | ||
pub const fn default_display() -> DisplayConfiguration { | ||
DisplayConfiguration { | ||
display_term_ids: false, | ||
display_quantifier_name: false, | ||
replace_symbols: SymbolReplacement::Code, | ||
html: true, | ||
// Set manually elsewhere | ||
enode_char_limit: None, | ||
ast_depth_limit: None, | ||
} | ||
} | ||
} | ||
|
||
impl Default for Configuration { | ||
fn default() -> Self { | ||
Self { | ||
display: Self::default_display(), | ||
term_display: TermDisplayContextFiles::default(), | ||
} | ||
} | ||
} | ||
|
||
/// A grouping of general TermDisplayContext and per file ones. | ||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] | ||
pub struct TermDisplayContextFiles { | ||
pub general: TermDisplayContext, | ||
pub per_file: FxHashMap<String, TermDisplayContext>, | ||
} | ||
|
||
impl Default for TermDisplayContextFiles { | ||
fn default() -> Self { | ||
Self { | ||
general: TermDisplayContext::basic(), | ||
per_file: FxHashMap::default(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
mod provider; | ||
mod page; | ||
mod data; | ||
|
||
pub use provider::*; | ||
pub use page::*; | ||
pub use data::*; |
Oops, something went wrong.