Render a separator between vertical splits.

pull/11/head
Blaž Hrastnik 4 years ago
parent 9f318a8529
commit 52da68e49a

@ -55,13 +55,26 @@ impl EditorView {
is_focused: bool, is_focused: bool,
) { ) {
let area = Rect::new( let area = Rect::new(
viewport.x + OFFSET, view.area.x + OFFSET,
viewport.y, view.area.y,
viewport.width - OFFSET, view.area.width - OFFSET,
viewport.height.saturating_sub(1), view.area.height.saturating_sub(1),
); // - 1 for statusline ); // - 1 for statusline
self.render_buffer(doc, view, area, surface, theme, is_focused); 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 // clear with background color
// TODO: this seems to prevent setting style later // TODO: this seems to prevent setting style later
// surface.set_style(viewport, theme.get("ui.background")); // surface.set_style(viewport, theme.get("ui.background"));
@ -69,9 +82,9 @@ impl EditorView {
self.render_diagnostics(doc, view, area, surface, theme, is_focused); self.render_diagnostics(doc, view, area, surface, theme, is_focused);
let area = Rect::new( let area = Rect::new(
viewport.x, view.area.x,
viewport.y + viewport.height.saturating_sub(1), view.area.y + view.area.height.saturating_sub(1),
viewport.width, view.area.width,
1, 1,
); );
self.render_statusline(doc, area, surface, theme, is_focused); self.render_statusline(doc, area, surface, theme, is_focused);
@ -79,7 +92,12 @@ impl EditorView {
// render status // render status
if let Some(status_msg) = &self.status_msg { if let Some(status_msg) = &self.status_msg {
let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender 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,
);
} }
} }
@ -595,7 +613,7 @@ impl Component for EditorView {
fn render(&self, mut area: Rect, surface: &mut Surface, cx: &mut Context) { fn render(&self, mut area: Rect, surface: &mut Surface, cx: &mut Context) {
for (view, is_focused) in cx.editor.tree.views() { for (view, is_focused) in cx.editor.tree.views() {
let doc = cx.editor.document(view.doc).unwrap(); 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 { if let Some(completion) = &self.completion {

@ -353,6 +353,9 @@ impl Tree {
let width = area.width / len as u16; 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; let mut child_x = area.x;
for (i, child) in container.children.iter().enumerate() { for (i, child) in container.children.iter().enumerate() {
@ -362,7 +365,7 @@ impl Tree {
width, width,
container.area.height, container.area.height,
); );
child_x += width; child_x += width + inner_gap;
// last child takes the remaining width because we can get uneven // last child takes the remaining width because we can get uneven
// space from rounding // space from rounding

@ -39,6 +39,7 @@
"ui.linenr" = { fg = "#5a5977" } # comet "ui.linenr" = { fg = "#5a5977" } # comet
"ui.statusline" = { bg = "#281733" } # revolver "ui.statusline" = { bg = "#281733" } # revolver
"ui.popup" = { bg = "#281733" } # revolver "ui.popup" = { bg = "#281733" } # revolver
"ui.window" = { bg = "#452859" } # bossa nova
"warning" = "#ffcd1c" "warning" = "#ffcd1c"
"error" = "#f47868" "error" = "#f47868"

Loading…
Cancel
Save