Skip to content

Commit

Permalink
Merge pull request #37 from destroyedlolo/Experimental
Browse files Browse the repository at this point in the history
terminal resizing example
  • Loading branch information
destroyedlolo authored Sep 6, 2024
2 parents 7fb5707 + 8c9bbb8 commit 2dece8c
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 2dece8c

Please sign in to comment.