#ifndef TUI_H
#define TUI_H

#include <stdint.h>

// Colour definitions (can be expanded later)
#define TUI_COLOUR_DEFAULT 0
#define TUI_COLOUR_YELLOW  1
#define TUI_COLOUR_RED     2
#define TUI_COLOUR_MAGENTA 3
#define TUI_COLOUR_WHITE   4
#define TUI_COLOUR_BLACK   5
#define TUI_COLOUR_GRAY    6

// Style for text
typedef struct {
    uint8_t fg_colour;
    uint8_t bg_colour;
    uint8_t bold;
} tui_style_t;

// Window definition
typedef struct {
    int x, y, width, height;
    const char* title;
    tui_style_t title_style;
    tui_style_t border_style;
    tui_style_t bg_style;
} tui_window_t;

// Initialize TUI system
void tui_init(int screen_width, int screen_height);

// Draw a window (with titlebar, borders, and automatic separators)
void tui_draw_window(const tui_window_t* win);

// Draw a scrollable/selectable list inside a window
void tui_draw_list(const tui_window_t* win, const char** items, int item_count, int selected_index, int scroll_offset, tui_style_t style, tui_style_t selected_style);

// Draw a text area inside a window (with automatic wrapping)
void tui_draw_text_area(const tui_window_t* win, const char* text, int scroll_offset, tui_style_t style);

// Draw a status/info bar at the bottom of the window or screen
void tui_draw_status_bar(const tui_window_t* win, const char* text, tui_style_t style);

// Draw text at (x, y) with style (for advanced/manual use)
void tui_draw_text(int x, int y, const char* text, tui_style_t style);

// Clear/redraw the screen
void tui_clear();
void tui_refresh();

// Keyboard input (returns key code)
int tui_read_key();

// Set when Alt is held down (updated by tui_read_key)
extern int tui_alt_pressed;
extern int tui_shift_pressed;

#endif // TUI_H 