diff --git a/src/main.cc b/src/main.cc index 9c2f8d32..81cabb17 100644 --- a/src/main.cc +++ b/src/main.cc @@ -925,7 +925,7 @@ void create_local_client(const String& init_command) void signal_handler(int signal) { - endwin(); + NCursesUI::abort(); const char* text = nullptr; switch (signal) { diff --git a/src/ncurses.cc b/src/ncurses.cc index e10ebd8d..a719b44d 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -7,6 +7,7 @@ #include +#include #include #include #include @@ -15,6 +16,8 @@ namespace Kakoune { +struct NCursesWin : WINDOW {}; + static void set_attribute(int attribute, bool on) { if (on) @@ -374,8 +377,8 @@ void NCursesUI::menu_show(const memoryview& choices, m_selected_choice = 0; m_menu_top_line = 0; - m_menu_win = newwin((int)size.line, (int)size.column, - (int)pos.line, (int)pos.column); + m_menu_win = (NCursesWin*)newwin((int)size.line, (int)size.column, + (int)pos.line, (int)pos.column); draw_menu(); } @@ -477,8 +480,8 @@ void NCursesUI::info_show(const String& content, DisplayCoord anchor, DisplayCoord pos = compute_pos(anchor, size, m_menu_win); - m_info_win = newwin((int)size.line, (int)size.column, - (int)pos.line, (int)pos.column); + m_info_win = (NCursesWin*)newwin((int)size.line, (int)size.column, + (int)pos.line, (int)pos.column); wbkgd(m_info_win, COLOR_PAIR(get_color_pair(colors))); wmove(m_info_win, 0, 0); @@ -507,4 +510,9 @@ void NCursesUI::set_input_callback(InputCallback callback) m_input_callback = std::move(callback); } +void NCursesUI::abort() +{ + endwin(); +} + } diff --git a/src/ncurses.hh b/src/ncurses.hh index f1297e6e..497bbb5e 100644 --- a/src/ncurses.hh +++ b/src/ncurses.hh @@ -5,11 +5,11 @@ #include "event_manager.hh" #include "user_interface.hh" -#include - namespace Kakoune { +struct NCursesWin; + class NCursesUI : public UserInterface { public: @@ -39,6 +39,8 @@ public: void set_input_callback(InputCallback callback) override; DisplayCoord dimensions() override; + + static void abort(); private: friend void on_term_resize(int); void redraw(); @@ -49,7 +51,7 @@ private: DisplayLine m_status_line; - WINDOW* m_menu_win = nullptr; + NCursesWin* m_menu_win = nullptr; std::vector m_choices; ColorPair m_menu_fg; ColorPair m_menu_bg; @@ -58,7 +60,7 @@ private: LineCount m_menu_top_line = 0; void draw_menu(); - WINDOW* m_info_win = nullptr; + NCursesWin* m_info_win = nullptr; FDWatcher m_stdin_watcher; InputCallback m_input_callback;