how do you append arrays?

asdf via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 26 00:47:55 PST 2016


On Friday, 26 February 2016 at 00:40:40 UTC, Steven Schveighoffer 
wrote:
> ugh!
>
> history = line ~ history[0 .. $ - 1];

That works alot better =)

Trying to uncook the terminal failed however. It can't recognize 
struct tag-declarations I think:


/*
    copy-paste code from:
    http://tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html
*/

import core.sys.linux.termios;

// struct termios oldterm;
// struct termios newterm;
termios.termios oldterm;
termios.termios newterm;

void uncook_term() {
     tcgetattr(stdin.fileno, &oldterm);
     newterm = oldterm;

     newterm.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
     newterm.c_iflag = IGNPAR;
     newterm.c_oflag = 0;
     newterm.c_lflag = 0;
     tcflush(stdin.fileno, TCIFLUSH);
     tcsetattr(stdin.fileno, TCSANOW, &newterm);
}

void restore_term() {
     tcsetattr(stdin.fileno, TCSANOW, &oldterm);
}

void main() {
     uncook_term();

     char ch = read();
     while(ch != 'q' && !stdin.eof) {
         write(ch);
         ch = read();
     }

     restore_term();
}





More information about the Digitalmars-d-learn mailing list