[m-rev.] for review: curs binding updates
Julien Fischer
juliensf at cs.mu.OZ.AU
Wed Dec 1 16:04:44 AEDT 2004
On Wed, 1 Dec 2004, Peter WANG wrote:
> For review by anyone.
>
> Estimated hours taken: 0.5
>
You should have an indication of which branch this will be
committed on - in this case the main one.
> extras/curs/curs.m:
> Added "nodelay" predicate to select nonblocking input from getch.
> Export "refresh" instead of "doupdate" as doupdate does nothing
> without a paired call to wnoutrefresh.
> Added "flushinp" to clear typeahead buffer.
> Added the constant "err" which can now be returned by getch if
> in nonblocking mode and there is no input ready.
>
> Index: curs.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/extras/curs/curs.m,v
> retrieving revision 1.4
> diff -u -r1.4 curs.m
> --- curs.m 6 Mar 2002 10:10:29 -0000 1.4
> +++ curs.m 30 Nov 2004 04:58:20 -0000
> @@ -28,7 +28,7 @@
>
> :- interface.
>
> -:- import_module io, string, char, int.
> +:- import_module bool, io, string, char, int.
>
>
>
> @@ -38,6 +38,12 @@
> %
> :- pred start(io__state::di, io__state::uo) is det.
>
> + % Enable or disable the no-delay option. If enabled (first argument is
> + % true) then getch will be a non-blocking call, i.e. return immediately
> + % if no input is ready rather than waiting for input.
> + %
s/first argument is true/first argument is yes/ there.
> +:- pred nodelay(bool::in, io__state::di, io__state::uo) is det.
> +
> % Close a curses session; necessary to return the tty to a sensible
> % state.
> %
> @@ -79,15 +85,20 @@
> :- pred attr_set(attr::in, io__state::di, io__state::uo) is det.
>
> % Update the display. Changes made to the display are not made
> - % visible until doupdate is called.
> + % visible until refresh is called.
> %
> -:- pred doupdate(io__state::di, io__state::uo) is det.
> +:- pred refresh(io__state::di, io__state::uo) is det.
>
Don't delete doupdate - if it's no longer of any use just put
an obsolete pragma on it.
> % Read a character from the keyboard (unbuffered) and translate it
> - % if necessary.
> + % if necessary. In no-delay mode, if no input is waiting, the value
> + % curs__err is returned.
> %
> :- pred getch(int::out, io__state::di, io__state::uo) is det.
>
> + % Throw away any typeahead that has not yet been read by the program.
> + %
> +:- pred flushinp(io__state::di, io__state::uo) is det.
> +
>
>
> % Draws a border around the inside edge of the display.
> @@ -104,6 +115,13 @@
>
>
>
> + % Error code; currently only used as return value of getch to
> + % indicate that no input is ready.
> + %
> +:- func err = int.
> +
> +
> +
> % Various key code translations outside the normal ASCII range.
> %
> :- func key_down = int.
> @@ -449,6 +467,16 @@
>
> % ---------------------------------------------------------------------------- %
>
> +:- pragma foreign_proc("C", nodelay(BF::in, IO0::di, IO::uo),
> + [will_not_call_mercury, promise_pure], "
> +
> + nodelay(stdscr, BF);
> + IO = IO0;
> +
> +").
> +
> +% ---------------------------------------------------------------------------- %
> +
> :- pragma foreign_proc("C", stop(IO0::di, IO::uo),
> [will_not_call_mercury, promise_pure], "
>
> @@ -538,10 +566,10 @@
>
> % ---------------------------------------------------------------------------- %
>
> -:- pragma foreign_proc("C", doupdate(IO0::di, IO::uo),
> +:- pragma foreign_proc("C", refresh(IO0::di, IO::uo),
> [will_not_call_mercury, promise_pure], "
>
> - doupdate();
> + refresh();
> IO = IO0;
>
> ").
> @@ -554,6 +582,23 @@
> CharCode = getch();
> IO = IO0;
>
> +").
> +
> +% ---------------------------------------------------------------------------- %
> +
> +:- pragma foreign_proc("C", flushinp(IO0::di, IO::uo),
> + [will_not_call_mercury, promise_pure], "
> +
> + flushinp();
> + IO = IO0;
> +
> +").
> +
> +% ---------------------------------------------------------------------------- %
> +
> +:- pragma foreign_proc("C", err = (E::out),
> + [will_not_call_mercury, promise_pure], "
> + E = ERR;
> ").
>
That looks fine otherwise.
Can you post a relative diff when you've made the changes I suggest above.
Cheers,
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list