Commit b720a360 authored by Christian Persch's avatar Christian Persch

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
parent 8fc00da9
......@@ -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
......
......@@ -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 }
};
......
......@@ -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;
......
......@@ -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.
*/
......@@ -13279,6 +13300,44 @@ vte_terminal_get_input_enabled (VteTerminal *terminal)
return terminal->pvt->input_enabled;
}
/**
* 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:
*
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment