DavidKruse.ES@XEROX.COM.UUCP (02/25/87)
The recent submissions by Jon Forrest and Michael Bednarek were much appreciated, as I have been putting off writing a SET DEFAULT replacement for some time. I spend much of my time on a VaxStation II using different window sizes for different tasks, (132 x 48 or 80 x 48 for EVE editing, 40 x 10 to keep a window active, but off in a corner of the screen...) and I thought another bell and whistle could be useful here. To Michael's PCD I added (ANSI compatable?) terminal sequences to position the directory spec to the far right of the screen after determining the screen width. And because I wanted the prompt, and my input to the prompt, to be more visible I created a procedure (PROMPT_WIDE) to add a DEC terminal sequence to the prompt to enable double-wide printing for the prompt and user input. Rather pretty looking on the VS-II windows, but if you use a lot of long command lines it may be annoying, because VMS won't know when to "wrap" the command line. Just call PROMPT_WIDE again, it will toggle the double-wide "feature" each time it is called. PROMPT_WIDE will also check for the existance of SD sequences in the prompt, and if true will call SD to re-calculate the directory spec position. Note that PROMPT_WIDE depends on the existance of a symbol "SD" to call the SD command procedure. Modify this as necessary for whatever symbol your LOGIN file sets for SD.COM. I notice that our mailer converts underscore characters on incomming mail. I don't know if it also does this on outgoing, but if for example in line 10 of the first procedure the symbol "OLD_DIR" is not received as "OLDunderscoreDIR" you will have to globally edit whatever character you receive back to the underscore character. Dave Kruse ******************************************************************************** $!! SD.COM - Dave Kruse 20-FEB-1987 $!! MUCH code from PDC.COM by Michael Bednarek $!! and CD.COM by Jon Forrest $!! Sets default to P1, or SYS$LOGIN if P1 is null, and validates directory spec $! Sets prompt to Current Directory/CR/Previous Prompt $! Produces a 32 character prompt string with the directory as far to the $! right as possible, positioning the cursor however after the 'previous prompt' $ ON ERROR THEN EXIT $ IF (P1 .EQS. "") THEN P1 = F$TRNLOG("SYS$LOGIN") $ OLD_DIR = F$ENVIRONMENT("DEFAULT") $ SET DEF 'P1' $ DIRECTORY = F$ENVIRONMENT("DEFAULT") $ IF F$PARSE(DIRECTORY) .EQS. "" THEN GOTO NO_SUCH $ CR[0,8] = 13 $ TAB[0,8] = 9 $ ESC[0,8] = 27 $ TERM = F$GETJPI("","TERMINAL") $ TERM_IS_ANSI = F$GETDVI(TERM,"TT_ANSICRT") $ TERM_WID = F$GETDVI(TERM,"DEVBUFSIZ") ! How far the dir spec moves $ OLD_PROMPT = F$ENVIRONMENT("PROMPT") $ PCR = F$LOCATE(CR,OLD_PROMPT) ! position of <CR> in Old_Prompt $ If PCR.EQ.F$LENGTH(OLD_PROMPT) THEN PCR = -1 $ PROMPT = F$EXTRACT(PCR+1,255,OLD_PROMPT) ! part of Old_Prompt after <CR> $ LP = F$LENGTH(PROMPT) ! length thereof $ LD = F$LENGTH(DIRECTORY) $ IF LP+LD .LE. 25 THEN GOTO DO_IT $! If the length of the part of OLD_Prompt that we want to retain (LP) plus $! the length of the current directory is greater than 25 (the number of $! characters we have left after the other control characters are added to the $! 32 character maximum prompt string) we extract the rightmost part of the $! directory string. $ X = 25-LP $ DIRECTORY = F$EXTRACT(LD-X,X,DIRECTORY) $ LD = X $DO_IT: ! Need ANSICRT $ IF .NOT. TERM_IS_ANSI THEN GOTO NO_ANSI ! for cursor positioning $ MOVE = TERM_WID-LD-1 ! -1 so term doesn't wrap $ PROMPT = "''ESC'[''MOVE'C" + DIRECTORY + CR + PROMPT $ SET PROMPT = "''PROMPT'" $ EXIT $NO_SUCH: $ WRITE SYS$OUTPUT "NO SUCH DIRECTORY AS ''F$ENVIRONMENT("DEFAULT")'" $ SET DEF 'OLD_DIR' $ EXIT $NO_ANSI: $ N = 31-LD-LP ! n = greatest number of <TAB>s we can insert $ IF N*8+LD .GT. TERM_WID-1 THEN N = (TERM_WID-1-LD)/8 ! don't fall off screen $ PROMPT = F$FAO("!''N'*''TAB'")+DIRECTORY+CR+PROMPT $ SET PROMPT = "''PROMPT'" $ EXIT ******************************************************************************* $!! PROMPT_WIDE.COM Dave Kruse 20-FEB-1987 $!! Will modify the prompt to include a DEC terminal sequence for $!! double-wide characters to bold the prompt (if its not too long) $!! and the users input. $!! Depends on the existance of a global symbol SD to call the $!! procedure SD.COM *if* SD.COM has modified the prompt string. $ CR[0,8] = 13 $ ESC[0,8] = 27 $ TERM = F$GETJPI("","TERMINAL") $ TERM_IS_DEC = F$GETDVI(TERM,"TT_DECCRT") $ IF .NOT. TERM_IS_DEC THEN EXIT ! Need DECCRT for double-wide chars $ PROMPT = F$ENVIRONMENT("PROMPT") $ PCR = F$LOCATE(CR,PROMPT) $ PL = F$LENGTH(PROMPT) ! Has SD.COM modified the prompt? $ SD_HERE = (PCR .NE. PL) .AND. (F$LOCATE("''ESC'[",PROMPT) .EQ. 0) $ IF F$LOCATE("''ESC'#6",PROMPT) .EQ. PL THEN GOTO MAKE_BIG_PROM $ PROMPT = PROMPT-"''ESC'#6" ! Already big, make it small $ SET PROMPT = "''PROMPT'" $ IF SD_HERE THEN $SD [] ! Have SD rebuild its part. $ EXIT $MAKE_BIG_PROM: $ IF SD_HERE THEN PROMPT = F$EXTRACT(PCR+1,255,PROMPT) $ IF F$LENGTH(PROMPT) .GT. 3 THEN GOTO LONG_PROM $ SET PROMPT = "''ESC'#6''PROMPT'" $ IF SD_HERE THEN $SD [] ! Have SD rebuild its part. $ EXIT $LONG_PROM: ! some long prompt $ PROMPT = PROMPT + "''ESC'#6" ! rather than bold the whole thing $ PL = F$LENGTH(PROMPT) ! do just the users input. $ IF PL .GT. 32 THEN PROMPT = F$EXTRACT(PL-32,32,PROMPT) $ SET PROMPT = "''PROMPT'" ! and if it's TOO long - truncate it!! $ IF SD_HERE THEN $SD [] ! Have SD rebuild its part. $ EXIT
rcb@mcnc.org@rti-sel.UUCP (02/26/87)
In article <870225-111323-1387@Xerox> DavidKruse.ES@XEROX.COM writes: >I spend much of my time on a VaxStation II using different window >sizes for different tasks, (132 x 48 or 80 x 48 for EVE editing, 40 x 10 >to keep a window active, but off in a corner of the screen...) and I >thought another bell and whistle could be useful here. > >To Michael's PCD I added (ANSI compatable?) terminal sequences to >position the directory spec to the far right of the screen after >determining the screen width. For Vaxstation users, there is a really nice trick I ran across that keeps the width of the prompt down. There are some documented escape sequences in the workstation software users guide to allow you to all kinds of useful things with the window (like change size, shrink to icon) What I use is to put my current default into the banner line on top of the window.