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]
|
[package]
|
||||||
name = "keymappings"
|
name = "keymaps"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::{fmt::Display, num::ParseIntError};
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::key::{key, keys, Keys};
|
use crate::key_repr::{key, keys, Keys};
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum TrieInsertError<V: Display> {
|
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;
|
use super::KeyValue;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default, Parser)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default, Parser)]
|
||||||
#[grammar = "./key/keys.pest"]
|
#[grammar = "./key_repr/key_representation.pest"]
|
||||||
pub struct Key {
|
pub struct Key {
|
||||||
// Modifiers
|
// Modifiers
|
||||||
pub(super) alt: bool,
|
pub(super) alt: bool,
|
||||||
|
@ -60,17 +60,6 @@ impl Key {
|
||||||
}
|
}
|
||||||
output
|
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 {
|
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 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 {
|
impl Key {
|
||||||
pub fn from_pair<R>(pair: Pair<R>) -> Self
|
pub fn from_pair<R>(pair: Pair<R>) -> Self
|
|
@ -1,3 +1,6 @@
|
||||||
|
#[cfg(crossterm)]
|
||||||
|
mod crossterm;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{Display, Write},
|
fmt::{Display, Write},
|
||||||
str::FromStr,
|
str::FromStr,
|
|
@ -8,7 +8,7 @@ use super::Key;
|
||||||
use std::{fmt::Display, str::FromStr};
|
use std::{fmt::Display, str::FromStr};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default, Parser)]
|
#[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>);
|
pub struct Keys(pub(super) Vec<Key>);
|
||||||
|
|
||||||
impl Keys {
|
impl Keys {
|
|
@ -1,4 +1,3 @@
|
||||||
pub mod chars;
|
|
||||||
pub mod key;
|
pub mod key;
|
||||||
pub mod key_value;
|
pub mod key_value;
|
||||||
pub mod keys;
|
pub mod keys;
|
||||||
|
@ -9,7 +8,7 @@ pub use keys::Keys;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::key::{Key, KeyValue};
|
use crate::key_repr::{Key, KeyValue};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use super::Keys;
|
use super::Keys;
|
|
@ -1,3 +1,3 @@
|
||||||
pub mod key;
|
pub mod key_repr;
|
||||||
pub mod trie;
|
pub mod trie;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use log::info;
|
||||||
|
|
||||||
use crate::error;
|
use crate::error;
|
||||||
|
|
||||||
use super::key::{Key, Keys};
|
use super::key_repr::{Key, Keys};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct Node<V: std::fmt::Display + ToOwned<Owned = V>> {
|
pub struct Node<V: std::fmt::Display + ToOwned<Owned = V>> {
|
||||||
|
|
Loading…
Reference in New Issue