[RFC] ColorD

Adam D. Ruppe destructionator at gmail.com
Sat Oct 27 10:31:42 PDT 2012


On Friday, 26 October 2012 at 18:58:20 UTC, Adam D. Ruppe wrote:
> I think this is another benefit of capturing the input with a 
> special type and method.

I've implemented the basic events for linux now:

http://arsdnet.net/dcode/terminal.d

Still need to check more of the input sequences, but it correctly 
detects mouse events (when requested) and has set the groundwork 
for the rest. Just a matter of actually making it happen yet.

It uses $TERM and sometimes $TERMCAP to check for a requested 
feature before enabling it to keep out trash output.

The loop looks like this right now:

         loop: while(true) {
                 auto event = input.nextEvent();

                 terminal.writef("%s\n", event.type);
                 final switch(event.type) {
                         case InputEvent.Type.CharacterEvent:
                                 auto ev = 
event.get!(InputEvent.Type.CharacterEvent);
                                 terminal.writef("\t%s\n", ev);
                                 if(ev.character == 'Q')
                                         break loop;
                         break;
                         case InputEvent.Type.NonCharacterKeyEvent:
                                 terminal.writef("\t%s\n", 
event.get!(InputEvent.Type.NonCharacterKeyEvent));
                         break;
                         case InputEvent.Type.PasteEvent:
                                 terminal.writef("\t%s\n", 
event.get!(InputEvent.Type.PasteEvent));
                         break;
                         case InputEvent.Type.MouseEvent:
                                 terminal.writef("\t%s\n", 
event.get!(InputEvent.Type.MouseEvent));
                         break;
                 }
          }


More information about the Digitalmars-d mailing list