/** * HELLO console support. */ module hello.console; import uefi; import hello.hello; import core.stdc.stdarg; import hulk.writef; struct Console { /** * Write a character to the console. * * @param ch Character to write. */ public static void write(ubyte ch) { if (ch == '\n') { write('\r'); } CHAR16[2] s16 = [ch, 0]; st.ConOut.OutputString(st.ConOut, &s16[0]); } /** * Write a formatted string to the console. * * @param s Format string. * @param args Variable arguments structure. */ public static void writef(string s, va_list args) { hulk.writef.writef(s, args, function void(ubyte ch) { Console.write(ch); }); } /** * Write a formatted string to the console. * * @param s Format string. */ public static extern (C) void writef(string s, ...) { va_list args; va_start(args, s); writef(s, args); va_end(args); } /** * Write a formatted string and newline to the console. * * @param s Format string. */ public static extern (C) void writefln(string s, ...) { va_list args; va_start(args, s); writef(s, args); writef("\n", args); va_end(args); } /** * Write a message to press any key and wait for a key to be pressed. */ public static void wait_key() { writefln("Press any key..."); st.ConIn.Reset(st.ConIn, FALSE); EFI_INPUT_KEY key; while (st.ConIn.ReadKeyStroke(st.ConIn, &key) == EFI_NOT_READY) { } } /** * Clear the console. */ public static void clear() { st.ConOut.ClearScreen(st.ConOut); } }