mirror of https://github.com/adamdruppe/arsd.git
rewrite getch in terms of the event system
This commit is contained in:
parent
b62ea55479
commit
a43aba4e58
15
terminal.d
15
terminal.d
|
@ -1264,11 +1264,16 @@ struct RealTimeConsoleInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get one character from the terminal
|
/// Get one character from the terminal, discarding other
|
||||||
char getch() {
|
/// events in the process.
|
||||||
terminal.flush();
|
dchar getch() {
|
||||||
import core.stdc.stdio;
|
auto event = nextEvent();
|
||||||
return cast(char) fgetc(stdin);
|
while(event.type != InputEvent.Type.CharacterEvent) {
|
||||||
|
if(event.type == InputEvent.Type.UserInterruptionEvent)
|
||||||
|
throw new Exception("Ctrl+c");
|
||||||
|
event = nextEvent();
|
||||||
|
}
|
||||||
|
return event.characterEvent.character;
|
||||||
}
|
}
|
||||||
|
|
||||||
//char[128] inputBuffer;
|
//char[128] inputBuffer;
|
||||||
|
|
Loading…
Reference in New Issue