diff options
-rw-r--r-- | doc/sciteco.7.template | 1 | ||||
-rw-r--r-- | src/qreg.c | 40 | ||||
-rw-r--r-- | tests/testsuite.at | 5 |
3 files changed, 21 insertions, 25 deletions
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template index a289476..965e203 100644 --- a/doc/sciteco.7.template +++ b/doc/sciteco.7.template @@ -1549,7 +1549,6 @@ but querying \(lq$\(rq will still return an absolute path. The \(lq$\(rq register may also be edited but changing its string contents this way has no effect on the current working directory. -Appending to the \(lq$\(rq register is unsupported. The register is initialized automatically on startup. .TP .BR $ " (Escape)" @@ -487,6 +487,19 @@ teco_qreg_external_edit(teco_qreg_t *qreg, GError **error) } static gboolean +teco_qreg_external_append_string(teco_qreg_t *qreg, const gchar *str, gsize len, GError **error) +{ + g_auto(teco_string_t) buf = {NULL, 0}; + guint codepage; + + if (!qreg->vtable->undo_set_string(qreg, error) || + !qreg->vtable->get_string(qreg, &buf.data, &buf.len, &codepage, error)) + return FALSE; + teco_string_append(&buf, str, len); + return qreg->vtable->set_string(qreg, buf.data, buf.len, codepage, error); +} + +static gboolean teco_qreg_external_exchange_string(teco_qreg_t *qreg, teco_doc_t *src, GError **error) { g_auto(teco_string_t) other_str, own_str = {NULL, 0}; @@ -604,6 +617,7 @@ teco_qreg_external_save(teco_qreg_t *qreg, const gchar *filename, GError **error .exchange_string = teco_qreg_external_exchange_string, \ .undo_exchange_string = teco_qreg_external_undo_exchange_string, \ .edit = teco_qreg_external_edit, \ + .append_string = teco_qreg_external_append_string, \ .get_character = teco_qreg_external_get_character, \ .get_length = teco_qreg_external_get_length, \ .load = teco_qreg_external_load, \ @@ -636,6 +650,8 @@ teco_qreg_bufferinfo_get_integer(teco_qreg_t *qreg, teco_int_t *ret, GError **er /* * FIXME: Something could be implemented here. There are 2 possibilities: * Either it renames the current buffer, or opens a file (alternative to EB). + * Should we implement it, we can probably remove the append_string + * implementation below. */ static gboolean teco_qreg_bufferinfo_set_string(teco_qreg_t *qreg, const gchar *str, gsize len, @@ -741,17 +757,6 @@ teco_qreg_workingdir_undo_set_string(teco_qreg_t *qreg, GError **error) return TRUE; } -/* - * FIXME: Redundant with teco_qreg_bufferinfo_append_string()... - * Best solution would be to simply implement them. - */ -static gboolean -teco_qreg_workingdir_append_string(teco_qreg_t *qreg, const gchar *str, gsize len, GError **error) -{ - teco_error_qregopunsupported_set(error, qreg->head.name.data, qreg->head.name.len, FALSE); - return FALSE; -} - static gboolean teco_qreg_workingdir_get_string(teco_qreg_t *qreg, gchar **str, gsize *len, guint *codepage, GError **error) @@ -785,7 +790,6 @@ teco_qreg_workingdir_new(void) static teco_qreg_vtable_t vtable = TECO_INIT_QREG_EXTERNAL( .set_string = teco_qreg_workingdir_set_string, .undo_set_string = teco_qreg_workingdir_undo_set_string, - .append_string = teco_qreg_workingdir_append_string, .get_string = teco_qreg_workingdir_get_string ); @@ -851,17 +855,6 @@ teco_qreg_clipboard_set_string(teco_qreg_t *qreg, const gchar *str, gsize len, return TRUE; } -/* - * FIXME: Redundant with teco_qreg_bufferinfo_append_string()... - * Best solution would be to simply implement them. - */ -static gboolean -teco_qreg_clipboard_append_string(teco_qreg_t *qreg, const gchar *str, gsize len, GError **error) -{ - teco_error_qregopunsupported_set(error, qreg->head.name.data, qreg->head.name.len, FALSE); - return FALSE; -} - static gboolean teco_qreg_clipboard_undo_set_string(teco_qreg_t *qreg, GError **error) { @@ -953,7 +946,6 @@ teco_qreg_clipboard_new(const gchar *name) static teco_qreg_vtable_t vtable = TECO_INIT_QREG_EXTERNAL( .set_string = teco_qreg_clipboard_set_string, .undo_set_string = teco_qreg_clipboard_undo_set_string, - .append_string = teco_qreg_clipboard_append_string, .get_string = teco_qreg_clipboard_get_string, .load = teco_qreg_clipboard_load ); diff --git a/tests/testsuite.at b/tests/testsuite.at index 034427f..2c9bec9 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -303,6 +303,11 @@ AT_SETUP([Memory limiting]) TE_CHECK([[50*1000*1000,2EJ <[a> !]!]], 1, ignore, ignore) AT_CLEANUP +AT_SETUP([Change working directory]) +TE_CHECK([[:Q$Ul @FG'..' Ql-:Q$-1"<(0/0)']], 0, ignore, ignore) +TE_CHECK([[:Q$Ul :@^U$'/..' Ql-:Q$-1"<(0/0)']], 0, ignore, ignore) +AT_CLEANUP + AT_SETUP([Execute external command]) # TODO: It would be a better test to generate a random number of bytes. # Unfortunately, neither $RANDOM, shuf nor jot are portable. |