.MCall .Module .Module KEDCM3 RELEASE=V02 VERSION=29 COMMENT=,IDENT=NO,AUDIT=NO,GLOBAL=.KEDC3 ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ;+ ;COND ; VT10$0 ; VT62$ ; ; Virt$C via KEDCPR controls generation of SOBs ; ; $KED$ ;- ; ;MODULE: KEDCM3 ; ;ABSTRACT: ; ; This module contains routines to size the screen, implement help, ; accept a string for a model or command and some of the simpler ; command functions. ; ;AUTHOR: DARRELL DUFFY ; ;DATE: 16-July-1979 ; ;REVISION HISTORY: ; ; Darrell Duffy ; ; 16-July-79 Add TABS ADJUST command ; ; Cheryl Vedoe ; ; 22-Oct-79 Add defensive code to SIZSCR routine to check for ; valid screen size. ; ; Jim Williams ; ; 24-April-1981 Fix SET SEARCH EXACT bug ; .Enable LC .Enable GBL .IIf NDF VT62$ VT62$ = 0 .SbTtl Error Macro Definitions ;+ ;ERROR ; .IIf NDF,$KED$, .Page .IIf NDF,$KED$, .SbTtl Errors from KEDCM3 module ; ; Module: KEDCM3 ; ; Define the error macros for this module ; .MCall ErrDef ErrDef C3,ERROR ;- ;+ ;HELPER ; .IIf NDF,$KED$, .Page .IIf NDF,$KED$, .SbTtl Help from KEDCM3 module ; ; Module: KEDCM3 ; ; Define the help macros for this module ; .MCall HlpDef HlpDef C3 ;- .SbTtl .SbTtl SIZSCR - Size the VT100 screen ;++ ;SIZSCR ; ;FUNCIONAL DESCRIPTION: ; ; Size the VT100 screen ; ; The VT100 screen can be of different sizes due to two ; factors. First the number of columns may be changed by ; the user via setup mode to either 80 or 132 columns. ; Second the advanced video option allows a full 24 ; lines by 132 columns. If this option is not present ; only 16 lines are available with 132 column format. ; Double high and double wide characters are not considered ; since these attributes are only valid on a line by line ; basis and the editor does not use them. ; ;Assumptions: ; It is assumed that the esc seq to move down and to the right ; will move to the extremeties of the screen and not fail to ; move if the number is illegal. Also an esc seq is needed to ; return the cursor position. ; Lines and columns are numbered 1 - n. N is returned. ; ;INPUTS: NONE ; ;OUTPUT: ; R1 = columns R2 = lines ; R0,R3,R4 destroyed ; C set if unable to size screen or if invalid screen size ;-- .If NE,VT10$0 ;VT100 Terminal .Enable LSB SizScr:: ;~x~ Call $TFlsh ;~x~Flush the input buffer Call $SpOn ;~x~Special mode $Print #SizSeq ;~x~Size the screen Mov #RtnSeq,R1 ;Return introducer 10$: Call $TtyIn ;~x~Does it match CmpB (R1)+,R0 ;? Bne 20$ ;~x~No ... return error TstB @R1 ;More to check? Bne 10$ ;~x~Yes Call GetPrm ;~x~Get the line size CmpB R0,# ;Separator Bne 20$ ;~x~ Mov R1,R2 ;Save lines ;>>>this looks broken, fix and add saving width first time thru Cmp R2,#V.Lin1 ;Valid number of lines? Blo 20$ ;~x~Br if not Call GetPrm ;~x~Get columns Cmp R1,#V.Lin8 ;Valid number of lines? Blo 20$ ;~x~Br if not CmpB R0,# ;Terminator Bne 20$ ;~x~ CallR HV.Fix ;~x~Fixup screen size in VWATCH .............. 20$: Sec ;~x~Return error Return ;~x~ ...... .Dsabl LSB .SbTtl GETPRM - Get esc seq parameter ;++ ;GETPRM ; ;FUNCTIONAL DESCRIPTION: ; ; Get esc seq parameter ; ;INPUT: NONE ; ;OUTPUT: ; R0 = term for param ; R1 = param value ;-- .Enable LSB GetPrm: Clr R1 ;~x~Clear value 10$: Call $TtyIn ;~x~Get a digit CmpB R0,# ;In range Blo 20$ ;~x~Nope - its a term CmpB R0,# ;In range Bhi 20$ ;~x~Nope - its a term Push ;And now for the famous x 10 sequence Asl R1 ;In case there are any newcomers ;in the audience Asl R1 ;Its based on 10x=(4x+1x)*2 and uses Add (SP)+,R1 ;the stack to save 1x until the ;shifts Asl R1 ;A shift is a * 2 Sub #,R0 ;Make char a binary digit Add R0,R1 ;Accumulate the digit Br 10$ ;~x~And back for another .......... 20$: Return ;~x~ ...... ; ; Esc seq for sizing screen (ANSI of course) ; PSect .TXT. SizSeq: .Byte , ;~d~Save cursor position .Byte ,, ;~d~Home .Byte ,,'2,'4, ;~d~Down .Byte ,, ;~d~Make single width line .Byte ,,'1,'3,'2, ;~d~Right move .Byte ,,, ;~d~Report cursor position .Byte , ;~d~Restore cursor position .Byte RtnSeq: .Byte &77,,000 ;~d~Return introducer PSect KEDCMD .Dsabl LSB .EndC; NE,VT10$0 .SbTtl PRMPT - Accept a prompt ;++ ;PRMPT ; ;FUNCTIONAL DESCRIPTION: ; ; Display a prompt. Accept a string and allow editing it ; Used in processing: REPEAT, FIND, COMMAND ; ;INPUT: ; Jsr R4,Prmpt ; .Word PrmStr ;Ascii ended with ; R1 = impure offset to string ; .BlkW ;to hold end address of str ; R1 -> .BlkB PrmSiz ;string space ; (R4) -> prompt text ; PrNum = 0 any chars legal ; Non 0 numbers only legal, first in R0 ; ;OUTPUT: ; C set , string no good, cancel command ; C Clr, R0 = keypad char, string filled ; R0 = term char ; R1 -> string (abs ptr) ; Other regs used ; ;EDITING IS: ; DEL = rub a char ; CTRL/U = rub whole line ; CTRL/C = cancel command ; CTRL/Z = cancel command ;-- .MCall .CkXX .CkXX .Enable LSB 10$: TstB QuoChr ;~x~Is the quote char defined? Bne 20$ ;~x~Yes, leave it alone MovB R0,QuoChr ;Else define it 20$: CmpB R0,QuoChr ;~x~Is this the quote char? Bne 60$ ;~x~no, just data then ComB QuoFlg ;flip the quoted state Br 60$ ;~x~and treat as data ........... Prmpt:: ;~x~ Mov R0,R2 ;Save char temp Call $DsPrm ;~x~Display prompt at terminal Mov R1,R3 ;Start here to store string Mov R2,R0 ;Get char back Clr QuoBth ;Clear quote char and flag bytes Tst PrNum ;Numbers only Bne 40$ ;~x~Yes, we have the input 30$: TtyIn ;~x~A char to look at 40$: Mov #PChars,R2 ;~x~point to list of interesting chars Ck.R2=PChars Ck.R2 PDEL,+1 CmpB R0,(R2)+ ;# Rub a char? Beq 90$ ;~x~Yep Ck.R2 PCtlW,+1 CmpB R0,(R2)+ ;# Ctrl/W refreshes the screen Beq 120$ ;~x~ Ck.R2 PCtlR,+1 CmpB R0,(R2)+ ;# Ctrl/R refreshes the screen Beq 120$ ;~x~ Ck.R2 PCtlU,+1 CmpB R0,(R2)+ ;# Rub the entire line Beq 160$ ;~x~Yep Tst PrNum ;Numbers only? Beq 50$ ;~x~No all legal Call DgtQ ;~x~Digit? rtn C clear Bne 210$ ;~x~No- dump us off Br 60$ ;~x~Yes- output it ........... Ck.R2 PCtlC,+1 50$: CmpB R0,(R2)+ ;~x~# Forget the whole mess Beq 190$ ;~x~Yep Ck.R2 PCtlZ,+1 CmpB R0,(R2)+ ;# Forget the whole mess Beq 200$ ;~x~Yep Ck.R2 PESC,+1 CmpB R0,(R2)+ ;#&77 Terminating sequence? Beq 210$ ;~x~Yep TstB R0 ;Is this the end of a recover file? Beq 210$ ;~x~Yup Ck.R2 P1Quot,+1 CmpB R0,(R2)+ ;# Is it a single quote char? Beq 10$ ;~x~yes Ck.R2 P2Quot,+1 CmpB R0,(R2)+ ;# Is it a double quote char? Beq 10$ ;~x~yes TstB QuoFlg ;Are we inside quotes? Bne 60$ ;~x~yes, then CR is data IsCR OFF,60$ ;~x~Are we in command mode? no Ck.R2 PCR,+1 CmpB R0,(R2)+ ;# Yup, do we have a ? Beq 210$ ;~x~Yep - let's split 60$: Push ;~x~Are we beyond the string Sub R1,@SP ;Make chars in string Cmp (SP)+,#PrmSiz ;Ok Bhis 140$ ;~x~Nope, too long .If NE,VT10$0 ; ; If VT100 check for special graphics ; Call SplGrf ;~x~Special echo char? Bcs 70$ ;~x~no Mov R0,R2 ;Yes, save real char $Print #GrfOn ;~x~Turn on graph mode MovB GrfTbl-(R2),R0 ;Get char TtyOut ;~x~Output it $Print #GrfOff ;~x~Graph mode off Mov R2,R0 ;Get char back CmpB #,R0 ;was it CR? Bne 80$ ;~x~no MovB R0,(R3)+ ;yes, put in buffer MovB #,R0 ;now add in a LF Br 60$ ;~x~Carry on ........... .EndC; NE,VT10$0 70$: CmpB R0,# ;~x~Control char Blo 180$ ;~x~Echo it properly TtyOut ;~x~Normal echo 80$: MovB R0,(R3)+ ;~x~Save the char Br 30$ ;~x~Back for another ........... ; ; Delete a char from string ; 90$: Cmp R3,R1 ;~x~Delete address check Blos 30$ ;~x~None left ignore .If NE VT62$!VT10$0 Call $RstVA ;~x~Change video attributes if necessary .EndC; NE VT62$!VT10$0 .If NE,VT10$0 MovB -(R3),R0 ;Get char CmpB R0,QuoChr ;is it the active quote char (never nulls) Bne 100$ ;~x~no ComB QuoFlg ;flip the "quoted" state 100$: Call SplGrf ;~x~Special echo char? Bcc 110$ ;~x~no CmpB R0,# ;Control char? .IfF; NE,VT10$0 CmpB -(R3),# ;Control char .IfTF; NE,VT10$0 Bhis 110$ ;~x~Nope erase only one $Print #BkSp ;~x~Erase two chars for control char 110$: $Print #BkSp ;~x~Erase one for normal char .EndC; NE,VT10$0 Br 130$ ;~x~Go get the next character ........... 120$: ;~x~ ; ; Refresh the screen ;*JMP* $Print #AltOn ;~x~Alternate keyboard on 130$: ;~x~ .If NE VT62$!VT10$0 Call $SetVA ;~x~Reset video attributes for input .EndC; NE,VT10$0!VT62$ Br 30$ ;~x~Back to another char ........... 140$: IsExe ON,150$ ;~x~Are getting input from a macro/@file? Call BelRng ;~x~Indicate error 150$: TtyIn ;~x~Get next character .If NE,VT10$0 Call RstQut ;~x~Restore screen if quiet mode .EndC; NE,VT10$0 Br 40$ ;~x~Back with character ........... ; ; Cancel the prompt ; 160$: ;~x~ .If NE,VT10$0!VT62$ Call $RstVA ;~x~Restore video attributes .EndC; NE,VT10$0!VT62$ Call $DsPrm ;~x~Re-display prompt Mov R1,R3 ;Set adr again Clr QuoBth ;Clear quote char and flag bytes 170$: Br 30$ ;~x~And restart ............ ; ; Print control char ; 180$: ;~x~ Push ;Save the char to echo control char TtyOut # ;Uparrow first Mov @SP,R0 ;Char back Bis #100,R0 ;Make printable TtyOut ;~x~Echo it Pop ;Restore the char .If EQ VT10$0 CmpB #,R0 ;was it CR? Bne 80$ ;~x~no MovB R0,(R3)+ ;yes, put in buffer MovB #,R0 ;now add in a LF Br 60$ ;~x~carry on ........... .IfF; EQ VT10$0 Br 80$ ;~x~save the char ........... .EndC; EQ VT10$0 ; ; Various means of leaving this routine ; 190$: IsJRe OFF 200$ ;~x~recovery? Call $RdRec ;~x~yes, process record Br 170$ ;~x~continue gathering command ........... 200$: Mov R1,R3 ;~x~Forget the whole thing, start=end Sec ;Return error set 210$: ;~x~ Rol R2 ;Preserve carry Mov R3,-2(R1) ;Save end of string Bit R0,(R4)+ ;Advance over arg .If NE,VT10$0!VT62$ Call $TrmPr ;~x~Terminate prompt (restore vid attr) .EndC; NE,VT10$0!VT62$ Ror R2 ;Restore carry Rts R4 ;~x~ and return .......... ; ; return carry clear if R0 is HT .. CR ; else return carry set ; SplGrf: ;~x~ CmpB R0,# Blo 220$ ;~x~Nope CmpB #,R0 ;? 220$: Return ;~x~ ...... ; ; Data for the prompt routine ; PSect IMPURE PrNum:: .BlkW 1 ;~d~Nonzero for numeric only QuoBth: ;~d~ QuoFLg: .BlkB 1 ;~d~zero outside quotes, nonzero inside QuoChr: .BlkB 1 ;~d~zero, no quote char, nonzero contents ;is the quote chaR (" or ') PSect .TXT. PChars: ;~d~chars used in main parse tests PDEL: .Byte ;~d~ PCtlW: .Byte ;~d~ PCtlR: .Byte ;~d~ PCtlU: .Byte ;~d~ PCtlC: .Byte ;~d~ PCtlZ: .Byte ;~d~ PESC: .Byte &77 ;~d~ P1Quot: .Byte ;~d~ P2Quot: .Byte ;~d~ PCR: .Byte ;~d~ BkSp: .Byte ,,, ;~d~Erase one character backward .Even .If NE,VT10$0 ;VT100 Terminal GrfTbl: .Byte ,,,, ;~d~TB,LF,VT,FF,CR special chars .Even .EndC; NE,VT10$0 ;VT100 Terminal PSect KEDCMD .Dsabl LSB .SbTtl SRCSET - Set up search defaults ; ;SrcSet ; ;Null out search string and set to use the defaults ; .Enable LSB SrcSet:: ;~x~ Mov #SrStr,SrEnd ;Set end of string to beginning Clr SrPlc ;Where to set cursor Clr ExctQ ;Non exact searches Clr SBound ;Non bounded search Clr TgtSlt ;No search select defaulting Mov SP,RetTNF ;Return on file not found Return ;~x~ ...... .Dsabl LSB .SbTtl C.S80 - Set screen size on vt100 .SbTtl C.S132 - ; ; C.S80 - C.S132 -- send esc sequence to set screen size ; and go to the screen update routine to resize screen etc. ; .If NE,VT10$0 ;VT100 Terminal .Enable LSB C.S80:: ;~x~ Mov #Set80,R0 ;For 80 columns Br 10$ ;~x~And go size screen ........... ; ; C.S132 - set size to 132 columns ; C.S132:: ;~x~ Mov #Set132,R0 ;For 132 columns 10$: ;~x~ EndChk ;~x~Validate command line termination Push TtInp ;Save input mode ExeOff ;Make sure we print $Print R0 ;~x~Print 80/132 Pop TtInp ;Restore mode CallR SetScr ;~x~Size screen and setup rest of things .............. .Dsable LSB PSect .TXT. .NList BEX Set132: .Byte ,,,, ;~d~for 132 columns .Byte ;~d~ .List BEX PSect KEDCMD .EndC; NE,VT10$0 ;VT100 Terminal .SbTtl C.HELP - Help function ; ;C.HELP ; ;Supply help for user ; .Enable LSB C.Help:: ;~x~ IsExe OFF 10$ ;~x~Are we executing a macro or file? Return ;~x~Yes, this is a NOP ...... 10$: ClrBsy ;~x~Not now busy Tst HlpTxT ;Is there a HELPER message? Bne 20$ ;~x~Yup, help is available Tst HlpFlg ;Is HELP suppressed? Beq 30$ ;~x~Nope print the help screens Call 70$ ;~x~Get SET HELP message 20$: Call $PrtHl ;~x~Else print help message Call HlpSet ;~x~Set for no help TtyIn ;~x~Wait here for the next input Br 60$ ;~x~and now go dispatch to it ........... ;without building ;stack space ; ;Display help forms ; 30$: Bit #HlPBit,LstCmd ;~x~Help form just displayed? Bne 50$ ;~x~Br if so 40$: Clr HlpFrm ;~x~Else initialize help form offset 50$: Mov HlpFrm,R4 ;~x~Get help form offset Tst HlpOvl(R4) ;Last one already displayed? Beq 40$ ;~x~If so start again .If NE,VT10$0 $Print #Set80 ;~x~Else set screen for 80 columns .IfTF ;For both Call ClrAll ;~x~Call VWATCH to clear screen Call @HlpOvl(R4) ;~x~Load in the help form overlay $Print (SP)+ ;~x~Print it Call $GtCod ;~x~Restore the code Bis #HlpBit,CurCmd ;Indicate help form displayed Add #2,HlpFrm ;Update help form offset TtyIn ;~x~Wait for the next input .IfT ;If VT100 Cmp #V.WCol,H.Size ;Screen in 132 column mode? Bne 60$ ;~x~Br if not Push ;Else save R0 $Print #Set132 ;~x~Restore 132 columns Pop ;Restore R0 .EndC ;NE,VT10$0 60$: Jmp CmdGo ;~x~Go dispatch on the input ............. 70$: ;~x~ ;+ ;HELPER HELPER ;~x~ ; ;The user pressed the help key when there was no helper message to report ;and the screens have been disabled with the SET NO HELP command. KED ;politely tells the user how to reenable the screens. ;- .DsAbl LSB ; ; HLPSET -- set for no help text ; HlpSet:: ;~x~ Clr HlpTxt ;No more help for him Return ;~x~ ...... .SbTtl C.SHLP,C.NHLP - Turn help suppression off/on ; ; C.SHLP -- Turn off HELP suppression ; ; ; C.NHLP -- Suppress HELP screens for PF2 ; .Enable LSB C.SHlp:: ;~x~ Clr R3 ;Turn off suppress HELP C.NHlp:: ;~x~R3<>0 EndChk ;~x~Validate command line termination Mov R3,HlpFlg ;Suppress HELP (helpless) Return ;~x~ ...... .Dsable LSB .SbTtl Data for help routines PSect IMPURE HlpFlg::.BlkW 1 ;~d~Help display suppression flag HlpTxt::.BlkW 1 ;~d~Pointer to help for user HlpFrm: .BlkW 1 ;~d~Offset to address to call to load ; help form overlay PSect HLPOVL HlpOvl: ;~x~Start of list of help form addresses .Word $GtHl1 ;~x~Keypad layout .Word $GtHl2 ;~x~Command help I .Word $GtHl3 ;~x~Command help II .Word $GtHl4 ;~x~Command help III .Word $GtHl5 ;~x~Command help III .Word $GtHl6 ;~x~Gold keyboard functions help .Word 0 ;~d~Null to end list of help forms PSect KEDCMD .SbTtl C.StWo,C.NoWo - Turn "Working" message on/off ; ; C.StWo -- Turn working message on ; ; ; C.NoWo -- Turn working message off ; .Enable LSB C.StWo:: ;~x~ Clr R3 ;Turn on "Working" Br 10$ ;~x~Join common code ........... C.NoWo:: ;~x~ Mov #100000,R3 ;Put "infinite" time in MRKT request EndChk ;~x~Validate command line termination 10$: ;~x~ Mov R3,BsyTic ;Make "Working" cycle 1 sec or "forever" Return ;~x~ ...... .Dsable LSB .SbTtl C.ErCo,C.ErSt - SET ERROR {CONT|STOP} ; ; C.ErCo -- Continue command file after error (like /Recover) ; ; ; C.ErSt -- Continue command file after error (normal action) ; .Enable LSB C.ErCo:: ;~x~ SerOn ;continue through errors Return ;~x~ ...... C.ErSt:: ;~x~ SerOff ;stop on error Return ;~x~ ...... .Dsable LSB .SbTtl C.SPAR - Define paragraph and page .SbTtl C.SPAG - ; ; C.SPAR, C.SPAG -- define paragraph and page ; .Enable LSB C.SPar:: ;~x~ Mov #Df$Par,R4 ;Paragraph definition block Br 10$ ;~x~Carry on ........... C.SPag:: ;~x~ Mov #Df$Pag,R4 ;Page definition block 10$: NoEChk ;~x~No command end check Call KnumQ ;~x~Lines or string? Bcc 60$ ;~x~Lines- number found MovB (R1)+,R0 ;Get next character as delimiter Beq 80$ ;~x~End of line- error CmpB R0,# ;Allow both quotes Beq 20$ ;~x~Ok CmpB R0,# ;Either is fine Bne 80$ ;~x~No good 20$: Mov R4,R2 ;~x~Start of string 30$: CmpB @R1,R0 ;~x~Look for end delimiter Bne 40$ ;~x~Not a delimiter CmpB 1(R1),R0 ;Paired delimiters? Bne 50$ ;~x~No TstB (R1)+ ;Yes, skip 1, use next as data 40$: MovB (R1)+,(R2)+ ;~x~Save the char Beq 80$ ;~x~No delimiter Br 30$ ;~x~Keep looking .......... 50$: Mov R2,-2(R4) ;~x~Save the end address Clc ;no error Return ;~x~No error ...... 60$: TstB @R1 ;~x~End of command? Beq 70$ ;~x~Yep- use lines Mov #K.PgR,R3 ;Analyse rest of line CallR KyCall ;~x~By subroutine .............. C.SpGL:: ;~x~ Call C1EndQ ;~x~Command terminated properly? 70$: Clr -2(R4) ;~x~Not string Mov KNumbr,@R4 ;Save number in next word Ble 80$ ;~x~Illegal line count Return ;~x~No error ...... C.SpGE:: ;~x~Error entry 80$: Clr -2(R4) ;~x~Error define as one line Mov #1,@R4 ;So do it ;+ ;HELPER HELPER ;~x~ ;illegal terminator ( not ' or ") , no string in command, ;no ending delimiter, or line count <= 0, or LINES not proper. ;- .Dsable LSB ; ; SETDPA -- define default page and paragraph ; .Enabl LSB SetDPa:: ;~x~ Mov #Df$Pag,R3 ;Page first Mov R3,-2(R3) ;End address Inc -2(R3) ;String one byte MovB #,@R3 ;Default string Mov #Df$Par,R3 ;Paragraph Clr -2(R3) ;Line definitions Mov #16.,@R3 ;16 lines is a paragraph Return ;~x~ ...... .Dsabl LSB .SbTtl .SbTtl C.TABS - Set structured tabs ; ; C.TABS -- set structured tab indent value ; ; SET TABS NN sets increment to nn and level to one ; default increment is 4 ; SET NOTABS disables feature ; SET NO TABS disables feature ; .Enabl LSB C.Tabs:: ;~x~ NoEChk ;~x~No command end check Call KNumQ ;~x~Get the level Bcc 10$ ;~x~A number fine Mov #4,R2 ;Use 4 as default 10$: Call C1EndQ ;~x~Command ended properly? Mov #1,TbLvl ;Set level to one Mov R2,TbCnt ;Save the tab indent value Bgt 20$ ;~x~Good ;+ ;HELPER HELPER ;~x~ ; ;Indent value was minus or zero ;- ; ; C.NOTB -- disable structured tabs ; C.NoTb:: ;~x~ EndChk ;~x~Validate command line termination Clr TbCnt ;Disable the tabs by clearing count Clr TbLvl ;And level 20$: ;~x~ Return ;~x~ ...... .Dsabl LSB .SbTtl C.TADJ - Adjust tab level of select range ;++ ;C.TADJ ; ;FUNCTIONAL DESCRIPTION: ; ; The first segment of tabs and/or spaces on each line of the ; select range is replaced by a segment of tabs and spaces ; which bring the following text to the original column ; plus or minus the change in level desired. ; ; This is accomplished by scanning the select range from ; beginning to end and first counting the column of the ; text beyond the tab segment then deleting it and replacing ; it as if it had just been typed in. ; ; A change in level count of zero is meaningful. It causes ; no change in the column count but causes the tab segment to ; be optimised by replacement with a minimum number of tabs and ; spaces. ; ;INPUT: ; Command line is as follows: ; ; [TABS] ADJUST [+-]nnn ; ; Where nnn is the desired change in increments of tab level. ; ;OUTPUT: ; The select range of the file is altered. ;-- .Enable LSB C.TAdj:: ;~x~ NoEChk ;~x~Do not perform end check on command Call KNumQ ;~x~Convert parameter Call C1EndQ ;~x~Check for end of command now Tst Inspct ;We must not be in inspect mode Bne 170$ ;~x~Illegal in inspect mode Tst TbCnt ;Tabs must be enabled Ble 180$ ;~x~Tabs are not enabled Tst SlctQ ;We must have explicit select range Beq 190$ ;~x~No select range, then error Mov R2,R1 ;Save the parameter for later check Bpl 10$ ;~x~Make a copy of it positive Neg R2 ;Absolute value 10$: Cmp R2,#50. ;~x~There is a limit to our helpfulness Bhi 200$ ;~x~This guy is silly, bump him off Clr Un$Blk ;Disable undeletes Mov SlctC,R3 ;Grab the select count Mov SlctC+2,R4 ;Hi part too Bne 20$ ;~x~OK, its valid Tst R3 ;Low part nonzero Beq 190$ ;~x~No select range of the second kind 20$: Clr R0 ;~x~Set up various dependencies Tst R2 ;Is this a zero adjust? Beq 40$ ;~x~Yes, the adjustment is zero 30$: Add TbCnt,R0 ;~x~Make the tab adjustment in columns Sob R2,30$ ;~x~The level count Tst R1 ;Which way do we go? Bpl 40$ ;~x~Positive so leave the count alone Neg R0 ;We are going to shorten the tabs 40$: Push ;~x~Move things to safe places Push ;So we can use a routine Mov #1,TbLvl ;Level is simple for simple use Push ;Save columns to change by Mov SP,SlctQ ;Save sp for error restore ; ; Adjust select range parameters and our position in range ; Tst R4 ;Which way does the select range go? Bpl 50$ ;~x~We are at the end of it Neg R4 ;Adjust the sign of the counter Neg R3 ;For our counter algorithm Sbc R4 ;To make it positive Br 70$ ;~x~Carry on later ........... 50$: Mov R4,R2 ;~x~Make copies to use Mov R3,R1 ;Of the count words 60$: Call MvBkw ;~x~Move back to start of select range Bcs 210$ ;~x~Something boo-boo'ed Sob R1,60$ ;~x~DP counter, low order Dec R2 ;High order Bpl 60$ ;~x~lots more 70$: ;~x~ ; ; Find first line to deal with ; Cmp BCP,PlyGnd ;Is this beginning of a line?? Blo 100$ ;~x~Start of text is start of line 80$: MovB @BCP,R0 ;~x~The character behind us Call LTerm ;~x~Is it a line terminator Beq 100$ ;~x~We found a line terminator 90$: Call 240$ ;~x~Move forward one character Br 80$ ;~x~Back for another character .......... ; ; Find start of first tab segment ; 100$: MovB @FCP,R0 ;~x~Character in front of us Call SpcTbQ ;~x~Look for a space or tab Beq 110$ ;~x~Right away Call 240$ ;~x~Move forward Br 100$ ;~x~'til we find a space or tab ........... ; ; Count our column and move to end of segment ; 110$: Call Count ;~x~Count where tab segment starts Push ;Save the start column 120$: Call 240$ ;~x~Move forward one character MovB @FCP,R0 ;To the end of the tab segment Call SpcTbQ ;~x~'til not a space or tab Beq 120$ ;~x~Back for next character Call Count ;~x~Count the column we are on Add 2(SP),R2 ;Increment the column Bgt 130$ ;~x~Desired column at least one Mov #1,R2 ;Desired column is one 130$: Cmp R2,(SP) ;~x~Is segment disappearing? Bhi 140$ ;~x~Its ok, more than one Mov (SP),R2 ;Use the column at beginning of ;tab segment Inc R2 ;Increase to make at least one 140$: Pop <> ;~x~Dump the count we don't need Mov R2,TbCnt ;Desired column 150$: MovB @BCP,R0 ;~x~Delete tab segment Call SpcTbQ ;~x~Spaces or tabs Bne 160$ ;~x~'til not space or tab Call RbChr ;~x~Delete a character Bcs 210$ ;~x~Some error occurred Br 150$ ;~x~Back for rest .......... 160$: Push ;~x~Save our count Push ;from harm Call PlcTab ;~x~Special entry to add tabs Bcs 210$ ;~x~Some error occurred Pop ;Restore our count Pop ;for use Br 90$ ;~x~Back for next line .......... ; ; Adjustment errors ; ; ; These errors need no special recovery ; 170$: Jmp NoInsp ;~x~then tell operation is invalid .............. 180$: ;~x~ ;+ ;HELPER HELPER ;~x~ ; ;SET TABS must have been done before ADJUST is legal. ;- 190$: ;~x~ ;+ ;HELPER HELPER ;~x~ ; ;An explicit select range is required for ADJUST. ;- 200$: ;~x~ ;+ ;HELPER HELPER ;~x~ ; ;The numeric parameter must be in the range -50 - +50 decimal. ;- ; ; 210$ -- Signal a logic error and return error set ; ; 220$ -- Return normally ; 210$: Call 230$ ;~x~Signal a logic error 220$: Mov SlctQ,SP ;~x~*C* Restore the stack Bic SP,SlctQ ;*C* Remove the select range Pop <>,SAVE=*C* ;*C* Dump the tab change count Pop ,SAVE=*C* ;*C* Restore the tab level Pop ,SAVE=*C* ;*C* Restore the tab count Return ;~x~*C* Return from the command routine ...... 230$: ;~x~ ;+ ;HELPER HELPER ;~x~ ; ;Some error halted a move or delete of text. CTRL/C will override ;this message. ;- ; ; Move forward with select range count ; 240$: Call MvFwd ;~x~Move to next character Bcs 210$ ;~x~Return an error Dec R3 ;Low order count first Bne 250$ ;~x~Plenty more to go Clc ;Return c clear if done Dec R4 ;High order count now Bmi 220$ ;~x~We are all done now 250$: Return ;~x~ ...... .END