[m-dev.] For review: new extras package - curses binding
Fergus Henderson
fjh at cs.mu.OZ.AU
Sat Jan 15 11:11:44 AEDT 2000
On 14-Jan-2000, Robert Ernst Johann JESCHOFNIK <rejj at cat.cs.mu.OZ.AU> wrote:
> Index: README
> ===================================================================
> RCS file: /home/mercury1/repository//mercury/extras/README,v
> retrieving revision 1.5
> diff -u -r1.5 README
> --- README 1999/03/15 08:56:53 1.5
> +++ README 2000/01/13 05:17:52
> @@ -12,6 +12,9 @@
> A Mercury library package containing support for
> complex and imaginary numbers.
>
> +curses A Mercury library providing a (partial) binding to
> + curses.
What's "curses"?
You should not assume that the user will know what curses is.
> +:- module mcurses:basics.
Please don't use `:', use `__' instead.
> + % Initilise curses.
Spelling error.
> This is used by curse.m, and should not be called by the
> + % programmer.
> +:- pred init(io__state, io__state).
> +:- mode init(di, uo) is det.
...
> +:- pragma c_code(init(IO0::di, IO::uo), "
> +{
> + WINDOW *w;
> + w = initscr();
> + noecho();
> + cbreak();
> + keypad(w, TRUE);
> + IO = IO0;
> +}
> +").
Hmm, the fact that this turns of echoing, etc.
should be documented somewhere...
> +:- module mcurses:misc.
> +:- interface.
> +
> +:- import_module array, char, int, io.
> +
> + % for(Accumulator, Max, Closure, StoreIn, StoreOut)
> + % perform an operation much like a `for loop' in imperative languages. For
> + % every value of Accumulator =< Max, call Closure with the current value of
> + % Accumulator.
> + %
> + % Example:
> + %
> + % for(0, 5, (pred(Num::in, IO1::di, IO2::uo) is det :-
> + % io__print(Num, IO1, IO2)
> + % ), IO0, IO)
> + %
> + % Would print "12345".
I suggest you change the example to use DCG notation:
% main -->
% for(0, 5, (pred(Num::in, di, uo) is det -->
% io__print(Num)
% )).
> + for(Min+1, Max, Pred, Acc1, Acc)
s/Min+1/Min + 1/
> Index: curses/sample/Mmakefile
> ===================================================================
> RCS file: Mmakefile
> diff -N Mmakefile
> --- /dev/null Thu Mar 4 04:20:11 1999
> +++ Mmakefile Fri Jan 14 15:30:03 2000
> @@ -0,0 +1,16 @@
> +# Specify location of the mcurses library
> +MCURSES_DIR = ..
> +
> +# Tell mmake to use the mcurses library
> +VPATH = $(MCURSES_DIR):$(MMAKE_VPATH)
> +MCFLAGS = -I$(MCURSES_DIR) $(EXTRA_MCFLAGS)
> +MLFLAGS = -R$(MCURSES_DIR) $(EXTRA_MLFLAGS) \
> + -L$(MCURSES_DIR)
> +# Note that you have to tell the linker to use the mcurses library
> +# AND the ncurses library (which mcurses is an interface for)
> +MLLIBS = -lmcurses -lncurses $(EXTRA_MLLIBS)
> +C2INITFLAGS = $(MCURSES_DIR)/mcurses.init
This could be significantly simplified now;
see the "Libraries" chapter of the Mercury User's Guide.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list