Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ratatui rewrite #653

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
730 changes: 671 additions & 59 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion skim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ log = "0.4.22"
env_logger = { version = "0.11.5", optional = true }
time = "0.3.13"
clap = { version = "4.5.20", optional = true, features = ["cargo", "derive"] }
tuikit = "0.5.0"
vte = "0.13.0"
fuzzy-matcher = "0.3.7"
rayon = "1.5.3"
Expand All @@ -45,6 +44,14 @@ defer-drop = "1.3.0"
indexmap = "2.6.0"
rand = "0.8.5"
which = "7.0.0"
ratatui = "0.29.0"
color-eyre = "0.6.3"
crossterm = { version = "0.28.1", features = ["event-stream"] }
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "sync", "time", "tokio-macros"] }
ansi-to-tui = "7.0.0"
futures = "0.3.31"
tokio-util = "0.7.12"
thiserror = "2.0.3"

[features]
default = ["cli"]
Expand Down
4 changes: 3 additions & 1 deletion skim/examples/cmd_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ impl CommandCollector for BasicCmdCollector {
}
}

pub fn main() {
#[tokio::main]
async fn main() {
let cmd_collector = BasicCmdCollector {
items: vec![String::from("foo"), String::from("bar"), String::from("baz")],
};
Expand All @@ -39,6 +40,7 @@ pub fn main() {
.unwrap();

let selected_items = Skim::run_with(&options, None)
.await
.map(|out| out.selected_items)
.unwrap_or_default();

Expand Down
4 changes: 3 additions & 1 deletion skim/examples/custom_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ impl SkimItem for MyItem {
}
}

pub fn main() {
#[tokio::main]
async fn main() {
let options = SkimOptionsBuilder::default()
.height(String::from("50%"))
.multi(true)
Expand All @@ -40,6 +41,7 @@ pub fn main() {
drop(tx_item); // so that skim could know when to stop waiting for more items.

let selected_items = Skim::run_with(&options, Some(rx_item))
.await
.map(|out| out.selected_items)
.unwrap_or_default();

Expand Down
10 changes: 6 additions & 4 deletions skim/examples/custom_keybinding_actions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extern crate skim;
use crossterm::event::KeyCode;
use skim::prelude::*;

// No action is actually performed on your filesystem!
Expand All @@ -12,7 +13,8 @@ fn fake_create_item(item: &str) {
println!("Creating a new item `{}`...", item);
}

pub fn main() {
#[tokio::main]
async fn main() {
// Note: `accept` is a keyword used define custom actions.
// For full list of accepted keywords see `parse_event` in `src/event.rs`.
// `delete` and `create` are arbitrary keywords used for this example.
Expand All @@ -22,12 +24,12 @@ pub fn main() {
.build()
.unwrap();

if let Some(out) = Skim::run_with(&options, None) {
if let Ok(out) = Skim::run_with(&options, None).await {
match out.final_key {
// Delete each selected item
Key::Backspace => out.selected_items.iter().for_each(|i| fake_delete_item(&i.text())),
KeyCode::Backspace => out.selected_items.iter().for_each(|i| fake_delete_item(&i.text())),
// Create a new item based on the query
Key::Enter => fake_create_item(out.query.as_ref()),
KeyCode::Enter => fake_create_item(out.query.as_ref()),
_ => (),
}
};
Expand Down
Loading
Loading