summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-01-26 14:30:30 +0000
committerChris Wilson <cpwilson@src.gnome.org>2007-01-26 14:30:30 +0000
commitd2dc82343a348aa22402c03b2a1677b6b73f7d5f (patch)
treec3db0d9306e298aba3c031b46e3ea80521ee16d2 /src
parentb01b8d2fe3e37a6d6f333c27a8890dfb49295a69 (diff)
Janitorial work - near elimination of #ifdef VTE_DEBUG from within
2007-01-26 Chris Wilson <chris@chris-wilson.co.uk> Janitorial work - near elimination of #ifdef VTE_DEBUG from within functions, trimming over a thousand lines of code. We introduce a _vte_debug_print macro to cover the more common occurrence of printing a message at a certain debug level. And a _VTE_DEBUG_ON for a conditional code block. src/debug.h | 11 src/iso2022.c | 201 ++------- src/keymap.c | 41 - src/matcher.c | 24 - src/pty.c | 134 +----- src/reaper.c | 21 src/ring.c | 78 +-- src/table.c | 11 src/trie.c | 19 src/vte.c | 1187 ++++++++++--------------------------------------- src/vteaccess.c | 198 +++------ src/vteapp.c | 21 src/vtebg.c | 43 -- src/vteconv.c | 60 +- src/vteconv.h | 12 src/vtedraw.c | 6 src/vtefc.c | 4 src/vteft2.c | 5 src/vteglyph.c | 27 - src/vtepango.c | 11 src/vtepangox.c | 7 src/vteregex.c | 2 src/vteseq.c | 385 +++++------------- src/vtexft.c | 26 - 24 files changed, 789 insertions(+), 1745 deletions(-) svn path=/trunk/; revision=1539
Diffstat (limited to 'src')
-rw-r--r--src/debug.h11
-rw-r--r--src/iso2022.c201
-rw-r--r--src/keymap.c41
-rw-r--r--src/matcher.c24
-rw-r--r--src/pty.c134
-rw-r--r--src/reaper.c21
-rw-r--r--src/ring.c78
-rw-r--r--src/table.c11
-rw-r--r--src/trie.c19
-rw-r--r--src/vte.c1187
-rw-r--r--src/vteaccess.c198
-rw-r--r--src/vteapp.c21
-rw-r--r--src/vtebg.c43
-rw-r--r--src/vteconv.c60
-rw-r--r--src/vteconv.h12
-rw-r--r--src/vtedraw.c6
-rw-r--r--src/vtefc.c4
-rw-r--r--src/vteft2.c5
-rw-r--r--src/vteglyph.c27
-rw-r--r--src/vtepango.c11
-rw-r--r--src/vtepangox.c7
-rw-r--r--src/vteregex.c2
-rw-r--r--src/vteseq.c385
-rw-r--r--src/vtexft.c26
24 files changed, 789 insertions, 1745 deletions
diff --git a/src/debug.h b/src/debug.h
index f041664..1838afa 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -47,6 +47,17 @@ typedef enum {
void _vte_debug_parse_string(const char *string);
gboolean _vte_debug_on(VteDebugFlags flags) G_GNUC_CONST;
+#ifdef VTE_DEBUG
+#define __VTE_DEBUG_START(flags) G_STMT_START{ if (_vte_debug_on (flags)) {
+#define __VTE_DEBUG_END } }G_STMT_END
+#define _VTE_DEBUG_ON(flags, code) __VTE_DEBUG_START(flags) code; __VTE_DEBUG_END
+#else
+#define _VTE_DEBUG_ON(flags, code)
+#endif
+
+#define _vte_debug_print(flags, fmt, ...) \
+ _VTE_DEBUG_ON(flags, g_printerr(fmt, ##__VA_ARGS__))
+
G_END_DECLS
#endif
diff --git a/src/iso2022.c b/src/iso2022.c
index f86e0c3..302e770 100644
--- a/src/iso2022.c
+++ b/src/iso2022.c
@@ -344,12 +344,8 @@ _vte_iso2022_ambiguous_width_guess(void)
ret = 2;
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("Ambiguous characters will have width = %d.\n",
- ret);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "Ambiguous characters will have width = %d.\n", ret);
return ret;
}
@@ -770,12 +766,9 @@ _vte_iso2022_state_new(const char *native_codeset,
}
state->utf8_codeset = "UTF-8";
state->target_codeset = VTE_CONV_GUNICHAR_TYPE;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("Native codeset \"%s\", currently %s\n",
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "Native codeset \"%s\", currently %s\n",
state->native_codeset, state->codeset);
- }
-#endif
state->conv = _vte_conv_open(state->target_codeset, state->codeset);
state->codeset_changed = fn;
state->codeset_changed_data = data;
@@ -783,11 +776,8 @@ _vte_iso2022_state_new(const char *native_codeset,
if (state->conv == VTE_INVALID_CONV) {
g_warning(_("Unable to convert characters from %s to %s."),
state->codeset, state->target_codeset);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("Using UTF-8 instead.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "Using UTF-8 instead.\n");
state->codeset = state->utf8_codeset;
state->conv = _vte_conv_open(state->target_codeset,
state->codeset);
@@ -819,11 +809,7 @@ _vte_iso2022_state_set_codeset(struct _vte_iso2022_state *state,
g_return_if_fail(codeset != NULL);
g_return_if_fail(strlen(codeset) > 0);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("%s\n", codeset);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION, "%s\n", codeset);
conv = _vte_conv_open(state->target_codeset, codeset);
if (conv == VTE_INVALID_CONV) {
g_warning(_("Unable to convert characters from %s to %s."),
@@ -1181,12 +1167,9 @@ process_8_bit_sequence(struct _vte_iso2022_state *state,
p = GINT_TO_POINTER(acc);
c = GPOINTER_TO_INT(g_tree_lookup(map, p));
if ((c == 0) && (acc != 0)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("%04lx -(%c)-> %04lx(?)\n",
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "%04lx -(%c)-> %04lx(?)\n",
acc, state->g[current] & 0xff, acc);
- }
-#endif
} else {
width = 0;
if (force_width != 0) {
@@ -1196,11 +1179,8 @@ process_8_bit_sequence(struct _vte_iso2022_state *state,
width = _vte_iso2022_ambiguous_width(state);
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("%05lx -> " "%04x\n", acc, c);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "%05lx -> " "%04x\n", acc, c);
c = _vte_iso2022_set_encoded_width(c, width);
}
/* Save the unichar. */
@@ -1235,14 +1215,11 @@ process_cdata(struct _vte_iso2022_state *state, const guchar *cdata, gsize lengt
single = (state->override != -1);
current = (state->override != -1) ? state->override : state->current;
state->override = -1;
- g_assert((current >= 0) && (current < G_N_ELEMENTS(state->g)));
+ g_assert(current < G_N_ELEMENTS(state->g));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("Current map = %d (%c).\n",
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "Current map = %d (%c).\n",
current, (state->g[current] & 0xff));
- }
-#endif
if (!state->nrc_enabled || (state->g[current] == 'B')) {
inbuf = cdata;
@@ -1337,15 +1314,12 @@ process_cdata(struct _vte_iso2022_state *state, const guchar *cdata, gsize lengt
p = GINT_TO_POINTER(acc);
c = GPOINTER_TO_INT(g_tree_lookup(map, p));
if ((c == 0) && (acc != 0)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("%04lx -(%c)-> "
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "%04lx -(%c)-> "
"%04lx(?)\n",
acc,
state->g[current] & 0xff,
acc);
- }
-#endif
g_array_append_val(gunichars, acc);
} else {
width = 0;
@@ -1356,12 +1330,9 @@ process_cdata(struct _vte_iso2022_state *state, const guchar *cdata, gsize lengt
width = ambiguous_width;
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("%05lx -> "
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "%05lx -> "
"%04x\n", acc, c);
- }
-#endif
c = _vte_iso2022_set_encoded_width(c, width);
g_array_append_val(gunichars, c);
}
@@ -1416,56 +1387,34 @@ process_control(struct _vte_iso2022_state *state, guchar *ctl, gsize length,
case '\r': /* CR */
c = '\r';
g_array_append_val(gunichars, c);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tCR\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION, "\tCR\n");
break;
case '\n': /* LF */
c = '\n';
g_array_append_val(gunichars, c);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tLF\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION, "\tLF\n");
break;
case '\016': /* SO */
state->current = 1;
state->override = -1;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tSO (^N)\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION, "\tSO (^N)\n");
break;
case '\017': /* SI */
state->current = 0;
state->override = -1;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tSI (^O)\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION, "\tSI (^O)\n");
break;
case 0x8e:
/* SS2 - 8bit */
state->override = 2;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tSS2 (8-bit)\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "\tSS2 (8-bit)\n");
break;
case 0x8f:
/* SS3 - 8bit */
state->override = 3;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tSS3 (8-bit)\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "\tSS3 (8-bit)\n");
break;
case '\033':
if (length >= 2) {
@@ -1480,8 +1429,7 @@ process_control(struct _vte_iso2022_state *state, guchar *ctl, gsize length,
g_array_append_val(gunichars,
c);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_SUBSTITUTION, ({
g_printerr("\t");
for (i = 0; i < length; i++) {
c = (guchar) ctl[i];
@@ -1493,42 +1441,29 @@ process_control(struct _vte_iso2022_state *state, guchar *ctl, gsize length,
c : c + 64);
}
g_printerr("\n");
- }
-#endif
+ }));
break;
case 'N': /* SS2 */
state->override = 2;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tSS2\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "\tSS2\n");
break;
case 'O': /* SS3 */
state->override = 3;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tSS3\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "\tSS3\n");
break;
case 'n': /* LS2 */
state->current = 2;
state->override = -1;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tLS2\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "\tLS2\n");
break;
case 'o': /* LS3 */
state->current = 3;
state->override = -1;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("\tLS3\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "\tLS3\n");
break;
case '(':
case ')':
@@ -1560,13 +1495,9 @@ process_control(struct _vte_iso2022_state *state, guchar *ctl, gsize length,
} else {
g_warning(_("Attempt to set invalid NRC map '%c'."), c);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr(
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
"\tG[%d] = %c.\n",
g, c);
- }
-#endif
}
break;
case '%':
@@ -1578,24 +1509,16 @@ process_control(struct _vte_iso2022_state *state, guchar *ctl, gsize length,
notify = TRUE;
}
_vte_iso2022_state_set_codeset(state, state->native_codeset);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr(
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
"\tNative encoding.\n");
- }
-#endif
break;
case 'G':
if (strcmp(state->codeset, state->utf8_codeset) != 0) {
notify = TRUE;
}
_vte_iso2022_state_set_codeset(state, state->utf8_codeset);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr(
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
"\tUTF-8 encoding.\n");
- }
-#endif
break;
default:
/* Application signalled an "identified coding system" we haven't heard of. See ECMA-35 for gory details. */
@@ -1650,13 +1573,9 @@ process_control(struct _vte_iso2022_state *state, guchar *ctl, gsize length,
} else {
g_warning(_("Attempt to set invalid wide NRC map '%c'."), c);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr(
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
"\tG[%d] = wide %c.\n",
g, c);
- }
-#endif
} else
if (length >= 3) {
gunichar c = 0;
@@ -1676,13 +1595,9 @@ process_control(struct _vte_iso2022_state *state, guchar *ctl, gsize length,
} else {
g_warning(_("Attempt to set invalid wide NRC map '%c'."), c);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr(
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
"\tG[0] = wide %c.\n",
c);
- }
-#endif
}
break;
default:
@@ -1715,8 +1630,7 @@ _vte_iso2022_process(struct _vte_iso2022_state *state,
block = &g_array_index(blocks, struct _vte_iso2022_block, i);
switch (block->type) {
case _vte_iso2022_cdata:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_SUBSTITUTION, ({
int j;
g_printerr("%3ld %3ld CDATA \"%.*s\"",
block->start, block->end,
@@ -1731,8 +1645,7 @@ _vte_iso2022_process(struct _vte_iso2022_state *state,
input->bytes[j]);
}
g_printerr(")\n");
- }
-#endif
+ }));
initial = 0;
while (initial < block->end - block->start) {
int j;
@@ -1758,12 +1671,9 @@ _vte_iso2022_process(struct _vte_iso2022_state *state,
}
break;
case _vte_iso2022_control:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("%3ld %3ld CONTROL ",
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "%3ld %3ld CONTROL ",
block->start, block->end);
- }
-#endif
process_control(state,
input->bytes + block->start,
block->end - block->start,
@@ -1771,12 +1681,9 @@ _vte_iso2022_process(struct _vte_iso2022_state *state,
preserve_last = FALSE;
break;
case _vte_iso2022_preserve:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("%3ld %3ld PRESERVE\n",
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "%3ld %3ld PRESERVE\n",
block->start, block->end);
- }
-#endif
g_assert(i == blocks->len - 1);
preserve_last = TRUE;
break;
@@ -1787,20 +1694,14 @@ _vte_iso2022_process(struct _vte_iso2022_state *state,
}
if (preserve_last && (blocks->len > 0)) {
block = &g_array_index(blocks, struct _vte_iso2022_block, blocks->len - 1);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("Consuming %ld bytes.\n", block->start);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "Consuming %ld bytes.\n", block->start);
_vte_buffer_consume(input, block->start);
g_assert(_vte_buffer_length(input) == block->end - block->start);
} else {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("Consuming %ld bytes.\n",
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "Consuming %ld bytes.\n",
(long) _vte_buffer_length(input));
- }
-#endif
_vte_buffer_clear(input);
}
g_array_free(blocks, TRUE);
diff --git a/src/keymap.c b/src/keymap.c
index 8cbd800..87f9332 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -947,8 +947,7 @@ _vte_keymap_map(guint keyval,
g_return_if_fail(normal_length != NULL);
g_return_if_fail(special != NULL);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_KEYBOARD, ({
g_printerr("Mapping ");
if (modifiers & GDK_CONTROL_MASK) {
g_printerr("Control+");
@@ -996,8 +995,7 @@ _vte_keymap_map(guint keyval,
}
g_printerr(")");
}
- }
-#endif
+ }));
/* Start from scratch. */
*normal = NULL;
@@ -1054,11 +1052,8 @@ _vte_keymap_map(guint keyval,
}
}
if (entries == NULL) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- g_printerr(" (ignoring, no map for key).\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD,
+ " (ignoring, no map for key).\n");
return;
}
@@ -1104,8 +1099,7 @@ _vte_keymap_map(guint keyval,
vt220_mode,
normal,
normal_length);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_KEYBOARD, ({
int j;
g_printerr(" to '");
for (j = 0; j < *normal_length; j++) {
@@ -1119,8 +1113,7 @@ _vte_keymap_map(guint keyval,
}
}
g_printerr("'.\n");
- }
-#endif
+ }));
return;
} else {
termcap_special = entries[i].special;
@@ -1132,21 +1125,14 @@ _vte_keymap_map(guint keyval,
if (strlen(cap) > 0) {
/* Save the special string. */
*special = entries[i].special;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- g_printerr(" to \"%s\"",
- *special);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD,
+ " to \"%s\"", *special);
}
g_free(cap);
if (*special != NULL) {
/* Return the special string. */
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- g_printerr(", returning.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD,
+ ", returning.\n");
return;
}
}
@@ -1201,11 +1187,8 @@ _vte_keymap_map(guint keyval,
}
#endif
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- g_printerr(" (ignoring, no match for modifier state).\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD,
+ " (ignoring, no match for modifier state).\n");
}
gboolean
diff --git a/src/matcher.c b/src/matcher.c
index fd1b25a..320f853 100644
--- a/src/matcher.c
+++ b/src/matcher.c
@@ -61,11 +61,7 @@ _vte_matcher_init(struct _vte_matcher *matcher, const char *emulation,
char *stripped;
int i;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("_vte_matcher_init()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "_vte_matcher_init()\n");
/* Load the known capability strings from the termcap structure into
* the table for recognition. */
@@ -117,13 +113,11 @@ _vte_matcher_init(struct _vte_matcher *matcher, const char *emulation,
_vte_matcher_add(matcher, "\n", 1, "sf", 0);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_TRIE)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_TRIE, ({
g_printerr("Trie contents:\n");
_vte_matcher_print(matcher);
g_printerr("\n");
- }
-#endif
+ }));
}
/* Allocates new matcher structure. */
@@ -133,11 +127,7 @@ _vte_matcher_create(gpointer key)
char *emulation = key;
struct _vte_matcher *ret = NULL;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("_vte_matcher_create()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "_vte_matcher_create()\n");
ret = g_slice_new(struct _vte_matcher);
ret->impl = &dummy_vte_matcher_trie;
ret->match = NULL;
@@ -158,11 +148,7 @@ _vte_matcher_destroy(gpointer value)
{
struct _vte_matcher *matcher = value;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("_vte_matcher_destroy()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "_vte_matcher_destroy()\n");
if (matcher->match != NULL) /* do not call destroy on dummy values */
matcher->impl->klass->destroy(matcher->impl);
g_slice_free(struct _vte_matcher, matcher);
diff --git a/src/pty.c b/src/pty.c
index 8179ab0..0dafb04 100644
--- a/src/pty.c
+++ b/src/pty.c
@@ -179,21 +179,14 @@ vte_pty_child_setup (gpointer arg)
break;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_PTY)) {
- g_printerr ("Setting up child pty: name = %s, fd = %d\n",
+ _vte_debug_print (VTE_DEBUG_PTY,
+ "Setting up child pty: name = %s, fd = %d\n",
tty ? tty : "(none)", fd);
- }
-#endif
/* Start a new session and become process-group leader. */
#if defined(HAVE_SETSID) && defined(HAVE_SETPGID)
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_PTY)) {
- g_printerr ("Starting new session\n");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_PTY, "Starting new session\n");
setsid();
setpgid(0, 0);
#endif
@@ -288,8 +281,7 @@ _vte_pty_run_on_pty (struct vte_pty_child_setup_data *data,
}
arg2[i+1] = NULL;
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_MISC)) {
+ _VTE_DEBUG_ON (VTE_DEBUG_MISC, ({
g_printerr("Spawing command '%s'\n", command);
for (i = 0; arg2[i] != NULL; i++) {
g_printerr(" argv[%d] = %s\n", i, arg2[i]);
@@ -302,8 +294,7 @@ _vte_pty_run_on_pty (struct vte_pty_child_setup_data *data,
}
g_printerr (" directory: %s\n",
directory ? directory : "(none)");
- }
-#endif
+ }));
ret = g_spawn_async_with_pipes (directory,
arg2, envp,
@@ -335,13 +326,10 @@ _vte_pty_run_on_pty (struct vte_pty_child_setup_data *data,
}
g_strfreev (arg2);
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_MISC)) {
- g_printerr ("Spawn result: %s%s\n",
- ret?"Success":"Failure - ",
- ret?"":local_error->message);
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_MISC,
+ "Spawn result: %s%s\n",
+ ret?"Success":"Failure - ",
+ ret?"":local_error->message);
if (local_error)
g_propagate_error (error, local_error);
}
@@ -435,21 +423,15 @@ _vte_pty_set_size(int master, int columns, int rows)
memset(&size, 0, sizeof(size));
size.ws_row = rows ? rows : 24;
size.ws_col = columns ? columns : 80;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Setting size on fd %d to (%d,%d).\n",
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "Setting size on fd %d to (%d,%d).\n",
master, columns, rows);
- }
-#endif
ret = ioctl(master, TIOCSWINSZ, &size);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- if (ret != 0) {
- g_printerr("Failed to set size on %d: %s.\n",
+ if (ret != 0) {
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "Failed to set size on %d: %s.\n",
master, strerror(errno));
- }
}
-#endif
return ret;
}
@@ -477,19 +459,13 @@ _vte_pty_get_size(int master, int *columns, int *rows)
if (rows != NULL) {
*rows = size.ws_row;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Size on fd %d is (%d,%d).\n",
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "Size on fd %d is (%d,%d).\n",
master, size.ws_col, size.ws_row);
- }
-#endif
} else {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Failed to read size from fd %d.\n",
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "Failed to read size from fd %d.\n",
master);
- }
-#endif
}
return ret;
}
@@ -507,11 +483,8 @@ _vte_pty_ptsname(int master)
switch (i) {
case 0:
/* Return the allocated buffer with the name in it. */
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("PTY slave is `%s'.\n", buf);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "PTY slave is `%s'.\n", buf);
return buf;
break;
default:
@@ -524,21 +497,14 @@ _vte_pty_ptsname(int master)
#elif defined(HAVE_PTSNAME)
char *p;
if ((p = ptsname(master)) != NULL) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("PTY slave is `%s'.\n", p);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY, "PTY slave is `%s'.\n", p);
return g_strdup(p);
}
#elif defined(TIOCGPTN)
int pty = 0;
if (ioctl(master, TIOCGPTN, &pty) == 0) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("PTY slave is `/dev/pts/%d'.\n", pty);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "PTY slave is `/dev/pts/%d'.\n", pty);
return g_strdup_printf("/dev/pts/%d", pty);
}
#endif
@@ -599,21 +565,14 @@ _vte_pty_open_unix98(GPid *child, char **env_add,
/* Attempt to open the master. */
fd = _vte_pty_getpt();
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Allocated pty on fd %d.\n", fd);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY, "Allocated pty on fd %d.\n", fd);
if (fd != -1) {
/* Read the slave number and unlock it. */
if (((buf = _vte_pty_ptsname(fd)) == NULL) ||
(_vte_pty_grantpt(fd) != 0) ||
(_vte_pty_unlockpt(fd) != 0)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("PTY setup failed, bailing.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "PTY setup failed, bailing.\n");
close(fd);
fd = -1;
} else {
@@ -893,39 +852,24 @@ _vte_pty_open_with_helper(GPid *child, char **env_add,
&ops, sizeof(ops)) != sizeof(ops)) {
return -1;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Sent request to helper.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY, "Sent request to helper.\n");
/* Read back the response. */
if (n_read(_vte_pty_helper_tunnel,
&ret, sizeof(ret)) != sizeof(ret)) {
return -1;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Received response from helper.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "Received response from helper.\n");
if (ret == 0) {
return -1;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Helper returns success.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY, "Helper returns success.\n");
/* Read back a tag. */
if (n_read(_vte_pty_helper_tunnel,
&tag, sizeof(tag)) != sizeof(tag)) {
return -1;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Tag = %p.\n", tag);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY, "Tag = %p.\n", tag);
/* Receive the master and slave ptys. */
_vte_pty_read_ptypair(_vte_pty_helper_tunnel,
&parentfd, &childfd);
@@ -935,12 +879,9 @@ _vte_pty_open_with_helper(GPid *child, char **env_add,
close(childfd);
return -1;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Got master pty %d and slave pty %d.\n",
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "Got master pty %d and slave pty %d.\n",
parentfd, childfd);
- }
-#endif
/* Add the parent and the tag to our map. */
g_tree_insert(_vte_pty_helper_map,
@@ -1026,12 +967,9 @@ _vte_pty_open(pid_t *child_pid, char **env_add,
if (ret != -1) {
*child_pid = (pid_t) child;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PTY)) {
- g_printerr("Returning ptyfd = %d, child = %ld.\n",
- ret, (long) child);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PTY,
+ "Returning ptyfd = %d, child = %ld.\n",
+ ret, (long) child);
return ret;
}
diff --git a/src/reaper.c b/src/reaper.c
index 66784df..74d468a 100644
--- a/src/reaper.c
+++ b/src/reaper.c
@@ -81,10 +81,8 @@ vte_reaper_emit_signal(GIOChannel *channel, GIOCondition condition,
g_assert(data == singleton_reaper);
read(singleton_reaper->iopipe[0], &info, sizeof(info));
if (info.signum == SIGCHLD) {
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Reaper emitting child-exited "
- "signal.\n");
- }
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Reaper emitting child-exited signal.\n");
g_signal_emit_by_name(data, "child-exited",
info.pid, info.status);
}
@@ -95,9 +93,8 @@ vte_reaper_emit_signal(GIOChannel *channel, GIOCondition condition,
static void
vte_reaper_child_watch_cb(GPid pid, gint status, gpointer data)
{
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Reaper emitting child-exited signal.\n");
- }
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Reaper emitting child-exited signal.\n");
g_signal_emit_by_name(data, "child-exited", pid, status);
g_spawn_close_pid (pid);
}
@@ -162,9 +159,8 @@ vte_reaper_init(VteReaper *reaper)
sigemptyset(&action.sa_mask);
action.sa_flags = SA_RESTART | SA_NOCLDSTOP;
sigaction(SIGCHLD, &action, NULL);
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Hooked SIGCHLD signal in reaper.\n");
- }
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Hooked SIGCHLD signal in reaper.\n");
}
static GObject*
@@ -196,9 +192,8 @@ vte_reaper_finalize(GObject *reaper)
if (old_action.sa_handler == vte_reaper_signal_handler) {
sigaction(SIGCHLD, &action, NULL);
}
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Unhooked SIGCHLD signal in reaper.\n");
- }
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Unhooked SIGCHLD signal in reaper.\n");
/* Remove the channel from the source list. */
g_source_remove_by_user_data(reaper);
diff --git a/src/ring.c b/src/ring.c
index be14104..97d2790 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -36,6 +36,8 @@ _vte_ring_validate(VteRing * ring)
g_assert(ring->array[i % ring->max] != NULL);
}
}
+#else
+#define _vte_ring_validate(ring)
#endif
/**
@@ -87,14 +89,11 @@ void
_vte_ring_insert(VteRing * ring, long position, gpointer data)
{
long point, i;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr("Inserting at position %ld.\n", position);
- g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
- ring->delta, ring->length, ring->max);
- }
+ _vte_debug_print(VTE_DEBUG_RING,
+ "Inserting at position %ld.\n"
+ " Delta = %ld, Length = %ld, Max = %ld.\n",
+ position, ring->delta, ring->length, ring->max);
_vte_ring_validate(ring);
-#endif
g_return_if_fail(ring != NULL);
g_return_if_fail(position >= ring->delta);
g_return_if_fail(position <= ring->delta + ring->length);
@@ -105,12 +104,9 @@ _vte_ring_insert(VteRing * ring, long position, gpointer data)
/* If there was something there before, free it. */
if ((ring->free != NULL) &&
(ring->array[position % ring->max] != NULL)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr("Freeing item at position "
+ _vte_debug_print(VTE_DEBUG_RING,
+ "Freeing item at position "
"%ld.\n", position);
- }
-#endif
ring->free(ring->array[position % ring->max],
ring->user_data);
}
@@ -124,14 +120,11 @@ _vte_ring_insert(VteRing * ring, long position, gpointer data)
} else {
ring->length++;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr(" Delta = %ld, Length = %ld, "
+ _vte_debug_print(VTE_DEBUG_RING,
+ " Delta = %ld, Length = %ld, "
"Max = %ld.\n",
ring->delta, ring->length, ring->max);
- }
_vte_ring_validate(ring);
-#endif
return;
}
@@ -147,12 +140,9 @@ _vte_ring_insert(VteRing * ring, long position, gpointer data)
* "lost" to make room for the new item so that the buffer
* doesn't grow (here we scroll off the *bottom*). */
if (ring->free && ring->array[point % ring->max]) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr("Freeing item at position "
+ _vte_debug_print(VTE_DEBUG_RING,
+ "Freeing item at position "
"%ld.\n", point);
- }
-#endif
ring->free(ring->array[point % ring->max],
ring->user_data);
}
@@ -171,13 +161,10 @@ _vte_ring_insert(VteRing * ring, long position, gpointer data)
* maximum length already. */
ring->array[position % ring->max] = data;
ring->length = CLAMP(ring->length + 1, 0, ring->max);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
+ _vte_debug_print(VTE_DEBUG_RING,
+ " Delta = %ld, Length = %ld, Max = %ld.\n",
ring->delta, ring->length, ring->max);
- }
_vte_ring_validate(ring);
-#endif
}
/**
@@ -200,14 +187,11 @@ _vte_ring_insert_preserve(VteRing * ring, long position, gpointer data)
g_return_if_fail(position <= _vte_ring_next(ring));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr("Inserting+ at position %ld.\n", position);
- g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
- ring->delta, ring->length, ring->max);
- }
+ _vte_debug_print(VTE_DEBUG_RING,
+ "Inserting+ at position %ld.\n"
+ " Delta = %ld, Length = %ld, Max = %ld.\n",
+ position, ring->delta, ring->length, ring->max);
_vte_ring_validate(ring);
-#endif
/* Allocate space to save existing elements. */
point = _vte_ring_next(ring);
@@ -250,22 +234,15 @@ void
_vte_ring_remove(VteRing * ring, long position, gboolean free)
{
long i;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr("Removing item at position %ld.\n", position);
- g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
- ring->delta, ring->length, ring->max);
- }
+ _vte_debug_print(VTE_DEBUG_RING,
+ "Removing item at position %ld.\n",
+ " Delta = %ld, Length = %ld, Max = %ld.\n",
+ position, ring->delta, ring->length, ring->max);
_vte_ring_validate(ring);
-#endif
/* Remove the data at this position. */
if (free && ring->array[position % ring->max] && ring->free) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr("Freeing item at position %ld.\n",
- position);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_RING,
+ "Freeing item at position %ld.\n", position);
ring->free(ring->array[position % ring->max], ring->user_data);
}
ring->array[position % ring->max] = NULL;
@@ -282,13 +259,10 @@ _vte_ring_remove(VteRing * ring, long position, gboolean free)
if (ring->length > 0) {
ring->length--;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_RING)) {
- g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
+ _vte_debug_print(VTE_DEBUG_RING,
+ " Delta = %ld, Length = %ld, Max = %ld.\n",
ring->delta, ring->length, ring->max);
- }
_vte_ring_validate(ring);
-#endif
}
/**
diff --git a/src/table.c b/src/table.c
index 5203bc3..a63fee1 100644
--- a/src/table.c
+++ b/src/table.c
@@ -131,14 +131,11 @@ _vte_table_addi(struct _vte_table *table,
/* If this is the terminal node, set the result. */
if (length == 0) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- if (table->result != NULL) {
+ _VTE_DEBUG_ON(VTE_DEBUG_PARSE,
+ if (table->result != NULL)
g_warning("`%s' and `%s' are indistinguishable",
- table->result, result);
- }
- }
-#endif
+ table->result, result)
+ );
table->resultq = g_quark_from_string(result);
table->result = g_quark_to_string(table->resultq);
if (table->original != NULL) {
diff --git a/src/trie.c b/src/trie.c
index fd53380..b20d866 100644
--- a/src/trie.c
+++ b/src/trie.c
@@ -317,11 +317,8 @@ char_class_string_extract(const gunichar *s, gsize length,
for (i = 0; i < len; i++) {
ret[i] &= ~(VTE_ISO2022_ENCODED_WIDTH_MASK);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Extracting string `%ls'.\n", (wchar_t*) ret);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Extracting string `%ls'.\n", (wchar_t*) ret);
memset(&value, 0, sizeof(value));
g_value_init(&value, G_TYPE_POINTER);
@@ -413,12 +410,9 @@ _vte_trie_addx(struct _vte_trie *trie, gunichar *pattern, gsize length,
trie->quark = g_quark_from_string(result);
trie->result = g_quark_to_string(trie->quark);
} else {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_PARSE,
g_warning(_("Duplicate (%s/%s)!"),
- result, trie->result);
- }
-#endif
+ result, trie->result));
}
return;
}
@@ -491,7 +485,8 @@ TRIE_MAYBE_STATIC void
_vte_trie_add(struct _vte_trie *trie, const char *pattern, gsize length,
const char *result, GQuark quark)
{
- char *wpattern, *wpattern_end, *tpattern;
+ const guchar *tpattern;
+ guchar *wpattern, *wpattern_end;
VteConv conv;
gsize wlength;
@@ -509,7 +504,7 @@ _vte_trie_add(struct _vte_trie *trie, const char *pattern, gsize length,
conv = _vte_conv_open(VTE_CONV_GUNICHAR_TYPE, "UTF-8");
g_assert(conv != VTE_INVALID_CONV);
- tpattern = (char*)pattern;
+ tpattern = (const guchar *)pattern;
_vte_conv(conv, &tpattern, &length, &wpattern_end, &wlength);
if (length == 0) {
wlength = (wpattern_end - wpattern) / sizeof(gunichar);
diff --git a/src/vte.c b/src/vte.c
index de07542..4b634e0 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -246,11 +246,7 @@ update_regions (VteTerminal *terminal)
terminal->pvt->update_regions = NULL;
terminal->pvt->invalidated_all = FALSE;
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("-");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, "-");
gdk_window_process_all_updates ();
@@ -274,16 +270,11 @@ _vte_invalidate_cells(VteTerminal *terminal,
return;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_UPDATES)) {
- g_printerr ("Invalidating cells at (%ld,%ld)x(%d,%d).\n",
- column_start, row_start,
- column_count, row_count);
- }
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("?");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_UPDATES,
+ "Invalidating cells at (%ld,%ld)x(%d,%d).\n",
+ column_start, row_start,
+ column_count, row_count);
+ _vte_debug_print (VTE_DEBUG_WORK, "?");
/* Subtract the scrolling offset from the row start so that the
* resulting rectangle is relative to the visible portion of the
@@ -348,11 +339,8 @@ _vte_invalidate_cells(VteTerminal *terminal,
* case updates are coming in really soon. */
add_update_timeout (terminal);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("!");
- }
-#endif
+
+ _vte_debug_print (VTE_DEBUG_WORK, "!");
}
/* Redraw the entire visible portion of the window. */
@@ -370,11 +358,7 @@ _vte_invalidate_all(VteTerminal *terminal)
return;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("*");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, "*");
/* replace invalid regions with one covering the whole terminal */
reset_update_regions (terminal);
@@ -540,12 +524,10 @@ _vte_invalidate_cell(VteTerminal *terminal, glong col, glong row)
_vte_invalidate_cells(terminal,
col, columns,
row, 1);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_UPDATES)) {
- g_printerr("Invalidating cell at (%ld,%ld-%ld).\n",
- row, col, col + columns);
- }
-#endif
+
+ _vte_debug_print(VTE_DEBUG_UPDATES,
+ "Invalidating cell at (%ld,%ld-%ld).\n",
+ row, col, col + columns);
}
/* Cause the cursor to be redrawn. */
@@ -598,12 +580,9 @@ _vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic)
columns++; /* one more for the preedit cursor */
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_UPDATES)) {
- g_printerr("Invalidating cursor at (%ld,%ld-%ld).\n",
- row, column, column + columns);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_UPDATES,
+ "Invalidating cursor at (%ld,%ld-%ld).\n",
+ row, column, column + columns);
_vte_invalidate_cells(terminal,
column, columns,
row, 1);
@@ -679,11 +658,8 @@ vte_invalidate_cursor_periodic (VteTerminal *terminal)
static void
vte_terminal_emit_selection_changed(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `selection-changed'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `selection-changed'.\n");
g_signal_emit_by_name(terminal, "selection-changed");
}
@@ -693,11 +669,10 @@ vte_terminal_emit_commit(VteTerminal *terminal, const gchar *text, guint length)
{
const char *result = NULL;
char *wrapped = NULL;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `commit' of %d bytes.\n", length);
- }
-#endif
+
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `commit' of %d bytes.\n", length);
+
if (length == (guint)-1) {
length = strlen(text);
result = text;
@@ -717,11 +692,8 @@ vte_terminal_emit_commit(VteTerminal *terminal, const gchar *text, guint length)
static void
vte_terminal_emit_emulation_changed(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `emulation-changed'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `emulation-changed'.\n");
g_signal_emit_by_name(terminal, "emulation-changed");
}
@@ -729,11 +701,8 @@ vte_terminal_emit_emulation_changed(VteTerminal *terminal)
static void
vte_terminal_emit_encoding_changed(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `encoding-changed'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `encoding-changed'.\n");
g_signal_emit_by_name(terminal, "encoding-changed");
}
@@ -741,11 +710,8 @@ vte_terminal_emit_encoding_changed(VteTerminal *terminal)
static void
vte_terminal_emit_child_exited(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `child-exited'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `child-exited'.\n");
g_signal_emit_by_name(terminal, "child-exited");
}
@@ -753,11 +719,8 @@ vte_terminal_emit_child_exited(VteTerminal *terminal)
void
_vte_terminal_emit_contents_changed(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `contents-changed'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `contents-changed'.\n");
g_signal_emit_by_name(terminal, "contents-changed");
}
@@ -765,11 +728,8 @@ _vte_terminal_emit_contents_changed(VteTerminal *terminal)
static void
vte_terminal_emit_cursor_moved(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `cursor-moved'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `cursor-moved'.\n");
g_signal_emit_by_name(terminal, "cursor-moved");
}
@@ -777,11 +737,8 @@ vte_terminal_emit_cursor_moved(VteTerminal *terminal)
static void
vte_terminal_emit_eof(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `eof'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `eof'.\n");
g_signal_emit_by_name(terminal, "eof");
}
@@ -790,11 +747,8 @@ static void
vte_terminal_emit_char_size_changed(VteTerminal *terminal,
guint width, guint height)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `char-size-changed'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `char-size-changed'.\n");
g_signal_emit_by_name(terminal, "char-size-changed",
width, height);
}
@@ -803,11 +757,8 @@ vte_terminal_emit_char_size_changed(VteTerminal *terminal,
void
_vte_terminal_emit_status_line_changed(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `status-line-changed'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `status-line-changed'.\n");
g_signal_emit_by_name(terminal, "status-line-changed");
}
@@ -815,11 +766,8 @@ _vte_terminal_emit_status_line_changed(VteTerminal *terminal)
static void
vte_terminal_emit_increase_font_size(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `increase-font-size'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `increase-font-size'.\n");
g_signal_emit_by_name(terminal, "increase-font-size");
}
@@ -827,11 +775,8 @@ vte_terminal_emit_increase_font_size(VteTerminal *terminal)
static void
vte_terminal_emit_decrease_font_size(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `decrease-font-size'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `decrease-font-size'.\n");
g_signal_emit_by_name(terminal, "decrease-font-size");
}
@@ -842,11 +787,8 @@ _vte_terminal_emit_text_inserted(VteTerminal *terminal)
if (!terminal->pvt->accessible_emit) {
return;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `text-inserted'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `text-inserted'.\n");
g_signal_emit_by_name(terminal, "text-inserted");
}
@@ -857,11 +799,8 @@ _vte_terminal_emit_text_deleted(VteTerminal *terminal)
if (!terminal->pvt->accessible_emit) {
return;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `text-deleted'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `text-deleted'.\n");
g_signal_emit_by_name(terminal, "text-deleted");
}
@@ -872,11 +811,8 @@ vte_terminal_emit_text_modified(VteTerminal *terminal)
if (!terminal->pvt->accessible_emit) {
return;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `text-modified'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `text-modified'.\n");
g_signal_emit_by_name(terminal, "text-modified");
}
@@ -887,11 +823,8 @@ vte_terminal_emit_text_scrolled(VteTerminal *terminal, gint delta)
if (!terminal->pvt->accessible_emit) {
return;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `text-scrolled'(%d).\n", delta);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `text-scrolled'(%d).\n", delta);
g_signal_emit_by_name(terminal, "text-scrolled", delta);
}
@@ -901,11 +834,8 @@ vte_terminal_deselect_all(VteTerminal *terminal)
{
if (terminal->pvt->has_selection) {
terminal->pvt->has_selection = FALSE;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Deselecting all text.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Deselecting all text.\n");
vte_terminal_emit_selection_changed(terminal);
_vte_invalidate_all(terminal);
}
@@ -1204,12 +1134,9 @@ vte_terminal_match_check_internal(VteTerminal *terminal,
struct _VteCharAttributes *attr = NULL;
gssize coffset;
struct _vte_regex_match matches[256];
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Checking for match at (%ld,%ld).\n",
- row, column);
- }
-#endif
+
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Checking for match at (%ld,%ld).\n", row, column);
if (tag != NULL) {
*tag = -1;
}
@@ -1235,15 +1162,13 @@ vte_terminal_match_check_internal(VteTerminal *terminal,
break;
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- if (offset < 0) {
+
+ _VTE_DEBUG_ON(VTE_DEBUG_EVENTS,
+ if (offset < 0)
g_printerr("Cursor is not on a character.\n");
- } else {
+ else
g_printerr("Cursor is on character %d.\n", offset);
- }
- }
-#endif
+ );
/* If the pointer isn't on a matchable character, bug out. */
if (offset < 0) {
@@ -1254,11 +1179,8 @@ vte_terminal_match_check_internal(VteTerminal *terminal,
/* If the pointer is on a newline, bug out. */
if ((g_ascii_isspace(terminal->pvt->match_contents[offset])) ||
(terminal->pvt->match_contents[offset] == '\0')) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Cursor is on whitespace.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Cursor is on whitespace.\n");
terminal->pvt->match_previous = -1;
return NULL;
}
@@ -1290,8 +1212,7 @@ vte_terminal_match_check_internal(VteTerminal *terminal,
terminal->pvt->match_attributes->len);
g_assert(matches[j].rm_eo + coffset <=
terminal->pvt->match_attributes->len);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_MISC, ({
char *match;
struct _VteCharAttributes *sattr, *eattr;
match = g_strndup(terminal->pvt->match_contents + matches[j].rm_so + coffset,
@@ -1313,8 +1234,7 @@ vte_terminal_match_check_internal(VteTerminal *terminal,
offset);
g_free(match);
- }
-#endif
+ }));
/* Snip off any final newlines. */
while ((matches[j].rm_eo > matches[j].rm_so) &&
(terminal->pvt->match_contents[coffset + matches[j].rm_eo - 1] == '\n')) {
@@ -1385,20 +1305,14 @@ vte_terminal_match_check(VteTerminal *terminal, glong column, glong row,
char *ret;
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
delta = terminal->pvt->screen->scroll_delta;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Checking for match at (%ld,%ld).\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Checking for match at (%ld,%ld).\n",
row, column);
- }
-#endif
ret = vte_terminal_match_check_internal(terminal,
column, row + delta,
tag, NULL, NULL);
-#ifdef VTE_DEBUG
- if ((ret != NULL) && _vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Matched `%s'.\n", ret);
- }
-#endif
+ _VTE_DEBUG_ON(VTE_DEBUG_EVENTS,
+ if (ret != NULL) g_printerr("Matched `%s'.\n", ret));
return ret;
}
@@ -1407,11 +1321,8 @@ static gboolean
vte_terminal_emit_adjustment_changed(VteTerminal *terminal)
{
if (terminal->pvt->adjustment_changed_tag) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting adjustment_changed.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting adjustment_changed.\n");
terminal->pvt->adjustment_changed_tag = 0;
gtk_adjustment_changed(terminal->adjustment);
}
@@ -1429,12 +1340,9 @@ vte_terminal_queue_adjustment_changed(VteTerminal *terminal)
terminal,
NULL);
} else {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Swallowing duplicate "
- "adjustment-changed signal.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Swallowing duplicate"
+ " adjustment-changed signal.\n");
}
}
@@ -1457,23 +1365,15 @@ _vte_terminal_adjust_adjustments(VteTerminal *terminal, gboolean immediate)
/* The lower value should be the first row in the buffer. */
screen = terminal->pvt->screen;
delta = _vte_ring_delta(screen->row_data);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changing adjustment values "
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changing adjustment values "
"(delta = %ld, scroll = %ld).\n",
delta, screen->scroll_delta);
- }
-#endif
if (terminal->adjustment->lower != delta) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changing lower bound from %lf to %ld\n",
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changing lower bound from %lf to %ld\n",
terminal->adjustment->lower,
delta);
-
- }
-#endif
-
terminal->adjustment->lower = delta;
changed = TRUE;
}
@@ -1490,30 +1390,20 @@ _vte_terminal_adjust_adjustments(VteTerminal *terminal, gboolean immediate)
rows = MAX(_vte_ring_next(terminal->pvt->screen->row_data),
terminal->pvt->screen->cursor_current.row + 1);
if (terminal->adjustment->upper != rows) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changing upper bound from %f to %ld\n",
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changing upper bound from %f to %ld\n",
terminal->adjustment->upper,
rows);
-
- }
-#endif
-
terminal->adjustment->upper = rows;
changed = TRUE;
}
/* The step increment should always be one. */
if (terminal->adjustment->step_increment != 1) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changing step increment from %lf to %ld\n",
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changing step increment from %lf to %ld\n",
terminal->adjustment->step_increment,
terminal->row_count);
-
- }
-#endif
-
terminal->adjustment->step_increment = 1;
changed = TRUE;
}
@@ -1521,15 +1411,10 @@ _vte_terminal_adjust_adjustments(VteTerminal *terminal, gboolean immediate)
/* Set the number of rows the user sees to the number of rows the
* user sees. */
if (terminal->adjustment->page_size != terminal->row_count) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changing page size from %f to %ld\n",
- terminal->adjustment->page_size,
- terminal->row_count);
-
- }
-#endif
-
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changing page size from %f to %ld\n",
+ terminal->adjustment->page_size,
+ terminal->row_count);
terminal->adjustment->page_size = terminal->row_count;
changed = TRUE;
}
@@ -1537,16 +1422,11 @@ _vte_terminal_adjust_adjustments(VteTerminal *terminal, gboolean immediate)
/* Clicking in the empty area should scroll one screen, so set the
* page size to the number of visible rows. */
if (terminal->adjustment->page_increment != terminal->row_count) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changing page increment from "
- "%f to %ld\n",
- terminal->adjustment->page_increment,
- terminal->row_count);
-
- }
-#endif
-
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changing page increment from "
+ "%f to %ld\n",
+ terminal->adjustment->page_increment,
+ terminal->row_count);
terminal->adjustment->page_increment = terminal->row_count;
changed = TRUE;
}
@@ -1554,35 +1434,24 @@ _vte_terminal_adjust_adjustments(VteTerminal *terminal, gboolean immediate)
/* Set the scrollbar adjustment to where the screen wants it to be. */
if (floor(terminal->adjustment->value) !=
screen->scroll_delta) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changing adjustment scroll position: "
- "%ld\n", screen->scroll_delta);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changing adjustment scroll position: "
+ "%ld\n", screen->scroll_delta);
/* This emits a "value-changed" signal, so no need to screw
* with anything else for just this. */
gtk_adjustment_set_value(terminal->adjustment,
screen->scroll_delta);
-
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changed adjustment scroll position: "
- "%ld\n", screen->scroll_delta);
- }
-#endif
-
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changed adjustment scroll position: "
+ "%ld\n", screen->scroll_delta);
}
/* If anything changed, signal that there was a change. */
if (changed == TRUE) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Changed adjustment values "
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Changed adjustment values "
"(delta = %ld, scroll = %ld).\n",
delta, terminal->pvt->screen->scroll_delta);
- }
-#endif
if (immediate) {
gtk_adjustment_changed(terminal->adjustment);
} else {
@@ -1596,11 +1465,7 @@ static void
vte_terminal_scroll_pages(VteTerminal *terminal, gint pages)
{
glong destination;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Scrolling %d pages.\n", pages);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_IO, "Scrolling %d pages.\n", pages);
/* Calculate the ideal position where we want to be before clamping. */
destination = floor(gtk_adjustment_get_value(terminal->adjustment));
destination += (pages * terminal->row_count);
@@ -1636,12 +1501,8 @@ vte_terminal_maybe_scroll_to_bottom(VteTerminal *terminal)
terminal->pvt->screen->insert_delta)) {
delta = terminal->pvt->screen->insert_delta;
gtk_adjustment_set_value(terminal->adjustment, delta);
-
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Snapping to bottom of screen\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Snapping to bottom of screen\n");
}
}
@@ -1701,7 +1562,7 @@ vte_terminal_set_encoding(VteTerminal *terminal, const char *codeset)
if ((_vte_buffer_length(terminal->pvt->outgoing) > 0) &&
(old_codeset != NULL)) {
/* Convert back to UTF-8. */
- obuf1 = g_convert(terminal->pvt->outgoing->bytes,
+ obuf1 = g_convert((gchar *)terminal->pvt->outgoing->bytes,
_vte_buffer_length(terminal->pvt->outgoing),
"UTF-8",
old_codeset,
@@ -1731,12 +1592,9 @@ vte_terminal_set_encoding(VteTerminal *terminal, const char *codeset)
_vte_iso2022_state_set_codeset(terminal->pvt->iso2022,
terminal->pvt->encoding);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Set terminal encoding to `%s'.\n",
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Set terminal encoding to `%s'.\n",
terminal->pvt->encoding);
- }
-#endif
vte_terminal_emit_encoding_changed(terminal);
}
@@ -1855,11 +1713,8 @@ _vte_terminal_set_pointer_visible(VteTerminal *terminal, gboolean visible)
terminal->pvt->mouse_hilite_tracking ||
terminal->pvt->mouse_cell_motion_tracking ||
terminal->pvt->mouse_all_motion_tracking) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_CURSOR)) {
- g_printerr("Setting mousing cursor.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_CURSOR,
+ "Setting mousing cursor.\n");
cursor = terminal->pvt->mouse_mousing_cursor;
} else
if ((terminal->pvt->match_previous > -1) &&
@@ -1869,20 +1724,13 @@ _vte_terminal_set_pointer_visible(VteTerminal *terminal, gboolean visible)
terminal->pvt->match_previous);
cursor = regex->cursor;
} else {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_CURSOR)) {
- g_printerr("Setting default mouse "
- "cursor.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_CURSOR,
+ "Setting default mouse cursor.\n");
cursor = terminal->pvt->mouse_default_cursor;
}
} else {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_CURSOR)) {
- g_printerr("Setting to invisible cursor.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_CURSOR,
+ "Setting to invisible cursor.\n");
cursor = terminal->pvt->mouse_inviso_cursor;
}
if (cursor) {
@@ -1903,13 +1751,10 @@ _vte_terminal_set_pointer_visible(VteTerminal *terminal, gboolean visible)
GtkWidget *
vte_terminal_new(void)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_new()\n");
- }
-#endif
-
- return g_object_new(vte_terminal_get_type(), NULL);
+ /* we don't parse VTE_DEBUG_FLAGS until class init ... */
+ GType type = vte_terminal_get_type ();
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_new()\n");
+ return g_object_new(type, NULL);
}
/* Set up a palette entry with a more-or-less match for the requested color. */
@@ -1968,22 +1813,16 @@ vte_terminal_generate_bold(const struct vte_palette_entry *foreground,
r = fy + 1.402 * fcr;
g = fy + 0.34414 * fcb - 0.71414 * fcr;
b = fy + 1.722 * fcb;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Calculated bold (%d, %d, %d) = (%lf,%lf,%lf)",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Calculated bold (%d, %d, %d) = (%lf,%lf,%lf)",
foreground->red, foreground->green, foreground->blue,
r, g, b);
- }
-#endif
bold->red = CLAMP(r, 0, 0xffff);
bold->green = CLAMP(g, 0, 0xffff);
bold->blue = CLAMP(b, 0, 0xffff);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("= (%04x,%04x,%04x).\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "= (%04x,%04x,%04x).\n",
bold->red, bold->green, bold->blue);
- }
-#endif
}
/**
@@ -2301,12 +2140,9 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
/* If we've enabled the special drawing set, map the characters to
* Unicode. */
if (screen->defaults.alternate) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
- g_printerr("Attempting charset substitution"
+ _vte_debug_print(VTE_DEBUG_SUBSTITUTION,
+ "Attempting charset substitution"
"for 0x%04x.\n", c);
- }
-#endif
/* See if there's a mapping for it. */
cell.c = _vte_iso2022_process_single(terminal->pvt->iso2022,
c, '0');
@@ -2335,15 +2171,11 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
}
c &= ~(VTE_ISO2022_ENCODED_WIDTH_MASK);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO) && _vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Inserting %ld %c (%d/%d)(%d), delta = %ld, ",
- (long)c,
- c < 256 ? c : ' ',
+ _vte_debug_print(VTE_DEBUG_IO|VTE_DEBUG_PARSE,
+ "Inserting %ld %c (%d/%d)(%d), delta = %ld, ",
+ (long)c, c < 256 ? c : ' ',
screen->defaults.fore, screen->defaults.back,
columns, (long)screen->insert_delta);
- }
-#endif
/* If we're autowrapping here, do it. */
col = screen->cursor_current.col;
@@ -2497,12 +2329,9 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
/* We added text, so make a note of it. */
terminal->pvt->text_inserted_count++;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO) && _vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("insertion delta => %ld.\n",
+ _vte_debug_print(VTE_DEBUG_IO|VTE_DEBUG_PARSE,
+ "insertion delta => %ld.\n",
(long)screen->insert_delta);
- }
-#endif
}
#ifdef VTE_DEBUG
@@ -2552,11 +2381,8 @@ vte_terminal_handle_sequence(VteTerminal *terminal,
VteTerminalSequenceHandler handler;
gboolean ret;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- display_control_sequence(match_s, params);
- }
-#endif
+ _VTE_DEBUG_ON(VTE_DEBUG_PARSE,
+ display_control_sequence(match_s, params));
/* Find the handler for this control sequence. */
handler = _vte_sequence_get_handler (match_s, match);
@@ -2590,8 +2416,7 @@ vte_terminal_catch_child_exited(VteReaper *reaper, int pid, int status,
VteTerminal *terminal)
{
if (pid == terminal->pvt->pty_pid) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_LIFECYCLE)) {
+ _VTE_DEBUG_ON (VTE_DEBUG_LIFECYCLE, ({
g_printerr ("Child[%d] exited with status %d\n",
pid, status);
#ifdef HAVE_SYS_WAIT_H
@@ -2603,8 +2428,7 @@ vte_terminal_catch_child_exited(VteReaper *reaper, int pid, int status,
pid, WTERMSIG (status));
}
#endif
- }
-#endif
+ }));
/* Disconnect from the reaper. */
if (terminal->pvt->pty_reaper != NULL) {
g_signal_handlers_disconnect_by_func(terminal->pvt->pty_reaper,
@@ -2854,31 +2678,22 @@ vte_terminal_fork_command(VteTerminal *terminal,
pwd = getpwuid(getuid());
if (pwd != NULL) {
terminal->pvt->shell = pwd->pw_shell;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Using user's shell (%s).\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Using user's shell (%s).\n",
terminal->pvt->shell);
- }
-#endif
}
}
if (terminal->pvt->shell == NULL) {
if (getenv ("SHELL")) {
terminal->pvt->shell = getenv ("SHELL");
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Using $SHELL shell (%s).\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Using $SHELL shell (%s).\n",
terminal->pvt->shell);
- }
-#endif
} else {
terminal->pvt->shell = "/bin/sh";
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Using default shell (%s).\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Using default shell (%s).\n",
terminal->pvt->shell);
- }
-#endif
}
}
command = terminal->pvt->shell;
@@ -2990,14 +2805,13 @@ vte_terminal_emit_pending_text_signals(VteTerminal *terminal, GQuark quark)
{"ta", 0},
{"character-attributes", 0},
};
- GQuark tmp;
guint i;
if (quark != 0) {
for (i = 0; i < G_N_ELEMENTS(non_visual_quarks); i++) {
if (non_visual_quarks[i].quark == 0) {
- tmp = g_quark_from_static_string(non_visual_quarks[i].name);
- non_visual_quarks[i].quark = tmp;
+ non_visual_quarks[i].quark =
+ g_quark_from_static_string(non_visual_quarks[i].name);
}
if (quark == non_visual_quarks[i].quark) {
return;
@@ -3006,31 +2820,22 @@ vte_terminal_emit_pending_text_signals(VteTerminal *terminal, GQuark quark)
}
if (terminal->pvt->text_modified_flag) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting buffered `text-modified'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting buffered `text-modified'.\n");
vte_terminal_emit_text_modified(terminal);
terminal->pvt->text_modified_flag = FALSE;
}
if (terminal->pvt->text_inserted_count) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting buffered `text-inserted' "
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting buffered `text-inserted' "
"(%ld).\n", terminal->pvt->text_inserted_count);
- }
-#endif
_vte_terminal_emit_text_inserted(terminal);
terminal->pvt->text_inserted_count = 0;
}
if (terminal->pvt->text_deleted_count) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting buffered `text-deleted' "
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting buffered `text-deleted' "
"(%ld).\n", terminal->pvt->text_deleted_count);
- }
-#endif
_vte_terminal_emit_text_deleted(terminal);
terminal->pvt->text_deleted_count = 0;
}
@@ -3055,18 +2860,14 @@ vte_terminal_process_incoming(VteTerminal *terminal)
gboolean invalidated_text;
GArray *unichars;
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Handler processing %d bytes.\n",
+ _vte_buffer_length(terminal->pvt->incoming));
+ _vte_debug_print (VTE_DEBUG_WORK, "(");
+
bottom = (terminal->pvt->screen->insert_delta ==
terminal->pvt->screen->scroll_delta);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Handler processing %d bytes.\n",
- _vte_buffer_length(terminal->pvt->incoming));
- }
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("(");
- }
-#endif
/* Save the current cursor position. */
screen = terminal->pvt->screen;
cursor = screen->cursor_current;
@@ -3196,27 +2997,24 @@ vte_terminal_process_incoming(VteTerminal *terminal)
continue;
}
}
-#ifdef VTE_DEBUG
- c = c & ~VTE_ISO2022_ENCODED_WIDTH_MASK;
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- if (c > 255) {
- g_printerr("U+%04lx\n", (long) c);
+ _VTE_DEBUG_ON(VTE_DEBUG_PARSE, ({
+ gunichar cc = c & ~VTE_ISO2022_ENCODED_WIDTH_MASK;
+ if (cc > 255) {
+ g_printerr("U+%04lx\n", (long) cc);
} else {
- if (c > 127) {
+ if (cc > 127) {
g_printerr("%ld = ",
- (long) c);
+ (long) cc);
}
- if (c < 32) {
+ if (cc < 32) {
g_printerr("^%lc\n",
- (wint_t)c + 64);
+ (wint_t)cc + 64);
} else {
g_printerr("`%lc'\n",
- (wint_t)c);
+ (wint_t)cc);
}
}
- }
- c = wbuf[start];
-#endif
+ }));
if (c != 0) {
/* Insert the character. */
_vte_terminal_insert_char(terminal, c,
@@ -3247,14 +3045,11 @@ vte_terminal_process_incoming(VteTerminal *terminal)
* middle of the sequence, then it's just garbage data,
* and for compatibility, we should discard it. */
if (wbuf + wcount > next) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Invalid control "
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Invalid control "
"sequence, discarding %d "
"characters.\n",
next - (wbuf + start));
- }
-#endif
/* Discard. */
start = next - wbuf + 1;
} else {
@@ -3385,16 +3180,11 @@ vte_terminal_process_incoming(VteTerminal *terminal)
&rect);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("%ld chars and %ld bytes left to process.\n",
+ _vte_debug_print(VTE_DEBUG_IO,
+ "%ld chars and %ld bytes left to process.\n",
(long) unichars->len,
(long) _vte_buffer_length(terminal->pvt->incoming));
- }
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr (")");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, ")");
return again;
}
@@ -3408,11 +3198,7 @@ vte_terminal_io_read(GIOChannel *channel,
int err = 0;
gboolean eof, leave_open = TRUE;
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr (".");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, ".");
/* Check for end-of-file. */
eof = FALSE;
@@ -3511,9 +3297,8 @@ vte_terminal_io_write(GIOChannel *channel,
count = write(fd, terminal->pvt->outgoing->bytes,
_vte_buffer_length(terminal->pvt->outgoing));
if (count != -1) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- int i;
+ _VTE_DEBUG_ON(VTE_DEBUG_IO, ({
+ gssize i;
for (i = 0; i < count; i++) {
g_printerr("Wrote %c%c\n",
((guint8)terminal->pvt->outgoing->bytes[i]) >= 32 ?
@@ -3522,8 +3307,7 @@ vte_terminal_io_write(GIOChannel *channel,
terminal->pvt->outgoing->bytes[i] :
((guint8)terminal->pvt->outgoing->bytes[i]) + 64);
}
- }
-#endif
+ }));
_vte_buffer_consume(terminal->pvt->outgoing, count);
}
@@ -3543,8 +3327,10 @@ vte_terminal_send(VteTerminal *terminal, const char *encoding,
const void *data, gssize length,
gboolean local_echo, gboolean newline_stuff)
{
- gssize icount, ocount;
- char *ibuf, *obuf, *obufptr, *cooked;
+ gsize icount, ocount;
+ const guchar *ibuf;
+ guchar *obuf, *obufptr;
+ gchar *cooked;
VteConv conv;
long crcount, cooked_length, i;
@@ -3559,12 +3345,12 @@ vte_terminal_send(VteTerminal *terminal, const char *encoding,
g_assert(conv != VTE_INVALID_CONV);
icount = length;
- ibuf = (char *) data;
+ ibuf = data;
ocount = ((length + 1) * VTE_UTF8_BPC) + 1;
_vte_buffer_set_minimum_size(terminal->pvt->conv_buffer, ocount);
obuf = obufptr = terminal->pvt->conv_buffer->bytes;
- if (_vte_conv(conv, &ibuf, &icount, &obuf, &ocount) == -1) {
+ if (_vte_conv(conv, &ibuf, &icount, &obuf, &ocount) == (gsize)-1) {
g_warning(_("Error (%s) converting data for child, dropping."),
strerror(errno));
} else {
@@ -3595,7 +3381,7 @@ vte_terminal_send(VteTerminal *terminal, const char *encoding,
}
}
} else {
- cooked = obufptr;
+ cooked = (gchar *)obufptr;
cooked_length = obuf - obufptr;
}
/* Tell observers that we're sending this to the child. */
@@ -3628,8 +3414,7 @@ vte_terminal_send(VteTerminal *terminal, const char *encoding,
if ((cooked_length > 0) && (terminal->pvt->pty_master != -1)) {
_vte_buffer_append(terminal->pvt->outgoing,
cooked, cooked_length);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_KEYBOARD, ({
for (i = 0; i < cooked_length; i++) {
if ((((guint8) cooked[i]) < 32) ||
(((guint8) cooked[i]) > 127)) {
@@ -3644,8 +3429,7 @@ vte_terminal_send(VteTerminal *terminal, const char *encoding,
cooked[i]);
}
}
- }
-#endif
+ }));
/* If we need to start waiting for the child pty to
* become available for writing, set that up here. */
_vte_terminal_connect_pty_write(terminal);
@@ -3729,11 +3513,8 @@ vte_terminal_feed_child_using_modes(VteTerminal *terminal,
static void
vte_terminal_im_commit(GtkIMContext *im_context, gchar *text, VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Input method committed `%s'.\n", text);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Input method committed `%s'.\n", text);
vte_terminal_feed_child_using_modes(terminal, text, -1);
/* Committed text was committed because the user pressed a key, so
* we need to obey the scroll-on-keystroke setting. */
@@ -3746,11 +3527,8 @@ vte_terminal_im_commit(GtkIMContext *im_context, gchar *text, VteTerminal *termi
static void
vte_terminal_im_preedit_start(GtkIMContext *im_context, VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Input method pre-edit started.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Input method pre-edit started.\n");
terminal->pvt->im_preedit_active = TRUE;
}
@@ -3758,11 +3536,8 @@ vte_terminal_im_preedit_start(GtkIMContext *im_context, VteTerminal *terminal)
static void
vte_terminal_im_preedit_end(GtkIMContext *im_context, VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Input method pre-edit ended.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Input method pre-edit ended.\n");
terminal->pvt->im_preedit_active = FALSE;
}
@@ -3775,12 +3550,9 @@ vte_terminal_im_preedit_changed(GtkIMContext *im_context, VteTerminal *terminal)
gint cursor;
gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Input method pre-edit changed (%s,%d).\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Input method pre-edit changed (%s,%d).\n",
str, cursor);
- }
-#endif
/* Queue the area where the current preedit string is being displayed
* for repainting. */
@@ -3804,11 +3576,7 @@ static gboolean
vte_terminal_configure_toplevel(GtkWidget *widget, GdkEventConfigure *event,
VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Top level parent configured.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS, "Top level parent configured.\n");
if (terminal->pvt->bg_transparent) {
/* We have to repaint the entire window, because we don't get
@@ -3827,12 +3595,7 @@ vte_terminal_hierarchy_changed(GtkWidget *widget, GtkWidget *old_toplevel,
{
GtkWidget *toplevel;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Hierarchy changed.\n");
- }
-#endif
-
+ _vte_debug_print(VTE_DEBUG_EVENTS, "Hierarchy changed.\n");
if (old_toplevel != NULL) {
g_signal_handlers_disconnect_by_func(old_toplevel,
vte_terminal_configure_toplevel,
@@ -3853,11 +3616,8 @@ vte_terminal_style_changed(GtkWidget *widget, GtkStyle *style, gpointer data)
{
VteTerminal *terminal;
if (!GTK_WIDGET_REALIZED(widget)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Don't change style if we aren't realized.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Don't change style if we aren't realized.\n");
return;
}
@@ -3972,14 +3732,11 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
_vte_terminal_set_pointer_visible(terminal, FALSE);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Keypress, modifiers=0x%x, "
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Keypress, modifiers=0x%x, "
"keyval=0x%x, raw string=`%s'.\n",
terminal->pvt->modifiers,
keyval, event->string);
- }
-#endif
/* We steal many keypad keys here. */
if (!terminal->pvt->im_preedit_active) {
@@ -4032,11 +3789,8 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
if (GTK_WIDGET_REALIZED(terminal) &&
gtk_im_context_filter_keypress(terminal->pvt->im_context,
event)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Keypress taken by IM.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Keypress taken by IM.\n");
return TRUE;
}
}
@@ -4225,14 +3979,12 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
}
}
}
-#ifdef VTE_DEBUG
- if (normal && _vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Keypress, modifiers=0x%x, "
- "keyval=0x%x, cooked string=`%s'.\n",
- terminal->pvt->modifiers,
- keyval, normal);
- }
-#endif
+ _VTE_DEBUG_ON(VTE_DEBUG_EVENTS,
+ if (normal) g_printerr(
+ "Keypress, modifiers=0x%x, "
+ "keyval=0x%x, cooked string=`%s'.\n",
+ terminal->pvt->modifiers,
+ keyval, normal));
}
/* If we got normal characters, send them to the child. */
if (normal != NULL) {
@@ -4475,14 +4227,10 @@ vte_terminal_paste_cb(GtkClipboard *clipboard, const gchar *text, gpointer data)
long length;
terminal = data;
if (text != NULL) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Pasting %d UTF-8 bytes.\n",
- strlen(text));
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Pasting %d UTF-8 bytes.\n", strlen(text));
if (!g_utf8_validate(text, -1, NULL)) {
- g_warning(_("Error (%s) converting data for child, dropping."), strerror(EINVAL));
+ g_warning(_("Error (%s) converting data for child, dropping."), g_strerror(EINVAL));
return;
}
@@ -4697,12 +4445,9 @@ vte_terminal_match_hilite_clear(VteTerminal *terminal)
terminal->pvt->match_end.row = -2;
terminal->pvt->match_end.column = -2;
if ((srow < erow) || ((srow == erow) && (scolumn < ecolumn))) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Repainting (%ld,%ld) to (%ld,%ld).\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Repainting (%ld,%ld) to (%ld,%ld).\n",
srow, scolumn, erow, ecolumn);
- }
-#endif
_vte_invalidate_cells(terminal,
0, terminal->column_count,
srow, erow - srow + 1);
@@ -4742,11 +4487,7 @@ vte_terminal_match_hilite(VteTerminal *terminal, double x, double y)
/* If there are no matches, repaint what we had matched before. */
if (match == NULL) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("No matches.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS, "No matches.\n");
vte_terminal_match_hilite_clear(terminal);
} else {
/* Save the old hilite area. */
@@ -4770,15 +4511,12 @@ vte_terminal_match_hilite(VteTerminal *terminal, double x, double y)
terminal->pvt->match_start.row,
terminal->pvt->match_end.row -
terminal->pvt->match_start.row + 1);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Matched (%ld,%ld) to (%ld,%ld).\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Matched (%ld,%ld) to (%ld,%ld).\n",
terminal->pvt->match_start.column,
terminal->pvt->match_start.row,
terminal->pvt->match_end.column,
terminal->pvt->match_end.row);
- }
-#endif
/* Repaint what used to be hilited, if anything. */
_vte_invalidate_cells(terminal,
0, terminal->column_count,
@@ -4794,11 +4532,7 @@ vte_terminal_clear_cb(GtkClipboard *clipboard, gpointer owner)
VteTerminal *terminal;
terminal = owner;
if (terminal->pvt->has_selection) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Lost selection.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION, "Lost selection.\n");
vte_terminal_deselect_all(terminal);
}
}
@@ -4811,8 +4545,7 @@ vte_terminal_copy_cb(GtkClipboard *clipboard, GtkSelectionData *data,
VteTerminal *terminal;
terminal = owner;
if (terminal->pvt->selection != NULL) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_SELECTION, ({
int i;
g_printerr("Setting selection (%d UTF-8 bytes.)\n",
strlen(terminal->pvt->selection));
@@ -4820,8 +4553,7 @@ vte_terminal_copy_cb(GtkClipboard *clipboard, GtkSelectionData *data,
g_printerr("0x%04x\n",
terminal->pvt->selection[i]);
}
- }
-#endif
+ }));
gtk_selection_data_set_text(data, terminal->pvt->selection, -1);
}
}
@@ -5165,11 +4897,8 @@ vte_terminal_copy(VteTerminal *terminal, GdkAtom board)
/* Place the text on the clipboard. */
if (terminal->pvt->selection != NULL) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Assuming ownership of selection.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Assuming ownership of selection.\n");
if (!targets) {
GtkTargetList *list;
GList *l;
@@ -5204,11 +4933,8 @@ vte_terminal_paste(VteTerminal *terminal, GdkAtom board)
GtkClipboard *clipboard;
clipboard = vte_terminal_clipboard_get(terminal, board);
if (clipboard != NULL) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Requesting clipboard contents.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Requesting clipboard contents.\n");
gtk_clipboard_request_text(clipboard,
vte_terminal_paste_cb,
terminal);
@@ -5267,13 +4993,10 @@ vte_terminal_start_selection(VteTerminal *terminal, GdkEventButton *event,
_vte_invalidate_cells(terminal,
0, terminal->column_count,
terminal->pvt->selection_start.y, 1);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Selection started at (%ld,%ld).\n",
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Selection started at (%ld,%ld).\n",
terminal->pvt->selection_start.x,
terminal->pvt->selection_start.y);
- }
-#endif
vte_terminal_emit_selection_changed(terminal);
/* Temporarily stop caring about input from the child. */
@@ -5310,13 +5033,10 @@ vte_terminal_extend_selection(VteTerminal *terminal, double x, double y,
/* Record the origin of the selection. */
terminal->pvt->selection_origin =
terminal->pvt->selection_restart_origin;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Selection delayed start at (%lf,%lf).\n",
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Selection delayed start at (%lf,%lf).\n",
terminal->pvt->selection_origin.x / width,
terminal->pvt->selection_origin.y / height);
- }
-#endif
}
/* Recognize that we've got a selected block. */
@@ -5362,12 +5082,9 @@ vte_terminal_extend_selection(VteTerminal *terminal, double x, double y,
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Selection is (%lf,%lf) to (%lf,%lf).\n",
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Selection is (%lf,%lf) to (%lf,%lf).\n",
start->x, start->y, end->x, end->y);
- }
-#endif
/* Recalculate the selection area in terms of cell positions. */
terminal->pvt->selection_start.x = MAX(0, start->x / width);
@@ -5602,15 +5319,12 @@ vte_terminal_extend_selection(VteTerminal *terminal, double x, double y,
if (!terminal->pvt->block_mode &&
((old_start.x != terminal->pvt->selection_start.x) ||
(old_start.y != terminal->pvt->selection_start.y))) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Refreshing lines %ld to %ld.\n",
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Refreshing lines %ld to %ld.\n",
MIN(old_start.y,
terminal->pvt->selection_start.y),
MAX(old_start.y,
terminal->pvt->selection_start.y));
- }
-#endif
_vte_invalidate_cells(terminal,
0,
terminal->column_count,
@@ -5624,13 +5338,10 @@ vte_terminal_extend_selection(VteTerminal *terminal, double x, double y,
if (!terminal->pvt->block_mode &&
((old_end.x != terminal->pvt->selection_end.x) ||
(old_end.y != terminal->pvt->selection_end.y))) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Refreshing selection, lines %ld to %ld.\n",
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Refreshing selection, lines %ld to %ld.\n",
MIN(old_end.y, terminal->pvt->selection_end.y),
MAX(old_end.y, terminal->pvt->selection_end.y));
- }
-#endif
_vte_invalidate_cells(terminal,
0,
terminal->column_count,
@@ -5642,15 +5353,12 @@ vte_terminal_extend_selection(VteTerminal *terminal, double x, double y,
terminal->pvt->selection_end.y) + 1);
}
if (invalidate_selected) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Invalidating selection, lines %ld to %ld.\n",
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Invalidating selection, lines %ld to %ld.\n",
MIN(terminal->pvt->selection_start.y,
terminal->pvt->selection_end.y),
MAX(terminal->pvt->selection_start.y,
terminal->pvt->selection_end.y));
- }
-#endif
_vte_invalidate_cells(terminal,
0,
terminal->column_count,
@@ -5662,16 +5370,13 @@ vte_terminal_extend_selection(VteTerminal *terminal, double x, double y,
terminal->pvt->selection_end.y) + 1);
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Selection changed to "
+ _vte_debug_print(VTE_DEBUG_SELECTION,
+ "Selection changed to "
"(%ld,%ld) to (%ld,%ld).\n",
terminal->pvt->selection_start.x,
terminal->pvt->selection_start.y,
terminal->pvt->selection_end.x,
terminal->pvt->selection_end.y);
- }
-#endif
vte_terminal_emit_selection_changed(terminal);
}
@@ -5694,11 +5399,7 @@ vte_terminal_autoscroll(VteTerminal *terminal)
gtk_adjustment_set_value(terminal->adjustment, adj);
extend = TRUE;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Autoscrolling down.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS, "Autoscrolling down.\n");
}
if (terminal->pvt->mouse_last_y >=
terminal->row_count * terminal->char_height) {
@@ -5711,11 +5412,7 @@ vte_terminal_autoscroll(VteTerminal *terminal)
gtk_adjustment_set_value(terminal->adjustment, adj);
extend = TRUE;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Autoscrolling up.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS, "Autoscrolling up.\n");
}
if (extend) {
/* Don't select off-screen areas. That just confuses people. */
@@ -5781,12 +5478,8 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
terminal->pvt->mouse_cell_motion_tracking ||
terminal->pvt->mouse_all_motion_tracking;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Motion notify (%lf,%lf).\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS, "Motion notify (%lf,%lf).\n",
event->x, event->y);
- }
-#endif
/* Show the cursor. */
_vte_terminal_set_pointer_visible(terminal, TRUE);
@@ -5800,11 +5493,7 @@ vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
case GDK_MOTION_NOTIFY:
switch (terminal->pvt->mouse_last_button) {
case 1:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Mousing drag 1.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS, "Mousing drag 1.\n");
/* If user hit ctrl, change selection mode. */
if ((terminal->pvt->modifiers & GDK_CONTROL_MASK) &&
!terminal->pvt->block_mode) {
@@ -5901,23 +5590,17 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
switch (event->type) {
case GDK_BUTTON_PRESS:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Button %d single-click at (%lf,%lf)\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Button %d single-click at (%lf,%lf)\n",
event->button,
event->x - VTE_PAD_WIDTH,
event->y - VTE_PAD_WIDTH +
(terminal->char_height * delta));
- }
-#endif
/* Handle this event ourselves. */
switch (event->button) {
case 1:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Handling click ourselves.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Handling click ourselves.\n");
/* Grab focus. */
if (!GTK_WIDGET_HAS_FOCUS(widget)) {
gtk_widget_grab_focus(widget);
@@ -5988,15 +5671,12 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
}
break;
case GDK_2BUTTON_PRESS:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Button %d double-click at (%lf,%lf)\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Button %d double-click at (%lf,%lf)\n",
event->button,
event->x - VTE_PAD_WIDTH,
event->y - VTE_PAD_WIDTH +
(terminal->char_height * delta));
- }
-#endif
switch (event->button) {
case 1:
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
@@ -6017,15 +5697,12 @@ vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
}
break;
case GDK_3BUTTON_PRESS:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Button %d triple-click at (%lf,%lf).\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Button %d triple-click at (%lf,%lf).\n",
event->button,
event->x - VTE_PAD_WIDTH,
event->y - VTE_PAD_WIDTH +
(terminal->char_height * delta));
- }
-#endif
switch (event->button) {
case 1:
if ((terminal->pvt->modifiers & GDK_SHIFT_MASK) ||
@@ -6089,14 +5766,11 @@ vte_terminal_button_release(GtkWidget *widget, GdkEventButton *event)
switch (event->type) {
case GDK_BUTTON_RELEASE:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Button %d released at (%lf,%lf).\n",
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Button %d released at (%lf,%lf).\n",
event->button,
event->x - VTE_PAD_WIDTH,
event->y - VTE_PAD_WIDTH);
- }
-#endif
switch (event->button) {
case 1:
/* If Shift is held down, or we're not in events mode,
@@ -6152,11 +5826,9 @@ vte_terminal_focus_in(GtkWidget *widget, GdkEventFocus *event)
{
VteTerminal *terminal;
GdkModifierType modifiers;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Focus in.\n");
- }
-#endif
+
+ _vte_debug_print(VTE_DEBUG_EVENTS, "Focus in.\n");
+
terminal = VTE_TERMINAL(widget);
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
/* Read the keyboard modifiers, though they're probably garbage. */
@@ -6186,11 +5858,7 @@ vte_terminal_focus_out(GtkWidget *widget, GdkEventFocus *event)
{
VteTerminal *terminal;
GdkModifierType modifiers;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Focus out.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS, "Focus out.\n");
terminal = VTE_TERMINAL(widget);
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
/* Read the keyboard modifiers, though they're probably garbage. */
@@ -6330,24 +5998,18 @@ vte_terminal_set_font_full(VteTerminal *terminal,
pango_font_description_set_family_static (desc, "monospace");
if (font_desc != NULL) {
pango_font_description_merge (desc, font_desc, TRUE);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_MISC, ({
if (desc) {
char *tmp;
tmp = pango_font_description_to_string(desc);
g_printerr("Using pango font \"%s\".\n", tmp);
g_free (tmp);
}
- }
-#endif
- }
-#ifdef VTE_DEBUG
- else {
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Using default monospace font.\n");
- }
+ }));
+ } else {
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Using default monospace font.\n");
}
-#endif
/* check for any change */
if (antialias == terminal->pvt->fontantialias &&
@@ -6483,12 +6145,9 @@ void
vte_terminal_set_size(VteTerminal *terminal, glong columns, glong rows)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Setting PTY size to %ldx%ld.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Setting PTY size to %ldx%ld.\n",
columns, rows);
- }
-#endif
if (terminal->pvt->pty_master != -1) {
/* Try to set the terminal size. */
if (_vte_pty_set_size(terminal->pvt->pty_master, columns, rows) != 0) {
@@ -6526,22 +6185,16 @@ vte_terminal_handle_scroll(VteTerminal *terminal)
}
if (dy != 0) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Scrolling by %ld\n", dy);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Scrolling by %ld\n", dy);
_vte_terminal_match_contents_clear(terminal);
_vte_terminal_scroll_region(terminal, screen->scroll_delta,
terminal->row_count, -dy);
vte_terminal_emit_text_scrolled(terminal, dy);
_vte_terminal_emit_contents_changed(terminal);
+ } else {
+ _vte_debug_print(VTE_DEBUG_IO, "Not scrolling\n");
}
-#ifdef VTE_DEBUG
- else if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Not scrolling\n");
- }
-#endif
}
/* Set the adjustment objects used by the terminal widget. */
@@ -6593,11 +6246,8 @@ vte_terminal_set_emulation(VteTerminal *terminal, const char *emulation)
emulation = vte_terminal_get_default_emulation(terminal);
}
terminal->pvt->emulation = g_intern_string(emulation);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Setting emulation to `%s'...\n", emulation);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Setting emulation to `%s'...\n", emulation);
/* Find and read the right termcap file. */
vte_terminal_set_termcap(terminal, NULL, FALSE);
@@ -6695,21 +6345,13 @@ vte_terminal_set_termcap(VteTerminal *terminal, const char *path,
}
terminal->pvt->termcap_path = path;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Loading termcap `%s'...",
+ _vte_debug_print(VTE_DEBUG_MISC, "Loading termcap `%s'...",
terminal->pvt->termcap_path);
- }
-#endif
if (terminal->pvt->termcap) {
_vte_termcap_free(terminal->pvt->termcap);
}
terminal->pvt->termcap = _vte_termcap_new(terminal->pvt->termcap_path);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC, "\n");
if (reset) {
vte_terminal_set_emulation(terminal, terminal->pvt->emulation);
}
@@ -6722,12 +6364,9 @@ vte_terminal_reset_rowdata(VteRing **ring, glong lines)
VteRowData *row;
long i, next;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Sizing scrollback buffer to %ld lines.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Sizing scrollback buffer to %ld lines.\n",
lines);
- }
-#endif
if (*ring && (_vte_ring_max(*ring) == lines)) {
return;
}
@@ -6751,12 +6390,9 @@ static void
vte_terminal_fc_settings_changed(GtkSettings *settings, GParamSpec *spec,
VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Fontconfig setting \"%s\" changed.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Fontconfig setting \"%s\" changed.\n",
spec->name);
- }
-#endif
vte_terminal_set_font_full(terminal, terminal->pvt->fontdesc,
terminal->pvt->fontantialias);
}
@@ -6825,11 +6461,7 @@ vte_terminal_init(VteTerminal *terminal)
VteTerminalPrivate *pvt;
GtkAdjustment *adjustment;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_init()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_init()\n");
GTK_WIDGET_SET_FLAGS(terminal, GTK_CAN_FOCUS);
@@ -6971,11 +6603,7 @@ vte_terminal_size_request(GtkWidget *widget, GtkRequisition *requisition)
{
VteTerminal *terminal;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_size_request()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_size_request()\n");
terminal = VTE_TERMINAL(widget);
@@ -6984,22 +6612,21 @@ vte_terminal_size_request(GtkWidget *widget, GtkRequisition *requisition)
if (terminal->pvt->pty_master != -1) {
vte_terminal_refresh_size(terminal);
requisition->width = terminal->char_width *
- terminal->column_count;
+ terminal->column_count;
requisition->height = terminal->char_height *
- terminal->row_count;
+ terminal->row_count;
} else {
requisition->width = terminal->char_width *
- terminal->pvt->default_column_count;
+ terminal->pvt->default_column_count;
requisition->height = terminal->char_height *
- terminal->pvt->default_row_count;
+ terminal->pvt->default_row_count;
}
requisition->width += VTE_PAD_WIDTH * 2;
requisition->height += VTE_PAD_WIDTH * 2;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Size request is %dx%d for %ldx%ld cells.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Size request is %dx%d for %ldx%ld cells.\n",
requisition->width, requisition->height,
(terminal->pvt->pty_master != -1) ?
terminal->column_count :
@@ -7007,8 +6634,6 @@ vte_terminal_size_request(GtkWidget *widget, GtkRequisition *requisition)
(terminal->pvt->pty_master != -1) ?
terminal->row_count :
terminal->pvt->default_row_count);
- }
-#endif
}
/* Accept a given size from GTK+. */
@@ -7019,11 +6644,8 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
glong width, height;
gboolean snapped_to_bottom, repaint;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_size_allocate()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE,
+ "vte_terminal_size_allocate()\n");
terminal = VTE_TERMINAL(widget);
@@ -7035,13 +6657,10 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
height = (allocation->height - (2 * VTE_PAD_WIDTH)) /
terminal->char_height;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Sizing window to %dx%d (%ldx%ld).\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Sizing window to %dx%d (%ldx%ld).\n",
allocation->width, allocation->height,
width, height);
- }
-#endif
repaint = widget->allocation.width != allocation->width ||
widget->allocation.height != allocation->height;
@@ -7105,13 +6724,9 @@ static void
vte_terminal_unrealize(GtkWidget *widget)
{
VteTerminal *terminal;
- VteBg *bg;
+ VteBg *bg;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_unrealize()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_unrealize()\n");
terminal = VTE_TERMINAL(widget);
@@ -7207,11 +6822,7 @@ vte_terminal_finalize(GObject *object)
struct vte_match_regex *regex;
guint i;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_finalize()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_finalize()\n");
terminal = VTE_TERMINAL(object);
@@ -7395,11 +7006,7 @@ vte_terminal_realize(GtkWidget *widget)
guint attributes_mask = 0, i;
VteBg *bg;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_realize()\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_realize()\n");
terminal = VTE_TERMINAL(widget);
@@ -7444,11 +7051,7 @@ vte_terminal_realize(GtkWidget *widget)
widget->window = gdk_window_new(gtk_widget_get_parent_window(widget),
&attributes,
attributes_mask);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_UPDATES)) {
- gdk_window_set_debug_updates(TRUE);
- }
-#endif
+ _VTE_DEBUG_ON(VTE_DEBUG_UPDATES, gdk_window_set_debug_updates(TRUE));
gdk_window_set_user_data(widget->window, widget);
/* Set the realized flag. */
@@ -8491,19 +8094,6 @@ vte_terminal_draw_cells(VteTerminal *terminal,
defbg = &terminal->pvt->palette[VTE_DEF_BG];
ascent = terminal->char_ascent;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC) && 0) {
- g_printerr("Rendering");
- for (i = 0; i < n; i++) {
- g_printerr(" (%ld,%ld)",
- (long) items[i].c,
- (long) items[i].columns);
- g_assert(items[i].columns > 0);
- }
- g_printerr(".\n");
- }
-#endif
-
color.red = bg->red;
color.blue = bg->blue;
color.green = bg->green;
@@ -8622,16 +8212,13 @@ _vte_terminal_map_pango_color(VteTerminal *terminal, PangoColor *color)
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_UPDATES)) {
- g_printerr("mapped PangoColor(%04x,%04x,%04x) to "
+ _vte_debug_print(VTE_DEBUG_UPDATES,
+ "mapped PangoColor(%04x,%04x,%04x) to "
"palette entry (%04x,%04x,%04x)\n",
color->red, color->green, color->blue,
terminal->pvt->palette[ret].red,
terminal->pvt->palette[ret].green,
terminal->pvt->palette[ret].blue);
- }
-#endif
return ret;
}
@@ -9050,15 +8637,12 @@ vte_terminal_draw_area (VteTerminal *terminal, GdkRectangle *area)
col = MAX(0, (area->x - VTE_PAD_WIDTH) / width);
col_stop = MIN(howmany(area->width + area->x - VTE_PAD_WIDTH, width),
terminal->column_count-1);
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_UPDATES)) {
- g_printerr ("vte_terminal_draw_area"
- " (%d,%d)x(%d,%d) pixels,"
- " (%d,%d)x(%d,%d) cells\n",
- area->x, area->y, area->width, area->height,
- col, row, col_stop - col + 1, row_stop - row + 1);
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_UPDATES,
+ "vte_terminal_draw_area"
+ " (%d,%d)x(%d,%d) pixels,"
+ " (%d,%d)x(%d,%d) cells\n",
+ area->x, area->y, area->width, area->height,
+ col, row, col_stop - col + 1, row_stop - row + 1);
_vte_draw_clear(terminal->pvt->draw,
area->x, area->y, area->width, area->height);
@@ -9090,14 +8674,8 @@ vte_terminal_paint(GtkWidget *widget, GdkRegion *region)
GdkRectangle all_area, selected_area;
gboolean blink, selected;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_paint()\n");
- }
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("=");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_paint()\n");
+ _vte_debug_print(VTE_DEBUG_WORK, "=");
terminal = VTE_TERMINAL(widget);
@@ -9141,15 +8719,13 @@ vte_terminal_paint(GtkWidget *widget, GdkRegion *region)
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_UPDATES)) {
+ _VTE_DEBUG_ON (VTE_DEBUG_UPDATES, ({
GdkRectangle clip;
gdk_region_get_clipbox (region, &clip);
g_printerr ("vte_terminal_paint"
" (%d,%d)x(%d,%d) pixels\n",
clip.x, clip.y, clip.width, clip.height);
- }
-#endif
+ }));
/* Calculate the bounding rectangle. */
if (_vte_draw_requires_repaint(terminal->pvt->draw)) {
@@ -9376,11 +8952,7 @@ vte_terminal_paint(GtkWidget *widget, GdkRegion *region)
static gint
vte_terminal_expose(GtkWidget *widget, GdkEventExpose *event)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("+");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, "+");
if (event->window == widget->window) {
VteTerminal *terminal = VTE_TERMINAL (widget);
if (GTK_WIDGET_DRAWABLE(widget) &&
@@ -9423,8 +8995,7 @@ vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
terminal->pvt->modifiers = modifiers;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_EVENTS, ({
switch (event->direction) {
case GDK_SCROLL_UP:
g_printerr("Scroll up.\n");
@@ -9434,9 +9005,7 @@ vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
break;
default:
break;
- }
- }
-#endif
+ }}));
/* If we're running a mouse-aware application, map the scroll event
* to a button press on buttons four and five. */
@@ -9539,12 +9108,11 @@ vte_terminal_class_init(VteTerminalClass *klass)
if (env != NULL) {
_vte_debug_parse_string(env);
}
- if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
- g_printerr("vte_terminal_class_init()\n");
- }
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- /* print out the legend */
- g_printerr ("Debugging work flow (top input to bottom output):\n"
+ _vte_debug_print(VTE_DEBUG_LIFECYCLE,
+ "vte_terminal_class_init()\n");
+ /* print out the legend */
+ _vte_debug_print(VTE_DEBUG_WORK,
+ "Debugging work flow (top input to bottom output):\n"
" . _vte_terminal_process_incoming\n"
" < start process_timeout\n"
" {[ start update_timeout [ => rate limited\n"
@@ -9558,7 +9126,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
" = vte_terminal_paint\n"
" ]} start update_timeout\n"
" > end process_timeout\n");
- }
}
#endif
@@ -10068,11 +9635,7 @@ void
vte_terminal_copy_clipboard(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Copying to CLIPBOARD.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION, "Copying to CLIPBOARD.\n");
if (terminal->pvt->selection != NULL) {
GtkClipboard *clipboard;
clipboard = vte_terminal_clipboard_get(terminal,
@@ -10094,11 +9657,7 @@ void
vte_terminal_paste_clipboard(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Pasting CLIPBOARD.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION, "Pasting CLIPBOARD.\n");
vte_terminal_paste(terminal, GDK_SELECTION_CLIPBOARD);
}
@@ -10114,11 +9673,7 @@ void
vte_terminal_copy_primary(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Copying to PRIMARY.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION, "Copying to PRIMARY.\n");
vte_terminal_copy(terminal, GDK_SELECTION_PRIMARY);
}
@@ -10137,11 +9692,7 @@ void
vte_terminal_paste_primary(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
- g_printerr("Pasting PRIMARY.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SELECTION, "Pasting PRIMARY.\n");
vte_terminal_paste(terminal, GDK_SELECTION_PRIMARY);
}
@@ -10176,20 +9727,14 @@ vte_terminal_background_update(VteTerminal *terminal)
/* If we're not realized yet, don't worry about it, because we get
* called when we realize. */
if (!GTK_WIDGET_REALIZED(terminal)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Can not set background image without "
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Can not set background image without "
"window.\n");
- }
-#endif
return TRUE;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC) || _vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Updating background image.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC|VTE_DEBUG_EVENTS,
+ "Updating background image.\n");
/* Set the default background color. */
bgcolor.red = terminal->pvt->palette[VTE_DEF_BG].red;
@@ -10266,17 +9811,11 @@ vte_terminal_queue_background_update(VteTerminal *terminal)
(GSourceFunc)vte_terminal_background_update,
terminal,
NULL);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Queued background update.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Queued background update.\n");
} else {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Skipping background update.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_EVENTS,
+ "Skipping background update.\n");
}
}
@@ -10300,13 +9839,10 @@ vte_terminal_set_background_saturation(VteTerminal *terminal, double saturation)
g_return_if_fail(VTE_IS_TERMINAL(terminal));
terminal->pvt->bg_saturation = CLAMP(saturation * VTE_SATURATION_MAX,
0, VTE_SATURATION_MAX);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Setting background saturation to %ld/%ld.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Setting background saturation to %ld/%ld.\n",
terminal->pvt->bg_saturation,
(long) VTE_SATURATION_MAX);
- }
-#endif
vte_terminal_queue_background_update(terminal);
}
@@ -10336,14 +9872,11 @@ vte_terminal_set_background_tint_color(VteTerminal *terminal,
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(color != NULL);
terminal->pvt->bg_tint_color = *color;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Setting background tint to %d,%d,%d.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Setting background tint to %d,%d,%d.\n",
terminal->pvt->bg_tint_color.red >> 8,
terminal->pvt->bg_tint_color.green >> 8,
terminal->pvt->bg_tint_color.blue >> 8);
- }
-#endif
vte_terminal_queue_background_update(terminal);
}
@@ -10362,12 +9895,9 @@ vte_terminal_set_background_transparent(VteTerminal *terminal,
gboolean transparent)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Turning background transparency %s.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Turning background transparency %s.\n",
transparent ? "on" : "off");
- }
-#endif
transparent = !!transparent;
if(transparent != terminal->pvt->bg_transparent) {
/* Save this background type. */
@@ -10397,12 +9927,9 @@ vte_terminal_set_background_image(VteTerminal *terminal, GdkPixbuf *image)
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(image==NULL || GDK_IS_PIXBUF(image));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("%s background image.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "%s background image.\n",
GDK_IS_PIXBUF(image) ? "Setting" : "Clearing");
- }
-#endif
/* Get a ref to the new image if there is one. Do it here just in
* case we're actually given the same one we're already using. */
@@ -10441,11 +9968,8 @@ void
vte_terminal_set_background_image_file(VteTerminal *terminal, const char *path)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Loading background image from `%s'.\n", path);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Loading background image from `%s'.\n", path);
/* Save this background type. */
g_free(terminal->pvt->bg_file);
terminal->pvt->bg_file = path ? g_strdup(path) : NULL;
@@ -10611,10 +10135,10 @@ vte_terminal_set_word_chars(VteTerminal *terminal, const char *spec)
{
VteConv conv;
gunichar *wbuf;
- char *ibuf, *ibufptr, *obuf, *obufptr;
+ guchar *ibuf, *ibufptr, *obuf, *obufptr;
gsize ilen, olen;
VteWordCharRange range;
- int i;
+ guint i;
g_return_if_fail(VTE_IS_TERMINAL(terminal));
/* Allocate a new range array. */
@@ -10635,13 +10159,13 @@ vte_terminal_set_word_chars(VteTerminal *terminal, const char *spec)
return;
}
ilen = strlen(spec);
- ibuf = ibufptr = g_strdup(spec);
+ ibuf = ibufptr = (guchar *)g_strdup(spec);
olen = (ilen + 1) * sizeof(gunichar);
_vte_buffer_set_minimum_size(terminal->pvt->conv_buffer, olen);
obuf = obufptr = terminal->pvt->conv_buffer->bytes;
wbuf = (gunichar*) obuf;
wbuf[ilen] = '\0';
- _vte_conv(conv, &ibuf, &ilen, &obuf, &olen);
+ _vte_conv(conv, (const guchar **)&ibuf, &ilen, &obuf, &olen);
_vte_conv_close(conv);
for (i = 0; i < ((obuf - obufptr) / sizeof(gunichar)); i++) {
/* The hyphen character. */
@@ -10649,11 +10173,8 @@ vte_terminal_set_word_chars(VteTerminal *terminal, const char *spec)
range.start = wbuf[i];
range.end = wbuf[i];
g_array_append_val(terminal->pvt->word_chars, range);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Word charset includes hyphen.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Word charset includes hyphen.\n");
continue;
}
/* A single character, not the start of a range. */
@@ -10661,12 +10182,9 @@ vte_terminal_set_word_chars(VteTerminal *terminal, const char *spec)
range.start = wbuf[i];
range.end = wbuf[i];
g_array_append_val(terminal->pvt->word_chars, range);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Word charset includes `%lc'.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Word charset includes `%lc'.\n",
(wint_t) wbuf[i]);
- }
-#endif
continue;
}
/* The start of a range. */
@@ -10677,13 +10195,10 @@ vte_terminal_set_word_chars(VteTerminal *terminal, const char *spec)
range.start = wbuf[i];
range.end = wbuf[i + 2];
g_array_append_val(terminal->pvt->word_chars, range);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Word charset includes range from "
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Word charset includes range from "
"`%lc' to `%lc'.\n", (wint_t) wbuf[i],
(wint_t) wbuf[i + 2]);
- }
-#endif
i += 2;
continue;
}
@@ -11323,11 +10838,7 @@ process_timeout (gpointer data)
VteTerminal *terminal = data;
gboolean again = TRUE;
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("<");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, "<");
while (again && need_processing (terminal)) {
again = vte_terminal_process_incoming(terminal);
@@ -11340,11 +10851,7 @@ process_timeout (gpointer data)
terminal->pvt->process_timeout = VTE_INVALID_SOURCE;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr (">");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, ">");
return again;
}
@@ -11355,11 +10862,7 @@ update_repeat_timeout (gpointer data)
VteTerminal *terminal = data;
gboolean again = TRUE;
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("[");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, "[");
while (again && need_processing (terminal)) {
again = vte_terminal_process_incoming(terminal);
@@ -11367,11 +10870,7 @@ update_repeat_timeout (gpointer data)
again = update_regions (terminal);
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("]");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, "]");
/* We only stop the timer if no update request was received in this
* past cycle.
@@ -11390,11 +10889,7 @@ update_timeout (gpointer data)
VteTerminal *terminal = data;
gboolean again = TRUE;
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("{");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, "{");
remove_process_timeout (terminal);
@@ -11404,11 +10899,7 @@ update_timeout (gpointer data)
update_regions (terminal);
-#ifdef VTE_DEBUG
- if (_vte_debug_on (VTE_DEBUG_WORK)) {
- g_printerr ("}");
- }
-#endif
+ _vte_debug_print (VTE_DEBUG_WORK, "}");
/* Set a timer such that we do not invalidate for a while. */
diff --git a/src/vteaccess.c b/src/vteaccess.c
index c3ac134..ed2b243 100644
--- a/src/vteaccess.c
+++ b/src/vteaccess.c
@@ -142,10 +142,9 @@ offset_from_xy (VteTerminalAccessiblePrivate *priv,
static void
xy_from_offset (VteTerminalAccessiblePrivate *priv,
- gint offset, gint *x, gint *y)
+ guint offset, gint *x, gint *y)
{
- gint i;
- gint linebreak;
+ guint i, linebreak;
gint cur_x, cur_y;
gint cur_offset = 0;
@@ -182,12 +181,9 @@ all_selected(VteTerminal *terminal, glong column, glong row, gpointer data)
static void
emit_text_caret_moved(GObject *object, glong caret)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Accessibility peer emitting "
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Accessibility peer emitting "
"`text-caret-moved'.\n");
- }
-#endif
g_signal_emit_by_name(object, "text-caret-moved", caret);
}
@@ -195,7 +191,6 @@ static void
emit_text_changed_insert(GObject *object,
const char *text, glong offset, glong len)
{
- const char *p;
glong start, count;
if (len == 0) {
return;
@@ -203,15 +198,12 @@ emit_text_changed_insert(GObject *object,
/* Convert the byte offsets to character offsets. */
start = g_utf8_pointer_to_offset (text, text + offset);
count = g_utf8_pointer_to_offset (text + offset, text + offset + len);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Accessibility peer emitting "
- "`text-changed::insert' (%ld, %ld) (%ld, %ld).\n",
- offset, len, start, count);
- g_printerr("Inserted text was `%.*s'.\n",
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Accessibility peer emitting "
+ "`text-changed::insert' (%ld, %ld) (%ld, %ld).\n"
+ "Inserted text was `%.*s'.\n",
+ offset, len, start, count,
(int) len, text + offset);
- }
-#endif
g_signal_emit_by_name(object, "text-changed::insert", start, count);
}
@@ -219,7 +211,6 @@ static void
emit_text_changed_delete(GObject *object,
const char *text, glong offset, glong len)
{
- const char *p;
glong start, count;
if (len == 0) {
return;
@@ -227,15 +218,12 @@ emit_text_changed_delete(GObject *object,
/* Convert the byte offsets to characters. */
start = g_utf8_pointer_to_offset (text, text + offset);
count = g_utf8_pointer_to_offset (text + offset, text + offset + len);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Accessibility peer emitting "
- "`text-changed::delete' (%ld, %ld) (%ld, %ld).\n",
- offset, len, start, count);
- g_printerr("Deleted text was `%.*s'.\n",
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Accessibility peer emitting "
+ "`text-changed::delete' (%ld, %ld) (%ld, %ld).\n"
+ "Deleted text was `%.*s'.\n",
+ offset, len, start, count,
(int) len, text + offset);
- }
-#endif
g_signal_emit_by_name(object, "text-changed::delete", start, count);
}
@@ -247,8 +235,9 @@ vte_terminal_accessible_update_private_data_if_needed(AtkObject *text,
VteTerminalAccessiblePrivate *priv;
struct _VteCharAttributes attrs;
char *next, *tmp;
- long row, i, offset, caret;
+ long row, offset, caret;
long ccol, crow;
+ guint i;
g_assert(VTE_IS_TERMINAL_ACCESSIBLE(text));
@@ -372,14 +361,10 @@ vte_terminal_accessible_update_private_data_if_needed(AtkObject *text,
* it's a new line and we need to keep track of where
* it is. */
if ((i == 0) || (attrs.row != row)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Row %d/%ld begins at "
- "%ld.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Row %d/%ld begins at %u.\n",
priv->snapshot_linebreaks->len,
attrs.row, i);
- }
-#endif
g_array_append_val(priv->snapshot_linebreaks, i);
}
row = attrs.row;
@@ -392,11 +377,8 @@ vte_terminal_accessible_update_private_data_if_needed(AtkObject *text,
/* Update the caret position. */
vte_terminal_get_cursor_position(terminal, &ccol, &crow);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Cursor at (%ld, " "%ld).\n", ccol, crow);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Cursor at (%ld, " "%ld).\n", ccol, crow);
/* Get the offsets to the beginnings of each line. */
caret = -1;
@@ -430,14 +412,11 @@ vte_terminal_accessible_update_private_data_if_needed(AtkObject *text,
/* Done updating the caret position, whether we needed to or not. */
priv->snapshot_caret_invalid = FALSE;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Refreshed accessibility snapshot, "
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Refreshed accessibility snapshot, "
"%ld cells, %ld characters.\n",
(long)priv->snapshot_attributes->len,
(long)priv->snapshot_characters->len);
- }
-#endif
}
/* A signal handler to catch "text-inserted/deleted/modified" signals. */
@@ -464,13 +443,12 @@ vte_terminal_accessible_text_modified(VteTerminal *terminal, gpointer data)
current = priv->snapshot_text->str;
clen = priv->snapshot_text->len;
- if (priv->snapshot_caret < 0 ||
- priv->snapshot_caret >= priv->snapshot_characters->len) {
- /* caret was not in the line */
- caret_offset = clen;
- } else {
+ if ((guint) priv->snapshot_caret < priv->snapshot_characters->len) {
caret_offset = g_array_index(priv->snapshot_characters,
int, priv->snapshot_caret);
+ } else {
+ /* caret was not in the line */
+ caret_offset = clen;
}
/* Find the offset where they don't match. */
@@ -553,7 +531,8 @@ vte_terminal_accessible_text_scrolled(VteTerminal *terminal,
{
VteTerminalAccessiblePrivate *priv;
struct _VteCharAttributes attr;
- long i, len, delta;
+ long delta;
+ guint i, len;
g_assert(VTE_IS_TERMINAL_ACCESSIBLE(data));
g_assert(howmuch != 0);
@@ -688,11 +667,8 @@ vte_terminal_accessible_invalidate_cursor(VteTerminal *terminal, gpointer data)
VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
g_assert(priv != NULL);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Invalidating accessibility cursor.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Invalidating accessibility cursor.\n");
priv->snapshot_caret_invalid = TRUE;
vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(data),
NULL, NULL);
@@ -872,11 +848,7 @@ vte_terminal_accessible_finalize(GObject *object)
VteTerminalAccessiblePrivate *priv;
GtkAccessible *accessible = NULL;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Finalizing accessible peer.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC, "Finalizing accessible peer.\n");
g_assert(VTE_IS_TERMINAL_ACCESSIBLE(object));
accessible = GTK_ACCESSIBLE(object);
@@ -962,13 +934,10 @@ vte_terminal_accessible_get_text(AtkText *text,
priv = g_object_get_data(G_OBJECT(text),
VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Getting text from %d to %d of %d.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Getting text from %d to %d of %d.\n",
start_offset, end_offset,
priv->snapshot_characters->len);
- }
-#endif
g_assert(ATK_IS_TEXT(text));
/* If the requested area is after all of the text, just return an
@@ -1011,7 +980,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
VteTerminalAccessiblePrivate *priv;
VteTerminal *terminal;
gunichar current, prev, next;
- int line;
+ guint start, end, line;
vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
NULL, NULL);
@@ -1020,9 +989,8 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
terminal = VTE_TERMINAL((GTK_ACCESSIBLE(text))->widget);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Getting %s %s at %d of %d.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Getting %s %s at %d of %d.\n",
(direction == direction_current) ? "this" :
((direction == direction_next) ? "next" : "previous"),
(boundary_type == ATK_TEXT_BOUNDARY_CHAR) ? "char" :
@@ -1033,8 +1001,6 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
((boundary_type == ATK_TEXT_BOUNDARY_SENTENCE_START) ? "sentence (start)" :
((boundary_type == ATK_TEXT_BOUNDARY_SENTENCE_END) ? "sentence (end)" : "unknown")))))),
offset, priv->snapshot_attributes->len);
- }
-#endif
g_assert(priv->snapshot_text != NULL);
g_assert(priv->snapshot_characters != NULL);
if (offset == priv->snapshot_characters->len) {
@@ -1048,9 +1014,8 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
/* We're either looking at the character at this
* position, the one before it, or the one after it. */
offset += direction;
- *start_offset = MAX(offset, 0);
- *end_offset = MIN(offset + 1,
- priv->snapshot_attributes->len);
+ start = MAX(offset, 0);
+ end = MIN(offset + 1, priv->snapshot_attributes->len);
break;
case ATK_TEXT_BOUNDARY_WORD_START:
/* Back up to the previous non-word-word transition. */
@@ -1062,7 +1027,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
break;
}
}
- *start_offset = offset;
+ start = offset;
/* If we started in a word and we're looking for the
* word before this one, keep searching by backing up
* to the previous non-word character and then searching
@@ -1084,7 +1049,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
break;
}
}
- *start_offset = offset;
+ start = offset;
}
/* If we're looking for the word after this one,
* search forward by scanning forward for the next
@@ -1107,7 +1072,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
break;
}
}
- *start_offset = offset;
+ start = offset;
}
/* Now find the end of this word. */
while (offset < priv->snapshot_characters->len) {
@@ -1128,7 +1093,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
break;
}
}
- *end_offset = offset;
+ end = offset;
break;
case ATK_TEXT_BOUNDARY_WORD_END:
/* Back up to the previous word-non-word transition. */
@@ -1143,7 +1108,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
current = prev;
}
}
- *start_offset = offset;
+ start = offset;
/* If we're looking for the word end before this one,
* keep searching by backing up to the previous word
* character and then searching for the word-end
@@ -1168,7 +1133,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
current = prev;
}
}
- *start_offset = offset;
+ start = offset;
}
/* If we're looking for the word end after this one,
* search forward by scanning forward for the next
@@ -1191,7 +1156,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
break;
}
}
- *start_offset = offset;
+ start = offset;
}
/* Now find the next word end. */
while (offset < priv->snapshot_characters->len) {
@@ -1210,7 +1175,7 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
break;
}
}
- *end_offset = offset;
+ end = offset;
break;
case ATK_TEXT_BOUNDARY_LINE_START:
case ATK_TEXT_BOUNDARY_LINE_END:
@@ -1227,44 +1192,33 @@ vte_terminal_accessible_get_text_somewhere(AtkText *text,
break;
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Character %d is on line %d.\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Character %d is on line %d.\n",
offset, line);
- }
-#endif
/* Perturb the line number to handle before/at/after. */
line += direction;
- line = CLAMP(line,
- 0, priv->snapshot_linebreaks->len - 1);
+ line = MIN(line, priv->snapshot_linebreaks->len - 1);
/* Read the offsets for this line. */
- *start_offset = g_array_index(priv->snapshot_linebreaks,
+ start = g_array_index(priv->snapshot_linebreaks,
int, line);
line++;
- line = CLAMP(line,
- 0, priv->snapshot_linebreaks->len - 1);
- *end_offset = g_array_index(priv->snapshot_linebreaks,
+ line = MIN(line, priv->snapshot_linebreaks->len - 1);
+ end = g_array_index(priv->snapshot_linebreaks,
int, line);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Line runs from %d to %d.\n",
- *start_offset, *end_offset);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Line runs from %d to %d.\n",
+ start, end);
break;
case ATK_TEXT_BOUNDARY_SENTENCE_START:
case ATK_TEXT_BOUNDARY_SENTENCE_END:
/* This doesn't make sense. Fall through. */
default:
- *start_offset = *end_offset = 0;
+ start = end = 0;
break;
}
- *start_offset = MIN(*start_offset, priv->snapshot_characters->len - 1);
- *end_offset = CLAMP(*end_offset, *start_offset,
- priv->snapshot_characters->len);
- return vte_terminal_accessible_get_text(text,
- *start_offset,
- *end_offset);
+ *start_offset = start = MIN(start, priv->snapshot_characters->len - 1);
+ *end_offset = end = CLAMP(end, start, priv->snapshot_characters->len);
+ return vte_terminal_accessible_get_text(text, start, end);
}
static gchar *
@@ -1395,7 +1349,7 @@ vte_terminal_accessible_get_run_attributes(AtkText *text, gint offset,
gint *start_offset, gint *end_offset)
{
VteTerminalAccessiblePrivate *priv;
- gint i;
+ guint i;
struct _VteCharAttributes cur_attr;
struct _VteCharAttributes attr;
@@ -1409,7 +1363,7 @@ vte_terminal_accessible_get_run_attributes(AtkText *text, gint offset,
struct _VteCharAttributes,
offset);
*start_offset = 0;
- for (i = offset - 1; i >= 0; i--) {
+ for (i = offset; i--;) {
cur_attr = g_array_index (priv->snapshot_attributes,
struct _VteCharAttributes,
i);
@@ -1668,12 +1622,8 @@ vte_terminal_accessible_text_init(gpointer iface, gpointer data)
AtkTextIface *text;
g_assert(G_TYPE_FROM_INTERFACE(iface) == ATK_TYPE_TEXT);
text = iface;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Initializing accessible peer's "
- "AtkText interface.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Initializing accessible peer's AtkText interface.\n");
text->get_text = vte_terminal_accessible_get_text;
text->get_text_after_offset = vte_terminal_accessible_get_text_after_offset;
text->get_text_at_offset = vte_terminal_accessible_get_text_at_offset;
@@ -1869,12 +1819,9 @@ vte_terminal_accessible_component_init(gpointer iface, gpointer data)
g_assert(G_TYPE_FROM_INTERFACE(iface) == ATK_TYPE_COMPONENT);
component = iface;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Initializing accessible peer's "
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Initializing accessible peer's "
"AtkComponent interface.\n");
- }
-#endif
/* Set our virtual functions. */
component->add_focus_handler = vte_terminal_accessible_add_focus_handler;
component->contains = vte_terminal_accessible_contains;
@@ -1990,12 +1937,9 @@ vte_terminal_accessible_action_init(gpointer iface, gpointer data)
g_return_if_fail(G_TYPE_FROM_INTERFACE(iface) == ATK_TYPE_ACTION);
action = iface;
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Initializing accessible peer's "
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Initializing accessible peer's "
"AtkAction interface.\n");
- }
-#endif
/* Set our virtual functions. */
action->do_action = vte_terminal_accessible_do_action;
action->get_n_actions = vte_terminal_accessible_get_n_actions;
@@ -2145,12 +2089,8 @@ vte_terminal_accessible_factory_init(VteTerminalAccessibleFactory *self)
AtkObjectFactory *
vte_terminal_accessible_factory_new(void)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Creating a new "
- "VteTerminalAccessibleFactory.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "Creating a new VteTerminalAccessibleFactory.\n");
return g_object_new(VTE_TYPE_TERMINAL_ACCESSIBLE_FACTORY, NULL);
}
diff --git a/src/vteapp.c b/src/vteapp.c
index 4598b05..8c2c253 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -147,20 +147,12 @@ destroy_and_quit(GtkWidget *widget, gpointer data)
static void
destroy_and_quit_eof(GtkWidget *widget, gpointer data)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_print("Detected EOF.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC, "Detected EOF.\n");
}
static void
destroy_and_quit_exited(GtkWidget *widget, gpointer data)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_print("Detected child exit.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC, "Detected child exit.\n");
destroy_and_quit(widget, data);
}
@@ -392,7 +384,7 @@ take_xconsole_ownership(GtkWidget *widget, gpointer data)
char *name, hostname[255];
GdkAtom atom;
GtkClipboard *clipboard;
- GtkTargetEntry targets[] = {
+ const GtkTargetEntry targets[] = {
{"UTF8_STRING", 0, 0},
{"COMPOUND_TEXT", 0, 0},
{"TEXT", 0, 0},
@@ -790,11 +782,8 @@ main(int argc, char **argv)
if (!console) {
if (shell) {
/* Launch a shell. */
- #ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- vte_terminal_feed(terminal, message, -1);
- }
- #endif
+ _VTE_DEBUG_ON(VTE_DEBUG_MISC,
+ vte_terminal_feed(terminal, message, -1));
vte_terminal_fork_command(terminal,
command, NULL, env_add,
working_directory,
diff --git a/src/vtebg.c b/src/vtebg.c
index 3987078..df84710 100644
--- a/src/vtebg.c
+++ b/src/vtebg.c
@@ -45,10 +45,10 @@ struct VteBgCacheItem {
};
-static void vte_bg_set_root_pixmap(VteBg *bg, GdkPixmap *pixmap);
static GdkPixbuf *_vte_bg_resize_pixbuf(GdkPixbuf *pixbuf,
gint min_width, gint min_height);
static void vte_bg_cache_item_free(struct VteBgCacheItem *item);
+static void vte_bg_cache_prune_int(VteBg *bg, gboolean root);
#if 0
static const char *
@@ -130,19 +130,16 @@ vte_bg_root_pixmap(VteBg *bg)
&prop_type, &prop_size,
&pixmaps)) {
if ((prop_type == GDK_TARGET_PIXMAP) &&
- (prop_size >= sizeof(XID) &&
+ (prop_size >= (int)sizeof(XID) &&
(pixmaps != NULL))) {
pixmap = gdk_pixmap_foreign_new_for_display(bg->native->display, pixmaps[0]);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC) ||
- _vte_debug_on(VTE_DEBUG_EVENTS)) {
+ _VTE_DEBUG_ON(VTE_DEBUG_MISC|VTE_DEBUG_EVENTS, ({
gint pwidth, pheight;
gdk_drawable_get_size(pixmap,
- &pwidth, &pheight);
+ &pwidth, &pheight);
g_printerr("New background image %dx%d\n",
pwidth, pheight);
- }
-#endif
+ }));
}
g_free(pixmaps);
}
@@ -151,6 +148,18 @@ vte_bg_root_pixmap(VteBg *bg)
return pixmap;
}
+static void
+vte_bg_set_root_pixmap(VteBg *bg, GdkPixmap *pixmap)
+{
+ if (bg->root_pixmap != NULL) {
+ g_object_unref(bg->root_pixmap);
+ }
+ bg->root_pixmap = pixmap;
+ vte_bg_cache_prune_int(bg, TRUE);
+ g_signal_emit_by_name(bg, "root-pixmap-changed");
+}
+
+
static GdkFilterReturn
vte_bg_root_filter(GdkXEvent *native, GdkEvent *event, gpointer data)
{
@@ -399,12 +408,9 @@ _vte_bg_resize_pixbuf(GdkPixbuf *pixbuf, gint min_width, gint min_height)
return pixbuf;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC) || _vte_debug_on(VTE_DEBUG_EVENTS)) {
- g_printerr("Resizing (root?) pixbuf from %dx%d to %dx%d\n",
+ _vte_debug_print(VTE_DEBUG_MISC|VTE_DEBUG_EVENTS,
+ "Resizing (root?) pixbuf from %dx%d to %dx%d\n",
src_width, src_height, dst_width, dst_height);
- }
-#endif
tmp = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pixbuf),
gdk_pixbuf_get_has_alpha(pixbuf),
@@ -423,17 +429,6 @@ _vte_bg_resize_pixbuf(GdkPixbuf *pixbuf, gint min_width, gint min_height)
return tmp;
}
-static void
-vte_bg_set_root_pixmap(VteBg *bg, GdkPixmap *pixmap)
-{
- if (bg->root_pixmap != NULL) {
- g_object_unref(bg->root_pixmap);
- }
- bg->root_pixmap = pixmap;
- vte_bg_cache_prune_int(bg, TRUE);
- g_signal_emit_by_name(bg, "root-pixmap-changed");
-}
-
/* Add an item to the cache, instructing all of the objects therein to clear
the field which holds a pointer to the object upon its destruction. */
static void
diff --git a/src/vteconv.c b/src/vteconv.c
index 35a6d57..36d7148 100644
--- a/src/vteconv.c
+++ b/src/vteconv.c
@@ -27,13 +27,14 @@
#include "buffer.h"
#include "vteconv.h"
-struct _VteConv {
- GIConv conv;
- size_t (*convert)(GIConv converter,
- gchar **inbuf,
+typedef size_t (*convert_func)(GIConv converter,
+ const guchar **inbuf,
gsize *inbytes_left,
- gchar **outbuf,
+ guchar **outbuf,
gsize *outbytes_left);
+struct _VteConv {
+ GIConv conv;
+ convert_func convert;
gint (*close)(GIConv converter);
gboolean in_unichar, out_unichar;
struct _vte_buffer *in_scratch, *out_scratch;
@@ -55,7 +56,7 @@ _vte_conv_utf8_strlen(const gchar *p, gssize max)
* same semantics as g_iconv(). */
static size_t
_vte_conv_utf8_utf8(GIConv converter,
- gchar **inbuf,
+ const gchar **inbuf,
gsize *inbytes_left,
gchar **outbuf,
gsize *outbytes_left)
@@ -63,7 +64,7 @@ _vte_conv_utf8_utf8(GIConv converter,
gboolean validated;
const gchar *endptr;
size_t length, bytes;
- int skip;
+ guint skip;
/* We don't tolerate shenanigans! */
g_assert(*outbytes_left >= *inbytes_left);
@@ -152,12 +153,12 @@ _vte_conv_open(const char *target, const char *source)
ret = g_slice_new0(struct _VteConv);
if (utf8) {
ret->conv = NULL;
- ret->convert = _vte_conv_utf8_utf8;
+ ret->convert = (convert_func) _vte_conv_utf8_utf8;
ret->close = NULL;
} else {
g_assert((conv != NULL) && (conv != ((GIConv) -1)));
ret->conv = conv;
- ret->convert = g_iconv;
+ ret->convert = (convert_func) g_iconv;
ret->close = g_iconv_close;
}
@@ -196,12 +197,12 @@ _vte_conv_close(VteConv converter)
size_t
_vte_conv(VteConv converter,
- gchar **inbuf, gsize *inbytes_left,
- gchar **outbuf, gsize *outbytes_left)
+ const guchar **inbuf, gsize *inbytes_left,
+ guchar **outbuf, gsize *outbytes_left)
{
size_t ret, tmp;
- gchar *work_inbuf_start, *work_inbuf_working;
- gchar *work_outbuf_start, *work_outbuf_working;
+ const guchar *work_inbuf_start, *work_inbuf_working;
+ guchar *work_outbuf_start, *work_outbuf_working;
gsize work_inbytes, work_outbytes;
gsize in_converted, out_converted;
@@ -217,8 +218,8 @@ _vte_conv(VteConv converter,
/* Possibly convert the input data from gunichars to UTF-8. */
if (converter->in_unichar) {
- int i, char_count, skip;
- char *p, *end;
+ int i, char_count;
+ guchar *p, *end;
gunichar *g;
/* Make sure the scratch buffer has enough space. */
char_count = *inbytes_left / sizeof(gunichar);
@@ -229,8 +230,7 @@ _vte_conv(VteConv converter,
p = converter->in_scratch->bytes;
end = p + (char_count + 1) * VTE_UTF8_BPC;
for (i = 0; i < char_count; i++) {
- skip = g_unichar_to_utf8(g[i], p);
- p += skip;
+ p += g_unichar_to_utf8(g[i], (gchar *)p);
g_assert(p <= end);
}
/* Update our working pointers. */
@@ -291,19 +291,19 @@ _vte_conv(VteConv converter,
/* Possibly convert the output from UTF-8 to gunichars. */
if (converter->out_unichar) {
int left = *outbytes_left;
- char *p;
gunichar *g;
+ gchar *p;
g = (gunichar*) *outbuf;
- for(p = work_outbuf_start;
- p < work_outbuf_working;
+ for(p = (gchar *)work_outbuf_start;
+ p < (gchar *)work_outbuf_working;
p = g_utf8_next_char(p)) {
g_assert(left>=0);
*g++ = g_utf8_get_char(p);
left -= sizeof(gunichar);
}
*outbytes_left = left;
- *outbuf = (gchar*) g;
+ *outbuf = (guchar*) g;
} else {
/* Pass on the output results. */
*outbuf = work_outbuf_working;
@@ -315,7 +315,7 @@ _vte_conv(VteConv converter,
/* Get an idea of how many characters were converted, and
* advance the pointer as required. */
int chars;
- chars = _vte_conv_utf8_strlen(work_inbuf_start,
+ chars = _vte_conv_utf8_strlen((const gchar *)work_inbuf_start,
work_inbuf_working - work_inbuf_start);
*inbuf += (sizeof(gunichar) * chars);
*inbytes_left -= (sizeof(gunichar) * chars);
@@ -330,31 +330,31 @@ _vte_conv(VteConv converter,
size_t
_vte_conv_cu(VteConv converter,
- char **inbuf, gsize *inbytes_left,
+ const guchar **inbuf, gsize *inbytes_left,
gunichar **outbuf, gsize *outbytes_left)
{
return _vte_conv(converter,
inbuf, inbytes_left,
- (char**)outbuf, outbytes_left);
+ (guchar**)outbuf, outbytes_left);
}
size_t
_vte_conv_uu(VteConv converter,
- gunichar **inbuf, gsize *inbytes_left,
+ const gunichar **inbuf, gsize *inbytes_left,
gunichar **outbuf, gsize *outbytes_left)
{
return _vte_conv(converter,
- (char**)inbuf, inbytes_left,
- (char**)outbuf, outbytes_left);
+ (const guchar**)inbuf, inbytes_left,
+ (guchar**)outbuf, outbytes_left);
}
size_t
_vte_conv_uc(VteConv converter,
- gunichar **inbuf, gsize *inbytes_left,
- char **outbuf, gsize *outbytes_left)
+ const gunichar **inbuf, gsize *inbytes_left,
+ guchar **outbuf, gsize *outbytes_left)
{
return _vte_conv(converter,
- (char**)inbuf, inbytes_left,
+ (const guchar**)inbuf, inbytes_left,
outbuf, outbytes_left);
}
diff --git a/src/vteconv.h b/src/vteconv.h
index a790fba..88485ae 100644
--- a/src/vteconv.h
+++ b/src/vteconv.h
@@ -34,16 +34,16 @@ typedef struct _VteConv *VteConv;
VteConv _vte_conv_open(const char *target, const char *source);
size_t _vte_conv(VteConv converter,
- gchar **inbuf, gsize *inbytes_left,
- gchar **outbuf, gsize *outbytes_left);
+ const guchar **inbuf, gsize *inbytes_left,
+ guchar **outbuf, gsize *outbytes_left);
size_t _vte_conv_uc(VteConv converter,
- gunichar **inbuf, gsize *inbytes_left,
- gchar **outbuf, gsize *outbytes_left);
+ const gunichar **inbuf, gsize *inbytes_left,
+ guchar **outbuf, gsize *outbytes_left);
size_t _vte_conv_uu(VteConv converter,
- gunichar **inbuf, gsize *inbytes_left,
+ const gunichar **inbuf, gsize *inbytes_left,
gunichar **outbuf, gsize *outbytes_left);
size_t _vte_conv_cu(VteConv converter,
- gchar **inbuf, gsize *inbytes_left,
+ const guchar **inbuf, gsize *inbytes_left,
gunichar **outbuf, gsize *outbytes_left);
gint _vte_conv_close(VteConv converter);
diff --git a/src/vtedraw.c b/src/vtedraw.c
index c885c99..8c44ec1 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -126,11 +126,7 @@ _vte_draw_new(GtkWidget *widget)
draw->impl = &_vte_draw_skel;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("Using %s.\n", draw->impl->name);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_MISC, "Using %s.\n", draw->impl->name);
draw->impl->create(draw, draw->widget);
diff --git a/src/vtefc.c b/src/vtefc.c
index 7e1409b..ddc67ba 100644
--- a/src/vtefc.c
+++ b/src/vtefc.c
@@ -117,7 +117,7 @@ _vte_fc_transcribe_from_pango_font_description(GtkWidget *widget,
/* Set the family for the pattern. */
family = pango_font_description_get_family(font_desc);
- FcPatternAddString(pattern, FC_FAMILY, family);
+ FcPatternAddString(pattern, FC_FAMILY, (guchar *) family);
/* Set the font size for the pattern. */
size = pango_font_description_get_size(font_desc);
@@ -127,7 +127,7 @@ _vte_fc_transcribe_from_pango_font_description(GtkWidget *widget,
language = pango_context_get_language(context);
if (pango_language_to_string(language) != NULL) {
FcPatternAddString(pattern, FC_LANG,
- pango_language_to_string(language));
+ (guchar *) pango_language_to_string(language));
}
/* There aren't any fallbacks for these, so just omit them from the
diff --git a/src/vteft2.c b/src/vteft2.c
index fac326d..8eb492e 100644
--- a/src/vteft2.c
+++ b/src/vteft2.c
@@ -267,12 +267,13 @@ _vte_ft2_draw_text(struct _vte_draw *draw,
GdkColor *color, guchar alpha)
{
struct _vte_ft2_data *data;
- int i, j;
+ gsize i, j;
data = (struct _vte_ft2_data*) draw->impl_data;
for (i = 0; i < n_requests; i++) {
- if (requests[i].c == -1 || requests[i].c == 32 /* space */)
+ if (requests[i].c == (gunichar)-1 ||
+ requests[i].c == 32 /* space */)
continue;
_vte_glyph_draw(data->cache, requests[i].c, color,
requests[i].x, requests[i].y,
diff --git a/src/vteglyph.c b/src/vteglyph.c
index 6a7c881..66d420a 100644
--- a/src/vteglyph.c
+++ b/src/vteglyph.c
@@ -83,7 +83,7 @@ _vte_glyph_cache_new(void)
void
_vte_glyph_cache_free(struct _vte_glyph_cache *cache)
{
- int i;
+ guint i;
g_return_if_fail(cache != NULL);
@@ -121,7 +121,8 @@ _vte_glyph_cache_set_font_description(GtkWidget *widget,
gpointer defaults_data)
{
FcChar8 *facefile;
- int i, j, error, count, width, faceindex;
+ int b, error, count, width, faceindex;
+ guint i,j;
double dpi, size;
GList *iter;
FcPattern *pattern;
@@ -207,19 +208,19 @@ _vte_glyph_cache_set_font_description(GtkWidget *widget,
/* Pull out other settings. */
cache->ft_load_flags = 0;
cache->ft_render_flags = 0;
- i = 0;
+ b = 0;
pattern = g_ptr_array_index(cache->patterns, 0);
/* Read and set the "use the autohinter", er, hint. */
#if defined(FC_AUTOHINT) && defined(FT_LOAD_FORCE_AUTOHINT)
- if (FcPatternGetBool(pattern, FC_AUTOHINT, 0, &i) == FcResultMatch) {
- if (i != 0) {
+ if (FcPatternGetBool(pattern, FC_AUTOHINT, 0, &b) == FcResultMatch) {
+ if (b != 0) {
cache->ft_load_flags |= FT_LOAD_FORCE_AUTOHINT;
}
}
#endif
/* Read and set the "use antialiasing" hint. */
- if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &i) == FcResultMatch) {
- if (i == 0) {
+ if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &b) == FcResultMatch) {
+ if (b == 0) {
cache->ft_load_flags |= FT_LOAD_MONOCHROME;
#if HAVE_DECL_FT_RENDER_MODE_MONO
cache->ft_render_flags = FT_RENDER_MODE_MONO;
@@ -230,14 +231,14 @@ _vte_glyph_cache_set_font_description(GtkWidget *widget,
}
}
/* Read and set the "hinting" hint. */
- if (FcPatternGetBool(pattern, FC_HINTING, 0, &i) == FcResultMatch) {
- if (i == 0) {
+ if (FcPatternGetBool(pattern, FC_HINTING, 0, &b) == FcResultMatch) {
+ if (b == 0) {
cache->ft_load_flags |= FT_LOAD_NO_HINTING;
} else {
#if defined(FC_AUTOHINT) && defined(FT_LOAD_FORCE_AUTOHINT)
if (FcPatternGetBool(pattern, FC_AUTOHINT, 0,
- &i) == FcResultMatch) {
- if (i != 0) {
+ &b) == FcResultMatch) {
+ if (b != 0) {
cache->ft_render_flags |=
FT_LOAD_FORCE_AUTOHINT;
}
@@ -245,8 +246,8 @@ _vte_glyph_cache_set_font_description(GtkWidget *widget,
#endif
#ifdef FC_HINT_STYLE
if (FcPatternGetInteger(pattern, FC_HINT_STYLE, 0,
- &i) == FcResultMatch) {
- switch (i) {
+ &b) == FcResultMatch) {
+ switch (b) {
#if HAVE_DECL_FT_LOAD_NO_HINTING
case FC_HINT_NONE:
cache->ft_load_flags |=
diff --git a/src/vtepango.c b/src/vtepango.c
index 277a132..64fa60a 100644
--- a/src/vtepango.c
+++ b/src/vtepango.c
@@ -241,7 +241,7 @@ _vte_pango_set_text_font(struct _vte_draw *draw,
gunichar full_codepoints[] = {VTE_DRAW_DOUBLE_WIDE_CHARACTERS};
GString *full_string;
gint full_width;
- int i;
+ guint i;
struct _vte_pango_data *data;
data = (struct _vte_pango_data*) draw->impl_data;
@@ -293,12 +293,9 @@ _vte_pango_set_text_font(struct _vte_draw *draw,
}
pango_layout_iter_free(iter);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("VtePango font metrics = %dx%d (%d).\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "VtePango font metrics = %dx%d (%d).\n",
draw->width, draw->height, draw->ascent);
- }
-#endif
g_object_unref(layout);
}
@@ -343,7 +340,7 @@ _vte_pango_draw_text(struct _vte_draw *draw,
{
struct _vte_pango_data *data;
char buf[VTE_UTF8_BPC];
- int i;
+ guint i;
gsize length;
GdkColor wcolor;
diff --git a/src/vtepangox.c b/src/vtepangox.c
index 5e2bc9b..27fb2d1 100644
--- a/src/vtepangox.c
+++ b/src/vtepangox.c
@@ -331,12 +331,9 @@ _vte_pango_x_set_text_font(struct _vte_draw *draw,
}
pango_layout_iter_free(iter);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("VtePangoX font metrics = %dx%d (%d).\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "VtePangoX font metrics = %dx%d (%d).\n",
draw->width, draw->height, draw->ascent);
- }
-#endif
g_object_unref(layout);
g_object_unref(ctx);
}
diff --git a/src/vteregex.c b/src/vteregex.c
index 7a077aa..f1001fd 100644
--- a/src/vteregex.c
+++ b/src/vteregex.c
@@ -245,7 +245,7 @@ _vte_regex_exec(struct _vte_regex *regex, const char *string,
gsize nmatch, struct _vte_regex_match *matches)
{
regmatch_t *posix_matches;
- int i, ret;
+ guint i, ret;
posix_matches = g_malloc(nmatch * sizeof(regmatch_t));
ret = regexec(&regex->posix_regex, string, nmatch, posix_matches, 0);
diff --git a/src/vteseq.c b/src/vteseq.c
index 68fb5d9..8806057 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -112,11 +112,8 @@ vte_g_array_fill(GArray *array, gpointer item, guint final_size)
static void
vte_terminal_emit_deiconify_window(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `deiconify-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `deiconify-window'.\n");
g_signal_emit_by_name(terminal, "deiconify-window");
}
@@ -124,11 +121,8 @@ vte_terminal_emit_deiconify_window(VteTerminal *terminal)
static void
vte_terminal_emit_iconify_window(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `iconify-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `iconify-window'.\n");
g_signal_emit_by_name(terminal, "iconify-window");
}
@@ -136,11 +130,8 @@ vte_terminal_emit_iconify_window(VteTerminal *terminal)
static void
vte_terminal_emit_icon_title_changed(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `icon-title-changed'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `icon-title-changed'.\n");
g_signal_emit_by_name(terminal, "icon-title-changed");
}
@@ -148,11 +139,8 @@ vte_terminal_emit_icon_title_changed(VteTerminal *terminal)
static void
vte_terminal_emit_window_title_changed(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `window-title-changed'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `window-title-changed'.\n");
g_signal_emit_by_name(terminal, "window-title-changed");
}
@@ -160,11 +148,8 @@ vte_terminal_emit_window_title_changed(VteTerminal *terminal)
static void
vte_terminal_emit_raise_window(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `raise-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `raise-window'.\n");
g_signal_emit_by_name(terminal, "raise-window");
}
@@ -172,11 +157,8 @@ vte_terminal_emit_raise_window(VteTerminal *terminal)
static void
vte_terminal_emit_lower_window(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `lower-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `lower-window'.\n");
g_signal_emit_by_name(terminal, "lower-window");
}
@@ -184,11 +166,8 @@ vte_terminal_emit_lower_window(VteTerminal *terminal)
static void
vte_terminal_emit_maximize_window(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `maximize-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `maximize-window'.\n");
g_signal_emit_by_name(terminal, "maximize-window");
}
@@ -196,11 +175,8 @@ vte_terminal_emit_maximize_window(VteTerminal *terminal)
static void
vte_terminal_emit_refresh_window(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `refresh-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `refresh-window'.\n");
g_signal_emit_by_name(terminal, "refresh-window");
}
@@ -208,11 +184,8 @@ vte_terminal_emit_refresh_window(VteTerminal *terminal)
static void
vte_terminal_emit_restore_window(VteTerminal *terminal)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `restore-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `restore-window'.\n");
g_signal_emit_by_name(terminal, "restore-window");
}
@@ -220,11 +193,8 @@ vte_terminal_emit_restore_window(VteTerminal *terminal)
static void
vte_terminal_emit_move_window(VteTerminal *terminal, guint x, guint y)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `move-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `move-window'.\n");
g_signal_emit_by_name(terminal, "move-window", x, y);
}
@@ -233,11 +203,8 @@ static void
vte_terminal_emit_resize_window(VteTerminal *terminal,
guint width, guint height)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
- g_printerr("Emitting `resize-window'.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `resize-window'.\n");
g_signal_emit_by_name(terminal, "resize-window", width, height);
}
@@ -392,7 +359,9 @@ vte_sequence_handler_set_title_internal(VteTerminal *terminal,
{
GValue *value;
VteConv conv;
- char *inbuf = NULL, *outbuf = NULL, *outbufptr = NULL, *title = NULL;
+ const guchar *inbuf = NULL;
+ guchar *outbuf = NULL, *outbufptr = NULL;
+ char *title = NULL;
gsize inbuf_len, outbuf_len;
gboolean ret = FALSE;
@@ -421,19 +390,16 @@ vte_sequence_handler_set_title_internal(VteTerminal *terminal,
if (conv != VTE_INVALID_CONV) {
if (_vte_conv(conv, &inbuf, &inbuf_len,
&outbuf, &outbuf_len) == -1) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_IO)) {
- g_printerr("Error "
+ _vte_debug_print(VTE_DEBUG_IO,
+ "Error "
"converting %ld title "
"bytes (%s), "
"skipping.\n",
(long) _vte_buffer_length(terminal->pvt->outgoing),
- strerror(errno));
- }
-#endif
+ g_strerror(errno));
outbufptr = NULL;
} else {
- title = g_strndup(outbufptr,
+ title = g_strndup((gchar *)outbufptr,
outbuf - outbufptr);
}
_vte_conv_close(conv);
@@ -661,12 +627,9 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
p = g_hash_table_lookup(terminal->pvt->dec_saved,
GINT_TO_POINTER(setting));
set = (p != NULL);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Setting %d was %s.\n",
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Setting %d was %s.\n",
setting, set ? "set" : "unset");
- }
-#endif
}
/* Save the current setting. */
if (save) {
@@ -681,24 +644,18 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
set = *(settings[i].pvalue) ==
settings[i].tvalue;
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Setting %d is %s, saving.\n",
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Setting %d is %s, saving.\n",
setting, set ? "set" : "unset");
- }
-#endif
g_hash_table_insert(terminal->pvt->dec_saved,
GINT_TO_POINTER(setting),
GINT_TO_POINTER(set));
}
/* Change the current setting to match the new/saved value. */
if (!save) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Setting %d to %s.\n",
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Setting %d to %s.\n",
setting, set ? "set" : "unset");
- }
-#endif
if (settings[i].set && set) {
settings[i].set(terminal, NULL, 0, NULL);
}
@@ -724,15 +681,9 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
/* Do whatever's necessary when the setting changes. */
switch (setting) {
case 1:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- if (set) {
- g_printerr("Entering application cursor mode.\n");
- } else {
- g_printerr("Leaving application cursor mode.\n");
- }
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD, set ?
+ "Entering application cursor mode.\n" :
+ "Leaving application cursor mode.\n");
break;
case 3:
vte_terminal_emit_resize_window(terminal,
@@ -822,59 +773,29 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
_vte_terminal_set_pointer_visible(terminal, TRUE);
break;
case 66:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- if (set) {
- g_printerr("Entering application keypad mode.\n");
- } else {
- g_printerr("Leaving application keypad mode.\n");
- }
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD, set ?
+ "Entering application keypad mode.\n" :
+ "Leaving application keypad mode.\n");
break;
case 1051:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- if (set) {
- g_printerr("Entering Sun fkey mode.\n");
- } else {
- g_printerr("Leaving Sun fkey mode.\n");
- }
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD, set ?
+ "Entering Sun fkey mode.\n" :
+ "Leaving Sun fkey mode.\n");
break;
case 1052:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- if (set) {
- g_printerr("Entering HP fkey mode.\n");
- } else {
- g_printerr("Leaving HP fkey mode.\n");
- }
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD, set ?
+ "Entering HP fkey mode.\n" :
+ "Leaving HP fkey mode.\n");
break;
case 1060:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- if (set) {
- g_printerr("Entering Legacy fkey mode.\n");
- } else {
- g_printerr("Leaving Legacy fkey mode.\n");
- }
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD, set ?
+ "Entering Legacy fkey mode.\n" :
+ "Leaving Legacy fkey mode.\n");
break;
case 1061:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- if (set) {
- g_printerr("Entering VT220 fkey mode.\n");
- } else {
- g_printerr("Leaving VT220 fkey mode.\n");
- }
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD, set ?
+ "Entering VT220 fkey mode.\n" :
+ "Leaving VT220 fkey mode.\n");
break;
default:
break;
@@ -1081,11 +1002,8 @@ vte_sequence_handler_bt(VteTerminal *terminal,
}
/* Warp the cursor. */
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Moving cursor to column %ld.\n", (long)newcol);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Moving cursor to column %ld.\n", (long)newcol);
terminal->pvt->screen->cursor_current.col = newcol;
return FALSE;
}
@@ -3101,11 +3019,8 @@ vte_sequence_handler_application_keypad(VteTerminal *terminal,
GQuark match_quark,
GValueArray *params)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- g_printerr("Entering application keypad mode.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD,
+ "Entering application keypad mode.\n");
terminal->pvt->keypad_mode = VTE_KEYMODE_APPLICATION;
return FALSE;
}
@@ -3116,11 +3031,8 @@ vte_sequence_handler_normal_keypad(VteTerminal *terminal,
GQuark match_quark,
GValueArray *params)
{
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
- g_printerr("Leaving application keypad mode.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_KEYBOARD,
+ "Leaving application keypad mode.\n");
terminal->pvt->keypad_mode = VTE_KEYMODE_NORMAL;
return FALSE;
}
@@ -3180,13 +3092,14 @@ vte_sequence_handler_reset_mode(VteTerminal *terminal,
GQuark match_quark,
GValueArray *params)
{
- int i, again;
+ guint i;
long setting;
GValue *value;
+ gboolean again;
if ((params == NULL) || (params->n_values == 0)) {
return FALSE;
}
- again = 0;
+ again = FALSE;
for (i = 0; i < params->n_values; i++) {
value = g_value_array_get_nth(params, i);
if (!G_VALUE_HOLDS_LONG(value)) {
@@ -3195,10 +3108,10 @@ vte_sequence_handler_reset_mode(VteTerminal *terminal,
setting = g_value_get_long(value);
if (vte_sequence_handler_set_mode_internal(terminal, setting,
FALSE)) {
- again++;
+ again = TRUE;
}
}
- return (again > 0);
+ return again;
}
/* Set certain terminal attributes. */
@@ -3210,11 +3123,12 @@ vte_sequence_handler_decset(VteTerminal *terminal,
{
GValue *value;
long setting;
- int i, again;
+ guint i;
+ gboolean again;
if ((params == NULL) || (params->n_values == 0)) {
return FALSE;
}
- again = 0;
+ again = FALSE;
for (i = 0; i < params->n_values; i++) {
value = g_value_array_get_nth(params, i);
if (!G_VALUE_HOLDS_LONG(value)) {
@@ -3223,10 +3137,10 @@ vte_sequence_handler_decset(VteTerminal *terminal,
setting = g_value_get_long(value);
if (vte_sequence_handler_decset_internal(terminal, setting,
FALSE, FALSE, TRUE)) {
- again++;
+ again = TRUE;
}
}
- return (again > 0);
+ return again;
}
/* Unset certain terminal attributes. */
@@ -3238,11 +3152,12 @@ vte_sequence_handler_decreset(VteTerminal *terminal,
{
GValue *value;
long setting;
- int i, again;
+ guint i;
+ gboolean again;
if ((params == NULL) || (params->n_values == 0)) {
return FALSE;
}
- again = 0;
+ again = FALSE;
for (i = 0; i < params->n_values; i++) {
value = g_value_array_get_nth(params, i);
if (!G_VALUE_HOLDS_LONG(value)) {
@@ -3251,10 +3166,10 @@ vte_sequence_handler_decreset(VteTerminal *terminal,
setting = g_value_get_long(value);
if (vte_sequence_handler_decset_internal(terminal, setting,
FALSE, FALSE, FALSE)) {
- again++;
+ again = TRUE;
}
}
- return (again > 0);
+ return again;
}
/* Erase a specified number of characters. */
@@ -3276,7 +3191,7 @@ vte_sequence_handler_erase_in_display(VteTerminal *terminal,
{
GValue *value;
long param;
- int i;
+ guint i;
gboolean again;
/* The default parameter is 0. */
param = 0;
@@ -3330,7 +3245,7 @@ vte_sequence_handler_erase_in_line(VteTerminal *terminal,
{
GValue *value;
long param;
- int i;
+ guint i;
gboolean again;
/* The default parameter is 0. */
param = 0;
@@ -3618,11 +3533,12 @@ vte_sequence_handler_restore_mode(VteTerminal *terminal,
{
GValue *value;
long setting;
- int i, again;
+ guint i;
+ gboolean again;
if ((params == NULL) || (params->n_values == 0)) {
return FALSE;
}
- again = 0;
+ again = FALSE;
for (i = 0; i < params->n_values; i++) {
value = g_value_array_get_nth(params, i);
if (!G_VALUE_HOLDS_LONG(value)) {
@@ -3631,10 +3547,10 @@ vte_sequence_handler_restore_mode(VteTerminal *terminal,
setting = g_value_get_long(value);
if (vte_sequence_handler_decset_internal(terminal, setting,
TRUE, FALSE, FALSE)) {
- again++;
+ again = TRUE;
}
}
- return (again > 0);
+ return again;
}
/* Save a certain terminal attribute. */
@@ -3646,11 +3562,12 @@ vte_sequence_handler_save_mode(VteTerminal *terminal,
{
GValue *value;
long setting;
- int i, again;
+ guint i;
+ gboolean again;
if ((params == NULL) || (params->n_values == 0)) {
return FALSE;
}
- again = 0;
+ again = FALSE;
for (i = 0; i < params->n_values; i++) {
value = g_value_array_get_nth(params, i);
if (!G_VALUE_HOLDS_LONG(value)) {
@@ -3659,10 +3576,10 @@ vte_sequence_handler_save_mode(VteTerminal *terminal,
setting = g_value_get_long(value);
if (vte_sequence_handler_decset_internal(terminal, setting,
FALSE, TRUE, FALSE)) {
- again++;
+ again = TRUE;
}
}
- return (again > 0);
+ return again;
}
/* Perform a screen alignment test -- fill all visible cells with the
@@ -3764,29 +3681,20 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
param = g_value_get_long(value);
switch (param) {
case 1:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Deiconifying window.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Deiconifying window.\n");
vte_terminal_emit_deiconify_window(terminal);
break;
case 2:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Iconifying window.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Iconifying window.\n");
vte_terminal_emit_iconify_window(terminal);
break;
case 3:
if ((arg1 != -1) && (arg2 != -2)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Moving window to "
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Moving window to "
"%ld,%ld.\n", arg1, arg2);
- }
-#endif
vte_terminal_emit_move_window(terminal,
arg1, arg2);
i += 2;
@@ -3794,13 +3702,10 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
break;
case 4:
if ((arg1 != -1) && (arg2 != -1)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Resizing window "
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Resizing window "
"(to %ldx%ld pixels).\n",
arg2, arg1);
- }
-#endif
vte_terminal_emit_resize_window(terminal,
arg2 +
VTE_PAD_WIDTH * 2,
@@ -3810,39 +3715,25 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
}
break;
case 5:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Raising window.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE, "Raising window.\n");
vte_terminal_emit_raise_window(terminal);
break;
case 6:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Lowering window.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE, "Lowering window.\n");
vte_terminal_emit_lower_window(terminal);
break;
case 7:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Refreshing window.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Refreshing window.\n");
_vte_invalidate_all(terminal);
vte_terminal_emit_refresh_window(terminal);
break;
case 8:
if ((arg1 != -1) && (arg2 != -1)) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Resizing window "
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Resizing window "
"(to %ld columns, %ld rows).\n",
arg2, arg1);
- }
-#endif
vte_terminal_emit_resize_window(terminal,
arg2 * terminal->char_width +
VTE_PAD_WIDTH * 2,
@@ -3854,19 +3745,13 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
case 9:
switch (arg1) {
case 0:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Restoring window.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Restoring window.\n");
vte_terminal_emit_restore_window(terminal);
break;
case 1:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Maximizing window.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Maximizing window.\n");
vte_terminal_emit_maximize_window(terminal);
break;
default:
@@ -3879,13 +3764,10 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
len = g_snprintf(buf, sizeof(buf),
_VTE_CAP_CSI "%dt",
1 + !GTK_WIDGET_MAPPED(widget));
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Reporting window state %s.\n",
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Reporting window state %s.\n",
GTK_WIDGET_MAPPED(widget) ?
"non-iconified" : "iconified");
- }
-#endif
vte_terminal_feed_child(terminal, buf, len);
break;
case 13:
@@ -3895,13 +3777,10 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
len = g_snprintf(buf, sizeof(buf),
_VTE_CAP_CSI "%d;%dt",
width + VTE_PAD_WIDTH, height + VTE_PAD_WIDTH);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Reporting window location"
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Reporting window location"
"(%d++,%d++).\n",
width, height);
- }
-#endif
vte_terminal_feed_child(terminal, buf, len);
break;
case 14:
@@ -3910,23 +3789,17 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
_VTE_CAP_CSI "%d;%dt",
widget->allocation.height - 2 * VTE_PAD_WIDTH,
widget->allocation.width - 2 * VTE_PAD_WIDTH);
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Reporting window size "
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Reporting window size "
"(%dx%dn",
width - 2 * VTE_PAD_WIDTH,
height - 2 * VTE_PAD_WIDTH);
- }
-#endif
vte_terminal_feed_child(terminal, buf, len);
break;
case 18:
/* Send widget size, in cells. */
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Reporting widget size.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Reporting widget size.\n");
len = g_snprintf(buf, sizeof(buf),
_VTE_CAP_CSI "%ld;%ldt",
terminal->row_count,
@@ -3934,11 +3807,8 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
vte_terminal_feed_child(terminal, buf, len);
break;
case 19:
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Reporting screen size.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Reporting screen size.\n");
if (gtk_widget_has_screen(widget)) {
gscreen = gtk_widget_get_screen(widget);
} else {
@@ -3954,34 +3824,25 @@ vte_sequence_handler_window_manipulation(VteTerminal *terminal,
break;
case 20:
/* Report the icon title. */
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Reporting icon title.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Reporting icon title.\n");
vte_terminal_feed_child(terminal,
_VTE_CAP_OSC "LTerminal" _VTE_CAP_ST,
- sizeof(_VTE_CAP_OSC "LTerminal" _VTE_CAP_ST));
+ sizeof(_VTE_CAP_OSC "LTerminal" _VTE_CAP_ST) - 1);
break;
case 21:
/* Report the window title. */
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Reporting window title.\n");
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Reporting window title.\n");
vte_terminal_feed_child(terminal,
_VTE_CAP_OSC "Terminal" _VTE_CAP_ST,
- sizeof(_VTE_CAP_OSC "Terminal" _VTE_CAP_ST));
+ sizeof(_VTE_CAP_OSC "Terminal" _VTE_CAP_ST) - 1);
break;
default:
if (param >= 24) {
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_PARSE)) {
- g_printerr("Resizing to %ld rows.\n",
- param);
- }
-#endif
+ _vte_debug_print(VTE_DEBUG_PARSE,
+ "Resizing to %ld rows.\n",
+ param);
/* Resize to the specified number of
* rows. */
vte_terminal_emit_resize_window(terminal,
diff --git a/src/vtexft.c b/src/vtexft.c
index 429d5c7..5711ef4 100644
--- a/src/vtexft.c
+++ b/src/vtexft.c
@@ -120,7 +120,7 @@ _vte_xft_font_close(struct _vte_xft_font *font)
Display *display;
XftFont *ftfont;
FcPattern *pattern;
- int i;
+ guint i;
for (i = 0; i < font->patterns->len; i++) {
pattern = g_ptr_array_index(font->patterns, i);
@@ -150,7 +150,7 @@ _vte_xft_font_close(struct _vte_xft_font *font)
static XftFont *
_vte_xft_font_for_char(struct _vte_xft_font *font, gunichar c)
{
- int i;
+ guint i;
XftFont *ftfont;
GdkDisplay *gdisplay;
Display *display;
@@ -483,21 +483,23 @@ _vte_xft_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
+ struct _vte_xft_font *ft;
XftFont *font;
XGlyphInfo extents;
struct _vte_xft_data *data;
gunichar wide_chars[] = {VTE_DRAW_DOUBLE_WIDE_CHARACTERS};
- int i, n, width, height;
+ guint i;
+ gint n, width, height;
FcChar32 c;
data = (struct _vte_xft_data*) draw->impl_data;
- font = _vte_xft_font_open(draw->widget, fontdesc, antialias);
- if (font != NULL) {
+ ft = _vte_xft_font_open(draw->widget, fontdesc, antialias);
+ if (ft != NULL) {
if (data->font != NULL) {
_vte_xft_font_close(data->font);
}
- data->font = font;
+ data->font = ft;
}
if (data->font == NULL) {
return;
@@ -549,12 +551,9 @@ _vte_xft_set_text_font(struct _vte_draw *draw,
}
}
-#ifdef VTE_DEBUG
- if (_vte_debug_on(VTE_DEBUG_MISC)) {
- g_printerr("VteXft font metrics = %dx%d (%d).\n",
+ _vte_debug_print(VTE_DEBUG_MISC,
+ "VteXft font metrics = %dx%d (%d).\n",
draw->width, draw->height, draw->ascent);
- }
-#endif
}
static int
@@ -669,9 +668,6 @@ _vte_xft_draw_text(struct _vte_draw *draw,
j++;
}
i++;
- if (j == VTE_DRAW_MAX_LENGTH) {
- break;
- }
/* find the next displayable character ... */
ft = NULL;
@@ -690,7 +686,7 @@ _vte_xft_draw_text(struct _vte_draw *draw,
}
break;
}
- } while (ft == font);
+ } while (j < VTE_DRAW_MAX_LENGTH && ft == font);
if (j > 0) {
XftDrawGlyphSpec (data->draw,
&ftcolor, font, glyphs, j);