This repository has been archived on 2026-05-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

155 lines
6.5 KiB
C

#ifndef __TUI_H__
#define __TUI_H__
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "main.h"
#include "users.h"
#define STANDARD_WIN_COLOUR 1
#define HIGHLIGHT_COLOUR 2
#define CONTRAST_WIN_COLOUR 6
#define ERROR_WIN_COLOUR 7
#define WARNING_WIN_COLOUR 8
#define SUCCESS_WIN_COLOUR 9
/**
* @brief Initializes a window with specified parameters and displays a header.
*
* @param _win Pointer to the WINDOW object to initialize.
* @param window_x The width of the window.
* @param terminal_x The x-coordinate position of the window in the terminal.
* @param terminal_y The y-coordinate position of the window in the terminal.
* @param window_colourpair The color pair attribute to use for the window.
* @param header The header text to display at the top of the window.
*/
void initWindow(WINDOW *_win, int window_x, int terminal_x, int terminal_y, int window_colourpair, char *header);
/**
* @brief Displays a dialog window with a message in the terminal.
*
* @param _type Type of dialog: 1 for success, 2 for warning, 3 for failure.
* @param _message The message to display in the dialog window.
* @param terminal_x The x-coordinate of the terminal where the dialog should appear.
* @param terminal_y The y-coordinate of the terminal where the dialog should appear.
*/
void dialogWindow(BYTE _type, char *_message, int terminal_x, int terminal_y);
/**
* @brief Opens a UART dialog interface at the specified terminal coordinates.
*
* This function initializes and displays a UART dialog using the provided UART address,
* and positions the dialog at the specified (terminal_x, terminal_y) coordinates on the terminal.
*
* @param uart_adress Pointer to a string containing the UART address.
* @param terminal_x X-coordinate for the dialog position in the terminal.
* @param terminal_y Y-coordinate for the dialog position in the terminal.
*/
void uartDialog(char *uart_adress, int terminal_x, int terminal_y);
/**
* @brief Displays and manages the main menu of the application.
*
* This function presents the main menu interface to the user, allowing interaction
* with the list of persons and database file. It handles user input and updates
* the application state accordingly.
*
* @param person_list Pointer to the list of persons to be managed.
* @param db_filename Path to the database file used for storing person data.
* @param terminal_x Width of the terminal window.
* @param terminal_y Height of the terminal window.
*/
void mainMenu(list_t *person_list, char *db_filename, int terminal_x, int terminal_y);
/**
* @brief Displays a list of persons in a terminal user interface.
*
* This function renders the provided list of persons within the terminal window,
* using the specified terminal dimensions.
*
* @param person_list Pointer to a list_t structure containing person entries to display.
* @param terminal_x The width of the terminal window in characters.
* @param terminal_y The height of the terminal window in characters.
*/
void personListing(list_t *person_list, int terminal_x, int terminal_y);
/**
* @brief Searches for a person in the given list and displays results in a terminal UI.
*
* This function allows the user to search for a person within the provided person_list.
* The search interface is rendered within a terminal window of the specified dimensions.
*
* @param person_list Pointer to the list of persons to search.
* @param terminal_x Width of the terminal window.
* @param terminal_y Height of the terminal window.
*/
void personSearch(list_t *person_list, int terminal_x, int terminal_y);
/**
* @brief Displays information about a person in a terminal user interface.
*
* This function presents the details of a person, represented by the node_t pointer,
* within a list structure, at the specified terminal coordinates.
*
* @param _list Pointer to the list containing person nodes.
* @param _person Pointer to the specific person node whose information will be displayed.
* @param terminal_x X-coordinate in the terminal where the information should be shown.
* @param terminal_y Y-coordinate in the terminal where the information should be shown.
*/
void personInfo(list_t *_list, node_t *_person, int terminal_x, int terminal_y);
/**
* @brief Displays an export dialog in the terminal user interface.
*
* This function presents an export dialog to the user, allowing them to select
* items from the provided list for export. The dialog is rendered at the specified
* terminal coordinates.
*
* @param _list Pointer to a list_t structure containing items to display.
* @param terminal_x The x-coordinate (column) for the dialog's position in the terminal.
* @param terminal_y The y-coordinate (row) for the dialog's position in the terminal.
* @return An integer status code indicating the result of the dialog operation.
*/
int exportDialog(list_t *_list, int terminal_x, int terminal_y);
/**
* @brief Displays and manages the Edit Database menu in the terminal UI.
*
* This function presents the user with options to edit entries in the provided person list,
* handling user input and updating the list as necessary. The menu is rendered according to
* the specified terminal dimensions.
*
* @param _person_list Pointer to the list of persons to be edited.
* @param terminal_x Width of the terminal window.
* @param terminal_y Height of the terminal window.
*/
void editDatabaseMenu(list_t *_person_list, int terminal_x, int terminal_y);
/**
* @brief Displays a dialog to add a new person to the provided list.
*
* This function opens a terminal-based dialog interface that allows the user
* to input information for a new person. The new person is then added to the
* specified person list.
*
* @param _person_list Pointer to the list where the new person will be added.
* @param terminal_x The width of the terminal window (in characters).
* @param terminal_y The height of the terminal window (in characters).
*/
void addPersonDialog(list_t *_person_list, int terminal_x, int terminal_y);
/**
* @brief Displays a dialog to delete a person from the given list.
*
* This function presents a user interface dialog at the specified terminal coordinates,
* allowing the user to select and delete a person from the provided list.
*
* @param _person_list Pointer to the list of persons to be managed.
* @param terminal_x X-coordinate for the dialog's position in the terminal.
* @param terminal_y Y-coordinate for the dialog's position in the terminal.
*/
void deletePersonDialog(list_t *_person_list, int terminal_x, int terminal_y);
#endif