From 8c9bbb80ef875e4bd06bdae5d8ffa028b763675d Mon Sep 17 00:00:00 2001 From: destroyedlolo Date: Sun, 30 Jun 2024 11:57:08 +0200 Subject: [PATCH] terminal resizing example --- SelenitesCurses/Resize.sel | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 SelenitesCurses/Resize.sel diff --git a/SelenitesCurses/Resize.sel b/SelenitesCurses/Resize.sel new file mode 100644 index 0000000..dd9eef2 --- /dev/null +++ b/SelenitesCurses/Resize.sel @@ -0,0 +1,36 @@ +#!Selene + +-- Test window's resizing + + +Selene.Use("SelCurses") +Selene.LetsGo() -- ensure late building dependencies + +local pwnd = SelCurses.init() + +function printsize() + -- Display the size of the root window at its center + local w,h = pwnd:GetSize() + local s = "Size w:".. w .. " h:" .. h + pwnd:clear() + pwnd:attrset( SelCurses.CharAttrConst("REVERSE") ) + pwnd:PrintAt( math.floor( (w-s:len())/2 ), math.floor(h/2), s ) + pwnd:attrset( SelCurses.CharAttrConst("NORMAL") ) + + pwnd:refresh() +end + +printsize() + +-- Let's go + +while true do + c = pwnd:getch() + if c == SelCurses.Key("RESIZE") then + printsize() + elseif string.char(c) == 'q' then + break + end +end + +SelCurses.endwin()