Move termcolour to shell
This commit is contained in:
64
src/common/shell/termcolour/termcolour.h
Normal file
64
src/common/shell/termcolour/termcolour.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef TERM_COLOUR_H
|
||||
#define TERM_COLOUR_H
|
||||
|
||||
#include "aliases.h"
|
||||
#include "misc_utils.h"
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef enum {
|
||||
WAPP_TERM_COLOUR_FG_BLACK,
|
||||
WAPP_TERM_COLOUR_FG_RED,
|
||||
WAPP_TERM_COLOUR_FG_GREEN,
|
||||
WAPP_TERM_COLOUR_FG_BLUE,
|
||||
WAPP_TERM_COLOUR_FG_CYAN,
|
||||
WAPP_TERM_COLOUR_FG_MAGENTA,
|
||||
WAPP_TERM_COLOUR_FG_YELLOW,
|
||||
WAPP_TERM_COLOUR_FG_WHITE,
|
||||
WAPP_TERM_COLOUR_FG_BR_BLACK,
|
||||
WAPP_TERM_COLOUR_FG_BR_RED,
|
||||
WAPP_TERM_COLOUR_FG_BR_GREEN,
|
||||
WAPP_TERM_COLOUR_FG_BR_BLUE,
|
||||
WAPP_TERM_COLOUR_FG_BR_CYAN,
|
||||
WAPP_TERM_COLOUR_FG_BR_MAGENTA,
|
||||
WAPP_TERM_COLOUR_FG_BR_YELLOW,
|
||||
WAPP_TERM_COLOUR_FG_BR_WHITE,
|
||||
|
||||
COUNT_TERM_COLOUR,
|
||||
} TerminalColour;
|
||||
|
||||
typedef struct terminal_colourist TerminalColourist;
|
||||
|
||||
// clang-format off
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <WinCon.h>
|
||||
|
||||
struct terminal_colourist {
|
||||
HANDLE handle;
|
||||
WORD default_colour;
|
||||
WORD current_colour;
|
||||
wapp_misc_utils_padding_size(sizeof(HANDLE) + sizeof(WORD) + sizeof(WORD));
|
||||
};
|
||||
#else
|
||||
struct terminal_colourist {
|
||||
const char *default_colour;
|
||||
const char *current_colour;
|
||||
};
|
||||
#endif // WAPP_PLATFORM_WINDOWS
|
||||
// clang-format on
|
||||
|
||||
TerminalColourist wapp_shell_termcolour_get_colourist(void);
|
||||
void wapp_shell_termcolour_print_text(TerminalColourist *colourist,
|
||||
const char *text, TerminalColour colour);
|
||||
void wapp_shell_termcolour_clear_colour(TerminalColourist *colourist);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !TERM_COLOUR_H
|
Reference in New Issue
Block a user