Reduce the size of the AVRDriver code.

Colorize the changed parameter.
Warning reduction across all files.
This commit is contained in:
2026-02-07 14:38:35 -06:00
parent 49edca0238
commit adad03c7df
10 changed files with 583 additions and 1429 deletions

View File

@@ -1,4 +1,30 @@
// Something for later
//
// #include <windows.h>
// #include <stdio.h>
//
// void enable_ansi_escape_sequences(void) {
// HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
// DWORD mode = 0;
//
// if (!GetConsoleMode(hOut, &mode)) {
// return; // handle error if needed
// }
//
// mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
//
// SetConsoleMode(hOut, mode);
// }
//
// int main() {
// enable_ansi_escape_sequences();
//
// printf("\x1b[32mGreen text\x1b[0m\n");
// printf("\x1b[31mRed text\x1b[0m\n");
//
// return 0;
// }
#include "stdafx.h"
#include <Windows.h>
@@ -17,6 +43,14 @@ 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_SetColor(WORD color) {
SetConsoleTextAttribute(hStdout, color);
}
void Console_RestoreColor() {
SetConsoleTextAttribute(hStdout, wOldColorAttrs);
}
void Console_Init(short Left, short Top, short Width, short Height, short bottomScrollHeight) {
hStdin = GetStdHandle(STD_INPUT_HANDLE);
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -24,6 +58,8 @@ void Console_Init(short Left, short Top, short Width, short Height, short bottom
fprintf(stderr, "Error: Unable to get console buffer info. Code: %lu\n", GetLastError());
exit(1);
}
wOldColorAttrs = csbi.wAttributes;
consoleWidth = Width;
consoleHeight = Height;
@@ -31,7 +67,7 @@ void Console_Init(short Left, short Top, short Width, short Height, short bottom
scrollTop = consoleHeight - bottomScrollHeight - 1;
// Desired size (width x height)
COORD newSize;
COORD newSize = { 0, 0 };
newSize.X = consoleWidth; // columns
newSize.Y = consoleHeight; // rows
@@ -42,7 +78,7 @@ void Console_Init(short Left, short Top, short Width, short Height, short bottom
}
// Step 3: Set final window size to match buffer
SMALL_RECT newWindow;
SMALL_RECT newWindow = { 0 };
newWindow.Left = 0;
newWindow.Top = 0;
newWindow.Right = newSize.X - 1;
@@ -56,8 +92,6 @@ void Console_Init(short Left, short Top, short Width, short Height, short bottom
Console_SetWindowPosition(Left, Top);
wOldColorAttrs = csbi.wAttributes;
//SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
}
void Console_Close() {