Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/ksh enable meta key in emacs mode for 7-bit locales. ap...
details: https://anonhg.NetBSD.org/src/rev/87e2ab36075d
branches: trunk
changeset: 538047:87e2ab36075d
user: provos <provos%NetBSD.org@localhost>
date: Thu Oct 10 17:41:19 2002 +0000
description:
enable meta key in emacs mode for 7-bit locales. approved thorpej.
diffstat:
bin/ksh/emacs.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diffs (69 lines):
diff -r df0a6c862af2 -r 87e2ab36075d bin/ksh/emacs.c
--- a/bin/ksh/emacs.c Thu Oct 10 17:12:23 2002 +0000
+++ b/bin/ksh/emacs.c Thu Oct 10 17:41:19 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emacs.c,v 1.14 2002/09/27 13:23:55 provos Exp $ */
+/* $NetBSD: emacs.c,v 1.15 2002/10/10 17:41:19 provos Exp $ */
/*
* Emacs-like command line editing and history
@@ -15,6 +15,7 @@
#include "ksh_stat.h"
#include "ksh_dir.h"
#include <ctype.h>
+#include <locale.h>
#include "edit.h"
static Area aedit;
@@ -23,6 +24,8 @@
#undef CTRL /* _BSD brain damage */
#define CTRL(x) ((x) == '?' ? 0x7F : (x) & 0x1F) /* ASCII */
#define UNCTRL(x) ((x) == 0x7F ? '?' : (x) | 0x40) /* ASCII */
+#define META(x) ((x) & 0x7f)
+#define ISMETA(x) (x_usemeta && ((x) & 0x80))
/* values returned by keyboard functions */
@@ -98,6 +101,7 @@
static int x_displen;
static int x_arg; /* general purpose arg */
static int x_arg_defaulted;/* x_arg not explicitly set; defaulted to 1 */
+static int x_usemeta; /* no 8-bit ascii, meta = ESC */
static int xlp_valid;
/* end from 4.9 edit.h } */
@@ -366,6 +370,11 @@
if ((c = x_e_getc()) < 0)
return 0;
+ if (ISMETA(c)) {
+ c = META(c);
+ x_curprefix = 1;
+ }
+
f = x_curprefix == -1 ? XFUNC_insert
: x_tab[x_curprefix][c&CHARMASK];
@@ -1495,6 +1504,7 @@
x_init_emacs()
{
register int i, j;
+ char *locale;
ainit(AEDIT);
x_nextcmd = -1;
@@ -1513,6 +1523,14 @@
for (i = 1; i < X_NTABS; i++)
for (j = 0; j < X_TABSZ; j++)
x_atab[i][j] = NULL;
+
+ /* Determine if we can translate meta key or use 8-bit AscII
+ * XXX - It would be nice if there was a locale attribute to
+ * determine if the locale is 7-bit or not.
+ */
+ locale = setlocale(LC_CTYPE, NULL);
+ if (locale == NULL || !strcmp(locale, "C") || !strcmp(locale, "POSIX"))
+ x_usemeta = 1;
}
static void
Home |
Main Index |
Thread Index |
Old Index