void push(wchar_t ch) { auto state = _esc.putch(ch); if (state == State::Ground) { _buffer.push_back(ch); } else { if (state == State::Escape) output_buffer(); // flush first _buffer.push_back(ch); if (state == State::Dispatch) handle_esc(); } }
/** * Get next byte from stdin, with special byte interpreted. * @return next byte from stdin */ int igetch(void) { static bool cr = 0; int ch; while (1) { ch = get_raw_ch(); switch (ch) { case IAC: handle_iac(); continue; case KEY_ESC: ch = handle_esc(); break; case Ctrl('L'): screen_redraw(); continue; case '\r': ch = '\n'; cr = true; break; case '\n': if (cr) { cr = false; continue; } break; case '\0': cr = false; continue; default: cr = false; break; } break; } return ch; }