Skip to content

Commit

Permalink
fatal if tb_init fails
Browse files Browse the repository at this point in the history
  • Loading branch information
adsr committed Apr 4, 2024
1 parent d7a6476 commit 6339749
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ int editor_init(editor_t *editor, int argc, char **argv) {
_editor_init_startup_macro(editor);

// Init terminal
_editor_init_term(editor);
rv = _editor_init_term(editor);
if (rv != MLE_OK) break;
} while(0);

editor->is_in_init = 0;
Expand Down Expand Up @@ -2652,10 +2653,15 @@ static int _editor_init_startup_macro(editor_t *editor) {

// Init terminal via termbox
static int _editor_init_term(editor_t *editor) {
int rv;
if (editor->headless_mode) {
return MLE_OK;
}
tb_init();
if ((rv = tb_init()) != TB_OK) {
MLE_LOG_ERR("Failed to init terminal: %s\n", tb_strerror(rv));
editor->exit_code = EXIT_FAILURE;
return MLE_ERR;
}
editor_set_input_mode(editor);
return MLE_OK;
}

0 comments on commit 6339749

Please sign in to comment.