ncurses calls

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ncurses calls

Brad Watson
I've been working on  a c call interace from gst to
ncurses, but it occured to me that maybe it's been
done before, and I just missed it....  Has it ?

Kind regards,


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: ncurses calls

Paolo Bonzini
Brad Watson wrote:
> I've been working on  a c call interace from gst to
> ncurses, but it occured to me that maybe it's been
> done before, and I just missed it....
No, it's on the ever growing TODO list. :-)

Paolo



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: ncurses calls

Paolo Bonzini
In reply to this post by Brad Watson
Brad Watson wrote:
> Is it better to use the dynamic library linking
> mechanism or the dynamic module linking system for
> ncurses ?
>
>  
I don't know it very well, but the possibilities are:

- use a module only: ok if the library is very small and a lot of
functions need wrappers; see examples/gdbm.st for an example, or the
regex module in 2.2 (now it's in the main image).

- use a library only: ok if the library is possibly complicated, but its
interface is such that it needs no wrappers; an example is when you use
functions from libc, or in the MD5 package.

- use a module *and* a library: ok if the library is quite big, and it
has an interface that is quite complicated so that it is necessary to
manipulate Smalltalk objects in the wrapper.  The most obvious example
is GTK.

I think that ncurses fits in case 2 -- only a library -- especially
because it is simple and its interface does not involve callbacks from
ncurses into user code.  Maybe you will need some C code in order to run
some initialization code or to handle SIGWINCH.  In this case you may
have a very thin module just to implement this (you have a very handy
place to set up the initialization code in gst_initModule), but still
most of the functionality would be provided by linking the ncurses library.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: ncurses calls

Paolo Bonzini
In reply to this post by Brad Watson
Brad Watson wrote:

> After doing a little more digging I found:
>
> "Ncurses 5.0 can be configured to establish its own
> SIGWINCH hander. In this configuration, the wgetch
> function will return a special keycode KEY_RESIZE when
> a resizing event is detected. The signal handler also
> calls resizeterm (Caveat: malloc and free are not
> guaranteed to be safe for use in a signal
> handler)...."
>
> Considering this, do you consider it worth the effort
> to implement the callback, or (my preference at the
> moment,) the KISS route where I don't bother ?
>  
Mine was just an example found after googling for a tutorial, so there
may be other reasons to have callbacks, but I don't think so and this is
good news: it means you can configure ncurses to have its own handler
installed, and then the program may or may not do something for KEY_RESIZE.

(don't be afraid to spam the list)

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: ncurses calls

Brad Watson
Paolo,

Thanks for the advice: initial indications (from
calling the Smalltalk initScr method) are that I've
been able to successfully access the ncurses functions
after defining them int cint.c, CFuncs.st.

Now to test a whole lot of ncurses functions, and
implement all of the multiple argument ncurses
functions that I skipped on the first go around....

Kind regards,






__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: ncurses calls

Paolo Bonzini
Brad Watson wrote:

> Paolo,
>
> Thanks for the advice: initial indications (from
> calling the Smalltalk initScr method) are that I've
> been able to successfully access the ncurses functions
> after defining them int cint.c, CFuncs.st.
>
> Now to test a whole lot of ncurses functions, and
> implement all of the multiple argument ncurses
> functions that I skipped on the first go around....
>  
You can use "DLD addLibrary: 'libncurses'" after which there is no need
to patch cint.c -- just put the definitions in your own .st file.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: ncurses calls

Brad Watson
Paolo,

I took your suggestions and implemented them.  I
humbly submit the attached:

Kind regards,

Brad Watson

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

myncurses.st (60K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ncurses calls

Paolo Bonzini
Brad Watson wrote:
> Paolo,
>
> I took your suggestions and implemented them.  I
> humbly submit the attached:
>  
Perfect, except that DLD addLibrary: 'ncurses'! belongs in myncurses.st.

I'll send you the copyright assignment forms later today.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk