Newer
Older
ddhx / tests / input.d
@dd86k dd86k on 21 Dec 2022 639 bytes Tabs -> 4 spaces
module tests.input;

import std.stdio;
import os.terminal;

@system unittest {
    enum MODS = Mod.ctrl | Mod.alt | Mod.shift;
    terminalInit(TermFeat.inputSys);
    
    // Tests terminalInit if we haven't screwed with stdout
    writeln("Exit by CTRL+C");
    
    TerminalInput input = void;
L_READ:
    terminalInput(input);
    
    writef(
    "TerminalInput: type=%s key=%s",
    cast(InputType)input.type, cast(Key)(cast(short)input.key)
    );
    
    if (input.key & Mod.ctrl) write("+ctrl");
    if (input.key & Mod.alt) write("+alt");
    if (input.key & Mod.shift) write("+shift");
    
    writeln;
    
    goto L_READ;
}