This set of patches supersedes what I posted in
<mid:[EMAIL PROTECTED]>.

ad2322a88c terminal doc: More comments about itrm->in.queue and bug 777.
88c2cf6af9 terminal: Kill the ESC timer when blocking the terminal.
cd82a82ff1 terminal: Move kbd_timeout below set_kbd_event.
0f4df85218 terminal: In the ESC timeout, don't assume merely ESC was pressed.
9e16b024b3 terminal: Rewrite process_queue.
7f0300792f terminal: Decode ESC O entirely separately from ESC [.
fef230a0e1 terminal doc: Add a comment about $TERM on FreeBSD.

!-------------------------------------------------------------flip-
terminal doc: More comments about itrm->in.queue and bug 777.

---
commit ad2322a88c2804777ff75582cc19da4f3967e53b
tree b10389c7e622e76bb7c1bae44d3678c1e97e1473
parent 91ecfc0fdf6016c3f965b077b645b9c1f335d57f
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:40:00 +0300
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:40:00 +0300

 src/terminal/itrm.h |    6 +++++-
 src/terminal/kbd.c  |   16 ++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/terminal/itrm.h b/src/terminal/itrm.h
index b1af33d..a43e734 100644
--- a/src/terminal/itrm.h
+++ b/src/terminal/itrm.h
@@ -44,7 +44,11 @@ struct itrm_in {
 	/* Bytes that have been received from @std but not yet
 	 * converted to events.  queue.data is allocated for
 	 * ITRM_IN_QUEUE_SIZE bytes and never resized.  The itrm
-	 * layer cannot parse control sequences longer than that.  */
+	 * layer cannot parse control sequences longer than that.
+	 * Anything that modifies queue.len should also call
+	 * unhandle_itrm_stdin() if the queue becomes full, or
+	 * handle_itrm_stdin() if the queue stops being full.
+	 * Those functions are internal to kbd.c.  */
 	struct itrm_queue queue;
 };
 
diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c
index e39896c..f918f6e 100644
--- a/src/terminal/kbd.c
+++ b/src/terminal/kbd.c
@@ -835,6 +835,11 @@ #endif
 
 /* I feeeeeel the neeeed ... to rewrite this ... --pasky */
 /* Just Do it ! --Zas */
+/* Parse one event from itrm->in.queue and append to itrm->out.queue.
+ * Return the number of bytes removed from itrm->in.queue; at least 0.
+ * If this function leaves the queue not full, it also reenables reading
+ * from itrm->in.std.  (Because it does not add to the queue, it never
+ * need disable reading.)  */
 static int
 process_queue(struct itrm *itrm)
 {
@@ -863,6 +868,10 @@ #ifdef DEBUG_ITRM_QUEUE
 	}
 #endif /* DEBUG_ITRM_QUEUE */
 
+	/* ELinks should also recognize U+009B CONTROL SEQUENCE INTRODUCER
+	 * as meaning the same as ESC 0x5B, and U+008F SINGLE SHIFT THREE as
+	 * meaning the same as ESC 0x4F, but those cannot yet be implemented
+	 * because of bug 777: the UTF-8 decoder is run too late.  */
 	if (itrm->in.queue.data[0] == ASCII_ESC) {
 		if (itrm->in.queue.len < 2) goto ret;
 		if (itrm->in.queue.data[1] == '[' || itrm->in.queue.data[1] == 'O') {
@@ -961,6 +970,10 @@ in_kbd(struct itrm *itrm)
 	while (process_queue(itrm));
 }
 
+/* Enable reading from itrm->in.std.  ELinks will read any available
+ * bytes from the tty into itrm->in.queue and then parse them.
+ * Reading should be enabled whenever itrm->in.queue is not full and
+ * itrm->blocked is 0.  */
 static void
 handle_itrm_stdin(struct itrm *itrm)
 {
@@ -968,6 +981,9 @@ handle_itrm_stdin(struct itrm *itrm)
 		     (select_handler_T) free_itrm, itrm);
 }
 
+/* Disable reading from itrm->in.std.  Reading should be disabled
+ * whenever itrm->in.queue is full (there is no room for the data)
+ * or itrm->blocked is 1 (other processes may read the data).  */
 static void
 unhandle_itrm_stdin(struct itrm *itrm)
 {
!-------------------------------------------------------------flip-
terminal: Kill the ESC timer when blocking the terminal.

Otherwise, the timeout could cause ELinks to resume reading from
the terminal device while another process is still using it.
This actually happened in a test.

On entry to some functions that could resume reading from the device,
assert that the terminal has not been blocked.

---
commit 88c2cf6af9c92a58f03947680973d5a7bf67b0ec
tree 8fcb1243b51145669c10bf6a72703dfc64a89a77
parent ad2322a88c2804777ff75582cc19da4f3967e53b
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:48:57 +0300
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:48:57 +0300

 src/terminal/kbd.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c
index f918f6e..a88761d 100644
--- a/src/terminal/kbd.c
+++ b/src/terminal/kbd.c
@@ -373,6 +373,8 @@ block_itrm(int fd)
 
 	ditrm->blocked = 1;
 	block_stdin();
+	kill_timer(&ditrm->timer);
+	ditrm->in.queue.len = 0;
 	unhandle_terminal_resize(ditrm->in.ctl);
 	send_done_sequence(ditrm->out.std, ditrm->altscreen);
 	tcsetattr(ditrm->in.ctl, TCSANOW, &ditrm->t);
@@ -626,14 +628,15 @@ kbd_timeout(struct itrm *itrm)
 
 	itrm->timer = TIMER_ID_UNDEF;
 
+	assertm(itrm->in.queue.len, "timeout on empty queue");
+	assert(!itrm->blocked);	/* block_itrm should have killed itrm->timer */
+	if_assert_failed return;
+
 	if (can_read(itrm->in.std)) {
 		in_kbd(itrm);
 		return;
 	}
 
-	assertm(itrm->in.queue.len, "timeout on empty queue");
-	if_assert_failed return;
-
 	set_kbd_term_event(&ev, KBD_ESC, KBD_MOD_NONE);
 	itrm_queue_event(itrm, (char *) &ev, sizeof(ev));
 
@@ -839,7 +842,7 @@ #endif
  * Return the number of bytes removed from itrm->in.queue; at least 0.
  * If this function leaves the queue not full, it also reenables reading
  * from itrm->in.std.  (Because it does not add to the queue, it never
- * need disable reading.)  */
+ * need disable reading.)  On entry, the itrm must not be blocked.  */
 static int
 process_queue(struct itrm *itrm)
 {
@@ -847,6 +850,8 @@ process_queue(struct itrm *itrm)
 	int el = 0;
 
 	if (!itrm->in.queue.len) goto end;
+	assert(!itrm->blocked);
+	if_assert_failed return 0; /* unlike goto, don't enable reading */
 
 	set_kbd_term_event(&ev, KBD_UNDEF, KBD_MOD_NONE);
 
!-------------------------------------------------------------flip-
terminal: Move kbd_timeout below set_kbd_event.

This ought to make the diff of the next commit more readable.

---
commit cd82a82ff1882706a388a9b741ea03f2004e0de2
tree 16633f7f44f6995ca45a3910010fdc86f01392d1
parent 88c2cf6af9c92a58f03947680973d5a7bf67b0ec
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:49:51 +0300
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:49:51 +0300

 src/terminal/kbd.c |   51 +++++++++++++++++++++++++--------------------------
 1 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c
index a88761d..1f9f370 100644
--- a/src/terminal/kbd.c
+++ b/src/terminal/kbd.c
@@ -621,32 +621,6 @@ free_and_return:
 }
 
 
-static void
-kbd_timeout(struct itrm *itrm)
-{
-	struct term_event ev;
-
-	itrm->timer = TIMER_ID_UNDEF;
-
-	assertm(itrm->in.queue.len, "timeout on empty queue");
-	assert(!itrm->blocked);	/* block_itrm should have killed itrm->timer */
-	if_assert_failed return;
-
-	if (can_read(itrm->in.std)) {
-		in_kbd(itrm);
-		return;
-	}
-
-	set_kbd_term_event(&ev, KBD_ESC, KBD_MOD_NONE);
-	itrm_queue_event(itrm, (char *) &ev, sizeof(ev));
-
-	if (--itrm->in.queue.len)
-		memmove(itrm->in.queue.data, itrm->in.queue.data + 1, itrm->in.queue.len);
-
-	while (process_queue(itrm));
-}
-
-
 /* Returns the length of the escape sequence */
 static inline int
 get_esc_code(unsigned char *str, int len, unsigned char *code, int *num)
@@ -836,6 +810,31 @@ #endif
 	set_kbd_term_event(ev, key, modifier);
 }
 
+static void
+kbd_timeout(struct itrm *itrm)
+{
+	struct term_event ev;
+
+	itrm->timer = TIMER_ID_UNDEF;
+
+	assertm(itrm->in.queue.len, "timeout on empty queue");
+	assert(!itrm->blocked);	/* block_itrm should have killed itrm->timer */
+	if_assert_failed return;
+
+	if (can_read(itrm->in.std)) {
+		in_kbd(itrm);
+		return;
+	}
+
+	set_kbd_term_event(&ev, KBD_ESC, KBD_MOD_NONE);
+	itrm_queue_event(itrm, (char *) &ev, sizeof(ev));
+
+	if (--itrm->in.queue.len)
+		memmove(itrm->in.queue.data, itrm->in.queue.data + 1, itrm->in.queue.len);
+
+	while (process_queue(itrm));
+}
+
 /* I feeeeeel the neeeed ... to rewrite this ... --pasky */
 /* Just Do it ! --Zas */
 /* Parse one event from itrm->in.queue and append to itrm->out.queue.
!-------------------------------------------------------------flip-
terminal: In the ESC timeout, don't assume merely ESC was pressed.

If there is e.g. ESC [ in the input buffer, combine that to Alt-[.
Check the first character too; don't blindly assume it is ESC, as
it can be NUL as well.  Note this means you can no longer activate
the main menu by pressing Ctrl-@ (or Ctrl-Space on some terminals).

---
commit 0f4df852182b4a16d3997d527ad699b5e6a2b1ab
tree 4d1410cbf97881cc1d57f4ee64b6101374dcad3d
parent cd82a82ff1882706a388a9b741ea03f2004e0de2
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:55:28 +0300
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:55:28 +0300

 src/terminal/kbd.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c
index 1f9f370..37204e5 100644
--- a/src/terminal/kbd.c
+++ b/src/terminal/kbd.c
@@ -800,6 +800,10 @@ #endif
 		key = KBD_ENTER;
 		break;
 
+	case ASCII_ESC:
+		key = KBD_ESC;
+		break;
+
 	default:
 		if (key < ' ') {
 			key += 'A' - 1;
@@ -814,6 +818,7 @@ static void
 kbd_timeout(struct itrm *itrm)
 {
 	struct term_event ev;
+	int el;
 
 	itrm->timer = TIMER_ID_UNDEF;
 
@@ -826,11 +831,19 @@ kbd_timeout(struct itrm *itrm)
 		return;
 	}
 
-	set_kbd_term_event(&ev, KBD_ESC, KBD_MOD_NONE);
+	if (itrm->in.queue.len >= 2 && itrm->in.queue.data[0] == ASCII_ESC) {
+		/* This is used for ESC [ and ESC O.  */
+		set_kbd_event(&ev, itrm->in.queue.data[1], KBD_MOD_ALT);
+		el = 2;
+	} else {
+		set_kbd_event(&ev, itrm->in.queue.data[0], KBD_MOD_NONE);
+		el = 1;
+	}
 	itrm_queue_event(itrm, (char *) &ev, sizeof(ev));
 
-	if (--itrm->in.queue.len)
-		memmove(itrm->in.queue.data, itrm->in.queue.data + 1, itrm->in.queue.len);
+	itrm->in.queue.len -= el;
+	if (itrm->in.queue.len)
+		memmove(itrm->in.queue.data, itrm->in.queue.data + el, itrm->in.queue.len);
 
 	while (process_queue(itrm));
 }
!-------------------------------------------------------------flip-
terminal: Rewrite process_queue.

---
commit 9e16b024b31e4e5bc75a8b366fe72d64c0ca53b1
tree 105713763dbdccb81abc3211a60a79876b7bf7b3
parent 0f4df852182b4a16d3997d527ad699b5e6a2b1ab
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:57:50 +0300
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:57:50 +0300

 src/terminal/kbd.c |  108 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 66 insertions(+), 42 deletions(-)

diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c
index 37204e5..9cb6ddb 100644
--- a/src/terminal/kbd.c
+++ b/src/terminal/kbd.c
@@ -848,8 +848,6 @@ kbd_timeout(struct itrm *itrm)
 	while (process_queue(itrm));
 }
 
-/* I feeeeeel the neeeed ... to rewrite this ... --pasky */
-/* Just Do it ! --Zas */
 /* Parse one event from itrm->in.queue and append to itrm->out.queue.
  * Return the number of bytes removed from itrm->in.queue; at least 0.
  * If this function leaves the queue not full, it also reenables reading
@@ -861,7 +859,7 @@ process_queue(struct itrm *itrm)
 	struct term_event ev;
 	int el = 0;
 
-	if (!itrm->in.queue.len) goto end;
+	if (!itrm->in.queue.len) goto return_without_event;
 	assert(!itrm->blocked);
 	if_assert_failed return 0; /* unlike goto, don't enable reading */
 
@@ -885,32 +883,55 @@ #ifdef DEBUG_ITRM_QUEUE
 	}
 #endif /* DEBUG_ITRM_QUEUE */
 
+	/* el == -1 means itrm->in.queue appears to be the beginning of an
+	 *          escape sequence but it is not yet complete.  Set a timer;
+	 *          if it times out, then assume it wasn't an escape sequence
+	 *          after all.
+	 * el == 0 means this function has not yet figured out what the data
+	 *         in itrm->in.queue is, but some possibilities remain.
+	 *         One of them will be chosen before returning.
+	 * el > 0 means some bytes were successfully parsed from the beginning
+	 *        of itrm->in.queue and should now be removed from there.
+	 *        However, this does not always imply an event will be queued.
+	 */
+
 	/* ELinks should also recognize U+009B CONTROL SEQUENCE INTRODUCER
 	 * as meaning the same as ESC 0x5B, and U+008F SINGLE SHIFT THREE as
 	 * meaning the same as ESC 0x4F, but those cannot yet be implemented
 	 * because of bug 777: the UTF-8 decoder is run too late.  */
 	if (itrm->in.queue.data[0] == ASCII_ESC) {
-		if (itrm->in.queue.len < 2) goto ret;
-		if (itrm->in.queue.data[1] == '[' || itrm->in.queue.data[1] == 'O') {
+		if (itrm->in.queue.len < 2) {
+			el = -1;
+		} else if (itrm->in.queue.data[1] == 0x5B /* CSI */
+			   || itrm->in.queue.data[1] == 0x4F /* SS3 */) {
 			el = decode_terminal_escape_sequence(itrm, &ev);
-
-			if (el == -1) goto ret;
-
-		} else {
-			el = 2;
-
-			if (itrm->in.queue.data[1] == ASCII_ESC) {
-				if (itrm->in.queue.len >= 3 &&
-				    (itrm->in.queue.data[2] == '[' ||
-				     itrm->in.queue.data[2] == 'O')) {
-					el = 1;
-				}
-
-				set_kbd_event(&ev, KBD_ESC, KBD_MOD_NONE);
-
+		} else if (itrm->in.queue.data[1] == ASCII_ESC) {
+			/* ESC ESC can be either Alt-Esc or the
+			 * beginning of e.g. ESC ESC 0x5B 0x41,
+			 * which we should parse as Esc Up.  */
+			if (itrm->in.queue.len < 3) {
+				/* Need more data to figure it out.  */
+				el = -1;
+			} else if (itrm->in.queue.data[2] == 0x5B
+				   || itrm->in.queue.data[2] == 0x4F) {
+				/* The first ESC appears to be followed
+				 * by an escape sequence.  Treat it as
+				 * a standalone Esc.  */
+				el = 1;
+				set_kbd_event(&ev, itrm->in.queue.data[0],
+					      KBD_MOD_NONE);
 			} else {
-				set_kbd_event(&ev, itrm->in.queue.data[1], KBD_MOD_ALT);
+				/* The second ESC of ESC ESC is not the
+				 * beginning of any known escape sequence.
+				 * This must be Alt-Esc, then.  */
+				el = 2;
+				set_kbd_event(&ev, itrm->in.queue.data[1],
+					      KBD_MOD_ALT);
 			}
+		} else {	/* ESC followed by something else */
+			el = 2;
+			set_kbd_event(&ev, itrm->in.queue.data[1],
+				      KBD_MOD_ALT);
 		}
 
 	} else if (itrm->in.queue.data[0] == 0) {
@@ -918,39 +939,42 @@ #endif /* DEBUG_ITRM_QUEUE */
 #include "terminal/key.inc"
 		};
 
-		if (itrm->in.queue.len < 2) goto ret;
-		copy_struct(&ev.info.keyboard, &os2xtd[itrm->in.queue.data[1]]);
-		el = 2;
+		if (itrm->in.queue.len < 2)
+			el = -1;
+		else {
+			el = 2;
+			copy_struct(&ev.info.keyboard, &os2xtd[itrm->in.queue.data[1]]);
+		}
+	}
 
-	} else {
+	if (el == 0) {
 		el = 1;
-		set_kbd_event(&ev, itrm->in.queue.data[0], 0);
+		set_kbd_event(&ev, itrm->in.queue.data[0], KBD_MOD_NONE);
 	}
 
-	assertm(itrm->in.queue.len >= el, "event queue underflow");
-	if_assert_failed { itrm->in.queue.len = el; }
-
-	itrm->in.queue.len -= el;
-
 	/* The call to decode_terminal_escape_sequence() might have changed the
 	 * keyboard event to a mouse event. */
 	if (ev.ev == EVENT_MOUSE || ev.info.keyboard.key != KBD_UNDEF)
 		itrm_queue_event(itrm, (char *) &ev, sizeof(ev));
 
-	if (itrm->in.queue.len)
-		memmove(itrm->in.queue.data, itrm->in.queue.data + el, itrm->in.queue.len);
-
-end:
-	if (itrm->in.queue.len < ITRM_IN_QUEUE_SIZE)
-		handle_itrm_stdin(itrm);
+ return_without_event:
+	if (el == -1) {
+		install_timer(&itrm->timer, ESC_TIMEOUT, (void (*)(void *)) kbd_timeout,
+			      itrm);
+		return 0;
+	} else {
+		assertm(itrm->in.queue.len >= el, "event queue underflow");
+		if_assert_failed { itrm->in.queue.len = el; }
 
-	return el;
+		itrm->in.queue.len -= el;
+		if (itrm->in.queue.len)
+			memmove(itrm->in.queue.data, itrm->in.queue.data + el, itrm->in.queue.len);
 
-ret:
-	install_timer(&itrm->timer, ESC_TIMEOUT, (void (*)(void *)) kbd_timeout,
-			itrm);
+		if (itrm->in.queue.len < ITRM_IN_QUEUE_SIZE)
+			handle_itrm_stdin(itrm);
 
-	return 0;
+		return el;
+	}
 }
 
 
!-------------------------------------------------------------flip-
terminal: Decode ESC O entirely separately from ESC [.

decode_terminal_escape_sequence() used to handle both, but
there is now a separate decode_terminal_application_key()
for ESC O.  I have not yet edited decode_terminal_escape_sequence();
there may be dead code in it.

---
commit 7f0300792f682f5cce4616762d787b2f281522df
tree ab0fb3f3d715974ddfec22a6219448807bb5cf7a
parent 9e16b024b31e4e5bc75a8b366fe72d64c0ca53b1
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:59:36 +0300
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 15:59:36 +0300

 src/terminal/kbd.c |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c
index 9cb6ddb..fba290c 100644
--- a/src/terminal/kbd.c
+++ b/src/terminal/kbd.c
@@ -775,6 +775,63 @@ #endif /* CONFIG_MOUSE */
 	return el;
 }
 
+/* Decode an escape sequence that begins with SS3 (SINGLE SHIFT 3).
+ * These are used for application cursor keys and the application keypad.
+ * Return one of:
+ *   -1 if the escape sequence is not yet complete; the caller sets a timer.
+ *   0 if the escape sequence should be parsed by some other function.
+ *   The length of the escape sequence otherwise.
+ * Returning >0 does not imply this function has altered *ev.  */
+static int
+decode_terminal_application_key(struct itrm *itrm, struct term_event *ev)
+{
+	unsigned char c;
+	struct term_event_keyboard kbd = { KBD_UNDEF, KBD_MOD_NONE };
+
+	assert(itrm->in.queue.len >= 2);
+	assert(itrm->in.queue.data[0] == ASCII_ESC);
+	assert(itrm->in.queue.data[1] == 0x4F); /* == 'O', incidentally */
+	if_assert_failed return 0;
+
+	if (itrm->in.queue.len < 3) return -1;
+	/* According to ECMA-35 section 8.4, a single (possibly multibyte)
+	 * character follows the SS3.  We now assume the code identifies
+	 * GL as the single-shift area and the designated set has 94
+	 * characters.  */
+	c = itrm->in.queue.data[2];
+	if (c < 0x21 || c > 0x7E) return 0;
+
+	/* These are all from xterm-215/ctlseqs.txt.  */
+	switch (c) {
+	case ' ': kbd.key = ' '; break;
+	case 'A': kbd.key = KBD_UP; break;
+	case 'B': kbd.key = KBD_DOWN; break;
+	case 'C': kbd.key = KBD_RIGHT; break;
+	case 'D': kbd.key = KBD_LEFT; break;
+	case 'F': kbd.key = KBD_END; break;
+	case 'H': kbd.key = KBD_HOME; break;
+	case 'I': kbd.key = KBD_TAB; break;
+	case 'M': kbd.key = KBD_ENTER; break;
+		/* FIXME: xterm generates ESC O 2 P for Shift-PF1 */
+	case 'P': kbd.key = KBD_F1; break;
+	case 'Q': kbd.key = KBD_F2; break;
+	case 'R': kbd.key = KBD_F3; break;
+	case 'S': kbd.key = KBD_F4; break;
+	case 'X': kbd.key = '='; break;
+
+	case 'j': case 'k': case 'l': case 'm': /* *+,- */
+	case 'n': case 'o': case 'p': case 'q': /* ./01 */
+	case 'r': case 's': case 't': case 'u': /* 2345 */
+	case 'v': case 'w': case 'x': case 'y': /* 6789 */
+		kbd.key = c - 'p' + '0'; break;
+	}
+	if (kbd.key != KBD_UNDEF)
+		copy_struct(&ev->info.keyboard, &kbd);
+
+	return 3;		/* even if we didn't recognize it */
+}
+
+
 static void
 set_kbd_event(struct term_event *ev, int key, int modifier)
 {
@@ -902,9 +959,10 @@ #endif /* DEBUG_ITRM_QUEUE */
 	if (itrm->in.queue.data[0] == ASCII_ESC) {
 		if (itrm->in.queue.len < 2) {
 			el = -1;
-		} else if (itrm->in.queue.data[1] == 0x5B /* CSI */
-			   || itrm->in.queue.data[1] == 0x4F /* SS3 */) {
-			el = decode_terminal_escape_sequence(itrm, &ev);
+		} else if (itrm->in.queue.data[1] == 0x5B /* CSI */) {
+ 			el = decode_terminal_escape_sequence(itrm, &ev);
+		} else if (itrm->in.queue.data[1] == 0x4F /* SS3 */) {
+			el = decode_terminal_application_key(itrm, &ev);
 		} else if (itrm->in.queue.data[1] == ASCII_ESC) {
 			/* ESC ESC can be either Alt-Esc or the
 			 * beginning of e.g. ESC ESC 0x5B 0x41,
!-------------------------------------------------------------flip-
terminal doc: Add a comment about $TERM on FreeBSD.

---
commit fef230a0e1b60b48e6b767da966f091843206b8f
tree 4e079721b8307463323a9c146bb4d6f33e4aece2
parent 7f0300792f682f5cce4616762d787b2f281522df
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 16:00:11 +0300
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Fri, 28 Jul 2006 16:00:11 +0300

 src/terminal/kbd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c
index fba290c..ca94ad4 100644
--- a/src/terminal/kbd.c
+++ b/src/terminal/kbd.c
@@ -692,7 +692,7 @@ #endif
 	case 'H': kbd.key = KBD_HOME; break;
 	case 'I': kbd.key = KBD_PAGE_UP; break;
 	case 'G': kbd.key = KBD_PAGE_DOWN; break;
-/* Free BSD */
+/* Free BSD (TERM=cons25 etc.) */
 /*	case 'M': kbd.key = KBD_F1; break;*/
 	case 'N': kbd.key = KBD_F2; break;
 	case 'O': kbd.key = KBD_F3; break;

Attachment: pgpaHZUe5N2Jz.pgp
Description: PGP signature

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to