Skip to content
This repository was archived by the owner on Sep 23, 2021. It is now read-only.

Small enhancements #1

@IngwiePhoenix

Description

@IngwiePhoenix

Hey there.

I am now using this library within my application, but wanted to report a small problem that there is.

The enum that contains the colors, should be move dinto the heaer file instead, as it can't be accessed otherwise.

I also have made a minimal piece of code that allows me to reset the console. I kinda picked the code up from stackoverflow and MSDN, but maybe it turns out to be useful.

#ifndef AP_HELPER
#define AP_HELPER

#ifdef WIN32
#include <windows.h>

// Console attributes.
HANDLE hConsole;
WORD saved_attributes;
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;

void initConsole() {
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
    WORD saved_attributes;

    /* Save current attributes */
    GetConsoleScreenBufferInfo(hConsole, &consoleInfo);
    saved_attributes = consoleInfo.wAttributes;
}

void deinitConsole() {
    /* Restore original attributes */
    SetConsoleTextAttribute(hConsole, saved_attributes);
}

#else
#include <stdio.h>

// Nothing to do here
void initConsole() {}

void deinitConsole() {
    printf("\e[0m");
}
#endif

#endif

Kind regards, Ingwie.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions