hide ncurses.h include in ncurses.cc

This commit is contained in:
Maxime Coste 2013-04-12 01:28:22 +02:00
parent e68f3cfe35
commit e4d87ee1f1
3 changed files with 19 additions and 9 deletions

View File

@ -925,7 +925,7 @@ void create_local_client(const String& init_command)
void signal_handler(int signal) void signal_handler(int signal)
{ {
endwin(); NCursesUI::abort();
const char* text = nullptr; const char* text = nullptr;
switch (signal) switch (signal)
{ {

View File

@ -7,6 +7,7 @@
#include <map> #include <map>
#include <ncurses.h>
#include <signal.h> #include <signal.h>
#include <termios.h> #include <termios.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -15,6 +16,8 @@
namespace Kakoune namespace Kakoune
{ {
struct NCursesWin : WINDOW {};
static void set_attribute(int attribute, bool on) static void set_attribute(int attribute, bool on)
{ {
if (on) if (on)
@ -374,8 +377,8 @@ void NCursesUI::menu_show(const memoryview<String>& choices,
m_selected_choice = 0; m_selected_choice = 0;
m_menu_top_line = 0; m_menu_top_line = 0;
m_menu_win = newwin((int)size.line, (int)size.column, m_menu_win = (NCursesWin*)newwin((int)size.line, (int)size.column,
(int)pos.line, (int)pos.column); (int)pos.line, (int)pos.column);
draw_menu(); draw_menu();
} }
@ -477,8 +480,8 @@ void NCursesUI::info_show(const String& content, DisplayCoord anchor,
DisplayCoord pos = compute_pos(anchor, size, m_menu_win); DisplayCoord pos = compute_pos(anchor, size, m_menu_win);
m_info_win = newwin((int)size.line, (int)size.column, m_info_win = (NCursesWin*)newwin((int)size.line, (int)size.column,
(int)pos.line, (int)pos.column); (int)pos.line, (int)pos.column);
wbkgd(m_info_win, COLOR_PAIR(get_color_pair(colors))); wbkgd(m_info_win, COLOR_PAIR(get_color_pair(colors)));
wmove(m_info_win, 0, 0); wmove(m_info_win, 0, 0);
@ -507,4 +510,9 @@ void NCursesUI::set_input_callback(InputCallback callback)
m_input_callback = std::move(callback); m_input_callback = std::move(callback);
} }
void NCursesUI::abort()
{
endwin();
}
} }

View File

@ -5,11 +5,11 @@
#include "event_manager.hh" #include "event_manager.hh"
#include "user_interface.hh" #include "user_interface.hh"
#include <ncurses.h>
namespace Kakoune namespace Kakoune
{ {
struct NCursesWin;
class NCursesUI : public UserInterface class NCursesUI : public UserInterface
{ {
public: public:
@ -39,6 +39,8 @@ public:
void set_input_callback(InputCallback callback) override; void set_input_callback(InputCallback callback) override;
DisplayCoord dimensions() override; DisplayCoord dimensions() override;
static void abort();
private: private:
friend void on_term_resize(int); friend void on_term_resize(int);
void redraw(); void redraw();
@ -49,7 +51,7 @@ private:
DisplayLine m_status_line; DisplayLine m_status_line;
WINDOW* m_menu_win = nullptr; NCursesWin* m_menu_win = nullptr;
std::vector<String> m_choices; std::vector<String> m_choices;
ColorPair m_menu_fg; ColorPair m_menu_fg;
ColorPair m_menu_bg; ColorPair m_menu_bg;
@ -58,7 +60,7 @@ private:
LineCount m_menu_top_line = 0; LineCount m_menu_top_line = 0;
void draw_menu(); void draw_menu();
WINDOW* m_info_win = nullptr; NCursesWin* m_info_win = nullptr;
FDWatcher m_stdin_watcher; FDWatcher m_stdin_watcher;
InputCallback m_input_callback; InputCallback m_input_callback;