aboutsummaryrefslogtreecommitdiff
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.tar.gz
luasystem-8996a5022fa82e5d5335f71580d0cd6b6d323c9b.tar.bz2
luasystem-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)
24end 24end
25 25
26 26
27local w, h 27local rows, cols
28print("Change the terminal window size, press any key to exit") 28print("Change the terminal window size, press any key to exit")
29while not sys.readansi(0.2) do -- use readansi to not leave stray bytes in the input buffer 29while not sys.readansi(0.2) do -- use readansi to not leave stray bytes in the input buffer
30 local nw, nh = sys.termsize() 30 local nrows, ncols = sys.termsize()
31 if w ~= nw or h ~= nh then 31 if rows ~= nrows or cols ~= ncols then
32 w, h = nw, nh 32 rows, cols = nrows, ncols
33 local text = "Terminal size: " .. w .. "x" .. h .. " " 33 local text = "Terminal size: " .. rows .. "x" .. cols .. " "
34 io.write(text .. cursor_move_horiz(-#text)) 34 io.write(text .. cursor_move_horiz(-#text))
35 io.flush() 35 io.flush()
36 end 36 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()
500 describe("termsize() #manual", function() 500 describe("termsize() #manual", function()
501 501
502 it("gets the terminal size", function() 502 it("gets the terminal size", function()
503 local w, h = system.termsize() 503 local rows, columns = system.termsize()
504 assert.is_number(w) 504 assert.is_number(rows)
505 assert.is_number(h) 505 assert.is_number(columns)
506 end) 506 end)
507 507
508 end) 508 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) {
857 857
858 858
859/*** 859/***
860Get the size of the terminal in columns and rows. 860Get the size of the terminal in rows and columns.
861@function termsize 861@function termsize
862@treturn[1] int the number of columns
863@treturn[1] int the number of rows 862@treturn[1] int the number of rows
863@treturn[1] int the number of columns
864@treturn[2] nil 864@treturn[2] nil
865@treturn[2] string error message 865@treturn[2] string error message
866*/ 866*/
@@ -885,8 +885,8 @@ static int lst_termsize(lua_State *L) {
885 rows = ws.ws_row; 885 rows = ws.ws_row;
886 886
887#endif 887#endif
888 lua_pushinteger(L, columns);
889 lua_pushinteger(L, rows); 888 lua_pushinteger(L, rows);
889 lua_pushinteger(L, columns);
890 return 2; 890 return 2;
891} 891}
892 892