From 83a723e66a30f38c25013648eddd807046cad0d8 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Mon, 13 Apr 2026 19:57:39 +0700 Subject: [PATCH] Remove scroll wheel code from TUI --- src/bin/repo.rs | 68 +++---------------------------------------------- 1 file changed, 3 insertions(+), 65 deletions(-) diff --git a/src/bin/repo.rs b/src/bin/repo.rs index 954bad4d9..afe639b91 100644 --- a/src/bin/repo.rs +++ b/src/bin/repo.rs @@ -13,7 +13,7 @@ use cookbook::recipe::{CookRecipe, recipes_flatten_package_names, recipes_mark_a use cookbook::{Error, staged_pkg}; use pkg::{PackageName, PackageState}; use ratatui::Terminal; -use ratatui::layout::{Constraint, Direction, Layout, Position, Rect}; +use ratatui::layout::{Constraint, Direction, Layout, Rect}; use ratatui::prelude::TermionBackend; use ratatui::style::{Color, Style}; use ratatui::text::{Line, Span, Text}; @@ -30,7 +30,7 @@ use std::sync::{Arc, OnceLock, mpsc}; use std::time::{Duration, Instant}; use std::{cmp, env, fs}; use std::{process, thread}; -use termion::event::{Event, Key, MouseEvent}; +use termion::event::{Event, Key}; use termion::input::TermRead; use termion::raw::IntoRawMode; use termion::screen::IntoAlternateScreen; @@ -976,15 +976,10 @@ struct TuiApp { log_scroll: usize, log_view_job: JobType, auto_scroll: bool, - fetch_scroll: usize, cook_scroll: usize, - cook_auto_scroll: bool, cook_list_state: ListState, fetch_complete: bool, cook_complete: bool, - fetch_panel_rect: Option, - cook_panel_rect: Option, - log_panel_rect: Option, prompt: Option, dump_logs_anyway: bool, dump_logs_on_exit: Option<(PackageName, String)>, @@ -1008,15 +1003,10 @@ impl TuiApp { log_scroll: 0, auto_scroll: true, log_view_job: JobType::Fetch, - fetch_scroll: 0, cook_scroll: 0, - cook_auto_scroll: true, cook_list_state: ListState::default(), fetch_complete: false, cook_complete: false, - fetch_panel_rect: None, - cook_panel_rect: None, - log_panel_rect: None, prompt: None, dump_logs_anyway: false, dump_logs_on_exit: None, @@ -1383,7 +1373,6 @@ fn run_tui_cook(config: CliConfig, recipes: Vec) -> Result) -> Result) -> Result 0 { - let max_offset = total_items.saturating_sub(panel_height as usize); - if *app.cook_list_state.offset_mut() > max_offset { - *app.cook_list_state.offset_mut() = max_offset; - } - } else { - *app.cook_list_state.offset_mut() = 0; - } } let cook_items: Vec = cook_items[app.cook_scroll..].into(); let cook_chunk = chunks[if app.fetch_complete { 0 } else { 1 }]; @@ -1721,46 +1699,6 @@ fn handle_main_event(app: &mut TuiApp, event: &Event) { } _ => {} }, - - //FIXME: This does nothing, it seems ratatui handles this itself magically - Event::Mouse(mouse_event) => { - match mouse_event { - MouseEvent::Press(termion::event::MouseButton::WheelUp, x, y) => { - // termion is 1-based, ratatui rects are 0-based - let pos = Position { - x: x.saturating_sub(1), - y: y.saturating_sub(1), - }; - - if app.fetch_panel_rect.map_or(false, |r| r.contains(pos)) { - app.fetch_scroll = app.fetch_scroll.saturating_sub(1); - } else if app.cook_panel_rect.map_or(false, |r| r.contains(pos)) { - app.cook_scroll = app.cook_scroll.saturating_sub(1); - app.cook_auto_scroll = false; - } else if app.log_panel_rect.map_or(false, |r| r.contains(pos)) { - app.auto_scroll = false; - app.log_scroll = app.log_scroll.saturating_sub(1); - } - } - MouseEvent::Press(termion::event::MouseButton::WheelDown, x, y) => { - let pos = Position { - x: x.saturating_sub(1), - y: y.saturating_sub(1), - }; - - if app.fetch_panel_rect.map_or(false, |r| r.contains(pos)) { - app.fetch_scroll = app.fetch_scroll.saturating_add(1); - } else if app.cook_panel_rect.map_or(false, |r| r.contains(pos)) { - app.cook_scroll = app.cook_scroll.saturating_add(1); - app.cook_auto_scroll = false; - } else if app.log_panel_rect.map_or(false, |r| r.contains(pos)) { - app.auto_scroll = false; - app.log_scroll = app.log_scroll.saturating_add(1); - } - } - _ => {} - } - } _ => {} } }