aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmdline.h')
-rw-r--r--src/cmdline.h41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/cmdline.h b/src/cmdline.h
index 85e657a..f4b84e4 100644
--- a/src/cmdline.h
+++ b/src/cmdline.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2023 Robin Haberkorn
+ * Copyright (C) 2012-2024 Robin Haberkorn
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -46,7 +46,7 @@ typedef struct {
gsize effective_len;
/** Program counter within the command-line macro */
- guint pc;
+ gsize pc;
/**
* Specifies whether the immediate editing modifier
@@ -60,35 +60,30 @@ typedef struct {
extern teco_cmdline_t teco_cmdline;
-gboolean teco_cmdline_insert(const gchar *data, gsize len, GError **error);
+gboolean teco_cmdline_keypress(const gchar *data, gsize len, GError **error);
-static inline gboolean
-teco_cmdline_rubin(GError **error)
-{
- return teco_cmdline.effective_len >= teco_cmdline.str.len ||
- teco_cmdline_insert(teco_cmdline.str.data + teco_cmdline.effective_len, 1, error);
-}
+typedef enum {
+ TECO_KEYMACRO_ERROR = 0, /**< GError occurred */
+ TECO_KEYMACRO_SUCCESS, /**< key macro found and inserted */
+ TECO_KEYMACRO_UNDEFINED /**< no key macro found */
+} teco_keymacro_status_t;
-gboolean teco_cmdline_keypress_c(gchar key, GError **error);
+teco_keymacro_status_t teco_cmdline_keymacro(const gchar *name, gssize name_len, GError **error);
static inline gboolean
-teco_cmdline_keypress(const gchar *str, gsize len, GError **error)
+teco_cmdline_keymacro_c(gchar key, GError **error)
{
- for (guint i = 0; i < len; i++)
- if (!teco_cmdline_keypress_c(str[i], error))
- return FALSE;
+ switch (teco_cmdline_keymacro(&key, sizeof(key), error)) {
+ case TECO_KEYMACRO_ERROR:
+ return FALSE;
+ case TECO_KEYMACRO_SUCCESS:
+ break;
+ case TECO_KEYMACRO_UNDEFINED:
+ return teco_cmdline_keypress(&key, sizeof(key), error);
+ }
return TRUE;
}
-gboolean teco_cmdline_fnmacro(const gchar *name, GError **error);
-
-static inline void
-teco_cmdline_rubout(void)
-{
- if (teco_cmdline.effective_len)
- teco_undo_pop(--teco_cmdline.effective_len);
-}
-
extern gboolean teco_quit_requested;
/*