diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-11-22 16:53:08 +0100 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-11-22 19:51:04 +0100 |
| commit | 910d8a61772570198eb12f752c5b7f8fcd006dc2 (patch) | |
| tree | 13fcd9805c3a82e8b39691a1e6b5d2e81662f784 /src/qreg.h | |
| parent | b283996b6ecffc3a1d05c52df02c89ec86cafa96 (diff) | |
implemented the FQq (free Q-register) command and extended EF
Since Q-registers can be dynamically allocated, we must have
a command for freeing them as well. This is especially important
when using long Q-register names to implement arrays and other complex
data structures. To ease freeing entire arrays, the :FQ[array.]
modification can be used -- this will free all registers with the given
prefix efficiently.
There is currently no variant that tells you whether the register
actually existed -- you can first check with :Qq if that is important.
EF has also been extended to free the currently edited register -
which is also what Video TECO appeared to do.
If the currently edited register is freed, we edit the current
buffer again.
Diffstat (limited to 'src/qreg.h')
| -rw-r--r-- | src/qreg.h | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -127,6 +127,11 @@ struct teco_qreg_t { guint must_undo : 1; /** whether the number cell is integer or float_val */ guint is_float : 1; + /** + * Whether the register has an internal function and must always exist (`_`, `~` etc.) + * Such a register cannot be removed with FQ. + */ + guint internal : 1; } flags; }; @@ -168,7 +173,7 @@ teco_qreg_free(teco_qreg_t *qreg) g_free(qreg); } -extern const teco_qreg_table_t *teco_qreg_table_current; +extern teco_qreg_table_t *teco_qreg_table_current; extern teco_qreg_t *teco_qreg_current; /** @extends teco_rb3str_tree_t */ @@ -236,6 +241,9 @@ teco_qreg_table_replace(teco_qreg_table_t *table, teco_qreg_t *qreg) } } +gboolean teco_qreg_table_remove(teco_qreg_table_t *table, teco_qreg_t *qreg, + GError **error); + /** @memberof teco_qreg_table_t */ static inline teco_qreg_t * teco_qreg_table_find(teco_qreg_table_t *table, const gchar *name, gsize len) @@ -243,6 +251,12 @@ teco_qreg_table_find(teco_qreg_table_t *table, const gchar *name, gsize len) return (teco_qreg_t *)teco_rb3str_find(&table->tree, TRUE, name, len); } +static inline teco_qreg_t * +teco_qreg_table_nfind(teco_qreg_table_t *table, const gchar *name, gsize len) +{ + return (teco_qreg_t *)teco_rb3str_nfind(&table->tree, TRUE, name, len); +} + /** @memberof teco_qreg_table_t */ static inline gboolean teco_qreg_table_get_string(teco_qreg_table_t *table, const gchar *name, @@ -325,7 +339,12 @@ typedef enum { */ TECO_QREG_OPTIONAL, /** Initialize register if it does not already exist */ - TECO_QREG_OPTIONAL_INIT + TECO_QREG_OPTIONAL_INIT, + /** + * Return register with the given prefix + * or NULL if no such register exists. + */ + TECO_QREG_OPTIONAL_PREFIX } teco_qreg_type_t; typedef struct teco_machine_qregspec_t teco_machine_qregspec_t; @@ -339,6 +358,7 @@ void teco_machine_qregspec_reset(teco_machine_qregspec_t *ctx); * FIXME: This uses a forward declaration since we must not include parser.h */ struct teco_machine_stringbuilding_t *teco_machine_qregspec_get_stringbuilding(teco_machine_qregspec_t *ctx); +teco_string_t teco_machine_qregspec_get_string(teco_machine_qregspec_t *ctx); teco_machine_qregspec_status_t teco_machine_qregspec_input(teco_machine_qregspec_t *ctx, gunichar chr, teco_qreg_t **result, |
