C · 3831 bytes Raw Blame History
1 /* Display and user interface functions */
2
3 #ifndef DISPLAY_H
4 #define DISPLAY_H
5
6 #include <stdbool.h>
7 #include "gitswitch.h"
8
9 /* Forward declarations - only declare what we need for Phase 2 */
10
11 /* Color codes */
12 #define COLOR_RESET "\033[0m"
13 #define COLOR_RED "\033[31m"
14 #define COLOR_GREEN "\033[32m"
15 #define COLOR_YELLOW "\033[33m"
16 #define COLOR_BLUE "\033[34m"
17 #define COLOR_MAGENTA "\033[35m"
18 #define COLOR_CYAN "\033[36m"
19 #define COLOR_WHITE "\033[37m"
20 #define COLOR_BOLD "\033[1m"
21 #define COLOR_DIM "\033[2m"
22
23 /* Status indicators */
24 #define STATUS_SUCCESS "[OK]"
25 #define STATUS_ERROR "[ERROR]"
26 #define STATUS_WARNING "[WARN]"
27 #define STATUS_INFO "[INFO]"
28
29 /* Function prototypes */
30
31 /**
32 * Initialize display system
33 * - Detect terminal capabilities
34 * - Set up color output based on TTY and preferences
35 */
36 int display_init(bool force_color, bool no_color);
37
38 /**
39 * Print formatted header with decorative border
40 */
41 void display_header(const char *title);
42
43 /**
44 * Print status message with appropriate color and icon
45 */
46 void display_status(const char *level, const char *message, ...);
47
48 /**
49 * Print account information in formatted table
50 */
51 void display_account(const account_t *account, bool is_current);
52
53 /**
54 * Print accounts list in formatted table
55 */
56 void display_accounts_list(const gitswitch_ctx_t *ctx);
57
58 /* These functions will be implemented in later phases
59 void display_current_status(const git_current_config_t *config);
60 void display_ssh_status(const ssh_config_t *ssh_config);
61 void display_gpg_status(const gpg_config_t *gpg_config);
62 void display_validation_results(const account_validation_t *validation);
63 */
64
65 /**
66 * Print health check results
67 */
68 void display_health_check(const gitswitch_ctx_t *ctx);
69
70 /**
71 * Display interactive account selection menu
72 * Returns selected account ID or 0 if cancelled
73 */
74 uint32_t display_account_menu(const gitswitch_ctx_t *ctx);
75
76 /**
77 * Prompt user for account information during add/edit
78 */
79 int display_prompt_account_info(account_t *account, bool is_edit);
80
81 /**
82 * Confirm dangerous operations (account removal, etc.)
83 */
84 bool display_confirm(const char *message, ...);
85
86 /**
87 * Display progress indicator for long operations
88 */
89 void display_progress(const char *operation, int percent);
90
91 /**
92 * Clear current line (for progress updates)
93 */
94 void display_clear_line(void);
95
96 /**
97 * Print error message with context
98 */
99 void display_error(const char *context, const char *message, ...);
100
101 /**
102 * Print warning message
103 */
104 void display_warning(const char *message, ...);
105
106 /**
107 * Print success message
108 */
109 void display_success(const char *message, ...);
110
111 /**
112 * Print info message
113 */
114 void display_info(const char *message, ...);
115
116 /**
117 * Format and colorize text based on content type
118 */
119 const char *display_colorize(const char *text, const char *type);
120
121 /**
122 * Check if terminal supports color output
123 */
124 bool display_supports_color(void);
125
126 /**
127 * Get user input with prompt and validation
128 */
129 int display_get_input(const char *prompt, char *buffer, size_t buffer_size,
130 bool (*validator)(const char *));
131
132 /**
133 * Get password/sensitive input (hidden)
134 */
135 int display_get_password(const char *prompt, char *buffer, size_t buffer_size);
136
137 /**
138 * Show help text for command or general usage
139 */
140 void display_help(const char *command);
141
142 /**
143 * Display version and build information
144 */
145 void display_version(void);
146
147 /**
148 * Print configuration file location and status
149 */
150 void display_config_info(const gitswitch_ctx_t *ctx);
151
152 /**
153 * Format table with proper column alignment
154 */
155 void display_table_header(const char **headers, const int *widths, int columns);
156 void display_table_row(const char **values, const int *widths, int columns);
157 void display_table_separator(const int *widths, int columns);
158
159 #endif /* DISPLAY_H */