robik / ConsoleD

Because colors are awesome.
63 stars 11 forks source link

Add function to clear screen. #5

Closed quickfur closed 11 years ago

quickfur commented 11 years ago

Note: I didn't implement the Windows version because although I found the code for it, I don't have a Windows dev environment to test it on.

adamdruppe commented 11 years ago

On Sat, Jan 19, 2013 at 10:43:29AM -0800, H. S. Teoh wrote:

Note: I didn't implement the Windows version because although I found the code for it, I don't have a Windows dev environment to test it on.

cool, I'll turn on my windows box at some point over the weekend and check it out.

BTW my future direction for this code is: get a different event loop or something (I have some generic epoll based code on my computer that I'd like to work in here. The benefit would be one event loop for any kind of D app.), and then get a real merging with Robik's code too.

Shouldn't break much though if we do it right, and I have no idea when I'll actually get around to it.

quickfur commented 11 years ago

Having a generic event loop in D would be very nice, esp. if it can be merged into Phobos. But it should be completely independent of terminal functions.

I think any generic event loop should support at least: 1) Handling of arbitrary file descriptors (probably trivial) 2) Timers and scheduled events 3) User-generated events (for extensibility).

Which shouldn't be too hard to implement, I think.

adamdruppe commented 11 years ago

On Mon, Jan 21, 2013 at 12:56:40PM -0800, H. S. Teoh wrote:

But it should be completely independent of terminal functions.

Aye. I integrated my thing into the terminal.d and pushed it up, protected by version so it is opt in.

The file is here: https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/eventloop.d

I haven't done a Windows or other unix version yet, only linux.

The way it works is you just add functions and send data. They are matched up by signatures.

struct MyEvent { int a; } addListener((MyEvent ev) { writeln("got a ", ev); }); send(MyEvent(10)); // will call the listener above

Can also do file descriptors for read/write/error (which is where the terminal thing hooks in, with a read ready on stdin event).

So I haven't added timers yet, but otherwise I think it fits the bill for what's needed.