!+
!
! Key scripts for cursor keys using KED or EDT under E11.
!
! Cursor keys are made to appear directionless by using the EDITBACKUP flag to
! keep track of the current ADVANCE/BACKUP direction.
!
! By John Wilson.
!
! 06/18/1997	JMBW	Created.
! 12/19/2006	JMBW	Changed to use EDITBACKUP instead of FLAG1.
!
!-
DEFINE KEYPRESS INS =           ! insert blank line &
 PRESS NUMLOCK : &
 PRESS KP0
DEFINE KEYPRESS DEL = &
 IF EDITBACKUP THEN             ! KED is going backwards &
  PRESS KP4 :                   ! switch forwards temporarily &
  IF VT52 THEN                  ! send code for keypad "," key &
   CHR$(27)+"?l" &
  ELSE &
   CHR$(27)+"Ol" &
  ENDIF : &
  PRESS KP5                     ! switch backwards again &
 ELSE &
  IF VT52 THEN                  ! send code for keypad "," key &
   CHR$(27)+"?l" &
  ELSE &
   CHR$(27)+"Ol" &
  ENDIF &
 ENDIF
DEFINE KEYPRESS HOME =          ! backspace doesn't do it in KED &
 IF EDITBACKUP THEN             ! KED is going backwards &
  PRESS KP0                     ! easy, "0" key does it &
 ELSE &
  PRESS KP5 :                   ! switch backwards temporarily &
  PRESS KP0 :                   ! go to begn of line &
  PRESS KP4                     ! switch forwards again &
 ENDIF
DEFINE KEYPRESS END = &
 IF EDITBACKUP THEN             ! KED is going backwards &
  PRESS KP4 :                   ! switch forwards temporarily &
  PRESS KP2 :                   ! jump to end of line &
  PRESS KP5                     ! switch backwards again &
 ELSE &
  PRESS KP2                     ! jump to end of line &
 ENDIF
DEFINE KEYPRESS PGUP = &
 IF EDITBACKUP THEN             ! KED is going backwards &
  PRESS KP8                     ! up a section &
 ELSE &
  PRESS KP5 :                   ! switch backards temporarily &
  PRESS KP8 :                   ! up a section &
  PRESS KP4                     ! switch forewards again &
 ENDIF
DEFINE KEYPRESS PGDN = &
 IF EDITBACKUP THEN             ! KED is going backwards &
  PRESS KP4 :                   ! switch forwards temporarily &
  PRESS KP8 :                   ! down a section &
  PRESS KP5                     ! switch backwards again &
 ELSE &
  PRESS KP8                     ! down a section &
 ENDIF
