FrostWing
A lightweight raw-control operating system.
Loading...
Searching...
No Matches
graphics.h
Go to the documentation of this file.
1
11#ifndef __GRAPHICS_H_
12#define __GRAPHICS_H_
13
14#include <stdint.h>
15#include <stddef.h>
16#include <stdarg.h>
17#include <stdbool.h>
18#include <basics.h>
19#include <strings.h>
20#include <stream.h>
21
22// ANSI color codes for text formatting
23#define reset_color "\033[37m"
24#define red_color "\x1b[91m"
25#define yellow_color "\x1b[93m"
26#define blue_color "\x1b[36m"
27#define green_color "\x1b[32m"
28#define orange_color "\x1b[38;5;208m"
29
30// #define reset_color "\x1b[38;5;248m"
31// #define red_color "\x1b[38;5;167m"
32// #define yellow_color "\x1b[38;5;179m"
33// #define blue_color "\x1b[38;5;75m"
34// #define green_color "\x1b[38;5;71m"
35// #define orange_color "\x1b[38;5;172m"
36
37
38extern string last_filename; // for warn, info, err, done
39extern string last_print_file;
40extern string last_print_func;
41extern uint32 last_print_line;
42extern bool enable_logging;
43
44#define printf(fmt, ...) \
45 printf_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
46
47#define printfnoln(fmt, ...) \
48 printfnoln_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
49
50#define eprintf(fmt, ...) \
51 eprintf_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
52
53
62void warn(cstring message, cstring file);
63
72void error(cstring message, cstring file);
73
82void info(cstring message, cstring file);
83
92void done(cstring message, cstring file);
93
94/* Normal Hybrid printing functions ahead */
95
101void putc(char c);
102
108void vputc(char c);
109
115void printbin(uint8_t value);
116
117int format_number(
118 char *out,
119 long value,
120 int base,
121 int width,
122 bool zero,
123 bool upper
124);
125
135void printf_internal(cstring file, cstring func, uint64 line, cstring format, ...);
136
146void printfnoln_internal(cstring file, cstring func, uint64 line, cstring format, ...);
147void eprintf_internal(cstring file, cstring func, uint64 line, cstring format, ...);
148
167void vprintf_internal(stream_t stream, cstring file, cstring func, uint64 line, bool newline, cstring format, va_list argp);
168
169/*
170 * @brief Formats a string into a buffer using a va_list.
171 *
172 * @param buf destination buffer.
173 * @param size buffer size in bytes.
174 * @param fmt format string.
175 * @param args variable argument list.
176 * @return number of characters written (excluding null terminator).
177 */
178int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
179
188int snprintf(char *buf, size_t size, const char *fmt, ...);
189
195void kprint(cstring msg);
196
202void print(cstring s);
203
214void print_bitmap(int x, int y, int w, int h, const bool* pixels, uint32 color);
215
216#endif
This is a basic header files with FrostWing specific short forms and basically a good for life header...
void print_bitmap(int x, int y, int w, int h, const bool *pixels, uint32 color)
void error(cstring message, cstring file)
Display an error message.
void vprintf_internal(stream_t stream, cstring file, cstring func, uint64 line, bool newline, cstring format, va_list argp)
Core printf implementation used internally by both printf_internal and printfnoln_internal.
void kprint(cstring msg)
RAW kernel print function for plain strings. (No Formatter & No Streams).
void print(cstring s)
Plain print function, goes through the stream.
void printfnoln_internal(cstring file, cstring func, uint64 line, cstring format,...)
Prints with formatting supported (does not add an new line).
void printbin(uint8_t value)
Prints a value in binary format.
void printf_internal(cstring file, cstring func, uint64 line, cstring format,...)
Prints with formatting supported.
void putc(char c)
Prints a char, using vput(char c); Replaces '' with "\b \b".
void done(cstring message, cstring file)
Display a success message.
void warn(cstring message, cstring file)
Display a warning message.
void vputc(char c)
Prints a char though the standard streams.
int snprintf(char *buf, size_t size, const char *fmt,...)
Formats a string into a fixed-size buffer.
void info(cstring message, cstring file)
Display an informational message.
Unix like standard streams.
The header file for strings.c.