aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs8
-rw-r--r--helix-term/src/ui/picker.rs5
-rw-r--r--helix-term/src/ui/popup.rs2
-rw-r--r--helix-term/src/ui/prompt.rs14
4 files changed, 16 insertions, 13 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 5913df29..95587b4c 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -26,6 +26,7 @@ use tui::{
buffer::Buffer as Surface,
layout::Rect,
style::{Color, Modifier, Style},
+ terminal::CursorKind,
};
pub struct EditorView {
@@ -739,15 +740,12 @@ impl Component for EditorView {
}
}
- fn cursor_position(&self, area: Rect, editor: &Editor) -> Option<Position> {
+ fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
// match view.doc.mode() {
// Mode::Insert => write!(stdout, "\x1B[6 q"),
// mode => write!(stdout, "\x1B[2 q"),
// };
- // return editor.cursor_position()
-
- // It's easier to just not render the cursor and use selection rendering instead.
- None
+ editor.cursor()
}
}
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index 20d51d5d..0aec9894 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -16,6 +16,7 @@ use crate::ui::{Prompt, PromptEvent};
use helix_core::Position;
use helix_view::editor::Action;
use helix_view::Editor;
+use tui::terminal::CursorKind;
pub struct Picker<T> {
options: Vec<T>,
@@ -304,7 +305,7 @@ impl<T: 'static> Component for Picker<T> {
}
}
- fn cursor_position(&self, area: Rect, editor: &Editor) -> Option<Position> {
+ fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
// TODO: this is mostly duplicate code
let area = inner_rect(area);
let block = Block::default().borders(Borders::ALL);
@@ -314,6 +315,6 @@ impl<T: 'static> Component for Picker<T> {
// prompt area
let area = Rect::new(inner.x + 1, inner.y, inner.width - 1, 1);
- self.prompt.cursor_position(area, editor)
+ self.prompt.cursor(area, editor)
}
}
diff --git a/helix-term/src/ui/popup.rs b/helix-term/src/ui/popup.rs
index ca349403..8488d1c6 100644
--- a/helix-term/src/ui/popup.rs
+++ b/helix-term/src/ui/popup.rs
@@ -116,7 +116,7 @@ impl<T: Component> Component for Popup<T> {
let position = self
.position
- .or_else(|| cx.editor.cursor_position())
+ .or_else(|| cx.editor.cursor().0)
.unwrap_or_default();
let (width, height) = self.size;
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index c388c315..7b8af820 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -4,6 +4,7 @@ use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
use helix_core::Position;
use helix_view::{Editor, Theme};
use std::{borrow::Cow, ops::RangeFrom};
+use tui::terminal::CursorKind;
pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
@@ -342,11 +343,14 @@ impl Component for Prompt {
self.render_prompt(area, surface, cx)
}
- fn cursor_position(&self, area: Rect, editor: &Editor) -> Option<Position> {
+ fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
let line = area.height as usize - 1;
- Some(Position::new(
- area.y as usize + line,
- area.x as usize + self.prompt.len() + self.cursor,
- ))
+ (
+ Some(Position::new(
+ area.y as usize + line,
+ area.x as usize + self.prompt.len() + self.cursor,
+ )),
+ CursorKind::Block,
+ )
}
}