From 2eb6b12bd75a9c53f4a117fa41f4fff33aa82325 Mon Sep 17 00:00:00 2001 From: Soispha Date: Tue, 7 Nov 2023 20:27:06 +0100 Subject: [PATCH] refactor(core): Use the new `keymaps` crate --- Cargo.toml | 1 + src/app/events/handlers/command.rs | 8 ++++---- src/app/events/handlers/input.rs | 2 +- src/app/mod.rs | 10 ++++------ src/app/status.rs | 3 +-- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3478cc7..d454cf3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ tokio = { version = "1.33", features = ["macros", "rt-multi-thread"] } # lua stuff language_macros = { path = "./language_macros" } +keymaps = { path = "./keymaps", features = ["crossterm"] } mlua = { version = "0.9.1", features = ["lua54", "async", "send", "serialize"] } once_cell = "1.18.0" diff --git a/src/app/events/handlers/command.rs b/src/app/events/handlers/command.rs index 9fb0eca..d39d89d 100644 --- a/src/app/events/handlers/command.rs +++ b/src/app/events/handlers/command.rs @@ -3,6 +3,10 @@ use std::{collections::HashMap, str::FromStr}; use anyhow::{Error, Result}; use cli_log::{info, trace, warn}; use crossterm::event::Event; +use keymaps::{ + key_repr::{Key, Keys}, + trie::Node, +}; use tokio::sync::oneshot; use crate::{ @@ -12,10 +16,6 @@ use crate::{ Api, Command, Debug, Keymaps, Raw, Trinitrix, Ui, }, events::EventStatus, - keymappings::{ - key::{Key, Keys}, - trie::Node, - }, status::State, App, }, diff --git a/src/app/events/handlers/input.rs b/src/app/events/handlers/input.rs index d28bff8..250d6d9 100644 --- a/src/app/events/handlers/input.rs +++ b/src/app/events/handlers/input.rs @@ -1,11 +1,11 @@ use anyhow::Result; use cli_log::info; use crossterm::event::Event as CrosstermEvent; +use keymaps::key_repr::{Key, Keys}; use crate::app::{ command_interface::{Api::Raw, Command, Raw::SendInputUnprocessed, Trinitrix::Api}, events::{Event, EventStatus}, - keymappings::key::{Key, Keys}, status::State, App, }; diff --git a/src/app/mod.rs b/src/app/mod.rs index f53c258..8d62176 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1,7 +1,6 @@ pub mod command_interface; pub mod config; pub mod events; -pub mod keymappings; pub mod status; use std::{ @@ -12,16 +11,15 @@ use std::{ use anyhow::{Context, Error, Result}; use cli_log::{info, warn}; use directories::ProjectDirs; +use keymaps::trie::Node; use matrix_sdk::Client; use tokio::sync::mpsc; use tokio_util::sync::CancellationToken; -use self::{ - command_interface::{ - command_transfer_value::support_types::Function, lua_command_manager::LuaCommandManager, - }, - keymappings::trie::Node, +use self::command_interface::{ + command_transfer_value::support_types::Function, lua_command_manager::LuaCommandManager, }; + use crate::{ accounts::{Account, AccountsManager}, app::{ diff --git a/src/app/status.rs b/src/app/status.rs index da6203c..814fc80 100644 --- a/src/app/status.rs +++ b/src/app/status.rs @@ -3,6 +3,7 @@ use core::fmt; use anyhow::{bail, Error, Result}; use cli_log::warn; use indexmap::IndexMap; +use keymaps::key_repr::Keys; use matrix_sdk::{ room::MessagesOptions, ruma::{ @@ -12,8 +13,6 @@ use matrix_sdk::{ Client, }; -use super::keymappings::key::Keys; - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Debug)] pub enum State { Normal,