aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/menu.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui/menu.rs')
-rw-r--r--helix-term/src/ui/menu.rs47
1 files changed, 34 insertions, 13 deletions
diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs
index 9704b1f2..0ee64ce9 100644
--- a/helix-term/src/ui/menu.rs
+++ b/helix-term/src/ui/menu.rs
@@ -7,11 +7,18 @@ use crate::{
use helix_core::fuzzy::MATCHER;
use nucleo::pattern::{Atom, AtomKind, CaseMatching};
use nucleo::{Config, Utf32Str};
-use tui::{buffer::Buffer as Surface, widgets::Table};
+use tui::{
+ buffer::Buffer as Surface,
+ widgets::{Block, Borders, Table, Widget},
+};
pub use tui::widgets::{Cell, Row};
-use helix_view::{editor::SmartTabConfig, graphics::Rect, Editor};
+use helix_view::{
+ editor::SmartTabConfig,
+ graphics::{Margin, Rect},
+ Editor,
+};
use tui::layout::Constraint;
pub trait Item: Sync + Send + 'static {
@@ -322,6 +329,15 @@ impl<T: Item + 'static> Component for Menu<T> {
let selected = theme.get("ui.menu.selected");
surface.clear_with(area, style);
+ let render_borders = cx.editor.menu_border();
+
+ let area = if render_borders {
+ Widget::render(Block::default().borders(Borders::ALL), area, surface);
+ area.inner(&Margin::vertical(1))
+ } else {
+ area
+ };
+
let scroll = self.scroll;
let options: Vec<_> = self
@@ -362,15 +378,19 @@ impl<T: Item + 'static> Component for Menu<T> {
false,
);
- if let Some(cursor) = self.cursor {
- let offset_from_top = cursor - scroll;
- let left = &mut surface[(area.left(), area.y + offset_from_top as u16)];
- left.set_style(selected);
- let right = &mut surface[(
- area.right().saturating_sub(1),
- area.y + offset_from_top as u16,
- )];
- right.set_style(selected);
+ let render_borders = cx.editor.menu_border();
+
+ if !render_borders {
+ if let Some(cursor) = self.cursor {
+ let offset_from_top = cursor - scroll;
+ let left = &mut surface[(area.left(), area.y + offset_from_top as u16)];
+ left.set_style(selected);
+ let right = &mut surface[(
+ area.right().saturating_sub(1),
+ area.y + offset_from_top as u16,
+ )];
+ right.set_style(selected);
+ }
}
let fits = len <= win_height;
@@ -385,12 +405,13 @@ impl<T: Item + 'static> Component for Menu<T> {
for i in 0..win_height {
cell = &mut surface[(area.right() - 1, area.top() + i as u16)];
- cell.set_symbol("▐"); // right half block
+ let half_block = if render_borders { "▌" } else { "▐" };
if scroll_line <= i && i < scroll_line + scroll_height {
// Draw scroll thumb
+ cell.set_symbol(half_block);
cell.set_fg(scroll_style.fg.unwrap_or(helix_view::theme::Color::Reset));
- } else {
+ } else if !render_borders {
// Draw scroll track
cell.set_fg(scroll_style.bg.unwrap_or(helix_view::theme::Color::Reset));
}