; TITLE "SINLINE - Syslib 4.0" NAME ('INLINE') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SINLINE.Z80 Ver 1.1 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.2 ; Module : SINLINE ; Abstract: This module contains the single routine INLINE which ; is a single line editor from the CON: device. It permits ; the user to pass a parameter in the A register to deter- ; mine whether entered characters should be echoed back to ; the user's console output device, or not echo, such as ; when entering a password. Line entry is terminated with ; entry of a carriage return, and an ending Null is added ; to the line. The Input Line editing characters used in ; this routine are: ; -- Delete previous char and back up cursor ; -- Delete precious char and echo it (hardcopy) ; -- Input Complete ; -- Skip down to next line and insert ; CTRL-X -- Erase current line and back up cursor ; CTRL-U -- Erase current line (hardcopy) ; CTRL-R -- Retype current line ; CTRL-E -- Go to next line ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points: PUBLIC INLINE ; From SYSLIB Get.. EXT CIN, COUT, CCOUT, CRLF ; Data Definitions: NULL EQU 0 ; Null BEL EQU 7 ; Bell BS EQU 8 ; Backspace TAB EQU 9 ; Tab LF EQU 10 ; Line Feed CR EQU 13 ; Carriage Return CTRLE EQU 'E'-40H ; Ctrl-E CTRLR EQU 'R'-40H ; Ctrl-R CTRLU EQU 'U'-40H ; Ctrl-U CTRLX EQU 'X'-40H ; Ctrl-X DEL EQU 7FH ; Delete Char .Z80 CSEG ;========================================================================= ; NAME - INLINE ; Entry: HL - Addresses a memory buffer to hold the character string ; A - Echo flag. A = 0 for NO Echo, A <> 0 for Echo ; Exit : - No parameters returned. The buffer has 0 or more characters ; with a terminating Null (0H). ; Uses : - None ; Special Requirements: The user is responsible for insuring that the ; buffer is large enough in size, or that the user does not enter ; so many characters that the size of the buffer is exceeded. ;========================================================================= INLINE: PUSH HL ; Save Registers PUSH DE PUSH BC PUSH AF LD E,0 ; Set for No echo OR A ; Test for echo request JR Z,INLIN0 ; ..jump if No echo request INC E ; Else set to Echo INLIN0: LD (START),HL ; Save start of string ; Inline Restert Loop INL0: LD HL,(START) ; Get start of string LD C,0 ; Set char count ; Main Loop INL1: CALL CIN ; Get input char OR A ; Do not permit JR Z,INL1 CP BS ; Backspace? JP Z,INBS CP DEL ; Delete? JR Z,INDEL CP TAB ; Tabulate? JR Z,INTAB CP CR ; Carriage Return? JP Z,INCR CP LF ; Line Feed? JR Z,INLF CP CTRLU ; Ctrl-U? JR Z,RESTRT CP CTRLX ; Ctrl-X? JR Z,REXSTRT CP CTRLR ; Ctrl-R? JR Z,RETYPE CP CTRLE ; Ctrl-E? JR Z,NEWLINE LD (HL),A ; Store char INC HL ; Pt to next CALL CTRL ; Print char INC C ; Incr char cnt JR INL1 ; Newline -- Echo and continue NEWLINE:CALL CRLF JR INL1 ; Tab -- Tabulate to next tab stop INTAB: LD (HL),A ; Store INC HL ; Pt to next char position CALL INTAB0 ; Tabulate JR INL1 ; Ctrl-R -- Retype current line RETYPE: LD (HL),0 ; Store end of string char LD C,0 ; Reset char cnt LD HL,(START) ; Get start address CALL HASH ; Print hash char RETY1: LD A,(HL) ; Get char OR A ; Zero? JR Z,INL1 ; Continue CALL CTRL ; Print it LD A,(HL) ; Get char again CP TAB ; Don't count if JR Z,RETY2 CP BEL ; Don't count if JR Z,RETY2 INC C ; Incr char cnt RETY2: INC HL ; Pt to next char JR RETY1 ; Ctrl-U -- Erase Line and restart RESTRT: CALL HASH ; Print hash char JR INL0 ; Start up again ; Ctrl-X -- Erase (and backspace) line and restart REXSTRT:LD A,C ; Check for empty line OR A ; 0 Chars? JR Z,INL0 CALL EXBS ; JR REXSTRT ; Line Feed -- Insert and echo INLF: LD (HL),CR ; Store INC HL ; Pt to next LD (HL),LF ; Store INC HL ; Pt to next LD C,0 ; Reset char cnt BIT 0,E ; Check Echo flag CALL NZ,CRLF ; Print New Line if Echoing INL1V: JR INL1 ; Delete -- Delete previous char and echo deleted char INDEL: CALL BOL ; Beginning of line? JR Z,INL1 ; Continue DEC HL ; Back up LD A,(HL) ; Get char CALL CTRL ; Print char CP BEL ; Don't change count if JR Z,INL1V INC C ; Incr display char count JR INL1V ; Backspace -- Delete previous char and back up cursor INBS: CALL EXBS ; Execute JR INL1V ; Backspace routine EXBS: CALL BOL ; Beginning of line? RET Z ; Continue if so DEC C ; Decr count DEC HL ; Back up BIT 0,E ; Are we echoing? RET Z ; ..Return if not LD A,BS ; Print CALL COUT LD A,' ' ; CALL COUT LD A,BS ; COUTV: JP COUT ; Carriage Return -- Done; Store ending zero INCR: LD (HL),0 ; Store ending zero BIT 0,E ; Are we echoing? CALL NZ,CRLF ; ..Print New Line if so POP AF ; Restore all registers POP BC POP DE POP HL RET ; BOL -- Returns w/zero flag set if user at beginning of line BOL: PUSH DE ; Save this register LD DE,(START) ; Get start adr LD A,D ; Check for match CP H ; Is it a match? RET NZ ; ..return if not LD A,E ; Check for complete match CP L POP DE ; Restore DE RET NZ ; ..Return if not complete match PUSH AF ; Save Flags LD A,BEL ; Beep CALL COUT POP AF RET ; Ctrl -- If Char >= , Print it; otherwise, print as Ctrl-char CTRL: BIT 0,E ; Are we Echoing? RET Z ; No output if no echo CP ' ' ; ? JR NC,COUTV ; Print it normally CTRL1: CP TAB ; Trap JP NZ,CCOUT ; Print with Ctrl-char processing ; ..fall thru ; Intab0 -- Tabulate on screen INTAB0: LD A,C ; Get char cnt AND 7 ; Mask for difference from 8 LD B,A ; Store in Reg B temporarily LD A,8 ; Subtract from 8 SUB B LD B,A ; count in B ADD A,C ; Add to char count LD C,A BIT 0,E ; Are we Echoing? RET Z ; ..return if Not LD A,' ' ; in A INTAB1: CALL COUT ; Print DJNZ INTAB1 ; Count down RET ; Hash -- Print hash mark followed by HASH: LD A,'#' ; Print Hash char CALL COUT JP CRLF ; Data Storage/Buffers DSEG ; Put in Data Segment START: DEFS 2 ; Temp storage for buffer start addr END