diff options
| author | Rich Kadel <richkadel@google.com> | 2020-09-08 16:08:35 -0700 |
|---|---|---|
| committer | Rich Kadel <richkadel@google.com> | 2020-09-08 17:19:38 -0700 |
| commit | c19b2370e419c0be7b46cc9ae7767773560a072c (patch) | |
| tree | 8f5fdd4b673789eb476a0877f408d9eb8a172643 /compiler/rustc_graphviz | |
| parent | 5099914a16a215794ad243df0cc7a05d91d168e0 (diff) | |
| download | rust-c19b2370e419c0be7b46cc9ae7767773560a072c.tar.gz rust-c19b2370e419c0be7b46cc9ae7767773560a072c.zip | |
Add -Zgraphviz_dark_mode
Many developers use a dark theme with editors and IDEs, but this typically doesn't extend to graphviz output. When I bring up a MIR graphviz document, the white background is strikingly bright. This new option changes the colors used for graphviz output to work better in dark-themed UIs.
Diffstat (limited to 'compiler/rustc_graphviz')
| -rw-r--r-- | compiler/rustc_graphviz/src/lib.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index 4339092b63e..252e3416865 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -599,6 +599,7 @@ pub enum RenderOption { NoNodeStyles, Monospace, + DarkTheme, } /// Returns vec holding all the default render options. @@ -630,10 +631,23 @@ where writeln!(w, "digraph {} {{", g.graph_id().as_slice())?; // Global graph properties + let mut graph_attrs = Vec::new(); + let mut content_attrs = Vec::new(); if options.contains(&RenderOption::Monospace) { - writeln!(w, r#" graph[fontname="monospace"];"#)?; - writeln!(w, r#" node[fontname="monospace"];"#)?; - writeln!(w, r#" edge[fontname="monospace"];"#)?; + let font = r#"fontname="monospace""#; + graph_attrs.push(font); + content_attrs.push(font); + }; + if options.contains(&RenderOption::DarkTheme) { + graph_attrs.push(r#"bgcolor="black""#); + content_attrs.push(r#"color="white""#); + content_attrs.push(r#"fontcolor="white""#); + } + if !(graph_attrs.is_empty() && content_attrs.is_empty()) { + writeln!(w, r#" graph[{}];"#, graph_attrs.join(" "))?; + let content_attrs_str = content_attrs.join(" "); + writeln!(w, r#" node[{}];"#, content_attrs_str)?; + writeln!(w, r#" edge[{}];"#, content_attrs_str)?; } for n in g.nodes().iter() { |
