This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ncurses for guile.


Ceri Storey writes:
 > I have put up a preliminary version of a ncurses wrapper for guile, at
 > http://www.nomorespam.freeserve.co.uk/guile-ncurses-0.1.tar.gz
 > why have i done this? 
 >     a) i could not find the alleged other implementation, so i did my 
 > own.
 >     b) i was bored.
 > if anyone would like to help (I'm not entirely sure how to do windows)
 > please check it out.

I had a first look at it by now.
What concerns windows, the standard way is to define a new smobtype.
This is described in the data-rep.info which (still?) comes in the
doc directory of guile distributions. It's a somewhat tough thing
because one needs to care for instructing garbage collection how
to deal with windows.

It's common practice among guile extenders to prevent guile
crashes from bad scheme code.

Your initscr wrapper does not check for the return value of
initscr. It should not be (WINDOW *)NULL, for this means
that initscr failed. Unfortunately there is no way to tell
why it failed, it might be due to lacking memory on the heap
for allocating stdscr and its lineptrs , or because the
terminfo entry is corrupted . If such an error occurs ,
later curses call will crash guile with a segmentation fault.
So it's a good idea to check and raise an error in case of
failure.
Also note that forgetting to call initscr will cause crashes
of guile. So it's a good idea to define a static variable
in the sourcecode with starts with 0 and is set to 1 upon
successful calling of initscr(). Then each other curses
routine should check the value of the static variable and
raise and raise an exception when it is zero, i.e. the
screen is still uninitialized.
Also some of the other ncurses functions should trigger an
exception or error upon returning ERR, to prevent crashes
in subsequent calls if the caller forgets check.

Klaus Schilling

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]