Skip to content

Commit

Permalink
tokio
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyaa committed Sep 5, 2023
1 parent cdbf4a2 commit a7da14f
Show file tree
Hide file tree
Showing 67 changed files with 724 additions and 364 deletions.
174 changes: 174 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ categories = ['command-line-interface', 'command-line-utilities']
[dependencies]
alphanumeric-sort = "^1"
ansi-to-tui = { version = "^3.1.0", optional = true }
async-recursion = "^1"
bitflags = { version = "^2", features = ["serde"] }
chrono = "^0"
clap = { version = "^4", features = ["derive"] }
Expand All @@ -35,6 +36,7 @@ shell-words = "^1"
shellexpand = { version = "^3", features = ["full"] }
signal-hook = "^0"
termion = "^2"
tokio = { version = "^1", features = ["full"] }
toml = "^0"
unicode-segmentation = "^1"
unicode-width = "^0"
Expand Down
23 changes: 13 additions & 10 deletions src/commands/bookmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use termion::event::Event;

use crate::config::{search_directories, BookmarkRaw, BookmarksRaw};
use crate::context::AppContext;
use crate::error::JoshutoResult;
use crate::error::AppResult;
use crate::event::{process_event, AppEvent};
use crate::traits::ToString;
use crate::ui::views::TuiView;
Expand All @@ -29,7 +29,7 @@ fn find_bookmark_file() -> Option<path::PathBuf> {
None
}

pub fn add_bookmark(context: &mut AppContext, backend: &mut AppBackend) -> JoshutoResult {
pub async fn add_bookmark(context: &mut AppContext, backend: &mut AppBackend) -> AppResult {
let cwd = std::env::current_dir()?;

let bookmark_path = match search_directories(BOOKMARKS_FILE, &CONFIG_HIERARCHY) {
Expand All @@ -38,7 +38,7 @@ pub fn add_bookmark(context: &mut AppContext, backend: &mut AppBackend) -> Joshu
};

if let Some(bookmark_path) = bookmark_path {
let key = poll_for_bookmark_key(context, backend);
let key = poll_for_bookmark_key(context, backend).await;
if let Some(key) = key {
if let Ok(mut bookmark) = BOOKMARKS_T.lock() {
bookmark.insert(key, cwd.to_string_lossy().to_string());
Expand Down Expand Up @@ -67,11 +67,11 @@ pub fn add_bookmark(context: &mut AppContext, backend: &mut AppBackend) -> Joshu
Ok(())
}

pub fn change_directory_bookmark(
pub async fn change_directory_bookmark(
context: &mut AppContext,
backend: &mut AppBackend,
) -> JoshutoResult {
let key = poll_for_bookmark_key(context, backend);
) -> AppResult {
let key = poll_for_bookmark_key(context, backend).await;

if let Some(key) = key {
if let Ok(bookmarks) = BOOKMARKS_T.lock() {
Expand All @@ -84,8 +84,11 @@ pub fn change_directory_bookmark(
Ok(())
}

fn poll_for_bookmark_key(context: &mut AppContext, backend: &mut AppBackend) -> Option<Event> {
context.flush_event();
async fn poll_for_bookmark_key(
context: &mut AppContext,
backend: &mut AppBackend,
) -> Option<Event> {
context.flush_event().await;

let mut bookmarks: Vec<String> = BOOKMARKS_T
.lock()
Expand Down Expand Up @@ -128,10 +131,10 @@ fn poll_for_bookmark_key(context: &mut AppContext, backend: &mut AppBackend) ->
frame.render_widget(menu_widget, menu_rect);
});

if let Ok(event) = context.poll_event() {
if let Ok(event) = context.poll_event().await {
match event {
AppEvent::Termion(key) => return Some(key),
event => process_event::process_noninteractive(event, context),
event => process_event::process_noninteractive(event, context).await,
};
}
}
Expand Down
Loading

0 comments on commit a7da14f

Please sign in to comment.