diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/term.c | 16 |
1 files changed, 14 insertions, 2 deletions
| @@ -384,6 +384,7 @@ See [setconsolemode documentation](https://learn.microsoft.com/en-us/windows/con | |||
| 384 | @treturn[1] boolean `true` on success | 384 | @treturn[1] boolean `true` on success |
| 385 | @treturn[2] nil | 385 | @treturn[2] nil |
| 386 | @treturn[2] string error message | 386 | @treturn[2] string error message |
| 387 | @within Terminal_Windows | ||
| 387 | @usage | 388 | @usage |
| 388 | local system = require('system') | 389 | local system = require('system') |
| 389 | system.listconsoleflags(io.stdout) -- List all the available flags and their current status | 390 | system.listconsoleflags(io.stdout) -- List all the available flags and their current status |
| @@ -427,13 +428,12 @@ input flags (for use with `io.stdin`) and `COF` are the output flags (for use wi | |||
| 427 | _Note_: See [setconsolemode documentation](https://learn.microsoft.com/en-us/windows/console/setconsolemode) | 428 | _Note_: See [setconsolemode documentation](https://learn.microsoft.com/en-us/windows/console/setconsolemode) |
| 428 | for more information on the flags. | 429 | for more information on the flags. |
| 429 | 430 | ||
| 430 | |||
| 431 | |||
| 432 | @function getconsoleflags | 431 | @function getconsoleflags |
| 433 | @tparam file file file handle to operate on, one of `io.stdin`, `io.stdout`, `io.stderr` | 432 | @tparam file file file handle to operate on, one of `io.stdin`, `io.stdout`, `io.stderr` |
| 434 | @treturn[1] bitflags the current console flags. | 433 | @treturn[1] bitflags the current console flags. |
| 435 | @treturn[2] nil | 434 | @treturn[2] nil |
| 436 | @treturn[2] string error message | 435 | @treturn[2] string error message |
| 436 | @within Terminal_Windows | ||
| 437 | @usage | 437 | @usage |
| 438 | local system = require('system') | 438 | local system = require('system') |
| 439 | 439 | ||
| @@ -497,6 +497,7 @@ The terminal attributes is a table with the following fields: | |||
| 497 | @treturn[2] string error message | 497 | @treturn[2] string error message |
| 498 | @treturn[2] int errnum | 498 | @treturn[2] int errnum |
| 499 | @return error message if failed | 499 | @return error message if failed |
| 500 | @within Terminal_Posix | ||
| 500 | @usage | 501 | @usage |
| 501 | local system = require('system') | 502 | local system = require('system') |
| 502 | 503 | ||
| @@ -591,6 +592,7 @@ _Note_: only `iflag`, `oflag`, and `lflag` are supported at the moment. The othe | |||
| 591 | @return[2] nil | 592 | @return[2] nil |
| 592 | @treturn[2] string error message | 593 | @treturn[2] string error message |
| 593 | @treturn[2] int errnum | 594 | @treturn[2] int errnum |
| 595 | @within Terminal_Posix | ||
| 594 | @usage | 596 | @usage |
| 595 | local system = require('system') | 597 | local system = require('system') |
| 596 | 598 | ||
| @@ -721,6 +723,7 @@ avoiding shared side effects. | |||
| 721 | Does not modify `stdin` (fd 0), and does nothing on Windows. | 723 | Does not modify `stdin` (fd 0), and does nothing on Windows. |
| 722 | @function detachfds | 724 | @function detachfds |
| 723 | @return boolean `true` on success, or throws an error on failure. | 725 | @return boolean `true` on success, or throws an error on failure. |
| 726 | @within Terminal_Posix | ||
| 724 | @see setnonblock | 727 | @see setnonblock |
| 725 | */ | 728 | */ |
| 726 | static int lst_detachfds(lua_State *L) { | 729 | static int lst_detachfds(lua_State *L) { |
| @@ -754,6 +757,7 @@ Check `detachfds` in case there are shared file descriptions. | |||
| 754 | @treturn[2] nil | 757 | @treturn[2] nil |
| 755 | @treturn[2] string error message | 758 | @treturn[2] string error message |
| 756 | @treturn[2] int errnum | 759 | @treturn[2] int errnum |
| 760 | @within Terminal_Posix | ||
| 757 | @see getnonblock | 761 | @see getnonblock |
| 758 | @see detachfds | 762 | @see detachfds |
| 759 | @usage | 763 | @usage |
| @@ -815,6 +819,7 @@ Gets non-blocking mode status for a file (Posix). | |||
| 815 | @treturn[2] nil | 819 | @treturn[2] nil |
| 816 | @treturn[2] string error message | 820 | @treturn[2] string error message |
| 817 | @treturn[2] int errnum | 821 | @treturn[2] int errnum |
| 822 | @within Terminal_Posix | ||
| 818 | @see setnonblock | 823 | @see setnonblock |
| 819 | */ | 824 | */ |
| 820 | static int lst_getnonblock(lua_State *L) | 825 | static int lst_getnonblock(lua_State *L) |
| @@ -882,6 +887,7 @@ sequences will be buffered internally and returned one byte at a time. | |||
| 882 | @treturn[3] nil on error | 887 | @treturn[3] nil on error |
| 883 | @treturn[3] string error message | 888 | @treturn[3] string error message |
| 884 | @treturn[3] int errnum (on posix) | 889 | @treturn[3] int errnum (on posix) |
| 890 | @within Terminal_Input | ||
| 885 | */ | 891 | */ |
| 886 | static int lst_readkey(lua_State *L) { | 892 | static int lst_readkey(lua_State *L) { |
| 887 | #ifdef _WIN32 | 893 | #ifdef _WIN32 |
| @@ -1071,6 +1077,7 @@ Get the width of a utf8 character for terminal display. | |||
| 1071 | @treturn[1] int the display width in columns of the first character in the string (0 for an empty string) | 1077 | @treturn[1] int the display width in columns of the first character in the string (0 for an empty string) |
| 1072 | @treturn[2] nil | 1078 | @treturn[2] nil |
| 1073 | @treturn[2] string error message | 1079 | @treturn[2] string error message |
| 1080 | @within Terminal_UTF-8 | ||
| 1074 | */ | 1081 | */ |
| 1075 | int lst_utf8cwidth(lua_State *L) { | 1082 | int lst_utf8cwidth(lua_State *L) { |
| 1076 | int width = 0; | 1083 | int width = 0; |
| @@ -1132,6 +1139,7 @@ Get the width of a utf8 string for terminal display. | |||
| 1132 | @treturn[1] int the display width of the string in columns (0 for an empty string) | 1139 | @treturn[1] int the display width of the string in columns (0 for an empty string) |
| 1133 | @treturn[2] nil | 1140 | @treturn[2] nil |
| 1134 | @treturn[2] string error message | 1141 | @treturn[2] string error message |
| 1142 | @within Terminal_UTF-8 | ||
| 1135 | */ | 1143 | */ |
| 1136 | int lst_utf8swidth(lua_State *L) { | 1144 | int lst_utf8swidth(lua_State *L) { |
| 1137 | const char *utf8_str; | 1145 | const char *utf8_str; |
| @@ -1182,6 +1190,7 @@ int lst_utf8swidth(lua_State *L) { | |||
| 1182 | Gets the current console code page (Windows). | 1190 | Gets the current console code page (Windows). |
| 1183 | @function getconsolecp | 1191 | @function getconsolecp |
| 1184 | @treturn[1] int the current code page (always 65001 on Posix systems) | 1192 | @treturn[1] int the current code page (always 65001 on Posix systems) |
| 1193 | @within Terminal_UTF-8 | ||
| 1185 | */ | 1194 | */ |
| 1186 | static int lst_getconsolecp(lua_State *L) { | 1195 | static int lst_getconsolecp(lua_State *L) { |
| 1187 | unsigned int cp = 65001; | 1196 | unsigned int cp = 65001; |
| @@ -1199,6 +1208,7 @@ Sets the current console code page (Windows). | |||
| 1199 | @function setconsolecp | 1208 | @function setconsolecp |
| 1200 | @tparam int cp the code page to set, use `system.CODEPAGE_UTF8` (65001) for UTF-8 | 1209 | @tparam int cp the code page to set, use `system.CODEPAGE_UTF8` (65001) for UTF-8 |
| 1201 | @treturn[1] bool `true` on success (always `true` on Posix systems) | 1210 | @treturn[1] bool `true` on success (always `true` on Posix systems) |
| 1211 | @within Terminal_UTF-8 | ||
| 1202 | */ | 1212 | */ |
| 1203 | static int lst_setconsolecp(lua_State *L) { | 1213 | static int lst_setconsolecp(lua_State *L) { |
| 1204 | unsigned int cp = (unsigned int)luaL_checkinteger(L, 1); | 1214 | unsigned int cp = (unsigned int)luaL_checkinteger(L, 1); |
| @@ -1216,6 +1226,7 @@ static int lst_setconsolecp(lua_State *L) { | |||
| 1216 | Gets the current console output code page (Windows). | 1226 | Gets the current console output code page (Windows). |
| 1217 | @function getconsoleoutputcp | 1227 | @function getconsoleoutputcp |
| 1218 | @treturn[1] int the current code page (always 65001 on Posix systems) | 1228 | @treturn[1] int the current code page (always 65001 on Posix systems) |
| 1229 | @within Terminal_UTF-8 | ||
| 1219 | */ | 1230 | */ |
| 1220 | static int lst_getconsoleoutputcp(lua_State *L) { | 1231 | static int lst_getconsoleoutputcp(lua_State *L) { |
| 1221 | unsigned int cp = 65001; | 1232 | unsigned int cp = 65001; |
| @@ -1233,6 +1244,7 @@ Sets the current console output code page (Windows). | |||
| 1233 | @function setconsoleoutputcp | 1244 | @function setconsoleoutputcp |
| 1234 | @tparam int cp the code page to set, use `system.CODEPAGE_UTF8` (65001) for UTF-8 | 1245 | @tparam int cp the code page to set, use `system.CODEPAGE_UTF8` (65001) for UTF-8 |
| 1235 | @treturn[1] bool `true` on success (always `true` on Posix systems) | 1246 | @treturn[1] bool `true` on success (always `true` on Posix systems) |
| 1247 | @within Terminal_UTF-8 | ||
| 1236 | */ | 1248 | */ |
| 1237 | static int lst_setconsoleoutputcp(lua_State *L) { | 1249 | static int lst_setconsoleoutputcp(lua_State *L) { |
| 1238 | unsigned int cp = (unsigned int)luaL_checkinteger(L, 1); | 1250 | unsigned int cp = (unsigned int)luaL_checkinteger(L, 1); |
