From b0f21ed2cb85613050b794bf6c78a7c367a94e0d Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Mon, 14 Sep 2026 15:47:53 -0400 Subject: feat: add cursor-based editing to text inputs (#3698) * feat: add cursor-based editing to text inputs refs #1803 * fix: preserve dialog actions with associated text refs #1803 * refactor: simplify text editor outcomes and tests refs #1803 --------- Co-authored-by: JJ Liebig --- src/client/shell/render.rs | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'src/client/shell/render.rs') diff --git a/src/client/shell/render.rs b/src/client/shell/render.rs index d51586a0..80387019 100644 --- a/src/client/shell/render.rs +++ b/src/client/shell/render.rs @@ -128,17 +128,36 @@ pub(super) fn render_mode_bar( crate::api::schema::PaneCopySearchDirection::Forward => "/", crate::api::schema::PaneCopySearchDirection::Backward => "?", }; - segments.extend([ - (" COPY ".to_owned(), mode_style), - (" ".to_owned(), base), - (marker.to_owned(), key), - ( - prompt.query.clone(), - Style::default().fg(palette.text).bg(palette.panel_bg), - ), - ("█".to_owned(), key), - (" enter search esc cancel".to_owned(), base), - ]); + buffer.set_stringn(bar.x, bar.y, " COPY ", usize::from(bar.width), mode_style); + let prefix = 8.min(bar.width); + if bar.width >= 8 { + buffer.set_string(bar.x + 7, bar.y, marker, key); + } + let footer = " enter search esc cancel"; + let footer_width = if bar.width >= 50 { + footer.len() as u16 + } else { + 0 + }; + let field = Rect::new( + bar.x + prefix, + bar.y, + bar.width.saturating_sub(prefix + footer_width), + 1, + ); + if let Some(cursor) = text_editor::render( + buffer, + field, + &prompt.query, + Style::default().fg(palette.text).bg(palette.panel_bg), + ) { + buffer[(cursor.x, cursor.y)] + .set_style(Style::default().fg(palette.panel_bg).bg(palette.text)); + } + if footer_width > 0 { + buffer.set_string(bar.right() - footer_width, bar.y, footer, base); + } + return Some(bar); } else { let select = if copy_mode.selection.is_some() { "selecting" -- cgit v1.2.3