[vte] widget: Add word-char-exceptions property infrastructure
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] widget: Add word-char-exceptions property infrastructure
- Date: Mon, 9 Feb 2015 17:55:53 +0000 (UTC)
commit b720a360829b713cf55c9db22b7d5c03bf6fa447
Author: Christian Persch <chpe gnome org>
Date: Sun Feb 8 19:44:34 2015 +0100
widget: Add word-char-exceptions property infrastructure
Just the infrastructure; not hooked up to anything yet.
https://bugzilla.gnome.org/show_bug.cgi?id=730632
doc/reference/vte-sections.txt | 2 +
src/app.vala | 12 ++++++--
src/vte-private.h | 1 +
src/vte.c | 59 ++++++++++++++++++++++++++++++++++++++++
src/vteterminal.h | 5 +++
5 files changed, 76 insertions(+), 3 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 745d8f1..8909e4c 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -65,6 +65,8 @@ vte_terminal_set_cjk_ambiguous_width
vte_terminal_get_cjk_ambiguous_width
vte_terminal_set_encoding
vte_terminal_get_encoding
+vte_terminal_set_word_char_exceptions
+vte_terminal_get_word_char_exceptions
vte_terminal_write_contents_sync
vte_terminal_search_find_next
vte_terminal_search_find_previous
diff --git a/src/app.vala b/src/app.vala
index 67a58a2..e102e46 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -114,6 +114,9 @@ class Window : Gtk.ApplicationWindow
}
}
+ if (App.Options.word_char_exceptions != null)
+ terminal.set_word_char_exceptions(App.Options.word_char_exceptions);
+
terminal.set_audible_bell(App.Options.audible);
terminal.set_cjk_ambiguous_width(App.Options.get_cjk_ambiguous_width());
terminal.set_cursor_blink_mode(App.Options.get_cursor_blink_mode());
@@ -567,6 +570,7 @@ class App : Gtk.Application
public static int scrollback_lines = 512;
public static int transparency_percent = 0;
public static bool version = false;
+ public static string? word_char_exceptions = null;
public static string? working_directory = null;
private static int parse_enum(Type type, string str)
@@ -587,7 +591,7 @@ class App : Gtk.Application
uint value = 0;
var flags_klass = (FlagsClass)type.class_ref();
string[]? flags = str.split(",|", -1);
-
+
if (flags == null)
return value;
@@ -697,7 +701,7 @@ class App : Gtk.Application
flags = Vte.PtyFlags.DEFAULT;
return flags;
}
-
+
public static const OptionEntry[] entries = {
{ "audible-bell", 'a', 0, OptionArg.NONE, ref audible,
"Use audible terminal bell", null },
@@ -761,7 +765,9 @@ class App : Gtk.Application
"Enable the use of a transparent background", "0..100" },
{ "version", 0, 0, OptionArg.NONE, ref version,
"Show version", null },
- { "working-directory", 'w', 0,OptionArg.FILENAME, ref working_directory,
+ { "word-char-exceptions", 0, 0, OptionArg.STRING, ref word_char_exceptions,
+ "Specify the word char exceptions", "CHARS" },
+ { "working-directory", 'w', 0, OptionArg.FILENAME, ref working_directory,
"Specify the initial working directory of the terminal", null },
{ null }
};
diff --git a/src/vte-private.h b/src/vte-private.h
index b4fc654..43d2266 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -286,6 +286,7 @@ struct _VteTerminalPrivate {
VteCharacterReplacement *character_replacement; /* pointer to the active one */
/* Selection information. */
+ char *word_char_exceptions;
gboolean has_selection;
gboolean selecting;
gboolean selecting_after_threshold;
diff --git a/src/vte.c b/src/vte.c
index e9dbe57..d49fccd 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -176,6 +176,7 @@ enum {
PROP_SCROLL_ON_KEYSTROKE,
PROP_SCROLL_ON_OUTPUT,
PROP_WINDOW_TITLE,
+ PROP_WORD_CHAR_EXCEPTIONS
};
/* these static variables are guarded by the GDK mutex */
@@ -8589,6 +8590,8 @@ vte_terminal_finalize(GObject *object)
g_free(terminal->pvt->current_file_uri_changed);
g_free(terminal->pvt->current_file_uri);
+ g_free(terminal->pvt->word_char_exceptions);
+
/* Free public-facing data. */
g_free(terminal->pvt->icon_title);
if (terminal->pvt->vadjustment != NULL) {
@@ -10136,6 +10139,9 @@ vte_terminal_get_property (GObject *object,
case PROP_WINDOW_TITLE:
g_value_set_string (value, vte_terminal_get_window_title (terminal));
break;
+ case PROP_WORD_CHAR_EXCEPTIONS:
+ g_value_set_string (value, vte_terminal_get_word_char_exceptions (terminal));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -10219,6 +10225,9 @@ vte_terminal_set_property (GObject *object,
case PROP_SCROLL_ON_OUTPUT:
vte_terminal_set_scroll_on_output (terminal, g_value_get_boolean (value));
break;
+ case PROP_WORD_CHAR_EXCEPTIONS:
+ vte_terminal_set_word_char_exceptions (terminal, g_value_get_string (value));
+ break;
/* Not writable */
case PROP_CURRENT_DIRECTORY_URI:
@@ -11116,6 +11125,18 @@ vte_terminal_class_init(VteTerminalClass *klass)
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
+ /**
+ * VteTerminal:word-char-exceptions:
+ *
+ * Since: 0.40
+ */
+ g_object_class_install_property
+ (gobject_class,
+ PROP_WORD_CHAR_EXCEPTIONS,
+ g_param_spec_string ("word-char-exceptions", NULL, NULL,
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
+
/* Disable GtkWidget's keybindings except for Shift-F10 and MenuKey
* which pop up the context menu.
*/
@@ -13280,6 +13301,44 @@ vte_terminal_get_input_enabled (VteTerminal *terminal)
}
/**
+ * vte_terminal_set_word_char_exceptions:
+ * @terminal: a #VteTerminal
+ * @word_char_exceptions: a string of ASCII punctuation characters, or %NULL
+ *
+ * Since: 0.40
+ */
+void
+vte_terminal_set_word_char_exceptions(VteTerminal *terminal,
+ const char *word_char_exceptions)
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+ if (g_strcmp0(word_char_exceptions, terminal->pvt->word_char_exceptions) == 0)
+ return;
+
+ g_free(terminal->pvt->word_char_exceptions);
+ terminal->pvt->word_char_exceptions = g_strdup(word_char_exceptions);
+
+ g_object_notify(G_OBJECT(terminal), "word-char-exceptions");
+}
+
+/**
+ * vte_terminal_get_word_char_exceptions:
+ * @terminal: a #VteTerminal
+ *
+ * Returns: (transfer none): a string, or %NULL
+ *
+ * Since: 0.40
+ */
+const char *
+vte_terminal_get_word_char_exceptions(VteTerminal *terminal)
+{
+ g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
+
+ return terminal->pvt->word_char_exceptions;
+}
+
+/**
* vte_get_major_version:
*
* Returns the major version of the VTE library at runtime.
diff --git a/src/vteterminal.h b/src/vteterminal.h
index 59f8ce7..08f3b8f 100644
--- a/src/vteterminal.h
+++ b/src/vteterminal.h
@@ -170,6 +170,11 @@ void vte_terminal_paste_primary(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
void vte_terminal_select_all(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
void vte_terminal_unselect_all(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+/* By-word selection */
+void vte_terminal_set_word_char_exceptions(VteTerminal *terminal,
+ const char *word_char_exceptions) _VTE_GNUC_NONNULL(1);
+const char *vte_terminal_get_word_char_exceptions(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
+
/* Set the terminal's size. */
void vte_terminal_set_size(VteTerminal *terminal,
glong columns, glong rows) _VTE_GNUC_NONNULL(1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]