mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
refactor: model better structure
This commit is contained in:
parent
45d84dc646
commit
005fa7890f
1 changed files with 38 additions and 38 deletions
76
src/model.rs
76
src/model.rs
|
|
@ -7,44 +7,6 @@ use sequence_trie::SequenceTrie;
|
|||
use crate::alphabets::Alphabet;
|
||||
use crate::regexes::{NamedPattern, EXCLUDE_PATTERNS, PATTERNS};
|
||||
|
||||
/// Represents matched text, its location on screen, the pattern that created
|
||||
/// it, and the associated hint.
|
||||
pub struct Match<'a> {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub pattern: &'a str,
|
||||
pub text: &'a str,
|
||||
pub hint: String,
|
||||
}
|
||||
|
||||
impl<'a> fmt::Debug for Match<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"Match {{ x: {}, y: {}, pattern: {}, text: {}, hint: <{}> }}",
|
||||
self.x, self.y, self.pattern, self.text, self.hint,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal surrogate for `Match`, before a Hint has been associated.
|
||||
struct RawMatch<'a> {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub pattern: &'a str,
|
||||
pub text: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> fmt::Debug for RawMatch<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"RawMatch {{ x: {}, y: {}, pattern: {}, text: {} }}",
|
||||
self.x, self.y, self.pattern, self.text,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Holds data for the `Ui`.
|
||||
pub struct Model<'a> {
|
||||
pub lines: &'a Vec<&'a str>,
|
||||
|
|
@ -259,6 +221,44 @@ impl<'a> Model<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Represents matched text, its location on screen, the pattern that created
|
||||
/// it, and the associated hint.
|
||||
pub struct Match<'a> {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub pattern: &'a str,
|
||||
pub text: &'a str,
|
||||
pub hint: String,
|
||||
}
|
||||
|
||||
impl<'a> fmt::Debug for Match<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"Match {{ x: {}, y: {}, pattern: {}, text: {}, hint: <{}> }}",
|
||||
self.x, self.y, self.pattern, self.text, self.hint,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal surrogate for `Match`, before a Hint has been associated.
|
||||
struct RawMatch<'a> {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub pattern: &'a str,
|
||||
pub text: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> fmt::Debug for RawMatch<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"RawMatch {{ x: {}, y: {}, pattern: {}, text: {} }}",
|
||||
self.x, self.y, self.pattern, self.text,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue