pause output while in command mode
This commit is contained in:
		
							parent
							
								
									4fe67dbc79
								
							
						
					
					
						commit
						53c1e6cd50
					
				| @ -22,6 +22,8 @@ KEYBINDINGS | |||||||
| COMMAND MODE | COMMAND MODE | ||||||
| ------------------- | ------------------- | ||||||
| 
 | 
 | ||||||
|  | *While in command mode, output is paused.* | ||||||
|  | 
 | ||||||
| * ``escape``: deactivate command mode | * ``escape``: deactivate command mode | ||||||
| * ``v``: visual mode | * ``v``: visual mode | ||||||
| * ``V``: visual line mode | * ``V``: visual line mode | ||||||
| @ -53,6 +55,5 @@ TODO | |||||||
| * hint mode overlay for urls (like elinks/vimperator/pentadactyl) | * hint mode overlay for urls (like elinks/vimperator/pentadactyl) | ||||||
| * scrollback search needs to be improved upstream [1]_ | * scrollback search needs to be improved upstream [1]_ | ||||||
| * expose keybindings in ``termite.cfg`` | * expose keybindings in ``termite.cfg`` | ||||||
| * output should be paused while in command mode |  | ||||||
| 
 | 
 | ||||||
| .. [1] https://bugzilla.gnome.org/show_bug.cgi?id=627886 | .. [1] https://bugzilla.gnome.org/show_bug.cgi?id=627886 | ||||||
|  | |||||||
							
								
								
									
										25
									
								
								termite.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								termite.c
									
									
									
									
									
								
							| @ -3,6 +3,9 @@ | |||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
|  | #include <termios.h> | ||||||
|  | #include <unistd.h> | ||||||
|  | 
 | ||||||
| #include <gdk/gdkx.h> | #include <gdk/gdkx.h> | ||||||
| #include <gtk/gtk.h> | #include <gtk/gtk.h> | ||||||
| #include <vte/vte.h> | #include <vte/vte.h> | ||||||
| @ -36,6 +39,7 @@ typedef struct select_info { | |||||||
|     long begin_row; |     long begin_row; | ||||||
|     long cursor_col; |     long cursor_col; | ||||||
|     long cursor_row; |     long cursor_row; | ||||||
|  |     tcflag_t ciflag_old; | ||||||
| } select_info; | } select_info; | ||||||
| 
 | 
 | ||||||
| typedef struct search_panel_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) { | static void start_selection(VteTerminal *vte, select_info *select) { | ||||||
|     feed_str(vte, CSI "?25l"); // hide cursor
 |     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; |     select->mode = SELECT_ON; | ||||||
|     vte_terminal_get_cursor_position(vte, &select->cursor_col, &select->cursor_row); |     vte_terminal_get_cursor_position(vte, &select->cursor_col, &select->cursor_row); | ||||||
|     update_selection(vte, select); |     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) { | static void end_selection(VteTerminal *vte, select_info *select) { | ||||||
|     feed_str(vte, CSI "?25h"); // show cursor
 |     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); |     vte_terminal_select_none(vte); | ||||||
|     select->mode = SELECT_OFF; |     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(overlay), vte); | ||||||
|     gtk_container_add(GTK_CONTAINER(window), overlay); |     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}; |     search_panel_info info = {vte, entry, alignment, OVERLAY_HIDDEN, select}; | ||||||
| 
 | 
 | ||||||
|     g_signal_connect(window,  "destroy",            G_CALLBACK(gtk_main_quit), NULL); |     g_signal_connect(window,  "destroy",            G_CALLBACK(gtk_main_quit), NULL); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Daniel Micay
						Daniel Micay