From 63397499d450a4568f4ab4090a8683f665825eb6 Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Thu, 4 Apr 2024 13:41:01 -0400 Subject: [PATCH] fatal if tb_init fails --- editor.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/editor.c b/editor.c index 405a5f1..607faa3 100644 --- a/editor.c +++ b/editor.c @@ -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; @@ -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; }