forked from trinitrix/core
refactor(keymaps): Remove dead code and duplicated module name (key)
This commit is contained in:
parent
2b39608f85
commit
831831cd1c
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "keymappings"
|
||||
name = "keymaps"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{fmt::Display, num::ParseIntError};
|
|||
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::key::{key, keys, Keys};
|
||||
use crate::key_repr::{key, keys, Keys};
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum TrieInsertError<V: Display> {
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
#[cfg(crossterm)]
|
||||
mod crossterm;
|
||||
|
||||
use std::{collections::VecDeque, fmt::Display};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct Chars(pub(super) VecDeque<char>);
|
||||
impl Chars {
|
||||
pub(super) fn peek(&self) -> Option<&char> {
|
||||
self.0.front()
|
||||
}
|
||||
pub(super) fn pop(&mut self) -> Option<char> {
|
||||
self.0.pop_front()
|
||||
}
|
||||
pub(super) fn prepend(&mut self, char_to_prepend: char) {
|
||||
let mut new_vec = VecDeque::with_capacity(self.0.len() + 1);
|
||||
new_vec.push_back(char_to_prepend);
|
||||
new_vec.append(&mut self.0);
|
||||
|
||||
self.0 = new_vec;
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Chars {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(&self.0.iter().collect::<String>()[..])
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ use pest_derive::Parser;
|
|||
use super::KeyValue;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default, Parser)]
|
||||
#[grammar = "./key/keys.pest"]
|
||||
#[grammar = "./key_repr/key_representation.pest"]
|
||||
pub struct Key {
|
||||
// Modifiers
|
||||
pub(super) alt: bool,
|
||||
|
@ -60,17 +60,6 @@ impl Key {
|
|||
}
|
||||
output
|
||||
}
|
||||
|
||||
fn merge_with(mut self, other: Key) -> Self {
|
||||
// Modifiers
|
||||
self.alt = self.alt || other.alt;
|
||||
self.ctrl = self.ctrl || other.ctrl;
|
||||
self.meta = self.meta || other.meta;
|
||||
self.shift = self.shift || other.shift;
|
||||
|
||||
self.value = Some(self.value.unwrap_or(other.value.unwrap_or(KeyValue::Null)));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Key {
|
|
@ -1,10 +1,10 @@
|
|||
use std::{fmt::Debug, hash::Hash, marker, mem, str::FromStr};
|
||||
use std::{fmt::Debug, hash::Hash, marker, str::FromStr};
|
||||
|
||||
use pest::{iterators::Pair, Parser};
|
||||
|
||||
use crate::{error, key::KeyValue};
|
||||
use crate::{error, key_repr::{KeyValue, key::Rule}};
|
||||
|
||||
use super::{Key, Rule};
|
||||
use super::Key;
|
||||
|
||||
impl Key {
|
||||
pub fn from_pair<R>(pair: Pair<R>) -> Self
|
|
@ -1,3 +1,6 @@
|
|||
#[cfg(crossterm)]
|
||||
mod crossterm;
|
||||
|
||||
use std::{
|
||||
fmt::{Display, Write},
|
||||
str::FromStr,
|
|
@ -8,7 +8,7 @@ use super::Key;
|
|||
use std::{fmt::Display, str::FromStr};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default, Parser)]
|
||||
#[grammar = "./key/keys.pest"]
|
||||
#[grammar = "./key_repr/key_representation.pest"]
|
||||
pub struct Keys(pub(super) Vec<Key>);
|
||||
|
||||
impl Keys {
|
|
@ -1,4 +1,3 @@
|
|||
pub mod chars;
|
||||
pub mod key;
|
||||
pub mod key_value;
|
||||
pub mod keys;
|
||||
|
@ -9,7 +8,7 @@ pub use keys::Keys;
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::key::{Key, KeyValue};
|
||||
use crate::key_repr::{Key, KeyValue};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::Keys;
|
|
@ -1,3 +1,3 @@
|
|||
pub mod key;
|
||||
pub mod key_repr;
|
||||
pub mod trie;
|
||||
pub mod error;
|
||||
|
|
|
@ -4,7 +4,7 @@ use log::info;
|
|||
|
||||
use crate::error;
|
||||
|
||||
use super::key::{Key, Keys};
|
||||
use super::key_repr::{Key, Keys};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Node<V: std::fmt::Display + ToOwned<Owned = V>> {
|
||||
|
|
Loading…
Reference in New Issue