From 2c3c7a54560acc49f7789795b704964b17778be1 Mon Sep 17 00:00:00 2001 From: graelo Date: Sat, 20 Mar 2021 07:46:43 +0100 Subject: [PATCH] refactor: alphabets.rs -> textbuf/alphabet.rs --- src/lib.rs | 19 ++++++++++--------- src/{alphabets.rs => textbuf/alphabet.rs} | 0 src/textbuf/mod.rs | 1 + src/textbuf/model.rs | 4 ++-- src/ui/vc.rs | 6 +++--- 5 files changed, 16 insertions(+), 14 deletions(-) rename src/{alphabets.rs => textbuf/alphabet.rs} (100%) diff --git a/src/lib.rs b/src/lib.rs index a08b072..b0a3d18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,3 @@ -use clap::Clap; -use std::collections::HashMap; -use std::path; -use std::str::FromStr; - -pub mod alphabets; pub mod error; pub mod output_destination; pub mod regexes; @@ -11,6 +5,13 @@ pub mod textbuf; pub mod tmux; pub mod ui; +use clap::Clap; +use std::collections::HashMap; +use std::path; +use std::str::FromStr; + +use crate::textbuf::alphabet; + /// Run copyrat on an input string `buffer`, configured by `Opt`. /// /// # Note @@ -72,8 +73,8 @@ pub struct CliOpt { /// /// "qwerty", "dvorak-homerow", "azerty-right-hand". #[clap(short = 'k', long, default_value = "dvorak", - parse(try_from_str = alphabets::parse_alphabet))] - alphabet: alphabets::Alphabet, + parse(try_from_str = alphabet::parse_alphabet))] + alphabet: alphabet::Alphabet, /// Use all available regex patterns. #[clap(short = 'A', long = "--all-patterns")] @@ -172,7 +173,7 @@ impl CliOpt { for (name, value) in options { match name.as_ref() { "@copyrat-alphabet" => { - self.alphabet = alphabets::parse_alphabet(value)?; + self.alphabet = alphabet::parse_alphabet(value)?; } "@copyrat-pattern-name" => { self.named_patterns = vec![regexes::parse_pattern_name(value)?] diff --git a/src/alphabets.rs b/src/textbuf/alphabet.rs similarity index 100% rename from src/alphabets.rs rename to src/textbuf/alphabet.rs diff --git a/src/textbuf/mod.rs b/src/textbuf/mod.rs index 6d912bd..6d0b615 100644 --- a/src/textbuf/mod.rs +++ b/src/textbuf/mod.rs @@ -1,3 +1,4 @@ +pub(crate) mod alphabet; mod matches; mod model; mod raw_match; diff --git a/src/textbuf/model.rs b/src/textbuf/model.rs index a8ee610..0dc31f4 100644 --- a/src/textbuf/model.rs +++ b/src/textbuf/model.rs @@ -3,9 +3,9 @@ use std::collections; use regex::Regex; use sequence_trie::SequenceTrie; +use super::alphabet::Alphabet; use super::matches::Match; use super::raw_match::RawMatch; -use crate::alphabets::Alphabet; use crate::regexes::{NamedPattern, EXCLUDE_PATTERNS, PATTERNS}; /// Holds data for the `Ui`. @@ -232,7 +232,7 @@ impl<'a> Model<'a> { #[cfg(test)] mod tests { use super::*; - use crate::alphabets::Alphabet; + use crate::textbuf::alphabet::Alphabet; #[test] fn match_reverse() { diff --git a/src/ui/vc.rs b/src/ui/vc.rs index acba916..0cd0c54 100644 --- a/src/ui/vc.rs +++ b/src/ui/vc.rs @@ -656,7 +656,7 @@ enum Event { #[cfg(test)] mod tests { use super::*; - use crate::alphabets; + use crate::textbuf::alphabet; #[test] fn test_render_all_lines() { @@ -909,7 +909,7 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - "; let use_all_patterns = true; let named_pat = vec![]; let custom_patterns = vec![]; - let alphabet = alphabets::Alphabet("abcd".to_string()); + let alphabet = alphabet::Alphabet("abcd".to_string()); let reverse = false; let mut model = textbuf::Model::new( content, @@ -984,7 +984,7 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - "; let use_all_patterns = true; let named_pat = vec![]; let custom_patterns = vec![]; - let alphabet = alphabets::Alphabet("abcd".to_string()); + let alphabet = alphabet::Alphabet("abcd".to_string()); let reverse = true; let mut model = textbuf::Model::new( content,