Skip to content

Commit

Permalink
Render a separator between vertical splits.
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Apr 8, 2021
1 parent 9f318a8 commit 52da68e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
36 changes: 27 additions & 9 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,49 @@ impl EditorView {
is_focused: bool,
) {
let area = Rect::new(
viewport.x + OFFSET,
viewport.y,
viewport.width - OFFSET,
viewport.height.saturating_sub(1),
view.area.x + OFFSET,
view.area.y,
view.area.width - OFFSET,
view.area.height.saturating_sub(1),
); // - 1 for statusline
self.render_buffer(doc, view, area, surface, theme, is_focused);

// if we're not at the edge of the screen, draw a right border
if viewport.right() != view.area.right() {
let x = area.right();
let border_style = theme.get("ui.window");
for y in area.top()..area.bottom() {
surface
.get_mut(x, y)
// .set_symbol(tui::symbols::line::VERTICAL)
.set_symbol(" ")
.set_style(border_style);
}
}

// clear with background color
// TODO: this seems to prevent setting style later
// surface.set_style(viewport, theme.get("ui.background"));

self.render_diagnostics(doc, view, area, surface, theme, is_focused);

let area = Rect::new(
viewport.x,
viewport.y + viewport.height.saturating_sub(1),
viewport.width,
view.area.x,
view.area.y + view.area.height.saturating_sub(1),
view.area.width,
1,
);
self.render_statusline(doc, area, surface, theme, is_focused);

// render status
if let Some(status_msg) = &self.status_msg {
let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
surface.set_string(viewport.x, viewport.y + viewport.height, status_msg, style);
surface.set_string(
view.area.x,
view.area.y + view.area.height,
status_msg,
style,
);
}
}

Expand Down Expand Up @@ -595,7 +613,7 @@ impl Component for EditorView {
fn render(&self, mut area: Rect, surface: &mut Surface, cx: &mut Context) {
for (view, is_focused) in cx.editor.tree.views() {
let doc = cx.editor.document(view.doc).unwrap();
self.render_view(doc, view, view.area, surface, &cx.editor.theme, is_focused);
self.render_view(doc, view, area, surface, &cx.editor.theme, is_focused);
}

if let Some(completion) = &self.completion {
Expand Down
5 changes: 4 additions & 1 deletion helix-view/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ impl Tree {

let width = area.width / len as u16;

let inner_gap = 1u16;
// let total_gap = inner_gap * (len as u16 - 1);

let mut child_x = area.x;

for (i, child) in container.children.iter().enumerate() {
Expand All @@ -362,7 +365,7 @@ impl Tree {
width,
container.area.height,
);
child_x += width;
child_x += width + inner_gap;

// last child takes the remaining width because we can get uneven
// space from rounding
Expand Down
1 change: 1 addition & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"ui.linenr" = { fg = "#5a5977" } # comet
"ui.statusline" = { bg = "#281733" } # revolver
"ui.popup" = { bg = "#281733" } # revolver
"ui.window" = { bg = "#452859" } # bossa nova

"warning" = "#ffcd1c"
"error" = "#f47868"
Expand Down

0 comments on commit 52da68e

Please sign in to comment.