1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-06 23:55:49 +03:00

feat: add unicode-aware soft-wrap modes and wrapped rendering (#8)

* feat(textarea): add unicode-aware soft-wrap modes and wrapped rendering

- add WrapMode API/state: None, Word, Glyph, WordOrGlyph
- keep None behavior unchanged (horizontal scroll)
- implement wrapped render path with logical-to-visual row mapping
- add Unicode-aware wrapping via unicode-segmentation + unicode-width
- make wrap width tab-aware to prevent hidden text
- apply cursor-line style on wrapped continuation rows
- fix selection at soft-wrap boundaries (no synthetic highlighted space)
- add wrap-focused tests for long text, newlines, tabs, tiny widths, and line-number
    continuations

* chore(release): bump to v0.9.0 and update README/CHANGELOG
Этот коммит содержится в:
srothgan
2026-02-18 18:26:48 +01:00
коммит произвёл GitHub
родитель cc783097ae
Коммит 1740facd24
9 изменённых файлов: 842 добавлений и 23 удалений

Просмотреть файл

@@ -138,6 +138,10 @@ impl<'a> LineHighlighter<'a> {
.push(Span::styled(format!("{}{} ", pad, row + 1), style));
}
pub fn line_number_placeholder(&mut self, lnum_len: u8, style: Style) {
self.spans.push(Span::styled(spaces(lnum_len + 2), style));
}
pub fn cursor_line(&mut self, cursor_col: usize, style: Style) {
if let Some((start, c)) = self.line.char_indices().nth(cursor_col) {
self.boundaries
@@ -149,6 +153,10 @@ impl<'a> LineHighlighter<'a> {
self.style_begin = style;
}
pub fn set_line_style(&mut self, style: Style) {
self.style_begin = style;
}
#[cfg(feature = "search")]
pub fn search(&mut self, matches: impl Iterator<Item = (usize, usize)>, style: Style) {
for (start, end) in matches {
@@ -208,6 +216,17 @@ impl<'a> LineHighlighter<'a> {
);
}
pub fn selection_segment(&mut self, start_off: usize, end_off: usize, select_at_end: bool) {
if start_off < end_off {
self.boundaries
.push((Boundary::Select(self.select_style), start_off));
self.boundaries.push((Boundary::End, end_off));
}
if select_at_end {
self.select_at_end = true;
}
}
pub fn custom(
&mut self,
current_row: usize,