From f39c8515280c43151c3b03ef52aaf167e472d45d Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Tue, 17 May 2022 17:26:49 +0200 Subject: list: reset, somewhat decent resize implementation and fix reframe list::reframe had buggy behaviour (especially after previous commit). list::reset allows easily resetting the list (cursor = 0, reset frame). list::resize allows resizing the list after a sigwinch more easily. It's a bit of a bitch to get a pretty, non-brutal (without cursor/frame resetting to avoid "jumping" effect) list resize, this algo acheives it somewhat decently and keeps the selected item in a somewhat predictable position. --- main.ha | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'main.ha') diff --git a/main.ha b/main.ha index bff260e..51c9b8a 100644 --- a/main.ha +++ b/main.ha @@ -28,8 +28,15 @@ fn sighandler(sig: int, info: *signal::siginfo, ucontext: *void) void = { } else { yield len(u.list.items); }; + const oldsz = list::ttysize { + rows = u.list.sz.rows, + cols = u.list.sz.cols, + }; u.list.sz.rows = rows: u16; u.list.sz.cols = sz.columns; + list::resize(u.list, oldsz); + libui::clear(u.list.widget.ui); + list::print(u.list)!; }; }; -- cgit v1.2.3