From 41ab5cf0289dab60ac1ddc97cf9680ee2468ea6c Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 9 Sep 2024 00:03:33 +0200 Subject: Xq and ]q inherit the document encoding from the source document (refs #5) * ^Uq however always sets an UTF8 register as the source is supposed to be a SciTECO macro which is always UTF-8. * :^Uq preserves the register's encoding * teco_doc_set_string() now also sets the encoding * instead of trying to restore the encoding in teco_doc_undo_set_string(), we now swap out the document in a teco_doc_t and pass it to an undo token. * The get_codepage() Q-Reg method has been removed as the same can now be done with teco_doc_get_string() and the get_string() method. --- src/cmdline.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/cmdline.c') diff --git a/src/cmdline.c b/src/cmdline.c index 255ffac..d6fcd37 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -125,7 +125,8 @@ teco_cmdline_insert(const gchar *data, gsize len, GError **error) teco_qreg_t *cmdline_reg = teco_qreg_table_find(&teco_qreg_table_globals, "\e", 1); teco_string_t new_cmdline; - if (!cmdline_reg->vtable->get_string(cmdline_reg, &new_cmdline.data, &new_cmdline.len, error)) + if (!cmdline_reg->vtable->get_string(cmdline_reg, &new_cmdline.data, &new_cmdline.len, + NULL, error)) return FALSE; /* @@ -307,7 +308,7 @@ teco_cmdline_fnmacro(const gchar *name, GError **error) return TRUE; g_auto(teco_string_t) macro_str = {NULL, 0}; - return macro_reg->vtable->get_string(macro_reg, ¯o_str.data, ¯o_str.len, error) && + return macro_reg->vtable->get_string(macro_reg, ¯o_str.data, ¯o_str.len, NULL, error) && teco_cmdline_keypress(macro_str.data, macro_str.len, error); } @@ -1051,7 +1052,7 @@ teco_state_save_cmdline_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg return &teco_state_start; if (!qreg->vtable->undo_set_string(qreg, error) || - !qreg->vtable->set_string(qreg, teco_last_cmdline.data, teco_last_cmdline.len, error)) + !qreg->vtable->set_string(qreg, teco_last_cmdline.data, teco_last_cmdline.len, SC_CP_UTF8, error)) return NULL; return &teco_state_start; -- cgit v1.2.3