mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 10:56:19 +04:00
add bufferline wrapping
This commit is contained in:
parent
a1e20a3426
commit
b21b6d29e1
@ -591,8 +591,9 @@ pub fn highlight_focused_view_elements(
|
|||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render bufferline at the top
|
/// Render bufferline at the top. Returns height of the bufferline so
|
||||||
pub fn render_bufferline(editor: &Editor, viewport: Rect, surface: &mut Surface) {
|
/// that the editor area can be clipped accordingly.
|
||||||
|
pub fn render_bufferline(editor: &Editor, viewport: Rect, surface: &mut Surface) -> u16 {
|
||||||
let scratch = PathBuf::from(SCRATCH_BUFFER_NAME); // default filename to use for scratch buffer
|
let scratch = PathBuf::from(SCRATCH_BUFFER_NAME); // default filename to use for scratch buffer
|
||||||
surface.clear_with(
|
surface.clear_with(
|
||||||
viewport,
|
viewport,
|
||||||
@ -615,6 +616,8 @@ pub fn render_bufferline(editor: &Editor, viewport: Rect, surface: &mut Surface)
|
|||||||
let mut x = viewport.x;
|
let mut x = viewport.x;
|
||||||
let current_doc = view!(editor).doc;
|
let current_doc = view!(editor).doc;
|
||||||
|
|
||||||
|
let mut y = viewport.y;
|
||||||
|
|
||||||
for doc in editor.documents() {
|
for doc in editor.documents() {
|
||||||
let fname = doc
|
let fname = doc
|
||||||
.path()
|
.path()
|
||||||
@ -634,14 +637,14 @@ pub fn render_bufferline(editor: &Editor, viewport: Rect, surface: &mut Surface)
|
|||||||
let used_width = viewport.x.saturating_sub(x);
|
let used_width = viewport.x.saturating_sub(x);
|
||||||
let rem_width = surface.area.width.saturating_sub(used_width);
|
let rem_width = surface.area.width.saturating_sub(used_width);
|
||||||
|
|
||||||
x = surface
|
if x + text.len() as u16 >= surface.area.right() {
|
||||||
.set_stringn(x, viewport.y, text, rem_width as usize, style)
|
x = 0;
|
||||||
.0;
|
y = y + 1;
|
||||||
|
}
|
||||||
|
|
||||||
if x >= surface.area.right() {
|
x = surface.set_stringn(x, y, text, rem_width as usize, style).0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
y + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_gutter<'d>(
|
pub fn render_gutter<'d>(
|
||||||
@ -1486,19 +1489,20 @@ fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) {
|
|||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// -1 for commandline and -1 for bufferline
|
// -1 for commandline
|
||||||
let mut editor_area = area.clip_bottom(1);
|
let mut editor_area = area.clip_bottom(1);
|
||||||
if use_bufferline {
|
if use_bufferline {
|
||||||
editor_area = editor_area.clip_top(1);
|
// -1 or more for the bufferline
|
||||||
|
editor_area = editor_area.clip_top(Self::render_bufferline(
|
||||||
|
cx.editor,
|
||||||
|
area.with_height(1),
|
||||||
|
surface,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the terminal size suddenly changed, we need to trigger a resize
|
// if the terminal size suddenly changed, we need to trigger a resize
|
||||||
cx.editor.resize(editor_area);
|
cx.editor.resize(editor_area);
|
||||||
|
|
||||||
if use_bufferline {
|
|
||||||
Self::render_bufferline(cx.editor, area.with_height(1), surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
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(cx.editor, doc, view, area, surface, is_focused);
|
self.render_view(cx.editor, doc, view, area, surface, is_focused);
|
||||||
|
Loading…
Reference in New Issue
Block a user