diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-09 00:03:33 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-09 18:22:21 +0200 |
commit | 41ab5cf0289dab60ac1ddc97cf9680ee2468ea6c (patch) | |
tree | 5497c50c7319bd08121afb09d627297ea2b9e17a /src/spawn.c | |
parent | 850fa38db9063e4bd52fba80588bfd3969ff0910 (diff) | |
download | sciteco-41ab5cf0289dab60ac1ddc97cf9680ee2468ea6c.tar.gz |
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.
Diffstat (limited to 'src/spawn.c')
-rw-r--r-- | src/spawn.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/spawn.c b/src/spawn.c index 4317288..c6dd779 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -121,7 +121,7 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error) teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals, "$COMSPEC", 8); g_assert(reg != NULL); teco_string_t comspec; - if (!reg->vtable->get_string(reg, &comspec.data, &comspec.len, error)) + if (!reg->vtable->get_string(reg, &comspec.data, &comspec.len, NULL, error)) return NULL; argv = g_new(gchar *, 5); @@ -140,7 +140,7 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error) teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals, "$SHELL", 6); g_assert(reg != NULL); teco_string_t shell; - if (!reg->vtable->get_string(reg, &shell.data, &shell.len, error)) + if (!reg->vtable->get_string(reg, &shell.data, &shell.len, NULL, error)) return NULL; argv = g_new(gchar *, 4); @@ -673,6 +673,8 @@ teco_spawn_stdout_watch_cb(GIOChannel *chan, GIOCondition condition, gpointer da /* source has already been dispatched */ return G_SOURCE_REMOVE; + teco_qreg_t *qreg = teco_spawn_ctx.register_argument; + for (;;) { teco_string_t buffer; @@ -691,20 +693,16 @@ teco_spawn_stdout_watch_cb(GIOChannel *chan, GIOCondition condition, gpointer da if (!buffer.len) return G_SOURCE_CONTINUE; - if (teco_spawn_ctx.register_argument) { + if (qreg) { if (teco_spawn_ctx.text_added) { - if (!teco_spawn_ctx.register_argument->vtable->undo_append_string(teco_spawn_ctx.register_argument, - &teco_spawn_ctx.error) || - !teco_spawn_ctx.register_argument->vtable->append_string(teco_spawn_ctx.register_argument, - buffer.data, buffer.len, - &teco_spawn_ctx.error)) + if (!qreg->vtable->undo_append_string(qreg, &teco_spawn_ctx.error) || + !qreg->vtable->append_string(qreg, buffer.data, buffer.len, + &teco_spawn_ctx.error)) goto error; } else { - if (!teco_spawn_ctx.register_argument->vtable->undo_set_string(teco_spawn_ctx.register_argument, - &teco_spawn_ctx.error) || - !teco_spawn_ctx.register_argument->vtable->set_string(teco_spawn_ctx.register_argument, - buffer.data, buffer.len, - &teco_spawn_ctx.error)) + if (!qreg->vtable->undo_set_string(qreg, &teco_spawn_ctx.error) || + !qreg->vtable->set_string(qreg, buffer.data, buffer.len, + SC_CP_UTF8, &teco_spawn_ctx.error)) goto error; } } else { |