Skip to main content

ferroui_base/media/text_formatting/
text_end_of_line.rs

1use crate::media::text_formatting::text_run::{text_run_any, TextRun, DEFAULT_TEXT_SOURCE_LENGTH};
2
3/// A text run that supports end of line.
4pub struct TextEndOfLine {
5    length: i32,
6}
7
8impl TextEndOfLine {
9    /// An end of line of the default text source length (1).
10    pub fn new() -> Self {
11        Self { length: DEFAULT_TEXT_SOURCE_LENGTH }
12    }
13
14    /// An end of line covering `text_source_length` text source positions.
15    pub fn with_length(text_source_length: i32) -> Self {
16        Self { length: text_source_length }
17    }
18}
19
20impl Default for TextEndOfLine {
21    fn default() -> Self {
22        Self::new()
23    }
24}
25
26impl TextRun for TextEndOfLine {
27    fn length(&self) -> i32 {
28        self.length
29    }
30
31    fn as_text_end_of_line(&self) -> Option<&TextEndOfLine> {
32        Some(self)
33    }
34
35    text_run_any!();
36}