|
|
@ -18,7 +18,7 @@ use helix_core::{
|
|
|
|
movement::Direction,
|
|
|
|
movement::Direction,
|
|
|
|
syntax::{self, HighlightEvent},
|
|
|
|
syntax::{self, HighlightEvent},
|
|
|
|
text_annotations::TextAnnotations,
|
|
|
|
text_annotations::TextAnnotations,
|
|
|
|
unicode::width::UnicodeWidthStr,
|
|
|
|
unicode::{segmentation::UnicodeSegmentation, width::UnicodeWidthStr},
|
|
|
|
visual_offset_from_block, Change, Position, Range, Selection, Transaction,
|
|
|
|
visual_offset_from_block, Change, Position, Range, Selection, Transaction,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use helix_view::{
|
|
|
|
use helix_view::{
|
|
|
@ -520,16 +520,8 @@ impl EditorView {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Render bufferline at the top
|
|
|
|
/// Render bufferline at the top
|
|
|
|
pub fn render_bufferline(editor: &Editor, viewport: Rect, surface: &mut Surface) {
|
|
|
|
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(
|
|
|
|
|
|
|
|
viewport,
|
|
|
|
|
|
|
|
editor
|
|
|
|
|
|
|
|
.theme
|
|
|
|
|
|
|
|
.try_get("ui.bufferline.background")
|
|
|
|
|
|
|
|
.unwrap_or_else(|| editor.theme.get("ui.statusline")),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let bufferline_active = editor
|
|
|
|
let bufferline_active = editor
|
|
|
|
.theme
|
|
|
|
.theme
|
|
|
|
.try_get("ui.bufferline.active")
|
|
|
|
.try_get("ui.bufferline.active")
|
|
|
@ -541,8 +533,11 @@ impl EditorView {
|
|
|
|
.unwrap_or_else(|| editor.theme.get("ui.statusline.inactive"));
|
|
|
|
.unwrap_or_else(|| editor.theme.get("ui.statusline.inactive"));
|
|
|
|
|
|
|
|
|
|
|
|
let mut x = viewport.x;
|
|
|
|
let mut x = viewport.x;
|
|
|
|
|
|
|
|
let mut y = 0;
|
|
|
|
let current_doc = view!(editor).doc;
|
|
|
|
let current_doc = view!(editor).doc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut tabs = Vec::<(String, u16, u16, Style)>::new();
|
|
|
|
|
|
|
|
|
|
|
|
for doc in editor.documents() {
|
|
|
|
for doc in editor.documents() {
|
|
|
|
let fname = doc
|
|
|
|
let fname = doc
|
|
|
|
.path()
|
|
|
|
.path()
|
|
|
@ -559,17 +554,34 @@ impl EditorView {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let text = format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" });
|
|
|
|
let text = format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" });
|
|
|
|
let used_width = viewport.x.saturating_sub(x);
|
|
|
|
let text_width = text.grapheme_indices(true).count() as u16;
|
|
|
|
let rem_width = surface.area.width.saturating_sub(used_width);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x = surface
|
|
|
|
if x + text_width > surface.area.width {
|
|
|
|
.set_stringn(x, viewport.y, text, rem_width as usize, style)
|
|
|
|
y += 1;
|
|
|
|
.0;
|
|
|
|
x = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if x >= surface.area.right() {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabs.push((text, x, y, style));
|
|
|
|
|
|
|
|
x += text_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let height = if x != 0 { y + 1 } else { y };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let viewport = viewport.with_height(height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surface.clear_with(
|
|
|
|
|
|
|
|
viewport,
|
|
|
|
|
|
|
|
editor
|
|
|
|
|
|
|
|
.theme
|
|
|
|
|
|
|
|
.try_get("ui.bufferline.background")
|
|
|
|
|
|
|
|
.unwrap_or_else(|| editor.theme.get("ui.statusline")),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (text, x, y, style) in tabs {
|
|
|
|
|
|
|
|
surface.set_string(x, y, text, style);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
height
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn render_gutter<'d>(
|
|
|
|
pub fn render_gutter<'d>(
|
|
|
@ -1412,16 +1424,13 @@ impl Component for EditorView {
|
|
|
|
// -1 for commandline and -1 for bufferline
|
|
|
|
// -1 for commandline and -1 for bufferline
|
|
|
|
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);
|
|
|
|
let bufferline_height = Self::render_bufferline(cx.editor, area, surface);
|
|
|
|
|
|
|
|
editor_area = editor_area.clip_top(bufferline_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|