diff options
| author | Mark Jaquith <mark@jaquith.me> | 2026-09-14 15:47:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-14 21:47:53 +0200 |
| commit | b0f21ed2cb85613050b794bf6c78a7c367a94e0d (patch) | |
| tree | 25c14e09338f5300bedbc8131aa23fab3d37add9 /src/client/shell/render.rs | |
| parent | d8b36691d10c6055293ad45324b22af8b8f570e5 (diff) | |
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 <jonathan.liebig@gmail.com>
Diffstat (limited to 'src/client/shell/render.rs')
| -rw-r--r-- | src/client/shell/render.rs | 41 |
1 files changed, 30 insertions, 11 deletions
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" |
