git: 5fec99caff3a - main - vt: Fix handling of backtab

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sun, 08 Feb 2026 16:44:45 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=5fec99caff3ac4f476bb88078ebf85fbecf6afb3

commit 5fec99caff3ac4f476bb88078ebf85fbecf6afb3
Author:     Nathaniel Braun <nathaniel.braun@gmail.com>
AuthorDate: 2026-01-17 17:14:42 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-02-08 16:44:42 +0000

    vt: Fix handling of backtab
    
    PR: 292463
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/2002
---
 sys/dev/vt/vt_core.c | 6 ++++++
 sys/teken/teken.c    | 4 ++++
 sys/teken/teken.h    | 2 ++
 3 files changed, 12 insertions(+)

diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index fd18e85092db..b9159a73ad79 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -952,6 +952,9 @@ vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c)
 			VT_UNLOCK(vd);
 			break;
 		}
+		case BKEY | BTAB: /* Back tab (usually, shift+tab). */
+			terminal_input_special(vw->vw_terminal, TKEY_BTAB);
+			break;
 		case FKEY | F(1):  case FKEY | F(2):  case FKEY | F(3):
 		case FKEY | F(4):  case FKEY | F(5):  case FKEY | F(6):
 		case FKEY | F(7):  case FKEY | F(8):  case FKEY | F(9):
@@ -1964,6 +1967,9 @@ vtterm_cngetc(struct terminal *tm)
 				VTBUF_SLCK_DISABLE(&vw->vw_buf);
 			}
 			break;
+		case SPCLKEY | BTAB: /* Back tab (usually, shift+tab). */
+			vw->vw_kbdsq = "\x1b[Z";
+			break;
 		/* XXX: KDB can handle history. */
 		case SPCLKEY | FKEY | F(50): /* Arrow up. */
 			vw->vw_kbdsq = "\x1b[A";
diff --git a/sys/teken/teken.c b/sys/teken/teken.c
index b0161a2e3b20..a1522e00ecf7 100644
--- a/sys/teken/teken.c
+++ b/sys/teken/teken.c
@@ -703,6 +703,8 @@ static const char * const special_strings_cons25[] = {
 	[TKEY_F7] = "\x1B[S",		[TKEY_F8] = "\x1B[T",
 	[TKEY_F9] = "\x1B[U",		[TKEY_F10] = "\x1B[V",
 	[TKEY_F11] = "\x1B[W",		[TKEY_F12] = "\x1B[X",
+
+	[TKEY_BTAB] = "\x1B[Z",
 };
 
 static const char * const special_strings_ckeys[] = {
@@ -726,6 +728,8 @@ static const char * const special_strings_normal[] = {
 	[TKEY_F7] = "\x1B[18~",		[TKEY_F8] = "\x1B[19~",
 	[TKEY_F9] = "\x1B[20~",		[TKEY_F10] = "\x1B[21~",
 	[TKEY_F11] = "\x1B[23~",	[TKEY_F12] = "\x1B[24~",
+
+	[TKEY_BTAB] = "\x1B[Z",
 };
 
 const char *
diff --git a/sys/teken/teken.h b/sys/teken/teken.h
index 38a85e80110e..c8c73db55f06 100644
--- a/sys/teken/teken.h
+++ b/sys/teken/teken.h
@@ -206,6 +206,8 @@ void	teken_set_winsize_noreset(teken_t *, const teken_pos_t *);
 #define	TKEY_F10	0x13
 #define	TKEY_F11	0x14
 #define	TKEY_F12	0x15
+
+#define	TKEY_BTAB	0x16
 const char *teken_get_sequence(const teken_t *, unsigned int);
 
 /* Legacy features. */