vte r2261 - in trunk: . src
- From: behdad svn gnome org
- To: svn-commits-list gnome org
- Subject: vte r2261 - in trunk: . src
- Date: Mon, 1 Dec 2008 08:10:01 +0000 (UTC)
Author: behdad
Date: Mon Dec 1 08:10:01 2008
New Revision: 2261
URL: http://svn.gnome.org/viewvc/vte?rev=2261&view=rev
Log:
2008-12-01 Behdad Esfahbod <behdad gnome org>
* src/vteseq.c (vte_sequence_handler_set_title_internal),
(vte_sequence_handler_set_mode_internal),
(vte_sequence_handler_invoke_internal):
Move some code around.
Modified:
trunk/ChangeLog
trunk/src/vteseq.c
Modified: trunk/src/vteseq.c
==============================================================================
--- trunk/src/vteseq.c (original)
+++ trunk/src/vteseq.c Mon Dec 1 08:10:01 2008
@@ -390,6 +390,124 @@
}
+/* Set icon/window titles. */
+static void
+vte_sequence_handler_set_title_internal(VteTerminal *terminal,
+ GValueArray *params,
+ gboolean icon_title,
+ gboolean window_title)
+{
+ GValue *value;
+ VteConv conv;
+ const guchar *inbuf = NULL;
+ guchar *outbuf = NULL, *outbufptr = NULL;
+ char *title = NULL;
+ gsize inbuf_len, outbuf_len;
+
+ if (icon_title == FALSE && window_title == FALSE)
+ return;
+
+ /* Get the string parameter's value. */
+ value = g_value_array_get_nth(params, 0);
+ if (value) {
+ if (G_VALUE_HOLDS_LONG(value)) {
+ /* Convert the long to a string. */
+ title = g_strdup_printf("%ld", g_value_get_long(value));
+ } else
+ if (G_VALUE_HOLDS_STRING(value)) {
+ /* Copy the string into the buffer. */
+ title = g_value_dup_string(value);
+ } else
+ if (G_VALUE_HOLDS_POINTER(value)) {
+ /* Convert the unicode-character string into a
+ * multibyte string. */
+ conv = _vte_conv_open("UTF-8", VTE_CONV_GUNICHAR_TYPE);
+ inbuf = g_value_get_pointer(value);
+ inbuf_len = vte_unichar_strlen((gunichar*)inbuf) *
+ sizeof(gunichar);
+ outbuf_len = (inbuf_len * VTE_UTF8_BPC) + 1;
+ _vte_buffer_set_minimum_size(terminal->pvt->conv_buffer,
+ outbuf_len);
+ outbuf = outbufptr = terminal->pvt->conv_buffer->bytes;
+ if (conv != VTE_INVALID_CONV) {
+ if (_vte_conv(conv, &inbuf, &inbuf_len,
+ &outbuf, &outbuf_len) == (size_t)-1) {
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Error "
+ "converting %ld title "
+ "bytes (%s), "
+ "skipping.\n",
+ (long) _vte_buffer_length(terminal->pvt->outgoing),
+ g_strerror(errno));
+ outbufptr = NULL;
+ } else {
+ title = g_strndup((gchar *)outbufptr,
+ outbuf - outbufptr);
+ }
+ _vte_conv_close(conv);
+ }
+ }
+ if (title != NULL) {
+ char *p, *validated;
+ const char *end;
+
+ /* Validate the text. */
+ g_utf8_validate(title, strlen(title), &end);
+ validated = g_strndup(title, end - title);
+
+ /* No control characters allowed. */
+ for (p = validated; *p != '\0'; p++) {
+ if ((*p & 0x1f) == *p) {
+ *p = ' ';
+ }
+ }
+
+ /* Emit the signal */
+ if (window_title) {
+ g_free (terminal->pvt->window_title_changed);
+ terminal->pvt->window_title_changed = g_strdup (validated);
+ }
+
+ if (icon_title) {
+ g_free (terminal->pvt->icon_title_changed);
+ terminal->pvt->icon_title_changed = g_strdup (validated);
+ }
+
+ g_free (validated);
+ g_free(title);
+ }
+ }
+}
+
+/* Toggle a terminal mode. */
+static void
+vte_sequence_handler_set_mode_internal(VteTerminal *terminal,
+ long setting, gboolean value)
+{
+ switch (setting) {
+ case 2: /* keyboard action mode (?) */
+ break;
+ case 4: /* insert/overtype mode */
+ terminal->pvt->screen->insert_mode = value;
+ break;
+ case 12: /* send/receive mode (local echo) */
+ terminal->pvt->screen->sendrecv_mode = value;
+ break;
+ case 20: /* automatic newline / normal linefeed mode */
+ terminal->pvt->screen->linefeed_mode = value;
+ break;
+ default:
+ break;
+ }
+}
+
+
+
+
+
+
+
+
@@ -429,6 +547,7 @@
((VteTerminalSequenceHandler) ((char *) &&VTE_SEQUENCE_HANDLER_LABEL(name) - (char *) && vte_sequence_handler__base_label))
#define vte_sequence_handler_invoke(handler, terminal, params) \
vte_sequence_handler_invoke_internal ((handler), NULL, (terminal), (params))
+
#define VTE_SEQUENCE_HANDLER_INVOKE(handler, terminal, params) \
vte_sequence_handler_invoke (VTE_SEQUENCE_HANDLER_REFERENCE (handler), (terminal), (params))
@@ -526,95 +645,6 @@
-/* Set icon/window titles. */
-static void
-vte_sequence_handler_set_title_internal(VteTerminal *terminal,
- GValueArray *params,
- gboolean icon_title,
- gboolean window_title)
-{
- GValue *value;
- VteConv conv;
- const guchar *inbuf = NULL;
- guchar *outbuf = NULL, *outbufptr = NULL;
- char *title = NULL;
- gsize inbuf_len, outbuf_len;
-
- if (icon_title == FALSE && window_title == FALSE)
- return;
-
- /* Get the string parameter's value. */
- value = g_value_array_get_nth(params, 0);
- if (value) {
- if (G_VALUE_HOLDS_LONG(value)) {
- /* Convert the long to a string. */
- title = g_strdup_printf("%ld", g_value_get_long(value));
- } else
- if (G_VALUE_HOLDS_STRING(value)) {
- /* Copy the string into the buffer. */
- title = g_value_dup_string(value);
- } else
- if (G_VALUE_HOLDS_POINTER(value)) {
- /* Convert the unicode-character string into a
- * multibyte string. */
- conv = _vte_conv_open("UTF-8", VTE_CONV_GUNICHAR_TYPE);
- inbuf = g_value_get_pointer(value);
- inbuf_len = vte_unichar_strlen((gunichar*)inbuf) *
- sizeof(gunichar);
- outbuf_len = (inbuf_len * VTE_UTF8_BPC) + 1;
- _vte_buffer_set_minimum_size(terminal->pvt->conv_buffer,
- outbuf_len);
- outbuf = outbufptr = terminal->pvt->conv_buffer->bytes;
- if (conv != VTE_INVALID_CONV) {
- if (_vte_conv(conv, &inbuf, &inbuf_len,
- &outbuf, &outbuf_len) == (size_t)-1) {
- _vte_debug_print(VTE_DEBUG_IO,
- "Error "
- "converting %ld title "
- "bytes (%s), "
- "skipping.\n",
- (long) _vte_buffer_length(terminal->pvt->outgoing),
- g_strerror(errno));
- outbufptr = NULL;
- } else {
- title = g_strndup((gchar *)outbufptr,
- outbuf - outbufptr);
- }
- _vte_conv_close(conv);
- }
- }
- if (title != NULL) {
- char *p, *validated;
- const char *end;
-
- /* Validate the text. */
- g_utf8_validate(title, strlen(title), &end);
- validated = g_strndup(title, end - title);
-
- /* No control characters allowed. */
- for (p = validated; *p != '\0'; p++) {
- if ((*p & 0x1f) == *p) {
- *p = ' ';
- }
- }
-
- /* Emit the signal */
- if (window_title) {
- g_free (terminal->pvt->window_title_changed);
- terminal->pvt->window_title_changed = g_strdup (validated);
- }
-
- if (icon_title) {
- g_free (terminal->pvt->icon_title_changed);
- terminal->pvt->icon_title_changed = g_strdup (validated);
- }
-
- g_free (validated);
- g_free(title);
- }
- }
-}
-
/* Manipulate certain terminal attributes. */
static void
vte_sequence_handler_decset_internal(VteTerminal *terminal,
@@ -974,29 +1004,6 @@
}
}
-/* Toggle a terminal mode. */
-static void
-vte_sequence_handler_set_mode_internal(VteTerminal *terminal,
- long setting, gboolean value)
-{
- switch (setting) {
- case 2: /* keyboard action mode (?) */
- break;
- case 4: /* insert/overtype mode */
- terminal->pvt->screen->insert_mode = value;
- break;
- case 12: /* send/receive mode (local echo) */
- terminal->pvt->screen->sendrecv_mode = value;
- break;
- case 20: /* automatic newline / normal linefeed mode */
- terminal->pvt->screen->linefeed_mode = value;
- break;
- default:
- break;
- }
-}
-
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]