-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
highlight_mode
attribute (#704)
* feat: Built-in vertical alignment for text * feat: `highlight_mode` attribute * clean up * text navigation fixes * clean up * clean up and bug fixes * parse tests
- Loading branch information
Showing
11 changed files
with
117 additions
and
40 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
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,24 @@ | ||
use crate::Parse; | ||
|
||
#[derive(Default, Clone, Debug, PartialEq)] | ||
pub enum HighlightMode { | ||
#[default] | ||
/// Highlight considering the actual measure text bounds. | ||
Fit, | ||
/// Highlight considering the `paragraph` element bounds. | ||
Expanded, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub struct HighlightModeError; | ||
|
||
impl Parse for HighlightMode { | ||
type Err = HighlightModeError; | ||
|
||
fn parse(value: &str) -> Result<Self, Self::Err> { | ||
match value { | ||
"expanded" => Ok(HighlightMode::Expanded), | ||
_ => Ok(HighlightMode::Fit), | ||
} | ||
} | ||
} |
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,23 @@ | ||
use freya_engine::prelude::*; | ||
use freya_node_state::{ | ||
HighlightMode, | ||
Parse, | ||
}; | ||
|
||
#[test] | ||
fn parse_expanded_highlight_mode() { | ||
let expanded = HighlightMode::parse("expanded"); | ||
assert_eq!(expanded, Ok(HighlightMode::Expanded)); | ||
} | ||
|
||
#[test] | ||
fn parse_fit_highlight_mode() { | ||
let fit = HighlightMode::parse("fit"); | ||
assert_eq!(fit, Ok(HighlightMode::Fit)); | ||
} | ||
|
||
#[test] | ||
fn parse_fallback_highlight_mode() { | ||
let fallback = HighlightMode::parse("Hello, World!"); | ||
assert_eq!(fallback, Ok(HighlightMode::Fit)); | ||
} |
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