aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--book/src/themes.md3
-rw-r--r--helix-dap/src/client.rs6
-rw-r--r--helix-term/src/ui/editor.rs52
-rw-r--r--helix-view/src/editor.rs7
-rw-r--r--helix-view/src/gutter.rs60
-rw-r--r--runtime/themes/acme.toml2
-rw-r--r--runtime/themes/autumn.toml2
-rw-r--r--runtime/themes/ayu_dark.toml2
-rw-r--r--runtime/themes/ayu_light.toml2
-rw-r--r--runtime/themes/ayu_mirage.toml2
-rw-r--r--runtime/themes/dracula.toml2
-rw-r--r--runtime/themes/dracula_at_night.toml2
-rw-r--r--runtime/themes/onedark.toml3
-rw-r--r--runtime/themes/onedarker.toml2
-rw-r--r--theme.toml4
15 files changed, 98 insertions, 53 deletions
diff --git a/book/src/themes.md b/book/src/themes.md
index 7accb67f..56d0372c 100644
--- a/book/src/themes.md
+++ b/book/src/themes.md
@@ -278,8 +278,11 @@ These scopes are used for theming the editor interface:
| `ui.cursor.primary.normal` | |
| `ui.cursor.primary.insert` | |
| `ui.cursor.primary.select` | |
+| `ui.debug.breakpoint` | Breakpoint indicator, found in the gutter |
+| `ui.debug.active` | Indicator for the line at which debugging execution is paused at, found in the gutter |
| `ui.gutter` | Gutter |
| `ui.gutter.selected` | Gutter for the line the cursor is on |
+| `ui.highlight.frameline` | Line at which debugging execution is paused at |
| `ui.linenr` | Line numbers |
| `ui.linenr.selected` | Line number for the line the cursor is on |
| `ui.statusline` | Statusline |
diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs
index ff727d00..7efb72d8 100644
--- a/helix-dap/src/client.rs
+++ b/helix-dap/src/client.rs
@@ -512,4 +512,10 @@ impl Client {
self.call::<requests::SetExceptionBreakpoints>(args)
}
+
+ pub fn current_stack_frame(&self) -> Option<&StackFrame> {
+ self.stack_frames
+ .get(&self.thread_id?)?
+ .get(self.active_frame?)
+ }
}
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 4cac0fa8..d4b141a0 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -93,40 +93,6 @@ impl EditorView {
let mut line_decorations: Vec<Box<dyn LineDecoration>> = Vec::new();
let mut translated_positions: Vec<TranslatedPosition> = Vec::new();
- // DAP: Highlight current stack frame position
- let stack_frame = editor.debugger.as_ref().and_then(|debugger| {
- if let (Some(frame), Some(thread_id)) = (debugger.active_frame, debugger.thread_id) {
- debugger
- .stack_frames
- .get(&thread_id)
- .and_then(|bt| bt.get(frame))
- } else {
- None
- }
- });
- if let Some(frame) = stack_frame {
- if doc.path().is_some()
- && frame
- .source
- .as_ref()
- .and_then(|source| source.path.as_ref())
- == doc.path()
- {
- let line = frame.line - 1; // convert to 0-indexing
- let style = theme.get("ui.highlight");
- let line_decoration = move |renderer: &mut TextRenderer, pos: LinePos| {
- if pos.doc_line != line {
- return;
- }
- renderer
- .surface
- .set_style(Rect::new(area.x, pos.visual_line, area.width, 1), style);
- };
-
- line_decorations.push(Box::new(line_decoration));
- }
- }
-
if is_focused && config.cursorline {
line_decorations.push(Self::cursorline_decorator(doc, view, theme))
}
@@ -135,6 +101,23 @@ impl EditorView {
Self::highlight_cursorcolumn(doc, view, surface, theme, inner, &text_annotations);
}
+ // Set DAP highlights, if needed.
+ if let Some(frame) = editor.current_stack_frame() {
+ let dap_line = frame.line.saturating_sub(1) as usize;
+ let style = theme.get("ui.highlight.frameline");
+ let line_decoration = move |renderer: &mut TextRenderer, pos: LinePos| {
+ if pos.doc_line != dap_line {
+ return;
+ }
+ renderer.surface.set_style(
+ Rect::new(inner.x, inner.y + pos.visual_line, inner.width, 1),
+ style,
+ );
+ };
+
+ line_decorations.push(Box::new(line_decoration));
+ }
+
let mut highlights =
Self::doc_syntax_highlights(doc, view.offset.anchor, inner.height, theme);
let overlay_highlights = Self::overlay_syntax_highlights(
@@ -422,6 +405,7 @@ impl EditorView {
let primary_selection_scope = theme
.find_scope_index_exact("ui.selection.primary")
.unwrap_or(selection_scope);
+
let base_cursor_scope = theme
.find_scope_index_exact("ui.cursor")
.unwrap_or(selection_scope);
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index ee535b5c..c939aa5c 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -10,6 +10,7 @@ use crate::{
view::ViewPosition,
Align, Document, DocumentId, View, ViewId,
};
+use dap::StackFrame;
use helix_vcs::DiffProviderRegistry;
use futures_util::stream::select_all::SelectAll;
@@ -1652,6 +1653,12 @@ impl Editor {
doc.restore_cursor = false;
}
}
+
+ pub fn current_stack_frame(&self) -> Option<&StackFrame> {
+ self.debugger
+ .as_ref()
+ .and_then(|debugger| debugger.current_stack_frame())
+ }
}
fn try_restore_indent(doc: &mut Document, view: &mut View) {
diff --git a/helix-view/src/gutter.rs b/helix-view/src/gutter.rs
index 36e8e16a..3ecae919 100644
--- a/helix-view/src/gutter.rs
+++ b/helix-view/src/gutter.rs
@@ -2,7 +2,7 @@ use std::fmt::Write;
use crate::{
editor::GutterType,
- graphics::{Color, Style, UnderlineStyle},
+ graphics::{Style, UnderlineStyle},
Document, Editor, Theme, View,
};
@@ -245,9 +245,9 @@ pub fn breakpoints<'doc>(
theme: &Theme,
_is_focused: bool,
) -> GutterFn<'doc> {
- let warning = theme.get("warning");
let error = theme.get("error");
let info = theme.get("info");
+ let breakpoint_style = theme.get("ui.debug.breakpoint");
let breakpoints = doc.path().and_then(|path| editor.breakpoints.get(path));
@@ -265,30 +265,52 @@ pub fn breakpoints<'doc>(
.iter()
.find(|breakpoint| breakpoint.line == line)?;
- let mut style = if breakpoint.condition.is_some() && breakpoint.log_message.is_some() {
+ let style = if breakpoint.condition.is_some() && breakpoint.log_message.is_some() {
error.underline_style(UnderlineStyle::Line)
} else if breakpoint.condition.is_some() {
error
} else if breakpoint.log_message.is_some() {
info
} else {
- warning
+ breakpoint_style
};
- if !breakpoint.verified {
- // Faded colors
- style = if let Some(Color::Rgb(r, g, b)) = style.fg {
- style.fg(Color::Rgb(
- ((r as f32) * 0.4).floor() as u8,
- ((g as f32) * 0.4).floor() as u8,
- ((b as f32) * 0.4).floor() as u8,
- ))
- } else {
- style.fg(Color::Gray)
- }
- };
+ let sym = if breakpoint.verified { "●" } else { "◯" };
+ write!(out, "{}", sym).unwrap();
+ Some(style)
+ },
+ )
+}
+
+fn execution_pause_indicator<'doc>(
+ editor: &'doc Editor,
+ doc: &'doc Document,
+ theme: &Theme,
+ is_focused: bool,
+) -> GutterFn<'doc> {
+ let style = theme.get("ui.debug.active");
+ let current_stack_frame = editor.current_stack_frame();
+ let frame_line = current_stack_frame.map(|frame| frame.line - 1);
+ let frame_source_path = current_stack_frame.map(|frame| {
+ frame
+ .source
+ .as_ref()
+ .and_then(|source| source.path.as_ref())
+ });
+ let should_display_for_current_doc =
+ doc.path().is_some() && frame_source_path.unwrap_or(None) == doc.path();
+
+ Box::new(
+ move |line: usize, _selected: bool, first_visual_line: bool, out: &mut String| {
+ if !first_visual_line
+ || !is_focused
+ || line != frame_line?
+ || !should_display_for_current_doc
+ {
+ return None;
+ }
- let sym = if breakpoint.verified { "▲" } else { "⊚" };
+ let sym = "▶";
write!(out, "{}", sym).unwrap();
Some(style)
},
@@ -304,9 +326,11 @@ pub fn diagnostics_or_breakpoints<'doc>(
) -> GutterFn<'doc> {
let mut diagnostics = diagnostic(editor, doc, view, theme, is_focused);
let mut breakpoints = breakpoints(editor, doc, view, theme, is_focused);
+ let mut execution_pause_indicator = execution_pause_indicator(editor, doc, theme, is_focused);
Box::new(move |line, selected, first_visual_line: bool, out| {
- breakpoints(line, selected, first_visual_line, out)
+ execution_pause_indicator(line, selected, first_visual_line, out)
+ .or_else(|| breakpoints(line, selected, first_visual_line, out))
.or_else(|| diagnostics(line, selected, first_visual_line, out))
})
}
diff --git a/runtime/themes/acme.toml b/runtime/themes/acme.toml
index e1d66ff8..65092474 100644
--- a/runtime/themes/acme.toml
+++ b/runtime/themes/acme.toml
@@ -12,6 +12,8 @@
"ui.virtual.ruler" = { bg = "acme_bar_bg" }
"ui.cursor.match" = {bg="acme_bar_bg"}
"ui.cursor" = {bg="cursor", fg="white"}
+"ui.debug" = {fg="orange"}
+"ui.highlight.frameline" = {bg="#da8581"}
"string" = "red"
"comment" = "green"
"ui.help" = {fg="black", bg="acme_bg"}
diff --git a/runtime/themes/autumn.toml b/runtime/themes/autumn.toml
index 1430e0a8..4474b0d4 100644
--- a/runtime/themes/autumn.toml
+++ b/runtime/themes/autumn.toml
@@ -26,6 +26,8 @@
"ui.cursor.primary" = { fg = "my_white", modifiers = ["reversed"] }
"ui.cursorline.primary" = { bg = "my_black" }
"ui.cursorline.secondary" = { bg = "my_black" }
+"ui.highlight.frameline" = { bg = "#8b6904" }
+"ui.debug" = { fg = "my_yellow1", bg = "my_gray0" }
"ui.text" = "my_white"
"operator" = "my_white"
"ui.text.focus" = "my_white"
diff --git a/runtime/themes/ayu_dark.toml b/runtime/themes/ayu_dark.toml
index 37060a24..211d423f 100644
--- a/runtime/themes/ayu_dark.toml
+++ b/runtime/themes/ayu_dark.toml
@@ -61,6 +61,8 @@
"diagnostic.error"= { underline = { color = "red", style="curl"} }
"ui.bufferline" = { fg = "gray", bg = "background" }
"ui.bufferline.active" = { fg = "foreground", bg = "dark_gray" }
+"ui.debug" = { fg = "orange", bg = "background" }
+"ui.highlight.frameline" = { bg = "#0067a3" }
"special" = "orange"
diff --git a/runtime/themes/ayu_light.toml b/runtime/themes/ayu_light.toml
index 58b25484..4b0ba1db 100644
--- a/runtime/themes/ayu_light.toml
+++ b/runtime/themes/ayu_light.toml
@@ -61,6 +61,8 @@
"diagnostic.error"= { underline = { color = "red", style = "curl" } }
"ui.bufferline" = { fg = "gray", bg = "background" }
"ui.bufferline.active" = { fg = "foreground", bg = "dark_gray" }
+"ui.debug" = { fg = "orange", bg = "background" }
+"ui.highlight.frameline" = { bg = "#cfe0f2" }
"special" = "orange"
diff --git a/runtime/themes/ayu_mirage.toml b/runtime/themes/ayu_mirage.toml
index 4c1f8fa6..5afe0acd 100644
--- a/runtime/themes/ayu_mirage.toml
+++ b/runtime/themes/ayu_mirage.toml
@@ -61,6 +61,8 @@
"diagnostic.error"= { underline = { color = "red", style = "curl" } }
"ui.bufferline" = { fg = "gray", bg = "background" }
"ui.bufferline.active" = { fg = "foreground", bg = "dark_gray" }
+"ui.debug" = { fg = "orange", bg = "background" }
+"ui.highlight.frameline" = { bg = "#0067a3" }
"special" = "orange"
diff --git a/runtime/themes/dracula.toml b/runtime/themes/dracula.toml
index 8bde4708..b08357db 100644
--- a/runtime/themes/dracula.toml
+++ b/runtime/themes/dracula.toml
@@ -25,6 +25,8 @@
"ui.cursor.primary" = { fg = "background", bg = "cyan", modifiers = ["dim"] }
"ui.cursorline.primary" = { bg = "background_dark" }
"ui.help" = { fg = "foreground", bg = "background_dark" }
+"ui.debug" = { fg = "red" }
+"ui.highlight.frameline" = { fg = "black", bg = "red" }
"ui.linenr" = { fg = "comment" }
"ui.linenr.selected" = { fg = "foreground" }
"ui.menu" = { fg = "foreground", bg = "background_dark" }
diff --git a/runtime/themes/dracula_at_night.toml b/runtime/themes/dracula_at_night.toml
index 9f10ec90..b2e3b9a9 100644
--- a/runtime/themes/dracula_at_night.toml
+++ b/runtime/themes/dracula_at_night.toml
@@ -25,6 +25,8 @@
"ui.cursor.match" = { fg = "green", modifiers = ["underlined"] }
"ui.cursor.primary" = { fg = "background", bg = "cyan", modifiers = ["dim"] }
"ui.help" = { fg = "foreground", bg = "background_dark" }
+"ui.debug" = { fg = "red" }
+"ui.highlight.frameline" = { fg = "black", bg = "red" }
"ui.linenr" = { fg = "comment" }
"ui.linenr.selected" = { fg = "foreground" }
"ui.menu" = { fg = "foreground", bg = "background_dark" }
diff --git a/runtime/themes/onedark.toml b/runtime/themes/onedark.toml
index 81ca0463..6df5f797 100644
--- a/runtime/themes/onedark.toml
+++ b/runtime/themes/onedark.toml
@@ -64,6 +64,7 @@
"ui.cursorline.primary" = { bg = "light-black" }
"ui.highlight" = { bg = "gray" }
+"ui.highlight.frameline" = { bg = "#97202a" }
"ui.linenr" = { fg = "linenr" }
"ui.linenr.selected" = { fg = "white" }
@@ -84,6 +85,8 @@
"ui.menu.selected" = { fg = "black", bg = "blue" }
"ui.menu.scroll" = { fg = "white", bg = "light-gray" }
+"ui.debug" = { fg = "red" }
+
[palette]
yellow = "#E5C07B"
diff --git a/runtime/themes/onedarker.toml b/runtime/themes/onedarker.toml
index 33f900cc..7169fd02 100644
--- a/runtime/themes/onedarker.toml
+++ b/runtime/themes/onedarker.toml
@@ -78,6 +78,8 @@
"ui.text.focus" = { fg = "white", bg = "light-black", modifiers = ["bold"] }
"ui.help" = { fg = "white", bg = "gray" }
+"ui.debug" = { fg = "red" }
+"ui.highlight.frameline" = { bg = "#97202a" }
"ui.popup" = { bg = "gray" }
"ui.window" = { fg = "gray" }
"ui.menu" = { fg = "white", bg = "gray" }
diff --git a/theme.toml b/theme.toml
index b67eaecc..dd1a5d88 100644
--- a/theme.toml
+++ b/theme.toml
@@ -69,7 +69,9 @@ label = "honey"
"ui.cursor" = { modifiers = ["reversed"] }
"ui.cursorline.primary" = { bg = "bossanova" }
"ui.highlight" = { bg = "bossanova" }
-
+"ui.highlight.frameline" = { bg = "#634450" }
+"ui.debug" = { fg = "#634450" }
+"ui.debug.breakpoint" = { fg = "apricot" }
"ui.menu" = { fg = "lavender", bg = "revolver" }
"ui.menu.selected" = { fg = "revolver", bg = "white" }
"ui.menu.scroll" = { fg = "lavender", bg = "comet" }