summaryrefslogtreecommitdiff
path: root/bin/ksh/emacs.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2016-01-08 13:17:58 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2016-01-08 13:17:58 +0000
commitf0fc11bef09b89446b6fc13f4c1a8798ee0db08f (patch)
treeb3d1f571fa5f673b201509ac67cb02fbf2145f3e /bin/ksh/emacs.c
parent41d6f00eaaf23d98000a86a28630193778903926 (diff)
Next step in UTF-8 support:
1. Improve all functions involving words by allowing non-ASCII characters to be part of words. 2. Allow insertion of non-ASCII characters without screwing up the display, by backing up to the start byte after inserting a continuation byte, and starting to re-print there. 3. Fix forward movement which i didn't get quite right in my previous commit: Always advance to a start byte, never to a final continuation byte, or the next insertion would split the character in the middle. OK mpi@
Diffstat (limited to 'bin/ksh/emacs.c')
-rw-r--r--bin/ksh/emacs.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/ksh/emacs.c b/bin/ksh/emacs.c
index 9a8259336b2..dfd94509e11 100644
--- a/bin/ksh/emacs.c
+++ b/bin/ksh/emacs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emacs.c,v 1.63 2015/12/30 15:21:42 tedu Exp $ */
+/* $OpenBSD: emacs.c,v 1.64 2016/01/08 13:17:57 schwarze Exp $ */
/*
* Emacs-like command line editing and history
@@ -51,7 +51,8 @@ struct x_ftab {
#define is_cfs(c) (c == ' ' || c == '\t' || c == '"' || c == '\'')
/* Separator for motion */
-#define is_mfs(c) (!(isalnum((unsigned char)c) || c == '_' || c == '$'))
+#define is_mfs(c) (!(isalnum((unsigned char)c) || \
+ c == '_' || c == '$' || c & 0x80))
/* Arguments for do_complete()
* 0 = enumerate M-= complete as much as possible and then list
@@ -683,6 +684,11 @@ x_zots(char *str)
{
int adj = x_adj_done;
+ if (str > xbuf && isu8cont(*str)) {
+ while (str > xbuf && isu8cont(*str))
+ str--;
+ x_e_putc('\b');
+ }
x_lastcp();
while (*str && str < xlp && adj == x_adj_done)
x_zotc(*str++);
@@ -729,7 +735,7 @@ x_mv_forw(int c)
}
if (x_arg > nleft)
x_arg = nleft;
- while (x_arg < nleft && isu8cont(xcp[x_arg + 1]))
+ while (x_arg < nleft && isu8cont(xcp[x_arg]))
x_arg++;
x_goto(xcp + x_arg);
return KSTD;