On Thursday, 10 October 2013 at 19:19:53 UTC, Ali Çehreli wrote:
import std.c.linux.termios;

worth noting that this is Linux only. doing it on Windows is a little different.

Working with console/terminal input and output can get surprisingly complex, and doing it cross-platform is easiest with a library.

Robik's consoleD is one:
https://github.com/robik/ConsoleD/blob/master/consoled.d

it focuses on enabling color and drawing mainly, and also has functions to turn off the line buffering and getch().

If you use his library, you can do this:

import consoled;

void main() {
        int a = getch(); // gets just one character
        writecln(a); // prints back out what you got
}

and other nice things.

Reply via email to