From 80931e3cab69c5b2a0e27dbe71be5ac00a7ad155 Mon Sep 17 00:00:00 2001 From: Alexandre Pasmantier Date: Fri, 24 Jan 2025 00:16:25 +0100 Subject: [PATCH] chore: flatten workspace --- CHANGELOG.md | 3 +- CONTRIBUTING.md | 129 ++++++++++------ Cargo.lock | 122 ++------------- Cargo.toml | 146 +++++++----------- benches/results_list_benchmark.rs | 8 +- crates/television-channels/Cargo.toml | 36 ----- crates/television-channels/src/cable.rs | 38 ----- crates/television-channels/src/lib.rs | 3 - crates/television-derive/Cargo.toml | 25 --- crates/television-fuzzy/Cargo.toml | 20 --- crates/television-fuzzy/src/lib.rs | 3 - crates/television-previewers/Cargo.toml | 41 ----- crates/television-previewers/src/lib.rs | 2 - crates/television-screen/Cargo.toml | 29 ---- crates/television-utils/Cargo.toml | 35 ----- crates/television/config/themes/builtin.rs | 46 ------ television-derive/Cargo.toml | 26 ++++ .../src/lib.rs | 8 +- {crates/television => television}/action.rs | 0 {crates/television => television}/app.rs | 6 +- {crates/television => television}/cable.rs | 8 +- .../src => television}/channels/alias.rs | 12 +- .../src => television}/channels/cable.rs | 50 +++++- .../src => television}/channels/dirs.rs | 8 +- .../src => television/channels}/entry.rs | 2 +- .../src => television}/channels/env.rs | 18 ++- .../src => television}/channels/files.rs | 8 +- .../src => television}/channels/git_repos.rs | 6 +- .../channels.rs => television/channels/mod.rs | 17 +- .../channels/remote_control.rs | 22 +-- .../src => television}/channels/stdin.rs | 11 +- .../src => television}/channels/text.rs | 25 +-- {crates/television => television}/cli.rs | 25 +-- {crates/television => television}/config.rs | 2 +- .../config/keybindings.rs | 2 +- .../config/previewers.rs | 5 +- .../config/shell_integration.rs | 0 .../config/styles.rs | 2 +- .../config/themes.rs | 8 +- television/config/themes/builtin.rs | 43 ++++++ .../television => television}/config/ui.rs | 2 +- {crates/television => television}/errors.rs | 0 {crates/television => television}/event.rs | 0 {crates/television => television}/input.rs | 2 +- {crates/television => television}/keymap.rs | 2 +- television/lib.rs | 19 +++ {crates/television => television}/logging.rs | 0 {crates/television => television}/main.rs | 38 ++--- .../src => television}/matcher/config.rs | 0 .../src => television}/matcher/injector.rs | 2 +- .../src => television}/matcher/lazy.rs | 4 +- .../matcher/matched_item.rs | 0 .../src => television}/matcher/mod.rs | 25 ++- {crates/television => television}/picker.rs | 2 +- .../src => television/preview}/ansi.rs | 6 +- .../src => television/preview}/ansi/LICENSE | 0 .../src => television/preview}/ansi/code.rs | 2 +- .../src => television/preview}/ansi/error.rs | 0 .../src => television/preview}/ansi/parser.rs | 17 +- .../preview}/cache.rs | 4 +- .../preview/mod.rs | 29 ++-- .../preview}/previewers/basic.rs | 4 +- .../preview}/previewers/command.rs | 14 +- .../preview}/previewers/env.rs | 4 +- .../preview}/previewers/files.rs | 12 +- .../preview}/previewers/meta.rs | 2 +- television/preview/previewers/mod.rs | 5 + {crates/television => television}/render.rs | 0 .../src => television/screen}/cache.rs | 2 +- .../src => television/screen}/colors.rs | 0 .../src => television/screen}/help.rs | 12 +- .../src => television/screen}/input.rs | 4 +- .../src => television/screen}/keybindings.rs | 2 +- .../src => television/screen}/layout.rs | 0 .../src => television/screen}/logo.rs | 0 .../src => television/screen}/metadata.rs | 6 +- .../src/lib.rs => television/screen/mod.rs | 0 .../src => television/screen}/mode.rs | 2 +- .../src => television/screen}/preview.rs | 23 ++- .../screen}/remote_control.rs | 12 +- .../src => television/screen}/results.rs | 18 +-- .../src => television/screen}/spinner.rs | 0 .../television => television}/television.rs | 42 ++--- {crates/television => television}/tui.rs | 0 .../src => television/utils}/cache.rs | 2 +- .../src => television/utils}/command.rs | 0 .../src => television/utils}/files.rs | 4 +- .../src => television/utils}/indices.rs | 0 .../src => television/utils}/input.rs | 0 .../src => television/utils}/metadata.rs | 0 .../src/lib.rs => television/utils/mod.rs | 0 .../src => television/utils}/shell.rs | 6 +- .../utils}/shell/completion.bash | 0 .../utils}/shell/completion.fish | 0 .../utils}/shell/completion.zsh | 0 .../src => television/utils}/stdin.rs | 0 .../src => television/utils}/strings.rs | 20 +-- .../src => television/utils}/syntax.rs | 0 .../src => television/utils}/threads.rs | 0 99 files changed, 545 insertions(+), 805 deletions(-) delete mode 100644 crates/television-channels/Cargo.toml delete mode 100644 crates/television-channels/src/cable.rs delete mode 100644 crates/television-channels/src/lib.rs delete mode 100644 crates/television-derive/Cargo.toml delete mode 100644 crates/television-fuzzy/Cargo.toml delete mode 100644 crates/television-fuzzy/src/lib.rs delete mode 100644 crates/television-previewers/Cargo.toml delete mode 100644 crates/television-previewers/src/lib.rs delete mode 100644 crates/television-screen/Cargo.toml delete mode 100644 crates/television-utils/Cargo.toml delete mode 100644 crates/television/config/themes/builtin.rs create mode 100644 television-derive/Cargo.toml rename {crates/television-derive => television-derive}/src/lib.rs (98%) rename {crates/television => television}/action.rs (100%) rename {crates/television => television}/app.rs (98%) rename {crates/television => television}/cable.rs (94%) rename {crates/television-channels/src => television}/channels/alias.rs (93%) rename {crates/television-channels/src => television}/channels/cable.rs (84%) rename {crates/television-channels/src => television}/channels/dirs.rs (95%) rename {crates/television-channels/src => television/channels}/entry.rs (99%) rename {crates/television-channels/src => television}/channels/env.rs (88%) rename {crates/television-channels/src => television}/channels/files.rs (96%) rename {crates/television-channels/src => television}/channels/git_repos.rs (96%) rename crates/television-channels/src/channels.rs => television/channels/mod.rs (98%) rename {crates/television-channels/src => television}/channels/remote_control.rs (95%) rename {crates/television-channels/src => television}/channels/stdin.rs (90%) rename {crates/television-channels/src => television}/channels/text.rs (95%) rename {crates/television => television}/cli.rs (96%) rename {crates/television => television}/config.rs (99%) rename {crates/television => television}/config/keybindings.rs (99%) rename {crates/television => television}/config/previewers.rs (91%) rename {crates/television => television}/config/shell_integration.rs (100%) rename {crates/television => television}/config/styles.rs (99%) rename {crates/television => television}/config/themes.rs (99%) create mode 100644 television/config/themes/builtin.rs rename {crates/television => television}/config/ui.rs (96%) rename {crates/television => television}/errors.rs (100%) rename {crates/television => television}/event.rs (100%) rename {crates/television => television}/input.rs (94%) rename {crates/television => television}/keymap.rs (97%) create mode 100644 television/lib.rs rename {crates/television => television}/logging.rs (100%) rename {crates/television => television}/main.rs (86%) rename {crates/television-fuzzy/src => television}/matcher/config.rs (100%) rename {crates/television-fuzzy/src => television}/matcher/injector.rs (95%) rename {crates/television-fuzzy/src => television}/matcher/lazy.rs (94%) rename {crates/television-fuzzy/src => television}/matcher/matched_item.rs (100%) rename {crates/television-fuzzy/src => television}/matcher/mod.rs (92%) rename {crates/television => television}/picker.rs (99%) rename {crates/television-previewers/src => television/preview}/ansi.rs (86%) rename {crates/television-previewers/src => television/preview}/ansi/LICENSE (100%) rename {crates/television-previewers/src => television/preview}/ansi/code.rs (99%) rename {crates/television-previewers/src => television/preview}/ansi/error.rs (100%) rename {crates/television-previewers/src => television/preview}/ansi/parser.rs (97%) rename {crates/television-previewers/src/previewers => television/preview}/cache.rs (96%) rename crates/television-previewers/src/previewers.rs => television/preview/mod.rs (91%) rename {crates/television-previewers/src => television/preview}/previewers/basic.rs (88%) rename {crates/television-previewers/src => television/preview}/previewers/command.rs (95%) rename {crates/television-previewers/src => television/preview}/previewers/env.rs (95%) rename {crates/television-previewers/src => television/preview}/previewers/files.rs (97%) rename {crates/television-previewers/src => television/preview}/previewers/meta.rs (94%) create mode 100644 television/preview/previewers/mod.rs rename {crates/television => television}/render.rs (100%) rename {crates/television-screen/src => television/screen}/cache.rs (98%) rename {crates/television-screen/src => television/screen}/colors.rs (100%) rename {crates/television-screen/src => television/screen}/help.rs (90%) rename {crates/television-screen/src => television/screen}/input.rs (98%) rename {crates/television-screen/src => television/screen}/keybindings.rs (99%) rename {crates/television-screen/src => television/screen}/layout.rs (100%) rename {crates/television-screen/src => television/screen}/logo.rs (100%) rename {crates/television-screen/src => television/screen}/metadata.rs (97%) rename crates/television-screen/src/lib.rs => television/screen/mod.rs (100%) rename {crates/television-screen/src => television/screen}/mode.rs (92%) rename {crates/television-screen/src => television/screen}/preview.rs (98%) rename {crates/television-screen/src => television/screen}/remote_control.rs (94%) rename {crates/television-screen/src => television/screen}/results.rs (96%) rename {crates/television-screen/src => television/screen}/spinner.rs (100%) rename {crates/television => television}/television.rs (97%) rename {crates/television => television}/tui.rs (100%) rename {crates/television-utils/src => television/utils}/cache.rs (99%) rename {crates/television-utils/src => television/utils}/command.rs (100%) rename {crates/television-utils/src => television/utils}/files.rs (99%) rename {crates/television-utils/src => television/utils}/indices.rs (100%) rename {crates/television-utils/src => television/utils}/input.rs (100%) rename {crates/television-utils/src => television/utils}/metadata.rs (100%) rename crates/television-utils/src/lib.rs => television/utils/mod.rs (100%) rename {crates/television-utils/src => television/utils}/shell.rs (69%) rename {crates/television-utils => television/utils}/shell/completion.bash (100%) rename {crates/television-utils => television/utils}/shell/completion.fish (100%) rename {crates/television-utils => television/utils}/shell/completion.zsh (100%) rename {crates/television-utils/src => television/utils}/stdin.rs (100%) rename {crates/television-utils/src => television/utils}/strings.rs (97%) rename {crates/television-utils/src => television/utils}/syntax.rs (100%) rename {crates/television-utils/src => television/utils}/threads.rs (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 311ead8..6250ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -227,7 +227,8 @@ All notable changes to this project will be documented in this file. ### 🐛 Bug Fixes -- *(channels)* Use the number of actual bytes read and not the sample buffer size when calculating the proportion of printable ASCII characters (#174) +- *(channels)* Use the number of actual bytes read and not the sample buffer size when calculating the proportion of + printable ASCII characters (#174) - *(ux)* Make DeletePrevWord trigger channel update (#175) ### 📚 Documentation diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6aa8bc2..9b75bbb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,11 +3,14 @@ First of all, thanks for considering contributing to this project. All contributions are welcome, whether they are bug reports, documentation improvements, feature requests, or pull requests. -Please make sure to read and follow our [Code of Conduct](CODE_OF_CONDUCT.md) to ensure a positive experience for everyone involved. +Please make sure to read and follow our [Code of Conduct](CODE_OF_CONDUCT.md) to ensure a positive experience for +everyone involved. -If you're not sure where to start, take a look at the [Hot Topics](#hot-topics) section for some ideas on what you could work on. +If you're not sure where to start, take a look at the [Hot Topics](#hot-topics) section for some ideas on what you could +work on. ## Table of Contents + - [Getting started](#getting-started) - [Prerequisites](#prerequisites) - [Forking the repository and setting up the project](#forking-the-repository-and-setting-up-the-project) @@ -17,12 +20,17 @@ If you're not sure where to start, take a look at the [Hot Topics](#hot-topics) - [Hot Topics](#hot-topics) ## Getting started + ### Prerequisites -These are pretty much the only things you need to have installed on your machine to get started with contributing to this project: + +These are pretty much the only things you need to have installed on your machine to get started with contributing to +this project: + - the [Rust](https://www.rust-lang.org/tools/install) toolchain installed on your machine - any working version of [Git](https://git-scm.com/downloads) ### Forking the repository and setting up the project + 1. Click on the `Fork` button at the top right corner of the repository page to create a copy of the repository to your GitHub account. 2. Clone the forked repository to your local machine by running the following command in your terminal: @@ -51,15 +59,19 @@ These are pretty much the only things you need to have installed on your machine ```shell git push origin ``` -8. If not done automatically, create a pull request by navigating to the original repository and clicking on the `New pull request` button. - +8. If not done automatically, create a pull request by navigating to the original repository and clicking on the + `New pull request` button. ### Building the project + Before anything else: + ```shell make setup ``` + To run the application in debug mode while developing, with the ability to see logs and debug information: + ```shell make run ``` @@ -75,58 +87,72 @@ configuration: | Windows | `{FOLDERID_LocalAppData}\television\television.log` | To build the project in debug mode, run the following command in the project directory: + ```shell make ``` + or + ```shell make build ``` To build the project in release mode, run the following command in the project directory: + ```shell make release ``` + Formatting the code + ```shell make format ``` + Linting the code + ```shell make lint ``` + Running the tests + ```shell make test ``` ### Project structure -The project is laid out in several rust crates that are organized in the following way: -- `television`: the main binary crate that contains the CLI application -- `television_channels`: a library crate that contains the channel implementations -- `television_derive`: a library crate that contains the derive macros used in the project -- `television_fuzzy`: a library crate that contains the fuzzy matcher -- `television_previewers`: a library crate that contains the previewer implementations -- `television_utils`: a library crate that contains utility functions and types used in the project +The project is laid out in several rust crates that are organized in the following way: + +- `television`: the main binary crate that contains the CLI application +- `television_derive`: a library crate that contains the derive macros used in the project ### Contributing a new channel `television` is built around the concept of _channels_. -From a technical standpoint, channels are structs that implement the `OnAir` trait defined in `crates/television-channels/src/channels.rs`. +From a technical standpoint, channels are structs that implement the `OnAir` trait defined in +`television/channels/mod.rs`. -They can be anything that can respond to a user query and return a result under the form of a list of entries. This means channels can be anything from conventional data sources you might want to search through (like files, git repositories, remote filesystems, environment variables etc.) to more exotic implementations that might include a REPL, a calculator, a web browser, search through your spotify library, your email, etc. +They can be anything that can respond to a user query and return a result under the form of a list of entries. This +means channels can be anything from conventional data sources you might want to search through (like files, git +repositories, remote filesystems, environment variables etc.) to more exotic implementations that might include a REPL, +a calculator, a web browser, search through your spotify library, your email, etc. -As mentioned in [Project structure](#project-structure) `television` uses [crates](https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html) for its different subcomponents (_previewers_, _channels_, _utils_, etc). +As mentioned in [Project structure](#project-structure) `television` +uses [crates](https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html) for its different subcomponents ( +_previewers_, _channels_, _utils_, etc). -When contributing a new channel, you should create a new module in the `television_channels` crate with a new struct for -your channel and ensure that it implements the `OnAir` trait defined in [crates/television-channels/src/channels.rs](crates/television-channels/src/channels.rs) +When contributing a new channel, you should create a new module in the `crate::channels` crate with a new struct for +your channel and ensure that it implements the `OnAir` trait defined +in [crates/television-channels/src/channels.rs](crates/television-channels/src/channels.rs) ```rust // crates/television-channels/src/channels/my_new_channel.rs -use television_channels::channels::OnAir; +use crate::channels::OnAir; pub struct MyNewChannel; @@ -135,12 +161,10 @@ impl OnAir for MyNewChannel { } ``` -You should also add your channel to the `TelevisionChannel` enum in the `television_channels` crate. +You should also add your channel to the `TelevisionChannel` enum in the `crate::channels` crate. ```rust -// crates/television-channels/src/channels.rs - - +// crates/television-channels/src/mod #[derive(ToUnitChannel, ToCliChannel, Broadcast)] pub enum TelevisionChannel { @@ -149,13 +173,15 @@ pub enum TelevisionChannel { } ``` -☝️ There are built-in channels in `television` that you might want to draw inspiration from if need be, they're located at [crates/television-channels/src/channels](crates/television-channels/src/channels). +☝️ There are built-in channels in `television` that you might want to draw inspiration from if need be, they're located +at [crates/television-channels/src/channels](crates/television-channels/src/channels). **TODO**: document transitions between channels and previewers - ## Hot Topics + ### Current hot topics: + - shell integration (autocomplete, keybindings) - packaging for various linux package managers (apt, dnf, ...) - configuring custom actions for each channel @@ -165,38 +191,39 @@ pub enum TelevisionChannel { See the [todo list](./TODO.md) for ideas. - `Customization`: - - allow users to further customize the behavior of the application (e.g. the default channel, fuzzy matching constants, channel heuristics, etc.) + - allow users to further customize the behavior of the application (e.g. the default channel, fuzzy matching + constants, channel heuristics, etc.) - `Channels`: - - new channel ideas (builtin or cable): - - shell history - - directories - - git (commits, branches, status, diff, ...) - - remote filesystems (s3, ...) - - kubernetes resources (jobs, pods, deployments, services, ...) - - recent directories - - makefile commands - - etc. - - add more tests for existing channels + - new channel ideas (builtin or cable): + - shell history + - directories + - git (commits, branches, status, diff, ...) + - remote filesystems (s3, ...) + - kubernetes resources (jobs, pods, deployments, services, ...) + - recent directories + - makefile commands + - etc. + - add more tests for existing channels - `Previewers`: - - new previewer ideas: - - previewing text in documents (pdfs, archives, ...) - - previewing images (actually already implemented but commented out) - - remote files (s3, ...) - - etc. - - more tests for existing previewers + - new previewer ideas: + - previewing text in documents (pdfs, archives, ...) + - previewing images (actually already implemented but commented out) + - remote files (s3, ...) + - etc. + - more tests for existing previewers - `Documentation`: - - add more technical documentation to the project - - general design of the TUI application - - design of channels, previewers, transitions, etc. - - how to contribute a new channel, previewer, etc. - - more docstrings + - add more technical documentation to the project + - general design of the TUI application + - design of channels, previewers, transitions, etc. + - how to contribute a new channel, previewer, etc. + - more docstrings - `Performance/Refactoring`: - - working on reducing coupling between the different crates in the project - - working on reducing the number of allocations and copies in the code - - writing benchmarks for different parts of the application + - working on reducing coupling between the different crates in the project + - working on reducing the number of allocations and copies in the code + - writing benchmarks for different parts of the application - `Project`: - - polish project configuration: - - CI/CD + - polish project configuration: + - CI/CD diff --git a/Cargo.lock b/Cargo.lock index 1e480e0..570b08e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -426,10 +426,8 @@ version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" dependencies = [ - "anstream", "anstyle", "clap_lex", - "strsim", ] [[package]] @@ -2054,12 +2052,6 @@ dependencies = [ "redox_syscall", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -3074,20 +3066,19 @@ dependencies = [ "fnv", "once_cell", "onig", - "plist", "regex-syntax 0.8.5", "serde", "serde_derive", "serde_json", "thiserror 1.0.69", "walkdir", - "yaml-rust", ] [[package]] name = "television" version = "0.9.4" dependencies = [ + "bat", "better-panic", "clap", "color-eyre", @@ -3097,47 +3088,31 @@ dependencies = [ "crossterm", "devicons", "directories", + "gag", "human-panic", + "ignore", "lazy_static", + "nom", + "nucleo", + "parking_lot", "ratatui", + "regex", "rustc-hash", "serde", "signal-hook", + "simdutf8", + "smallvec", + "strum", "syntect", - "television-channels", "television-derive", - "television-fuzzy", - "television-previewers", - "television-screen", - "television-utils", + "thiserror 1.0.69", "tokio", "toml", "tracing", "tracing-subscriber", "unicode-width 0.2.0", "vergen-gix", -] - -[[package]] -name = "television-channels" -version = "0.0.23" -dependencies = [ - "clap", - "color-eyre", - "devicons", - "directories", - "ignore", - "lazy_static", - "regex", - "rustc-hash", - "serde", - "strum", - "television-derive", - "television-fuzzy", - "television-utils", - "tokio", - "toml", - "tracing", + "winapi-util", ] [[package]] @@ -3149,70 +3124,6 @@ dependencies = [ "syn", ] -[[package]] -name = "television-fuzzy" -version = "0.0.23" -dependencies = [ - "nucleo", - "parking_lot", -] - -[[package]] -name = "television-previewers" -version = "0.0.23" -dependencies = [ - "color-eyre", - "devicons", - "lazy_static", - "nom", - "parking_lot", - "ratatui", - "regex", - "rustc-hash", - "simdutf8", - "smallvec", - "syntect", - "television-channels", - "television-utils", - "thiserror 1.0.69", - "tokio", - "tracing", -] - -[[package]] -name = "television-screen" -version = "0.0.23" -dependencies = [ - "color-eyre", - "devicons", - "ratatui", - "rustc-hash", - "serde", - "syntect", - "television-channels", - "television-previewers", - "television-utils", - "tracing", -] - -[[package]] -name = "television-utils" -version = "0.0.23" -dependencies = [ - "bat", - "color-eyre", - "directories", - "gag", - "ignore", - "lazy_static", - "rustc-hash", - "syntect", - "tokio", - "tracing", - "unicode-width 0.2.0", - "winapi-util", -] - [[package]] name = "tempfile" version = "3.15.0" @@ -4068,15 +3979,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "yaml-rust2" version = "0.8.1" diff --git a/Cargo.toml b/Cargo.toml index 44b3869..8664882 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,106 +10,78 @@ repository = "https://github.com/alexpasmantier/television" homepage = "https://github.com/alexpasmantier/television" keywords = ["search", "fuzzy", "preview", "tui", "terminal"] categories = [ - "command-line-utilities", - "command-line-interface", - "concurrency", - "development-tools", + "command-line-utilities", + "command-line-interface", + "concurrency", + "development-tools", ] include = [ - "LICENSE", - "README.md", - "themes/**/*.toml", - "crates/television/**/*.rs", - "build.rs", - ".config/config.toml", - "cable", + "LICENSE", + "README.md", + "themes/**/*.toml", + "television/**", + "build.rs", + ".config/config.toml", + "cable", ] rust-version = "1.81" -[workspace] -resolver = "2" -members = ["crates/television-*"] - -[workspace.package] -edition = "2021" -description = "The revolution will be televised." -license = "MIT" -authors = ["Alexandre Pasmantier "] -repository = "https://github.com/alexpasmantier/television" -homepage = "https://github.com/alexpasmantier/television" -keywords = ["search", "fuzzy", "preview", "tui", "terminal"] -categories = [ - "command-line-utilities", - "command-line-interface", - "concurrency", - "development-tools", -] -include = [ - "LICENSE", - "README.md", - "crates/television/**/*.rs", - "build.rs", - "shell/**/*.sh", -] -rust-version = "1.81" -readme = "README.md" - -[workspace.dependencies] -directories = "5.0.1" -devicons = "0.6.11" -color-eyre = "0.6.3" -lazy_static = "1.5.0" -tokio = { version = "1.41.1", features = ["full"] } -tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter", "serde"] } -rustc-hash = "2.1.0" -syntect = { version = "5.2.0" } -unicode-width = "0.2.0" -clap = { version = "4.5.20", features = ["derive", "cargo", "string"] } -serde = { version = "1.0.214", features = ["derive"] } -toml = "0.8.19" -ratatui = { version = "0.29.0", features = ["serde", "macros"] } - +[lib] +path = "television/lib.rs" [dependencies] -# local dependencies -television-fuzzy = { path = "crates/television-fuzzy", version = "0.0.23" } -television-derive = { path = "crates/television-derive", version = "0.0.23" } -television-screen = { path = "crates/television-screen", version = "0.0.23" } -television-channels = { path = "crates/television-channels", version = "0.0.23" } -television-previewers = { path = "crates/television-previewers", version = "0.0.23" } -television-utils = { path = "crates/television-utils", version = "0.0.23" } +television-derive = { path = "television-derive", version = "0.0.23" } -# workspace dependencies -directories = { workspace = true } -color-eyre = { workspace = true } -lazy_static = { workspace = true } -tokio = { workspace = true, features = ["full"] } -tracing = { workspace = true } -tracing-subscriber = { workspace = true, features = ["env-filter", "serde"] } -rustc-hash = { workspace = true } -syntect = { workspace = true } -unicode-width = { workspace = true } -clap = { workspace = true, features = ["derive", "cargo", "string"] } -serde = { workspace = true, features = ["derive"] } -toml = { workspace = true } -ratatui = { workspace = true, features = ["serde", "macros"] } +directories = "5.0" +devicons = "0.6" +color-eyre = { version = "0.6" } +lazy_static = "1.5" +tokio = { version = "1.43", features = ["full"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter", "serde"] } +rustc-hash = "2.1" +syntect = { version = "5.2", default-features = false } +unicode-width = "0.2" +clap = { version = "4.5", default-features = false, features = [ + "std", + "derive", + "cargo", + "string", +] } +serde = { version = "1.0", features = ["derive"] } +ratatui = { version = "0.29", features = ["serde", "macros"] } +better-panic = "0.3" +config = "0.14" +signal-hook = "0.3" +human-panic = "2.0" +copypasta = "0.10" +ignore = "0.4" +strum = { version = "0.26", features = ["derive"] } +regex = "1.11" +parking_lot = "0.12" +nom = "7.1" +thiserror = "1.0" +simdutf8 = { version = "0.1", optional = true } +smallvec = { version = "1.13", features = ["const_generics"] } +bat = { version = "0.24", default-features = false, features = ["regex-onig"] } +gag = "1.0" +nucleo = "0.5" +toml = "0.8" -# external dependencies -better-panic = "0.3.0" -config = "0.14.0" -crossterm = { version = "0.28.1", features = ["serde"] } -signal-hook = "0.3.17" -human-panic = "2.0.2" -copypasta = "0.10.1" +[target.'cfg(windows)'.dependencies] +winapi-util = "0.1.9" [dev-dependencies] criterion = "0.5.1" -devicons = { workspace = true } + +[features] +simd = ["dep:simdutf8"] +zero-copy = [] +default = ["zero-copy", "simd"] [[bin]] bench = false -path = "crates/television/main.rs" +path = "television/main.rs" name = "tv" [[bench]] @@ -117,11 +89,13 @@ name = "results_list_benchmark" harness = false [build-dependencies] -vergen-gix = { version = "1.0.0", features = ["build", "cargo", "rustc"] } +vergen-gix = { version = "1.0", features = ["build", "cargo", "rustc"] } [target.'cfg(target_os = "macos")'.dependencies] crossterm = { version = "0.28.1", features = ["serde", "use-dev-tty"] } +[target.'cfg(not(target_os = "macos"))'.dependencies] +crossterm = { version = "0.28", features = ["serde"] } [profile.staging] inherits = "dev" diff --git a/benches/results_list_benchmark.rs b/benches/results_list_benchmark.rs index c963089..f781e5f 100644 --- a/benches/results_list_benchmark.rs +++ b/benches/results_list_benchmark.rs @@ -5,10 +5,10 @@ use ratatui::prelude::{Line, Style}; use ratatui::style::Color; use ratatui::widgets::{Block, BorderType, Borders, ListDirection, Padding}; use rustc_hash::FxHashMap; -use television_channels::entry::merge_ranges; -use television_channels::entry::{Entry, PreviewType}; -use television_screen::colors::ResultsColorscheme; -use television_screen::results::build_results_list; +use television::channels::entry::merge_ranges; +use television::channels::entry::{Entry, PreviewType}; +use television::screen::colors::ResultsColorscheme; +use television::screen::results::build_results_list; pub fn results_list_benchmark(c: &mut Criterion) { let mut icon_color_cache = FxHashMap::default(); diff --git a/crates/television-channels/Cargo.toml b/crates/television-channels/Cargo.toml deleted file mode 100644 index f616c48..0000000 --- a/crates/television-channels/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] -name = "television-channels" -version = "0.0.23" -description.workspace = true -authors.workspace = true -repository.workspace = true -homepage.workspace = true -keywords.workspace = true -categories.workspace = true -readme.workspace = true -license.workspace = true -edition.workspace = true -rust-version.workspace = true - -[dependencies] -television-fuzzy = { path = "../television-fuzzy", version = "0.0.23" } -television-utils = { path = "../television-utils", version = "0.0.23" } -television-derive = { path = "../television-derive", version = "0.0.23" } - -tracing = { workspace = true } -tokio = { workspace = true, features = ["rt"] } -clap = { workspace = true, features = ["derive"] } -devicons = { workspace = true } -directories = { workspace = true } -color-eyre = { workspace = true } -serde = { workspace = true } -lazy_static = { workspace = true } -toml = { workspace = true } -rustc-hash = { workspace = true } - -ignore = "0.4.23" -strum = { version = "0.26.3", features = ["derive"] } -regex = "1.11.1" - -[lints] -workspace = true diff --git a/crates/television-channels/src/cable.rs b/crates/television-channels/src/cable.rs deleted file mode 100644 index 3a17a47..0000000 --- a/crates/television-channels/src/cable.rs +++ /dev/null @@ -1,38 +0,0 @@ -use rustc_hash::FxHashMap; -use std::{ - fmt::{self, Display, Formatter}, - ops::Deref, -}; - -#[derive(Clone, Debug, serde::Deserialize, PartialEq)] -pub struct CableChannelPrototype { - pub name: String, - pub source_command: String, - pub preview_command: Option, - #[serde(default = "default_delimiter")] - pub preview_delimiter: Option, -} - -pub const DEFAULT_DELIMITER: &str = " "; - -#[allow(clippy::unnecessary_wraps)] -fn default_delimiter() -> Option { - Some(DEFAULT_DELIMITER.to_string()) -} - -impl Display for CableChannelPrototype { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "{}", self.name) - } -} - -#[derive(Debug, serde::Deserialize, Default)] -pub struct CableChannels(pub FxHashMap); - -impl Deref for CableChannels { - type Target = FxHashMap; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} diff --git a/crates/television-channels/src/lib.rs b/crates/television-channels/src/lib.rs deleted file mode 100644 index 024325d..0000000 --- a/crates/television-channels/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod cable; -pub mod channels; -pub mod entry; diff --git a/crates/television-derive/Cargo.toml b/crates/television-derive/Cargo.toml deleted file mode 100644 index 628e97c..0000000 --- a/crates/television-derive/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "television-derive" -version = "0.0.23" -description.workspace = true -authors.workspace = true -repository.workspace = true -homepage.workspace = true -keywords.workspace = true -categories.workspace = true -readme.workspace = true -license.workspace = true -edition.workspace = true -rust-version.workspace = true - -[dependencies] -proc-macro2 = "1.0.87" -quote = "1.0.37" -syn = "2.0.79" - - -[lib] -proc-macro = true - -[lints] -workspace = true diff --git a/crates/television-fuzzy/Cargo.toml b/crates/television-fuzzy/Cargo.toml deleted file mode 100644 index 496ca37..0000000 --- a/crates/television-fuzzy/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "television-fuzzy" -version = "0.0.23" -description.workspace = true -authors.workspace = true -repository.workspace = true -homepage.workspace = true -keywords.workspace = true -categories.workspace = true -readme.workspace = true -license.workspace = true -edition.workspace = true -rust-version.workspace = true - -[dependencies] -nucleo = "0.5.0" -parking_lot = "0.12.3" - -[lints] -workspace = true diff --git a/crates/television-fuzzy/src/lib.rs b/crates/television-fuzzy/src/lib.rs deleted file mode 100644 index 62db079..0000000 --- a/crates/television-fuzzy/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod matcher; - -pub use matcher::Matcher; diff --git a/crates/television-previewers/Cargo.toml b/crates/television-previewers/Cargo.toml deleted file mode 100644 index c151e06..0000000 --- a/crates/television-previewers/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "television-previewers" -version = "0.0.23" -description.workspace = true -authors.workspace = true -repository.workspace = true -homepage.workspace = true -keywords.workspace = true -categories.workspace = true -readme.workspace = true -license.workspace = true -edition.workspace = true -rust-version.workspace = true - -[dependencies] -television-channels = { path = "../television-channels", version = "0.0.23" } -television-utils = { path = "../television-utils", version = "0.0.23" } - -syntect = { workspace = true } -devicons = { workspace = true } -tracing = { workspace = true } -tokio = { workspace = true } -color-eyre = { workspace = true } -lazy_static = { workspace = true } -rustc-hash = { workspace = true } - -parking_lot = "0.12.3" -regex = "1.11.1" -nom = "7.1" -tui = { version = "0.29", default-features = false, package = "ratatui" } -thiserror = "1.0" -simdutf8 = { version = "0.1", optional = true } -smallvec = { version = "1.10.0", features = ["const_generics"] } - -[features] -simd = ["dep:simdutf8"] -zero-copy = [] -default = ["zero-copy", "simd"] - -[lints] -workspace = true diff --git a/crates/television-previewers/src/lib.rs b/crates/television-previewers/src/lib.rs deleted file mode 100644 index 4218378..0000000 --- a/crates/television-previewers/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod ansi; -pub mod previewers; diff --git a/crates/television-screen/Cargo.toml b/crates/television-screen/Cargo.toml deleted file mode 100644 index 9714358..0000000 --- a/crates/television-screen/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "television-screen" -version = "0.0.23" -description.workspace = true -authors.workspace = true -repository.workspace = true -homepage.workspace = true -keywords.workspace = true -categories.workspace = true -readme.workspace = true -license.workspace = true -edition.workspace = true -rust-version.workspace = true - -[dependencies] -television-utils = { path = "../television-utils", version = "0.0.23" } -television-channels = { path = "../television-channels", version = "0.0.23" } -television-previewers = { path = "../television-previewers", version = "0.0.23" } - -ratatui = { workspace = true } -serde = { workspace = true } -color-eyre = { workspace = true } -syntect = { workspace = true } -rustc-hash = { workspace = true } -tracing = { workspace = true } -devicons = { workspace = true } - -[lints] -workspace = true diff --git a/crates/television-utils/Cargo.toml b/crates/television-utils/Cargo.toml deleted file mode 100644 index e355024..0000000 --- a/crates/television-utils/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "television-utils" -version = "0.0.23" -description.workspace = true -authors.workspace = true -repository.workspace = true -homepage.workspace = true -keywords.workspace = true -categories.workspace = true -readme.workspace = true -license.workspace = true -edition.workspace = true -rust-version.workspace = true - -[dependencies] -lazy_static = { workspace = true } -tracing = { workspace = true } -color-eyre = { workspace = true } -directories = { workspace = true } -syntect = { workspace = true } -unicode-width = { workspace = true } -rustc-hash = { workspace = true } -tokio = { workspace = true } - -ignore = "0.4.23" -bat = { version = "0.24.0", default-features = false, features = [ - "regex-onig", -] } -gag = "1.0.0" - -[target.'cfg(windows)'.dependencies] -winapi-util = "0.1.9" - -[lints] -workspace = true diff --git a/crates/television/config/themes/builtin.rs b/crates/television/config/themes/builtin.rs deleted file mode 100644 index 305066a..0000000 --- a/crates/television/config/themes/builtin.rs +++ /dev/null @@ -1,46 +0,0 @@ -use rustc_hash::FxHashMap; - -use lazy_static::lazy_static; - -lazy_static! { - pub static ref BUILTIN_THEMES: FxHashMap<&'static str, &'static str> = { - let mut m = FxHashMap::default(); - m.insert("default", include_str!("../../../../themes/default.toml")); - m.insert( - "television", - include_str!("../../../../themes/television.toml"), - ); - m.insert( - "gruvbox-dark", - include_str!("../../../../themes/gruvbox-dark.toml"), - ); - m.insert( - "gruvbox-light", - include_str!("../../../../themes/gruvbox-light.toml"), - ); - m.insert( - "catppuccin", - include_str!("../../../../themes/catppuccin.toml"), - ); - m.insert( - "nord-dark", - include_str!("../../../../themes/nord-dark.toml"), - ); - m.insert( - "solarized-dark", - include_str!("../../../../themes/solarized-dark.toml"), - ); - m.insert( - "solarized-light", - include_str!("../../../../themes/solarized-light.toml"), - ); - m.insert("dracula", include_str!("../../../../themes/dracula.toml")); - m.insert("monokai", include_str!("../../../../themes/monokai.toml")); - m.insert("onedark", include_str!("../../../../themes/onedark.toml")); - m.insert( - "tokyonight", - include_str!("../../../../themes/tokyonight.toml"), - ); - m - }; -} diff --git a/television-derive/Cargo.toml b/television-derive/Cargo.toml new file mode 100644 index 0000000..048f109 --- /dev/null +++ b/television-derive/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "television-derive" +version = "0.0.23" +edition = "2021" +description = "The revolution will be televised." +license = "MIT" +authors = ["Alexandre Pasmantier "] +repository = "https://github.com/alexpasmantier/television" +homepage = "https://github.com/alexpasmantier/television" +keywords = ["search", "fuzzy", "preview", "tui", "terminal"] +categories = [ + "command-line-utilities", + "command-line-interface", + "concurrency", + "development-tools", +] +rust-version = "1.81" + +[dependencies] +proc-macro2 = "1.0.87" +quote = "1.0.37" +syn = "2.0.79" + + +[lib] +proc-macro = true diff --git a/crates/television-derive/src/lib.rs b/television-derive/src/lib.rs similarity index 98% rename from crates/television-derive/src/lib.rs rename to television-derive/src/lib.rs index 0cd8f86..394dcee 100644 --- a/crates/television-derive/src/lib.rs +++ b/television-derive/src/lib.rs @@ -5,9 +5,9 @@ use quote::quote; /// to convert into a `TelevisionChannel` member: /// /// ```ignore -/// use crate::channels::{TelevisionChannel, OnAir}; +/// use television::channels::{TelevisionChannel, OnAir}; /// use television-derive::ToCliChannel; -/// use crate::channels::{files, text}; +/// use television::channels::{files, text}; /// /// #[derive(ToCliChannel)] /// enum TelevisionChannel { @@ -132,8 +132,8 @@ fn impl_cli_channel(ast: &syn::DeriveInput) -> TokenStream { /// Example: /// ```ignore /// use television-derive::Broadcast; -/// use crate::channels::{TelevisionChannel, OnAir}; -/// use crate::channels::{files, text}; +/// use television::channels::{TelevisionChannel, OnAir}; +/// use television::channels::{files, text}; /// /// #[derive(Broadcast)] /// enum TelevisionChannel { diff --git a/crates/television/action.rs b/television/action.rs similarity index 100% rename from crates/television/action.rs rename to television/action.rs diff --git a/crates/television/app.rs b/television/app.rs similarity index 98% rename from crates/television/app.rs rename to television/app.rs index 78b7c69..3c7c2ee 100644 --- a/crates/television/app.rs +++ b/television/app.rs @@ -1,11 +1,13 @@ use rustc_hash::FxHashSet; use std::sync::Arc; +use crate::screen::mode::Mode; use color_eyre::Result; -use television_screen::mode::Mode; use tokio::sync::{mpsc, Mutex}; use tracing::{debug, info}; +use crate::channels::entry::Entry; +use crate::channels::TelevisionChannel; use crate::config::{parse_key, Config}; use crate::keymap::Keymap; use crate::television::Television; @@ -14,8 +16,6 @@ use crate::{ event::{Event, EventLoop, Key}, render::{render, RenderingTask}, }; -use television_channels::channels::TelevisionChannel; -use television_channels::entry::Entry; /// The main application struct that holds the state of the application. pub struct App { diff --git a/crates/television/cable.rs b/television/cable.rs similarity index 94% rename from crates/television/cable.rs rename to television/cable.rs index 6b01719..8ee9466 100644 --- a/crates/television/cable.rs +++ b/television/cable.rs @@ -2,8 +2,8 @@ use std::path::PathBuf; use rustc_hash::FxHashMap; +use crate::channels::cable::{CableChannelPrototype, CableChannels}; use color_eyre::Result; -use television_channels::cable::{CableChannelPrototype, CableChannels}; use tracing::{debug, error}; use crate::config::get_config_dir; @@ -20,11 +20,11 @@ const CABLE_FILE_FORMAT: &str = "toml"; #[cfg(unix)] const DEFAULT_CABLE_CHANNELS: &str = - include_str!("../../cable/unix-channels.toml"); + include_str!("../cable/unix-channels.toml"); #[cfg(not(unix))] const DEFAULT_CABLE_CHANNELS: &str = - include_str!("../../cable/windows-channels.toml"); + include_str!("../cable/windows-channels.toml"); const DEFAULT_CABLE_CHANNELS_FILE_NAME: &str = "default_channels.toml"; @@ -34,7 +34,7 @@ const DEFAULT_CABLE_CHANNELS_FILE_NAME: &str = "default_channels.toml"; /// pattern in the config directory: `*channels.toml`. /// /// # Example: -/// ``` +/// ```ignore /// config_folder/ /// ├── cable_channels.toml /// ├── my_channels.toml diff --git a/crates/television-channels/src/channels/alias.rs b/television/channels/alias.rs similarity index 93% rename from crates/television-channels/src/channels/alias.rs rename to television/channels/alias.rs index ef11c61..a2a4b98 100644 --- a/crates/television-channels/src/channels/alias.rs +++ b/television/channels/alias.rs @@ -1,13 +1,13 @@ use std::collections::HashSet; +use crate::channels::entry::Entry; +use crate::channels::entry::PreviewType; use crate::channels::OnAir; -use crate::entry::Entry; -use crate::entry::PreviewType; +use crate::matcher::{config::Config, injector::Injector, Matcher}; +use crate::utils::indices::sep_name_and_value_indices; use devicons::FileIcon; use rustc_hash::FxBuildHasher; use rustc_hash::FxHashSet; -use television_fuzzy::matcher::{config::Config, injector::Injector, Matcher}; -use television_utils::indices::sep_name_and_value_indices; use tracing::debug; #[derive(Debug, Clone)] @@ -170,8 +170,8 @@ async fn load_aliases(injector: Injector) { None }) .for_each(|alias| { - let () = injector.push(alias.clone(), |_, cols| { - cols[0] = (alias.name.clone() + &alias.value).into(); + let () = injector.push(alias.clone(), |e, cols| { + cols[0] = (e.name.clone() + &e.value).into(); }); }); } diff --git a/crates/television-channels/src/channels/cable.rs b/television/channels/cable.rs similarity index 84% rename from crates/television-channels/src/channels/cable.rs rename to television/channels/cable.rs index 8ec848c..aa66230 100644 --- a/crates/television-channels/src/channels/cable.rs +++ b/television/channels/cable.rs @@ -1,3 +1,9 @@ +use rustc_hash::FxHashMap; +use std::{ + fmt::{self, Display, Formatter}, + ops::Deref, +}; + use std::collections::HashSet; use std::io::{BufRead, BufReader}; use std::process::Stdio; @@ -8,14 +14,11 @@ use regex::Regex; use rustc_hash::{FxBuildHasher, FxHashSet}; use tracing::debug; -use crate::cable::{CableChannelPrototype, DEFAULT_DELIMITER}; +use crate::channels::entry::{Entry, PreviewCommand, PreviewType}; use crate::channels::OnAir; -use crate::entry::{Entry, PreviewCommand, PreviewType}; -use television_fuzzy::{ - matcher::{config::Config, injector::Injector}, - Matcher, -}; -use television_utils::command::shell_command; +use crate::matcher::Matcher; +use crate::matcher::{config::Config, injector::Injector}; +use crate::utils::command::shell_command; #[derive(Debug, Clone)] enum PreviewKind { @@ -214,3 +217,36 @@ impl OnAir for Channel { fn shutdown(&self) {} } + +#[derive(Clone, Debug, serde::Deserialize, PartialEq)] +pub struct CableChannelPrototype { + pub name: String, + pub source_command: String, + pub preview_command: Option, + #[serde(default = "default_delimiter")] + pub preview_delimiter: Option, +} + +pub const DEFAULT_DELIMITER: &str = " "; + +#[allow(clippy::unnecessary_wraps)] +fn default_delimiter() -> Option { + Some(DEFAULT_DELIMITER.to_string()) +} + +impl Display for CableChannelPrototype { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "{}", self.name) + } +} + +#[derive(Debug, serde::Deserialize, Default)] +pub struct CableChannels(pub FxHashMap); + +impl Deref for CableChannels { + type Target = FxHashMap; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} diff --git a/crates/television-channels/src/channels/dirs.rs b/television/channels/dirs.rs similarity index 95% rename from crates/television-channels/src/channels/dirs.rs rename to television/channels/dirs.rs index bc1f34e..26b62dd 100644 --- a/crates/television-channels/src/channels/dirs.rs +++ b/television/channels/dirs.rs @@ -1,11 +1,11 @@ +use crate::channels::entry::{Entry, PreviewCommand, PreviewType}; use crate::channels::{OnAir, TelevisionChannel}; -use crate::entry::{Entry, PreviewCommand, PreviewType}; +use crate::matcher::{config::Config, injector::Injector, Matcher}; +use crate::utils::files::{walk_builder, DEFAULT_NUM_THREADS}; use devicons::FileIcon; use rustc_hash::{FxBuildHasher, FxHashSet}; use std::collections::HashSet; use std::path::PathBuf; -use television_fuzzy::matcher::{config::Config, injector::Injector, Matcher}; -use television_utils::files::{walk_builder, DEFAULT_NUM_THREADS}; pub struct Channel { matcher: Matcher, @@ -172,7 +172,7 @@ async fn load_dirs(paths: Vec, injector: Injector) { return ignore::WalkState::Continue; } let () = injector.push(dir_path.to_string(), |e, cols| { - cols[0] = e.clone().into(); + cols[0] = e.to_string().into(); }); } } diff --git a/crates/television-channels/src/entry.rs b/television/channels/entry.rs similarity index 99% rename from crates/television-channels/src/entry.rs rename to television/channels/entry.rs index 1405098..3cee902 100644 --- a/crates/television-channels/src/entry.rs +++ b/television/channels/entry.rs @@ -80,7 +80,7 @@ impl Entry { /// /// Additional fields can be set using the builder pattern. /// ``` - /// use television_channels::entry::{Entry, PreviewType}; + /// use television::channels::entry::{Entry, PreviewType}; /// use devicons::FileIcon; /// /// let entry = Entry::new("name".to_string(), PreviewType::EnvVar) diff --git a/crates/television-channels/src/channels/env.rs b/television/channels/env.rs similarity index 88% rename from crates/television-channels/src/channels/env.rs rename to television/channels/env.rs index aee2f6b..737c468 100644 --- a/crates/television-channels/src/channels/env.rs +++ b/television/channels/env.rs @@ -4,9 +4,9 @@ use devicons::FileIcon; use rustc_hash::{FxBuildHasher, FxHashSet}; use super::OnAir; -use crate::entry::{Entry, PreviewType}; -use television_fuzzy::matcher::{config::Config, Matcher}; -use television_utils::indices::sep_name_and_value_indices; +use crate::channels::entry::{Entry, PreviewType}; +use crate::matcher::{config::Config, Matcher}; +use crate::utils::indices::sep_name_and_value_indices; #[derive(Debug, Clone)] struct EnvVar { @@ -29,9 +29,15 @@ impl Channel { let matcher = Matcher::new(Config::default().n_threads(NUM_THREADS)); let injector = matcher.injector(); for (name, value) in std::env::vars() { - let () = injector.push(EnvVar { name, value }, |e, cols| { - cols[0] = (e.name.clone() + &e.value).into(); - }); + let () = injector.push( + EnvVar { + name: name.clone(), + value: value.clone(), + }, + |e, cols| { + cols[0] = (e.name.clone() + &e.value).into(); + }, + ); } Channel { matcher, diff --git a/crates/television-channels/src/channels/files.rs b/television/channels/files.rs similarity index 96% rename from crates/television-channels/src/channels/files.rs rename to television/channels/files.rs index cdc9cff..ef09b07 100644 --- a/crates/television-channels/src/channels/files.rs +++ b/television/channels/files.rs @@ -1,11 +1,11 @@ +use crate::channels::entry::{Entry, PreviewType}; use crate::channels::{OnAir, TelevisionChannel}; -use crate::entry::{Entry, PreviewType}; +use crate::matcher::{config::Config, injector::Injector, Matcher}; +use crate::utils::files::{walk_builder, DEFAULT_NUM_THREADS}; use devicons::FileIcon; use rustc_hash::{FxBuildHasher, FxHashSet}; use std::collections::HashSet; use std::path::PathBuf; -use television_fuzzy::matcher::{config::Config, injector::Injector, Matcher}; -use television_utils::files::{walk_builder, DEFAULT_NUM_THREADS}; pub struct Channel { matcher: Matcher, @@ -176,7 +176,7 @@ async fn load_files(paths: Vec, injector: Injector) { .to_string_lossy(); let () = injector.push(file_path.to_string(), |e, cols| { - cols[0] = e.clone().into(); + cols[0] = e.to_string().into(); }); } } diff --git a/crates/television-channels/src/channels/git_repos.rs b/television/channels/git_repos.rs similarity index 96% rename from crates/television-channels/src/channels/git_repos.rs rename to television/channels/git_repos.rs index 1b283fc..d3b574d 100644 --- a/crates/television-channels/src/channels/git_repos.rs +++ b/television/channels/git_repos.rs @@ -8,10 +8,10 @@ use std::path::PathBuf; use tokio::task::JoinHandle; use tracing::debug; +use crate::channels::entry::{Entry, PreviewCommand, PreviewType}; use crate::channels::OnAir; -use crate::entry::{Entry, PreviewCommand, PreviewType}; -use television_fuzzy::matcher::{config::Config, injector::Injector, Matcher}; -use television_utils::files::{walk_builder, DEFAULT_NUM_THREADS}; +use crate::matcher::{config::Config, injector::Injector, Matcher}; +use crate::utils::files::{walk_builder, DEFAULT_NUM_THREADS}; pub struct Channel { matcher: Matcher, diff --git a/crates/television-channels/src/channels.rs b/television/channels/mod.rs similarity index 98% rename from crates/television-channels/src/channels.rs rename to television/channels/mod.rs index 6071d9b..c259aac 100644 --- a/crates/television-channels/src/channels.rs +++ b/television/channels/mod.rs @@ -1,17 +1,18 @@ -use crate::entry::Entry; +use crate::channels::entry::Entry; use color_eyre::Result; use rustc_hash::FxHashSet; use television_derive::{Broadcast, ToCliChannel, ToUnitChannel}; -mod alias; -mod cable; -mod dirs; -mod env; -mod files; -mod git_repos; +pub mod alias; +pub mod cable; +pub mod dirs; +pub mod entry; +pub mod env; +pub mod files; +pub mod git_repos; pub mod remote_control; pub mod stdin; -mod text; +pub mod text; /// The interface that all television channels must implement. /// diff --git a/crates/television-channels/src/channels/remote_control.rs b/television/channels/remote_control.rs similarity index 95% rename from crates/television-channels/src/channels/remote_control.rs rename to television/channels/remote_control.rs index 3347d59..323ecaf 100644 --- a/crates/television-channels/src/channels/remote_control.rs +++ b/television/channels/remote_control.rs @@ -1,14 +1,14 @@ use std::collections::HashSet; use std::fmt::Display; -use crate::cable::{CableChannelPrototype, CableChannels}; +use crate::channels::cable::{CableChannelPrototype, CableChannels}; +use crate::channels::entry::{Entry, PreviewType}; use crate::channels::{CliTvChannel, OnAir, TelevisionChannel, UnitChannel}; -use crate::entry::{Entry, PreviewType}; +use crate::matcher::{config::Config, Matcher}; use clap::ValueEnum; use color_eyre::Result; use devicons::FileIcon; use rustc_hash::{FxBuildHasher, FxHashSet}; -use television_fuzzy::matcher::{config::Config, Matcher}; use super::cable; @@ -56,7 +56,7 @@ impl RemoteControl { ); for button in buttons { let () = injector.push(button.clone(), |e, cols| { - cols[0] = e.to_string().clone().into(); + cols[0] = e.to_string().into(); }); } RemoteControl { @@ -154,13 +154,6 @@ impl OnAir for RemoteControl { .collect() } - fn selected_entries(&self) -> &FxHashSet { - &self.selected_entries - } - - #[allow(unused_variables)] - fn toggle_selection(&mut self, entry: &Entry) {} - fn get_result(&self, index: u32) -> Option { self.matcher.get_result(index).map(|item| { let path = item.matched_string; @@ -168,6 +161,13 @@ impl OnAir for RemoteControl { }) } + fn selected_entries(&self) -> &FxHashSet { + &self.selected_entries + } + + #[allow(unused_variables)] + fn toggle_selection(&mut self, entry: &Entry) {} + fn result_count(&self) -> u32 { self.matcher.matched_item_count } diff --git a/crates/television-channels/src/channels/stdin.rs b/television/channels/stdin.rs similarity index 90% rename from crates/television-channels/src/channels/stdin.rs rename to television/channels/stdin.rs index 2ea4262..6acb760 100644 --- a/crates/television-channels/src/channels/stdin.rs +++ b/television/channels/stdin.rs @@ -8,8 +8,8 @@ use rustc_hash::{FxBuildHasher, FxHashSet}; use tracing::debug; use super::OnAir; -use crate::entry::{Entry, PreviewType}; -use television_fuzzy::matcher::{config::Config, injector::Injector, Matcher}; +use crate::channels::entry::{Entry, PreviewType}; +use crate::matcher::{config::Config, injector::Injector, Matcher}; pub struct Channel { matcher: Matcher, @@ -48,9 +48,10 @@ fn stream_from_stdin(injector: &Injector) { loop { match stdin.read_line(&mut buffer) { Ok(c) if c > 0 => { - if !buffer.trim().is_empty() { - injector.push(buffer.trim().to_string(), |e, cols| { - cols[0] = e.clone().into(); + let buf = buffer.trim(); + if !buf.is_empty() { + injector.push(buf.to_string(), |e, cols| { + cols[0] = e.to_string().into(); }); } buffer.clear(); diff --git a/crates/television-channels/src/channels/text.rs b/television/channels/text.rs similarity index 95% rename from crates/television-channels/src/channels/text.rs rename to television/channels/text.rs index d58fa30..303249d 100644 --- a/crates/television-channels/src/channels/text.rs +++ b/television/channels/text.rs @@ -1,5 +1,10 @@ use super::{OnAir, TelevisionChannel}; -use crate::entry::{Entry, PreviewType}; +use crate::channels::entry::{Entry, PreviewType}; +use crate::matcher::{config::Config, injector::Injector, Matcher}; +use crate::utils::files::{walk_builder, DEFAULT_NUM_THREADS}; +use crate::utils::strings::{ + proportion_of_printable_ascii_characters, PRINTABLE_ASCII_THRESHOLD, +}; use devicons::FileIcon; use ignore::WalkState; use rustc_hash::{FxBuildHasher, FxHashSet}; @@ -10,11 +15,6 @@ use std::{ path::{Path, PathBuf}, sync::{atomic::AtomicUsize, Arc}, }; -use television_fuzzy::matcher::{config::Config, injector::Injector, Matcher}; -use television_utils::files::{walk_builder, DEFAULT_NUM_THREADS}; -use television_utils::strings::{ - proportion_of_printable_ascii_characters, PRINTABLE_ASCII_THRESHOLD, -}; use tracing::{debug, trace, warn}; #[derive(Debug, Clone)] @@ -86,14 +86,15 @@ impl Channel { let injector = matcher.injector(); let load_handle = tokio::spawn(async move { for entry in entries.into_iter().take(MAX_LINES_IN_MEM) { + let v = entry.value.unwrap(); injector.push( CandidateLine::new( entry.name.into(), - entry.value.unwrap(), + v, entry.line_number.unwrap(), ), - |c, cols| { - cols[0] = c.line.clone().into(); + |e, cols| { + cols[0] = e.line.clone().into(); }, ); } @@ -358,11 +359,11 @@ fn try_inject_lines( path.strip_prefix(current_dir) .unwrap_or(path) .to_path_buf(), - l, + l.clone(), line_number, ); - let () = injector.push(candidate, |c, cols| { - cols[0] = c.line.clone().into(); + let () = injector.push(candidate, |e, cols| { + cols[0] = e.line.clone().into(); }); injected_lines += 1; } diff --git a/crates/television/cli.rs b/television/cli.rs similarity index 96% rename from crates/television/cli.rs rename to television/cli.rs index 9f218b9..44a925d 100644 --- a/crates/television/cli.rs +++ b/television/cli.rs @@ -5,15 +5,14 @@ use clap::{Parser, Subcommand, ValueEnum}; use color_eyre::{eyre::eyre, Result}; use tracing::debug; +use crate::channels::{ + cable::CableChannelPrototype, entry::PreviewCommand, CliTvChannel, +}; +use crate::utils::shell::Shell as UtilShell; use crate::{ cable, config::{get_config_dir, get_data_dir}, }; -use television_channels::{ - cable::CableChannelPrototype, channels::CliTvChannel, - entry::PreviewCommand, -}; -use television_utils::shell::Shell as UtilShell; #[derive(Parser, Debug)] #[command(author, version = version(), about)] @@ -224,7 +223,11 @@ pub fn list_channels() { /// if no match is found, throw an error /// /// ## Example: -/// ``` +/// ```ignore +/// use television::channels::CliTvChannel; +/// use television::cli::ParsedCliChannel; +/// use television::cli::guess_channel_from_prompt; +/// /// let prompt = "ls -l"; /// let command_mapping = hashmap! { /// "ls".to_string() => "files".to_string(), @@ -246,12 +249,10 @@ pub fn guess_channel_from_prompt( // git checkout -qf // --- -------- --- <--------- if prompt.trim().is_empty() { - match command_mapping.get("") { - Some(channel) => return parse_channel(channel), - None => { - return Err(eyre!("No channel found for prompt: {}", prompt)) - } - } + return match command_mapping.get("") { + Some(channel) => parse_channel(channel), + None => Err(eyre!("No channel found for prompt: {}", prompt)), + }; } let rev_prompt_words = prompt.split_whitespace().rev(); let mut stack = Vec::new(); diff --git a/crates/television/config.rs b/television/config.rs similarity index 99% rename from crates/television/config.rs rename to television/config.rs index 17844cc..0abcfc8 100644 --- a/crates/television/config.rs +++ b/television/config.rs @@ -20,7 +20,7 @@ mod styles; mod themes; mod ui; -const CONFIG: &str = include_str!("../../.config/config.toml"); +const CONFIG: &str = include_str!("../.config/config.toml"); #[allow(dead_code, clippy::module_name_repetitions)] #[derive(Clone, Debug, Deserialize, Default)] diff --git a/crates/television/config/keybindings.rs b/television/config/keybindings.rs similarity index 99% rename from crates/television/config/keybindings.rs rename to television/config/keybindings.rs index 4298efc..4743799 100644 --- a/crates/television/config/keybindings.rs +++ b/television/config/keybindings.rs @@ -1,11 +1,11 @@ use crate::action::Action; use crate::event::{convert_raw_event_to_key, Key}; +use crate::screen::mode::Mode; use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; use rustc_hash::FxHashMap; use serde::{Deserialize, Deserializer}; use std::fmt::Display; use std::ops::{Deref, DerefMut}; -use television_screen::mode::Mode; #[derive(Clone, Debug, Deserialize)] pub enum Binding { diff --git a/crates/television/config/previewers.rs b/television/config/previewers.rs similarity index 91% rename from crates/television/config/previewers.rs rename to television/config/previewers.rs index 2c75686..1ea5f37 100644 --- a/crates/television/config/previewers.rs +++ b/television/config/previewers.rs @@ -1,9 +1,8 @@ use std::collections::HashMap; +use crate::preview::{previewers, PreviewerConfig}; use config::ValueKind; use serde::Deserialize; -use television_previewers::previewers; -use television_previewers::previewers::PreviewerConfig; #[derive(Clone, Debug, Deserialize, Default)] pub struct PreviewersConfig { @@ -17,7 +16,7 @@ pub struct PreviewersConfig { impl From for PreviewerConfig { fn from(val: PreviewersConfig) -> Self { PreviewerConfig::default() - .file(previewers::FilePreviewerConfig::new(val.file.theme)) + .file(previewers::files::FilePreviewerConfig::new(val.file.theme)) } } diff --git a/crates/television/config/shell_integration.rs b/television/config/shell_integration.rs similarity index 100% rename from crates/television/config/shell_integration.rs rename to television/config/shell_integration.rs diff --git a/crates/television/config/styles.rs b/television/config/styles.rs similarity index 99% rename from crates/television/config/styles.rs rename to television/config/styles.rs index d7f65e4..19a826a 100644 --- a/crates/television/config/styles.rs +++ b/television/config/styles.rs @@ -1,8 +1,8 @@ +use crate::screen::mode::Mode; use ratatui::prelude::{Color, Modifier, Style}; use rustc_hash::FxHashMap; use serde::{Deserialize, Deserializer}; use std::ops::{Deref, DerefMut}; -use television_screen::mode::Mode; #[derive(Clone, Debug, Default)] pub struct Styles(pub FxHashMap>); diff --git a/crates/television/config/themes.rs b/television/config/themes.rs similarity index 99% rename from crates/television/config/themes.rs rename to television/config/themes.rs index dca43ae..01c9ddf 100644 --- a/crates/television/config/themes.rs +++ b/television/config/themes.rs @@ -1,12 +1,12 @@ use color_eyre::Result; use std::path::PathBuf; -use ratatui::style::Color as RatatuiColor; -use serde::Deserialize; -use television_screen::colors::{ +use crate::screen::colors::{ Colorscheme, GeneralColorscheme, HelpColorscheme, InputColorscheme, ModeColorscheme, PreviewColorscheme, ResultsColorscheme, }; +use ratatui::style::Color as RatatuiColor; +use serde::Deserialize; use super::get_config_dir; @@ -149,7 +149,7 @@ pub const DEFAULT_THEME: &str = "default"; impl Default for Theme { fn default() -> Self { - let theme_content = include_str!("../../../themes/default.toml"); + let theme_content = include_str!("../../themes/default.toml"); toml::from_str(theme_content).unwrap() } } diff --git a/television/config/themes/builtin.rs b/television/config/themes/builtin.rs new file mode 100644 index 0000000..bb6826d --- /dev/null +++ b/television/config/themes/builtin.rs @@ -0,0 +1,43 @@ +use rustc_hash::FxHashMap; + +use lazy_static::lazy_static; + +lazy_static! { + pub static ref BUILTIN_THEMES: FxHashMap<&'static str, &'static str> = { + let mut m = FxHashMap::default(); + m.insert("default", include_str!("../../../themes/default.toml")); + m.insert( + "television", + include_str!("../../../themes/television.toml"), + ); + m.insert( + "gruvbox-dark", + include_str!("../../../themes/gruvbox-dark.toml"), + ); + m.insert( + "gruvbox-light", + include_str!("../../../themes/gruvbox-light.toml"), + ); + m.insert( + "catppuccin", + include_str!("../../../themes/catppuccin.toml"), + ); + m.insert("nord-dark", include_str!("../../../themes/nord-dark.toml")); + m.insert( + "solarized-dark", + include_str!("../../../themes/solarized-dark.toml"), + ); + m.insert( + "solarized-light", + include_str!("../../../themes/solarized-light.toml"), + ); + m.insert("dracula", include_str!("../../../themes/dracula.toml")); + m.insert("monokai", include_str!("../../../themes/monokai.toml")); + m.insert("onedark", include_str!("../../../themes/onedark.toml")); + m.insert( + "tokyonight", + include_str!("../../../themes/tokyonight.toml"), + ); + m + }; +} diff --git a/crates/television/config/ui.rs b/television/config/ui.rs similarity index 96% rename from crates/television/config/ui.rs rename to television/config/ui.rs index 5ebea97..fddd459 100644 --- a/crates/television/config/ui.rs +++ b/television/config/ui.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use config::ValueKind; use serde::Deserialize; -use television_screen::layout::{InputPosition, PreviewTitlePosition}; +use crate::screen::layout::{InputPosition, PreviewTitlePosition}; use super::themes::DEFAULT_THEME; diff --git a/crates/television/errors.rs b/television/errors.rs similarity index 100% rename from crates/television/errors.rs rename to television/errors.rs diff --git a/crates/television/event.rs b/television/event.rs similarity index 100% rename from crates/television/event.rs rename to television/event.rs diff --git a/crates/television/input.rs b/television/input.rs similarity index 94% rename from crates/television/input.rs rename to television/input.rs index 61bcc95..65b81ad 100644 --- a/crates/television/input.rs +++ b/television/input.rs @@ -1,5 +1,5 @@ use crate::action::Action; -use television_utils::input::InputRequest; +use crate::utils::input::InputRequest; pub fn convert_action_to_input_request( action: &Action, diff --git a/crates/television/keymap.rs b/television/keymap.rs similarity index 97% rename from crates/television/keymap.rs rename to television/keymap.rs index dc443ef..2090fb7 100644 --- a/crates/television/keymap.rs +++ b/television/keymap.rs @@ -1,8 +1,8 @@ use rustc_hash::FxHashMap; use std::ops::Deref; +use crate::screen::mode::Mode; use color_eyre::Result; -use television_screen::mode::Mode; use crate::action::Action; use crate::config::{Binding, KeyBindings}; diff --git a/television/lib.rs b/television/lib.rs new file mode 100644 index 0000000..17f710f --- /dev/null +++ b/television/lib.rs @@ -0,0 +1,19 @@ +pub mod action; +pub mod app; +pub mod cable; +pub mod channels; +pub mod cli; +pub mod config; +pub mod errors; +pub mod event; +pub mod input; +pub mod keymap; +pub mod logging; +pub mod matcher; +pub mod picker; +pub mod preview; +pub mod render; +pub mod screen; +pub mod television; +pub mod tui; +pub mod utils; diff --git a/crates/television/logging.rs b/television/logging.rs similarity index 100% rename from crates/television/logging.rs rename to television/logging.rs diff --git a/crates/television/main.rs b/television/main.rs similarity index 86% rename from crates/television/main.rs rename to television/main.rs index 1349209..9119582 100644 --- a/crates/television/main.rs +++ b/television/main.rs @@ -7,40 +7,24 @@ use clap::Parser; use color_eyre::Result; use tracing::{debug, error, info}; -use crate::app::App; -use crate::cli::{ +use television::app::App; +use television::channels::{ + entry::PreviewType, stdin::Channel as StdinChannel, TelevisionChannel, +}; +use television::cli::{ guess_channel_from_prompt, list_channels, Cli, ParsedCliChannel, PostProcessedCli, }; -use crate::config::Config; -use television_channels::{ - channels::{stdin::Channel as StdinChannel, TelevisionChannel}, - entry::PreviewType, -}; -use television_utils::{ +use television::config::Config; +use television::utils::{ shell::{completion_script, Shell}, stdin::is_readable_stdin, }; -pub mod action; -pub mod app; -pub mod cable; -pub mod cli; -pub mod config; -pub mod errors; -pub mod event; -pub mod input; -pub mod keymap; -pub mod logging; -pub mod picker; -pub mod render; -pub mod television; -pub mod tui; - #[tokio::main(flavor = "multi_thread")] async fn main() -> Result<()> { - errors::init()?; - logging::init()?; + television::errors::init()?; + television::logging::init()?; let args: PostProcessedCli = Cli::parse().into(); debug!("{:?}", args); @@ -49,11 +33,11 @@ async fn main() -> Result<()> { if let Some(command) = args.command { match command { - cli::Command::ListChannels => { + television::cli::Command::ListChannels => { list_channels(); exit(0); } - cli::Command::InitShell { shell } => { + television::cli::Command::InitShell { shell } => { let script = completion_script(Shell::from(shell))?; println!("{script}"); exit(0); diff --git a/crates/television-fuzzy/src/matcher/config.rs b/television/matcher/config.rs similarity index 100% rename from crates/television-fuzzy/src/matcher/config.rs rename to television/matcher/config.rs diff --git a/crates/television-fuzzy/src/matcher/injector.rs b/television/matcher/injector.rs similarity index 95% rename from crates/television-fuzzy/src/matcher/injector.rs rename to television/matcher/injector.rs index 3f7a74d..236480a 100644 --- a/crates/television-fuzzy/src/matcher/injector.rs +++ b/television/matcher/injector.rs @@ -28,7 +28,7 @@ where /// /// # Example /// ``` - /// use television_fuzzy::matcher::{config::Config, Matcher}; + /// use television::matcher::{config::Config, Matcher}; /// /// let config = Config::default(); /// let matcher = Matcher::new(config); diff --git a/crates/television-fuzzy/src/matcher/lazy.rs b/television/matcher/lazy.rs similarity index 94% rename from crates/television-fuzzy/src/matcher/lazy.rs rename to television/matcher/lazy.rs index 055fbb4..e8930d0 100644 --- a/crates/television-fuzzy/src/matcher/lazy.rs +++ b/television/matcher/lazy.rs @@ -9,7 +9,7 @@ use std::ops::DerefMut; /// /// # Example /// ```rust -/// use television_fuzzy::matcher::lazy::LazyMutex; +/// use television::matcher::lazy::LazyMutex; /// /// struct Thing { /// // ... @@ -61,7 +61,7 @@ impl LazyMutex { /// /// # Example /// ```ignore -/// use television-fuzzy::matcher::{lazy::MATCHER, matched_item::MatchedItem}; +/// use television::matcher::{lazy::MATCHER, matched_item::MatchedItem}; /// /// let snapshot = channel_matcher.snapshot(); /// diff --git a/crates/television-fuzzy/src/matcher/matched_item.rs b/television/matcher/matched_item.rs similarity index 100% rename from crates/television-fuzzy/src/matcher/matched_item.rs rename to television/matcher/matched_item.rs diff --git a/crates/television-fuzzy/src/matcher/mod.rs b/television/matcher/mod.rs similarity index 92% rename from crates/television-fuzzy/src/matcher/mod.rs rename to television/matcher/mod.rs index 3602814..1eae8a6 100644 --- a/crates/television-fuzzy/src/matcher/mod.rs +++ b/television/matcher/mod.rs @@ -1,10 +1,6 @@ use injector::Injector; use std::sync::Arc; -use crate::matcher::{ - config::Config, lazy::MATCHER, matched_item::MatchedItem, -}; - pub mod config; pub mod injector; pub mod lazy; @@ -61,7 +57,7 @@ where I: Sync + Send + Clone + 'static, { /// Create a new fuzzy matcher with the given configuration. - pub fn new(config: Config) -> Self { + pub fn new(config: config::Config) -> Self { Self { inner: nucleo::Nucleo::new( (&config).into(), @@ -89,7 +85,7 @@ where /// /// # Example /// ``` - /// use television_fuzzy::matcher::{config::Config, Matcher}; + /// use television::matcher::{config::Config, Matcher}; /// /// let config = Config::default(); /// let matcher = Matcher::new(config); @@ -139,7 +135,7 @@ where /// /// # Example /// ``` - /// use television_fuzzy::matcher::{config::Config, Matcher}; + /// use television::matcher::{config::Config, Matcher}; /// /// let config = Config::default(); /// let mut matcher: Matcher = Matcher::new(config); @@ -158,13 +154,13 @@ where &mut self, num_entries: u32, offset: u32, - ) -> Vec> { + ) -> Vec> { let snapshot = self.inner.snapshot(); self.total_item_count = snapshot.item_count(); self.matched_item_count = snapshot.matched_item_count(); let mut col_indices = Vec::new(); - let mut matcher = MATCHER.lock(); + let mut matcher = lazy::MATCHER.lock(); snapshot .matched_items( @@ -182,7 +178,7 @@ where let indices = col_indices.drain(..); let matched_string = item.matcher_columns[0].to_string(); - MatchedItem { + matched_item::MatchedItem { inner: item.data.clone(), matched_string, match_indices: indices.map(|i| (i, i + 1)).collect(), @@ -195,7 +191,7 @@ where /// /// # Example /// ``` - /// use television_fuzzy::matcher::{config::Config, Matcher}; + /// use television::matcher::{config::Config, Matcher}; /// /// let config = Config::default(); /// let mut matcher: Matcher = Matcher::new(config); @@ -206,11 +202,14 @@ where /// // ... /// } /// ``` - pub fn get_result(&self, index: u32) -> Option> { + pub fn get_result( + &self, + index: u32, + ) -> Option> { let snapshot = self.inner.snapshot(); snapshot.get_matched_item(index).map(|item| { let matched_string = item.matcher_columns[0].to_string(); - MatchedItem { + matched_item::MatchedItem { inner: item.data.clone(), matched_string, match_indices: Vec::new(), diff --git a/crates/television/picker.rs b/television/picker.rs similarity index 99% rename from crates/television/picker.rs rename to television/picker.rs index e25ba2f..a192cd0 100644 --- a/crates/television/picker.rs +++ b/television/picker.rs @@ -1,5 +1,5 @@ +use crate::utils::{input::Input, strings::EMPTY_STRING}; use ratatui::widgets::ListState; -use television_utils::{input::Input, strings::EMPTY_STRING}; #[derive(Debug)] pub struct Picker { diff --git a/crates/television-previewers/src/ansi.rs b/television/preview/ansi.rs similarity index 86% rename from crates/television-previewers/src/ansi.rs rename to television/preview/ansi.rs index 893e3dd..f841281 100644 --- a/crates/television-previewers/src/ansi.rs +++ b/television/preview/ansi.rs @@ -8,7 +8,7 @@ pub mod code; pub mod error; pub mod parser; pub use error::Error; -use tui::text::Text; +use ratatui::text::Text; /// `IntoText` will convert any type that has a `AsRef<[u8]>` to a Text. pub trait IntoText { @@ -24,11 +24,11 @@ where T: AsRef<[u8]>, { fn into_text(&self) -> Result, Error> { - Ok(crate::ansi::parser::text(self.as_ref())?.1) + Ok(parser::text(self.as_ref())?.1) } #[cfg(feature = "zero-copy")] fn to_text(&self) -> Result, Error> { - Ok(crate::ansi::parser::text_fast(self.as_ref())?.1) + Ok(parser::text_fast(self.as_ref())?.1) } } diff --git a/crates/television-previewers/src/ansi/LICENSE b/television/preview/ansi/LICENSE similarity index 100% rename from crates/television-previewers/src/ansi/LICENSE rename to television/preview/ansi/LICENSE diff --git a/crates/television-previewers/src/ansi/code.rs b/television/preview/ansi/code.rs similarity index 99% rename from crates/television-previewers/src/ansi/code.rs rename to television/preview/ansi/code.rs index 52305a0..d23d3c9 100644 --- a/crates/television-previewers/src/ansi/code.rs +++ b/television/preview/ansi/code.rs @@ -1,4 +1,4 @@ -use tui::style::Color; +use ratatui::style::Color; /// This enum stores most types of ansi escape sequences /// diff --git a/crates/television-previewers/src/ansi/error.rs b/television/preview/ansi/error.rs similarity index 100% rename from crates/television-previewers/src/ansi/error.rs rename to television/preview/ansi/error.rs diff --git a/crates/television-previewers/src/ansi/parser.rs b/television/preview/ansi/parser.rs similarity index 97% rename from crates/television-previewers/src/ansi/parser.rs rename to television/preview/ansi/parser.rs index 4dc520e..9f8eb2e 100644 --- a/crates/television-previewers/src/ansi/parser.rs +++ b/television/preview/ansi/parser.rs @@ -1,4 +1,4 @@ -use crate::ansi::code::AnsiCode; +use crate::preview::ansi::code::AnsiCode; use nom::{ branch::alt, bytes::complete::{tag, take, take_till, take_while}, @@ -6,18 +6,17 @@ use nom::{ complete::{char, i64, not_line_ending, u8}, is_alphabetic, }, - combinator::{map_res, opt, recognize, value}, - error::{self, FromExternalError}, + combinator::{map_res, opt}, multi::fold_many0, - sequence::{delimited, preceded, terminated, tuple}, + sequence::{delimited, preceded, tuple}, IResult, Parser, }; -use smallvec::{SmallVec, ToSmallVec}; -use std::str::FromStr; -use tui::{ +use ratatui::{ style::{Color, Modifier, Style, Stylize}, text::{Line, Span, Text}, }; +use smallvec::SmallVec; +use std::str::FromStr; #[derive(Debug, Clone, Copy, Eq, PartialEq)] enum ColorType { @@ -35,11 +34,11 @@ struct AnsiItem { #[derive(Debug, Clone, PartialEq)] struct AnsiStates { - pub items: smallvec::SmallVec<[AnsiItem; 2]>, + pub items: SmallVec<[AnsiItem; 2]>, pub style: Style, } -impl From for tui::style::Style { +impl From for Style { fn from(states: AnsiStates) -> Self { let mut style = states.style; for item in states.items { diff --git a/crates/television-previewers/src/previewers/cache.rs b/television/preview/cache.rs similarity index 96% rename from crates/television-previewers/src/previewers/cache.rs rename to television/preview/cache.rs index 718f835..dd1db23 100644 --- a/crates/television-previewers/src/previewers/cache.rs +++ b/television/preview/cache.rs @@ -1,8 +1,8 @@ use rustc_hash::FxHashMap; use std::sync::Arc; -use crate::previewers::Preview; -use television_utils::cache::RingSet; +use crate::preview::Preview; +use crate::utils::cache::RingSet; use tracing::debug; /// Default size of the preview cache: 100 entries. diff --git a/crates/television-previewers/src/previewers.rs b/television/preview/mod.rs similarity index 91% rename from crates/television-previewers/src/previewers.rs rename to television/preview/mod.rs index 7727032..ad9342b 100644 --- a/crates/television-previewers/src/previewers.rs +++ b/television/preview/mod.rs @@ -1,26 +1,23 @@ use std::sync::Arc; +use crate::channels::entry::{Entry, PreviewType}; use devicons::FileIcon; -use television_channels::entry::{Entry, PreviewType}; -pub mod basic; +pub mod ansi; pub mod cache; -pub mod command; -pub mod env; -pub mod files; -pub mod meta; +pub mod previewers; // previewer types -pub use basic::BasicPreviewer; -pub use basic::BasicPreviewerConfig; -pub use command::CommandPreviewer; -pub use command::CommandPreviewerConfig; -pub use env::EnvVarPreviewer; -pub use env::EnvVarPreviewerConfig; -pub use files::FilePreviewer; -pub use files::FilePreviewerConfig; -use television_utils::cache::RingSet; -use television_utils::syntax::HighlightedLines; +use crate::utils::cache::RingSet; +use crate::utils::syntax::HighlightedLines; +pub use previewers::basic::BasicPreviewer; +pub use previewers::basic::BasicPreviewerConfig; +pub use previewers::command::CommandPreviewer; +pub use previewers::command::CommandPreviewerConfig; +pub use previewers::env::EnvVarPreviewer; +pub use previewers::env::EnvVarPreviewerConfig; +pub use previewers::files::FilePreviewer; +pub use previewers::files::FilePreviewerConfig; #[derive(Clone, Debug)] pub enum PreviewContent { diff --git a/crates/television-previewers/src/previewers/basic.rs b/television/preview/previewers/basic.rs similarity index 88% rename from crates/television-previewers/src/previewers/basic.rs rename to television/preview/previewers/basic.rs index 0e8c040..9cddec9 100644 --- a/crates/television-previewers/src/previewers/basic.rs +++ b/television/preview/previewers/basic.rs @@ -1,7 +1,7 @@ use std::sync::Arc; -use crate::previewers::{Preview, PreviewContent}; -use television_channels::entry::Entry; +use crate::channels::entry::Entry; +use crate::preview::{Preview, PreviewContent}; #[derive(Debug, Default)] pub struct BasicPreviewer { diff --git a/crates/television-previewers/src/previewers/command.rs b/television/preview/previewers/command.rs similarity index 95% rename from crates/television-previewers/src/previewers/command.rs rename to television/preview/previewers/command.rs index 14942bd..122c08a 100644 --- a/crates/television-previewers/src/previewers/command.rs +++ b/television/preview/previewers/command.rs @@ -1,13 +1,13 @@ -use crate::previewers::cache::PreviewCache; -use crate::previewers::{Preview, PreviewContent}; +use crate::channels::entry::{Entry, PreviewCommand}; +use crate::preview::cache::PreviewCache; +use crate::preview::{Preview, PreviewContent}; +use crate::utils::command::shell_command; use lazy_static::lazy_static; use parking_lot::Mutex; use regex::Regex; use rustc_hash::FxHashSet; use std::sync::atomic::{AtomicU8, Ordering}; use std::sync::Arc; -use television_channels::entry::{Entry, PreviewCommand}; -use television_utils::command::shell_command; use tracing::debug; #[allow(dead_code)] @@ -123,8 +123,8 @@ lazy_static! { /// /// # Example /// ``` -/// use television_channels::entry::{PreviewCommand, PreviewType, Entry}; -/// use television_previewers::previewers::command::format_command; +/// use television::channels::entry::{PreviewCommand, PreviewType, Entry}; +/// use television::preview::previewers::command::format_command; /// /// let command = PreviewCommand { /// command: "something {} {2} {0}".to_string(), @@ -200,7 +200,7 @@ pub fn try_preview( #[cfg(test)] mod tests { use super::*; - use television_channels::entry::{Entry, PreviewType}; + use crate::channels::entry::{Entry, PreviewType}; #[test] fn test_format_command() { diff --git a/crates/television-previewers/src/previewers/env.rs b/television/preview/previewers/env.rs similarity index 95% rename from crates/television-previewers/src/previewers/env.rs rename to television/preview/previewers/env.rs index 8264130..f043413 100644 --- a/crates/television-previewers/src/previewers/env.rs +++ b/television/preview/previewers/env.rs @@ -1,8 +1,8 @@ use rustc_hash::FxHashMap; use std::sync::Arc; -use crate::previewers::{Preview, PreviewContent}; -use television_channels::entry; +use crate::channels::entry; +use crate::preview::{Preview, PreviewContent}; #[derive(Debug, Default)] pub struct EnvVarPreviewer { diff --git a/crates/television-previewers/src/previewers/files.rs b/television/preview/previewers/files.rs similarity index 97% rename from crates/television-previewers/src/previewers/files.rs rename to television/preview/previewers/files.rs index d8854b7..52043d5 100644 --- a/crates/television-previewers/src/previewers/files.rs +++ b/television/preview/previewers/files.rs @@ -1,3 +1,5 @@ +use crate::utils::files::{read_into_lines_capped, ReadResult}; +use crate::utils::syntax::HighlightedLines; use parking_lot::Mutex; use rustc_hash::{FxBuildHasher, FxHashSet}; use std::collections::HashSet; @@ -8,16 +10,14 @@ use std::sync::{ atomic::{AtomicU8, Ordering}, Arc, }; -use television_utils::files::{read_into_lines_capped, ReadResult}; -use television_utils::syntax::HighlightedLines; use syntect::{highlighting::Theme, parsing::SyntaxSet}; use tracing::{debug, warn}; -use super::cache::PreviewCache; -use crate::previewers::{meta, Preview, PreviewContent}; -use television_channels::entry; -use television_utils::{ +use crate::channels::entry; +use crate::preview::cache::PreviewCache; +use crate::preview::{previewers::meta, Preview, PreviewContent}; +use crate::utils::{ files::FileType, strings::preprocess_line, syntax::{self, load_highlighting_assets, HighlightingAssetsExt}, diff --git a/crates/television-previewers/src/previewers/meta.rs b/television/preview/previewers/meta.rs similarity index 94% rename from crates/television-previewers/src/previewers/meta.rs rename to television/preview/previewers/meta.rs index 9bfa858..67a24ec 100644 --- a/crates/television-previewers/src/previewers/meta.rs +++ b/television/preview/previewers/meta.rs @@ -1,4 +1,4 @@ -use crate::previewers::{Preview, PreviewContent}; +use crate::preview::{Preview, PreviewContent}; use std::sync::Arc; pub fn not_supported(title: &str) -> Arc { diff --git a/television/preview/previewers/mod.rs b/television/preview/previewers/mod.rs new file mode 100644 index 0000000..fb06d47 --- /dev/null +++ b/television/preview/previewers/mod.rs @@ -0,0 +1,5 @@ +pub mod basic; +pub mod command; +pub mod env; +pub mod files; +pub mod meta; diff --git a/crates/television/render.rs b/television/render.rs similarity index 100% rename from crates/television/render.rs rename to television/render.rs diff --git a/crates/television-screen/src/cache.rs b/television/screen/cache.rs similarity index 98% rename from crates/television-screen/src/cache.rs rename to television/screen/cache.rs index fad4d32..846a0f8 100644 --- a/crates/television-screen/src/cache.rs +++ b/television/screen/cache.rs @@ -2,8 +2,8 @@ use devicons::FileIcon; use rustc_hash::FxHashMap; use std::sync::Arc; +use crate::utils::cache::RingSet; use ratatui::widgets::Paragraph; -use television_utils::cache::RingSet; const DEFAULT_RENDERED_PREVIEW_CACHE_SIZE: usize = 10; diff --git a/crates/television-screen/src/colors.rs b/television/screen/colors.rs similarity index 100% rename from crates/television-screen/src/colors.rs rename to television/screen/colors.rs diff --git a/crates/television-screen/src/help.rs b/television/screen/help.rs similarity index 90% rename from crates/television-screen/src/help.rs rename to television/screen/help.rs index 99f14bf..cc7b6ab 100644 --- a/crates/television-screen/src/help.rs +++ b/television/screen/help.rs @@ -1,14 +1,14 @@ use super::layout::HelpBarLayout; -use crate::colors::{Colorscheme, GeneralColorscheme}; -use crate::logo::build_logo_paragraph; -use crate::metadata::build_metadata_table; -use crate::mode::{mode_color, Mode}; +use crate::channels::UnitChannel; +use crate::screen::colors::{Colorscheme, GeneralColorscheme}; +use crate::screen::logo::build_logo_paragraph; +use crate::screen::metadata::build_metadata_table; +use crate::screen::mode::{mode_color, Mode}; +use crate::utils::metadata::AppMetadata; use ratatui::layout::Rect; use ratatui::prelude::{Color, Style}; use ratatui::widgets::{Block, BorderType, Borders, Padding, Table}; use ratatui::Frame; -use television_channels::channels::UnitChannel; -use television_utils::metadata::AppMetadata; pub fn draw_logo_block( f: &mut Frame, diff --git a/crates/television-screen/src/input.rs b/television/screen/input.rs similarity index 98% rename from crates/television-screen/src/input.rs rename to television/screen/input.rs index 9c0f433..11dbb9f 100644 --- a/crates/television-screen/src/input.rs +++ b/television/screen/input.rs @@ -1,3 +1,4 @@ +use crate::utils::input::Input; use color_eyre::Result; use ratatui::{ layout::{ @@ -8,9 +9,8 @@ use ratatui::{ widgets::{Block, BorderType, Borders, ListState, Paragraph}, Frame, }; -use television_utils::input::Input; -use crate::{ +use crate::screen::{ colors::Colorscheme, spinner::{Spinner, SpinnerState}, }; diff --git a/crates/television-screen/src/keybindings.rs b/television/screen/keybindings.rs similarity index 99% rename from crates/television-screen/src/keybindings.rs rename to television/screen/keybindings.rs index 5e29cb6..6ece418 100644 --- a/crates/television-screen/src/keybindings.rs +++ b/television/screen/keybindings.rs @@ -1,7 +1,7 @@ use rustc_hash::FxHashMap; use std::fmt::Display; -use crate::{colors::Colorscheme, mode::Mode}; +use crate::screen::{colors::Colorscheme, mode::Mode}; use ratatui::{ layout::Constraint, style::{Color, Style}, diff --git a/crates/television-screen/src/layout.rs b/television/screen/layout.rs similarity index 100% rename from crates/television-screen/src/layout.rs rename to television/screen/layout.rs diff --git a/crates/television-screen/src/logo.rs b/television/screen/logo.rs similarity index 100% rename from crates/television-screen/src/logo.rs rename to television/screen/logo.rs diff --git a/crates/television-screen/src/metadata.rs b/television/screen/metadata.rs similarity index 97% rename from crates/television-screen/src/metadata.rs rename to television/screen/metadata.rs index 8ac12d8..8a6484c 100644 --- a/crates/television-screen/src/metadata.rs +++ b/television/screen/metadata.rs @@ -1,17 +1,17 @@ use std::fmt::Display; -use crate::{ +use crate::channels::UnitChannel; +use crate::screen::{ colors::Colorscheme, mode::{mode_color, Mode}, }; +use crate::utils::metadata::AppMetadata; use ratatui::{ layout::Constraint, style::Style, text::Span, widgets::{Cell, Row, Table}, }; -use television_channels::channels::UnitChannel; -use television_utils::metadata::AppMetadata; impl Display for Mode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/crates/television-screen/src/lib.rs b/television/screen/mod.rs similarity index 100% rename from crates/television-screen/src/lib.rs rename to television/screen/mod.rs diff --git a/crates/television-screen/src/mode.rs b/television/screen/mode.rs similarity index 92% rename from crates/television-screen/src/mode.rs rename to television/screen/mode.rs index bcf1480..2b80d45 100644 --- a/crates/television-screen/src/mode.rs +++ b/television/screen/mode.rs @@ -1,7 +1,7 @@ use ratatui::style::Color; use serde::{Deserialize, Serialize}; -use crate::colors::ModeColorscheme; +use crate::screen::colors::ModeColorscheme; pub fn mode_color(mode: Mode, colorscheme: &ModeColorscheme) -> Color { match mode { diff --git a/crates/television-screen/src/preview.rs b/television/screen/preview.rs similarity index 98% rename from crates/television-screen/src/preview.rs rename to television/screen/preview.rs index 2e75984..53a87f8 100644 --- a/crates/television-screen/src/preview.rs +++ b/television/screen/preview.rs @@ -1,7 +1,16 @@ -use crate::{ +use crate::channels::entry::Entry; +use crate::preview::{ + ansi::IntoText, Preview, PreviewContent, FILE_TOO_LARGE_MSG, LOADING_MSG, + PREVIEW_NOT_SUPPORTED_MSG, TIMEOUT_MSG, +}; +use crate::screen::{ cache::RenderedPreviewCache, colors::{Colorscheme, PreviewColorscheme}, }; +use crate::utils::strings::{ + replace_non_printable, shrink_with_ellipsis, ReplaceNonPrintableConfig, + EMPTY_STRING, +}; use color_eyre::eyre::Result; use devicons::FileIcon; use ratatui::widgets::{Block, BorderType, Borders, Padding, Paragraph, Wrap}; @@ -12,18 +21,6 @@ use ratatui::{ }; use std::str::FromStr; use std::sync::{Arc, Mutex}; -use television_channels::entry::Entry; -use television_previewers::{ - ansi::IntoText, - previewers::{ - Preview, PreviewContent, FILE_TOO_LARGE_MSG, LOADING_MSG, - PREVIEW_NOT_SUPPORTED_MSG, TIMEOUT_MSG, - }, -}; -use television_utils::strings::{ - replace_non_printable, shrink_with_ellipsis, ReplaceNonPrintableConfig, - EMPTY_STRING, -}; #[allow(dead_code)] const FILL_CHAR_SLANTED: char = '╱'; diff --git a/crates/television-screen/src/remote_control.rs b/television/screen/remote_control.rs similarity index 94% rename from crates/television-screen/src/remote_control.rs rename to television/screen/remote_control.rs index 387d8e6..b84d285 100644 --- a/crates/television-screen/src/remote_control.rs +++ b/television/screen/remote_control.rs @@ -1,11 +1,11 @@ use rustc_hash::FxHashMap; -use crate::colors::{Colorscheme, GeneralColorscheme}; -use crate::logo::build_remote_logo_paragraph; -use crate::mode::{mode_color, Mode}; -use crate::results::build_results_list; -use television_channels::entry::Entry; -use television_utils::input::Input; +use crate::channels::entry::Entry; +use crate::screen::colors::{Colorscheme, GeneralColorscheme}; +use crate::screen::logo::build_remote_logo_paragraph; +use crate::screen::mode::{mode_color, Mode}; +use crate::screen::results::build_results_list; +use crate::utils::input::Input; use color_eyre::eyre::Result; use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect}; diff --git a/crates/television-screen/src/results.rs b/television/screen/results.rs similarity index 96% rename from crates/television-screen/src/results.rs rename to television/screen/results.rs index 6c52416..dfc40cb 100644 --- a/crates/television-screen/src/results.rs +++ b/television/screen/results.rs @@ -1,5 +1,10 @@ -use crate::colors::{Colorscheme, ResultsColorscheme}; -use crate::layout::InputPosition; +use crate::channels::entry::Entry; +use crate::screen::colors::{Colorscheme, ResultsColorscheme}; +use crate::screen::layout::InputPosition; +use crate::utils::strings::{ + make_matched_string_printable, next_char_boundary, + slice_at_char_boundaries, +}; use color_eyre::eyre::Result; use ratatui::layout::{Alignment, Rect}; use ratatui::prelude::{Color, Line, Span, Style}; @@ -10,15 +15,10 @@ use ratatui::widgets::{ use ratatui::Frame; use rustc_hash::{FxHashMap, FxHashSet}; use std::str::FromStr; -use television_channels::entry::Entry; -use television_utils::strings::{ - make_matched_string_printable, next_char_boundary, - slice_at_char_boundaries, -}; const POINTER_SYMBOL: &str = "> "; const SELECTED_SYMBOL: &str = "● "; -const DESLECTED_SYMBOL: &str = " "; +const DESELECTED_SYMBOL: &str = " "; pub fn build_results_list<'a, 'b>( results_block: Block<'b>, @@ -43,7 +43,7 @@ where Style::default().fg(colorscheme.result_selected_fg), ) } else { - Span::from(DESLECTED_SYMBOL) + Span::from(DESELECTED_SYMBOL) }); } } diff --git a/crates/television-screen/src/spinner.rs b/television/screen/spinner.rs similarity index 100% rename from crates/television-screen/src/spinner.rs rename to television/screen/spinner.rs diff --git a/crates/television/television.rs b/television/television.rs similarity index 97% rename from crates/television/television.rs rename to television/television.rs index 45bf823..9d5a914 100644 --- a/crates/television/television.rs +++ b/television/television.rs @@ -1,7 +1,28 @@ use crate::action::Action; +use crate::channels::entry::{Entry, PreviewType, ENTRY_PLACEHOLDER}; +use crate::channels::{ + remote_control::{load_builtin_channels, RemoteControl}, + OnAir, TelevisionChannel, UnitChannel, +}; use crate::config::{Config, KeyBindings, Theme}; use crate::input::convert_action_to_input_request; use crate::picker::Picker; +use crate::preview::Previewer; +use crate::screen::cache::RenderedPreviewCache; +use crate::screen::colors::Colorscheme; +use crate::screen::help::draw_help_bar; +use crate::screen::input::draw_input_box; +use crate::screen::keybindings::{ + build_keybindings_table, DisplayableAction, DisplayableKeybindings, +}; +use crate::screen::layout::{Dimensions, InputPosition, Layout}; +use crate::screen::mode::Mode; +use crate::screen::preview::draw_preview_content_block; +use crate::screen::remote_control::draw_remote_control; +use crate::screen::results::draw_results_list; +use crate::screen::spinner::{Spinner, SpinnerState}; +use crate::utils::metadata::{AppMetadata, BuildMetadata}; +use crate::utils::strings::EMPTY_STRING; use crate::{cable::load_cable_channels, keymap::Keymap}; use color_eyre::Result; use copypasta::{ClipboardContext, ClipboardProvider}; @@ -9,27 +30,6 @@ use ratatui::{layout::Rect, style::Color, Frame}; use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet}; use std::collections::HashSet; use std::sync::{Arc, Mutex}; -use television_channels::channels::{ - remote_control::{load_builtin_channels, RemoteControl}, - OnAir, TelevisionChannel, UnitChannel, -}; -use television_channels::entry::{Entry, PreviewType, ENTRY_PLACEHOLDER}; -use television_previewers::previewers::Previewer; -use television_screen::cache::RenderedPreviewCache; -use television_screen::colors::Colorscheme; -use television_screen::help::draw_help_bar; -use television_screen::input::draw_input_box; -use television_screen::keybindings::{ - build_keybindings_table, DisplayableAction, DisplayableKeybindings, -}; -use television_screen::layout::{Dimensions, InputPosition, Layout}; -use television_screen::mode::Mode; -use television_screen::preview::draw_preview_content_block; -use television_screen::remote_control::draw_remote_control; -use television_screen::results::draw_results_list; -use television_screen::spinner::{Spinner, SpinnerState}; -use television_utils::metadata::{AppMetadata, BuildMetadata}; -use television_utils::strings::EMPTY_STRING; use tokio::sync::mpsc::UnboundedSender; pub struct Television { diff --git a/crates/television/tui.rs b/television/tui.rs similarity index 100% rename from crates/television/tui.rs rename to television/tui.rs diff --git a/crates/television-utils/src/cache.rs b/television/utils/cache.rs similarity index 99% rename from crates/television-utils/src/cache.rs rename to television/utils/cache.rs index 7f157e3..93a49e3 100644 --- a/crates/television-utils/src/cache.rs +++ b/television/utils/cache.rs @@ -11,7 +11,7 @@ use tracing::debug; /// /// # Example /// ```rust -/// use television_utils::cache::RingSet; +/// use television::utils::cache::RingSet; /// /// let mut ring_set = RingSet::with_capacity(3); /// // push 3 values into the ringset diff --git a/crates/television-utils/src/command.rs b/television/utils/command.rs similarity index 100% rename from crates/television-utils/src/command.rs rename to television/utils/command.rs diff --git a/crates/television-utils/src/files.rs b/television/utils/files.rs similarity index 99% rename from crates/television-utils/src/files.rs rename to television/utils/files.rs index dba455f..fb81fc4 100644 --- a/crates/television-utils/src/files.rs +++ b/television/utils/files.rs @@ -11,10 +11,10 @@ use ignore::{overrides::Override, types::TypesBuilder, WalkBuilder}; use lazy_static::lazy_static; use tracing::{debug, warn}; -use crate::strings::{ +use crate::utils::strings::{ proportion_of_printable_ascii_characters, PRINTABLE_ASCII_THRESHOLD, }; -use crate::threads::default_num_threads; +use crate::utils::threads::default_num_threads; pub struct PartialReadResult { pub lines: Vec, diff --git a/crates/television-utils/src/indices.rs b/television/utils/indices.rs similarity index 100% rename from crates/television-utils/src/indices.rs rename to television/utils/indices.rs diff --git a/crates/television-utils/src/input.rs b/television/utils/input.rs similarity index 100% rename from crates/television-utils/src/input.rs rename to television/utils/input.rs diff --git a/crates/television-utils/src/metadata.rs b/television/utils/metadata.rs similarity index 100% rename from crates/television-utils/src/metadata.rs rename to television/utils/metadata.rs diff --git a/crates/television-utils/src/lib.rs b/television/utils/mod.rs similarity index 100% rename from crates/television-utils/src/lib.rs rename to television/utils/mod.rs diff --git a/crates/television-utils/src/shell.rs b/television/utils/shell.rs similarity index 69% rename from crates/television-utils/src/shell.rs rename to television/utils/shell.rs index faf1911..3d9d0bb 100644 --- a/crates/television-utils/src/shell.rs +++ b/television/utils/shell.rs @@ -9,9 +9,9 @@ pub enum Shell { Cmd, } -const COMPLETION_ZSH: &str = include_str!("../shell/completion.zsh"); -const COMPLETION_BASH: &str = include_str!("../shell/completion.bash"); -const COMPLETION_FISH: &str = include_str!("../shell/completion.fish"); +const COMPLETION_ZSH: &str = include_str!("shell/completion.zsh"); +const COMPLETION_BASH: &str = include_str!("shell/completion.bash"); +const COMPLETION_FISH: &str = include_str!("shell/completion.fish"); pub fn completion_script(shell: Shell) -> Result<&'static str> { match shell { diff --git a/crates/television-utils/shell/completion.bash b/television/utils/shell/completion.bash similarity index 100% rename from crates/television-utils/shell/completion.bash rename to television/utils/shell/completion.bash diff --git a/crates/television-utils/shell/completion.fish b/television/utils/shell/completion.fish similarity index 100% rename from crates/television-utils/shell/completion.fish rename to television/utils/shell/completion.fish diff --git a/crates/television-utils/shell/completion.zsh b/television/utils/shell/completion.zsh similarity index 100% rename from crates/television-utils/shell/completion.zsh rename to television/utils/shell/completion.zsh diff --git a/crates/television-utils/src/stdin.rs b/television/utils/stdin.rs similarity index 100% rename from crates/television-utils/src/stdin.rs rename to television/utils/stdin.rs diff --git a/crates/television-utils/src/strings.rs b/television/utils/strings.rs similarity index 97% rename from crates/television-utils/src/strings.rs rename to television/utils/strings.rs index e9ee29a..be63aa2 100644 --- a/crates/television-utils/src/strings.rs +++ b/television/utils/strings.rs @@ -7,7 +7,7 @@ use lazy_static::lazy_static; /// /// # Examples /// ``` -/// use television_utils::strings::next_char_boundary; +/// use television::utils::strings::next_char_boundary; /// /// let s = "Hello, World!"; /// assert_eq!(next_char_boundary(s, 0), 0); @@ -41,7 +41,7 @@ pub fn next_char_boundary(s: &str, start: usize) -> usize { /// /// # Examples /// ``` -/// use television_utils::strings::prev_char_boundary; +/// use television::utils::strings::prev_char_boundary; /// /// let s = "Hello, World!"; /// assert_eq!(prev_char_boundary(s, 0), 0); @@ -68,7 +68,7 @@ pub fn prev_char_boundary(s: &str, start: usize) -> usize { /// /// # Examples /// ``` -/// use television_utils::strings::slice_at_char_boundaries; +/// use television::utils::strings::slice_at_char_boundaries; /// /// let s = "Hello, World!"; /// assert_eq!(slice_at_char_boundaries(s, 0, 0), ""); @@ -102,7 +102,7 @@ pub fn slice_at_char_boundaries( /// /// # Examples /// ``` -/// use television_utils::strings::slice_up_to_char_boundary; +/// use television::utils::strings::slice_up_to_char_boundary; /// /// let s = "Hello, World!"; /// assert_eq!(slice_up_to_char_boundary(s, 0), ""); @@ -125,7 +125,7 @@ pub fn slice_up_to_char_boundary(s: &str, byte_index: usize) -> &str { /// /// # Examples /// ``` -/// use television_utils::strings::try_parse_utf8_char; +/// use television::utils::strings::try_parse_utf8_char; /// /// let input = b"Hello, World!"; /// let (chr, n) = try_parse_utf8_char(input).unwrap(); @@ -253,7 +253,7 @@ fn is_emoji(ch: char) -> bool { /// /// # Examples /// ``` -/// use television_utils::strings::{replace_non_printable, ReplaceNonPrintableConfig}; +/// use television::utils::strings::{replace_non_printable, ReplaceNonPrintableConfig}; /// /// let input = b"Hello, World!"; /// let (output, offsets) = replace_non_printable(input, &ReplaceNonPrintableConfig::default()); @@ -363,7 +363,7 @@ pub const PRINTABLE_ASCII_THRESHOLD: f32 = 0.7; /// /// # Examples /// ``` -/// use television_utils::strings::proportion_of_printable_ascii_characters; +/// use television::utils::strings::proportion_of_printable_ascii_characters; /// /// let buffer = b"Hello, World!"; /// let proportion = proportion_of_printable_ascii_characters(buffer); @@ -396,7 +396,7 @@ const MAX_LINE_LENGTH: usize = 300; /// /// # Examples /// ``` -/// use television_utils::strings::preprocess_line; +/// use television::utils::strings::preprocess_line; /// /// let line = "Hello, World!"; /// let (processed, offsets) = preprocess_line(line); @@ -434,7 +434,7 @@ pub fn preprocess_line(line: &str) -> (String, Vec) { /// /// # Examples /// ``` -/// use television_utils::strings::make_matched_string_printable; +/// use television::utils::strings::make_matched_string_printable; /// /// let matched_string = "Hello, World!"; /// let match_ranges = vec![(0, 1), (7, 8)]; @@ -525,7 +525,7 @@ pub fn make_matched_string_printable( /// /// # Examples /// ``` -/// use television_utils::strings::shrink_with_ellipsis; +/// use television::utils::strings::shrink_with_ellipsis; /// /// let s = "Hello, World!"; /// assert_eq!(shrink_with_ellipsis(s, 13), "Hello, World!"); diff --git a/crates/television-utils/src/syntax.rs b/television/utils/syntax.rs similarity index 100% rename from crates/television-utils/src/syntax.rs rename to television/utils/syntax.rs diff --git a/crates/television-utils/src/threads.rs b/television/utils/threads.rs similarity index 100% rename from crates/television-utils/src/threads.rs rename to television/utils/threads.rs