window: set timeout to 0 while fetching pieces of terminal sequence
This commit is contained in:
@@ -35,6 +35,21 @@
|
|||||||
|
|
||||||
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;
|
||||||
@@ -678,6 +693,7 @@ int Window::getInputChar()
|
|||||||
# if NCURSES_SEQUENCE_ESCAPING
|
# if NCURSES_SEQUENCE_ESCAPING
|
||||||
return wgetch(m_window);
|
return wgetch(m_window);
|
||||||
# else
|
# else
|
||||||
|
ScopedWindowTimeout swt(m_window, 0, m_window_timeout);
|
||||||
int key = wgetch(m_window);
|
int key = wgetch(m_window);
|
||||||
if (!m_escape_terminal_sequences || key != KEY_ESCAPE)
|
if (!m_escape_terminal_sequences || key != KEY_ESCAPE)
|
||||||
return key;
|
return key;
|
||||||
@@ -858,6 +874,8 @@ int Window::getInputChar()
|
|||||||
return ERR;
|
return ERR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ERR:
|
||||||
|
return KEY_ESCAPE;
|
||||||
default:
|
default:
|
||||||
m_input_queue.push(key);
|
m_input_queue.push(key);
|
||||||
return KEY_ESCAPE;
|
return KEY_ESCAPE;
|
||||||
|
|||||||
Reference in New Issue
Block a user