ncurses-like library for haxe?

507 views
Skip to first unread message

Ryland Taylor-Almanza

unread,
Mar 23, 2012, 5:18:29 PM3/23/12
to haxe...@googlegroups.com
Hi, I'm writing an ascii roguelike in haxe. Originally, I was compiling to javascript, but for some things it's just not fast enough, so I'd like to compile to c++. To do this, I'll need some kind of library like ncurses or pdcurses for haxe. Does anyone know of such a thing? If not, could someone point me in the right direction to make a binding for haxe? Thanks, again!

Ryland Taylor-Almanza

unread,
Mar 23, 2012, 6:18:14 PM3/23/12
to haxe...@googlegroups.com
I just discovered the cpp.Lib.load function, but I'm not sure how to use it. How would I load a dll in the same directory, and then how do I use it?

Ashiq A.

unread,
Mar 2, 2015, 11:50:43 PM3/2/15
to haxe...@googlegroups.com
Since this is the only result in Google for this topic, did anyone ever figure this out? Are there any console-drawing libraries for Haxe?

Miha Lunar

unread,
Mar 7, 2015, 4:51:18 AM3/7/15
to haxe...@googlegroups.com
Hi, I have a library that's not really even close to ncurses, but it might be helpful as a base foundation for basic console drawing: https://github.com/SmilyOrg/ansi

Ashiq A.

unread,
Mar 7, 2015, 8:02:17 AM3/7/15
to haxe...@googlegroups.com
Hi,

That looks fantastic. It's great that you also figured out how to move
the cursor.

--Ashiq
> --
> To post to this group haxe...@googlegroups.com
> http://groups.google.com/group/haxelang?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Haxe" group.
> For more options, visit https://groups.google.com/d/optout.

Marcelo de Moraes Serpa

unread,
Mar 7, 2015, 1:54:39 PM3/7/15
to haxe...@googlegroups.com
Interesting - how hard would it be to wrap ncurses and provide an API (from a ndll maybe?) through hxcpp? cc/ Hugh

Andreas Mokros

unread,
Mar 7, 2015, 2:30:21 PM3/7/15
to haxe...@googlegroups.com
Hi.

On Sat, 7 Mar 2015 12:54:33 -0600
Marcelo de Moraes Serpa <fullofc...@gmail.com> wrote:
> Interesting - how hard would it be to wrap ncurses and provide an API
> (from a ndll maybe?) through hxcpp?

A complete ncurses binding is a bit of work, see e.g.:
https://github.com/mscdex/node-ncurses/blob/master/src/binding.cc

--
Mockey

Ashiq A.

unread,
Mar 7, 2015, 3:51:15 PM3/7/15
to haxe...@googlegroups.com
Hi,

Thanks for investigating. That is quite a large amount of code.

I personally think it's much easier (and a more mature code path) to
use something graphical, like OpenFL + HaxeFlixel/HaxePunk. If I did
console, I would prefer a native Haxe approach,even if it's like
Miha's solution (outputting specific console codes -- not real, full
console support), because it's cross-platform.

Since the original thread was from 2012, I can guess that nobody's
really interested in this right now. At least there are two options if
someone decides to investigate.

--Ashiq

John LeGrande

unread,
Mar 7, 2015, 4:45:47 PM3/7/15
to haxe...@googlegroups.com
I'm interested in this as well. Over the last week I've been looking at some of the "terminal-ui" options and I think wrapping termbox (https://github.com/nsf/termbox) might be a little less work than wrapping ncurses. I'm hoping to take a stab at it this weekend.

tondy

unread,
Mar 8, 2015, 3:44:15 AM3/8/15
to haxe...@googlegroups.com
hi,
there is many options for creating text user interface and nothing ideal

1. using tput in unix console

2. using ansi codes
need separate install of ansicon on old windows-es
i see new win10 finally has ansi support /after 30 years of developing?!?!/

3. wrap ncurses in haxe
this is a really for bloody masochists

4. porting to haxe something like lanterna

5. go for web interface
this is the easiest way, but presupposes a good knowledge of web technologies

I chose 5 and created hako embedded web server
hklib is haxelib web interface. i use it every day. the code needs polishing but work :)

Ashiq A.

unread,
Apr 8, 2015, 4:23:19 PM4/8/15
to haxe...@googlegroups.com
Miha: I ran some tests on your library. The API is quite clean and
straight-forward, which I like.

My test was to draw 80x24 continuously; each character is a random
number (0-9) and a random colour.

The results were interesting, to say the least. I tested this on my
Ubuntu VM. On Neko, I get around 3-4FPS; if I build against CPP, I get
around 12-13 FPS (which is quite usable for a roguelike).
ANSI.eraseScreen seems to cause horrendous flickering, though.

On Windows, I got no colour at all.

I've tried Lanterna before, and it's not bad, but it has some
interesting and peculiar bugs.

Wrapping NCurses is what other languages do (eg. Ruby, Python). It is
a lot of work though.

Miha Lunar

unread,
Apr 9, 2015, 7:21:18 AM4/9/15
to haxe...@googlegroups.com
Those are some interesting results, thanks for testing!

Do you have flickering if you clear the screen manually too? Perhaps the best option is to internally have a screen buffer that you change and it just updates the characters that are different at the end of the "frame".

As for Windows, do you have ansicon installed? It's the easiest way to get a colored terminal imo.

Lanterna looks intriguing, seems like it actually uses it's own terminal emulator on graphical platforms, so that may be one way to increase fps/compatibility.

Wrapping ncurses would probably be the best and worst option though :)

tecteun

unread,
Apr 9, 2015, 9:54:46 AM4/9/15
to haxe...@googlegroups.com
How nice, i've been looking at this for a commandline neko app, but for Windows support it's better to use the windows console api 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682073%28v=vs.85%29.aspx

Thus, if someone begins work on a port, I would suggest working on pdcurses, 
for the sake of keeping it compatible with all platforms, without imposing the use of ANSI Dll's on windows. (because ansi is not natively supported, and requires using command.com, which is quite old ;))

Ashiq A.

unread,
Apr 9, 2015, 2:43:53 PM4/9/15
to haxe...@googlegroups.com
Miha: If I stop clearing the screen, the flickering goes away. Maybe
it's because it's in a VM -- I'm not sure. But, I did the same test
with Python and Ruby, and neither flickers. Both offered much better
framerates, too, but that's probably because they used curses under
the hood; I have a feeling it's faster than ANSI console codes.

I didn't try ansicon; I'm looking for something that works on "vanilla" Windows.

Is anyone actively working on this? I'm not.

One option, like Lanterna, is to use a GUI framework (OpenFL?
HaxeFlixel? HaxePunk?) and create a terminal emulator. That would give
you full colour across platforms (even on Windows), and GPU
performance (so unlikely to get low FPS).


--Ashiq
Reply all
Reply to author
Forward
0 new messages