www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - ncurses bindings for D?

reply Tabris <Tabris_member pathlink.com> writes:
Does anyone know if there are any ncurses bindings around for D? I'm looking to
develop a roguelike using D, and it would save me a lot of time if someone has
already done all the nasty work of converting ncurses.h to a D module --
particularly as there are so many macro functions in there that I have no idea
how to tackle parts of it. For example:

extern NCURSES_EXPORT_VAR(chtype) acs_map[];

#define NCURSES_ACS(c)	(acs_map[(unsigned char)c])

/* VT100 symbols begin here */
#define ACS_ULCORNER	NCURSES_ACS('l') /* upper left corner */
#define ACS_LLCORNER	NCURSES_ACS('m') /* lower left corner */
..
etc.

Does D support exported variables like this?
Would the declaration become something like this?
export chtype *acs_map;
Oct 16 2004
next sibling parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
To use ncurses (and all it's macros) you would have to convert the 
macros to functions. As it is, I'm doing a port of PDCurses to D. 
Currently some of the functionality works on Windows. If you want to use 
curses for something useful (e.g. rogue), you'll probably be better off 
using ncurses (or PDCurses as it has a native Windows implementation) 
yet. I think it'll be a while until dcurses is ready. It's mostly a 
learning experience for me.

Lars Ivar Igesund

Tabris wrote:
 Does anyone know if there are any ncurses bindings around for D? I'm looking to
 develop a roguelike using D, and it would save me a lot of time if someone has
 already done all the nasty work of converting ncurses.h to a D module --
 particularly as there are so many macro functions in there that I have no idea
 how to tackle parts of it. For example:
 
 extern NCURSES_EXPORT_VAR(chtype) acs_map[];
 
 #define NCURSES_ACS(c)	(acs_map[(unsigned char)c])
 
 /* VT100 symbols begin here */
 #define ACS_ULCORNER	NCURSES_ACS('l') /* upper left corner */
 #define ACS_LLCORNER	NCURSES_ACS('m') /* lower left corner */
 ..
 etc.
 
 Does D support exported variables like this?
 Would the declaration become something like this?
 export chtype *acs_map;
 
 

Oct 17 2004
parent reply Tabris <Tabris_member pathlink.com> writes:
In article <ckt849$2sfu$1 digitaldaemon.com>, Lars Ivar Igesund says...
To use ncurses (and all it's macros) you would have to convert the 
macros to functions. As it is, I'm doing a port of PDCurses to D. 
Currently some of the functionality works on Windows. If you want to use 
curses for something useful (e.g. rogue), you'll probably be better off 
using ncurses (or PDCurses as it has a native Windows implementation) 
yet. I think it'll be a while until dcurses is ready. It's mostly a 
learning experience for me.

Lars Ivar Igesund

Tabris wrote:
 Does anyone know if there are any ncurses bindings around for D? I'm looking to
 develop a roguelike using D, and it would save me a lot of time if someone has
 already done all the nasty work of converting ncurses.h to a D module --
 particularly as there are so many macro functions in there that I have no idea
 how to tackle parts of it. For example:
 
 extern NCURSES_EXPORT_VAR(chtype) acs_map[];
 
 #define NCURSES_ACS(c)	(acs_map[(unsigned char)c])
 
 /* VT100 symbols begin here */
 #define ACS_ULCORNER	NCURSES_ACS('l') /* upper left corner */
 #define ACS_LLCORNER	NCURSES_ACS('m') /* lower left corner */
 ..
 etc.
 
 Does D support exported variables like this?
 Would the declaration become something like this?
 export chtype *acs_map;
 
 


Can't wait to see your D implementation of curses :) If I manage to create a D ncurses binding successfully, I'll bump this thread with it, since there must be a few other people in this position.
Oct 18 2004
parent reply "Jaap Geurts" <jaapsen hotmail.com> writes:
I wrote an ncurses translation and it works pretty well.
It doesn't support all the functions, but you can fill them in as you wish.

The only small problem is the C macros for the ACS characters.
In C you would do:
putchar(ACS_BULLET)

I couldn't get that to work in D so i do this instead:
putchar(acs_map[ACS_BULLET]);

wish is good enough for me.

Good luck, Jaap
Oct 19 2004
parent reply "Jaap Geurts" <jaapsen hotmail.com> writes:
Please ignore the attachment in the last post. It won't compile because it
had some windows stuff in it.

Here is the ncurses pure one.

Jaap
Oct 19 2004
parent Tabris <Tabris_member pathlink.com> writes:
In article <cl3don$6uj$1 digitaldaemon.com>, Jaap Geurts says...
Please ignore the attachment in the last post. It won't compile because it
had some windows stuff in it.

Here is the ncurses pure one.

Jaap

Many thanks, this has saved me a fair amount of work :)
Oct 25 2004
prev sibling parent reply "Jaap Geurts" <jaapsen hotmail.com> writes:
Hi Tabris,

Is Rogue a screen widget library?

Actually I developed one. It's not complete, it's not very efficient, but
the basics are working and it does what I currently need. (windows, buttons,
editboxes, tables, pulldown, listbox, radio, checkbox, progressbar). It can
do UTF-8 too.
If you are interested let me know.

Jaap


"Tabris" <Tabris_member pathlink.com> wrote in message
news:cksd0c$2322$1 digitaldaemon.com...
 Does anyone know if there are any ncurses bindings around for D? I'm

 develop a roguelike using D, and it would save me a lot of time if someone

 already done all the nasty work of converting ncurses.h to a D module --
 particularly as there are so many macro functions in there that I have no

 how to tackle parts of it. For example:

 extern NCURSES_EXPORT_VAR(chtype) acs_map[];

 #define NCURSES_ACS(c) (acs_map[(unsigned char)c])

 /* VT100 symbols begin here */
 #define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */
 #define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */
 ..
 etc.

 Does D support exported variables like this?
 Would the declaration become something like this?
 export chtype *acs_map;

Oct 19 2004
parent Lars Ivar Igesund <larsivar igesund.net> writes:
Jaap Geurts wrote:
 Hi Tabris,
 
 Is Rogue a screen widget library?

Rogue was an early consolebased game. NetHack, Angband and others are classified as Rogue-likes. Lars Ivar Igesund
Oct 19 2004