diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-13 00:53:58 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-13 00:53:58 +0300 |
commit | 8c6de6cc718debf44f6056a4c34c4fbb13bc5020 (patch) | |
tree | a522cb6d5608b3a4ba08fdb8a3f840514eb07281 /src/interface-gtk | |
parent | 078c1927cffc6514168566c267151a8d6eca7367 (diff) | |
download | sciteco-8c6de6cc718debf44f6056a4c34c4fbb13bc5020.tar.gz |
allow changing the default clipboard by setting the `~` integer
* It continues to default to 67 (C), which is the system clipboard.
But you can now overwrite it e.g. by adding `^^PU~` to the profile.
* This fixes a minor memory leak:
If you set one of the clipboard registers in the profile (initializing
them as plain registers), the clipboard register had been leaked.
The clipboard registers now replace any existing register,
while at the same time preserving the numeric part.
* All remaining Q-Reg table insertions use a new function
teco_qreg_table_insert_unique() which adds an assertion, so that
we notice any future possible memory leaks.
Diffstat (limited to 'src/interface-gtk')
-rw-r--r-- | src/interface-gtk/interface.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c index 3d33972..6c22590 100644 --- a/src/interface-gtk/interface.c +++ b/src/interface-gtk/interface.c @@ -160,10 +160,14 @@ teco_interface_init(void) * clipboards/selections are supported on this system, * so we register only some default ones. */ - teco_qreg_table_insert(&teco_qreg_table_globals, teco_qreg_clipboard_new("")); - teco_qreg_table_insert(&teco_qreg_table_globals, teco_qreg_clipboard_new("P")); - teco_qreg_table_insert(&teco_qreg_table_globals, teco_qreg_clipboard_new("S")); - teco_qreg_table_insert(&teco_qreg_table_globals, teco_qreg_clipboard_new("C")); + teco_qreg_table_replace(&teco_qreg_table_globals, + teco_qreg_clipboard_new(""), TRUE, NULL); + teco_qreg_table_replace(&teco_qreg_table_globals, + teco_qreg_clipboard_new("P"), TRUE, NULL); + teco_qreg_table_replace(&teco_qreg_table_globals, + teco_qreg_clipboard_new("S"), TRUE, NULL); + teco_qreg_table_replace(&teco_qreg_table_globals, + teco_qreg_clipboard_new("C"), TRUE, NULL); teco_interface.event_queue = g_queue_new(); @@ -606,6 +610,8 @@ teco_interface_cmdline_update(const teco_cmdline_t *cmdline) static GdkAtom teco_interface_get_selection_by_name(const gchar *name) { + g_assert(*name != '\0'); + /* * We can use gdk_atom_intern() to support arbitrary X11 selection * names. However, since we cannot find out which selections are @@ -614,11 +620,9 @@ teco_interface_get_selection_by_name(const gchar *name) * Checking them here avoids expensive X server roundtrips. */ switch (*name) { - case '\0': return GDK_NONE; case 'P': return GDK_SELECTION_PRIMARY; case 'S': return GDK_SELECTION_SECONDARY; case 'C': return GDK_SELECTION_CLIPBOARD; - default: break; } return gdk_atom_intern(name, FALSE); |