aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-12-09 02:28:53 +0000
committerBlaž Hrastnik2021-12-09 02:28:53 +0000
commitdf3b88387b311e16b3af3771c3870b2ea0235c95 (patch)
treec6096da01150ede81dc652eb4458f2a6319861ea /helix-term/src/commands
parentdac317e620f227611e8c572125b0572ece4043c4 (diff)
dap: Improve variables UI
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/dap.rs31
1 files changed, 25 insertions, 6 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index c556f214..8935bc9c 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -619,22 +619,41 @@ pub fn dap_variables(cx: &mut Context) {
// TODO: group by scope
// TODO: ui::Text to use tui::text + styled builder
+ // let contents = tui::text::Text::new();
+
+ let theme = &cx.editor.theme;
+ let scope_style = theme.get("ui.linenr.selected");
+ let type_style = theme.get("ui.text");
+ let text_style = theme.get("ui.text.focus");
+
for scope in scopes.iter() {
+ // use helix_view::graphics::Style;
+ use tui::text::{Span, Spans};
let response = block_on(debugger.variables(scope.variables_reference));
+ variables.push(Spans::from(Span::styled(
+ format!("▸ {}", scope.name),
+ scope_style,
+ )));
+
if let Ok(vars) = response {
variables.reserve(vars.len());
for var in vars {
- let prefix = match var.ty {
- Some(data_type) => format!("{} ", data_type),
- None => "".to_owned(),
- };
- variables.push(format!("{}{} = {}", prefix, var.name, var.value));
+ let mut spans = Vec::with_capacity(5);
+
+ spans.push(Span::styled(var.name.to_owned(), text_style));
+ if let Some(ty) = var.ty {
+ spans.push(Span::raw(": "));
+ spans.push(Span::styled(ty.to_owned(), type_style));
+ }
+ spans.push(Span::raw(" = "));
+ spans.push(Span::styled(var.value.to_owned(), text_style));
+ variables.push(Spans::from(spans));
}
}
}
- let contents = Text::new(variables.join("\n"));
+ let contents = Text::from(tui::text::Text::from(variables));
let popup = Popup::new(contents);
cx.push_layer(Box::new(popup));
}