forked from trinitrix/core
1
0
Fork 0

refactor(keymaps): Remove dead code and duplicated module name (key)

This commit is contained in:
Benedikt Peetz 2023-11-07 19:47:35 +01:00
parent 2b39608f85
commit 831831cd1c
Signed by: bpeetz
GPG Key ID: A5E94010C3A642AD
13 changed files with 13 additions and 50 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "keymappings"
name = "keymaps"
version = "0.1.0"
edition = "2021"

View File

@ -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> {

View File

@ -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>()[..])
}
}

View File

@ -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 {

View File

@ -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

View File

@ -1,3 +1,6 @@
#[cfg(crossterm)]
mod crossterm;
use std::{
fmt::{Display, Write},
str::FromStr,

View File

@ -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 {

View File

@ -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;

View File

@ -1,3 +1,3 @@
pub mod key;
pub mod key_repr;
pub mod trie;
pub mod error;

View File

@ -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>> {