Skip to content

Commit

Permalink
Fix regression: CSI character instead of ^{[ in terminal special key …
Browse files Browse the repository at this point in the history
…sequence.

Remove terminal special key conditional compilation.
  • Loading branch information
rfivet committed Aug 6, 2021
1 parent 5002897 commit 4b45ca2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 34 deletions.
31 changes: 6 additions & 25 deletions estruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
#ifndef _ESTRUCT_H_
#define _ESTRUCT_H_

/* ESTRUCT.H
*
* Structure and preprocessor defines
/* Structure and preprocessor defines
*
* written by Dave G. Conroy
* modified by Steve Wilhite, George Jones
* substantially modified by Daniel Lawrence
* substantially modified by Daniel Lawrence
* modified by Petri Kutvonen
*/

Expand Down Expand Up @@ -66,29 +64,12 @@
#endif

#ifndef AUTOCONF

/* Special keyboard definitions */

#define VT220 0 /* Use keypad escapes P.K. */
#define VT100 0 /* Handle VT100 style keypad. */

/* Terminal Output definitions */

#define ANSI 0 /* ANSI escape sequences */
#define VT52 0 /* VT52 terminal (Zenith). */
#define TERMCAP 0 /* Use TERMCAP */
#define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */

# define TERMCAP 0 /* Use TERMCAP */
# define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */
#else

#define VT220 UNIX
#define VT100 0

#define ANSI 0
#define VT52 0
#define TERMCAP UNIX
#define IBMPC MSDOS

# define TERMCAP UNIX
# define IBMPC MSDOS
#endif /* Autoconf. */

/* Configuration options */
Expand Down
18 changes: 11 additions & 7 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ static int get1unicode( int *up) {
return bytes ;
}

/* Terminal sequences need up to 6 read ahead characters */
#define STACKSIZE 6
/* Terminal sequences need up to 7 read ahead characters */
#define STACKSIZE 7
static int keystack[ STACKSIZE] ;
static int *stackptr = &keystack[ STACKSIZE] ;
#define KPUSH( c) *(--stackptr) = (c)
Expand Down Expand Up @@ -381,17 +381,21 @@ int getcmd( void) {
int c ;

for( ;;) {
c = get1key() ;
if( c == (CTRL | '[')) {
c = *(kptr++) = get1key() ;
if( c == 0x9B)
goto foundCSI ;
else if( c == (CTRL | '[')) {
/* fetch terminal sequence */
c = *(kptr++) = get1key() ;
if( c == 'O') { /* F1 .. F4 */
c = *(kptr++) = get1key() ;
if( c >= 'P' && c <= 'S')
return c | SPEC | cmask ;
} else if( c == '[') {
int v = 0 ; /* ^[[v1;v~ or ^[[v~ */
int v1 = 0 ;
int v1, v ; /* ^[[v1;v~ or ^[[v~ */

foundCSI:
v1 = v = 0 ;
while( kptr < &keyread[ STACKSIZE]) {
c = *(kptr++) = get1key() ;
if( (c == '~') || (c >= 'A' && c <= 'Z')) {
Expand Down Expand Up @@ -428,7 +432,7 @@ int getcmd( void) {
while( kptr > keyread)
KPUSH( *(--kptr)) ;

c = CTRL | '[' ;
c = get1key() ;
}

if( c == metac) {
Expand Down
3 changes: 1 addition & 2 deletions names.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const name_bind names[] = {
{ NULL, (fnp_t) setmark, META | '.'},
// { NULL, bktoshell, META | 'S'},

#if VT220
/* special key mapping */
{ NULL, yank, SPEC | '2'}, /* Insert */
{ NULL, forwdel /* killregion */, SPEC | '3'}, /* Delete */
{ NULL, (fnp_t) backpage, SPEC | '5'}, /* Page Up */
Expand All @@ -244,7 +244,6 @@ const name_bind names[] = {
{ NULL, (fnp_t) gotoeob, SPEC | 'F'}, /* End */
{ NULL, (fnp_t) gotobob, SPEC | 'H'}, /* Home */
{ NULL, help, SPEC | 'P'}, /* F1 */
#endif

/* hooks */
{ NULL, nullproc, SPEC | META | 'R'}, /* hook */
Expand Down

0 comments on commit 4b45ca2

Please sign in to comment.