diff --git a/Cargo.lock b/Cargo.lock index bc6b5eebb..c3798ede0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "arrayvec" @@ -450,6 +450,34 @@ version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +[[package]] +name = "linutil_core" +version = "0.1.0" +dependencies = [ + "ego-tree", + "include_dir", + "serde", + "tempdir", + "toml", + "which", +] + +[[package]] +name = "linutil_tui" +version = "0.1.0" +dependencies = [ + "chrono", + "clap", + "crossterm", + "ego-tree", + "linutil_core", + "oneshot", + "portable-pty", + "ratatui", + "tui-term", + "unicode-width", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -678,9 +706,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" dependencies = [ "bitflags 2.6.0", ] @@ -696,9 +724,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.36" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -972,26 +1000,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tui" -version = "0.1.0" -dependencies = [ - "chrono", - "clap", - "crossterm", - "ego-tree", - "include_dir", - "oneshot", - "portable-pty", - "ratatui", - "serde", - "tempdir", - "toml", - "tui-term", - "unicode-width", - "which", -] - [[package]] name = "tui-term" version = "0.1.13" @@ -1004,9 +1012,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-segmentation" diff --git a/Cargo.toml b/Cargo.toml index 1d10db9ea..551f0bc4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,34 +1,16 @@ -[package] -name = "tui" +[workspace.package] +license = "MIT" version = "0.1.0" -edition = "2021" -[dependencies] -clap = { version = "4.5.16", features = ["derive"] } -crossterm = "0.28.1" +[workspace.dependencies] ego-tree = "0.6.2" -oneshot = "0.1.8" -portable-pty = "0.8.1" -ratatui = "0.28.1" -tui-term = "0.1.12" -include_dir = "0.7.4" -tempdir = "0.3.7" -serde = { version = "1.0.205", features = ["derive"] } -toml = "0.8.19" -which = "6.0.3" -unicode-width = "0.1.13" - -[build-dependencies] -chrono = "0.4.33" - -[[bin]] -name = "linutil" -path = "src/main.rs" - +[workspace] +members = ["tui", "core"] +resolver = "2" [profile.release] -opt-level = 3 +opt-level = "z" debug = false lto = true codegen-units = 1 diff --git a/build.rs b/build.rs deleted file mode 100644 index ee7af0661..000000000 --- a/build.rs +++ /dev/null @@ -1,12 +0,0 @@ -fn main() { - // Rebuild program if any file in commands directory changes. - println!("cargo:rerun-if-changed=src/commands"); - // Rerun build script if any code is modified - println!("cargo:rerun-if-changed=src"); - - // Add current date as a variable to be displayed in the 'Linux Toolbox' text. - println!( - "cargo:rustc-env=BUILD_DATE={}", - chrono::Local::now().format("%Y-%m-%d") - ); -} diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 000000000..ebe1091df --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "linutil_core" +edition = "2021" +version.workspace = true +license.workspace = true + +[dependencies] +include_dir = "0.7.4" +tempdir = "0.3.7" +serde = { version = "1.0.205", features = ["derive"] } +toml = "0.8.19" +which = "6.0.3" +ego-tree = { workspace = true } diff --git a/src/tabs.rs b/core/src/inner.rs similarity index 87% rename from src/tabs.rs rename to core/src/inner.rs index 979693262..f23d21044 100644 --- a/src/tabs.rs +++ b/core/src/inner.rs @@ -1,7 +1,42 @@ -use crate::running_command::Command; +use crate::{Command, ListNode, Tab}; use ego_tree::{NodeMut, Tree}; +use include_dir::{include_dir, Dir}; use serde::Deserialize; use std::path::{Path, PathBuf}; +use tempdir::TempDir; + +const TAB_DATA: Dir = include_dir!("$CARGO_MANIFEST_DIR/../tabs"); + +pub fn get_tabs(validate: bool) -> Vec { + let tab_files = TabList::get_tabs(); + let tabs = tab_files.into_iter().map(|path| { + let directory = path.parent().unwrap().to_owned(); + let data = std::fs::read_to_string(path).expect("Failed to read tab data"); + let mut tab_data: TabEntry = toml::from_str(&data).expect("Failed to parse tab data"); + + if validate { + filter_entries(&mut tab_data.data); + } + (tab_data, directory) + }); + + let tabs: Vec = tabs + .map(|(TabEntry { name, data }, directory)| { + let mut tree = Tree::new(ListNode { + name: "root".to_string(), + command: Command::None, + }); + let mut root = tree.root_mut(); + create_directory(data, &mut root, &directory); + Tab { name, tree } + }) + .collect(); + + if tabs.is_empty() { + panic!("No tabs found"); + } + tabs +} #[derive(Deserialize)] struct TabList { @@ -79,49 +114,6 @@ enum SystemDataType { CommandExists, } -#[derive(Hash, Eq, PartialEq)] -pub struct Tab { - pub name: String, - pub tree: Tree, -} - -#[derive(Clone, Hash, Eq, PartialEq)] -pub struct ListNode { - pub name: String, - pub command: Command, -} - -pub fn get_tabs(command_dir: &Path, validate: bool) -> Vec { - let tab_files = TabList::get_tabs(command_dir); - let tabs = tab_files.into_iter().map(|path| { - let directory = path.parent().unwrap().to_owned(); - let data = std::fs::read_to_string(path).expect("Failed to read tab data"); - let mut tab_data: TabEntry = toml::from_str(&data).expect("Failed to parse tab data"); - - if validate { - filter_entries(&mut tab_data.data); - } - (tab_data, directory) - }); - - let tabs: Vec = tabs - .map(|(TabEntry { name, data }, directory)| { - let mut tree = Tree::new(ListNode { - name: "root".to_string(), - command: Command::None, - }); - let mut root = tree.root_mut(); - create_directory(data, &mut root, &directory); - Tab { name, tree } - }) - .collect(); - - if tabs.is_empty() { - panic!("No tabs found"); - } - tabs -} - fn filter_entries(entries: &mut Vec) { entries.retain_mut(|entry| { if !entry.is_supported() { @@ -176,15 +168,21 @@ fn create_directory(data: Vec, node: &mut NodeMut, command_dir: } } } + impl TabList { - fn get_tabs(command_dir: &Path) -> Vec { - let tab_files = std::fs::read_to_string(command_dir.join("tabs.toml")) - .expect("Failed to read tabs.toml"); + fn get_tabs() -> Vec { + let temp_dir = TempDir::new("linutil_scripts").unwrap().into_path(); + TAB_DATA + .extract(&temp_dir) + .expect("Failed to extract the saved directory"); + + let tab_files = + std::fs::read_to_string(temp_dir.join("tabs.toml")).expect("Failed to read tabs.toml"); let data: Self = toml::from_str(&tab_files).expect("Failed to parse tabs.toml"); data.directories - .into_iter() - .map(|path| command_dir.join(path).join("tab_data.toml")) + .iter() + .map(|path| temp_dir.join(path).join("tab_data.toml")) .collect() } } diff --git a/core/src/lib.rs b/core/src/lib.rs new file mode 100644 index 000000000..93ce0619e --- /dev/null +++ b/core/src/lib.rs @@ -0,0 +1,25 @@ +mod inner; + +use ego_tree::Tree; +use std::path::PathBuf; + +pub use inner::get_tabs; + +#[derive(Clone, Hash, Eq, PartialEq)] +pub enum Command { + Raw(String), + LocalFile(PathBuf), + None, // Directory +} + +#[derive(Clone, Hash, Eq, PartialEq)] +pub struct Tab { + pub name: String, + pub tree: Tree, +} + +#[derive(Clone, Hash, Eq, PartialEq)] +pub struct ListNode { + pub name: String, + pub command: Command, +} diff --git a/src/commands/applications-setup/alacritty-setup.sh b/tabs/applications-setup/alacritty-setup.sh similarity index 100% rename from src/commands/applications-setup/alacritty-setup.sh rename to tabs/applications-setup/alacritty-setup.sh diff --git a/src/commands/applications-setup/dwmtitus-setup.sh b/tabs/applications-setup/dwmtitus-setup.sh similarity index 100% rename from src/commands/applications-setup/dwmtitus-setup.sh rename to tabs/applications-setup/dwmtitus-setup.sh diff --git a/src/commands/applications-setup/kitty-setup.sh b/tabs/applications-setup/kitty-setup.sh similarity index 100% rename from src/commands/applications-setup/kitty-setup.sh rename to tabs/applications-setup/kitty-setup.sh diff --git a/src/commands/applications-setup/rofi-setup.sh b/tabs/applications-setup/rofi-setup.sh similarity index 100% rename from src/commands/applications-setup/rofi-setup.sh rename to tabs/applications-setup/rofi-setup.sh diff --git a/src/commands/applications-setup/tab_data.toml b/tabs/applications-setup/tab_data.toml similarity index 100% rename from src/commands/applications-setup/tab_data.toml rename to tabs/applications-setup/tab_data.toml diff --git a/src/commands/applications-setup/zsh-setup.sh b/tabs/applications-setup/zsh-setup.sh similarity index 100% rename from src/commands/applications-setup/zsh-setup.sh rename to tabs/applications-setup/zsh-setup.sh diff --git a/src/commands/common-script.sh b/tabs/common-script.sh similarity index 100% rename from src/commands/common-script.sh rename to tabs/common-script.sh diff --git a/src/commands/gaming/diablo-ii/d2r-loot-filters.sh b/tabs/gaming/diablo-ii/d2r-loot-filters.sh similarity index 100% rename from src/commands/gaming/diablo-ii/d2r-loot-filters.sh rename to tabs/gaming/diablo-ii/d2r-loot-filters.sh diff --git a/src/commands/gaming/tab_data.toml b/tabs/gaming/tab_data.toml similarity index 100% rename from src/commands/gaming/tab_data.toml rename to tabs/gaming/tab_data.toml diff --git a/src/commands/security/firewall-baselines.sh b/tabs/security/firewall-baselines.sh similarity index 100% rename from src/commands/security/firewall-baselines.sh rename to tabs/security/firewall-baselines.sh diff --git a/src/commands/security/tab_data.toml b/tabs/security/tab_data.toml similarity index 100% rename from src/commands/security/tab_data.toml rename to tabs/security/tab_data.toml diff --git a/src/commands/system-setup/1-compile-setup.sh b/tabs/system-setup/1-compile-setup.sh similarity index 100% rename from src/commands/system-setup/1-compile-setup.sh rename to tabs/system-setup/1-compile-setup.sh diff --git a/src/commands/system-setup/2-gaming-setup.sh b/tabs/system-setup/2-gaming-setup.sh similarity index 100% rename from src/commands/system-setup/2-gaming-setup.sh rename to tabs/system-setup/2-gaming-setup.sh diff --git a/src/commands/system-setup/3-global-theme.sh b/tabs/system-setup/3-global-theme.sh similarity index 100% rename from src/commands/system-setup/3-global-theme.sh rename to tabs/system-setup/3-global-theme.sh diff --git a/src/commands/system-setup/4-remove-snaps.sh b/tabs/system-setup/4-remove-snaps.sh similarity index 100% rename from src/commands/system-setup/4-remove-snaps.sh rename to tabs/system-setup/4-remove-snaps.sh diff --git a/src/commands/system-setup/arch/paru-setup.sh b/tabs/system-setup/arch/paru-setup.sh similarity index 100% rename from src/commands/system-setup/arch/paru-setup.sh rename to tabs/system-setup/arch/paru-setup.sh diff --git a/src/commands/system-setup/arch/server-setup.sh b/tabs/system-setup/arch/server-setup.sh similarity index 100% rename from src/commands/system-setup/arch/server-setup.sh rename to tabs/system-setup/arch/server-setup.sh diff --git a/src/commands/system-setup/arch/yay-setup.sh b/tabs/system-setup/arch/yay-setup.sh similarity index 100% rename from src/commands/system-setup/arch/yay-setup.sh rename to tabs/system-setup/arch/yay-setup.sh diff --git a/src/commands/system-setup/fedora/rpm-fusion-setup.sh b/tabs/system-setup/fedora/rpm-fusion-setup.sh similarity index 100% rename from src/commands/system-setup/fedora/rpm-fusion-setup.sh rename to tabs/system-setup/fedora/rpm-fusion-setup.sh diff --git a/src/commands/system-setup/system-update.sh b/tabs/system-setup/system-update.sh similarity index 100% rename from src/commands/system-setup/system-update.sh rename to tabs/system-setup/system-update.sh diff --git a/src/commands/system-setup/tab_data.toml b/tabs/system-setup/tab_data.toml similarity index 100% rename from src/commands/system-setup/tab_data.toml rename to tabs/system-setup/tab_data.toml diff --git a/src/commands/tabs.toml b/tabs/tabs.toml similarity index 100% rename from src/commands/tabs.toml rename to tabs/tabs.toml diff --git a/src/commands/test/lib.sh b/tabs/test/lib.sh similarity index 100% rename from src/commands/test/lib.sh rename to tabs/test/lib.sh diff --git a/src/commands/test/main.sh b/tabs/test/main.sh similarity index 100% rename from src/commands/test/main.sh rename to tabs/test/main.sh diff --git a/src/commands/utils/bluetooth-control.sh b/tabs/utils/bluetooth-control.sh similarity index 100% rename from src/commands/utils/bluetooth-control.sh rename to tabs/utils/bluetooth-control.sh diff --git a/src/commands/utils/monitor-control/auto_detect_displays.sh b/tabs/utils/monitor-control/auto_detect_displays.sh similarity index 100% rename from src/commands/utils/monitor-control/auto_detect_displays.sh rename to tabs/utils/monitor-control/auto_detect_displays.sh diff --git a/src/commands/utils/monitor-control/change_orientation.sh b/tabs/utils/monitor-control/change_orientation.sh similarity index 100% rename from src/commands/utils/monitor-control/change_orientation.sh rename to tabs/utils/monitor-control/change_orientation.sh diff --git a/src/commands/utils/monitor-control/disable_monitor.sh b/tabs/utils/monitor-control/disable_monitor.sh similarity index 100% rename from src/commands/utils/monitor-control/disable_monitor.sh rename to tabs/utils/monitor-control/disable_monitor.sh diff --git a/src/commands/utils/monitor-control/duplicate_displays.sh b/tabs/utils/monitor-control/duplicate_displays.sh similarity index 100% rename from src/commands/utils/monitor-control/duplicate_displays.sh rename to tabs/utils/monitor-control/duplicate_displays.sh diff --git a/src/commands/utils/monitor-control/enable_monitor.sh b/tabs/utils/monitor-control/enable_monitor.sh similarity index 100% rename from src/commands/utils/monitor-control/enable_monitor.sh rename to tabs/utils/monitor-control/enable_monitor.sh diff --git a/src/commands/utils/monitor-control/extend_displays.sh b/tabs/utils/monitor-control/extend_displays.sh similarity index 100% rename from src/commands/utils/monitor-control/extend_displays.sh rename to tabs/utils/monitor-control/extend_displays.sh diff --git a/src/commands/utils/monitor-control/manage_arrangement.sh b/tabs/utils/monitor-control/manage_arrangement.sh similarity index 100% rename from src/commands/utils/monitor-control/manage_arrangement.sh rename to tabs/utils/monitor-control/manage_arrangement.sh diff --git a/src/commands/utils/monitor-control/reset_scaling.sh b/tabs/utils/monitor-control/reset_scaling.sh similarity index 100% rename from src/commands/utils/monitor-control/reset_scaling.sh rename to tabs/utils/monitor-control/reset_scaling.sh diff --git a/src/commands/utils/monitor-control/scale_monitor.sh b/tabs/utils/monitor-control/scale_monitor.sh similarity index 100% rename from src/commands/utils/monitor-control/scale_monitor.sh rename to tabs/utils/monitor-control/scale_monitor.sh diff --git a/src/commands/utils/monitor-control/set_primary_monitor.sh b/tabs/utils/monitor-control/set_primary_monitor.sh similarity index 100% rename from src/commands/utils/monitor-control/set_primary_monitor.sh rename to tabs/utils/monitor-control/set_primary_monitor.sh diff --git a/src/commands/utils/monitor-control/set_resolutions.sh b/tabs/utils/monitor-control/set_resolutions.sh similarity index 100% rename from src/commands/utils/monitor-control/set_resolutions.sh rename to tabs/utils/monitor-control/set_resolutions.sh diff --git a/src/commands/utils/monitor-control/utility_functions.sh b/tabs/utils/monitor-control/utility_functions.sh similarity index 100% rename from src/commands/utils/monitor-control/utility_functions.sh rename to tabs/utils/monitor-control/utility_functions.sh diff --git a/src/commands/utils/numlock.sh b/tabs/utils/numlock.sh similarity index 100% rename from src/commands/utils/numlock.sh rename to tabs/utils/numlock.sh diff --git a/src/commands/utils/tab_data.toml b/tabs/utils/tab_data.toml similarity index 100% rename from src/commands/utils/tab_data.toml rename to tabs/utils/tab_data.toml diff --git a/src/commands/utils/wifi-control.sh b/tabs/utils/wifi-control.sh similarity index 100% rename from src/commands/utils/wifi-control.sh rename to tabs/utils/wifi-control.sh diff --git a/tui/Cargo.toml b/tui/Cargo.toml new file mode 100644 index 000000000..383dd1548 --- /dev/null +++ b/tui/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "linutil_tui" +edition = "2021" +version.workspace = true +license.workspace = true + +[dependencies] +clap = { version = "4.5.16", features = ["derive"] } +crossterm = "0.28.1" +ego-tree = { workspace = true } +oneshot = "0.1.8" +portable-pty = "0.8.1" +ratatui = "0.28.1" +tui-term = "0.1.12" +unicode-width = "0.1.13" +linutil_core = { path = "../core" } + +[build-dependencies] +chrono = "0.4.33" + +[[bin]] +name = "linutil" +path = "src/main.rs" diff --git a/tui/build.rs b/tui/build.rs new file mode 100644 index 000000000..121931c16 --- /dev/null +++ b/tui/build.rs @@ -0,0 +1,7 @@ +fn main() { + // Add current date as a variable to be displayed in the 'Linux Toolbox' text. + println!( + "cargo:rustc-env=BUILD_DATE={}", + chrono::Local::now().format("%Y-%m-%d") + ); +} diff --git a/src/filter.rs b/tui/src/filter.rs similarity index 98% rename from src/filter.rs rename to tui/src/filter.rs index 89d15a70f..e6ff2cc2b 100644 --- a/src/filter.rs +++ b/tui/src/filter.rs @@ -1,6 +1,7 @@ -use crate::{state::ListEntry, tabs::Tab, theme::Theme}; +use crate::{state::ListEntry, theme::Theme}; use crossterm::event::{KeyCode, KeyEvent}; use ego_tree::NodeId; +use linutil_core::Tab; use ratatui::{ layout::{Position, Rect}, style::Style, diff --git a/src/float.rs b/tui/src/float.rs similarity index 100% rename from src/float.rs rename to tui/src/float.rs diff --git a/src/floating_text.rs b/tui/src/floating_text.rs similarity index 99% rename from src/floating_text.rs rename to tui/src/floating_text.rs index e1d8deb35..ccf796ee1 100644 --- a/src/floating_text.rs +++ b/tui/src/floating_text.rs @@ -1,9 +1,9 @@ use crate::{ float::FloatContent, hint::{Shortcut, ShortcutList}, - running_command::Command, }; use crossterm::event::{KeyCode, KeyEvent}; +use linutil_core::Command; use ratatui::{ layout::Rect, style::{Style, Stylize}, diff --git a/src/hint.rs b/tui/src/hint.rs similarity index 100% rename from src/hint.rs rename to tui/src/hint.rs diff --git a/src/main.rs b/tui/src/main.rs similarity index 85% rename from src/main.rs rename to tui/src/main.rs index 1759435cc..4355a9107 100644 --- a/src/main.rs +++ b/tui/src/main.rs @@ -4,7 +4,6 @@ mod floating_text; mod hint; mod running_command; pub mod state; -mod tabs; mod theme; use std::{ @@ -21,13 +20,11 @@ use crossterm::{ terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, ExecutableCommand, }; -use include_dir::include_dir; use ratatui::{ backend::{Backend, CrosstermBackend}, Terminal, }; use state::AppState; -use tempdir::TempDir; // Linux utility toolbox #[derive(Debug, Parser)] @@ -44,13 +41,7 @@ struct Args { fn main() -> std::io::Result<()> { let args = Args::parse(); - let commands_dir = include_dir!("src/commands"); - let temp_dir: TempDir = TempDir::new("linutil_scripts").unwrap(); - commands_dir - .extract(temp_dir.path()) - .expect("Failed to extract the saved directory"); - - let mut state = AppState::new(args.theme, temp_dir.path(), args.override_validation); + let mut state = AppState::new(args.theme, args.override_validation); stdout().execute(EnterAlternateScreen)?; enable_raw_mode()?; diff --git a/src/running_command.rs b/tui/src/running_command.rs similarity index 98% rename from src/running_command.rs rename to tui/src/running_command.rs index 0840f189b..d8df34028 100644 --- a/src/running_command.rs +++ b/tui/src/running_command.rs @@ -3,6 +3,7 @@ use crate::{ hint::{Shortcut, ShortcutList}, }; use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; +use linutil_core::Command; use oneshot::{channel, Receiver}; use portable_pty::{ ChildKiller, CommandBuilder, ExitStatus, MasterPty, NativePtySystem, PtySize, PtySystem, @@ -16,7 +17,6 @@ use ratatui::{ }; use std::{ io::Write, - path::PathBuf, sync::{Arc, Mutex}, thread::JoinHandle, }; @@ -25,13 +25,6 @@ use tui_term::{ widget::PseudoTerminal, }; -#[derive(Clone, Hash, Eq, PartialEq)] -pub enum Command { - Raw(String), - LocalFile(PathBuf), - None, // Directory -} - pub struct RunningCommand { /// A buffer to save all the command output (accumulates, until the command exits) buffer: Arc>>, diff --git a/src/state.rs b/tui/src/state.rs similarity index 98% rename from src/state.rs rename to tui/src/state.rs index 6bb4f5f33..267e6769c 100644 --- a/src/state.rs +++ b/tui/src/state.rs @@ -3,12 +3,12 @@ use crate::{ float::{Float, FloatContent}, floating_text::FloatingText, hint::{draw_shortcuts, SHORTCUT_LINES}, - running_command::{Command, RunningCommand}, - tabs::{ListNode, Tab}, + running_command::RunningCommand, theme::Theme, }; use crossterm::event::{KeyCode, KeyEvent, KeyEventKind}; use ego_tree::NodeId; +use linutil_core::{Command, ListNode, Tab}; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout}, style::{Style, Stylize}, @@ -16,7 +16,6 @@ use ratatui::{ widgets::{Block, Borders, List, ListState, Paragraph}, Frame, }; -use std::path::Path; pub struct AppState { /// Selected theme @@ -50,8 +49,8 @@ pub struct ListEntry { } impl AppState { - pub fn new(theme: Theme, temp_path: &Path, override_validation: bool) -> Self { - let tabs = crate::tabs::get_tabs(temp_path, !override_validation); + pub fn new(theme: Theme, override_validation: bool) -> Self { + let tabs = linutil_core::get_tabs(!override_validation); let root_id = tabs[0].tree.root().id(); let mut state = Self { theme, diff --git a/src/theme.rs b/tui/src/theme.rs similarity index 100% rename from src/theme.rs rename to tui/src/theme.rs