svn commit: r258165 - user/ed/newcons/sys/dev/vt
Aleksandr Rybalko
ray at FreeBSD.org
Fri Nov 15 11:33:37 UTC 2013
Author: ray
Date: Fri Nov 15 11:33:36 2013
New Revision: 258165
URL: http://svnweb.freebsd.org/changeset/base/258165
Log:
Add VT_ALT_TO_ESC_HACK enabled by default. This will prepend ESC sequence before
any chars when any of ALT keys is down.
! Not sure if it right way, but now it is possible to use Alt keys in vim.
Sponsored by: The FreeBSD Foundation
Modified:
user/ed/newcons/sys/dev/vt/vt.h
user/ed/newcons/sys/dev/vt/vt_core.c
Modified: user/ed/newcons/sys/dev/vt/vt.h
==============================================================================
--- user/ed/newcons/sys/dev/vt/vt.h Fri Nov 15 11:32:19 2013 (r258164)
+++ user/ed/newcons/sys/dev/vt/vt.h Fri Nov 15 11:33:36 2013 (r258165)
@@ -56,6 +56,10 @@
#endif
#endif
+#ifndef VT_ALT_TO_ESC_HACK
+#define VT_ALT_TO_ESC_HACK 1
+#endif
+
#define VT_CONSWINDOW 0
#if defined(SC_TWOBUTTON_MOUSE) || defined(VT_TWOBUTTON_MOUSE)
@@ -125,6 +129,7 @@ struct vt_device {
#define VDF_INITIALIZED 0x20 /* vtterm_cnprobe already done. */
#define VDF_MOUSECURSOR 0x40 /* Mouse cursor visible. */
int vd_keyboard; /* (G) Keyboard index. */
+ unsigned int vd_kbstate; /* (?) Device unit. */
unsigned int vd_unit; /* (c) Device unit. */
};
@@ -318,6 +323,7 @@ static struct vt_device driver ## _consd
.vd_windows = { [VT_CONSWINDOW] = &driver ## _conswindow, }, \
.vd_curwindow = &driver ## _conswindow, \
.vd_markedwin = NULL, \
+ .vd_kbstate = 0, \
}; \
static term_char_t driver ## _constextbuf[(width) * \
(VBF_DEFAULT_HISTORY_SIZE)]; \
Modified: user/ed/newcons/sys/dev/vt/vt_core.c
==============================================================================
--- user/ed/newcons/sys/dev/vt/vt_core.c Fri Nov 15 11:32:19 2013 (r258164)
+++ user/ed/newcons/sys/dev/vt/vt_core.c Fri Nov 15 11:33:36 2013 (r258165)
@@ -390,8 +390,27 @@ vt_processkey(keyboard_t *kbd, struct vt
struct vt_window *vw = vd->vd_curwindow;
int state = 0;
+#if VT_ALT_TO_ESC_HACK
+ if (c & RELKEY) {
+ switch (c & ~RELKEY) {
+ case (SPCLKEY | RALT):
+ case (SPCLKEY | LALT):
+ vd->vd_kbstate &= ~ALKED;
+ }
+ /* Other keys ignored for RELKEY event. */
+ return (0);
+ } else {
+ switch (c & ~RELKEY) {
+ case (SPCLKEY | RALT):
+ case (SPCLKEY | LALT):
+ vd->vd_kbstate |= ALKED;
+ }
+ }
+#else
if (c & RELKEY)
+ /* Other keys ignored for RELKEY event. */
return (0);
+#endif
if (vt_machine_kbdevent(c))
return (0);
@@ -471,9 +490,18 @@ vt_processkey(keyboard_t *kbd, struct vt
}
} else if (KEYFLAGS(c) == 0) {
/* Don't do UTF-8 conversion when doing raw mode. */
- if (vw->vw_kbdmode == K_XLATE)
+ if (vw->vw_kbdmode == K_XLATE) {
+#if VT_ALT_TO_ESC_HACK
+ if (vd->vd_kbstate & ALKED) {
+ /*
+ * Prepend ESC sequence if one of ALT keys down.
+ */
+ terminal_input_char(vw->vw_terminal, 0x1b);
+ }
+#endif
+
terminal_input_char(vw->vw_terminal, KEYCHAR(c));
- else
+ } else
terminal_input_raw(vw->vw_terminal, c);
}
return (0);
More information about the svn-src-user
mailing list