mirror of
https://github.com/a0rtega/pafish
synced 2024-11-25 07:40:56 +03:00
Bugfix: Restore Command Line Color Scheme
pafish modifies the command-line color scheme but does not restore original color scheme after execution. Not cool. This commit fixes the issue.
This commit is contained in:
parent
9fb472d7da
commit
084eb6726d
@ -6,9 +6,21 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
void init_cmd_colors() {
|
unsigned short init_cmd_colors() {
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
unsigned short original_colors = 0;
|
||||||
HANDLE handler = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE handler = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
// Get original console colors
|
||||||
|
GetConsoleScreenBufferInfo(handler, &csbi);
|
||||||
SetConsoleTextAttribute(handler, FOREGROUND_INTENSITY);
|
SetConsoleTextAttribute(handler, FOREGROUND_INTENSITY);
|
||||||
|
// Return original console colors
|
||||||
|
return csbi.wAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void restore_cmd_colors(unsigned short original_colors) {
|
||||||
|
HANDLE handler = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
// Restore original console colors
|
||||||
|
SetConsoleTextAttribute(handler, original_colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_header() {
|
void print_header() {
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
#ifndef COMM_H
|
#ifndef COMM_H
|
||||||
#define COMM_H
|
#define COMM_H
|
||||||
|
|
||||||
void init_cmd_colors();
|
unsigned short init_cmd_colors();
|
||||||
|
|
||||||
|
void restore_cmd_colors(unsigned short);
|
||||||
|
|
||||||
void print_header();
|
void print_header();
|
||||||
|
|
||||||
|
@ -36,10 +36,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
char icon[] = "Blue fish icon thanks to http://www.fasticon.com/", winverstr[32], aux[1024];
|
char icon[] = "Blue fish icon thanks to http://www.fasticon.com/", winverstr[32], aux[1024];
|
||||||
OSVERSIONINFO winver;
|
OSVERSIONINFO winver;
|
||||||
|
unsigned short original_colors = 0;
|
||||||
|
|
||||||
write_log("Start");
|
write_log("Start");
|
||||||
|
|
||||||
init_cmd_colors();
|
original_colors = init_cmd_colors();
|
||||||
print_header();
|
print_header();
|
||||||
|
|
||||||
winver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
winver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
@ -335,6 +336,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
fflush(stdin);
|
fflush(stdin);
|
||||||
getchar();
|
getchar();
|
||||||
|
/* Restore Original Console Colors */
|
||||||
|
restore_cmd_colors(original_colors);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user