Prevent ncurses input queue from breaking by cleaning KEY_RESIZE asap
This commit is contained in:
@@ -199,6 +199,8 @@ void resizeScreen(bool reload_main_window)
|
|||||||
rl_resize_terminal();
|
rl_resize_terminal();
|
||||||
endwin();
|
endwin();
|
||||||
refresh();
|
refresh();
|
||||||
|
// Remove KEY_RESIZE from input queue, I'm not sure how these make it in.
|
||||||
|
getch();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainHeight = LINES-(Config.design == Design::Alternative ? 7 : 4);
|
MainHeight = LINES-(Config.design == Design::Alternative ? 7 : 4);
|
||||||
|
|||||||
@@ -103,12 +103,8 @@ int main(int argc, char **argv)
|
|||||||
cerr_buffer = std::cerr.rdbuf();
|
cerr_buffer = std::cerr.rdbuf();
|
||||||
std::cerr.rdbuf(errorlog.rdbuf());
|
std::cerr.rdbuf(errorlog.rdbuf());
|
||||||
|
|
||||||
# ifndef WIN32
|
sigignore(SIGPIPE);
|
||||||
signal(SIGPIPE, sighandler);
|
|
||||||
signal(SIGWINCH, sighandler);
|
signal(SIGWINCH, sighandler);
|
||||||
// ignore Ctrl-C
|
|
||||||
sigignore(SIGINT);
|
|
||||||
# endif // !WIN32
|
|
||||||
|
|
||||||
NC::initScreen(Config.colors_enabled, Config.mouse_support);
|
NC::initScreen(Config.colors_enabled, Config.mouse_support);
|
||||||
|
|
||||||
|
|||||||
@@ -33,21 +33,6 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct ScopedWindowTimeout
|
|
||||||
{
|
|
||||||
ScopedWindowTimeout(WINDOW *w, int init_timeout, int term_timeout)
|
|
||||||
: m_w(w), m_term_timeout(term_timeout) {
|
|
||||||
wtimeout(w, init_timeout);
|
|
||||||
}
|
|
||||||
~ScopedWindowTimeout() {
|
|
||||||
wtimeout(m_w, m_term_timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
WINDOW *m_w;
|
|
||||||
int m_term_timeout;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace rl {
|
namespace rl {
|
||||||
|
|
||||||
bool aborted;
|
bool aborted;
|
||||||
@@ -359,6 +344,7 @@ void initScreen(bool enable_colors, bool enable_mouse)
|
|||||||
raw();
|
raw();
|
||||||
nonl();
|
nonl();
|
||||||
noecho();
|
noecho();
|
||||||
|
timeout(0);
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
|
||||||
// setup mouse
|
// setup mouse
|
||||||
@@ -387,6 +373,7 @@ void initScreen(bool enable_colors, bool enable_mouse)
|
|||||||
rl_deprep_term_function = nullptr;
|
rl_deprep_term_function = nullptr;
|
||||||
// do not catch signals
|
// do not catch signals
|
||||||
rl_catch_signals = 0;
|
rl_catch_signals = 0;
|
||||||
|
rl_catch_sigwinch = 0;
|
||||||
// overwrite readline callbacks
|
// overwrite readline callbacks
|
||||||
rl_getc_function = rl::read_key;
|
rl_getc_function = rl::read_key;
|
||||||
rl_redisplay_function = rl::display_string;
|
rl_redisplay_function = rl::display_string;
|
||||||
@@ -586,7 +573,7 @@ void Window::recreate(size_t width, size_t height)
|
|||||||
{
|
{
|
||||||
delwin(m_window);
|
delwin(m_window);
|
||||||
m_window = newpad(height, width);
|
m_window = newpad(height, width);
|
||||||
setTimeout(m_window_timeout);
|
wtimeout(m_window, 0);
|
||||||
setColor(m_color);
|
setColor(m_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,11 +688,7 @@ void Window::altCharset(bool altcharset_state) const
|
|||||||
|
|
||||||
void Window::setTimeout(int timeout)
|
void Window::setTimeout(int timeout)
|
||||||
{
|
{
|
||||||
if (timeout != m_window_timeout)
|
m_window_timeout = timeout;
|
||||||
{
|
|
||||||
m_window_timeout = timeout;
|
|
||||||
wtimeout(m_window, timeout);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::addFDCallback(int fd, void (*callback)())
|
void Window::addFDCallback(int fd, void (*callback)())
|
||||||
@@ -800,7 +783,6 @@ Key::Type Window::getInputChar(int key)
|
|||||||
result = result*10 + x - '0';
|
result = result*10 + x - '0';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ScopedWindowTimeout swt(m_window, 0, m_window_timeout);
|
|
||||||
key = wgetch(m_window);
|
key = wgetch(m_window);
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user