1
0
Fork 0
mirror of https://github.com/helix-editor/helix synced 2024-05-07 23:46:05 +02:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Jesse Luehrs c6bb517475
Merge 934a1f6645 into 5ee7411450 2024-04-26 23:55:27 +02:00
Diogenesoftoronto 5ee7411450
Change cursor color per mode for default (#10608) 2024-04-26 16:50:29 -05:00
Keir Lawson 31248d4e2f
Enable metals inlay hints (#10597) 2024-04-26 16:48:23 -05:00
Jesse Luehrs 934a1f6645 allow stacking the picker preview vertically
a lot of pickers don't actually make sense without the preview (global
search, for instance), so forcibly hiding the preview on 80x24 terminal
windows (the default in most situations) is not ideal.
2024-04-20 17:26:05 -05:00
3 changed files with 56 additions and 20 deletions

View File

@ -49,7 +49,10 @@
pub const ID: &str = "picker";
use super::{menu::Item, overlay::Overlay};
pub const MIN_AREA_WIDTH_FOR_PREVIEW: u16 = 72;
pub const MIN_AREA_WIDTH_FOR_PREVIEW: u16 = 40;
pub const MIN_AREA_HEIGHT_FOR_PREVIEW: u16 = 9;
pub const MAX_AREA_WIDTH_FOR_PREVIEW: u16 = 80;
pub const MAX_AREA_HEIGHT_FOR_PREVIEW: u16 = 24;
/// Biggest file size to preview in bytes
pub const MAX_FILE_SIZE_FOR_PREVIEW: u64 = 10 * 1024 * 1024;
@ -802,28 +805,59 @@ fn render_preview(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context
impl<T: Item + 'static + Send + Sync> Component for Picker<T> {
fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) {
// +---------+ +---------+
// |prompt | |preview |
// +---------+ | |
// |picker | | |
// | | | |
// +---------+ +---------+
let render_preview =
self.show_preview && self.file_fn.is_some() && area.width > MIN_AREA_WIDTH_FOR_PREVIEW;
let picker_width = if render_preview {
area.width / 2
let (show_preview, vertical) = if area.width / 2 >= MIN_AREA_WIDTH_FOR_PREVIEW
&& area.height / 2 >= MIN_AREA_HEIGHT_FOR_PREVIEW
{
if (area.width / 2).abs_diff(area.height * 10 / 3)
> area.width.abs_diff(area.height * 10 / 3 / 2)
{
(self.show_preview, true)
} else {
(self.show_preview, false)
}
} else if area.width >= MIN_AREA_WIDTH_FOR_PREVIEW
&& area.height / 2 >= MIN_AREA_HEIGHT_FOR_PREVIEW
{
(self.show_preview, true)
} else if area.width / 2 >= MIN_AREA_WIDTH_FOR_PREVIEW
&& area.height >= MIN_AREA_HEIGHT_FOR_PREVIEW
{
(self.show_preview, false)
} else {
area.width
(false, false)
};
let picker_area = area.with_width(picker_width);
self.render_picker(picker_area, surface, cx);
if show_preview && self.file_fn.is_some() {
if vertical {
// +---------------------+
// |prompt |
// +---------------------+
// |picker |
// | |
// +---------------------+
// |preview |
// | |
// +---------------------+
let preview_height = (area.height / 2).min(MAX_AREA_HEIGHT_FOR_PREVIEW);
let picker_height = area.height - preview_height;
if render_preview {
let preview_area = area.clip_left(picker_width);
self.render_preview(preview_area, surface, cx);
self.render_picker(area.with_height(picker_height), surface, cx);
self.render_preview(area.clip_top(picker_height), surface, cx);
} else {
// +---------+ +---------+
// |prompt | |preview |
// +---------+ | |
// |picker | | |
// | | | |
// +---------+ +---------+
let preview_width = (area.width / 2).min(MAX_AREA_WIDTH_FOR_PREVIEW);
let picker_width = area.width - preview_width;
self.render_picker(area.with_width(picker_width), surface, cx);
self.render_preview(area.clip_left(picker_width), surface, cx);
}
} else {
self.render_picker(area, surface, cx);
}
}

View File

@ -53,7 +53,7 @@ ltex-ls = { command = "ltex-ls" }
markdoc-ls = { command = "markdoc-ls", args = ["--stdio"] }
markdown-oxide = { command = "markdown-oxide" }
marksman = { command = "marksman", args = ["server"] }
metals = { command = "metals", config = { "isHttpEnabled" = true } }
metals = { command = "metals", config = { "isHttpEnabled" = true, metals = { inlayHints = { typeParameters = {enable = true} , hintsInPatternMatch = {enable = true} } } } }
mint = { command = "mint", args = ["ls"] }
nil = { command = "nil" }
nimlangserver = { command = "nimlangserver" }

View File

@ -66,6 +66,8 @@ label = "honey"
# TODO: namespace ui.cursor as ui.selection.cursor?
"ui.cursor.select" = { bg = "delta" }
"ui.cursor.insert" = { bg = "white" }
"ui.cursor.primary.select" = { bg = "delta" }
"ui.cursor.primary.insert" = { bg = "white" }
"ui.cursor.match" = { fg = "#212121", bg = "#6C6999" }
"ui.cursor" = { modifiers = ["reversed"] }
"ui.cursorline.primary" = { bg = "bossanova" }