diff --git a/benches/main/ui.rs b/benches/main/ui.rs index 2d5ce7c..bb0c661 100644 --- a/benches/main/ui.rs +++ b/benches/main/ui.rs @@ -8,12 +8,11 @@ use ratatui::prelude::{Line, Style}; use ratatui::style::Color; use ratatui::widgets::{Block, BorderType, Borders, ListDirection, Padding}; use ratatui::Terminal; -use television::channels::cable::prototypes::Cable; use television::{ action::Action, channels::{ - cable::prototypes::ChannelPrototype, entry::{into_ranges, Entry}, + prototypes::{Cable, ChannelPrototype}, }, config::{Config, ConfigEnv}, screen::{colors::ResultsColorscheme, results::build_results_list}, diff --git a/television/app.rs b/television/app.rs index f0fbee4..be2c481 100644 --- a/television/app.rs +++ b/television/app.rs @@ -4,16 +4,17 @@ use anyhow::Result; use tokio::sync::mpsc; use tracing::{debug, trace}; -use crate::channels::cable::prototypes::{Cable, ChannelPrototype}; -use crate::channels::entry::Entry; -use crate::config::{default_tick_rate, Config}; -use crate::keymap::Keymap; -use crate::render::UiState; -use crate::television::{Mode, Television}; use crate::{ action::Action, + channels::{ + entry::Entry, + prototypes::{Cable, ChannelPrototype}, + }, + config::{default_tick_rate, Config}, event::{Event, EventLoop, Key}, - render::{render, RenderingTask}, + keymap::Keymap, + render::{render, RenderingTask, UiState}, + television::{Mode, Television}, }; #[allow(clippy::struct_excessive_bools)] diff --git a/television/cable.rs b/television/cable.rs index b615107..c8cf2c7 100644 --- a/television/cable.rs +++ b/television/cable.rs @@ -6,7 +6,7 @@ use anyhow::Result; use tracing::{debug, error}; use crate::{ - channels::cable::prototypes::{Cable, ChannelPrototype}, + channels::prototypes::{Cable, ChannelPrototype}, config::get_config_dir, }; diff --git a/television/channels/cable.rs b/television/channels/cable.rs index 4eeb1af..d9810d4 100644 --- a/television/channels/cable.rs +++ b/television/channels/cable.rs @@ -2,17 +2,18 @@ use std::collections::HashSet; use std::io::{BufRead, BufReader}; use std::process::Stdio; -use prototypes::{ChannelPrototype, DEFAULT_DELIMITER}; use rustc_hash::{FxBuildHasher, FxHashSet}; use tracing::debug; -use crate::channels::{entry::Entry, preview::PreviewCommand}; +use crate::channels::{ + entry::Entry, + preview::PreviewCommand, + prototypes::{ChannelPrototype, DEFAULT_DELIMITER}, +}; use crate::matcher::Matcher; use crate::matcher::{config::Config, injector::Injector}; use crate::utils::command::shell_command; -pub mod prototypes; - #[allow(dead_code)] pub struct Channel { pub name: String, diff --git a/television/channels/mod.rs b/television/channels/mod.rs index 48981b8..5d20f43 100644 --- a/television/channels/mod.rs +++ b/television/channels/mod.rs @@ -1,4 +1,5 @@ pub mod cable; pub mod entry; pub mod preview; +pub mod prototypes; pub mod remote_control; diff --git a/television/channels/preview.rs b/television/channels/preview.rs index 5b270c9..5c7f48a 100644 --- a/television/channels/preview.rs +++ b/television/channels/preview.rs @@ -1,7 +1,9 @@ use std::fmt::Display; -use super::{cable::prototypes::DEFAULT_DELIMITER, entry::Entry}; -use crate::channels::cable::prototypes::ChannelPrototype; +use crate::channels::{ + entry::Entry, + prototypes::{ChannelPrototype, DEFAULT_DELIMITER}, +}; use lazy_regex::{regex, Lazy, Regex}; use tracing::debug; diff --git a/television/channels/cable/prototypes.rs b/television/channels/prototypes.rs similarity index 95% rename from television/channels/cable/prototypes.rs rename to television/channels/prototypes.rs index 2568626..05166fc 100644 --- a/television/channels/cable/prototypes.rs +++ b/television/channels/prototypes.rs @@ -6,7 +6,7 @@ use std::{ use crate::{cable::CableSpec, channels::preview::PreviewCommand}; -/// A prototype for a cable channel. +/// A prototype for cable channels. /// /// This can be seen as a cable channel specification, which is used to /// create a cable channel. @@ -122,7 +122,7 @@ impl Display for ChannelPrototype { } } -/// A neat `HashMap` of cable channel prototypes indexed by their name. +/// A neat `HashMap` of channel prototypes indexed by their name. /// /// This is used to store cable channel prototypes throughout the application /// in a way that facilitates answering questions like "what's the prototype @@ -142,12 +142,12 @@ impl Deref for Cable { /// application. #[cfg(unix)] const DEFAULT_CABLE_CHANNELS_FILE: &str = - include_str!("../../../cable/unix-channels.toml"); + include_str!("../../cable/unix-channels.toml"); /// A default cable channels specification that is compiled into the /// application. #[cfg(not(unix))] const DEFAULT_CABLE_CHANNELS_FILE: &str = - include_str!("../../../cable/windows-channels.toml"); + include_str!("../../cable/windows-channels.toml"); impl Default for Cable { /// Fallback to the default cable channels specification (the template file diff --git a/television/channels/remote_control.rs b/television/channels/remote_control.rs index 0bcbeb7..ae5b855 100644 --- a/television/channels/remote_control.rs +++ b/television/channels/remote_control.rs @@ -1,11 +1,13 @@ -use crate::channels::cable::prototypes::Cable; -use crate::channels::entry::Entry; -use crate::matcher::{config::Config, Matcher}; +use crate::{ + channels::{ + entry::Entry, + prototypes::{Cable, ChannelPrototype}, + }, + matcher::{config::Config, Matcher}, +}; use anyhow::Result; use devicons::FileIcon; -use super::cable::prototypes::ChannelPrototype; - pub struct RemoteControl { matcher: Matcher, cable_channels: Option, diff --git a/television/cli/mod.rs b/television/cli/mod.rs index 8307d14..4b87808 100644 --- a/television/cli/mod.rs +++ b/television/cli/mod.rs @@ -4,13 +4,14 @@ use std::path::Path; use anyhow::{anyhow, Result}; use tracing::debug; -use crate::channels::cable::prototypes::{Cable, ChannelPrototype}; -use crate::channels::preview::PreviewCommand; -use crate::cli::args::{Cli, Command}; -use crate::config::{KeyBindings, DEFAULT_CHANNEL}; use crate::{ cable, - config::{get_config_dir, get_data_dir}, + channels::{ + preview::PreviewCommand, + prototypes::{Cable, ChannelPrototype}, + }, + cli::args::{Cli, Command}, + config::{get_config_dir, get_data_dir, KeyBindings, DEFAULT_CHANNEL}, }; pub mod args; diff --git a/television/main.rs b/television/main.rs index d032eff..57713e7 100644 --- a/television/main.rs +++ b/television/main.rs @@ -5,9 +5,11 @@ use std::process::exit; use anyhow::Result; use clap::Parser; -use television::cable; -use television::channels::cable::prototypes::{Cable, ChannelPrototype}; -use television::utils::clipboard::CLIPBOARD; +use television::{ + cable, + channels::prototypes::{Cable, ChannelPrototype}, + utils::clipboard::CLIPBOARD, +}; use tracing::{debug, error, info}; use television::app::{App, AppOptions}; @@ -177,7 +179,7 @@ pub fn determine_channel( mod tests { use rustc_hash::FxHashMap; use television::{ - cable::load_cable, channels::cable::prototypes::ChannelPrototype, + cable::load_cable, channels::prototypes::ChannelPrototype, }; use super::*; diff --git a/television/preview/previewer.rs b/television/preview/previewer.rs index e9576d0..0ba5d0f 100644 --- a/television/preview/previewer.rs +++ b/television/preview/previewer.rs @@ -1,9 +1,9 @@ -use crate::channels::cable::prototypes::ChannelPrototype; -use crate::preview::{Preview, PreviewContent}; -use crate::utils::command::shell_command; use crate::{ - channels::{entry::Entry, preview::PreviewCommand}, - preview::cache::PreviewCache, + channels::{ + entry::Entry, preview::PreviewCommand, prototypes::ChannelPrototype, + }, + preview::{cache::PreviewCache, Preview, PreviewContent}, + utils::command::shell_command, }; use parking_lot::Mutex; use rustc_hash::FxHashSet; diff --git a/television/television.rs b/television/television.rs index cb52db8..1c30cda 100644 --- a/television/television.rs +++ b/television/television.rs @@ -1,11 +1,9 @@ use crate::{ action::Action, channels::{ - cable::{ - prototypes::{Cable, ChannelPrototype}, - Channel as CableChannel, - }, + cable::Channel as CableChannel, entry::Entry, + prototypes::{Cable, ChannelPrototype}, remote_control::RemoteControl, }, config::{Config, Theme}, diff --git a/tests/app.rs b/tests/app.rs index e96170e..35e8854 100644 --- a/tests/app.rs +++ b/tests/app.rs @@ -3,7 +3,7 @@ use std::{collections::HashSet, path::PathBuf, time::Duration}; use television::{ action::Action, app::{App, AppOptions}, - channels::cable::prototypes::{Cable, ChannelPrototype}, + channels::prototypes::{Cable, ChannelPrototype}, config::default_config_from_file, }; use tokio::{task::JoinHandle, time::timeout};