nim-notcurses: a wrapper for the Nim programming language #2034
Replies: 5 comments 2 replies
-
[schwarzgerat](0) $ pkg-config --static --libs notcurses
-lnotcurses -lstdc++ -lnotcurses-core -lunistring -lm -ltinfo
[schwarzgerat](0) $ pkg-config --static --libs notcurses-core
-lnotcurses-core -lunistring -lm -ltinfo
[schwarzgerat](0) $ |
Beta Was this translation helpful? Give feedback.
-
I hope the wrapper are added to this project once it seems ready for consuming. Since precedence has already been set by including other wrappers, it logically makes sense to consolidate them all to this repo. |
Beta Was this translation helpful? Give feedback.
-
Quick update: For about half a month I've been working on an overhaul of nim-notcurses as personal time has allowed. The ongoing effort is taking place on the It's still very much a WIP, there are miles to go, but I'm starting to be pleased with the overall shape the layers are taking. I've updated the readme on that branch with respect to where/how I want to end up. Highlights:
Notes:
The internal structure of my nim-notcurses overhaul (as opposed to the API it presents) is perhaps a bit unusual, but my chosen approach allows me a lot of flexibility re: wrapping and presenting core, CLI mode, and Direct mode with minimal code duplication and without dependence on compile-time options passed to the Nim compiler by users of nim-notcurses. A side benefit of the approach is that I'm learning a lot more about C and Notcurses internals than I would have by relying purely on nimterop to generate the ABI wrapper. I'll be opening some discussions and/or issues in the near future, because I'm already running into Notcurses things that aren't working as I (maybe wrongly) expect, and as far as I can tell they're behaviors of Notcurses and not my ABI wrapper nor API. I'll do my best to pose the questions in a way that doesn't require non-Nimmers to get hot and heavy with Nim, i.e. I'll try to frame them in terms of Notcurses' C headers and sources as much as possible. Happy New Year 🎉 |
Beta Was this translation helpful? Give feedback.
-
I've got GitHub Actions cruising along for my Compilation and runs of my I'm having some trouble on Windows. It's in three parts, and I'll break it down here. If any of these seem like they're possible bugs or changes needed in Notcurses, let me know and I'll create issues for investigation. I'm also happy to try to create PRs, if/when I have the insight to do so. 1. Build files not copied to Locally and in GHA, I'm building Notcurses on Windows like this in a clone of the repo:
When I run I was a bit surprised they didn't get copied into the appropriate
With the files in place there, I can compile my
And in Windows Terminal like this:
What do you think? Could / should 2. dynlib problems After sorting out (1) above, with only a few adjustments I got my When I did From here: proc ncplane_set_scrolling(n: ptr ncplane, scrollp: cuint): bool
{.cdecl, dynlib: notcurses_lib, importc.}
Nim's On linux and mac, it seems to be enough to tell Nim to inform the linker about both But on Windows it seems that I need on a per symbol basis to know and specify if it's coming from notcurses or notcurses-core.
It's possible to tell the Nim compiler to arrange for dlopen to not be used, i.e. to instead depend on linker flags. I tried that, but it didn't work: gcc started barfing about duplicated references to The Notcurses binaries that are built on Windows with cmake/make (e.g. notcurses-input) don't have have this problem, so obviously there's shortcomings in the way the Nim compiler does things by default, with respect to what needs to be done for Notcurses on Windows. 3. mintty is spewing My But in mintty all three nim-notcurses programs spew garbage into the terminal, and for I'm using the notcurses-input built with cmake/make doesn't have this problem in mintty, so again, there must be something related to how the sausage is getting made by the Nim compiler. I can probably sort it out eventually, but if someone has any ideas on where/how to investigate, I'll be grateful. |
Beta Was this translation helpful? Give feedback.
-
i'm sorry not to have responded to this yet; i will do so this weekend! |
Beta Was this translation helpful? Give feedback.
-
It's a small start, but still a start:
https://github.com/michaelsbradleyjr/nim-notcurses
Things to note:
I've not yet published it as a package for nimble, but will do so once I'm convinced a good portion of the Notcurses API is reasonably usable via nim-notcurses.I decided to go ahead and add it, carpe diem: Added notcurses nim-lang/packages#1982.v2.3.13
, but I may delete and re-create that tag if I discover major problems with the wrapper as it exists currently.examples/hello_direct.nim
is being compiled and run across Linux, macOS, and maybe even Windows.--passL
option. I tried earlier today for bothlibnotcurses.a
andlibnotcurses-core.a
, but couldn't get it to work. I'll need to do more research, and once I know the "formula" I'll include some notes in the README (or an.md
doc linked from it). There will, of course, be variances by platform, but I'll try to cover the bases.Beta Was this translation helpful? Give feedback.
All reactions