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;
39extern string last_filename; // for warn, info, err, done
40extern string last_print_file;
41extern string last_print_func;
42extern int32 last_print_line;
43extern bool enable_logging;
44
45#define printf(fmt, ...) \
46 printf_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
47
48#define printfnoln(fmt, ...) \
49 printfnoln_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
50
51#define eprintf(fmt, ...) \
52 eprintf_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
53
54
63void warn(cstring message, cstring file);
64
73void error(cstring message, cstring file);
74
83void info(cstring message, cstring file);
84
93void done(cstring message, cstring file);
94
95/* Normal Hybrid printing functions ahead */
96
102void putc(char c);
103
109void vputc(char c);
110
116void printbin(uint8_t value);
117
118int format_number(
119 char *out,
120 long value,
121 int base,
122 int width,
123 bool zero,
124 bool upper
125);
126
136void printf_internal(cstring file, cstring func, int64 line, cstring format, ...);
137
147void printfnoln_internal(cstring file, cstring func, int64 line, cstring format, ...);
148
167void vprintf_internal(stream_t stream, cstring file, cstring func, int64 line, bool newline, cstring format, va_list argp);
168
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, bool* pixels, int32 color);
215
216#endif
This is a basic header files with FrostWing specific short forms and basically a good for life header...
void vprintf_internal(stream_t stream, cstring file, cstring func, int64 line, bool newline, cstring format, va_list argp)
Core printf implementation used internally by both printf_internal and printfnoln_internal.
void printf_internal(cstring file, cstring func, int64 line, cstring format,...)
Prints with formatting supported.
void error(cstring message, cstring file)
Display an error message.
void print_bitmap(int x, int y, int w, int h, bool *pixels, int32 color)
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, int64 line, cstring format,...)
Prints with formatting supported (does not add an new line).
void printbin(uint8_t value)
Prints a value in binary format.
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
Formats a string into a buffer using a va_list.
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.