aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-14 02:50:00 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-14 02:50:00 +0300
commited4253d6031c9a3b12ddd6dfc7d7bf39480ae761 (patch)
tree315cea3ee7b5ad3a7c3f9fb31272064a0eed5dd2 /src/ui
parent287bf51640f8e1bed227cb27d93377d962851196 (diff)
feat: add tmux-style mouse capture config
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/sidebar.rs2
-rw-r--r--src/ui/tabs.rs35
2 files changed, 31 insertions, 6 deletions
diff --git a/src/ui/sidebar.rs b/src/ui/sidebar.rs
index 8a104dba..f10c4241 100644
--- a/src/ui/sidebar.rs
+++ b/src/ui/sidebar.rs
@@ -716,7 +716,7 @@ fn render_workspace_list(app: &AppState, frame: &mut Frame, area: Rect, is_navig
render_scrollbar(frame, metrics, track, p.surface_dim, p.overlay0, "▕");
}
- if list_bottom > area.y {
+ if app.mouse_capture && list_bottom > area.y {
let new_rect = app.sidebar_new_button_rect();
frame.render_widget(
Paragraph::new(Span::styled("new", Style::default().fg(p.overlay0))),
diff --git a/src/ui/tabs.rs b/src/ui/tabs.rs
index a6ce0e68..ce859432 100644
--- a/src/ui/tabs.rs
+++ b/src/ui/tabs.rs
@@ -98,11 +98,28 @@ pub(crate) fn compute_tab_bar_view(
area: Rect,
current_scroll: usize,
follow_active: bool,
+ mouse_chrome: bool,
) -> TabBarView {
if area.width == 0 || area.height == 0 {
return TabBarView::default();
}
+ if !mouse_chrome {
+ let max_scroll = max_tab_scroll(ws, area);
+ let scroll = if follow_active {
+ centered_tab_scroll(ws, area).min(max_scroll)
+ } else {
+ current_scroll.min(max_scroll)
+ };
+ return TabBarView {
+ scroll,
+ tab_hit_areas: layout_tab_hit_areas(ws, area, scroll),
+ scroll_left_hit_area: Rect::default(),
+ scroll_right_hit_area: Rect::default(),
+ new_tab_hit_area: Rect::default(),
+ };
+ }
+
let area_right = area.x + area.width;
let all_tabs_area = Rect::new(
area.x,
@@ -253,7 +270,7 @@ pub(super) fn render_tab_bar(app: &AppState, frame: &mut Frame, area: Rect) {
let can_scroll_right = app.view.tab_scroll_right_hit_area.width > 0
&& last_visible_idx.is_some_and(|idx| idx + 1 < ws.tabs.len());
- if app.view.tab_scroll_left_hit_area.width > 0 {
+ if app.mouse_capture && app.view.tab_scroll_left_hit_area.width > 0 {
let style = if can_scroll_left {
Style::default().fg(p.overlay1).bg(p.surface0)
} else {
@@ -268,7 +285,7 @@ pub(super) fn render_tab_bar(app: &AppState, frame: &mut Frame, area: Rect) {
);
}
- if app.view.tab_scroll_right_hit_area.width > 0 {
+ if app.mouse_capture && app.view.tab_scroll_right_hit_area.width > 0 {
let style = if can_scroll_right {
Style::default().fg(p.overlay1).bg(p.surface0)
} else {
@@ -330,7 +347,7 @@ pub(super) fn render_tab_bar(app: &AppState, frame: &mut Frame, area: Rect) {
}
}
- if app.view.new_tab_hit_area.width > 0 {
+ if app.mouse_capture && app.view.new_tab_hit_area.width > 0 {
frame.render_widget(
Paragraph::new(" + ").style(Style::default().fg(p.overlay1)),
app.view.new_tab_hit_area,
@@ -338,7 +355,11 @@ pub(super) fn render_tab_bar(app: &AppState, frame: &mut Frame, area: Rect) {
}
if first_visible_idx.is_some_and(|idx| idx > 0) {
- let x = app.view.tab_scroll_left_hit_area.x + app.view.tab_scroll_left_hit_area.width;
+ let x = if app.mouse_capture && app.view.tab_scroll_left_hit_area.width > 0 {
+ app.view.tab_scroll_left_hit_area.x + app.view.tab_scroll_left_hit_area.width
+ } else {
+ area.x
+ };
if x < area.x + area.width {
frame.buffer_mut()[(x, area.y)]
.set_symbol("…")
@@ -346,7 +367,11 @@ pub(super) fn render_tab_bar(app: &AppState, frame: &mut Frame, area: Rect) {
}
}
if last_visible_idx.is_some_and(|idx| idx + 1 < ws.tabs.len()) {
- let x = app.view.tab_scroll_right_hit_area.x.saturating_sub(1);
+ let x = if app.mouse_capture && app.view.tab_scroll_right_hit_area.width > 0 {
+ app.view.tab_scroll_right_hit_area.x.saturating_sub(1)
+ } else {
+ area.x + area.width.saturating_sub(1)
+ };
if x >= area.x && x < area.x + area.width {
frame.buffer_mut()[(x, area.y)]
.set_symbol("…")