diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-01 15:48:22 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-01 15:48:22 +0300 |
| commit | 207be3c771d281baae6e5fa0fb74be9a056e97a2 (patch) | |
| tree | d7b037ecdf629224a048c841d11659efdc23507d /src/ui/scrollbar.rs | |
| parent | 8a6d697308162874a236c84aac0b0f8c7ac01f83 (diff) | |
refactor: render the shell in the client (#3487)
* feat: add opt-in client-rendered shell
* feat: add client-owned shell mouse controls
* feat: complete client-owned shell chrome
* feat: add client-owned shell settings and notifications
* feat: run client shell custom commands
* feat: render popup terminals in client shell
* feat: add client-owned scrollback and copy mode
* fix: preserve client worktree trust defaults
* feat: render startup diagnostics in client shell
* feat: render onboarding in client shell
* feat: render product announcements in client shell
* feat: render release notes in client shell
* feat: render mobile switcher in client shell
* feat: render kitty graphics in client shell
* fix: preserve client shell lifecycle coherence
* refactor: route client shell commands through endpoint connections
* refactor: make the client-rendered shell the default
* refactor: remove monolithic launch mode
* refactor: complete client-rendered shell cutover
* perf: retain client pane surface updates
* perf: scale retained pane surface updates
* perf: remove remote pane input latency
* test: make client shell checks platform-independent
* fix: prevent client timer starvation
* test: fix client shell platform gates
* test: accept retained surfaces in cross-area checks
* test: make client mode assertions platform-neutral
* fix: badge only outdated integrations
Diffstat (limited to 'src/ui/scrollbar.rs')
| -rw-r--r-- | src/ui/scrollbar.rs | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/src/ui/scrollbar.rs b/src/ui/scrollbar.rs index b73b2c50..cf700825 100644 --- a/src/ui/scrollbar.rs +++ b/src/ui/scrollbar.rs @@ -1,4 +1,5 @@ use ratatui::{ + buffer::Buffer, layout::Rect, style::{Color, Style}, Frame, @@ -75,7 +76,7 @@ pub(crate) fn scrollbar_thumb_grab_offset( row: u16, ) -> Option<u16> { let thumb = scrollbar_thumb(metrics, track)?; - (row >= thumb.top && row < thumb.top + thumb.len).then_some(row - thumb.top) + (row >= thumb.top && row < thumb.top + thumb.len).then(|| row - thumb.top) } fn scrollbar_offset_from_thumb_top( @@ -132,8 +133,8 @@ pub(crate) fn scrollbar_offset_from_drag_row( scrollbar_offset_from_thumb_top(metrics, track, desired_top) } -pub(super) fn render_scrollbar( - frame: &mut Frame, +pub(crate) fn render_scrollbar_buffer( + buffer: &mut Buffer, metrics: crate::pane::ScrollMetrics, track: Rect, track_color: Color, @@ -148,19 +149,40 @@ pub(super) fn render_scrollbar( return; }; - let buf = frame.buffer_mut(); for y in track.y..track.y + track.height { - let cell = &mut buf[(track.x, y)]; + let cell = &mut buffer[(track.x, y)]; cell.set_symbol("▕"); cell.set_style(Style::default().fg(track_color)); } for y in thumb.top..thumb.top + thumb.len { - let cell = &mut buf[(track.x, y)]; + let cell = &mut buffer[(track.x, y)]; cell.set_symbol(thumb_symbol); cell.set_style(Style::default().fg(thumb_color)); } } +pub(crate) fn render_pane_scrollbar_buffer( + buffer: &mut Buffer, + metrics: crate::pane::ScrollMetrics, + track: Rect, + palette: &crate::app::state::Palette, + focused: bool, +) { + let (track_color, thumb_color, thumb_symbol) = if focused { + (palette.overlay0, palette.overlay1, "▐") + } else { + (palette.surface_dim, palette.overlay0, "▕") + }; + render_scrollbar_buffer( + buffer, + metrics, + track, + track_color, + thumb_color, + thumb_symbol, + ); +} + pub(super) fn render_pane_scrollbar( app: &AppState, frame: &mut Frame, @@ -173,19 +195,11 @@ pub(super) fn render_pane_scrollbar( let Some(track) = pane_scrollbar_rect(info) else { return; }; - - let (track_color, thumb_color, thumb_symbol) = if info.is_focused { - (app.palette.overlay0, app.palette.overlay1, "▐") - } else { - (app.palette.surface_dim, app.palette.overlay0, "▕") - }; - - render_scrollbar( - frame, + render_pane_scrollbar_buffer( + frame.buffer_mut(), metrics, track, - track_color, - thumb_color, - thumb_symbol, + &app.palette, + info.is_focused, ); } |
