aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/spawn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/spawn.c')
-rw-r--r--src/spawn.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/spawn.c b/src/spawn.c
index 6289830..933d8f4 100644
--- a/src/spawn.c
+++ b/src/spawn.c
@@ -49,17 +49,6 @@
#include "error.h"
#include "spawn.h"
-/*
- * Glib v2.70 deprecates g_spawn_check_exit_status(),
- * renaming it to g_spawn_check_wait_status().
- * This leaves no way to work on both new and old versions without warnings.
- */
-#if GLIB_CHECK_VERSION(2,70,0)
-#define teco_spawn_check_wait_status g_spawn_check_wait_status
-#else
-#define teco_spawn_check_wait_status g_spawn_check_exit_status
-#endif
-
static void teco_spawn_child_watch_cb(GPid pid, gint status, gpointer data);
static gboolean teco_spawn_stdin_watch_cb(GIOChannel *chan,
GIOCondition condition, gpointer data);
@@ -125,10 +114,9 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error)
#ifdef G_OS_WIN32
if (!(teco_ed & TECO_ED_SHELLEMU)) {
- 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, NULL, error))
+ if (!teco_qreg_table_get_string(&teco_qreg_table_globals, "$COMSPEC",
+ &comspec.data, &comspec.len, error))
return NULL;
if (teco_string_contains(comspec, '\0')) {
teco_string_clear(&comspec);
@@ -145,10 +133,9 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error)
}
#elif defined(G_OS_UNIX)
if (!(teco_ed & TECO_ED_SHELLEMU)) {
- 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, NULL, error))
+ if (!teco_qreg_table_get_string(&teco_qreg_table_globals, "$SHELL",
+ &shell.data, &shell.len, error))
return NULL;
if (teco_string_contains(shell, '\0')) {
teco_string_clear(&shell);
@@ -435,10 +422,16 @@ teco_state_execute_done(teco_machine_main_t *ctx, teco_string_t str, GError **er
teco_interface_ssm(SCI_GOTOPOS, teco_spawn_ctx.to, 0);
}
- teco_interface_ssm(SCI_BEGINUNDOACTION, 0, 0);
teco_spawn_ctx.start = teco_spawn_ctx.from;
g_main_loop_run(teco_spawn_ctx.mainloop);
if (!teco_spawn_ctx.register_argument) {
+ if (teco_current_doc_must_undo()) {
+ undo__teco_interface_ssm(SCI_DELETERANGE, teco_spawn_ctx.to,
+ teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0)-teco_spawn_ctx.to);
+ teco_undo_interface_insert(teco_spawn_ctx.from,
+ teco_spawn_ctx.to - teco_spawn_ctx.from);
+ }
+
teco_interface_ssm(SCI_DELETERANGE, teco_spawn_ctx.from,
teco_spawn_ctx.to - teco_spawn_ctx.from);
@@ -450,7 +443,6 @@ teco_state_execute_done(teco_machine_main_t *ctx, teco_string_t str, GError **er
teco_current_doc_set_dot(to);
}
- teco_interface_ssm(SCI_ENDUNDOACTION, 0, 0);
if (teco_spawn_ctx.register_argument) {
if (teco_spawn_ctx.stdout_reader.eol_style >= 0) {
@@ -459,9 +451,6 @@ teco_state_execute_done(teco_machine_main_t *ctx, teco_string_t str, GError **er
teco_spawn_ctx.stdout_reader.eol_style);
}
} else if (teco_spawn_ctx.from != teco_spawn_ctx.to || teco_spawn_ctx.text_added) {
- /* undo action has only been created if it changed anything */
- if (teco_current_doc_must_undo())
- undo__teco_interface_ssm(SCI_UNDO, 0, 0);
teco_ring_dirtify();
}