-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
111 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use super::FzfQuery; | ||
|
||
/// TODO: docs | ||
#[derive(Default, Clone)] | ||
pub struct FzfParser { | ||
vec: Vec<char>, | ||
} | ||
|
||
impl FzfParser { | ||
/// TODO: docs | ||
#[inline] | ||
pub fn parse<'a>(&'a mut self, query: &str) -> FzfQuery<'a> { | ||
if query.len() > self.vec.len() { | ||
self.vec.resize(query.len(), '\0'); | ||
} | ||
|
||
let mut char_len = 0; | ||
|
||
for ch in query.chars() { | ||
self.vec[char_len] = ch; | ||
char_len += 1; | ||
} | ||
|
||
FzfQuery::new(&self.vec[..char_len]) | ||
} | ||
|
||
/// TODO: docs | ||
#[inline] | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,42 @@ | ||
/// TODO: docs. | ||
#[derive(Clone, Copy, Debug)] | ||
#[derive(Clone, Copy)] | ||
pub struct FzfQuery<'a> { | ||
/// TODO: docs. | ||
raw: &'a str, | ||
chars: &'a [char], | ||
} | ||
|
||
impl core::fmt::Debug for FzfQuery<'_> { | ||
#[inline] | ||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
let s = self.chars.iter().collect::<String>(); | ||
f.debug_tuple("FzfQuery").field(&s).finish() | ||
} | ||
} | ||
|
||
impl<'a> FzfQuery<'a> { | ||
/// TODO: docs | ||
#[inline] | ||
pub fn new(s: &'a str) -> Self { | ||
Self { raw: s } | ||
pub(super) fn char_len(&self) -> usize { | ||
self.chars.len() | ||
} | ||
|
||
/// TODO: docs | ||
#[inline] | ||
pub(crate) fn chars( | ||
&self, | ||
) -> impl Iterator<Item = char> + DoubleEndedIterator + '_ { | ||
self.chars.iter().copied() | ||
} | ||
|
||
/// TODO: docs | ||
#[inline] | ||
pub(super) fn is_empty(&self) -> bool { | ||
self.chars.is_empty() | ||
} | ||
|
||
/// TODO: docs | ||
#[inline] | ||
pub(super) fn raw(&self) -> &'a str { | ||
self.raw | ||
pub(super) fn new(chars: &'a [char]) -> Self { | ||
Self { chars } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters