Skip to content

Commit

Permalink
Support drawing popup border
Browse files Browse the repository at this point in the history
  • Loading branch information
ath3 committed Oct 16, 2022
1 parent e16c632 commit adf6d19
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ on unix operating systems.
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` |
| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
| `popup-border` | Draw border around popups | `false` |

### `[editor.statusline]` Section

Expand Down
3 changes: 2 additions & 1 deletion helix-term/src/ui/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ impl SignatureHelp {
}

impl Component for SignatureHelp {
fn render(&mut self, area: Rect, surface: &mut Buffer, cx: &mut Context) {
fn render(&mut self, mut area: Rect, surface: &mut Buffer, cx: &mut Context) {
let margin = Margin::horizontal(1);
area.height -= 1;

let active_param_span = self.active_param_range.map(|(start, end)| {
vec![(
Expand Down
12 changes: 9 additions & 3 deletions helix-term/src/ui/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,20 @@ impl<T: Component> Component for Popup<T> {
let (rel_x, rel_y) = self.get_rel_position(viewport, cx);

// clip to viewport
let area = viewport.intersection(Rect::new(rel_x, rel_y, self.size.0, self.size.1));
let mut area = viewport.intersection(Rect::new(rel_x, rel_y, self.size.0, self.size.1));

// clear area
let background = cx.editor.theme.get("ui.popup");
surface.clear_with(area, background);

let inner = area.inner(&self.margin);
self.contents.render(inner, surface, cx);
if cx.editor.config().popup_border {
use tui::widgets::{Block, Borders, Widget};
Widget::render(Block::default().borders(Borders::ALL), area, surface);
} else {
area = area.inner(&self.margin);
}

self.contents.render(area, surface, cx);
}

fn id(&self) -> Option<&'static str> {
Expand Down
3 changes: 3 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ pub struct Config {
pub indent_guides: IndentGuidesConfig,
/// Whether to color modes with different colors. Defaults to `false`.
pub color_modes: bool,
/// Draw border around popups.
pub popup_border: bool,
}

#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -605,6 +607,7 @@ impl Default for Config {
bufferline: BufferLine::default(),
indent_guides: IndentGuidesConfig::default(),
color_modes: false,
popup_border: false,
}
}
}
Expand Down

0 comments on commit adf6d19

Please sign in to comment.