I’ve been thinking about monitoring tools lately and have been thinking about how to get nice UI’s through a terminal window. I had a project going on with the wxErlang library but I scrapped it (or rather put it aside for a little while) because the reality is that most system don’t have a window manager and you usually connect to a machine through ssh.
So I created cecho.
cecho is an ncurses library (wrapper). It works nicely on my linux machine which is as far as I have tested it so it is really pre-alfa but it seems to work. It can be found here: http://www.github.com/mazenharake/cecho
If you download it then check out the cecho_example.erl file for some simple examples on how to use it. It is intended to stay as close as possible to the ncurses API but in some cases it is impossible so I try to make it as alike as possible.
Here is a hello world example:
hello_world() -> application:start(cecho), cecho:cbreak(), cecho:noecho(), cecho:move(10, 10), cecho:addstr("Hello world!"), timer:sleep(2000), application:stop(cecho).
Hopefully this will become useful for someone and some cool stuff come out of it.
Important: This library does NOT support keyboard input yet… I haven’t figured out a proper way to implement it without it being a hack so therefore it will have to wait.
Important2: For some reason the Erlang VM crashes when one do a cecho:move to the max coordinates (the values of cecho:getmaxyx -1) and then add a character (or string). I don’t know why but I think it has to do with newline moving the cursor out of bounds or something… I’m still looking into it.
Have fun… I know I will 🙂