mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
feat: remove y from alphabet at runtime
This commit is contained in:
parent
ea512a8dfc
commit
372781e231
1 changed files with 10 additions and 3 deletions
|
|
@ -1,5 +1,11 @@
|
||||||
use crate::error;
|
use crate::error;
|
||||||
|
|
||||||
|
/// Catalog of available alphabets.
|
||||||
|
///
|
||||||
|
/// # Note
|
||||||
|
///
|
||||||
|
/// Keep in mind letters 'n' and 'y' are systematically removed at runtime to
|
||||||
|
/// prevent conflict with navigation and yank/copy keys.
|
||||||
const ALPHABETS: [(&'static str, &'static str); 21] = [
|
const ALPHABETS: [(&'static str, &'static str); 21] = [
|
||||||
// ("abcd", "abcd"),
|
// ("abcd", "abcd"),
|
||||||
("qwerty", "asdfqwerzxcvjklmiuopghtybn"),
|
("qwerty", "asdfqwerzxcvjklmiuopghtybn"),
|
||||||
|
|
@ -24,7 +30,7 @@ const ALPHABETS: [(&'static str, &'static str); 21] = [
|
||||||
("colemak-right-hand", "neioluymjhk"),
|
("colemak-right-hand", "neioluymjhk"),
|
||||||
(
|
(
|
||||||
"longest",
|
"longest",
|
||||||
"aoeuqjkxpyhtnsgcrlmwvzfidb;,~<>'@!#$%^&*~1234567890",
|
"aoeuqjkxpyhtnsgcrlmwvzfidb-;,~<>'@!#$%^&*~1234567890",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -33,13 +39,14 @@ const ALPHABETS: [(&'static str, &'static str); 21] = [
|
||||||
/// # Note
|
/// # Note
|
||||||
///
|
///
|
||||||
/// Letters 'n' and 'N' are systematically removed to prevent conflict with
|
/// Letters 'n' and 'N' are systematically removed to prevent conflict with
|
||||||
/// navigation keys (arrows and 'n' 'N').
|
/// navigation keys (arrows and 'n' 'N'). Letters 'y' and 'Y' are also removed
|
||||||
|
/// to prevent conflict with yank/copy.
|
||||||
pub fn parse_alphabet(src: &str) -> Result<Alphabet, error::ParseError> {
|
pub fn parse_alphabet(src: &str) -> Result<Alphabet, error::ParseError> {
|
||||||
let alphabet_pair = ALPHABETS.iter().find(|&(name, _letters)| name == &src);
|
let alphabet_pair = ALPHABETS.iter().find(|&(name, _letters)| name == &src);
|
||||||
|
|
||||||
match alphabet_pair {
|
match alphabet_pair {
|
||||||
Some((_name, letters)) => {
|
Some((_name, letters)) => {
|
||||||
let letters = letters.replace(&['n', 'N'][..], "");
|
let letters = letters.replace(&['n', 'N', 'y', 'Y'][..], "");
|
||||||
Ok(Alphabet(letters.to_string()))
|
Ok(Alphabet(letters.to_string()))
|
||||||
}
|
}
|
||||||
None => Err(error::ParseError::UnknownAlphabet),
|
None => Err(error::ParseError::UnknownAlphabet),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue