summaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
authorGokul Soumya2021-06-14 14:01:17 +0000
committerBlaž Hrastnik2021-06-16 06:00:14 +0000
commitd1c8a74771b241ee0824853bd5e8229cb0ab4187 (patch)
tree583f5e890713384295c82930a1f531cf1a6693af /helix-term/src/ui/editor.rs
parent33a35b7589dbc35f43f8823b79591ca857bceeac (diff)
Add theme key for selected line number
Adds `ui.linenr.selected` which controls highlight of linu numbes which have cursors on. - Fallback to linenr if linenr.selected is missing - Update docs and themes - Add TODOs for themes with temporary linenr.selected
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs81
1 files changed, 46 insertions, 35 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 95587b4c..63b3e277 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -232,7 +232,45 @@ impl EditorView {
}
}
- // render selections
+ // render gutters
+
+ let linenr: Style = theme.get("ui.linenr");
+ let warning: Style = theme.get("warning");
+ let error: Style = theme.get("error");
+ let info: Style = theme.get("info");
+ let hint: Style = theme.get("hint");
+
+ for (i, line) in (view.first_line..last_line).enumerate() {
+ use helix_core::diagnostic::Severity;
+ if let Some(diagnostic) = doc.diagnostics().iter().find(|d| d.line == line) {
+ surface.set_stringn(
+ viewport.x - OFFSET,
+ viewport.y + i as u16,
+ "●",
+ 1,
+ match diagnostic.severity {
+ Some(Severity::Error) => error,
+ Some(Severity::Warning) | None => warning,
+ Some(Severity::Info) => info,
+ Some(Severity::Hint) => hint,
+ },
+ );
+ }
+
+ // line numbers having selections are rendered differently
+ surface.set_stringn(
+ viewport.x + 1 - OFFSET,
+ viewport.y + i as u16,
+ format!("{:>5}", line + 1),
+ 5,
+ linenr,
+ );
+ }
+
+ // render selections and selected linenr(s)
+ let linenr_select: Style = theme
+ .try_get("ui.linenr.selected")
+ .unwrap_or_else(|| theme.get("ui.linenr"));
if is_focused {
let screen = {
@@ -329,6 +367,13 @@ impl EditorView {
),
cursor_style,
);
+ surface.set_stringn(
+ viewport.x + 1 - OFFSET,
+ viewport.y + head.row as u16,
+ format!("{:>5}", view.first_line + head.row + 1),
+ 5,
+ linenr_select,
+ );
// TODO: set cursor position for IME
if let Some(syntax) = doc.syntax() {
use helix_core::match_brackets;
@@ -357,40 +402,6 @@ impl EditorView {
}
}
}
-
- // render gutters
-
- let style: Style = theme.get("ui.linenr");
- let warning: Style = theme.get("warning");
- let error: Style = theme.get("error");
- let info: Style = theme.get("info");
- let hint: Style = theme.get("hint");
-
- for (i, line) in (view.first_line..last_line).enumerate() {
- use helix_core::diagnostic::Severity;
- if let Some(diagnostic) = doc.diagnostics().iter().find(|d| d.line == line) {
- surface.set_stringn(
- viewport.x - OFFSET,
- viewport.y + i as u16,
- "●",
- 1,
- match diagnostic.severity {
- Some(Severity::Error) => error,
- Some(Severity::Warning) | None => warning,
- Some(Severity::Info) => info,
- Some(Severity::Hint) => hint,
- },
- );
- }
-
- surface.set_stringn(
- viewport.x + 1 - OFFSET,
- viewport.y + i as u16,
- format!("{:>5}", line + 1),
- 5,
- style,
- );
- }
}
pub fn render_diagnostics(