[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Provide NCurses Bindings for Java

From: Rudolf Schmidt
Subject: Re: Provide NCurses Bindings for Java
Date: Wed, 28 Feb 2018 14:10:32 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 02/27/2018 12:33 AM, Rich Coe wrote:
On Mon, 26 Feb 2018 20:55:08 +0100
Rudolf Schmidt <address@hidden> wrote:

I took at look into charva, I see some bindings there, but the binding
code looks quite complex.
I only write this to document my findings, not to deter you on your quest.

Part of the problem with Java bindings for curses is that tty mode in
Java is a second-class (or third-class) priority.

When java quits (or dies) the code needs to restore the terminal settings to
sane.  One problem is that its possible for java to exit without
calling shutdown handlers.  Perhaps you can avoid this by wrapping the calling
of the app in a script (or another java program) that restores the tty settings.

There may be other issues that I'm not remembering at the moment.

I looked for my review notes after I investigated an easy way to put
the terminal into cooked mode from java.  I didn't find my notes, it was a while
ago.  I did find notes that I liked jcurses and lanterna.
I have created a prototype: https://github.com/rudolfschmidt/jcurses

It uses jna (java native access) to the shared library ncurses.

You can even start a window already, at the moment I struggle with the key recognition.
Even laterna had its problems. Its also a reason why I have skiped using it.

in c something like
int key = getc();
if (key == KEY_ENTER) printw("works");

should do the work.
In java I get some strange results, the octa numbers dont fit together. could you imagine why?

I try to move the source code from ncurses to java step by step.

I love terminal apps and in imho Java is one of the best coding languages out there atm, specially because of the tooling like intellij.
Its a nogo that java still has no proper support for curses.

I'd also recommend that it's far easier to modify an existing library that
does some of what you want than it is to write something from scratch.
The problem with existing libraries is that first you need to understand the complex code structure. It doesnt mean thaht you cannot copy relevant parts. Sometime its easier to start something from scratch. Also I remember that both libraries dont use JNA.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]