#include #include #include #include "main.h" // Global state variables static char current_pads_dir[512] = ""; static int is_interactive_mode = 0; static int pads_dir_initialized = 0; // Terminal dimensions (moved from ui.c to state.c for global access) static int terminal_width = 80; // Default fallback width static int terminal_height = 24; // Default fallback height // Getters and setters for global state const char* get_current_pads_dir(void) { // Initialize pads directory on first access if not already set if (!pads_dir_initialized && strlen(current_pads_dir) == 0) { char* home_dir = getenv("HOME"); if (home_dir) { snprintf(current_pads_dir, sizeof(current_pads_dir), "%s/.otp/pads", home_dir); } else { // Fallback to relative path if HOME is not set strncpy(current_pads_dir, DEFAULT_PADS_DIR, sizeof(current_pads_dir) - 1); } current_pads_dir[sizeof(current_pads_dir) - 1] = '\0'; pads_dir_initialized = 1; } return current_pads_dir; } void set_current_pads_dir(const char* dir) { if (dir) { strncpy(current_pads_dir, dir, sizeof(current_pads_dir) - 1); current_pads_dir[sizeof(current_pads_dir) - 1] = '\0'; pads_dir_initialized = 1; } } int get_interactive_mode(void) { return is_interactive_mode; } void set_interactive_mode(int mode) { is_interactive_mode = mode; } int get_terminal_width(void) { return terminal_width; } int get_terminal_height(void) { return terminal_height; } void set_terminal_dimensions(int width, int height) { terminal_width = width; terminal_height = height; }