mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-07 12:05:34 +00:00
chore(rust): update rust edition to 2024 and version to 1.87 (#528)
This commit is contained in:
parent
aac7e4dc45
commit
738fe08fbb
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "television"
|
name = "television"
|
||||||
version = "0.11.9"
|
version = "0.11.9"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
description = "A cross-platform, fast and extensible general purpose fuzzy finder TUI."
|
description = "A cross-platform, fast and extensible general purpose fuzzy finder TUI."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Alexandre Pasmantier <alex.pasmant@gmail.com>"]
|
authors = ["Alexandre Pasmantier <alex.pasmant@gmail.com>"]
|
||||||
@ -24,7 +24,7 @@ include = [
|
|||||||
"build.rs",
|
"build.rs",
|
||||||
"man",
|
"man",
|
||||||
]
|
]
|
||||||
rust-version = "1.83"
|
rust-version = "1.87"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
use criterion::criterion_group;
|
use criterion::criterion_group;
|
||||||
use criterion::{black_box, Criterion};
|
use criterion::{Criterion, black_box};
|
||||||
use devicons::FileIcon;
|
use devicons::FileIcon;
|
||||||
|
use ratatui::Terminal;
|
||||||
use ratatui::backend::TestBackend;
|
use ratatui::backend::TestBackend;
|
||||||
use ratatui::layout::Alignment;
|
use ratatui::layout::Alignment;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use ratatui::prelude::{Line, Style};
|
use ratatui::prelude::{Line, Style};
|
||||||
use ratatui::style::Color;
|
use ratatui::style::Color;
|
||||||
use ratatui::widgets::{Block, BorderType, Borders, ListDirection, Padding};
|
use ratatui::widgets::{Block, BorderType, Borders, ListDirection, Padding};
|
||||||
use ratatui::Terminal;
|
|
||||||
use television::{
|
use television::{
|
||||||
action::Action,
|
action::Action,
|
||||||
channels::{
|
channels::{
|
||||||
entry::{into_ranges, Entry},
|
entry::{Entry, into_ranges},
|
||||||
prototypes::Cable,
|
prototypes::Cable,
|
||||||
},
|
},
|
||||||
config::{Config, ConfigEnv},
|
config::{Config, ConfigEnv},
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.83"
|
channel = "1.87"
|
||||||
components = ["rustfmt", "clippy", "rust-analyzer"]
|
components = ["rustfmt", "clippy", "rust-analyzer"]
|
||||||
|
@ -10,10 +10,10 @@ use crate::{
|
|||||||
entry::Entry,
|
entry::Entry,
|
||||||
prototypes::{Cable, ChannelPrototype},
|
prototypes::{Cable, ChannelPrototype},
|
||||||
},
|
},
|
||||||
config::{default_tick_rate, Config},
|
config::{Config, default_tick_rate},
|
||||||
event::{Event, EventLoop, Key},
|
event::{Event, EventLoop, Key},
|
||||||
keymap::Keymap,
|
keymap::Keymap,
|
||||||
render::{render, RenderingTask, UiState},
|
render::{RenderingTask, UiState, render},
|
||||||
television::{Mode, Television},
|
television::{Mode, Television},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ impl App {
|
|||||||
// forward action to the television handler
|
// forward action to the television handler
|
||||||
if let Some(action) = self.television.update(&action)? {
|
if let Some(action) = self.television.update(&action)? {
|
||||||
self.action_tx.send(action)?;
|
self.action_tx.send(action)?;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(ActionOutcome::None)
|
Ok(ActionOutcome::None)
|
||||||
|
@ -104,10 +104,10 @@ where
|
|||||||
let p = p.as_ref();
|
let p = p.as_ref();
|
||||||
p.file_stem()
|
p.file_stem()
|
||||||
.and_then(|s| s.to_str())
|
.and_then(|s| s.to_str())
|
||||||
.map_or(false, |s| s.ends_with(CABLE_FILE_NAME_SUFFIX))
|
.map_or_else(|| false, |s| s.ends_with(CABLE_FILE_NAME_SUFFIX))
|
||||||
&& p.extension()
|
&& p.extension()
|
||||||
.and_then(|e| e.to_str())
|
.and_then(|e| e.to_str())
|
||||||
.map_or(false, |e| e.to_lowercase() == CABLE_FILE_FORMAT)
|
.map_or_else(|| false, |e| e.to_lowercase() == CABLE_FILE_FORMAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
use std::hash::{Hash, Hasher};
|
use std::{
|
||||||
|
fmt::Write,
|
||||||
|
hash::{Hash, Hasher},
|
||||||
|
};
|
||||||
|
|
||||||
use devicons::FileIcon;
|
use devicons::FileIcon;
|
||||||
|
|
||||||
@ -131,7 +134,7 @@ impl Entry {
|
|||||||
pub fn stdout_repr(&self) -> String {
|
pub fn stdout_repr(&self) -> String {
|
||||||
let mut repr = self.name.clone();
|
let mut repr = self.name.clone();
|
||||||
if let Some(line_number) = self.line_number {
|
if let Some(line_number) = self.line_number {
|
||||||
repr.push_str(&format!(":{line_number}"));
|
write!(repr, ":{}", line_number).unwrap();
|
||||||
}
|
}
|
||||||
repr
|
repr
|
||||||
}
|
}
|
||||||
|
@ -16,21 +16,21 @@ use crate::{
|
|||||||
///
|
///
|
||||||
/// The prototype contains the following fields:
|
/// The prototype contains the following fields:
|
||||||
/// - `name`: The name of the channel. This will be used to identify the
|
/// - `name`: The name of the channel. This will be used to identify the
|
||||||
/// channel throughout the application and in UI menus.
|
/// channel throughout the application and in UI menus.
|
||||||
/// - `source_command`: The command to run to get the source for the channel.
|
/// - `source_command`: The command to run to get the source for the channel.
|
||||||
/// This is a shell command that will be run in the background.
|
/// This is a shell command that will be run in the background.
|
||||||
/// - `interactive`: Whether the source command should be run in an interactive
|
/// - `interactive`: Whether the source command should be run in an interactive
|
||||||
/// shell. This is useful for commands that need the user's environment e.g.
|
/// shell. This is useful for commands that need the user's environment e.g.
|
||||||
/// `alias`.
|
/// `alias`.
|
||||||
/// - `preview_command`: The command to run on each entry to get the preview
|
/// - `preview_command`: The command to run on each entry to get the preview
|
||||||
/// for the channel. If this is not `None`, the channel will display a preview
|
/// for the channel. If this is not `None`, the channel will display a preview
|
||||||
/// pane with the output of this command.
|
/// pane with the output of this command.
|
||||||
/// - `preview_delimiter`: The delimiter to use to split an entry into
|
/// - `preview_delimiter`: The delimiter to use to split an entry into
|
||||||
/// multiple parts that can then be referenced in the preview command (e.g.
|
/// multiple parts that can then be referenced in the preview command (e.g.
|
||||||
/// `{1} + {2}`).
|
/// `{1} + {2}`).
|
||||||
/// - `preview_offset`: a litteral expression that will be interpreted later on
|
/// - `preview_offset`: a litteral expression that will be interpreted later on
|
||||||
/// in order to determine the vertical offset at which the preview should be
|
/// in order to determine the vertical offset at which the preview should be
|
||||||
/// displayed.
|
/// displayed.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// The default files channel might look something like this:
|
/// The default files channel might look something like this:
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
entry::Entry,
|
entry::Entry,
|
||||||
prototypes::{Cable, ChannelPrototype},
|
prototypes::{Cable, ChannelPrototype},
|
||||||
},
|
},
|
||||||
matcher::{config::Config, Matcher},
|
matcher::{Matcher, config::Config},
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use devicons::FileIcon;
|
use devicons::FileIcon;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{Result, anyhow};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -11,7 +11,7 @@ use crate::{
|
|||||||
prototypes::{Cable, ChannelPrototype},
|
prototypes::{Cable, ChannelPrototype},
|
||||||
},
|
},
|
||||||
cli::args::{Cli, Command},
|
cli::args::{Cli, Command},
|
||||||
config::{get_config_dir, get_data_dir, KeyBindings},
|
config::{KeyBindings, get_config_dir, get_data_dir},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod args;
|
pub mod args;
|
||||||
@ -327,8 +327,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a tuple containing a command mapping and a fallback channel.
|
/// Returns a tuple containing a command mapping and a fallback channel.
|
||||||
fn guess_channel_from_prompt_setup<'a>(
|
fn guess_channel_from_prompt_setup<'a>()
|
||||||
) -> (FxHashMap<String, String>, &'a str, Cable) {
|
-> (FxHashMap<String, String>, &'a str, Cable) {
|
||||||
let mut command_mapping = FxHashMap::default();
|
let mut command_mapping = FxHashMap::default();
|
||||||
command_mapping.insert("vim".to_string(), "files".to_string());
|
command_mapping.insert("vim".to_string(), "files".to_string());
|
||||||
command_mapping.insert("export".to_string(), "env".to_string());
|
command_mapping.insert("export".to_string(), "env".to_string());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::action::Action;
|
use crate::action::Action;
|
||||||
use crate::event::{convert_raw_event_to_key, Key};
|
use crate::event::{Key, convert_raw_event_to_key};
|
||||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
@ -144,7 +144,7 @@ fn extract_modifiers(raw: &str) -> (&str, KeyModifiers) {
|
|||||||
current = &rest[6..];
|
current = &rest[6..];
|
||||||
}
|
}
|
||||||
_ => break, // break out of the loop if no known prefix is detected
|
_ => break, // break out of the loop if no known prefix is detected
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(current, modifiers)
|
(current, modifiers)
|
||||||
@ -273,8 +273,7 @@ pub fn parse_key(raw: &str) -> anyhow::Result<Key, String> {
|
|||||||
raw
|
raw
|
||||||
} else {
|
} else {
|
||||||
let raw = raw.strip_prefix('<').unwrap_or(raw);
|
let raw = raw.strip_prefix('<').unwrap_or(raw);
|
||||||
let raw = raw.strip_suffix('>').unwrap_or(raw);
|
raw.strip_suffix('>').unwrap_or(raw)
|
||||||
raw
|
|
||||||
};
|
};
|
||||||
let key_event = parse_key_event(raw)?;
|
let key_event = parse_key_event(raw)?;
|
||||||
Ok(convert_raw_event_to_key(key_event))
|
Ok(convert_raw_event_to_key(key_event))
|
||||||
|
@ -8,7 +8,7 @@ use std::{
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
pub use keybindings::merge_keybindings;
|
pub use keybindings::merge_keybindings;
|
||||||
pub use keybindings::{parse_key, Binding, KeyBindings};
|
pub use keybindings::{Binding, KeyBindings, parse_key};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use shell_integration::ShellIntegrationConfig;
|
use shell_integration::ShellIntegrationConfig;
|
||||||
pub use themes::Theme;
|
pub use themes::Theme;
|
||||||
@ -138,7 +138,10 @@ impl Config {
|
|||||||
Ok(final_cfg)
|
Ok(final_cfg)
|
||||||
} else {
|
} else {
|
||||||
// otherwise, create the default configuration file
|
// otherwise, create the default configuration file
|
||||||
warn!("No config file found at {:?}, creating default configuration file at that location.", config_env.config_dir);
|
warn!(
|
||||||
|
"No config file found at {:?}, creating default configuration file at that location.",
|
||||||
|
config_env.config_dir
|
||||||
|
);
|
||||||
// create the default configuration file in the user's config directory
|
// create the default configuration file in the user's config directory
|
||||||
std::fs::write(
|
std::fs::write(
|
||||||
config_env.config_dir.join(CONFIG_FILE_NAME),
|
config_env.config_dir.join(CONFIG_FILE_NAME),
|
||||||
@ -213,14 +216,13 @@ pub fn get_data_dir() -> PathBuf {
|
|||||||
.filter(|p| p.is_absolute())
|
.filter(|p| p.is_absolute())
|
||||||
});
|
});
|
||||||
|
|
||||||
let directory = if let Some(s) = data_folder {
|
if let Some(s) = data_folder {
|
||||||
s
|
s
|
||||||
} else if let Some(proj_dirs) = project_directory() {
|
} else if let Some(proj_dirs) = project_directory() {
|
||||||
proj_dirs.data_local_dir().to_path_buf()
|
proj_dirs.data_local_dir().to_path_buf()
|
||||||
} else {
|
} else {
|
||||||
PathBuf::from("../../../../..").join(".data")
|
PathBuf::from("../../../../..").join(".data")
|
||||||
};
|
}
|
||||||
directory
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_config_dir() -> PathBuf {
|
pub fn get_config_dir() -> PathBuf {
|
||||||
@ -235,14 +237,12 @@ pub fn get_config_dir() -> PathBuf {
|
|||||||
.map(|p| p.join(PROJECT_NAME))
|
.map(|p| p.join(PROJECT_NAME))
|
||||||
.filter(|p| p.is_absolute())
|
.filter(|p| p.is_absolute())
|
||||||
});
|
});
|
||||||
let directory = if let Some(s) = config_dir {
|
if let Some(s) = config_dir {
|
||||||
s
|
s
|
||||||
} else if cfg!(unix) {
|
} else if cfg!(unix) {
|
||||||
// default to ~/.config/television for unix systems
|
// default to ~/.config/television for unix systems
|
||||||
if let Some(base_dirs) = directories::BaseDirs::new() {
|
if let Some(base_dirs) = directories::BaseDirs::new() {
|
||||||
let cfg_dir =
|
base_dirs.home_dir().join(".config").join("television")
|
||||||
base_dirs.home_dir().join(".config").join("television");
|
|
||||||
cfg_dir
|
|
||||||
} else {
|
} else {
|
||||||
PathBuf::from("../../../../..").join(".config")
|
PathBuf::from("../../../../..").join(".config")
|
||||||
}
|
}
|
||||||
@ -250,8 +250,7 @@ pub fn get_config_dir() -> PathBuf {
|
|||||||
proj_dirs.config_local_dir().to_path_buf()
|
proj_dirs.config_local_dir().to_path_buf()
|
||||||
} else {
|
} else {
|
||||||
PathBuf::from("../../../../..").join("../../../../../.config")
|
PathBuf::from("../../../../..").join("../../../../../.config")
|
||||||
};
|
}
|
||||||
directory
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn project_directory() -> Option<ProjectDirs> {
|
fn project_directory() -> Option<ProjectDirs> {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::{hash::Hash, time::Instant};
|
use std::{hash::Hash, time::Instant};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ratatui::{layout::Rect, Frame};
|
use ratatui::{Frame, layout::Rect};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -8,8 +8,8 @@ use std::{
|
|||||||
|
|
||||||
use crossterm::event::{
|
use crossterm::event::{
|
||||||
KeyCode::{
|
KeyCode::{
|
||||||
BackTab, Backspace, Char, Delete, Down, End, Enter, Esc, Home, Insert,
|
BackTab, Backspace, Char, Delete, Down, End, Enter, Esc, F, Home,
|
||||||
Left, PageDown, PageUp, Right, Tab, Up, F,
|
Insert, Left, PageDown, PageUp, Right, Tab, Up,
|
||||||
},
|
},
|
||||||
KeyEvent, KeyEventKind, KeyModifiers,
|
KeyEvent, KeyEventKind, KeyModifiers,
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
use tracing_subscriber::{EnvFilter, fmt, prelude::*};
|
||||||
|
|
||||||
use crate::config::get_data_dir;
|
use crate::config::get_data_dir;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::io::{stdout, BufWriter, IsTerminal, Write};
|
use std::io::{BufWriter, IsTerminal, Write, stdout};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
@ -15,14 +15,15 @@ use tracing::{debug, error, info};
|
|||||||
|
|
||||||
use television::app::{App, AppOptions};
|
use television::app::{App, AppOptions};
|
||||||
use television::cli::{
|
use television::cli::{
|
||||||
|
PostProcessedCli,
|
||||||
args::{Cli, Command},
|
args::{Cli, Command},
|
||||||
guess_channel_from_prompt, list_channels, PostProcessedCli,
|
guess_channel_from_prompt, list_channels,
|
||||||
};
|
};
|
||||||
|
|
||||||
use television::config::{merge_keybindings, Config, ConfigEnv};
|
use television::config::{Config, ConfigEnv, merge_keybindings};
|
||||||
use television::utils::shell::render_autocomplete_script_template;
|
use television::utils::shell::render_autocomplete_script_template;
|
||||||
use television::utils::{
|
use television::utils::{
|
||||||
shell::{completion_script, Shell},
|
shell::{Shell, completion_script},
|
||||||
stdin::is_readable_stdin,
|
stdin::is_readable_stdin,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ impl Picker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::doc_overindented_list_items)]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -14,7 +14,7 @@ use crate::{
|
|||||||
channels::{entry::Entry, preview::PreviewCommand},
|
channels::{entry::Entry, preview::PreviewCommand},
|
||||||
utils::{
|
utils::{
|
||||||
command::shell_command,
|
command::shell_command,
|
||||||
strings::{replace_non_printable, ReplaceNonPrintableConfig},
|
strings::{ReplaceNonPrintableConfig, replace_non_printable},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -193,12 +193,16 @@ impl Previewer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Request::Shutdown => {
|
Request::Shutdown => {
|
||||||
debug!("Received shutdown signal, breaking out of the previewer loop.");
|
debug!(
|
||||||
|
"Received shutdown signal, breaking out of the previewer loop."
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug!("Preview request channel closed and no messages left, breaking out of the previewer loop.");
|
debug!(
|
||||||
|
"Preview request channel closed and no messages left, breaking out of the previewer loop."
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use anyhow::Result;
|
|||||||
use crossterm::terminal::{BeginSynchronizedUpdate, EndSynchronizedUpdate};
|
use crossterm::terminal::{BeginSynchronizedUpdate, EndSynchronizedUpdate};
|
||||||
use crossterm::{execute, queue};
|
use crossterm::{execute, queue};
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use std::io::{stderr, stdout, LineWriter};
|
use std::io::{LineWriter, stderr, stdout};
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
@ -5,10 +5,10 @@ use crate::screen::metadata::build_metadata_table;
|
|||||||
use crate::screen::mode::mode_color;
|
use crate::screen::mode::mode_color;
|
||||||
use crate::television::Mode;
|
use crate::television::Mode;
|
||||||
use crate::utils::metadata::AppMetadata;
|
use crate::utils::metadata::AppMetadata;
|
||||||
|
use ratatui::Frame;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use ratatui::prelude::{Color, Style};
|
use ratatui::prelude::{Color, Style};
|
||||||
use ratatui::widgets::{Block, BorderType, Borders, Padding, Table};
|
use ratatui::widgets::{Block, BorderType, Borders, Padding, Table};
|
||||||
use ratatui::Frame;
|
|
||||||
|
|
||||||
pub fn draw_logo_block(
|
pub fn draw_logo_block(
|
||||||
f: &mut Frame,
|
f: &mut Frame,
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
use crate::utils::input::Input;
|
use crate::utils::input::Input;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{
|
layout::{
|
||||||
Alignment, Constraint, Direction, Layout as RatatuiLayout, Rect,
|
Alignment, Constraint, Direction, Layout as RatatuiLayout, Rect,
|
||||||
},
|
},
|
||||||
style::{Style, Stylize},
|
style::{Style, Stylize},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{
|
widgets::{
|
||||||
block::Position, Block, BorderType, Borders, ListState, Paragraph,
|
Block, BorderType, Borders, ListState, Paragraph, block::Position,
|
||||||
},
|
},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::screen::{colors::Colorscheme, spinner::Spinner};
|
use crate::screen::{colors::Colorscheme, spinner::Spinner};
|
||||||
|
@ -21,8 +21,7 @@ pub fn build_logo_paragraph<'a>() -> Paragraph<'a> {
|
|||||||
.lines()
|
.lines()
|
||||||
.map(std::convert::Into::into)
|
.map(std::convert::Into::into)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let logo_paragraph = Paragraph::new(lines);
|
Paragraph::new(lines)
|
||||||
logo_paragraph
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const REMOTE_LOGO: &str = r"
|
const REMOTE_LOGO: &str = r"
|
||||||
@ -51,6 +50,5 @@ pub fn build_remote_logo_paragraph<'a>() -> Paragraph<'a> {
|
|||||||
.lines()
|
.lines()
|
||||||
.map(std::convert::Into::into)
|
.map(std::convert::Into::into)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let logo_paragraph = Paragraph::new(lines);
|
Paragraph::new(lines)
|
||||||
logo_paragraph
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
use crate::previewer::state::PreviewState;
|
use crate::previewer::state::PreviewState;
|
||||||
use crate::screen::colors::Colorscheme;
|
use crate::screen::colors::Colorscheme;
|
||||||
use crate::utils::strings::{
|
use crate::utils::strings::{
|
||||||
replace_non_printable, shrink_with_ellipsis, ReplaceNonPrintableConfig,
|
EMPTY_STRING, ReplaceNonPrintableConfig, replace_non_printable,
|
||||||
EMPTY_STRING,
|
shrink_with_ellipsis,
|
||||||
};
|
};
|
||||||
use ansi_to_tui::IntoText;
|
use ansi_to_tui::IntoText;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use devicons::FileIcon;
|
use devicons::FileIcon;
|
||||||
use ratatui::widgets::{Block, BorderType, Borders, Padding, Paragraph};
|
|
||||||
use ratatui::Frame;
|
use ratatui::Frame;
|
||||||
|
use ratatui::widgets::{Block, BorderType, Borders, Padding, Paragraph};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
prelude::{Color, Line, Span, Style, Stylize, Text},
|
prelude::{Color, Line, Span, Style, Stylize, Text},
|
||||||
|
@ -7,6 +7,7 @@ use crate::television::Mode;
|
|||||||
use crate::utils::input::Input;
|
use crate::utils::input::Input;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use ratatui::Frame;
|
||||||
use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect};
|
use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect};
|
||||||
use ratatui::prelude::Style;
|
use ratatui::prelude::Style;
|
||||||
use ratatui::style::{Color, Stylize};
|
use ratatui::style::{Color, Stylize};
|
||||||
@ -14,7 +15,6 @@ use ratatui::text::{Line, Span};
|
|||||||
use ratatui::widgets::{
|
use ratatui::widgets::{
|
||||||
Block, BorderType, Borders, ListDirection, ListState, Padding, Paragraph,
|
Block, BorderType, Borders, ListDirection, ListState, Padding, Paragraph,
|
||||||
};
|
};
|
||||||
use ratatui::Frame;
|
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn draw_remote_control(
|
pub fn draw_remote_control(
|
||||||
|
@ -4,14 +4,15 @@ use crate::screen::layout::InputPosition;
|
|||||||
use crate::utils::indices::truncate_highlighted_string;
|
use crate::utils::indices::truncate_highlighted_string;
|
||||||
use crate::utils::strings::make_matched_string_printable;
|
use crate::utils::strings::make_matched_string_printable;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use ratatui::Frame;
|
||||||
use ratatui::layout::{Alignment, Rect};
|
use ratatui::layout::{Alignment, Rect};
|
||||||
use ratatui::prelude::{Color, Line, Span, Style};
|
use ratatui::prelude::{Color, Line, Span, Style};
|
||||||
use ratatui::style::Stylize;
|
use ratatui::style::Stylize;
|
||||||
use ratatui::widgets::{
|
use ratatui::widgets::{
|
||||||
Block, BorderType, Borders, List, ListDirection, ListState, Padding,
|
Block, BorderType, Borders, List, ListDirection, ListState, Padding,
|
||||||
};
|
};
|
||||||
use ratatui::Frame;
|
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
use std::fmt::Write;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
@ -73,7 +74,8 @@ fn build_result_line<'a>(
|
|||||||
entry,
|
entry,
|
||||||
area_width,
|
area_width,
|
||||||
use_icons,
|
use_icons,
|
||||||
selected_entries.map_or(false, |selected| selected.contains(entry)),
|
selected_entries
|
||||||
|
.map_or_else(|| false, |selected| selected.contains(entry)),
|
||||||
);
|
);
|
||||||
// optional selection symbol
|
// optional selection symbol
|
||||||
if let Some(selected_entries) = selected_entries {
|
if let Some(selected_entries) = selected_entries {
|
||||||
@ -257,10 +259,10 @@ pub fn draw_results_list(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut toggle_hints = String::new();
|
let mut toggle_hints = String::new();
|
||||||
if !no_help {
|
if !no_help {
|
||||||
toggle_hints.push_str(&format!(" help: <{help_keybinding}> ",));
|
write!(toggle_hints, " help: <{}> ", help_keybinding)?;
|
||||||
}
|
}
|
||||||
if preview_togglable {
|
if preview_togglable {
|
||||||
toggle_hints.push_str(&format!(" preview: <{preview_keybinding}> ",));
|
write!(toggle_hints, " preview: <{}> ", preview_keybinding)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let results_block = Block::default()
|
let results_block = Block::default()
|
||||||
|
@ -11,8 +11,8 @@ use crate::{
|
|||||||
input::convert_action_to_input_request,
|
input::convert_action_to_input_request,
|
||||||
picker::Picker,
|
picker::Picker,
|
||||||
previewer::{
|
previewer::{
|
||||||
state::PreviewState, Config as PreviewerConfig, Preview, Previewer,
|
Config as PreviewerConfig, Preview, Previewer,
|
||||||
Request as PreviewRequest, Ticket,
|
Request as PreviewRequest, Ticket, state::PreviewState,
|
||||||
},
|
},
|
||||||
render::UiState,
|
render::UiState,
|
||||||
screen::{
|
screen::{
|
||||||
@ -29,7 +29,7 @@ use rustc_hash::{FxBuildHasher, FxHashSet};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use tokio::sync::mpsc::{
|
use tokio::sync::mpsc::{
|
||||||
unbounded_channel, UnboundedReceiver, UnboundedSender,
|
UnboundedReceiver, UnboundedSender, unbounded_channel,
|
||||||
};
|
};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
io::{stderr, LineWriter, Write},
|
io::{LineWriter, Write, stderr},
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -9,8 +9,8 @@ use crossterm::{
|
|||||||
event::DisableMouseCapture,
|
event::DisableMouseCapture,
|
||||||
execute,
|
execute,
|
||||||
terminal::{
|
terminal::{
|
||||||
disable_raw_mode, enable_raw_mode, is_raw_mode_enabled,
|
EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode,
|
||||||
EnterAlternateScreen, LeaveAlternateScreen,
|
enable_raw_mode, is_raw_mode_enabled,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use ratatui::{backend::CrosstermBackend, layout::Size};
|
use ratatui::{backend::CrosstermBackend, layout::Size};
|
||||||
|
@ -82,7 +82,7 @@ impl Clipboard {
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub async fn set(&self, s: impl AsRef<std::ffi::OsStr>) {
|
pub async fn set(&self, s: impl AsRef<std::ffi::OsStr>) {
|
||||||
use std::{
|
use std::{
|
||||||
io::{stderr, BufWriter},
|
io::{BufWriter, stderr},
|
||||||
process::Stdio,
|
process::Stdio,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ impl Clipboard {
|
|||||||
mod osc52 {
|
mod osc52 {
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
|
||||||
use base64::{engine::general_purpose, Engine};
|
use base64::{Engine, engine::general_purpose};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SetClipboard {
|
pub struct SetClipboard {
|
||||||
|
@ -10,7 +10,7 @@ use std::sync::OnceLock;
|
|||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
use crate::utils::strings::{
|
use crate::utils::strings::{
|
||||||
proportion_of_printable_ascii_characters, PRINTABLE_ASCII_THRESHOLD,
|
PRINTABLE_ASCII_THRESHOLD, proportion_of_printable_ascii_characters,
|
||||||
};
|
};
|
||||||
use crate::utils::threads::default_num_threads;
|
use crate::utils::threads::default_num_threads;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use lazy_regex::{regex, Lazy, Regex};
|
use lazy_regex::{Lazy, Regex, regex};
|
||||||
|
|
||||||
/// Returns the index of the next character boundary in the given string.
|
/// Returns the index of the next character boundary in the given string.
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user