summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2024-06-08 09:28:20 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2024-06-08 09:28:20 +0200
commit8996a5022fa82e5d5335f71580d0cd6b6d323c9b (patch)
treeaac6b6a015cf06aad845627f51b739fe58f85166
parent52562e9986f8f5a4d2dda4333acba110734def0f (diff)
downloadluasystem-8996a5022fa82e5d5335f71580d0cd6b6d323c9b.zip
switch termsize results to standard; rows, cols
-rw-r--r--examples/terminalsize.lua10
-rw-r--r--spec/04-term_spec.lua6
-rw-r--r--src/term.c6
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)
diff --git a/src/term.c b/src/term.c
index 79fb801..db3c300 100644
--- a/src/term.c
+++ b/src/term.c
@@ -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;
}