зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-04 23:05:50 +03:00
Feat/textarea row measurement min max (#14)
* feat(textarea): add row measurement API with configurable min/max bounds - add TextAreaMeasure and TextArea::measure(width_cols) - make measurement wrap-aware and include block chrome rows - add set_min_rows/set_max_rows (+ getters) with invariant normalization - clamp preferred_rows to effective [min_rows, max_rows] - export TextAreaMeasure at crate root - switch examples/variable.rs to measured preferred_rows - add integration tests for measure + min/max behavior * chore(release): bump to v0.10.0 and update changelog
Этот коммит содержится в:
@@ -29,7 +29,8 @@ fn main() -> io::Result<()> {
|
||||
loop {
|
||||
term.draw(|f| {
|
||||
const MIN_HEIGHT: usize = 3;
|
||||
let height = cmp::max(textarea.lines().len(), MIN_HEIGHT) as u16 + 2; // + 2 for borders
|
||||
let measure = textarea.measure(f.area().width);
|
||||
let height = cmp::max(measure.preferred_rows as usize, MIN_HEIGHT) as u16;
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Length(height), Constraint::Min(0)])
|
||||
|
||||
Ссылка в новой задаче
Block a user