Building Curses applications

593 views
Skip to first unread message

Nikos Chantziaras

unread,
Aug 10, 2012, 5:39:27 PM8/10/12
to emscripte...@googlegroups.com
Hello.

Is there some sort of curses/ncurses support in Emscripten? Or at least other forms of terminal/console based character I/O?

Alon Zakai

unread,
Aug 13, 2012, 4:45:45 PM8/13/12
to emscripte...@googlegroups.com
Currently no, but this would be useful, for sure.

I am not familiar with curses. If you can perhaps make a testcase that
uses the important parts of the API and file a github issue, we can
investigate how hard it would be to implement this. I am hoping all we
need is to implement some simple low-level calls that render
characters to screen locations, which I guess we would do to a
textarea HTML element.

- azakai

Ehsan Akhgari

unread,
Aug 14, 2012, 9:51:49 AM8/14/12
to emscripte...@googlegroups.com
Here's a short tutorial to the ncurses API:
<http://invisible-island.net/ncurses/ncurses-intro.html>

Based on my limited knowledge of the API, the HTML textarea element is
not a suitable fit since you need to be able to control things like
the foreground and background color of individual cells in the screen
matrix. It would totally be possible, however, to use an HTML table
or some such element to represent the screen, and render individual
cells in each cell of the table. Basically the work boils down to
somebody implementing the ncurses APIs in Emscripten.

I would be happy to help whoever wants to step up for doing this.

Cheers,
--
Ehsan
<http://ehsanakhgari.org/>

Ivan Vučica

unread,
Aug 14, 2012, 10:40:41 AM8/14/12
to emscripte...@googlegroups.com
Fabrice Bellard uses this very method. Too bad JSLinux is not (officially) open source.
http://bellard.org/jslinux/

He does link to "termlib.js".
http://www.masswerk.at/termlib/
which has the following license

> This JavaScript-library is free.
> Include a visible backlink to <http://www.masswerk.at/termlib/> in the embedding web page or application. The library should always be accompanied by the "readme.txt" and the sample HTML-documents.
--
Ivan Vučica
iv...@vucica.net - http://ivan.vucica.net/

Alon Zakai

unread,
Aug 14, 2012, 2:32:50 PM8/14/12
to emscripte...@googlegroups.com
Hmm that license is not an open source one, sadly.

Anyhow, a terminal in HTML can't be that hard to do. Another option is
to use canvas for it.

The real question is whether it makes more sense to compile curses and
implement the lower-level OS API it uses, or just implement curses
itself. The latter is simpler, unless curses has a lot of internal
functionality, I can't tell without writing some code in it. But the
API seems simple at first glance.

- azakai

Nikos Chantziaras

unread,
Aug 14, 2012, 2:45:02 PM8/14/12
to emscripte...@googlegroups.com
The core API is quite simple. There's optional stuff like routines for
menus and panels. But AFAIK they are all wrappers around the core API.
So if that core API was available, then the extra libraries for menus
and panels (and any other extension library) can probably be compiled
from C as-is.

Ehsan Akhgari

unread,
Aug 14, 2012, 3:18:06 PM8/14/12
to emscripte...@googlegroups.com
Yeah, I think we must be able to compile most of the higher level APIs
on top of a few core functions.

--
Ehsan
<http://ehsanakhgari.org/>

Alon Zakai

unread,
Aug 14, 2012, 8:03:15 PM8/14/12
to emscripte...@googlegroups.com
If they have menus and so forth, then yeah, sounds like we should
compile curses and implement lower-level stuff that it needs.

- azakai

hhm

unread,
Aug 9, 2013, 5:10:59 AM8/9/13
to emscripte...@googlegroups.com
PDCurses <http://pdcurses.sourceforge.net/> may be good for this job, it has an SDL backend. The only question then is, how compatible it is with ncurses.

Simon Lienhard

unread,
Feb 22, 2019, 9:28:30 AM2/22/19
to emscripten-discuss

Anything new on a curses/ncurses support in Emscripten?
Reply all
Reply to author
Forward
0 new messages