Conversation
this has come up once or twice as there aren't many good libraries for writing cross-platform terminal applications. to my surprise, recent windows versions support xterm-like caps if you put the console in a special mode. initializing the console, reading and writing to it, and handling resize events are different but everything else is the same. `wcwidth` isn't available, so everything is assumed to occupy 1 column. i haven't tested anything besides the keyboard demo, which seems to work just fine.
|
agreed that's a lot of ifdefs. This would no longer be a single-header library if you split out platform-dependant stuff and then conditionally #include the right one.
How would you do that ? |
|
Hi, thanks for looking at this. Yeah maybe something like that. Alternatively we can abstract the platform-dependent stuff into function table, one for POSIX, one for Windows. The extra layer would make the code slightly harder to read, but it would cut down on the number of ifdefs to maybe 2 or 3 and wouldn't introduce any new source files or codegen in the repo. I'm also separately trying to see how many of the ifdefs are really necessary. For example I tried converting the stdio |
|
Closing in favor of another draft PR #66 |
This has come up once or twice as there aren't many good libraries for writing cross-platform terminal applications. To my surprise, recent versions of Windows Console support xterm-like caps if you put the console in a special mode. Initializing the console, reading and writing to it, and handling resize events are different but everything else is the same.
wcwidthisn't available, so everything is assumed to occupy 1 column.I haven't tested anything besides the keyboard demo, which seems to work just fine.
The ifdefs ugly up the code a lot, so I'm hesitant to actually merge this. I may attempt to code-gen a separate artifact
termbox2-win.hor something. Feedback welcome.