diff --git a/src/ui/hint_alignment.rs b/src/ui/hint_alignment.rs new file mode 100644 index 0000000..610bdb5 --- /dev/null +++ b/src/ui/hint_alignment.rs @@ -0,0 +1,26 @@ +use clap::Clap; +use std::str::FromStr; + +use crate::error::ParseError; + +/// Describes if, during rendering, a hint should aligned to the leading edge of +/// the matched text, or to its trailing edge. +#[derive(Debug, Clap)] +pub enum HintAlignment { + Leading, + Trailing, +} + +impl FromStr for HintAlignment { + type Err = ParseError; + + fn from_str(s: &str) -> Result { + match s { + "leading" => Ok(HintAlignment::Leading), + "trailing" => Ok(HintAlignment::Trailing), + _ => Err(ParseError::ExpectedString(String::from( + "leading or trailing", + ))), + } + } +} diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 154cd0e..2db4d8d 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -18,11 +18,12 @@ //! pub mod colors; +pub mod hint_alignment; pub mod hint_style; mod selection; mod vc; +pub use hint_alignment::HintAlignment; pub use hint_style::HintStyle; pub use selection::Selection; -pub use vc::HintAlignment; pub use vc::ViewController; diff --git a/src/ui/vc.rs b/src/ui/vc.rs index c2ffca9..8ec32be 100644 --- a/src/ui/vc.rs +++ b/src/ui/vc.rs @@ -1,16 +1,13 @@ use std::char; use std::cmp; use std::io; -use std::str::FromStr; -use clap::Clap; use sequence_trie::SequenceTrie; use termion::{self, color, cursor, event, style}; use super::colors::UiColors; -use super::HintStyle; use super::Selection; -use crate::error::ParseError; +use super::{HintAlignment, HintStyle}; use crate::{output_destination::OutputDestination, textbuf}; pub struct ViewController<'a> { @@ -608,28 +605,6 @@ fn get_line_offsets(lines: &[&str], term_width: u16) -> Vec { .collect() } -/// Describes if, during rendering, a hint should aligned to the leading edge of -/// the matched text, or to its trailing edge. -#[derive(Debug, Clap)] -pub enum HintAlignment { - Leading, - Trailing, -} - -impl FromStr for HintAlignment { - type Err = ParseError; - - fn from_str(s: &str) -> Result { - match s { - "leading" => Ok(HintAlignment::Leading), - "trailing" => Ok(HintAlignment::Trailing), - _ => Err(ParseError::ExpectedString(String::from( - "leading or trailing", - ))), - } - } -} - /// Returned value after the `Ui` has finished listening to events. enum Event { /// Exit with no selected matches,