Lines 110-118
typedef gunichar wint_t;
Link Here
|
110 |
#define VTE_FX_PRIORITY G_PRIORITY_DEFAULT_IDLE |
110 |
#define VTE_FX_PRIORITY G_PRIORITY_DEFAULT_IDLE |
111 |
#define VTE_REGCOMP_FLAGS REG_EXTENDED |
111 |
#define VTE_REGCOMP_FLAGS REG_EXTENDED |
112 |
#define VTE_REGEXEC_FLAGS 0 |
112 |
#define VTE_REGEXEC_FLAGS 0 |
113 |
#define VTE_INPUT_CHUNK_SIZE 0x1000 |
113 |
#define VTE_INPUT_CHUNK_SIZE 0x1000 |
114 |
#define VTE_INVALID_BYTE '?' |
114 |
#define VTE_INVALID_BYTE '?' |
115 |
#define VTE_COALESCE_TIMEOUT 2 |
115 |
#define VTE_COALESCE_TIMEOUT 10 |
|
|
116 |
#define VTE_DISPLAY_TIMEOUT 15 |
116 |
|
117 |
|
117 |
/* The structure we use to hold characters we're supposed to display -- this |
118 |
/* The structure we use to hold characters we're supposed to display -- this |
118 |
* includes any supported visible attributes. */ |
119 |
* includes any supported visible attributes. */ |
Lines 204-211
struct _VteTerminalPrivate {
Link Here
|
204 |
struct _vte_iso2022_state *iso2022; |
205 |
struct _vte_iso2022_state *iso2022; |
205 |
struct _vte_buffer *incoming; /* pending bytestream */ |
206 |
struct _vte_buffer *incoming; /* pending bytestream */ |
206 |
GArray *pending; /* pending characters */ |
207 |
GArray *pending; /* pending characters */ |
207 |
gboolean processing; |
208 |
gint coalesce_timeout; |
208 |
gint processing_tag; |
209 |
gint display_timeout; |
209 |
|
210 |
|
210 |
/* Output data queue. */ |
211 |
/* Output data queue. */ |
211 |
struct _vte_buffer *outgoing; /* pending input characters */ |
212 |
struct _vte_buffer *outgoing; /* pending input characters */ |
Lines 462-468
static void vte_terminal_match_hilite_cl
Link Here
|
462 |
static gboolean vte_terminal_background_update(gpointer data); |
463 |
static gboolean vte_terminal_background_update(gpointer data); |
463 |
static void vte_terminal_queue_background_update(VteTerminal *terminal); |
464 |
static void vte_terminal_queue_background_update(VteTerminal *terminal); |
464 |
static void vte_terminal_queue_adjustment_changed(VteTerminal *terminal); |
465 |
static void vte_terminal_queue_adjustment_changed(VteTerminal *terminal); |
465 |
static gboolean vte_terminal_process_incoming(gpointer data); |
466 |
static gboolean vte_terminal_process_incoming(VteTerminal *terminal); |
466 |
static gboolean vte_cell_is_selected(VteTerminal *terminal, |
467 |
static gboolean vte_cell_is_selected(VteTerminal *terminal, |
467 |
glong col, glong row, gpointer data); |
468 |
glong col, glong row, gpointer data); |
468 |
static char *vte_terminal_get_text_range_maybe_wrapped(VteTerminal *terminal, |
469 |
static char *vte_terminal_get_text_range_maybe_wrapped(VteTerminal *terminal, |
Lines 489-494
static char *vte_terminal_get_text_maybe
Link Here
|
489 |
gboolean include_trailing_spaces); |
490 |
gboolean include_trailing_spaces); |
490 |
static void _vte_terminal_disconnect_pty_read(VteTerminal *terminal); |
491 |
static void _vte_terminal_disconnect_pty_read(VteTerminal *terminal); |
491 |
static void _vte_terminal_disconnect_pty_write(VteTerminal *terminal); |
492 |
static void _vte_terminal_disconnect_pty_write(VteTerminal *terminal); |
|
|
493 |
static void vte_terminal_stop_processing (VteTerminal *terminal); |
494 |
static void vte_terminal_start_processing (VteTerminal *terminal); |
495 |
static gboolean vte_terminal_is_processing (VteTerminal *terminal); |
492 |
|
496 |
|
493 |
/* Free a no-longer-used row data array. */ |
497 |
/* Free a no-longer-used row data array. */ |
494 |
static void |
498 |
static void |
Lines 6989-6999
vte_terminal_catch_child_exited(VteReape
Link Here
|
6989 |
/* Take one last shot at processing whatever data is pending, |
6993 |
/* Take one last shot at processing whatever data is pending, |
6990 |
* then flush the buffers in case we're about to run a new |
6994 |
* then flush the buffers in case we're about to run a new |
6991 |
* command, disconnecting the timeout. */ |
6995 |
* command, disconnecting the timeout. */ |
6992 |
if (terminal->pvt->processing) { |
6996 |
vte_terminal_stop_processing (terminal); |
6993 |
g_source_remove(terminal->pvt->processing_tag); |
6997 |
|
6994 |
terminal->pvt->processing = FALSE; |
|
|
6995 |
terminal->pvt->processing_tag = VTE_INVALID_SOURCE; |
6996 |
} |
6997 |
if (_vte_buffer_length(terminal->pvt->incoming) > 0) { |
6998 |
if (_vte_buffer_length(terminal->pvt->incoming) > 0) { |
6998 |
vte_terminal_process_incoming(terminal); |
6999 |
vte_terminal_process_incoming(terminal); |
6999 |
} |
7000 |
} |
Lines 7277-7287
vte_terminal_eof(GIOChannel *channel, gp
Link Here
|
7277 |
/* Take one last shot at processing whatever data is pending, then |
7278 |
/* Take one last shot at processing whatever data is pending, then |
7278 |
* flush the buffers in case we're about to run a new command, |
7279 |
* flush the buffers in case we're about to run a new command, |
7279 |
* disconnecting the timeout. */ |
7280 |
* disconnecting the timeout. */ |
7280 |
if (terminal->pvt->processing) { |
7281 |
vte_terminal_stop_processing (terminal); |
7281 |
g_source_remove(terminal->pvt->processing_tag); |
|
|
7282 |
terminal->pvt->processing = FALSE; |
7283 |
terminal->pvt->processing_tag = VTE_INVALID_SOURCE; |
7284 |
} |
7285 |
if (_vte_buffer_length(terminal->pvt->incoming) > 0) { |
7282 |
if (_vte_buffer_length(terminal->pvt->incoming) > 0) { |
7286 |
vte_terminal_process_incoming(terminal); |
7283 |
vte_terminal_process_incoming(terminal); |
7287 |
} |
7284 |
} |
Lines 7379-7388
vte_terminal_emit_pending_text_signals(V
Link Here
|
7379 |
/* Process incoming data, first converting it to unicode characters, and then |
7376 |
/* Process incoming data, first converting it to unicode characters, and then |
7380 |
* processing control sequences. */ |
7377 |
* processing control sequences. */ |
7381 |
static gboolean |
7378 |
static gboolean |
7382 |
vte_terminal_process_incoming(gpointer data) |
7379 |
vte_terminal_process_incoming(VteTerminal *terminal) |
7383 |
{ |
7380 |
{ |
7384 |
GValueArray *params = NULL; |
7381 |
GValueArray *params = NULL; |
7385 |
VteTerminal *terminal; |
|
|
7386 |
VteScreen *screen; |
7382 |
VteScreen *screen; |
7387 |
struct vte_cursor_position cursor; |
7383 |
struct vte_cursor_position cursor; |
7388 |
GtkWidget *widget; |
7384 |
GtkWidget *widget; |
Lines 7396-7405
vte_terminal_process_incoming(gpointer d
Link Here
|
7396 |
gboolean leftovers, modified, bottom, inserted, again; |
7392 |
gboolean leftovers, modified, bottom, inserted, again; |
7397 |
GArray *unichars; |
7393 |
GArray *unichars; |
7398 |
|
7394 |
|
7399 |
g_return_val_if_fail(GTK_IS_WIDGET(data), FALSE); |
7395 |
g_return_val_if_fail(GTK_IS_WIDGET(terminal), FALSE); |
7400 |
g_return_val_if_fail(VTE_IS_TERMINAL(data), FALSE); |
7396 |
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE); |
7401 |
widget = GTK_WIDGET(data); |
7397 |
widget = GTK_WIDGET(terminal); |
7402 |
terminal = VTE_TERMINAL(data); |
|
|
7403 |
|
7398 |
|
7404 |
bottom = (terminal->pvt->screen->insert_delta == |
7399 |
bottom = (terminal->pvt->screen->insert_delta == |
7405 |
terminal->pvt->screen->scroll_delta); |
7400 |
terminal->pvt->screen->scroll_delta); |
Lines 7410-7416
vte_terminal_process_incoming(gpointer d
Link Here
|
7410 |
_vte_buffer_length(terminal->pvt->incoming)); |
7405 |
_vte_buffer_length(terminal->pvt->incoming)); |
7411 |
} |
7406 |
} |
7412 |
#endif |
7407 |
#endif |
7413 |
|
|
|
7414 |
/* Save the current cursor position. */ |
7408 |
/* Save the current cursor position. */ |
7415 |
screen = terminal->pvt->screen; |
7409 |
screen = terminal->pvt->screen; |
7416 |
cursor = screen->cursor_current; |
7410 |
cursor = screen->cursor_current; |
Lines 7705-7719
vte_terminal_process_incoming(gpointer d
Link Here
|
7705 |
(long) _vte_buffer_length(terminal->pvt->incoming)); |
7699 |
(long) _vte_buffer_length(terminal->pvt->incoming)); |
7706 |
} |
7700 |
} |
7707 |
#endif |
7701 |
#endif |
7708 |
/* Disconnect this function from the main loop. */ |
7702 |
|
7709 |
if (!again) { |
|
|
7710 |
terminal->pvt->processing = FALSE; |
7711 |
if (terminal->pvt->processing_tag != VTE_INVALID_SOURCE) { |
7712 |
g_source_remove(terminal->pvt->processing_tag); |
7713 |
} |
7714 |
terminal->pvt->processing_tag = VTE_INVALID_SOURCE; |
7715 |
} |
7716 |
|
7717 |
#ifdef VTE_DEBUG |
7703 |
#ifdef VTE_DEBUG |
7718 |
if (_vte_debug_on(VTE_DEBUG_IO)) { |
7704 |
if (_vte_debug_on(VTE_DEBUG_IO)) { |
7719 |
if (terminal->pvt->processing) { |
7705 |
if (terminal->pvt->processing) { |
Lines 7724-7730
vte_terminal_process_incoming(gpointer d
Link Here
|
7724 |
} |
7710 |
} |
7725 |
#endif |
7711 |
#endif |
7726 |
|
7712 |
|
7727 |
return terminal->pvt->processing; |
7713 |
return again; |
7728 |
} |
7714 |
} |
7729 |
|
7715 |
|
7730 |
/* Read and handle data from the child. */ |
7716 |
/* Read and handle data from the child. */ |
Lines 7832-7872
vte_terminal_feed(VteTerminal *terminal,
Link Here
|
7832 |
_vte_buffer_append(terminal->pvt->incoming, data, length); |
7818 |
_vte_buffer_append(terminal->pvt->incoming, data, length); |
7833 |
} |
7819 |
} |
7834 |
|
7820 |
|
7835 |
/* If we have sufficient data, just process it now. */ |
7821 |
vte_terminal_start_processing (terminal); |
7836 |
if (_vte_buffer_length(terminal->pvt->incoming) > |
|
|
7837 |
VTE_INPUT_CHUNK_SIZE) { |
7838 |
/* Disconnect the timeout if one is pending. */ |
7839 |
if (terminal->pvt->processing) { |
7840 |
g_source_remove(terminal->pvt->processing_tag); |
7841 |
terminal->pvt->processing = FALSE; |
7842 |
terminal->pvt->processing_tag = VTE_INVALID_SOURCE; |
7843 |
} |
7844 |
vte_terminal_process_incoming(terminal); |
7845 |
} |
7846 |
|
7847 |
/* Wait no more than N milliseconds for more data. We don't |
7848 |
* touch the timeout if we're already slated to call it again |
7849 |
* because if the output were carefully timed, we could |
7850 |
* conceivably put it off forever. */ |
7851 |
if (!terminal->pvt->processing && |
7852 |
(_vte_buffer_length(terminal->pvt->incoming) > 0)) { |
7853 |
#ifdef VTE_DEBUG |
7854 |
if (_vte_debug_on(VTE_DEBUG_IO)) { |
7855 |
fprintf(stderr, "Adding timed handler.\n"); |
7856 |
} |
7857 |
#endif |
7858 |
terminal->pvt->processing = TRUE; |
7859 |
terminal->pvt->processing_tag = g_timeout_add(VTE_COALESCE_TIMEOUT, |
7860 |
vte_terminal_process_incoming, |
7861 |
terminal); |
7862 |
} else { |
7863 |
#ifdef VTE_DEBUG |
7864 |
if (_vte_debug_on(VTE_DEBUG_IO)) { |
7865 |
fprintf(stderr, "Not touching timed handler, " |
7866 |
"or no data.\n"); |
7867 |
} |
7868 |
#endif |
7869 |
} |
7870 |
} |
7822 |
} |
7871 |
|
7823 |
|
7872 |
/* Send locally-encoded characters to the child. */ |
7824 |
/* Send locally-encoded characters to the child. */ |
Lines 11313-11320
vte_terminal_init(VteTerminal *terminal,
Link Here
|
11313 |
(gpointer)terminal); |
11265 |
(gpointer)terminal); |
11314 |
pvt->incoming = _vte_buffer_new(); |
11266 |
pvt->incoming = _vte_buffer_new(); |
11315 |
pvt->pending = g_array_new(TRUE, TRUE, sizeof(gunichar)); |
11267 |
pvt->pending = g_array_new(TRUE, TRUE, sizeof(gunichar)); |
11316 |
pvt->processing = FALSE; |
11268 |
pvt->coalesce_timeout = VTE_INVALID_SOURCE; |
11317 |
pvt->processing_tag = VTE_INVALID_SOURCE; |
11269 |
pvt->display_timeout = VTE_INVALID_SOURCE; |
11318 |
pvt->outgoing = _vte_buffer_new(); |
11270 |
pvt->outgoing = _vte_buffer_new(); |
11319 |
pvt->outgoing_conv = (VteConv) -1; |
11271 |
pvt->outgoing_conv = (VteConv) -1; |
11320 |
pvt->conv_buffer = _vte_buffer_new(); |
11272 |
pvt->conv_buffer = _vte_buffer_new(); |
Lines 11892-11901
vte_terminal_finalize(GObject *object)
Link Here
|
11892 |
terminal->pvt->pty_reaper = NULL; |
11844 |
terminal->pvt->pty_reaper = NULL; |
11893 |
|
11845 |
|
11894 |
/* Stop processing input. */ |
11846 |
/* Stop processing input. */ |
11895 |
if (terminal->pvt->processing_tag != VTE_INVALID_SOURCE) { |
11847 |
vte_terminal_stop_processing (terminal); |
11896 |
g_source_remove(terminal->pvt->processing_tag); |
|
|
11897 |
terminal->pvt->processing_tag = VTE_INVALID_SOURCE; |
11898 |
} |
11899 |
|
11848 |
|
11900 |
/* Discard any pending data. */ |
11849 |
/* Discard any pending data. */ |
11901 |
if (terminal->pvt->incoming != NULL) { |
11850 |
if (terminal->pvt->incoming != NULL) { |
Lines 15421-15431
vte_terminal_reset(VteTerminal *terminal
Link Here
|
15421 |
{ |
15370 |
{ |
15422 |
g_return_if_fail(VTE_IS_TERMINAL(terminal)); |
15371 |
g_return_if_fail(VTE_IS_TERMINAL(terminal)); |
15423 |
/* Stop processing any of the data we've got backed up. */ |
15372 |
/* Stop processing any of the data we've got backed up. */ |
15424 |
if (terminal->pvt->processing) { |
15373 |
vte_terminal_stop_processing (terminal); |
15425 |
g_source_remove(terminal->pvt->processing_tag); |
15374 |
|
15426 |
terminal->pvt->processing_tag = VTE_INVALID_SOURCE; |
|
|
15427 |
terminal->pvt->processing = FALSE; |
15428 |
} |
15429 |
/* Clear the input and output buffers. */ |
15375 |
/* Clear the input and output buffers. */ |
15430 |
if (terminal->pvt->incoming != NULL) { |
15376 |
if (terminal->pvt->incoming != NULL) { |
15431 |
_vte_buffer_clear(terminal->pvt->incoming); |
15377 |
_vte_buffer_clear(terminal->pvt->incoming); |
Lines 15757-15760
_vte_terminal_accessible_ref(VteTerminal
Link Here
|
15757 |
{ |
15703 |
{ |
15758 |
g_return_if_fail(VTE_IS_TERMINAL(terminal)); |
15704 |
g_return_if_fail(VTE_IS_TERMINAL(terminal)); |
15759 |
terminal->pvt->accessible_emit = TRUE; |
15705 |
terminal->pvt->accessible_emit = TRUE; |
|
|
15706 |
} |
15707 |
|
15708 |
static gboolean display_timeout (gpointer data); |
15709 |
static gboolean coalesce_timeout (gpointer data); |
15710 |
|
15711 |
static void |
15712 |
add_display_timeout (VteTerminal *terminal) |
15713 |
{ |
15714 |
terminal->pvt->display_timeout = |
15715 |
g_timeout_add (VTE_DISPLAY_TIMEOUT, display_timeout, terminal); |
15716 |
} |
15717 |
|
15718 |
static void |
15719 |
add_coalesce_timeout (VteTerminal *terminal) |
15720 |
{ |
15721 |
terminal->pvt->coalesce_timeout = |
15722 |
g_timeout_add (VTE_COALESCE_TIMEOUT, coalesce_timeout, terminal); |
15723 |
} |
15724 |
|
15725 |
static void |
15726 |
remove_display_timeout (VteTerminal *terminal) |
15727 |
{ |
15728 |
g_source_remove (terminal->pvt->display_timeout); |
15729 |
terminal->pvt->display_timeout = VTE_DISPLAY_TIMEOUT; |
15730 |
} |
15731 |
|
15732 |
static void |
15733 |
remove_coalesce_timeout (VteTerminal *terminal) |
15734 |
{ |
15735 |
g_source_remove (terminal->pvt->coalesce_timeout); |
15736 |
terminal->pvt->coalesce_timeout = VTE_INVALID_SOURCE; |
15737 |
} |
15738 |
|
15739 |
static void |
15740 |
vte_terminal_stop_processing (VteTerminal *terminal) |
15741 |
{ |
15742 |
remove_display_timeout (terminal); |
15743 |
remove_coalesce_timeout (terminal); |
15744 |
} |
15745 |
|
15746 |
static void |
15747 |
vte_terminal_start_processing (VteTerminal *terminal) |
15748 |
{ |
15749 |
if (vte_terminal_is_processing (terminal)) { |
15750 |
remove_coalesce_timeout (terminal); |
15751 |
add_coalesce_timeout (terminal); |
15752 |
} |
15753 |
else { |
15754 |
add_coalesce_timeout (terminal); |
15755 |
add_display_timeout (terminal); |
15756 |
} |
15757 |
} |
15758 |
|
15759 |
static gboolean |
15760 |
vte_terminal_is_processing (VteTerminal *terminal) |
15761 |
{ |
15762 |
return terminal->pvt->coalesce_timeout != VTE_INVALID_SOURCE; |
15763 |
} |
15764 |
|
15765 |
|
15766 |
/* This function is called every DISPLAY_TIMEOUT ms. |
15767 |
* It makes sure output is never delayed by more than DISPLAY_TIMEOUT |
15768 |
*/ |
15769 |
static gboolean |
15770 |
display_timeout (gpointer data) |
15771 |
{ |
15772 |
gboolean cont; |
15773 |
VteTerminal *terminal = data; |
15774 |
|
15775 |
cont = vte_terminal_process_incoming (terminal); |
15776 |
|
15777 |
if (!cont) { |
15778 |
remove_coalesce_timeout (terminal); |
15779 |
|
15780 |
terminal->pvt->display_timeout = VTE_INVALID_SOURCE; |
15781 |
|
15782 |
return FALSE; |
15783 |
} |
15784 |
else { |
15785 |
remove_coalesce_timeout (terminal); |
15786 |
add_coalesce_timeout (terminal); |
15787 |
} |
15788 |
|
15789 |
return TRUE; |
15790 |
} |
15791 |
|
15792 |
/* This function is called whenever data haven't arrived for |
15793 |
* COALESCE_TIMEOUT ms |
15794 |
*/ |
15795 |
static gboolean |
15796 |
coalesce_timeout (gpointer data) |
15797 |
{ |
15798 |
gboolean cont; |
15799 |
VteTerminal *terminal = data; |
15800 |
|
15801 |
cont = vte_terminal_process_incoming (terminal); |
15802 |
|
15803 |
if (!cont) { |
15804 |
remove_display_timeout (terminal); |
15805 |
|
15806 |
terminal->pvt->coalesce_timeout = VTE_INVALID_SOURCE; |
15807 |
|
15808 |
return FALSE; |
15809 |
} |
15810 |
else { |
15811 |
/* reset display timeout since we just displayed */ |
15812 |
remove_display_timeout (terminal); |
15813 |
add_display_timeout (terminal); |
15814 |
} |
15815 |
|
15816 |
return TRUE; |
15760 |
} |
15817 |
} |