DungeonCrawl
|
Implements functionality for handing ouptputting to the console. More...
#include "output_handler.h"
#include "../../../common.h"
#include "../../../logging/logger.h"
#include "../../input/input_handler.h"
#include "../../input/input_types.h"
#include "../../io_handler.h"
#include <notcurses/nckeys.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Go to the source code of this file.
Functions | |
bool | init_output_handler () |
Initialize the output handler. | |
void | clear_screen (void) |
Clear the screen. | |
void | print_text (int y, int x, const char *text, uint64_t ncchannel) |
Print text at a specific position. | |
void | print_text_default (int y, int x, const char *text) |
Print text at a specific position with default colors. | |
void | print_text_multi_line (int y, int x, const char *text, int max_width, uint64_t ncchannel) |
void | print_text_multi_line_default (int y, int x, const char *text, int max_width) |
Print multi-line text with word wrapping and default colors. | |
void | print_text_multi_strings (int y, int x, const char *text[], int count, uint64_t ncchannel) |
Print multiple strings on consecutive lines. | |
void | print_text_multi_strings_default (int y, int x, const char *text[], int count) |
Print multiple strings on consecutive lines with default colors. | |
void | print_menu (const char *title, const char **options, int option_count, int selected_index, int y, int x, uint64_t title_channel, uint64_t option_channel, uint64_t selected_channel) |
Print a menu with selection highlighting. | |
void | print_menu_default (const char *title, const char **options, int option_count, int selected_index, int y, int x) |
Print a menu with selection highlighting using default colors. | |
bool | get_text_input (const char *prompt, char *buffer, int buffer_size, const char *confirm_msg, int y, int x) |
Get a text input from the user. | |
void | show_message_screen (const char *message, const char *continue_message, int y, int x) |
Show a message screen. | |
bool | render_frame (void) |
Render the current frame. | |
bool | get_screen_dimensions (int *width, int *height) |
Get the dimensions of the standard plane. | |
void | shutdown_output_handler (void) |
Shutdown the output handler. |
Implements functionality for handing ouptputting to the console.
Definition in file output_handler.c.
void clear_screen | ( | void | ) |
Clear the screen.
Clears the entire standard plane.
Definition at line 39 of file output_handler.c.
bool get_screen_dimensions | ( | int * | width, |
int * | height ) |
Get the dimensions of the standard plane.
[out] | width | Pointer to store the width |
[out] | height | Pointer to store the height |
Definition at line 257 of file output_handler.c.
bool get_text_input | ( | const char * | prompt, |
char * | buffer, | ||
int | buffer_size, | ||
const char * | confirm_msg, | ||
int | y, | ||
int | x ) |
Get a text input from the user.
Displays a prompt and gets a text input from the user.
prompt | The text prompt to display |
buffer | The buffer to store the input in |
buffer_size | The size of the buffer |
confirm_msg | The text explaining that Enter confirms (can be NULL) |
y | The Y coordinate (row) for the prompt |
x | The X coordinate (column) for the prompt |
Definition at line 156 of file output_handler.c.
bool init_output_handler | ( | void | ) |
Initialize the output handler.
Sets up the output handling system. This function must be called before any other output functions.
Definition at line 26 of file output_handler.c.
void print_menu | ( | const char * | title, |
const char ** | options, | ||
int | option_count, | ||
int | selected_index, | ||
int | y, | ||
int | x, | ||
uint64_t | title_channel, | ||
uint64_t | option_channel, | ||
uint64_t | selected_channel ) |
Print a menu with selection highlighting.
Renders a menu with the specified options, highlighting the selected option.
title | The menu title |
options | Array of option strings |
option_count | Number of options |
selected_index | Index of the selected option |
y | The Y coordinate (row) for the menu start |
x | The X coordinate (column) for the menu start |
title_channel | The color channel for the title |
option_channel | The color channel for the options |
selected_channel | The color channel for the selected option |
Definition at line 124 of file output_handler.c.
void print_menu_default | ( | const char * | title, |
const char ** | options, | ||
int | option_count, | ||
int | selected_index, | ||
int | y, | ||
int | x ) |
Print a menu with selection highlighting using default colors.
Renders a menu with the specified options, highlighting the selected option. Uses default colors for normal options and inverted colors for the selected option.
title | The menu title |
options | Array of option strings |
option_count | Number of options |
selected_index | Index of the selected option |
y | The Y coordinate (row) for the menu start |
x | The X coordinate (column) for the menu start |
Definition at line 150 of file output_handler.c.
void print_text | ( | int | y, |
int | x, | ||
const char * | text, | ||
uint64_t | ncchannel ) |
Print text at a specific position.
Renders text at the specified coordinates with the given foreground and background colors.
y | The Y coordinate (row) |
x | The X coordinate (column) |
text | The text to render |
ncchannel | The color channel (foreground and background) |
Definition at line 50 of file output_handler.c.
void print_text_default | ( | int | y, |
int | x, | ||
const char * | text ) |
Print text at a specific position with default colors.
Renders text at the specified coordinates with the default colors.
y | The Y coordinate (row) |
x | The X coordinate (column) |
text | The text to render |
Definition at line 61 of file output_handler.c.
void print_text_multi_line | ( | int | y, |
int | x, | ||
const char * | text, | ||
int | max_width, | ||
uint64_t | ncchannel ) |
Definition at line 65 of file output_handler.c.
void print_text_multi_line_default | ( | int | y, |
int | x, | ||
const char * | text, | ||
int | max_width ) |
Print multi-line text with word wrapping and default colors.
Renders text with word wrapping at the specified coordinates using default colors.
y | The Y coordinate (row) |
x | The X coordinate (column) |
text | The text to render |
max_width | The maximum width for line wrapping |
Definition at line 99 of file output_handler.c.
void print_text_multi_strings | ( | int | y, |
int | x, | ||
const char * | text[], | ||
int | count, | ||
uint64_t | ncchannel ) |
Print multiple strings on consecutive lines.
Renders an array of strings starting at the specified coordinates.
y | The Y coordinate (row) for the first string |
x | The X coordinate (column) |
text | Array of strings to render |
count | Number of strings in the array |
ncchannel | The color channel (foreground and background) |
Definition at line 103 of file output_handler.c.
void print_text_multi_strings_default | ( | int | y, |
int | x, | ||
const char * | text[], | ||
int | count ) |
Print multiple strings on consecutive lines with default colors.
Renders an array of strings starting at the specified coordinates using default colors.
y | The Y coordinate (row) for the first string |
x | The X coordinate (column) |
text | Array of strings to render |
count | Number of strings in the array |
Definition at line 120 of file output_handler.c.
bool render_frame | ( | void | ) |
Render the current frame.
Renders all changes to the screen.
Definition at line 246 of file output_handler.c.
void show_message_screen | ( | const char * | message, |
const char * | continue_message, | ||
int | y, | ||
int | x ) |
Show a message screen.
Displays a message on the screen and waits for user input.
message | The message to display |
continue_message | Optional message explaining how to continue (can be NULL) |
y | The Y coordinate (row) for the message |
x | The X coordinate (column) for the message |
Definition at line 221 of file output_handler.c.
void shutdown_output_handler | ( | void | ) |
Shutdown the output handler.
Cleans up resources.
Definition at line 270 of file output_handler.c.