Skip to content

Commit

Permalink
terminal resizing example
Browse files Browse the repository at this point in the history
  • Loading branch information
destroyedlolo committed Jun 30, 2024
1 parent 7faf8e4 commit 8c9bbb8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions SelenitesCurses/Resize.sel
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 8c9bbb8

Please sign in to comment.