From 4a053bcb2bd2a2efbfb97b7aaa1b07b207e18911 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Sat, 6 Jul 2024 04:22:28 +0500 Subject: [PATCH 01/10] add cursorcolumn and cursorline to base16_transparent theme --- runtime/themes/base16_transparent.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/themes/base16_transparent.toml b/runtime/themes/base16_transparent.toml index 70452366f4c8..d5786f89eb85 100644 --- a/runtime/themes/base16_transparent.toml +++ b/runtime/themes/base16_transparent.toml @@ -24,6 +24,10 @@ "ui.cursor.match" = { fg = "light-yellow", underline = { color = "light-yellow", style = "line" } } "ui.cursor.primary" = { modifiers = ["reversed", "slow_blink"] } "ui.cursor.secondary" = { modifiers = ["reversed"] } +"ui.cursorline.primary" = { underline = { color = "light-gray", style = "line" } } +"ui.cursorline.secondary" = { underline = { color = "light-gray", style = "line" } } +"ui.cursorcolumn.primary" = { bg = "gray" } +"ui.cursorcolumn.secondary" = { bg = "gray" } "ui.virtual.ruler" = { bg = "gray" } "ui.virtual.whitespace" = "gray" "ui.virtual.indent-guide" = "gray" From c185d403dc583178c9dab97d12f5bd97fa36e009 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Fri, 6 Sep 2024 02:42:32 +0500 Subject: [PATCH 02/10] remove-margins-from-overlay --- helix-term/src/ui/overlay.rs | 2 +- helix-term/src/ui/picker.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/overlay.rs b/helix-term/src/ui/overlay.rs index ff184d4073fa..6f49c9217e0b 100644 --- a/helix-term/src/ui/overlay.rs +++ b/helix-term/src/ui/overlay.rs @@ -19,7 +19,7 @@ pub struct Overlay { pub fn overlaid(content: T) -> Overlay { Overlay { content, - calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 90, 90)), + calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 100, 100)), } } diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 82fe9689164d..633dff7ed97e 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -960,7 +960,7 @@ impl Component for Picker MIN_AREA_WIDTH_FOR_PREVIEW; let picker_width = if render_preview { - area.width / 2 + area.width * 3 / 8 } else { area.width }; From 5ad7319ac27e462fcd4d94361142ec7865b62258 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Sun, 20 Oct 2024 15:16:09 +0500 Subject: [PATCH 03/10] remove-bottom-clip --- helix-term/src/ui/overlay.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/ui/overlay.rs b/helix-term/src/ui/overlay.rs index 6f49c9217e0b..599737709f9e 100644 --- a/helix-term/src/ui/overlay.rs +++ b/helix-term/src/ui/overlay.rs @@ -19,7 +19,7 @@ pub struct Overlay { pub fn overlaid(content: T) -> Overlay { Overlay { content, - calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 100, 100)), + calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(0), 100, 100)), } } From ee5f956cbffb6138d9c67f9636bcca5e9d1d91d9 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Sun, 22 Dec 2024 03:05:27 +0500 Subject: [PATCH 04/10] cleanup-and-comments --- helix-term/src/ui/overlay.rs | 22 +--------------------- helix-term/src/ui/picker.rs | 13 +++++++------ 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/helix-term/src/ui/overlay.rs b/helix-term/src/ui/overlay.rs index 599737709f9e..2fa643ab606c 100644 --- a/helix-term/src/ui/overlay.rs +++ b/helix-term/src/ui/overlay.rs @@ -15,30 +15,10 @@ pub struct Overlay { pub calc_child_size: Box Rect>, } -/// Surrounds the component with a margin of 5% on each side, and an additional 2 rows at the bottom pub fn overlaid(content: T) -> Overlay { Overlay { content, - calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(0), 100, 100)), - } -} - -fn clip_rect_relative(rect: Rect, percent_horizontal: u8, percent_vertical: u8) -> Rect { - fn mul_and_cast(size: u16, factor: u8) -> u16 { - ((size as u32) * (factor as u32) / 100).try_into().unwrap() - } - - let inner_w = mul_and_cast(rect.width, percent_horizontal); - let inner_h = mul_and_cast(rect.height, percent_vertical); - - let offset_x = rect.width.saturating_sub(inner_w) / 2; - let offset_y = rect.height.saturating_sub(inner_h) / 2; - - Rect { - x: rect.x + offset_x, - y: rect.y + offset_y, - width: inner_w, - height: inner_h, + calc_child_size: Box::new(|rect: Rect| rect), } } diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index c76c686d02ea..e466d333d2cc 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -934,16 +934,17 @@ impl Picker { impl Component for Picker { fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { - // +---------+ +---------+ - // |prompt | |preview | - // +---------+ | | - // |picker | | | - // | | | | - // +---------+ +---------+ + // +---------+ +-------------+ + // |prompt | |preview | + // +---------+ | | + // |picker | | | + // | | | | + // +---------+ +-------------+ let render_preview = self.show_preview && self.file_fn.is_some() && area.width > MIN_AREA_WIDTH_FOR_PREVIEW; + // The preview gets more space if it present let picker_width = if render_preview { area.width * 3 / 8 } else { From 7ad3d9906421ae338dc62a713f9038a2ebc9947e Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Sun, 22 Dec 2024 05:15:32 +0500 Subject: [PATCH 05/10] typo-correction --- helix-term/src/ui/picker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index e466d333d2cc..70d5faaf8d62 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -944,7 +944,7 @@ impl Component for Picker MIN_AREA_WIDTH_FOR_PREVIEW; - // The preview gets more space if it present + // The preview gets more space if it is present let picker_width = if render_preview { area.width * 3 / 8 } else { From 4939e5a6525cdb0da6d3c5cd1e3e3e948e8f0a64 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Sun, 22 Dec 2024 05:19:48 +0500 Subject: [PATCH 06/10] slightly-adjust-comment-wording --- helix-term/src/ui/picker.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 70d5faaf8d62..facecadbf34d 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -944,9 +944,8 @@ impl Component for Picker MIN_AREA_WIDTH_FOR_PREVIEW; - // The preview gets more space if it is present let picker_width = if render_preview { - area.width * 3 / 8 + area.width * 3 / 8 // makes preview's width greater than the picker's } else { area.width }; From 63f5b069c19ddac2dea0e5f24181b0505cd576d3 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Sun, 22 Dec 2024 05:22:48 +0500 Subject: [PATCH 07/10] ui/picker.rs: remove a comment --- helix-term/src/ui/picker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index facecadbf34d..049538bcdf41 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -945,7 +945,7 @@ impl Component for Picker MIN_AREA_WIDTH_FOR_PREVIEW; let picker_width = if render_preview { - area.width * 3 / 8 // makes preview's width greater than the picker's + area.width * 3 / 8 } else { area.width }; From e63f01694b996ba86c83cd3e1f84cb7b33e3f516 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Thu, 2 Jan 2025 01:31:27 +0500 Subject: [PATCH 08/10] undo-picker-preview-ratio-change --- helix-term/src/ui/picker.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 049538bcdf41..df8d52ebd2f8 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -934,18 +934,18 @@ impl Picker { impl Component for Picker { fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { - // +---------+ +-------------+ - // |prompt | |preview | - // +---------+ | | - // |picker | | | - // | | | | - // +---------+ +-------------+ + // +---------+ +---------+ + // |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 * 3 / 8 + area.width / 2 } else { area.width }; From d24eaa1e51542e865d8bfccf7d71d42e55e23c11 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Thu, 2 Jan 2025 01:33:53 +0500 Subject: [PATCH 09/10] undo-fullscreen-without-status-line-and-bring-back-old-code --- helix-term/src/ui/overlay.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/overlay.rs b/helix-term/src/ui/overlay.rs index 2fa643ab606c..ff184d4073fa 100644 --- a/helix-term/src/ui/overlay.rs +++ b/helix-term/src/ui/overlay.rs @@ -15,10 +15,30 @@ pub struct Overlay { pub calc_child_size: Box Rect>, } +/// Surrounds the component with a margin of 5% on each side, and an additional 2 rows at the bottom pub fn overlaid(content: T) -> Overlay { Overlay { content, - calc_child_size: Box::new(|rect: Rect| rect), + calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 90, 90)), + } +} + +fn clip_rect_relative(rect: Rect, percent_horizontal: u8, percent_vertical: u8) -> Rect { + fn mul_and_cast(size: u16, factor: u8) -> u16 { + ((size as u32) * (factor as u32) / 100).try_into().unwrap() + } + + let inner_w = mul_and_cast(rect.width, percent_horizontal); + let inner_h = mul_and_cast(rect.height, percent_vertical); + + let offset_x = rect.width.saturating_sub(inner_w) / 2; + let offset_y = rect.height.saturating_sub(inner_h) / 2; + + Rect { + x: rect.x + offset_x, + y: rect.y + offset_y, + width: inner_w, + height: inner_h, } } From 09685a08d3fd95233e8924b4a23bf71102041195 Mon Sep 17 00:00:00 2001 From: Salman Farooq Date: Thu, 2 Jan 2025 02:12:51 +0500 Subject: [PATCH 10/10] make-overlaid-content-conditionally-take-all-the-space --- helix-term/src/ui/overlay.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/overlay.rs b/helix-term/src/ui/overlay.rs index ff184d4073fa..1230404c7f4c 100644 --- a/helix-term/src/ui/overlay.rs +++ b/helix-term/src/ui/overlay.rs @@ -7,6 +7,8 @@ use tui::buffer::Buffer; use crate::compositor::{Component, Context, Event, EventResult}; +pub const FULL_OVERLAID_MAX_WIDTH: u16 = 240; + /// Contains a component placed in the center of the parent component pub struct Overlay { /// Child component @@ -19,7 +21,14 @@ pub struct Overlay { pub fn overlaid(content: T) -> Overlay { Overlay { content, - calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 90, 90)), + calc_child_size: Box::new(|rect: Rect| { + let percentage = if rect.width < FULL_OVERLAID_MAX_WIDTH { + 100 + } else { + 90 + }; + clip_rect_relative(rect.clip_bottom(2), percentage, percentage) + }), } }