From c71ed30cf0c554d288edfe87842082cc9ec393a7 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 28 Aug 2024 20:52:03 +0200 Subject: implemented Unicode support for rubin/rubout and a number of commands (WIP) (refs #5) certain test cases are still way too slow: 10000<@I/X^J/> 20000 or 10000<@I/X^J/> 20000<%a-1J> SCI_ALLOCATELINECHARACTERINDEX does not help much here. It probably speeds up only SCI_LINEFROMINDEXPOSITION and SCI_INDEXPOSITIONFROMLINE. --- src/cmdline.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/cmdline.c') diff --git a/src/cmdline.c b/src/cmdline.c index ca0a570..255ffac 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -179,6 +179,19 @@ teco_cmdline_insert(const gchar *data, gsize len, GError **error) return TRUE; } +gboolean +teco_cmdline_rubin(GError **error) +{ + if (!teco_cmdline.str.len) + return TRUE; + + const gchar *start, *end, *next; + start = teco_cmdline.str.data+teco_cmdline.effective_len; + end = teco_cmdline.str.data+teco_cmdline.str.len; + next = g_utf8_find_next_char(start, end) ? : end; + return teco_cmdline_insert(start, next-start, error); +} + gboolean teco_cmdline_keypress_c(gchar key, GError **error) { @@ -316,6 +329,18 @@ teco_cmdline_fnmacro(const gchar *name, GError **error) return TRUE; } +void +teco_cmdline_rubout(void) +{ + const gchar *p; + p = g_utf8_find_prev_char(teco_cmdline.str.data, + teco_cmdline.str.data+teco_cmdline.effective_len); + if (p) { + teco_cmdline.effective_len = p - teco_cmdline.str.data; + teco_undo_pop(teco_cmdline.effective_len); + } +} + static void TECO_DEBUG_CLEANUP teco_cmdline_cleanup(void) { -- cgit v1.2.3