mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-06 03:25:23 +00:00
chore: fix linting warnings (#230)
This commit is contained in:
parent
da2396e19a
commit
d20784891f
@ -8,6 +8,7 @@ use television_channels::entry::merge_ranges;
|
|||||||
use television_channels::entry::{Entry, PreviewType};
|
use television_channels::entry::{Entry, PreviewType};
|
||||||
use television_screen::colors::ResultsColorscheme;
|
use television_screen::colors::ResultsColorscheme;
|
||||||
use television_screen::results::build_results_list;
|
use television_screen::results::build_results_list;
|
||||||
|
|
||||||
pub fn results_list_benchmark(c: &mut Criterion) {
|
pub fn results_list_benchmark(c: &mut Criterion) {
|
||||||
let mut icon_color_cache = std::collections::HashMap::default();
|
let mut icon_color_cache = std::collections::HashMap::default();
|
||||||
// FIXME: there's probably a way to have this as a benchmark asset
|
// FIXME: there's probably a way to have this as a benchmark asset
|
||||||
@ -17,7 +18,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/LICENSE".to_string(),
|
name: "typeshed/LICENSE".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -34,7 +35,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/README.md".to_string(),
|
name: "typeshed/README.md".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -51,7 +52,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/re.pyi".to_string(),
|
name: "typeshed/stdlib/re.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -68,7 +69,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/io.pyi".to_string(),
|
name: "typeshed/stdlib/io.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -85,7 +86,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/gc.pyi".to_string(),
|
name: "typeshed/stdlib/gc.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -102,7 +103,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/uu.pyi".to_string(),
|
name: "typeshed/stdlib/uu.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -119,7 +120,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/nt.pyi".to_string(),
|
name: "typeshed/stdlib/nt.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -136,7 +137,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/dis.pyi".to_string(),
|
name: "typeshed/stdlib/dis.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -153,7 +154,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/imp.pyi".to_string(),
|
name: "typeshed/stdlib/imp.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -170,7 +171,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/bdb.pyi".to_string(),
|
name: "typeshed/stdlib/bdb.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -187,7 +188,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/abc.pyi".to_string(),
|
name: "typeshed/stdlib/abc.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -204,7 +205,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/cgi.pyi".to_string(),
|
name: "typeshed/stdlib/cgi.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -221,7 +222,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/bz2.pyi".to_string(),
|
name: "typeshed/stdlib/bz2.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -238,7 +239,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/grp.pyi".to_string(),
|
name: "typeshed/stdlib/grp.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -255,7 +256,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/ast.pyi".to_string(),
|
name: "typeshed/stdlib/ast.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -272,7 +273,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/csv.pyi".to_string(),
|
name: "typeshed/stdlib/csv.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -289,7 +290,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/pdb.pyi".to_string(),
|
name: "typeshed/stdlib/pdb.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -306,7 +307,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/pwd.pyi".to_string(),
|
name: "typeshed/stdlib/pwd.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -323,7 +324,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/ssl.pyi".to_string(),
|
name: "typeshed/stdlib/ssl.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -340,7 +341,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/tty.pyi".to_string(),
|
name: "typeshed/stdlib/tty.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -357,7 +358,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/nis.pyi".to_string(),
|
name: "typeshed/stdlib/nis.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -374,7 +375,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/pty.pyi".to_string(),
|
name: "typeshed/stdlib/pty.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -391,7 +392,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/cmd.pyi".to_string(),
|
name: "typeshed/stdlib/cmd.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -408,7 +409,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/tests/utils.py".to_string(),
|
name: "typeshed/tests/utils.py".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -425,7 +426,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/pyproject.toml".to_string(),
|
name: "typeshed/pyproject.toml".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -442,7 +443,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/MAINTAINERS.md".to_string(),
|
name: "typeshed/MAINTAINERS.md".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -459,7 +460,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/enum.pyi".to_string(),
|
name: "typeshed/stdlib/enum.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -476,7 +477,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/hmac.pyi".to_string(),
|
name: "typeshed/stdlib/hmac.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -493,7 +494,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/uuid.pyi".to_string(),
|
name: "typeshed/stdlib/uuid.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -510,7 +511,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/glob.pyi".to_string(),
|
name: "typeshed/stdlib/glob.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -527,7 +528,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/_ast.pyi".to_string(),
|
name: "typeshed/stdlib/_ast.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -544,7 +545,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/_csv.pyi".to_string(),
|
name: "typeshed/stdlib/_csv.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -561,7 +562,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/code.pyi".to_string(),
|
name: "typeshed/stdlib/code.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -578,7 +579,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/spwd.pyi".to_string(),
|
name: "typeshed/stdlib/spwd.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -595,7 +596,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
Entry {
|
Entry {
|
||||||
name: "typeshed/stdlib/_msi.pyi".to_string(),
|
name: "typeshed/stdlib/_msi.pyi".to_string(),
|
||||||
value: None,
|
value: None,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -619,7 +620,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
}),
|
}),
|
||||||
line_number: None,
|
line_number: None,
|
||||||
preview_type: PreviewType::Files,
|
preview_type: PreviewType::Files,
|
||||||
name_match_ranges: Some(merge_ranges(&vec![
|
name_match_ranges: Some(merge_ranges(&[
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(1, 2),
|
(1, 2),
|
||||||
(2, 3),
|
(2, 3),
|
||||||
@ -655,7 +656,7 @@ pub fn results_list_benchmark(c: &mut Criterion) {
|
|||||||
&mut icon_color_cache,
|
&mut icon_color_cache,
|
||||||
&colorscheme,
|
&colorscheme,
|
||||||
);
|
);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ pub struct CableChannelPrototype {
|
|||||||
|
|
||||||
pub const DEFAULT_DELIMITER: &str = " ";
|
pub const DEFAULT_DELIMITER: &str = " ";
|
||||||
|
|
||||||
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
fn default_delimiter() -> Option<String> {
|
fn default_delimiter() -> Option<String> {
|
||||||
Some(DEFAULT_DELIMITER.to_string())
|
Some(DEFAULT_DELIMITER.to_string())
|
||||||
}
|
}
|
||||||
|
@ -89,18 +89,17 @@ impl OnAir for Channel {
|
|||||||
.with_icon(self.file_icon);
|
.with_icon(self.file_icon);
|
||||||
|
|
||||||
if should_add_name_indices {
|
if should_add_name_indices {
|
||||||
entry = entry.with_name_match_ranges(
|
let name_indices: Vec<(u32, u32)> =
|
||||||
name_indices.into_iter().map(|i| (i, i + 1)).collect(),
|
name_indices.into_iter().map(|i| (i, i + 1)).collect();
|
||||||
);
|
entry = entry.with_name_match_ranges(&name_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_add_value_indices {
|
if should_add_value_indices {
|
||||||
entry = entry.with_value_match_ranges(
|
let value_indices: Vec<(u32, u32)> = value_indices
|
||||||
value_indices
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|i| (i, i + 1))
|
.map(|i| (i, i + 1))
|
||||||
.collect(),
|
.collect();
|
||||||
);
|
entry = entry.with_value_match_ranges(&value_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry
|
entry
|
||||||
|
@ -141,7 +141,7 @@ impl OnAir for Channel {
|
|||||||
PreviewKind::None => PreviewType::None,
|
PreviewKind::None => PreviewType::None,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_name_match_ranges(item.match_indices)
|
.with_name_match_ranges(&item.match_indices)
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ impl OnAir for Channel {
|
|||||||
" ",
|
" ",
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.with_name_match_ranges(item.match_indices)
|
.with_name_match_ranges(&item.match_indices)
|
||||||
.with_icon(FileIcon::from(&path))
|
.with_icon(FileIcon::from(&path))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -69,18 +69,17 @@ impl OnAir for Channel {
|
|||||||
.with_icon(self.file_icon);
|
.with_icon(self.file_icon);
|
||||||
|
|
||||||
if should_add_name_indices {
|
if should_add_name_indices {
|
||||||
entry = entry.with_name_match_ranges(
|
let name_indices: Vec<(u32, u32)> =
|
||||||
name_indices.into_iter().map(|i| (i, i + 1)).collect(),
|
name_indices.into_iter().map(|i| (i, i + 1)).collect();
|
||||||
);
|
entry = entry.with_name_match_ranges(&name_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_add_value_indices {
|
if should_add_value_indices {
|
||||||
entry = entry.with_value_match_ranges(
|
let value_indices: Vec<(u32, u32)> = value_indices
|
||||||
value_indices
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|i| (i, i + 1))
|
.map(|i| (i, i + 1))
|
||||||
.collect(),
|
.collect();
|
||||||
);
|
entry = entry.with_value_match_ranges(&value_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry
|
entry
|
||||||
|
@ -92,7 +92,7 @@ impl OnAir for Channel {
|
|||||||
.map(|item| {
|
.map(|item| {
|
||||||
let path = item.matched_string;
|
let path = item.matched_string;
|
||||||
Entry::new(path.clone(), PreviewType::Files)
|
Entry::new(path.clone(), PreviewType::Files)
|
||||||
.with_name_match_ranges(item.match_indices)
|
.with_name_match_ranges(&item.match_indices)
|
||||||
.with_icon(FileIcon::from(&path))
|
.with_icon(FileIcon::from(&path))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -64,7 +64,7 @@ impl OnAir for Channel {
|
|||||||
path.clone(),
|
path.clone(),
|
||||||
PreviewType::Command(PREVIEW_COMMAND.clone()),
|
PreviewType::Command(PREVIEW_COMMAND.clone()),
|
||||||
)
|
)
|
||||||
.with_name_match_ranges(item.match_indices)
|
.with_name_match_ranges(&item.match_indices)
|
||||||
.with_icon(self.icon)
|
.with_icon(self.icon)
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -131,7 +131,7 @@ impl OnAir for RemoteControl {
|
|||||||
.map(|item| {
|
.map(|item| {
|
||||||
let path = item.matched_string;
|
let path = item.matched_string;
|
||||||
Entry::new(path, PreviewType::Basic)
|
Entry::new(path, PreviewType::Basic)
|
||||||
.with_name_match_ranges(item.match_indices)
|
.with_name_match_ranges(&item.match_indices)
|
||||||
.with_icon(match item.inner {
|
.with_icon(match item.inner {
|
||||||
RCButton::Channel(_) => TV_ICON,
|
RCButton::Channel(_) => TV_ICON,
|
||||||
RCButton::CableChannel(_) => CABLE_ICON,
|
RCButton::CableChannel(_) => CABLE_ICON,
|
||||||
|
@ -79,7 +79,7 @@ impl OnAir for Channel {
|
|||||||
// NOTE: we're passing `PreviewType::Basic` here just as a placeholder
|
// NOTE: we're passing `PreviewType::Basic` here just as a placeholder
|
||||||
// to avoid storing the preview command multiple times for each item.
|
// to avoid storing the preview command multiple times for each item.
|
||||||
Entry::new(item.matched_string, PreviewType::Basic)
|
Entry::new(item.matched_string, PreviewType::Basic)
|
||||||
.with_name_match_ranges(item.match_indices)
|
.with_name_match_ranges(&item.match_indices)
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ impl OnAir for Channel {
|
|||||||
item.inner.path.to_string_lossy().to_string();
|
item.inner.path.to_string_lossy().to_string();
|
||||||
Entry::new(display_path, PreviewType::Files)
|
Entry::new(display_path, PreviewType::Files)
|
||||||
.with_value(line)
|
.with_value(line)
|
||||||
.with_value_match_ranges(item.match_indices)
|
.with_value_match_ranges(&item.match_indices)
|
||||||
.with_icon(FileIcon::from(item.inner.path.as_path()))
|
.with_icon(FileIcon::from(item.inner.path.as_path()))
|
||||||
.with_line_number(item.inner.line_number)
|
.with_line_number(item.inner.line_number)
|
||||||
})
|
})
|
||||||
|
@ -56,8 +56,8 @@ impl Entry {
|
|||||||
///
|
///
|
||||||
/// let entry = Entry::new("name".to_string(), PreviewType::EnvVar)
|
/// let entry = Entry::new("name".to_string(), PreviewType::EnvVar)
|
||||||
/// .with_value("value".to_string())
|
/// .with_value("value".to_string())
|
||||||
/// .with_name_match_ranges(vec![(0, 1)])
|
/// .with_name_match_ranges(&vec![(0, 1)])
|
||||||
/// .with_value_match_ranges(vec![(0, 1)])
|
/// .with_value_match_ranges(&vec![(0, 1)])
|
||||||
/// .with_icon(FileIcon::default())
|
/// .with_icon(FileIcon::default())
|
||||||
/// .with_line_number(0);
|
/// .with_line_number(0);
|
||||||
/// ```
|
/// ```
|
||||||
@ -88,17 +88,17 @@ impl Entry {
|
|||||||
|
|
||||||
pub fn with_name_match_ranges(
|
pub fn with_name_match_ranges(
|
||||||
mut self,
|
mut self,
|
||||||
name_match_ranges: Vec<(u32, u32)>,
|
name_match_ranges: &[(u32, u32)],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.name_match_ranges = Some(merge_ranges(&name_match_ranges));
|
self.name_match_ranges = Some(merge_ranges(name_match_ranges));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_value_match_ranges(
|
pub fn with_value_match_ranges(
|
||||||
mut self,
|
mut self,
|
||||||
value_match_ranges: Vec<(u32, u32)>,
|
value_match_ranges: &[(u32, u32)],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.value_match_ranges = Some(merge_ranges(&value_match_ranges));
|
self.value_match_ranges = Some(merge_ranges(value_match_ranges));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ impl PreviewCommand {
|
|||||||
|
|
||||||
impl Display for PreviewCommand {
|
impl Display for PreviewCommand {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{:?}", self)
|
write!(f, "{self:?}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ pub mod parser;
|
|||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
use tui::text::Text;
|
use tui::text::Text;
|
||||||
|
|
||||||
/// IntoText will convert any type that has a AsRef<[u8]> to a Text.
|
/// `IntoText` will convert any type that has a `AsRef<[u8]>` to a Text.
|
||||||
pub trait IntoText {
|
pub trait IntoText {
|
||||||
/// Convert the type to a Text.
|
/// Convert the type to a Text.
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
|
@ -3,7 +3,7 @@ use tui::style::Color;
|
|||||||
/// This enum stores most types of ansi escape sequences
|
/// This enum stores most types of ansi escape sequences
|
||||||
///
|
///
|
||||||
/// You can turn an escape sequence to this enum variant using
|
/// You can turn an escape sequence to this enum variant using
|
||||||
/// AnsiCode::from(code: u8)
|
/// `AnsiCode::from(code: u8)`
|
||||||
/// This doesn't support all of them but does support most of them.
|
/// This doesn't support all of them but does support most of them.
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
@ -124,6 +124,7 @@ impl From<u8> for AnsiCode {
|
|||||||
94 => AnsiCode::ForegroundColor(Color::LightBlue),
|
94 => AnsiCode::ForegroundColor(Color::LightBlue),
|
||||||
95 => AnsiCode::ForegroundColor(Color::LightMagenta),
|
95 => AnsiCode::ForegroundColor(Color::LightMagenta),
|
||||||
96 => AnsiCode::ForegroundColor(Color::LightCyan),
|
96 => AnsiCode::ForegroundColor(Color::LightCyan),
|
||||||
|
#[allow(clippy::match_same_arms)]
|
||||||
97 => AnsiCode::ForegroundColor(Color::White),
|
97 => AnsiCode::ForegroundColor(Color::White),
|
||||||
100 => AnsiCode::BackgroundColor(Color::DarkGray),
|
100 => AnsiCode::BackgroundColor(Color::DarkGray),
|
||||||
101 => AnsiCode::BackgroundColor(Color::LightRed),
|
101 => AnsiCode::BackgroundColor(Color::LightRed),
|
||||||
|
@ -48,32 +48,32 @@ impl From<AnsiStates> for tui::style::Style {
|
|||||||
.remove_modifier(Modifier::DIM);
|
.remove_modifier(Modifier::DIM);
|
||||||
}
|
}
|
||||||
AnsiCode::Italic => {
|
AnsiCode::Italic => {
|
||||||
style = style.add_modifier(Modifier::ITALIC)
|
style = style.add_modifier(Modifier::ITALIC);
|
||||||
}
|
}
|
||||||
AnsiCode::Underline => {
|
AnsiCode::Underline => {
|
||||||
style = style.add_modifier(Modifier::UNDERLINED)
|
style = style.add_modifier(Modifier::UNDERLINED);
|
||||||
}
|
}
|
||||||
AnsiCode::SlowBlink => {
|
AnsiCode::SlowBlink => {
|
||||||
style = style.add_modifier(Modifier::SLOW_BLINK)
|
style = style.add_modifier(Modifier::SLOW_BLINK);
|
||||||
}
|
}
|
||||||
AnsiCode::RapidBlink => {
|
AnsiCode::RapidBlink => {
|
||||||
style = style.add_modifier(Modifier::RAPID_BLINK)
|
style = style.add_modifier(Modifier::RAPID_BLINK);
|
||||||
}
|
}
|
||||||
AnsiCode::Reverse => {
|
AnsiCode::Reverse => {
|
||||||
style = style.add_modifier(Modifier::REVERSED)
|
style = style.add_modifier(Modifier::REVERSED);
|
||||||
}
|
}
|
||||||
AnsiCode::Conceal => {
|
AnsiCode::Conceal => {
|
||||||
style = style.add_modifier(Modifier::HIDDEN)
|
style = style.add_modifier(Modifier::HIDDEN);
|
||||||
}
|
}
|
||||||
AnsiCode::CrossedOut => {
|
AnsiCode::CrossedOut => {
|
||||||
style = style.add_modifier(Modifier::CROSSED_OUT)
|
style = style.add_modifier(Modifier::CROSSED_OUT);
|
||||||
}
|
}
|
||||||
AnsiCode::DefaultForegroundColor => {
|
AnsiCode::DefaultForegroundColor => {
|
||||||
style = style.fg(Color::Reset)
|
style = style.fg(Color::Reset);
|
||||||
}
|
}
|
||||||
AnsiCode::SetForegroundColor => {
|
AnsiCode::SetForegroundColor => {
|
||||||
if let Some(color) = item.color {
|
if let Some(color) = item.color {
|
||||||
style = style.fg(color)
|
style = style.fg(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnsiCode::ForegroundColor(color) => style = style.fg(color),
|
AnsiCode::ForegroundColor(color) => style = style.fg(color),
|
||||||
@ -84,13 +84,14 @@ impl From<AnsiStates> for tui::style::Style {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
pub(crate) fn text(mut s: &[u8]) -> IResult<&[u8], Text<'static>> {
|
pub(crate) fn text(mut s: &[u8]) -> IResult<&[u8], Text<'static>> {
|
||||||
let mut lines = Vec::new();
|
let mut lines = Vec::new();
|
||||||
let mut last = Style::new();
|
let mut last = Style::new();
|
||||||
while let Ok((_s, (line, style))) = line(last)(s) {
|
while let Ok((c, (line, style))) = line(last)(s) {
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
last = style;
|
last = style;
|
||||||
s = _s;
|
s = c;
|
||||||
if s.is_empty() {
|
if s.is_empty() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -99,13 +100,14 @@ pub(crate) fn text(mut s: &[u8]) -> IResult<&[u8], Text<'static>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "zero-copy")]
|
#[cfg(feature = "zero-copy")]
|
||||||
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
pub(crate) fn text_fast(mut s: &[u8]) -> IResult<&[u8], Text<'_>> {
|
pub(crate) fn text_fast(mut s: &[u8]) -> IResult<&[u8], Text<'_>> {
|
||||||
let mut lines = Vec::new();
|
let mut lines = Vec::new();
|
||||||
let mut last = Style::new();
|
let mut last = Style::new();
|
||||||
while let Ok((_s, (line, style))) = line_fast(last)(s) {
|
while let Ok((c, (line, style))) = line_fast(last)(s) {
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
last = style;
|
last = style;
|
||||||
s = _s;
|
s = c;
|
||||||
if s.is_empty() {
|
if s.is_empty() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ const PATH: &str = "PATH";
|
|||||||
|
|
||||||
fn maybe_add_newline_after_colon(s: &str, name: &str) -> String {
|
fn maybe_add_newline_after_colon(s: &str, name: &str) -> String {
|
||||||
if name.contains(PATH) {
|
if name.contains(PATH) {
|
||||||
return s.replace(":", "\n");
|
return s.replace(':', "\n");
|
||||||
}
|
}
|
||||||
s.to_string()
|
s.to_string()
|
||||||
}
|
}
|
||||||
|
@ -125,8 +125,8 @@ impl FilePreviewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn cache_preview(&mut self, key: String, preview: Arc<Preview>) {
|
fn cache_preview(&mut self, key: String, preview: &Arc<Preview>) {
|
||||||
self.cache.lock().insert(key, &preview);
|
self.cache.lock().insert(key, preview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ pub fn draw_input_box(
|
|||||||
Constraint::Fill(1),
|
Constraint::Fill(1),
|
||||||
// result count
|
// result count
|
||||||
Constraint::Length(
|
Constraint::Length(
|
||||||
3 * ((total_count as f32).log10().ceil() as u16 + 1) + 3,
|
3 * (u16::try_from((total_count).ilog10()).unwrap() + 1) + 3,
|
||||||
),
|
),
|
||||||
// spinner
|
// spinner
|
||||||
Constraint::Length(1),
|
Constraint::Length(1),
|
||||||
|
@ -27,6 +27,7 @@ use television_utils::strings::{
|
|||||||
const FILL_CHAR_SLANTED: char = '╱';
|
const FILL_CHAR_SLANTED: char = '╱';
|
||||||
const FILL_CHAR_EMPTY: char = ' ';
|
const FILL_CHAR_EMPTY: char = ' ';
|
||||||
|
|
||||||
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
pub fn build_preview_paragraph(
|
pub fn build_preview_paragraph(
|
||||||
preview_block: Block<'_>,
|
preview_block: Block<'_>,
|
||||||
inner: Rect,
|
inner: Rect,
|
||||||
@ -89,6 +90,7 @@ pub fn build_preview_paragraph(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
fn build_ansi_text_paragraph(
|
fn build_ansi_text_paragraph(
|
||||||
text: String,
|
text: String,
|
||||||
preview_block: Block,
|
preview_block: Block,
|
||||||
@ -110,6 +112,7 @@ fn build_ansi_text_paragraph(
|
|||||||
.scroll((preview_scroll, 0))
|
.scroll((preview_scroll, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
fn build_plain_text_paragraph(
|
fn build_plain_text_paragraph(
|
||||||
text: Vec<String>,
|
text: Vec<String>,
|
||||||
preview_block: Block<'_>,
|
preview_block: Block<'_>,
|
||||||
@ -151,6 +154,7 @@ fn build_plain_text_paragraph(
|
|||||||
.scroll((preview_scroll, 0))
|
.scroll((preview_scroll, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
fn build_plain_text_wrapped_paragraph(
|
fn build_plain_text_wrapped_paragraph(
|
||||||
text: String,
|
text: String,
|
||||||
preview_block: Block<'_>,
|
preview_block: Block<'_>,
|
||||||
@ -169,6 +173,7 @@ fn build_plain_text_wrapped_paragraph(
|
|||||||
.wrap(Wrap { trim: true })
|
.wrap(Wrap { trim: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
fn build_syntect_highlighted_paragraph(
|
fn build_syntect_highlighted_paragraph(
|
||||||
highlighted_lines: Vec<Vec<(syntect::highlighting::Style, String)>>,
|
highlighted_lines: Vec<Vec<(syntect::highlighting::Style, String)>>,
|
||||||
preview_block: Block,
|
preview_block: Block,
|
||||||
|
@ -273,6 +273,7 @@ pub fn guess_channel_from_prompt(
|
|||||||
Err(eyre!("No channel found for prompt: {}", prompt))
|
Err(eyre!("No channel found for prompt: {}", prompt))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
fn delimiter_parser(s: &str) -> Result<String, String> {
|
fn delimiter_parser(s: &str) -> Result<String, String> {
|
||||||
Ok(match s {
|
Ok(match s {
|
||||||
"" => ":".to_string(),
|
"" => ":".to_string(),
|
||||||
|
@ -16,10 +16,12 @@ pub enum Binding {
|
|||||||
impl Display for Binding {
|
impl Display for Binding {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Binding::SingleKey(key) => write!(f, "{}", key),
|
Binding::SingleKey(key) => write!(f, "{key}"),
|
||||||
Binding::MultipleKeys(keys) => {
|
Binding::MultipleKeys(keys) => {
|
||||||
let keys_str: Vec<String> =
|
let keys_str: Vec<String> = keys
|
||||||
keys.iter().map(|k| k.to_string()).collect();
|
.iter()
|
||||||
|
.map(std::string::ToString::to_string)
|
||||||
|
.collect();
|
||||||
write!(f, "{}", keys_str.join(", "))
|
write!(f, "{}", keys_str.join(", "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,6 +256,7 @@ impl Television {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
/// Update the state of the component based on a received action.
|
/// Update the state of the component based on a received action.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
@ -108,7 +108,7 @@ where
|
|||||||
{
|
{
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
match self.exit() {
|
match self.exit() {
|
||||||
Ok(_) => debug!("Successfully exited terminal"),
|
Ok(()) => debug!("Successfully exited terminal"),
|
||||||
Err(e) => debug!("Failed to exit terminal: {:?}", e),
|
Err(e) => debug!("Failed to exit terminal: {:?}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user