зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-03 14:26:17 +03:00
pass mask character on creating LineHighlighter instance
Этот коммит содержится в:
@@ -94,10 +94,11 @@ pub struct LineHighlighter<'a> {
|
||||
cursor_at_end: bool,
|
||||
cursor_style: Style,
|
||||
tab_len: u8,
|
||||
mask: Option<char>,
|
||||
}
|
||||
|
||||
impl<'a> LineHighlighter<'a> {
|
||||
pub fn new(line: &'a str, cursor_style: Style, tab_len: u8) -> Self {
|
||||
pub fn new(line: &'a str, cursor_style: Style, tab_len: u8, mask: Option<char>) -> Self {
|
||||
Self {
|
||||
line,
|
||||
spans: vec![],
|
||||
@@ -106,6 +107,7 @@ impl<'a> LineHighlighter<'a> {
|
||||
cursor_at_end: false,
|
||||
cursor_style,
|
||||
tab_len,
|
||||
mask,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +138,7 @@ impl<'a> LineHighlighter<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_spans(self, mask: Option<char>) -> Spans<'a> {
|
||||
pub fn into_spans(self) -> Spans<'a> {
|
||||
let Self {
|
||||
line,
|
||||
mut spans,
|
||||
@@ -145,6 +147,7 @@ impl<'a> LineHighlighter<'a> {
|
||||
style_begin,
|
||||
cursor_style,
|
||||
cursor_at_end,
|
||||
mask,
|
||||
} = self;
|
||||
|
||||
if boundaries.is_empty() {
|
||||
|
||||
@@ -1011,7 +1011,7 @@ impl<'a> TextArea<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn line_spans<'b>(&'b self, line: &'b str, row: usize, lnum_len: u8) -> Spans<'b> {
|
||||
let mut hl = LineHighlighter::new(line, self.cursor_style, self.tab_len);
|
||||
let mut hl = LineHighlighter::new(line, self.cursor_style, self.tab_len, self.mask);
|
||||
|
||||
if let Some(style) = self.line_number_style {
|
||||
hl.line_number(row, lnum_len, style);
|
||||
@@ -1026,7 +1026,7 @@ impl<'a> TextArea<'a> {
|
||||
hl.search(matches, self.search.style);
|
||||
}
|
||||
|
||||
hl.into_spans(self.mask)
|
||||
hl.into_spans()
|
||||
}
|
||||
|
||||
/// Build a tui-rs widget to render the current state of the textarea. The widget instance returned from this
|
||||
|
||||
Ссылка в новой задаче
Block a user