jzellner/encurses — pull request #4 by erikmack (2014-07-27 21:21:13+00:00)
Title: Implement wgetch

Thank you for encurses! It should allow me to prototype games quickly in erlang.

```getch``` is implemented to take keyboard input, but ```getch``` doesn't support windows. An explanation is [here](http://stackoverflow.com/questions/19748685/curses-library-why-does-getch-clear-my-screen).

This patch implements ncurses' ```wgetch```, which is a general case of ```getch(0)```.

This escript illustrates the problem and the fix, depending on which line is enabled:

#!/usr/bin/env escript
%%! -noinput -pa ebin

-include_lib("include/encurses.hrl").

main(_) ->
encurses:initscr(),
encurses:noecho(),
encurses:curs_set(?CURS_INVISIBLE),

Canvas = encurses:newwin(20,20,1,1),
encurses:box(Canvas,?ACS_DIAMOND,?ACS_LANTERN),
encurses:refresh(Canvas),
Keyloop = fun F() ->

%% Implicit refresh overwrites all windows
%% Ch = encurses:getch(),

%% This allows input to windows
Ch = encurses:wgetch(Canvas),

encurses:mvwaddstr(Canvas,10,10," "),
encurses:mvwaddstr(Canvas,10,10,io_lib:format("~p",[Ch])),
encurses:refresh(Canvas),
F()
end,
spawn(Keyloop),
timer:sleep(10000),
encurses:endwin().