[vte: 16/17] Merge branch 'work-html' into merge-html
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte: 16/17] Merge branch 'work-html' into merge-html
- Date: Mon, 27 Apr 2015 16:36:53 +0000 (UTC)
commit 6a74baeaabb0a1ce54444611b324338f94721a5c
Merge: 3fac446 56ea581
Author: Christian Persch <chpe gnome org>
Date: Mon Apr 27 13:48:52 2015 +0200
Merge branch 'work-html' into merge-html
src/pty.cc | 1 -
src/vte-private.h | 4 +
src/vte.cc | 371 ++++++++++++++++++++++++++++++++++++++++++----------
src/vteinternal.hh | 31 ++++-
4 files changed, 335 insertions(+), 72 deletions(-)
---
diff --cc src/pty.cc
index 80ad61e,82b15d6..530dd4d
--- a/src/pty.cc
+++ b/src/pty.cc
@@@ -30,9 -32,7 +30,8 @@@
#include "vtepty.h"
#include "vtepty-private.h"
--#include "vte.h"
+#include "vteenums.h"
+#include "vtetypebuiltins.h"
#include "vteversion.h"
#include <sys/types.h>
diff --cc src/vte-private.h
index 2fbad44,1ccc44b..869b2a9
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@@ -100,13 -484,11 +100,17 @@@ VteRowData *_vte_terminal_ring_insert (
VteRowData *_vte_terminal_ring_append (VteTerminal *terminal, gboolean fill);
void _vte_terminal_ring_remove (VteTerminal *terminal, glong position);
+void _vte_terminal_set_cursor_style(VteTerminal *terminal, VteCursorStyle style);
+
++char *_vte_terminal_attributes_to_html(VteTerminal *terminal,
++ const gchar *text,
++ GArray *attributes);
++
/* vteseq.c: */
void _vte_terminal_handle_sequence(VteTerminal *terminal,
- const char *match_s,
- GQuark match,
+ const char *match,
GValueArray *params);
+
gboolean _vte_terminal_xy_to_grid(VteTerminal *terminal,
long x,
long y,
diff --cc src/vte.cc
index ee3bcdd,3dd8d22..a3a28c6
--- a/src/vte.cc
+++ b/src/vte.cc
@@@ -5956,11 -5881,13 +5969,13 @@@ vte_terminal_clipboard_get(VteTerminal
static void
vte_terminal_clear_cb(GtkClipboard *clipboard, gpointer owner)
{
- VteTerminal *terminal;
- terminal = owner;
+ VteTerminal *terminal = (VteTerminal *)owner;
+
- if (terminal->pvt->has_selection) {
- _vte_debug_print(VTE_DEBUG_SELECTION, "Lost selection.\n");
- vte_terminal_deselect_all(terminal);
+ if (clipboard == vte_terminal_clipboard_get(terminal, GDK_SELECTION_PRIMARY)) {
+ if (terminal->pvt->has_selection) {
+ _vte_debug_print(VTE_DEBUG_SELECTION, "Lost selection.\n");
+ vte_terminal_deselect_all(terminal);
+ }
}
}
@@@ -5969,20 -5896,42 +5984,44 @@@ static voi
vte_terminal_copy_cb(GtkClipboard *clipboard, GtkSelectionData *data,
guint info, gpointer owner)
{
- VteSelection sel;
- VteTerminal *terminal;
- terminal = owner;
- for (sel = 0; sel < LAST_VTE_SELECTION; sel ++) {
+ VteTerminal *terminal = (VteTerminal *)owner;
++ int sel;
+
- if (terminal->pvt->selection != NULL) {
- _VTE_DEBUG_IF(VTE_DEBUG_SELECTION) {
- int i;
- g_printerr("Setting selection (%" G_GSIZE_FORMAT " UTF-8 bytes.)\n",
- strlen(terminal->pvt->selection));
- for (i = 0; terminal->pvt->selection[i] != '\0'; i++) {
- g_printerr("0x%04x\n",
- terminal->pvt->selection[i]);
++ for (sel = 0; sel < LAST_VTE_SELECTION; sel++) {
+ if (clipboard == terminal->pvt->clipboard[sel] && terminal->pvt->selection_text[sel] != NULL)
{
+ _VTE_DEBUG_IF(VTE_DEBUG_SELECTION) {
+ int i;
- g_printerr("Setting selection %d (%"G_GSIZE_FORMAT" UTF-8 bytes.)\n",
++ g_printerr("Setting selection %d (%" G_GSIZE_FORMAT " UTF-8 bytes.)\n",
+ sel,
+ strlen(terminal->pvt->selection_text[sel]));
+ for (i = 0; terminal->pvt->selection_text[sel][i] != '\0'; i++) {
+ g_printerr("0x%04x\n",
+ terminal->pvt->selection_text[sel][i]);
+ }
}
+ if (info == VTE_TARGET_TEXT) {
+ gtk_selection_data_set_text(data, terminal->pvt->selection_text[sel], -1);
- } else {
++ } else if (info == VTE_TARGET_HTML) {
++#ifdef HTML_SELECTION
+ gsize len;
+ gchar *selection;
+
- g_assert(info == VTE_TARGET_HTML);
-
+ /* Mozilla asks that we start our text/html with the Unicode byte order mark
*/
+ /* (Comment found in gtkimhtml.c of pidgin fame) */
+ selection = g_convert(terminal->pvt->selection_html[sel],
+ -1, "UTF-16", "UTF-8", NULL, &len, NULL);
+ gtk_selection_data_set(data,
+ gdk_atom_intern("text/html", FALSE),
+ 16,
+ (const guchar *)selection,
+ len);
+ g_free(selection);
- }
++#endif
++ } else {
++ /* Not reached */
++ }
}
- gtk_selection_data_set_text(data, terminal->pvt->selection, -1);
- }
+ }
}
/* Convert the internal color code (either index or RGB, see vte-private.h) into RGB. */
@@@ -6288,6 -6227,166 +6327,171 @@@ vte_terminal_get_text_include_trailing_
TRUE);
}
+ /*
+ * Compares the visual attributes of a VteCellAttr for equality, but ignores
+ * attributes that tend to change from character to character or are otherwise
+ * strange (in particular: fragment, columns).
+ */
+ static gboolean
-vte_terminal_cellattr_equal(const VteCellAttr *attr1, const VteCellAttr *attr2) {
++vte_terminal_cellattr_equal(const VteCellAttr *attr1,
++ const VteCellAttr *attr2)
++{
+ return (attr1->bold == attr2->bold &&
+ attr1->fore == attr2->fore &&
+ attr1->back == attr2->back &&
- attr1->standout == attr2->standout &&
+ attr1->underline == attr2->underline &&
+ attr1->strikethrough == attr2->strikethrough &&
+ attr1->reverse == attr2->reverse &&
+ attr1->blink == attr2->blink &&
- attr1->half == attr2->half &&
+ attr1->invisible == attr2->invisible);
+ }
+
+ /*
+ * Wraps a given string according to the VteCellAttr in HTML tags. Used
+ * old-style HTML (and not CSS) for better compatibility with, for example,
+ * evolution's mail editor component.
+ */
+ static gchar *
-vte_terminal_cellattr_to_html(VteTerminal *terminal, const VteCellAttr *attr, const gchar *text) {
++vte_terminal_cellattr_to_html(VteTerminal *terminal,
++ const VteCellAttr *attr,
++ const gchar *text)
++{
+ GString *string;
+ guint fore, back;
+
- g_assert (terminal->pvt->palette_initialized);
-
+ string = g_string_new(text);
+
+ vte_terminal_determine_colors_internal (terminal, attr,
+ FALSE, FALSE,
+ &fore, &back);
+
- if (attr->bold || attr->standout) {
++ if (attr->bold) {
+ g_string_prepend(string, "<b>");
+ g_string_append(string, "</b>");
+ }
+ if (attr->fore != VTE_DEFAULT_FG || attr->reverse) {
+ PangoColor color;
+ char *tag;
+
+ vte_terminal_get_rgb_from_index(terminal, attr->fore, &color);
+ tag = g_strdup_printf("<font color=\"#%02X%02X%02X\">",
+ color.red >> 8,
+ color.green >> 8,
+ color.blue >> 8);
+ g_string_prepend(string, tag);
+ g_free(tag);
+ g_string_append(string, "</font>");
+ }
+ if (attr->back != VTE_DEFAULT_BG || attr->reverse) {
+ PangoColor color;
+ char *tag;
+
+ vte_terminal_get_rgb_from_index(terminal, attr->back, &color);
+ tag = g_strdup_printf("<span style=\"background-color:#%02X%02X%02X\">",
+ color.red >> 8,
+ color.green >> 8,
+ color.blue >> 8);
+ g_string_prepend(string, tag);
+ g_free(tag);
+ g_string_append(string, "</span>");
+ }
+ if (attr->underline) {
+ g_string_prepend(string, "<u>");
+ g_string_append(string, "</u>");
+ }
+ if (attr->strikethrough) {
+ g_string_prepend(string, "<strike>");
+ g_string_append(string, "</strike>");
+ }
+ if (attr->blink) {
+ g_string_prepend(string, "<blink>");
+ g_string_append(string, "</blink>");
+ }
+ /* reverse and invisible are not supported */
+
+ return g_string_free(string, FALSE);
+ }
+
+ /*
+ * Similar to vte_terminal_find_charcell, but takes a VteCharAttribute for
+ * indexing and returns the VteCellAttr.
+ */
+ static const VteCellAttr *
-vte_terminal_char_to_cell_attr(VteTerminal *terminal, VteCharAttributes *attr)
++vte_terminal_char_to_cell_attr(VteTerminal *terminal,
++ VteCharAttributes *attr)
+ {
+ const VteCell *cell;
+
+ cell = vte_terminal_find_charcell(terminal, attr->column, attr->row);
+ if (cell)
+ return &cell->attr;
+ return NULL;
+ }
+
+
-/**
- * vte_terminal_attributes_to_html:
++/*
++ * _vte_terminal_attributes_to_html:
+ * @terminal: a #VteTerminal
+ * @text: A string as returned by the vte_terminal_get_* family of functions.
+ * @attrs: (array) (element-type Vte.CharAttributes): text attributes, as created by vte_terminal_get_*
+ *
+ * Marks the given text up according to the given attributes, using HTML <span>
+ * commands, and wraps the string in a <pre> element. The attributes have to be
+ * "fresh" in the sense that the terminal must not have changed since they were
+ * obtained using the vte_terminal_get* function.
+ *
+ * Returns: (transfer full): a newly allocated text string, or %NULL.
+ */
+ char *
-vte_terminal_attributes_to_html(VteTerminal *terminal, const gchar *text, GArray *attrs) {
++_vte_terminal_attributes_to_html(VteTerminal *terminal,
++ const gchar *text,
++ GArray *attrs)
++{
+ GString *string;
+ guint from,to;
+ const VteCellAttr *attr;
+ char *escaped, *marked;
+
+ g_assert(strlen(text) == attrs->len);
+
+ /* Initial size fits perfectly if the text has no attributes and no
+ * characters that need to be escaped
+ */
+ string = g_string_sized_new (strlen(text) + 11);
+
+ g_string_append(string, "<pre>");
+ /* Find streches with equal attributes. Newlines are treated specially,
+ * so that the <span> do not cover multiple lines.
+ */
+ from = to = 0;
+ while (text[from] != '\0') {
+ g_assert(from == to);
+ if (text[from] == '\n') {
+ g_string_append_c(string, '\n');
+ from = ++to;
+ } else {
+ attr = vte_terminal_char_to_cell_attr(terminal,
+ &g_array_index(attrs, VteCharAttributes, from));
+ while (text[to] != '\0' && text[to] != '\n' &&
+ vte_terminal_cellattr_equal(attr,
+ vte_terminal_char_to_cell_attr(terminal,
+ &g_array_index(attrs, VteCharAttributes, to))))
+ {
+ to++;
+ }
+ escaped = g_markup_escape_text(text + from, to - from);
+ marked = vte_terminal_cellattr_to_html(terminal, attr, escaped);
+ g_string_append(string, marked);
+ g_free(escaped);
+ g_free(marked);
+ from = to;
+ }
+ }
+ g_string_append(string, "</pre>");
+
+ return g_string_free(string, FALSE);
+ }
+
/**
* vte_terminal_get_cursor_position:
* @terminal: a #VteTerminal
@@@ -6326,12 -6417,16 +6522,15 @@@ vte_terminal_copy(VteTerminal *terminal
GtkClipboard *clipboard;
static GtkTargetEntry *targets = NULL;
static gint n_targets = 0;
+ GArray *attributes;
- clipboard = vte_terminal_clipboard_get(terminal, board);
+ clipboard = terminal->pvt->clipboard[sel];
+
+ attributes = g_array_new(FALSE, TRUE, sizeof(struct _VteCharAttributes));
/* Chuck old selected text and retrieve the newly-selected text. */
- g_free(terminal->pvt->selection);
- terminal->pvt->selection =
+ g_free(terminal->pvt->selection_text[sel]);
- g_free(terminal->pvt->selection_html[sel]);
+ terminal->pvt->selection_text[sel] =
vte_terminal_get_text_range(terminal,
terminal->pvt->selection_start.row,
0,
@@@ -6339,18 -6434,29 +6538,37 @@@
terminal->pvt->column_count,
vte_cell_is_selected,
NULL,
- NULL);
- terminal->pvt->has_selection = TRUE;
+ attributes);
++#ifdef HTML_SELECTION
++ g_free(terminal->pvt->selection_html[sel]);
+ terminal->pvt->selection_html[sel] =
- vte_terminal_attributes_to_html(terminal,
- terminal->pvt->selection_text[sel],
- attributes);
++ _vte_terminal_attributes_to_html(terminal,
++ terminal->pvt->selection_text[sel],
++ attributes);
++#endif
++
+ g_array_free (attributes, TRUE);
+
- if (sel == VTE_SELECTION_PRIMARY)
++ if (sel == VTE_SELECTION_PRIMARY)
+ terminal->pvt->has_selection = TRUE;
/* Place the text on the clipboard. */
- if (terminal->pvt->selection != NULL) {
+ if (terminal->pvt->selection_text[sel] != NULL) {
_vte_debug_print(VTE_DEBUG_SELECTION,
"Assuming ownership of selection.\n");
if (!targets) {
GtkTargetList *list;
list = gtk_target_list_new (NULL, 0);
- gtk_target_list_add_text_targets (list, 0);
+ gtk_target_list_add_text_targets (list, VTE_TARGET_TEXT);
++
++#ifdef HTML_SELECTION
+ gtk_target_list_add (list,
+ gdk_atom_intern("text/html", FALSE),
+ 0,
+ VTE_TARGET_HTML);
++#endif
++
targets = gtk_target_table_new_from_list (list, &n_targets);
gtk_target_list_unref (list);
}
@@@ -8097,10 -8328,9 +8315,11 @@@ _vte_terminal_inline_error_message(VteT
static void
vte_terminal_init(VteTerminal *terminal)
{
+ void *place;
VteTerminalPrivate *pvt;
GtkStyleContext *context;
+ int i;
+ GdkDisplay *display;
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_init()\n");
@@@ -8531,7 -8775,8 +8755,8 @@@ vte_terminal_finalize(GObject *object
VteTerminalPrivate *pvt = terminal->pvt;
GtkClipboard *clipboard;
GtkSettings *settings;
- VteSelection sel;
struct vte_match_regex *regex;
++ int sel;
guint i;
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_finalize()\n");
@@@ -8590,15 -8835,17 +8815,19 @@@
/* Free any selected text, but if we currently own the selection,
* throw the text onto the clipboard without an owner so that it
* doesn't just disappear. */
- if (terminal->pvt->selection != NULL) {
- clipboard = vte_terminal_clipboard_get(terminal,
- GDK_SELECTION_PRIMARY);
- if (gtk_clipboard_get_owner(clipboard) == object) {
- gtk_clipboard_set_text(clipboard,
- terminal->pvt->selection,
- -1);
+ for (sel = VTE_SELECTION_PRIMARY; sel < LAST_VTE_SELECTION; sel++) {
+ if (terminal->pvt->selection_text[sel] != NULL) {
+ clipboard = terminal->pvt->clipboard[sel];
+ if (gtk_clipboard_get_owner(clipboard) == object) {
+ gtk_clipboard_set_text(clipboard,
+ terminal->pvt->selection_text[sel],
+ -1);
+ }
+ g_free(terminal->pvt->selection_text[sel]);
++#ifdef HTML_SELECTION
+ g_free(terminal->pvt->selection_html[sel]);
++#endif
}
- g_free(terminal->pvt->selection);
}
/* Clear the output histories. */
@@@ -8812,15 -9057,14 +9041,14 @@@ vte_terminal_determine_colors_internal(
{
guint fore, back;
- if (!cell)
- cell = &basic_cell.cell;
+ g_assert(attr);
/* Start with cell colors */
- fore = cell->attr.fore;
- back = cell->attr.back;
+ fore = attr->fore;
+ back = attr->back;
/* Reverse-mode switches default fore and back colors */
- if (G_UNLIKELY (terminal->pvt->screen->reverse_mode)) {
+ if (G_UNLIKELY (terminal->pvt->reverse_mode)) {
if (fore == VTE_DEFAULT_FG)
fore = VTE_DEFAULT_BG;
if (back == VTE_DEFAULT_BG)
@@@ -8836,15 -9080,22 +9064,15 @@@
}
}
- /* Handle half similarly */
- if (attr->half) {
- if (fore == VTE_DEFAULT_FG)
- fore = VTE_DIM_FG;
- else if (fore >= VTE_LEGACY_COLORS_OFFSET && fore < VTE_LEGACY_COLORS_OFFSET +
VTE_LEGACY_COLOR_SET_SIZE)
- fore = corresponding_dim_index[fore - VTE_LEGACY_COLORS_OFFSET];
- }
-
- /* And standout */
- if (attr->standout) {
- if (back >= VTE_LEGACY_COLORS_OFFSET && back < VTE_LEGACY_COLORS_OFFSET +
VTE_LEGACY_COLOR_SET_SIZE)
- back += VTE_COLOR_BRIGHT_OFFSET;
- }
+ /* Handle dim colors. Only apply to palette colors, dimming direct RGB wouldn't make sense.
+ * Apply to the foreground color only, but do this before handling reverse/highlight so that
+ * those can be used to dim the background instead. */
- if (cell->attr.dim && !(fore & VTE_RGB_COLOR)) {
++ if (attr->dim && !(fore & VTE_RGB_COLOR)) {
+ fore |= VTE_DIM_COLOR;
+ }
/* Reverse cell? */
- if (cell->attr.reverse) {
+ if (attr->reverse) {
swap (&fore, &back);
}
@@@ -11937,7 -12783,8 +12161,7 @@@ vte_terminal_reset(VteTerminal *termina
gboolean clear_history)
{
VteTerminalPrivate *pvt;
-- int i;
- VteSelection sel;
++ int i, sel;
g_return_if_fail(VTE_IS_TERMINAL(terminal));
@@@ -12020,22 -12908,26 +12244,29 @@@
pvt->selecting = FALSE;
pvt->selecting_restart = FALSE;
pvt->selecting_had_delta = FALSE;
- if (pvt->selection != NULL) {
- g_free(pvt->selection);
- pvt->selection = NULL;
- memset(&pvt->selection_origin, 0,
- sizeof(pvt->selection_origin));
- memset(&pvt->selection_last, 0,
- sizeof(pvt->selection_last));
- memset(&pvt->selection_start, 0,
- sizeof(pvt->selection_start));
- memset(&pvt->selection_end, 0,
- sizeof(pvt->selection_end));
+ for (sel = VTE_SELECTION_PRIMARY; sel < LAST_VTE_SELECTION; sel++) {
+ if (pvt->selection_text[sel] != NULL) {
+ g_free(pvt->selection_text[sel]);
- g_free(pvt->selection_html[sel]);
+ pvt->selection_text[sel] = NULL;
++#ifdef HTML_SELECTION
++ g_free(pvt->selection_html[sel]);
+ pvt->selection_html[sel] = NULL;
++#endif
+ }
}
+ memset(&pvt->selection_origin, 0,
+ sizeof(pvt->selection_origin));
+ memset(&pvt->selection_last, 0,
+ sizeof(pvt->selection_last));
+ memset(&pvt->selection_start, 0,
+ sizeof(pvt->selection_start));
+ memset(&pvt->selection_end, 0,
+ sizeof(pvt->selection_end));
+
/* Reset mouse motion events. */
pvt->mouse_tracking_mode = MOUSE_TRACKING_NONE;
- pvt->mouse_last_button = 0;
+ pvt->mouse_pressed_buttons = 0;
+ pvt->mouse_handled_buttons = 0;
pvt->mouse_last_x = 0;
pvt->mouse_last_y = 0;
pvt->mouse_xterm_extension = FALSE;
diff --cc src/vteinternal.hh
index b5edc5d,0000000..4eeeddb
mode 100644,000000..100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@@ -1,375 -1,0 +1,404 @@@
+/*
+ * Copyright (C) 2001-2004 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include <glib.h>
+
+typedef enum {
+ VTE_REGEX_CURSOR_GDKCURSOR,
+ VTE_REGEX_CURSOR_GDKCURSORTYPE,
+ VTE_REGEX_CURSOR_NAME
+} VteRegexCursorMode;
+
+/* The order is important */
+typedef enum {
+ MOUSE_TRACKING_NONE,
+ MOUSE_TRACKING_SEND_XY_ON_CLICK,
+ MOUSE_TRACKING_SEND_XY_ON_BUTTON,
+ MOUSE_TRACKING_HILITE_TRACKING,
+ MOUSE_TRACKING_CELL_MOTION_TRACKING,
+ MOUSE_TRACKING_ALL_MOTION_TRACKING
+} MouseTrackingMode;
+
+/* A match regex, with a tag. */
+struct vte_match_regex {
+ gint tag;
+ GRegex *regex;
+ GRegexMatchFlags match_flags;
+ VteRegexCursorMode cursor_mode;
+ union {
+ GdkCursor *cursor;
+ char *cursor_name;
+ GdkCursorType cursor_type;
+ } cursor;
+};
+
+typedef enum _VteCharacterReplacement {
+ VTE_CHARACTER_REPLACEMENT_NONE,
+ VTE_CHARACTER_REPLACEMENT_LINE_DRAWING,
+ VTE_CHARACTER_REPLACEMENT_BRITISH
+} VteCharacterReplacement;
+
+/* The terminal's keypad/cursor state. A terminal can either be using the
+ * normal keypad, or the "application" keypad. */
+typedef enum _VteKeymode {
+ VTE_KEYMODE_NORMAL,
+ VTE_KEYMODE_APPLICATION
+} VteKeymode;
+
+typedef struct _VtePaletteColor {
+ struct {
+ PangoColor color;
+ gboolean is_set;
+ } sources[2];
+} VtePaletteColor;
+
+/* These correspond to the parameters for DECSCUSR (Set cursor style). */
+typedef enum _VteCursorStyle {
+ /* We treat 0 and 1 differently, assuming that the VT510 does so too.
+ *
+ * See, according to the "VT510 Video Terminal Programmer Information",
+ * from vt100.net, paragraph "2.5.7 Cursor Display", there was a menu
+ * item in the "Terminal Set-Up" to set the cursor's style. It looks
+ * like that defaulted to blinking block. So it makes sense for 0 to
+ * mean "set cursor style to default (set by Set-Up)" and 1 to mean
+ * "set cursor style to blinking block", since that default need not be
+ * blinking block. Access to a VT510 is needed to test this theory,
+ * but it seems plausible. And, anyhow, we can even decide we know
+ * better than the VT510 designers! */
+ VTE_CURSOR_STYLE_TERMINAL_DEFAULT = 0,
+ VTE_CURSOR_STYLE_BLINK_BLOCK = 1,
+ VTE_CURSOR_STYLE_STEADY_BLOCK = 2,
+ VTE_CURSOR_STYLE_BLINK_UNDERLINE = 3,
+ VTE_CURSOR_STYLE_STEADY_UNDERLINE = 4,
+ /* *_IBEAM are xterm extensions */
+ VTE_CURSOR_STYLE_BLINK_IBEAM = 5,
+ VTE_CURSOR_STYLE_STEADY_IBEAM = 6
+} VteCursorStyle;
+
+typedef struct _vte_incoming_chunk _vte_incoming_chunk_t;
+struct _vte_incoming_chunk{
+ _vte_incoming_chunk_t *next;
+ guint len;
+ guchar data[VTE_INPUT_CHUNK_SIZE - 2 * sizeof(void *)];
+};
+
+typedef struct _VteScreen VteScreen;
+struct _VteScreen {
+ VteRing row_data[1]; /* buffer contents */
+ long scroll_delta; /* scroll offset */
+ long insert_delta; /* insertion offset */
+
+ /* Stuff saved along with the cursor */
+ struct {
+ VteVisualPosition cursor;
+ gboolean reverse_mode;
+ gboolean origin_mode;
+ gboolean sendrecv_mode;
+ gboolean insert_mode;
+ gboolean linefeed_mode;
+ VteCell defaults;
+ VteCell color_defaults;
+ VteCell fill_defaults;
+ VteCharacterReplacement character_replacements[2];
+ VteCharacterReplacement *character_replacement;
+ } saved;
+};
+
+enum vte_selection_type {
+ selection_type_char,
+ selection_type_word,
+ selection_type_line
+};
+
++/* Until the selection can be generated on demand, let's not enable this on stable */
++#include "vte/vteversion.h"
++#if (VTE_MINOR_VERSION % 2) == 0
++#undef HTML_SELECTION
++#else
++#define HTML_SELECTION
++#endif
++
++/* For unified handling of PRIMARY and CLIPBOARD selection */
++typedef enum {
++ VTE_SELECTION_PRIMARY,
++ VTE_SELECTION_CLIPBOARD,
++ LAST_VTE_SELECTION
++} VteSelection;
++
++/* Used in the GtkClipboard API, to distinguish requests for HTML and TEXT
++ * contents of a clipboard */
++typedef enum {
++ VTE_TARGET_TEXT,
++ VTE_TARGET_HTML,
++ LAST_VTE_TARGET
++} VteSelectionTarget;
++
+struct selection_event_coords {
+ long x, y;
+};
+
+struct vte_scrolling_region {
+ int start, end;
+};
+
+/* Terminal private data. */
+class VteTerminalPrivate {
+public:
+ VteTerminalPrivate() { }
+ ~VteTerminalPrivate() { }
+public:
+ /* Metric and sizing data: dimensions of the window */
+ glong row_count;
+ glong column_count;
+
+ /* Emulation setup data. */
+ struct _vte_matcher *matcher; /* control sequence matcher */
+ gboolean autowrap; /* auto wraparound at right margin */
+ int keypad_mode, cursor_mode; /* these would be VteKeymodes, but we
+ need to guarantee its type */
+ GHashTable *dec_saved;
+
+ /* PTY handling data. */
+ VtePty *pty;
+ GIOChannel *pty_channel; /* master channel */
+ guint pty_input_source;
+ guint pty_output_source;
+ gboolean pty_input_active;
+ GPid pty_pid; /* pid of child using pty slave */
+ guint child_watch_source;
+
+ /* Input data queues. */
+ const char *encoding; /* the pty's encoding */
+ int utf8_ambiguous_width;
+ struct _vte_iso2022_state *iso2022;
+ _vte_incoming_chunk_t *incoming;/* pending bytestream */
+ GArray *pending; /* pending characters */
+ GSList *update_regions;
+ gboolean invalidated_all; /* pending refresh of entire terminal */
+ GList *active; /* is the terminal processing data */
+ glong input_bytes;
+ glong max_input_bytes;
+
+ /* Output data queue. */
+ VteByteArray *outgoing; /* pending input characters */
+ VteConv outgoing_conv;
+
+ /* IConv buffer. */
+ VteByteArray *conv_buffer;
+
+ /* Screen data. We support the normal screen, and an alternate
+ * screen, which seems to be a DEC-specific feature. */
+ struct _VteScreen normal_screen, alternate_screen, *screen;
+
+ /* Values we save along with the cursor */
+ VteVisualPosition cursor; /* relative to the insertion delta */
+ gboolean reverse_mode; /* reverse mode */
+ gboolean origin_mode; /* origin mode */
+ gboolean sendrecv_mode; /* sendrecv mode */
+ gboolean insert_mode; /* insert mode */
+ gboolean linefeed_mode; /* linefeed mode */
+ VteCell defaults; /* default characteristics
+ for insertion of any new
+ characters */
+ VteCell color_defaults; /* original defaults
+ plus the current
+ fore/back */
+ VteCell fill_defaults; /* original defaults
+ plus the current
+ fore/back with no
+ character data */
+ VteCharacterReplacement character_replacements[2]; /* charsets in the G0 and G1 slots */
+ VteCharacterReplacement *character_replacement; /* pointer to the active one */
+
+
+ /* Word chars */
+ char *word_char_exceptions_string;
+ gunichar *word_char_exceptions;
+ gsize word_char_exceptions_len;
+
+ /* Selection information. */
+ gboolean has_selection;
+ gboolean selecting;
+ gboolean selecting_after_threshold;
+ gboolean selecting_restart;
+ gboolean selecting_had_delta;
+ gboolean selection_block_mode;
- char *selection;
+ enum vte_selection_type selection_type;
+ struct selection_event_coords selection_origin, selection_last;
+ VteVisualPosition selection_start, selection_end;
+
++ /* Clipboard data information. */
++ char *selection_text[LAST_VTE_SELECTION];
++#ifdef HTML_SELECTION
++ char *selection_html[LAST_VTE_SELECTION];
++#endif
++ GtkClipboard *clipboard[LAST_VTE_SELECTION];
++
+ /* Miscellaneous options. */
+ VteEraseBinding backspace_binding, delete_binding;
+ gboolean meta_sends_escape;
+ gboolean audible_bell;
+ gboolean margin_bell;
+ guint bell_margin;
+ gboolean allow_bold;
+ gboolean deccolm_mode; /* DECCOLM allowed */
+ GHashTable *tabstops;
+ gboolean text_modified_flag;
+ gboolean text_inserted_flag;
+ gboolean text_deleted_flag;
+ gboolean rewrap_on_resize;
+ gboolean bracketed_paste_mode;
+
+ /* Scrolling options. */
+ gboolean scroll_background;
+ gboolean scroll_on_output;
+ gboolean scroll_on_keystroke;
+ gboolean alternate_screen_scroll;
+ long scrollback_lines;
+
+ /* Restricted scrolling */
+ struct vte_scrolling_region scrolling_region; /* the region we scroll in */
+ gboolean scrolling_restricted;
+
+ /* Cursor shape, as set via API */
+ VteCursorShape cursor_shape;
+ float cursor_aspect_ratio;
+
+ /* Cursor blinking, as set in dconf. */
+ VteCursorBlinkMode cursor_blink_mode;
+ gboolean cursor_blink_state;
+ guint cursor_blink_tag; /* cursor blinking timeout ID */
+ gint cursor_blink_cycle; /* gtk-cursor-blink-time / 2 */
+ gint cursor_blink_timeout; /* gtk-cursor-blink-timeout */
+ gboolean cursor_blinks; /* whether the cursor is actually blinking */
+ gint64 cursor_blink_time; /* how long the cursor has been blinking yet */
+ gboolean cursor_visible;
+ gboolean has_focus; /* is the terminal window focused */
+
+ /* DECSCUSR cursor style (shape and blinking possibly overridden
+ * via escape sequence) */
+ VteCursorStyle cursor_style;
+
+ /* Input device options. */
+ gboolean input_enabled;
+ time_t last_keypress_time;
+
+ int mouse_tracking_mode; /* this is of type MouseTrackingMode,
+ but we need to guarantee its type. */
+ guint mouse_pressed_buttons; /* bits 0, 1, 2 resp. for buttons 1, 2, 3 */
+ guint mouse_handled_buttons; /* similar bitmap for buttons we handled ourselves */
+ long mouse_last_x, mouse_last_y;
+ gboolean mouse_autohide;
+ guint mouse_autoscroll_tag;
+ gboolean mouse_xterm_extension;
+ gboolean mouse_urxvt_extension;
+ double mouse_smooth_scroll_delta;
+
+ /* State variables for handling match checks. */
+ char *match_contents;
+ GArray *match_attributes;
+ GArray *match_regexes;
+ char *match;
+ int match_tag;
+ VteVisualPosition match_start, match_end;
+ gboolean show_match;
+
+ /* Search data. */
+ GRegex *search_regex;
+ GRegexMatchFlags search_match_flags;
+ gboolean search_wrap_around;
+ GArray *search_attrs; /* Cache attrs */
+
+ /* Data used when rendering the text which does not require server
+ * resources and which can be kept after unrealizing. */
+ PangoFontDescription *unscaled_font_desc;
+ PangoFontDescription *fontdesc;
+ gdouble font_scale;
+ gboolean fontdirty;
+ glong char_ascent;
+ glong char_descent;
+ /* dimensions of character cells */
+ glong char_width;
+ glong char_height;
+
+ /* Data used when rendering the text which reflects server resources
+ * and data, which should be dropped when unrealizing and (re)created
+ * when realizing. */
+ struct _vte_draw *draw;
+
+ VtePaletteColor palette[VTE_PALETTE_SIZE];
+
+ /* Mouse cursors. */
+ gboolean mouse_cursor_visible;
+ GdkCursor *mouse_default_cursor,
+ *mouse_mousing_cursor,
+ *mouse_inviso_cursor;
+
+ /* Input method support. */
+ GtkIMContext *im_context;
+ gboolean im_preedit_active;
+ char *im_preedit;
+ PangoAttrList *im_preedit_attrs;
+ int im_preedit_cursor;
+
+ gboolean accessible_emit;
+
+ /* Adjustment updates pending. */
+ gboolean adjustment_changed_pending;
+ gboolean adjustment_value_changed_pending;
+
+ gboolean cursor_moved_pending;
+ gboolean contents_changed_pending;
+
+ /* window name changes */
+ gchar *window_title;
+ gchar *window_title_changed;
+ gchar *icon_title;
+ gchar *icon_title_changed;
+ gchar *current_directory_uri;
+ gchar *current_directory_uri_changed;
+ gchar *current_file_uri;
+ gchar *current_file_uri_changed;
+
+ /* Background */
+ gdouble background_alpha;
+
+ /* Key modifiers. */
+ guint modifiers;
+
+ /* Obscured? state. */
+ GdkVisibilityState visibility_state;
+
+ /* Font stuff. */
+ gboolean has_fonts;
+ glong line_thickness;
+ glong underline_position;
+ glong strikethrough_position;
+
+ /* Style stuff */
+ GtkBorder padding;
+
+ /* GtkScrollable impl */
+ GtkAdjustment *hadjustment; /* unused */
+ GtkAdjustment *vadjustment;
+ guint hscroll_policy : 1; /* unused */
+
+ guint vscroll_policy : 1;
+};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]