@@ -16,14 +16,14 @@ use helix_core::{
16 LineEnding, Position, Range, Selection, Transaction,
16 LineEnding, Position, Range, Selection, Transaction,
18use helix_view::{
18use helix_view::{
19− document::Mode,
19+ document::{Mode, SCRATCH_BUFFER_NAME},
20 editor::{CompleteAction, CursorShapeConfig},
20 editor::{CompleteAction, CursorShapeConfig},
21 graphics::{Color, CursorKind, Modifier, Rect, Style},
21 graphics::{Color, CursorKind, Modifier, Rect, Style},
22 input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind},
22 input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind},
23 keyboard::{KeyCode, KeyModifiers},
23 keyboard::{KeyCode, KeyModifiers},
24 Document, Editor, Theme, View,
24 Document, Editor, Theme, View,
26−use std::borrow::Cow;
26+use std::{borrow::Cow, path::PathBuf};
28use tui::buffer::Buffer as Surface;
28use tui::buffer::Buffer as Surface;
@@ -619,6 +619,59 @@ impl EditorView {
622+ /// Render bufferline at the top
623+ pub fn render_bufferline(editor: &Editor, viewport: Rect, surface: &mut Surface) {
624+ let scratch = PathBuf::from(SCRATCH_BUFFER_NAME); // default filename to use for scratch buffer
629+ .try_get("ui.bufferline.background")
630+ .unwrap_or_else(|| editor.theme.get("ui.statusline")),
633+ let bufferline_active = editor
635+ .try_get("ui.bufferline.active")
636+ .unwrap_or_else(|| editor.theme.get("ui.statusline.active"));
638+ let bufferline_inactive = editor
640+ .try_get("ui.bufferline")
641+ .unwrap_or_else(|| editor.theme.get("ui.statusline.inactive"));
643+ let mut x = viewport.x;
644+ let current_doc = view!(editor).doc;
646+ for doc in editor.documents() {
649+ .unwrap_or(&scratch)
651+ .unwrap_or_default()
653+ .unwrap_or_default();
655+ let style = if current_doc == doc.id() {
661+ let text = format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" });
662+ let used_width = viewport.x.saturating_sub(x);
663+ let rem_width = surface.area.width.saturating_sub(used_width);
666+ .set_stringn(x, viewport.y, text, rem_width as usize, style)
669+ if x >= surface.area.right() {
622 pub fn render_gutter(
675 pub fn render_gutter(
623 editor: &Editor,
676 editor: &Editor,
624 doc: &Document,
677 doc: &Document,
@@ -1291,8 +1344,27 @@ impl Component for EditorView {
1291 // clear with background color
1344 // clear with background color
1292 surface.set_style(area, cx.editor.theme.get("ui.background"));
1345 surface.set_style(area, cx.editor.theme.get("ui.background"));
1293 let config = cx.editor.config();
1346 let config = cx.editor.config();
1348+ // check if bufferline should be rendered
1349+ use helix_view::editor::BufferLine;
1350+ let use_bufferline = match config.bufferline {
1351+ BufferLine::Always => true,
1352+ BufferLine::Multiple if cx.editor.documents.len() > 1 => true,
1356+ // -1 for commandline and -1 for bufferline
1357+ let mut editor_area = area.clip_bottom(1);
1358+ if use_bufferline {
1359+ editor_area = editor_area.clip_top(1);
1294 // if the terminal size suddenly changed, we need to trigger a resize
1362 // if the terminal size suddenly changed, we need to trigger a resize
1295− cx.editor.resize(area.clip_bottom(1)); // -1 from bottom for commandline
1363+ cx.editor.resize(editor_area);
1365+ if use_bufferline {
1366+ Self::render_bufferline(cx.editor, area.with_height(1), surface);
1297 for (view, is_focused) in cx.editor.tree.views() {
1369 for (view, is_focused) in cx.editor.tree.views() {
1298 let doc = cx.editor.document(view.doc).unwrap();
1370 let doc = cx.editor.document(view.doc).unwrap();