On 2/25/16 4:39 PM, asdf wrote:

         if(line != "" && line != history[0]) {
             string[] x = [line];
             foreach(string i; history[0..99]) x ~= i;
             history = x;
         }

ugh!

history = line ~ history[0 .. $ - 1];

What you may want to consider is making history backwards referenced. That is, history[0] is the oldest line.

Then you could do:
history = history[1 .. $];
history ~= line;

Is there a good way to pick out matching prefixes of a string? Picking
out the first word without disrupting whitespace after the second word
would be nice =)

How do you read chars without waiting for a newline? That would be
needed to respond to the ANSI esapes for arrow keys...

If you are only getting characters after a newline, then you aren't interacting directly with the terminal (which requires some terminal access library). The terminal is letting the user edit the line, then when he hits return, it sends the whole line to your program. You won't get arrow key codes.

-Steve

Reply via email to