fix: initialize Carla host in main.c and add terminal error checks

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-02 22:23:41 +00:00
parent 02f741a01d
commit 426e36087b
2 changed files with 26 additions and 14 deletions

35
tui.c
View File

@@ -815,23 +815,34 @@ void tui_init(Engine *engine) {
g_dispatch = engine->dispatch;
initscr();
if (!has_colors()) {
endwin();
fprintf(stderr, "Terminal does not support colors\n");
exit(1);
}
cbreak();
noecho();
keypad(stdscr, TRUE);
curs_set(0);
// Check terminal size
if (LINES < 20 || COLS < 40) {
endwin();
fprintf(stderr, "Terminal too small (need at least 20x40)\n");
exit(1);
}
mousemask(BUTTON1_CLICKED | BUTTON3_CLICKED | BUTTON2_CLICKED | BUTTON1_DOUBLE_CLICKED, NULL);
mouseinterval(10);
if (has_colors()) {
start_color();
init_pair(COLOR_EMPTY, COLOR_WHITE, COLOR_BLACK);
init_pair(COLOR_RECORDING, COLOR_RED, COLOR_BLACK);
init_pair(COLOR_LOOPING, COLOR_GREEN, COLOR_BLACK);
init_pair(COLOR_STOPPED, COLOR_BLUE, COLOR_BLACK);
init_pair(COLOR_SELECTED, COLOR_BLACK, COLOR_CYAN);
init_pair(COLOR_HELP, COLOR_CYAN, COLOR_BLACK);
}
start_color();
init_pair(COLOR_EMPTY, COLOR_WHITE, COLOR_BLACK);
init_pair(COLOR_RECORDING, COLOR_RED, COLOR_BLACK);
init_pair(COLOR_LOOPING, COLOR_GREEN, COLOR_BLACK);
init_pair(COLOR_STOPPED, COLOR_BLUE, COLOR_BLACK);
init_pair(COLOR_SELECTED, COLOR_BLACK, COLOR_CYAN);
init_pair(COLOR_HELP, COLOR_CYAN, COLOR_BLACK);
}
void tui_run(Engine *engine) {
@@ -844,11 +855,7 @@ void tui_run(Engine *engine) {
marks[i] = -1;
}
// Initialize Carla
AppState init_state = dispatcher_get_state();
carla_init(&init_state.carla_host, engine->client);
carla_scan_plugins(&init_state.carla_host);
// Carla is now initialized in main.c before dispatcher starts
draw_grid();
while (1) {