FrostWing
A lightweight raw-control operating system.
Loading...
Searching...
No Matches
graphics.h File Reference

Contains all the print functions. More...

#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
#include <basics.h>
#include <strings.h>
#include <stream.h>
Include dependency graph for graphics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define reset_color   "\033[37m"
#define red_color   "\x1b[91m"
#define yellow_color   "\x1b[93m"
#define blue_color   "\x1b[36m"
#define green_color   "\x1b[32m"
#define orange_color   "\x1b[38;5;208m"
#define printf(fmt, ...)
#define printfnoln(fmt, ...)
#define eprintf(fmt, ...)

Functions

void warn (cstring message, cstring file)
 Display a warning message.
void error (cstring message, cstring file)
 Display an error message.
void info (cstring message, cstring file)
 Display an informational message.
void done (cstring message, cstring file)
 Display a success message.
void putc (char c)
 Prints a char, using vput(char c); Replaces '' with "\b \b".
void vputc (char c)
 Prints a char though the standard streams.
void printbin (uint8_t value)
 Prints a value in binary format.
int format_number (char *out, long value, int base, int width, bool zero, bool upper)
void printf_internal (cstring file, cstring func, int64 line, cstring format,...)
 Prints with formatting supported.
void printfnoln_internal (cstring file, cstring func, int64 line, cstring format,...)
 Prints with formatting supported (does not add an new line).
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.
int vsnprintf (char *buf, size_t size, const char *fmt, va_list args)
 Formats a string into a buffer using a va_list.
int snprintf (char *buf, size_t size, const char *fmt,...)
 Formats a string into a fixed-size buffer.
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 print_bitmap (int x, int y, int w, int h, bool *pixels, int32 color)

Variables

string last_filename
string last_print_file
string last_print_func
int32 last_print_line
bool enable_logging

Detailed Description

Contains all the print functions.

Author
Pradosh (prado.nosp@m.shga.nosp@m.me@gm.nosp@m.ail..nosp@m.com) and (partially) GAMINGNOOB (https://github.com/GAMINGNOOBdev)
Version
0.1
Date
2023-10-21

Definition in file graphics.h.

Macro Definition Documentation

◆ blue_color

#define blue_color   "\x1b[36m"

Definition at line 26 of file graphics.h.

◆ eprintf

#define eprintf ( fmt,
... )
Value:
eprintf_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)

Definition at line 51 of file graphics.h.

◆ green_color

#define green_color   "\x1b[32m"

Definition at line 27 of file graphics.h.

◆ orange_color

#define orange_color   "\x1b[38;5;208m"

Definition at line 28 of file graphics.h.

◆ printf

#define printf ( fmt,
... )
Value:
printf_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
void printf_internal(cstring file, cstring func, int64 line, cstring format,...)
Prints with formatting supported.

Definition at line 45 of file graphics.h.

◆ printfnoln

#define printfnoln ( fmt,
... )
Value:
printfnoln_internal(__FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__)
void printfnoln_internal(cstring file, cstring func, int64 line, cstring format,...)
Prints with formatting supported (does not add an new line).

Definition at line 48 of file graphics.h.

◆ red_color

#define red_color   "\x1b[91m"

Definition at line 24 of file graphics.h.

◆ reset_color

#define reset_color   "\033[37m"

Definition at line 23 of file graphics.h.

◆ yellow_color

#define yellow_color   "\x1b[93m"

Definition at line 25 of file graphics.h.

Function Documentation

◆ done()

void done ( cstring message,
cstring file )

Display a success message.

This function displays a success message on the console with color formatting.

Parameters
messageThe success message to be displayed.
fileThe file name associated with the success.

◆ error()

void error ( cstring message,
cstring file )

Display an error message.

This function displays an error message on the console with color formatting.

Parameters
messageThe error message to be displayed.
fileThe file name where the error occurred.

◆ info()

void info ( cstring message,
cstring file )

Display an informational message.

This function displays an informational message on the console with color formatting.

Parameters
messageThe informational message to be displayed.
fileThe file name where the information is coming from.

◆ kprint()

void kprint ( cstring msg)

RAW kernel print function for plain strings. (No Formatter & No Streams).

Parameters
msgThe string.

◆ print()

void print ( cstring s)

Plain print function, goes through the stream.

Parameters
sNormal string to be displayed

◆ print_bitmap()

void print_bitmap ( int x,
int y,
int w,
int h,
bool * pixels,
int32 color )
Parameters
x
y
w
h
pixels
color

◆ printbin()

void printbin ( uint8_t value)

Prints a value in binary format.

Parameters
valueThe value that will be printed

◆ printf_internal()

void printf_internal ( cstring file,
cstring func,
int64 line,
cstring format,
... )

Prints with formatting supported.

Parameters
fileFilename where the function is called.
funcThe function name.
lineThe line.
formatString.
...

◆ printfnoln_internal()

void printfnoln_internal ( cstring file,
cstring func,
int64 line,
cstring format,
... )

Prints with formatting supported (does not add an new line).

Parameters
fileFilename where the function is called.
funcThe function name.
lineThe line.
formatString.
...

◆ putc()

void putc ( char c)

Prints a char, using vput(char c); Replaces '' with "\b \b".

Parameters
cchar to print

◆ snprintf()

int snprintf ( char * buf,
size_t size,
const char * fmt,
... )

Formats a string into a fixed-size buffer.

Parameters
bufdestination buffer.
sizebuffer size in bytes.
fmtformat string.
Returns
number of characters written (excluding null terminator).

◆ vprintf_internal()

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.

This function handles all formatted output processing, including support for format specifiers such as b, x, X, u, d, s, and c. It also interprets escape characters like '
', '\r', and '\t'.

The newline flag controls whether a newline character ('
') is printed automatically at the end of the output.

Parameters
streamThe unix like STDOUT, STDERR.
fileThe source file name of the caller (for logging context)
funcThe function name of the caller (for logging context)
lineThe source line number of the call (for logging context)
newlineIf true, appends a newline at the end of the formatted output
formatThe printf-style format string
argpThe variable argument list (already started via va_start)

◆ vputc()

void vputc ( char c)

Prints a char though the standard streams.

Parameters
cThe charecter to be printed.

◆ vsnprintf()

int vsnprintf ( char * buf,
size_t size,
const char * fmt,
va_list args )

Formats a string into a buffer using a va_list.

Parameters
bufdestination buffer.
sizebuffer size in bytes.
fmtformat string.
argsvariable argument list.
Returns
number of characters written (excluding null terminator).

◆ warn()

void warn ( cstring message,
cstring file )

Display a warning message.

This function displays a warning message on the console with color formatting.

Parameters
messageThe warning message to be displayed.
fileThe file name where the warning occurred.

Variable Documentation

◆ last_filename

string last_filename
extern

Definition at line 39 of file graphics.h.