aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/qreg.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-27 19:51:10 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-28 04:32:12 +0300
commit427092d2c8ee11b4a56eb50dbf68861f10f2a81f (patch)
tree87b6be1df9aaa7a69a615f759f347562a8bdaf9b /src/qreg.c
parent5a6862bba8eed7fc1f74592b88f677e22ed86f25 (diff)
downloadsciteco-427092d2c8ee11b4a56eb50dbf68861f10f2a81f.tar.gz
fixed rubbing out <:Xq>, <:^Uq> and other append-to-register operations
* This was a regression introduced in 41ab5cf0289dab60ac1ddc97cf9680ee2468ea6c, which changed the semantics of teco_doc_undo_set_string(). * Removed undo_append_string() Q-Reg virtual method. append_string() now does its own undo token emission, so that we can defer the teco_doc_undo_edit() after the point that the document was initialized. This is important, so that we can configure the default encoding on new registers.
Diffstat (limited to 'src/qreg.c')
-rw-r--r--src/qreg.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/qreg.c b/src/qreg.c
index a0e5415..487a725 100644
--- a/src/qreg.c
+++ b/src/qreg.c
@@ -183,6 +183,20 @@ teco_qreg_plain_append_string(teco_qreg_t *qreg, const gchar *str, gsize len, GE
if (!len)
return TRUE;
+ if (qreg->must_undo) { // FIXME
+ /*
+ * Necessary, so that upon rubout the
+ * string's parameters are restored.
+ */
+ teco_doc_update(&qreg->string, teco_qreg_view);
+
+ if (teco_qreg_current && teco_qreg_current->must_undo) // FIXME
+ teco_doc_undo_edit(&teco_qreg_current->string);
+
+ teco_doc_undo_reset(&qreg->string);
+ undo__teco_view_ssm(teco_qreg_view, SCI_UNDO, 0, 0);
+ }
+
if (teco_qreg_current)
teco_doc_update(&teco_qreg_current->string, teco_qreg_view);
@@ -194,6 +208,15 @@ teco_qreg_plain_append_string(teco_qreg_t *qreg, const gchar *str, gsize len, GE
if (teco_qreg_current)
teco_doc_edit(&teco_qreg_current->string, 0);
+
+ /*
+ * Make sure these undo tokens are only generated now,
+ * so that teco_doc_edit() always initializes the document and
+ * the default codepage.
+ */
+ if (qreg->must_undo) // FIXME
+ teco_doc_undo_edit(&qreg->string);
+
return TRUE;
}
@@ -354,7 +377,6 @@ teco_qreg_plain_save(teco_qreg_t *qreg, const gchar *filename, GError **error)
.set_string = teco_qreg_plain_set_string, \
.undo_set_string = teco_qreg_plain_undo_set_string, \
.append_string = teco_qreg_plain_append_string, \
- .undo_append_string = teco_qreg_plain_undo_set_string, \
.get_string = teco_qreg_plain_get_string, \
.get_character = teco_qreg_plain_get_character, \
.get_length = teco_qreg_plain_get_length, \
@@ -567,12 +589,6 @@ teco_qreg_bufferinfo_append_string(teco_qreg_t *qreg, const gchar *str, gsize le
return FALSE;
}
-static gboolean
-teco_qreg_bufferinfo_undo_append_string(teco_qreg_t *qreg, GError **error)
-{
- return TRUE;
-}
-
/*
* NOTE: The `string` component is currently unused on the "*" register.
*/
@@ -609,7 +625,6 @@ teco_qreg_bufferinfo_new(void)
.set_string = teco_qreg_bufferinfo_set_string,
.undo_set_string = teco_qreg_bufferinfo_undo_set_string,
.append_string = teco_qreg_bufferinfo_append_string,
- .undo_append_string = teco_qreg_bufferinfo_undo_append_string,
.get_string = teco_qreg_bufferinfo_get_string,
/*
* As teco_qreg_bufferinfo_set_string() is not implemented,
@@ -671,12 +686,6 @@ teco_qreg_workingdir_append_string(teco_qreg_t *qreg, const gchar *str, gsize le
}
static gboolean
-teco_qreg_workingdir_undo_append_string(teco_qreg_t *qreg, GError **error)
-{
- return TRUE;
-}
-
-static gboolean
teco_qreg_workingdir_get_string(teco_qreg_t *qreg, gchar **str, gsize *len,
guint *codepage, GError **error)
{
@@ -709,7 +718,6 @@ teco_qreg_workingdir_new(void)
.set_string = teco_qreg_workingdir_set_string,
.undo_set_string = teco_qreg_workingdir_undo_set_string,
.append_string = teco_qreg_workingdir_append_string,
- .undo_append_string = teco_qreg_workingdir_undo_append_string,
.get_string = teco_qreg_workingdir_get_string
);
@@ -779,12 +787,6 @@ teco_qreg_clipboard_append_string(teco_qreg_t *qreg, const gchar *str, gsize len
}
static gboolean
-teco_qreg_clipboard_undo_append_string(teco_qreg_t *qreg, GError **error)
-{
- return TRUE;
-}
-
-static gboolean
teco_qreg_clipboard_undo_set_string(teco_qreg_t *qreg, GError **error)
{
/*
@@ -878,7 +880,6 @@ teco_qreg_clipboard_new(const gchar *name)
.set_string = teco_qreg_clipboard_set_string,
.undo_set_string = teco_qreg_clipboard_undo_set_string,
.append_string = teco_qreg_clipboard_append_string,
- .undo_append_string = teco_qreg_clipboard_undo_append_string,
.get_string = teco_qreg_clipboard_get_string,
.load = teco_qreg_clipboard_load
);