From 272f098884c8ea02527aa472c51ffd53ee78ea12 Mon Sep 17 00:00:00 2001 From: vasilito Date: Fri, 19 Jun 2026 19:57:36 +0300 Subject: [PATCH] =?UTF-8?q?tlc:=20cleanup=20=E2=80=94=20remove=20dead=20co?= =?UTF-8?q?de,=20debug=20logging,=20fix=20import=20placement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove two dead pub fn render free functions (render.rs + mod.rs) - Remove debug_raw_event/should_log_raw_event (always-on /tmp logging) - Move use std::sync::Arc to top of dispatch.rs - Fix unused imports from dead code removal --- local/recipes/tui/tlc/source/src/app.rs | 43 +------------------ .../tlc/source/src/filemanager/dispatch.rs | 6 +-- .../tui/tlc/source/src/filemanager/mod.rs | 7 +-- .../tui/tlc/source/src/filemanager/render.rs | 5 --- 4 files changed, 6 insertions(+), 55 deletions(-) diff --git a/local/recipes/tui/tlc/source/src/app.rs b/local/recipes/tui/tlc/source/src/app.rs index 023997c30e..712a75dab5 100644 --- a/local/recipes/tui/tlc/source/src/app.rs +++ b/local/recipes/tui/tlc/source/src/app.rs @@ -9,7 +9,6 @@ //! 4. On `Cmd::Quit` (or terminal EOF), tear down cleanly. use std::path::PathBuf; -use std::io::Write; use std::time::Duration; use anyhow::Result; @@ -70,7 +69,7 @@ impl Application { let stdin = std::io::stdin(); let mut events = stdin.lock().events_and_raw(); - let (event, raw) = match events.next() { + let (event, _raw) = match events.next() { Some(Ok(pair)) => pair, Some(Err(e)) => { log::debug!("input error: {e}"); @@ -78,9 +77,6 @@ impl Application { } None => break, }; - if should_log_raw_event(&event) { - debug_raw_event(&event, &raw); - } let tk = match event { TermEvent::Key(k) => k, TermEvent::Mouse(_) => continue, @@ -439,43 +435,6 @@ where } } -fn should_log_raw_event(event: &TermEvent) -> bool { - matches!( - event, - TermEvent::Key( - TermKey::ShiftLeft - | TermKey::AltLeft - | TermKey::CtrlLeft - | TermKey::ShiftRight - | TermKey::AltRight - | TermKey::CtrlRight - | TermKey::ShiftUp - | TermKey::AltUp - | TermKey::CtrlUp - | TermKey::ShiftDown - | TermKey::AltDown - | TermKey::CtrlDown - | TermKey::CtrlHome - | TermKey::CtrlEnd - | TermKey::BackTab - ) | TermEvent::Unsupported(_) - ) -} - -fn debug_raw_event(event: &TermEvent, raw: &[u8]) { - let hex = raw - .iter() - .map(|b| format!("{b:02X}")) - .collect::>() - .join(" "); - if let Ok(mut f) = std::fs::OpenOptions::new() - .create(true) - .append(true) - .open("/tmp/tlc-debug.log") - { - let _ = writeln!(f, "{event:?} raw=[{hex}]"); - } -} /// CLI argument struct (re-exported at crate root). #[derive(Debug, Clone, Default)] diff --git a/local/recipes/tui/tlc/source/src/filemanager/dispatch.rs b/local/recipes/tui/tlc/source/src/filemanager/dispatch.rs index 2de5ff5910..0cf496a138 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/dispatch.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/dispatch.rs @@ -7,6 +7,8 @@ //! outcome. The Ctrl-X chord entry point, [`dispatch_ctrl_x_followup`], //! resolves the second key and re-dispatches the chosen [`Cmd`]. +use std::sync::Arc; + use anyhow::Result; use crate::filemanager::{ @@ -683,6 +685,4 @@ impl FileManager { } consumed } -} - -use std::sync::Arc; \ No newline at end of file +} \ No newline at end of file diff --git a/local/recipes/tui/tlc/source/src/filemanager/mod.rs b/local/recipes/tui/tlc/source/src/filemanager/mod.rs index c43de3b9bf..8c8506b130 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/mod.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/mod.rs @@ -56,7 +56,9 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use anyhow::Result; +#[cfg(test)] use ratatui::layout::Rect; +#[cfg(test)] use ratatui::Frame; use crate::config::{Config, FilemanagerConfig}; @@ -642,11 +644,6 @@ fn panel_footer_text(panel: &Panel) -> String { format_utils::panel_footer_text(panel) } -/// Render the file manager into a frame at the given area. -pub fn render(fm: &mut FileManager, frame: &mut Frame, area: Rect) { - fm.render(frame, area); -} - /// Re-export the panel sort field at module level. pub use self::panel::SortField as PanelSortField; diff --git a/local/recipes/tui/tlc/source/src/filemanager/render.rs b/local/recipes/tui/tlc/source/src/filemanager/render.rs index d7950272fe..7161bb1dcf 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/render.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/render.rs @@ -22,11 +22,6 @@ use crate::vfs::local::Entry; use super::filehighlight; use super::panel; -/// Render the file manager to a ratatui frame. -pub fn render(fm: &mut FileManager, frame: &mut Frame, area: Rect) { - fm.render(frame, area); -} - impl FileManager { /// Render the file manager to a ratatui frame. pub fn render(&mut self, frame: &mut Frame, area: Rect) {