Skip to content

Commit

Permalink
Add display configuration flags (#46)
Browse files Browse the repository at this point in the history
* Add display configuration flags

* Fixes

* Cleanup

* Small changes
  • Loading branch information
JonasAlaif authored May 30, 2024
1 parent 7952445 commit 23741f9
Show file tree
Hide file tree
Showing 36 changed files with 2,884 additions and 549 deletions.
9 changes: 6 additions & 3 deletions axiom-profiler-GUI/assets/html/perfetto.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ table {
}

.flags-page {
height: 100%;
overflow-y: scroll;
z-index: 1;
}
.flags-content {
max-width: 100ch;
Expand All @@ -282,7 +284,7 @@ table {
background: none;
border: 1px solid rgb(218, 220, 224);
border-radius: 2px;
color: rgb(25, 103, 210);
color: var(--flags-accent-color);
font-size: 0.8125rem;
padding: 8px 12px;
cursor: pointer;
Expand All @@ -305,8 +307,8 @@ table {
.flag-widget select {
grid-area: control;
background: white;
border: 1px solid rgb(25, 103, 210);
color: rgb(25, 103, 210);
border: 1px solid var(--flags-accent-color);
color: var(--flags-accent-color);
font-size: 0.8125rem;
height: 1.625rem;
letter-spacing: 0.01em;
Expand Down Expand Up @@ -473,6 +475,7 @@ table {
--section-background: hsl(213, 26%, 87%);
--hover-background: hsl(216, 15%, 75%);
--topbar-background: hsl(215, 1%, 95%);
--flags-accent-color: rgb(10, 75, 165);
}

* {
Expand Down
58 changes: 58 additions & 0 deletions axiom-profiler-GUI/assets/html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,61 @@ mwc-dialog {
vertical-align: baseline;
padding: 2px 3px;
}

.flags-content button:disabled {
cursor: default;
opacity: 0.5;
}
.flag-widget.term-display {
display: block;
}

ul.td {
padding: 0;
margin-bottom: 6px;
}
li.td-row {
display: flex;
padding: 2px 0;
}

li .td-matcher {
flex: 1 2 auto;
margin-right: 2px;
}
li.td-row.error .td-matcher, li .td-matcher.error {
border-color: red;
}
li .td-formatter {
flex: 2 1 auto;
margin-left: 2px;
}
li.td-row.error .td-formatter, li .td-formatter.error {
border-color: red;
}
li .td-error {
width: 1.8em;
margin-left: 4px;
display: flex;
justify-content: right;
align-items: center;
}
li .td-error.error {
cursor: help;
}

li .td-matcher, li .td-formatter {
width: 100%;
padding: 3px 2px;
}
li input.td-matcher, li input.td-formatter {
background: white;
border: 1px solid var(--flags-accent-color);
color: var(--flags-accent-color);
font-size: 0.8125rem;
height: 1.625rem;
letter-spacing: 0.01em;
}
.td-buttons {
float: right;
}
80 changes: 80 additions & 0 deletions axiom-profiler-GUI/src/configuration/data.rs
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(),
}
}
}
2 changes: 2 additions & 0 deletions axiom-profiler-GUI/src/configuration/mod.rs
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::*;
Loading

0 comments on commit 23741f9

Please sign in to comment.