; LNED1.M68  (18) 7-Sept-84  Patch to LINEED.LIT  1.5A(108)  571-431-140-110
; By Irv Bromberg, Medic/OS Consultants, 78 Wildginger Way, Toronto, Ontario,
; CANADA  M3H 5X1
; Patch #1:
; To correct cursor right bug which caused the following LINEED commands to
; malfunction:  ^L or -->, ^Gn, ^W, ^X, ^N.
; Original LINEED did not work properly on ADDS Viewpoint, Cybernex MDL-100
; or Hewlett-Packard or any other terminal that does not use CTRL-L for
; cursor right.  LINEED sends CTRL-L to move the cursor right, this patch
; fixes this by sending the contents of the input buffer from the
; current cursor position to the new cursor position thereby avoiding the
; need to know how to move the cursor right on any CRT type.

; Patch #2:
; This patch changes handling of RETURN or CTRL-M so that insert
; character mode is always turned off after the line is entered.

COPY PATCH

OVER    1,5,1,108.,0
NVER    1,5,1,108.,2    ; this file does 2 new different patches

OHASH   571,431,140,110
NHASH   017,434,127,622

T.ICC   =22

Worksp  =A0
TCB     =A5

NewPos  =D0     ; new cursor position in line
Char    =D1
Count   =D3

BS      =10

=1142
       WORD    RETURN-.                ; change branch for processing ^M

=2436
       JMP     L3034
       NOP                             ; clean-up so garbage not left here
       NOP
       NOP
L2450:                                  ; queue up backspaces to move left

=2460
L2460:  TRMBFQ
L2462:

=2472
L2472:

=3034
L3034:  ; original PRGEND

       MOV     NewPos,Count            ; has position changed?
       SUB     T.ICC(TCB),Count
       JEQ     L2472                   ; no
       JMI     L2450                   ; yes, move left
       LEA     A6,0(Worksp)[~NewPos]   ; new cursor right routine
       MOV     A6,D1                   ; D1 now has new cursor position
       SUB     Count,D1                ; subtract count to calculate
       JMP     L2460                   ; original cursor position
       ; jump to queue up input line from original pos'n to new pos'n

RETURN: ; modified ^M processing routine
       BCLR    #4,@A1                  ; clear insert character mode
Loop:   TSTB    0(Worksp)[~D0]          ; find end of entry line
       JEQ     L2462
       ADD     #1,D0
       BR      Loop

       END