mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
refactor: alphabets.rs -> textbuf/alphabet.rs
This commit is contained in:
parent
7d4d9a8824
commit
2c3c7a5456
5 changed files with 16 additions and 14 deletions
19
src/lib.rs
19
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 error;
|
||||||
pub mod output_destination;
|
pub mod output_destination;
|
||||||
pub mod regexes;
|
pub mod regexes;
|
||||||
|
|
@ -11,6 +5,13 @@ pub mod textbuf;
|
||||||
pub mod tmux;
|
pub mod tmux;
|
||||||
pub mod ui;
|
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`.
|
/// Run copyrat on an input string `buffer`, configured by `Opt`.
|
||||||
///
|
///
|
||||||
/// # Note
|
/// # Note
|
||||||
|
|
@ -72,8 +73,8 @@ pub struct CliOpt {
|
||||||
///
|
///
|
||||||
/// "qwerty", "dvorak-homerow", "azerty-right-hand".
|
/// "qwerty", "dvorak-homerow", "azerty-right-hand".
|
||||||
#[clap(short = 'k', long, default_value = "dvorak",
|
#[clap(short = 'k', long, default_value = "dvorak",
|
||||||
parse(try_from_str = alphabets::parse_alphabet))]
|
parse(try_from_str = alphabet::parse_alphabet))]
|
||||||
alphabet: alphabets::Alphabet,
|
alphabet: alphabet::Alphabet,
|
||||||
|
|
||||||
/// Use all available regex patterns.
|
/// Use all available regex patterns.
|
||||||
#[clap(short = 'A', long = "--all-patterns")]
|
#[clap(short = 'A', long = "--all-patterns")]
|
||||||
|
|
@ -172,7 +173,7 @@ impl CliOpt {
|
||||||
for (name, value) in options {
|
for (name, value) in options {
|
||||||
match name.as_ref() {
|
match name.as_ref() {
|
||||||
"@copyrat-alphabet" => {
|
"@copyrat-alphabet" => {
|
||||||
self.alphabet = alphabets::parse_alphabet(value)?;
|
self.alphabet = alphabet::parse_alphabet(value)?;
|
||||||
}
|
}
|
||||||
"@copyrat-pattern-name" => {
|
"@copyrat-pattern-name" => {
|
||||||
self.named_patterns = vec![regexes::parse_pattern_name(value)?]
|
self.named_patterns = vec![regexes::parse_pattern_name(value)?]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
pub(crate) mod alphabet;
|
||||||
mod matches;
|
mod matches;
|
||||||
mod model;
|
mod model;
|
||||||
mod raw_match;
|
mod raw_match;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ use std::collections;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use sequence_trie::SequenceTrie;
|
use sequence_trie::SequenceTrie;
|
||||||
|
|
||||||
|
use super::alphabet::Alphabet;
|
||||||
use super::matches::Match;
|
use super::matches::Match;
|
||||||
use super::raw_match::RawMatch;
|
use super::raw_match::RawMatch;
|
||||||
use crate::alphabets::Alphabet;
|
|
||||||
use crate::regexes::{NamedPattern, EXCLUDE_PATTERNS, PATTERNS};
|
use crate::regexes::{NamedPattern, EXCLUDE_PATTERNS, PATTERNS};
|
||||||
|
|
||||||
/// Holds data for the `Ui`.
|
/// Holds data for the `Ui`.
|
||||||
|
|
@ -232,7 +232,7 @@ impl<'a> Model<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::alphabets::Alphabet;
|
use crate::textbuf::alphabet::Alphabet;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn match_reverse() {
|
fn match_reverse() {
|
||||||
|
|
|
||||||
|
|
@ -656,7 +656,7 @@ enum Event {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::alphabets;
|
use crate::textbuf::alphabet;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_render_all_lines() {
|
fn test_render_all_lines() {
|
||||||
|
|
@ -909,7 +909,7 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
|
||||||
let use_all_patterns = true;
|
let use_all_patterns = true;
|
||||||
let named_pat = vec![];
|
let named_pat = vec![];
|
||||||
let custom_patterns = vec![];
|
let custom_patterns = vec![];
|
||||||
let alphabet = alphabets::Alphabet("abcd".to_string());
|
let alphabet = alphabet::Alphabet("abcd".to_string());
|
||||||
let reverse = false;
|
let reverse = false;
|
||||||
let mut model = textbuf::Model::new(
|
let mut model = textbuf::Model::new(
|
||||||
content,
|
content,
|
||||||
|
|
@ -984,7 +984,7 @@ Barcelona https://en.wikipedia.org/wiki/Barcelona - ";
|
||||||
let use_all_patterns = true;
|
let use_all_patterns = true;
|
||||||
let named_pat = vec![];
|
let named_pat = vec![];
|
||||||
let custom_patterns = vec![];
|
let custom_patterns = vec![];
|
||||||
let alphabet = alphabets::Alphabet("abcd".to_string());
|
let alphabet = alphabet::Alphabet("abcd".to_string());
|
||||||
let reverse = true;
|
let reverse = true;
|
||||||
let mut model = textbuf::Model::new(
|
let mut model = textbuf::Model::new(
|
||||||
content,
|
content,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue