diff options
-rw-r--r-- | doc/sciteco.7.template | 14 | ||||
-rw-r--r-- | fallback.teco_ini | bin | 2221 -> 2225 bytes | |||
-rw-r--r-- | src/interface-curses/interface.c | 15 | ||||
-rw-r--r-- | src/interface-gtk/interface.c | 12 | ||||
-rw-r--r-- | src/qreg.c | 49 | ||||
-rw-r--r-- | src/qreg.h | 24 | ||||
-rw-r--r-- | src/sciteco.h | 3 |
7 files changed, 47 insertions, 70 deletions
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template index 16a54a6..a289476 100644 --- a/doc/sciteco.7.template +++ b/doc/sciteco.7.template @@ -1591,14 +1591,10 @@ The existence of a clipboard register can thus be checked in macros to determine whether getting and modifying that particular clipboard is supported natively. .br -If there are multiple clipboard registers, you can choose -the default one via the ASCII code in the numeric cell of -register \(lq~\(rq, which defaults to 67 (\(lq~C\(rq). -For instance if setting \(lq^^PU~\(rq, register \(lq~\(rq -and register \(lq~P\(rq will refer to the same primary -clipboard. -The numeric parts of all the other clipboard registers are -currently not used by \*(ST. +The default clipboard \(lq~\(rq refers to the clipboard selection +if there are multiple clipboards. +You can set bit 10 of the \fBED\fP flags to change it to the +primary clipboard. .br \*(ST supports two ways of driving the clipboard on ncurses. .SCITECO_TOPIC OSC-52 xterm @@ -1647,6 +1643,8 @@ EOL normalization will take place (if enabled), so that pasting clipboards does not introduce unexpected EOL sequences. The Q-Register view's EOL mode will \fBnot\fP be guessed from the original clipboard contents, though. +The numeric parts of the clipboard registers are +currently not used by \*(ST. .TP .BI ^K key Key macro registers as documented in section diff --git a/fallback.teco_ini b/fallback.teco_ini Binary files differindex cee87dc..68814dd 100644 --- a/fallback.teco_ini +++ b/fallback.teco_ini diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 1b04f47..127e0b6 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -1239,8 +1239,7 @@ teco_interface_init_clipboard(void) if (rc == PDC_CLIP_SUCCESS) PDC_freeclipboard(contents); - 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("")); } gboolean @@ -1506,14 +1505,10 @@ teco_interface_init_clipboard(void) !teco_qreg_table_find(&teco_qreg_table_globals, "$SCITECO_CLIPBOARD_GET", 22))) return; - 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_qreg_table_replace(&teco_qreg_table_globals, teco_qreg_clipboard_new("")); + teco_qreg_table_replace(&teco_qreg_table_globals, teco_qreg_clipboard_new("P")); + teco_qreg_table_replace(&teco_qreg_table_globals, teco_qreg_clipboard_new("S")); + teco_qreg_table_replace(&teco_qreg_table_globals, teco_qreg_clipboard_new("C")); } gboolean diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c index 6c22590..b2316bc 100644 --- a/src/interface-gtk/interface.c +++ b/src/interface-gtk/interface.c @@ -160,14 +160,10 @@ teco_interface_init(void) * clipboards/selections are supported on this system, * so we register only some default ones. */ - 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_qreg_table_replace(&teco_qreg_table_globals, teco_qreg_clipboard_new("")); + teco_qreg_table_replace(&teco_qreg_table_globals, teco_qreg_clipboard_new("P")); + teco_qreg_table_replace(&teco_qreg_table_globals, teco_qreg_clipboard_new("S")); + teco_qreg_table_replace(&teco_qreg_table_globals, teco_qreg_clipboard_new("C")); teco_interface.event_queue = g_queue_new(); @@ -25,8 +25,6 @@ #include <Scintilla.h> -//#include <rb3ptr.h> - #include "sciteco.h" #include "string-utils.h" #include "file-utils.h" @@ -803,19 +801,21 @@ teco_qreg_workingdir_new(void) return teco_qreg_new(&vtable, "$", 1); } -static inline gchar +static inline const gchar * teco_qreg_clipboard_get_name(const teco_qreg_t *qreg) { g_assert(1 <= qreg->head.name.len && qreg->head.name.len <= 2 && *qreg->head.name.data == '~'); - return qreg->head.name.len < 2 ? qreg->integer : qreg->head.name.data[1]; + if (qreg->head.name.len > 1) + return qreg->head.name.data+1; + return teco_ed & TECO_ED_CLIP_PRIMARY ? "P" : "C"; } static gboolean teco_qreg_clipboard_set_string(teco_qreg_t *qreg, const gchar *str, gsize len, guint codepage, GError **error) { - gchar clipboard_name[] = {teco_qreg_clipboard_get_name(qreg), '\0'}; + const gchar *clipboard_name = teco_qreg_clipboard_get_name(qreg); if (teco_ed & TECO_ED_AUTOEOL) { /* @@ -875,7 +875,7 @@ teco_qreg_clipboard_undo_set_string(teco_qreg_t *qreg, GError **error) if (!teco_undo_enabled) return TRUE; - gchar clipboard_name[] = {teco_qreg_clipboard_get_name(qreg), '\0'}; + const gchar *clipboard_name = teco_qreg_clipboard_get_name(qreg); /* * Ownership of str is passed to the undo token. @@ -893,7 +893,7 @@ static gboolean teco_qreg_clipboard_get_string(teco_qreg_t *qreg, gchar **str, gsize *len, guint *codepage, GError **error) { - gchar clipboard_name[] = {teco_qreg_clipboard_get_name(qreg), '\0'}; + const gchar *clipboard_name = teco_qreg_clipboard_get_name(qreg); if (!(teco_ed & TECO_ED_AUTOEOL)) /* @@ -937,7 +937,7 @@ teco_qreg_clipboard_get_string(teco_qreg_t *qreg, gchar **str, gsize *len, static gboolean teco_qreg_clipboard_load(teco_qreg_t *qreg, const gchar *filename, GError **error) { - gchar clipboard_name[] = {teco_qreg_clipboard_get_name(qreg), '\0'}; + const gchar *clipboard_name = teco_qreg_clipboard_get_name(qreg); g_auto(teco_string_t) str = {NULL, 0}; @@ -997,39 +997,6 @@ teco_qreg_table_init_locals(teco_qreg_table_t *table, gboolean must_undo) teco_qreg_table_insert_unique(table, table->radix); } -/** - * Insert Q-register into table, possibly replacing a register with the same name. - * - * This is useful for initializing Q-registers late when the user could have - * already created one in the profile. - * - * @param table Table to insert into - * @param qreg Q-Register to insert - * @param inherit_int Whether to preserve the numeric part of - * any Q-register found in the table. - * @param error GError - * @return TRUE if error occurred - * @memberof teco_qreg_table_t - */ -gboolean -teco_qreg_table_replace(teco_qreg_table_t *table, teco_qreg_t *qreg, - gboolean inherit_int, GError **error) -{ - teco_qreg_t *found = teco_qreg_table_insert(table, qreg); - if (!found) - return TRUE; - - teco_int_t v; - if (inherit_int && - (!found->vtable->get_integer(found, &v, error) || - !qreg->vtable->set_integer(qreg, v, error))) - return FALSE; - - rb3_replace(&found->head.head, &qreg->head.head); - teco_qreg_free(found); - return TRUE; -} - static inline void teco_qreg_table_remove(teco_qreg_t *reg) { @@ -18,6 +18,8 @@ #include <glib.h> +//#include <rb3ptr.h> + #include "sciteco.h" #include "view.h" #include "doc.h" @@ -178,8 +180,26 @@ teco_qreg_table_insert_unique(teco_qreg_table_t *table, teco_qreg_t *qreg) g_assert(found == NULL); } -gboolean teco_qreg_table_replace(teco_qreg_table_t *table, teco_qreg_t *qreg, - gboolean inherit_int, GError **error); +/** + * Insert Q-register into table, possibly replacing a register with the same name. + * + * This is useful for initializing Q-registers late when the user could have + * already created one in the profile. + * + * @param table Table to insert into + * @param qreg Q-Register to insert + * + * @memberof teco_qreg_table_t + */ +static inline void +teco_qreg_table_replace(teco_qreg_table_t *table, teco_qreg_t *qreg) +{ + teco_qreg_t *found = teco_qreg_table_insert(table, qreg); + if (found) { + rb3_replace(&found->head.head, &qreg->head.head); + teco_qreg_free(found); + } +} /** @memberof teco_qreg_table_t */ static inline teco_qreg_t * diff --git a/src/sciteco.h b/src/sciteco.h index 4868303..2dc4749 100644 --- a/src/sciteco.h +++ b/src/sciteco.h @@ -92,7 +92,8 @@ enum { TECO_ED_MOUSEKEY = (1 << 6), TECO_ED_SHELLEMU = (1 << 7), TECO_ED_OSC52 = (1 << 8), - TECO_ED_ICONS = (1 << 9) + TECO_ED_ICONS = (1 << 9), + TECO_ED_CLIP_PRIMARY = (1 << 10) }; /* in main.c */ |