Complete with the OO changes. Also, added more built-in help information.

This commit is contained in:
2026-01-29 16:50:53 -06:00
parent 0d41768fe7
commit 87ece7eb14
6 changed files with 759 additions and 975 deletions

View File

@@ -17,7 +17,7 @@ static short consoleHeight = 0;
static short scrollBot = 0; // set at init: consoleHeight - 1
static short scrollTop = 0; // set at init: consoleHeight - consoleScrollHeight - 1
void Console_Init(short Width, short Height, short bottomScrollHeight) {
void Console_Init(short Left, short Top, short Width, short Height, short bottomScrollHeight) {
hStdin = GetStdHandle(STD_INPUT_HANDLE);
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (!GetConsoleScreenBufferInfo(hStdout, &csbi)) {
@@ -54,6 +54,8 @@ void Console_Init(short Width, short Height, short bottomScrollHeight) {
}
// end
Console_SetWindowPosition(Left, Top);
wOldColorAttrs = csbi.wAttributes;
//SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
}
@@ -96,15 +98,26 @@ void Console_Cls() {
SetConsoleCursorPosition(hStdout, coordScreen);
}
void Console_SetWindowPosition(int x, int y) {
HWND hwnd = GetConsoleWindow();
if (!hwnd) return;
// Move the window to (x,y) in screen coordinates without changing size or z-order
SetWindowPos(hwnd, HWND_TOP, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
}
void Console_Write(const char *text) {
DWORD written;
WriteConsole(hStdout, text, (DWORD)strlen(text), &written, nullptr);
}
void Console_WriteAt(short x, short y, const char *text) {
Console_SetCursor(x, y);
DWORD written;
WriteConsole(hStdout, text, (DWORD)strlen(text), &written, nullptr);
if (hStdout) {
Console_SetCursor(x, y);
WriteConsole(hStdout, text, (DWORD)strlen(text), &written, nullptr);
} else {
printf("%s\n", text);
}
}
void Console_SetCursor(short x, short y) {