Convert hello.console to use a namespacing struct
This commit is contained in:
parent
bcec23ef89
commit
f904ec2b48
@ -7,6 +7,8 @@ import uefi;
|
|||||||
import hello.hello;
|
import hello.hello;
|
||||||
import core.stdc.stdarg;
|
import core.stdc.stdarg;
|
||||||
|
|
||||||
|
struct console
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Format a hexadecimal value to a string.
|
* Format a hexadecimal value to a string.
|
||||||
*
|
*
|
||||||
@ -15,7 +17,7 @@ import core.stdc.stdarg;
|
|||||||
* @param ptr If true, always output all 16 digits, and separate the upper and
|
* @param ptr If true, always output all 16 digits, and separate the upper and
|
||||||
* lower halves with an underscore.
|
* lower halves with an underscore.
|
||||||
*/
|
*/
|
||||||
private size_t format_hex(CHAR16 * s, ulong v, bool ptr)
|
private static size_t format_hex(CHAR16 * s, ulong v, bool ptr)
|
||||||
{
|
{
|
||||||
string hex_chars = "0123456789ABCDEF";
|
string hex_chars = "0123456789ABCDEF";
|
||||||
bool print = ptr;
|
bool print = ptr;
|
||||||
@ -45,7 +47,7 @@ private size_t format_hex(CHAR16 * s, ulong v, bool ptr)
|
|||||||
* @param s String buffer.
|
* @param s String buffer.
|
||||||
* @param v Value to format.
|
* @param v Value to format.
|
||||||
*/
|
*/
|
||||||
private size_t format_dec(CHAR16 * s, ulong v)
|
private static size_t format_dec(CHAR16 * s, ulong v)
|
||||||
{
|
{
|
||||||
string dec_chars = "0123456789";
|
string dec_chars = "0123456789";
|
||||||
bool print;
|
bool print;
|
||||||
@ -70,7 +72,7 @@ private size_t format_dec(CHAR16 * s, ulong v)
|
|||||||
* @param s Format string.
|
* @param s Format string.
|
||||||
* @param args Variable arguments structure.
|
* @param args Variable arguments structure.
|
||||||
*/
|
*/
|
||||||
void write(string s, va_list args)
|
public static void write(string s, va_list args)
|
||||||
{
|
{
|
||||||
__gshared static CHAR16[256] s16;
|
__gshared static CHAR16[256] s16;
|
||||||
size_t i = 0u;
|
size_t i = 0u;
|
||||||
@ -134,7 +136,7 @@ void write(string s, va_list args)
|
|||||||
*
|
*
|
||||||
* @param s Format string.
|
* @param s Format string.
|
||||||
*/
|
*/
|
||||||
extern (C) void write(string s, ...)
|
public static extern (C) void write(string s, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, s);
|
va_start(args, s);
|
||||||
@ -147,7 +149,7 @@ extern (C) void write(string s, ...)
|
|||||||
*
|
*
|
||||||
* @param s Format string.
|
* @param s Format string.
|
||||||
*/
|
*/
|
||||||
extern (C) void writeln(string s, ...)
|
public static extern (C) void writeln(string s, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, s);
|
va_start(args, s);
|
||||||
@ -159,7 +161,7 @@ extern (C) void writeln(string s, ...)
|
|||||||
/**
|
/**
|
||||||
* Write a message to press any key and wait for a key to be pressed.
|
* Write a message to press any key and wait for a key to be pressed.
|
||||||
*/
|
*/
|
||||||
void wait_key()
|
public static void wait_key()
|
||||||
{
|
{
|
||||||
writeln("Press any key...");
|
writeln("Press any key...");
|
||||||
st.ConIn.Reset(st.ConIn, FALSE);
|
st.ConIn.Reset(st.ConIn, FALSE);
|
||||||
@ -172,7 +174,8 @@ void wait_key()
|
|||||||
/**
|
/**
|
||||||
* Clear the console.
|
* Clear the console.
|
||||||
*/
|
*/
|
||||||
void clear()
|
public static void clear()
|
||||||
{
|
{
|
||||||
st.ConOut.ClearScreen(st.ConOut);
|
st.ConOut.ClearScreen(st.ConOut);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
module hello.hello;
|
module hello.hello;
|
||||||
|
|
||||||
import uefi;
|
import uefi;
|
||||||
import console = hello.console;
|
import hello.console;
|
||||||
import hello.scratch;
|
import hello.scratch;
|
||||||
import hulk.bootinfo;
|
import hulk.bootinfo;
|
||||||
import hulk.header;
|
import hulk.header;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user