diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-06-08 09:28:20 +0200 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-06-08 09:28:20 +0200 |
commit | 8996a5022fa82e5d5335f71580d0cd6b6d323c9b (patch) | |
tree | aac6b6a015cf06aad845627f51b739fe58f85166 | |
parent | 52562e9986f8f5a4d2dda4333acba110734def0f (diff) | |
download | luasystem-8996a5022fa82e5d5335f71580d0cd6b6d323c9b.zip |
switch termsize results to standard; rows, cols
-rw-r--r-- | examples/terminalsize.lua | 10 | ||||
-rw-r--r-- | spec/04-term_spec.lua | 6 | ||||
-rw-r--r-- | src/term.c | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/examples/terminalsize.lua b/examples/terminalsize.lua index ed66792..105a415 100644 --- a/examples/terminalsize.lua +++ b/examples/terminalsize.lua @@ -24,13 +24,13 @@ local function cursor_move_horiz(n) end -local w, h +local rows, cols print("Change the terminal window size, press any key to exit") while not sys.readansi(0.2) do -- use readansi to not leave stray bytes in the input buffer - local nw, nh = sys.termsize() - if w ~= nw or h ~= nh then - w, h = nw, nh - local text = "Terminal size: " .. w .. "x" .. h .. " " + local nrows, ncols = sys.termsize() + if rows ~= nrows or cols ~= ncols then + rows, cols = nrows, ncols + local text = "Terminal size: " .. rows .. "x" .. cols .. " " io.write(text .. cursor_move_horiz(-#text)) io.flush() end diff --git a/spec/04-term_spec.lua b/spec/04-term_spec.lua index 84b4731..d5b4eee 100644 --- a/spec/04-term_spec.lua +++ b/spec/04-term_spec.lua @@ -500,9 +500,9 @@ describe("Terminal:", function() describe("termsize() #manual", function() it("gets the terminal size", function() - local w, h = system.termsize() - assert.is_number(w) - assert.is_number(h) + local rows, columns = system.termsize() + assert.is_number(rows) + assert.is_number(columns) end) end) @@ -857,10 +857,10 @@ static int lst_readkey(lua_State *L) { /*** -Get the size of the terminal in columns and rows. +Get the size of the terminal in rows and columns. @function termsize -@treturn[1] int the number of columns @treturn[1] int the number of rows +@treturn[1] int the number of columns @treturn[2] nil @treturn[2] string error message */ @@ -885,8 +885,8 @@ static int lst_termsize(lua_State *L) { rows = ws.ws_row; #endif - lua_pushinteger(L, columns); lua_pushinteger(L, rows); + lua_pushinteger(L, columns); return 2; } |