From 72eec58d9ea3cd8051dbd52905de27985aa0aaed Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Mon, 27 Aug 2012 00:46:52 -0400 Subject: [PATCH] pause output in command mode --- TODO.rst | 1 - expose_select_text.patch | 114 ++++++++++++++++++++++++++++++++++++--- termite.cc | 12 ++--- 3 files changed, 112 insertions(+), 15 deletions(-) diff --git a/TODO.rst b/TODO.rst index a6b2ae3..0f8c96a 100644 --- a/TODO.rst +++ b/TODO.rst @@ -2,6 +2,5 @@ * 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/expose_select_text.patch b/expose_select_text.patch index 72dee30..ce92818 100644 --- a/expose_select_text.patch +++ b/expose_select_text.patch @@ -1,7 +1,95 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c ---- vte-0.32.2-old/src/vte.c 2012-07-09 22:28:18.307063631 -0400 -+++ vte-0.32.2/src/vte.c 2012-07-09 22:31:58.323320464 -0400 -@@ -14567,6 +14567,51 @@ +--- vte-0.32.2-old/src/vte.c 2012-07-13 21:09:04.003969877 -0400 ++++ vte-0.32.2/src/vte.c 2012-08-27 00:38:20.036602880 -0400 +@@ -129,7 +129,6 @@ + gpointer data, + GArray *attributes, + gboolean include_trailing_spaces); +-static void _vte_terminal_disconnect_pty_read(VteTerminal *terminal); + static void _vte_terminal_disconnect_pty_write(VteTerminal *terminal); + static void vte_terminal_stop_processing (VteTerminal *terminal); + +@@ -3508,8 +3507,8 @@ + _vte_debug_print (VTE_DEBUG_IO, "removed poll of vte_terminal_io_read\n"); + terminal->pvt->pty_input_source = 0; + } +-static void +-_vte_terminal_connect_pty_read(VteTerminal *terminal) ++void ++vte_terminal_connect_pty_read(VteTerminal *terminal) + { + if (terminal->pvt->pty_channel == NULL) { + return; +@@ -3560,8 +3559,8 @@ + } + } + +-static void +-_vte_terminal_disconnect_pty_read(VteTerminal *terminal) ++void ++vte_terminal_disconnect_pty_read(VteTerminal *terminal) + { + if (terminal->pvt->pty_input_source != 0) { + _vte_debug_print (VTE_DEBUG_IO, "disconnecting poll of vte_terminal_io_read\n"); +@@ -6676,7 +6675,7 @@ + terminal->pvt->selection_start.row); + + /* Temporarily stop caring about input from the child. */ +- _vte_terminal_disconnect_pty_read(terminal); ++ vte_terminal_disconnect_pty_read(terminal); + } + + static gboolean +@@ -6693,7 +6692,7 @@ + terminal->pvt->selecting = FALSE; + + /* Reconnect to input from the child if we paused it. */ +- _vte_terminal_connect_pty_read(terminal); ++ vte_terminal_connect_pty_read(terminal); + + return TRUE; + } +@@ -8994,7 +8993,7 @@ + #endif + kill(terminal->pvt->pty_pid, SIGHUP); + } +- _vte_terminal_disconnect_pty_read(terminal); ++ vte_terminal_disconnect_pty_read(terminal); + _vte_terminal_disconnect_pty_write(terminal); + if (terminal->pvt->pty_channel != NULL) { + g_io_channel_unref (terminal->pvt->pty_channel); +@@ -13641,6 +13640,12 @@ + g_object_notify(G_OBJECT(terminal), "cursor-blink-mode"); + } + ++void ++vte_terminal_set_cursor_visible(VteTerminal *terminal, gboolean visible) { ++ g_return_if_fail(VTE_IS_TERMINAL(terminal)); ++ terminal->pvt->cursor_visible = visible; ++} ++ + /** + * vte_terminal_get_cursor_blink_mode: + * @terminal: a #VteTerminal +@@ -14384,7 +14389,7 @@ + g_object_freeze_notify(object); + + if (pvt->pty != NULL) { +- _vte_terminal_disconnect_pty_read(terminal); ++ vte_terminal_disconnect_pty_read(terminal); + _vte_terminal_disconnect_pty_write(terminal); + + if (terminal->pvt->pty_channel != NULL) { +@@ -14440,7 +14445,7 @@ + _vte_terminal_setup_utf8 (terminal); + + /* Open channels to listen for input on. */ +- _vte_terminal_connect_pty_read (terminal); ++ vte_terminal_connect_pty_read (terminal); + + g_object_notify(object, "pty"); + g_object_notify(object, "pty-object"); +@@ -14567,6 +14572,51 @@ } } @@ -54,9 +142,9 @@ diff -aur vte-0.32.2-old/src/vte.c vte-0.32.2/src/vte.c _vte_terminal_select_text(VteTerminal *terminal, long start_col, long start_row, diff -aur vte-0.32.2-old/src/vte.h vte-0.32.2/src/vte.h ---- vte-0.32.2-old/src/vte.h 2012-07-09 22:28:18.307063631 -0400 -+++ vte-0.32.2/src/vte.h 2012-07-09 22:28:21.587107210 -0400 -@@ -296,6 +296,11 @@ +--- vte-0.32.2-old/src/vte.h 2012-07-13 21:09:04.003969877 -0400 ++++ vte-0.32.2/src/vte.h 2012-08-27 00:35:43.754405161 -0400 +@@ -296,6 +296,15 @@ /* simple manipulation of selection */ void vte_terminal_select_all(VteTerminal *terminal); void vte_terminal_select_none(VteTerminal *terminal); @@ -65,6 +153,20 @@ diff -aur vte-0.32.2-old/src/vte.h vte-0.32.2/src/vte.h +void vte_terminal_select_text(VteTerminal *terminal, + long start_col, long start_row, + long end_col, long end_row); ++ ++/* pause and unpause output */ ++void vte_terminal_disconnect_pty_read(VteTerminal *vte); ++void vte_terminal_connect_pty_read(VteTerminal *vte); /* Set the terminal's size. */ void vte_terminal_set_size(VteTerminal *terminal, +@@ -364,6 +373,9 @@ + gboolean transparent); + void vte_terminal_set_opacity(VteTerminal *terminal, guint16 opacity); + ++/* Set whether the cursor is visible. */ ++void vte_terminal_set_cursor_visible(VteTerminal *terminal, gboolean visible); ++ + /* Set whether or not the cursor blinks. */ + void vte_terminal_set_cursor_blink_mode(VteTerminal *terminal, + VteTerminalCursorBlinkMode mode); diff --git a/termite.cc b/termite.cc index 84fa09d..03a803d 100644 --- a/termite.cc +++ b/termite.cc @@ -12,8 +12,6 @@ #include "url_regex.h" -#define CSI "\x1b[" - enum class overlay_mode { hidden, search, @@ -120,19 +118,17 @@ static void update_selection(VteTerminal *vte, const select_info *select) { vte_terminal_copy_primary(vte); } -static void feed_str(VteTerminal *vte, const char *s) { - vte_terminal_feed(vte, s, (long)strlen(s)); -} - static void start_selection(VteTerminal *vte, select_info *select) { - feed_str(vte, CSI "?25l"); // hide cursor + vte_terminal_set_cursor_visible(vte, FALSE); + vte_terminal_disconnect_pty_read(vte); select->mode = vi_mode::command; vte_terminal_get_cursor_position(vte, &select->cursor_col, &select->cursor_row); update_selection(vte, select); } static void end_selection(VteTerminal *vte, select_info *select) { - feed_str(vte, CSI "?25h"); // show cursor + vte_terminal_set_cursor_visible(vte, TRUE); + vte_terminal_connect_pty_read(vte); vte_terminal_select_none(vte); select->mode = vi_mode::insert; }