[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ocaml-tmk-devel] Re: [Caml-list] ANNOUNCE: ocaml-curses 1.0.0 released
From: |
Richard Jones |
Subject: |
[Ocaml-tmk-devel] Re: [Caml-list] ANNOUNCE: ocaml-curses 1.0.0 released |
Date: |
Tue, 14 Aug 2007 17:38:01 +0100 |
User-agent: |
Mutt/1.5.9i |
On Mon, Aug 13, 2007 at 11:14:32PM -0400, Paul Pelzl wrote:
> On Mon, Aug 13, 2007 at 02:19:49PM +0100, Richard Jones wrote:
> > I am pleased to announce the first public release of OCaml Curses,
> > which is an OCaml binding to the curses/ncurses library.
> >
> > This project was formerly called OCaml TMK, and all the actual work on
> > it was done by Nicolas George.
>
> Hi Richard,
>
> I have a couple of projects that use curses bindings that I forked off
> of ocaml-tmk a few years back. It looks like I have a couple of
> bugfixes and additional features that you may be interested in migrating
> over. I tried to make a clean patch for you (attached). I see you've
> made some minor changes in the coding style, so feel free to rearrange
> these modifications as you see fit.
>
> Just so it's not overlooked: the most important element in the patch is
> a fix for the typo in ML5.
>
> You can (usually) grab a copy of my code from the latest Wyrd release at
> http://www.eecs.umich.edu/~pelzlpj/wyrd ; unfortunately the web server
> is down at the moment. You might find some value in looking at my
> configure and build scripts, which are fairly well tested with ncurses
> on a variety of platforms.
Thanks for the patch - I'll take a look and apply to CVS.
A question for you, as a user: the getyx function returns (x,y).
Do you regard this as a bug?
Rich.
> diff -pruN ocaml-curses-1.0.0/curses.ml ocaml-curses-patched/curses.ml
> --- ocaml-curses-1.0.0/curses.ml 2007-08-13 07:45:06.000000000 -0500
> +++ ocaml-curses-patched/curses.ml 2007-08-13 21:54:41.000000000 -0500
> @@ -104,6 +104,11 @@ end
>
> #include "functions.c"
>
> +(* these two were written separately in ml_curses.c,
> + * to permit proper threading behavior *)
> +ML0(getch,int)
> +ML1(wgetch,int,window)
> +
> let null_window = null_window ()
>
> let bool_terminfo_variables = Hashtbl.create 67
> diff -pruN ocaml-curses-1.0.0/curses.mli ocaml-curses-patched/curses.mli
> --- ocaml-curses-1.0.0/curses.mli 2007-08-13 07:45:06.000000000 -0500
> +++ ocaml-curses-patched/curses.mli 2007-08-13 21:54:41.000000000 -0500
> @@ -143,6 +143,7 @@ external wclrtobot : window -> unit = "m
> external clrtoeol : unit -> unit = "mlcurses_clrtoeol"
> external wclrtoeol : window -> unit = "mlcurses_wclrtoeol"
> external start_color : unit -> err = "mlcurses_start_color"
> +external use_default_colors : unit -> err = "mlcurses_use_default_colors"
> external init_pair : int -> int -> int -> err = "mlcurses_init_pair"
> external init_color : int -> int -> int -> int -> err = "mlcurses_init_color"
> external has_colors : unit -> bool = "mlcurses_has_colors"
> diff -pruN ocaml-curses-1.0.0/functions.c ocaml-curses-patched/functions.c
> --- ocaml-curses-1.0.0/functions.c 2007-08-13 07:45:06.000000000 -0500
> +++ ocaml-curses-patched/functions.c 2007-08-13 21:57:34.000000000 -0500
> @@ -168,6 +168,7 @@ ML0d(color_pairs,int) BEG0 r_int(COLOR_P
>
> /* delch */
>
> +ML0(use_default_colors,err)
> ML0(delch,err)
> ML1(wdelch,err,window)
> ML2(mvdelch,err,int,int)
> @@ -184,8 +185,6 @@ ML1(winsertln,err,window)
>
> /* getch */
>
> -ML0(getch,int)
> -ML1(wgetch,int,window)
> ML2(mvgetch,int,int,int)
> ML3(mvwgetch,int,window,int,int)
> ML1(ungetch,err,int)
> diff -pruN ocaml-curses-1.0.0/ml_curses.c ocaml-curses-patched/ml_curses.c
> --- ocaml-curses-1.0.0/ml_curses.c 2007-08-13 07:45:06.000000000 -0500
> +++ ocaml-curses-patched/ml_curses.c 2007-08-13 21:56:23.000000000 -0500
> @@ -78,7 +78,7 @@
> { RA4 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac),a_##td(ad))); }
> #define ML5(f,tr,ta,tb,tc,td,te) \
> value mlcurses_##f(value aa,value ab,value ac,value ad,value ae) \
> - { RA5 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac),a_##td(ad),a_##te(ad))); }
> + { RA5 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac),a_##td(ad),a_##te(ae))); }
>
> #define ML7(f,tr,ta,tb,tc,td,te,tf,tg) \
> value mlcurses_##f##_bytecode(value *a,int n) \
> @@ -164,4 +164,36 @@ static void winch_handler(int n)
> }
>
> #include "functions.c"
> +#include "caml/signals.h"
> +
> +/* The following routines are special-cased to allow other threads to run
> + * while getch() is blocking */
> +value mlcurses_getch(void)
> +{
> + CAMLparam0();
> + int ch;
> +
> + enter_blocking_section();
> + ch = getch();
> + leave_blocking_section();
> +
> + CAMLreturn(Val_int(ch));
> +}
> +
> +
> +value mlcurses_wgetch(value win)
> +{
> + CAMLparam1(win);
> + int ch;
> + WINDOW* w;
> +
> + caml__dummy_win = caml__dummy_win;
> + w = (WINDOW *) win;
> +
> + enter_blocking_section();
> + ch = wgetch(w);
> + leave_blocking_section();
> +
> + CAMLreturn(Val_int(ch));
> +}
>
--
Richard Jones
Red Hat