-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(term): getting/setting console flags (windows) #21
base: master
Are you sure you want to change the base?
Conversation
91da293
to
ed49e5b
Compare
0f44ddb
to
0f5b3b0
Compare
@o-lim I still need to add more tests. But a first review would be most welcome. |
{NULL, NULL} | ||
}; | ||
|
||
static const struct luaL_Reg lsbf_methods[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't all of this be implemented in lua
rather than C
? Is there something special about bitflags
that can only be done in C
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lua 5.1 doesn't have bitwise operators.
easier to handle this on the Lua side
Handles utf8, and character width
60a49e3
to
0e0e50c
Compare
@o-lim this has turned out to be a bit of a rabbit hole. But it is now covered I think, although a far larger contribution than anticipated. Once keyboard input was added, it needed UTF-8 conversion and non-blocking mode, which then needed UTF-8 width again... The most powerful example I think is the So apologies for the massive PR, hope you can find some time for a review. The file |
adding some terminal functions to be able to better control terminal in- and output.
getconsoleflags
andsetconsoleflags
for getting/setting the current console configuration flags on Windowsgetconsolecp
andsetconsolecp
for getting/setting the console codepage on Windowsgetconsoleoutputcp
andsetconsoleoutputcp
for getting/setting the console output codepage on Windowstcgetattr
andtcsetattr
for getting/setting the current console configuration flags on Posixgetnonblock
andsetnonblock
for getting/setting the non-blocking flag on Posixbitflags
: a support feature for the above flag type controls to facilitate bit manipulation without resorting to binary operations (to also support PuC Lua 5.1)readkey
reads a keyboard input fromstdin
in a non-blocking way (utf8, also on Windows)readansi
reads a keyboard input fromstdin
in a non-blocking way, parses ansi and utf8 sequencestermsize
gets the current terminal size in rows and columnsutf8cwidth
andutf8swidth
for getting the display width (in columns) of respectively a single utf8 character, or a utf8 stringtermbackup
,termrestore
,autotermrestore
, andtermwrap
for managing the many terminal settings on all platforms.Terminal behaviour is fundamentally different on Posix and Windows. So in pretty much all cases of using terminal in/output cross platform the user will still have to write platform specific code. But the above primitives at least allow to create CLI applications that behave similar on all platforms.
See
doc_topics/03-terminal.md
for an overview of functionalities.This PR includes a number of examples:
EDIT: adjusted description to match the latest code