diff --git a/README.rst b/README.rst index cdd2159..3122785 100644 --- a/README.rst +++ b/README.rst @@ -22,6 +22,8 @@ KEYBINDINGS COMMAND MODE ------------------- +*While in command mode, output is paused.* + * ``escape``: deactivate command mode * ``v``: visual mode * ``V``: visual line mode @@ -53,6 +55,5 @@ TODO * hint mode overlay for urls (like elinks/vimperator/pentadactyl) * scrollback search needs to be improved upstream [1]_ * expose keybindings in ``termite.cfg`` -* output should be paused while in command mode .. [1] https://bugzilla.gnome.org/show_bug.cgi?id=627886 diff --git a/termite.c b/termite.c index 2eb9538..ecfc764 100644 --- a/termite.c +++ b/termite.c @@ -3,6 +3,9 @@ #include #include +#include +#include + #include #include #include @@ -36,6 +39,7 @@ typedef struct select_info { long begin_row; long cursor_col; long cursor_row; + tcflag_t ciflag_old; } select_info; typedef struct search_panel_info { @@ -118,6 +122,16 @@ static void feed_str(VteTerminal *vte, const char *s) { static void start_selection(VteTerminal *vte, select_info *select) { feed_str(vte, CSI "?25l"); // hide cursor + + // enable flow control + int fd = vte_pty_get_fd(vte_terminal_get_pty_object(vte)); + struct termios t; + tcgetattr(fd, &t); + select->ciflag_old = t.c_iflag; + t.c_iflag |= IXON; + tcsetattr(fd, TCSANOW, &t); + + vte_terminal_feed_child(vte, "\x13", 1); // pause output (XOFF) select->mode = SELECT_ON; vte_terminal_get_cursor_position(vte, &select->cursor_col, &select->cursor_row); update_selection(vte, select); @@ -125,6 +139,15 @@ static void start_selection(VteTerminal *vte, select_info *select) { static void end_selection(VteTerminal *vte, select_info *select) { feed_str(vte, CSI "?25h"); // show cursor + + // restore c_iflag + int fd = vte_pty_get_fd(vte_terminal_get_pty_object(vte)); + struct termios t; + tcgetattr(fd, &t); + t.c_iflag = select->ciflag_old; + tcsetattr(fd, TCSANOW, &t); + + vte_terminal_feed_child(vte, "\x11", 1); // resume output (XON) vte_terminal_select_none(vte); select->mode = SELECT_OFF; } @@ -738,7 +761,7 @@ int main(int argc, char **argv) { gtk_container_add(GTK_CONTAINER(overlay), vte); gtk_container_add(GTK_CONTAINER(window), overlay); - select_info select = {SELECT_OFF, 0, 0, 0, 0}; + select_info select = {SELECT_OFF, 0, 0, 0, 0, 0}; search_panel_info info = {vte, entry, alignment, OVERLAY_HIDDEN, select}; g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);