From 8c6de6cc718debf44f6056a4c34c4fbb13bc5020 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 13 Jul 2025 00:53:58 +0300 Subject: 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. --- src/qreg.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/qreg.h') diff --git a/src/qreg.h b/src/qreg.h index 7a9e13c..aaadb7a 100644 --- a/src/qreg.h +++ b/src/qreg.h @@ -156,7 +156,13 @@ struct teco_qreg_table_t { void teco_qreg_table_init(teco_qreg_table_t *table, gboolean must_undo); void teco_qreg_table_init_locals(teco_qreg_table_t *table, gboolean must_undo); -/** @memberof teco_qreg_table_t */ +/** + * Insert Q-Register into table. + * + * @return If non-NULL a register with the same name as qreg already + * existed in table. In this case qreg is __not__ automatically freed. + * @memberof teco_qreg_table_t + */ static inline teco_qreg_t * teco_qreg_table_insert(teco_qreg_table_t *table, teco_qreg_t *qreg) { @@ -164,6 +170,17 @@ teco_qreg_table_insert(teco_qreg_table_t *table, teco_qreg_t *qreg) return (teco_qreg_t *)teco_rb3str_insert(&table->tree, TRUE, &qreg->head); } +/** @memberof teco_qreg_table_t */ +static inline void +teco_qreg_table_insert_unique(teco_qreg_table_t *table, teco_qreg_t *qreg) +{ + G_GNUC_UNUSED teco_qreg_t *found = teco_qreg_table_insert(table, qreg); + g_assert(found == NULL); +} + +gboolean teco_qreg_table_replace(teco_qreg_table_t *table, teco_qreg_t *qreg, + gboolean inherit_int, GError **error); + /** @memberof teco_qreg_table_t */ static inline teco_qreg_t * teco_qreg_table_find(teco_qreg_table_t *table, const gchar *name, gsize len) -- cgit v1.2.3