mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-03 01:50:12 +00:00
refactor(channels): some renaming and refactoring the channels module (#503)
This commit is contained in:
parent
cd33151bac
commit
1a5fa5dd4c
@ -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},
|
||||
|
@ -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)]
|
||||
|
@ -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,
|
||||
};
|
||||
|
||||
|
@ -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,
|
||||
|
@ -1,4 +1,5 @@
|
||||
pub mod cable;
|
||||
pub mod entry;
|
||||
pub mod preview;
|
||||
pub mod prototypes;
|
||||
pub mod remote_control;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
@ -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<String>,
|
||||
cable_channels: Option<Cable>,
|
||||
|
@ -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;
|
||||
|
@ -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::*;
|
||||
|
@ -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;
|
||||
|
@ -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},
|
||||
|
@ -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};
|
||||
|
Loading…
x
Reference in New Issue
Block a user