! TECO.INI - Kelvin Smith ! ! This initialization file does a series of loads into q-registers and ! ! executes two user-defined switches, if present. General permission ! ! to copy or modify, but not for profit, is hereby given. ! ::@S%MUNG% "S @O!EXIT! ! MUNG command--don't execute this stuff ! ' :@S%/VT% "S @O!CMDOPS! ! /VT - loading VTEDIT; no macros ! ' @^A/Loading library functions / ! Let user know what's happening ! ! MQ - back up a file, returning to same position ! ! 1MQ - exit, marking position such that /FIND returns to that spot ! ! -1MQ - find front of file (useful if past first page) ! ! Equivalent to VTEDIT commands $1$F, $0$F, and $F respectively ! @^UQ} +0U.A @EW// ! Make sure we have right file name ! Q.A+1"> ! 0MQ or 1MQ ! @I%~~/\~~ % ' ! Mark position (/FIND compatible) ! Q.A-1"< ! -1MQ or 0MQ ! EC @EB%Q*% ! Close and reopen same (?) file ! Q.A"= ! 0MQ ! @FN%~~/\~~ %% ! Find marker and delete ! @^A/File backed up / | Y ! -1MQ ! @^A/At beginning of / :G* 13^T 10^T ! Verify the file ! ' | @^A/Position marked, exiting / EX ! 1MQ ! ' } ! [n]M1 - delete n words (default: 1), saving deleted text in q-reg 0 ! ! "word" defined as series of printing characters followed by series ! ! of non-printing and/or space characters (ASCII<=32) ! ! Reasonably equivalent to VTEDIT [-]^B (may behave differently with ! ! starting blanks and one-letter words). ! @^U1~ +0U.B Q.B"= 1U.B ! Default = 1 ! ' Q.B"> ! Positive direction ! Z-."= ! If at end of buffer ! @O!M1EXIT! ! Nothing to delete ! ' 0U.A Q.B< < %.AA-33:; ! Skip over printing chars ! > < %.AA-33; ! Skip over control and space chars ! Q.AA"< ! Have we hit end of buffer? ! 1; ! We can quit ! ' > Q.AA"< ! Exit main loop at buffer end ! 1; ' > | ."= ! If at start of buffer ! @O!M1EXIT! ! Nothing to delete ! ' -1U.A ! Negative direction ! -Q.B< < -1%.AA-33; ! Back over control and space chars ! > < -1%.AA-33:; ! Back over printing chars ! ! No check needed for buffer begin: ! > ! it will stop automatically (AA=-1) ! %.A ! Correct overrun ! +.-1:; ! Exit loop if at buffer begin ! > ' .,.+Q.AX0 Q.AD ! Save in q-reg 0 before deleting ! !M1EXIT! ~ ! [n]M2 - Scrolling TECO for wide screen; n is lines of scrolling ! ! command region (default: 8). Set flag so that failing searches ! ! preserve dot (avoid repainting the screen), and let user know. ! @^U2~ +0U.A 0,16ED ! Failing searches preserve dot ! 132,1:W^[ ! Wide screen ! Q.A"= 8U.A ! Default of eight lines ! ' Q.A,7:W ! Set up scrolling TECO ! @^A/Failing searches preserve dot/ 13^T 10^T ~ ! m,nM3 - effective m,nD (or m,nK), but save deleted text in q-reg 0. ! ! This can work as a cut-and-paste operator, and can also give peace ! ! of mind when making large deletions. . . . ! @^U3~ U.A U.0 Q.A,Q.0X0 Q.A,Q.0D ! Save text before deleting ! ~ ! [n]M4: W. Franklin Mitchell's "super delete" -- delete all text until ! ! next occurrence of character given. My additions: store deleted text ! ! in q-reg 0; allow search for nth occurrence; if n<0, append text to ! ! q-reg 0 (like M3, this is useful as a cut-and-paste tool). ! @^U4~ +0U.0 Q.0"< ! Check for negative (append) ! -1U.B 0-Q.0U.0 ! Flag it and switch back to positive ! | 0U.B ' Q.0"= 1U.0 ! Default: first occurrence ! ' .U.A @^A/Chr? / ^T@^U.A%% ! Get character from user ! 13^T 10^T Q.0:@S%Q.A% ! Find it ! "S Q.B"N ! Negative: append to q-reg 0 ! Q.A,.:X0 Q.A,.D | Q.A,.X0 Q.A,.D ! Positive: stuff it in ! ' | Q.AJ ! Couldn't find it--restore pointer ! 7^T ! and ring bell ! ' ~ ! M5: VTEDIT's ESC -N command -- take last word from previous line and ! ! put it at beginning of present line (you must be at the beginning of ! ! the line). Here "word" is delimited by a space or tab. ! @^U5~ -2D @I/ / -2@FS%S% %~ ! Replace space(s) & tab(s) with CR-LF ! ! M6: Fix indentation. With a positive argument (default: 1), this ! ! command adds a tab to each line (argument is number of lines to so ! ! alter), removing a tab before any comment. With a negative argument, ! ! remove a tab from the beginning of the line and add it before any ! ! comment (so comment lines continue to line up). Blank lines remain ! ! unaffected in either case. ! @^U6~ +0U.A Q.A"= 1U.A ! Default: 1 ! ' Q.A"> ! Positive--add tab ! 0L Q.A< ! Do QA lines ! 1^Q-2"> C 9@I%% ! Add tab; not on blank lines ! :@FC% !%!% ! Remove tab if one before a comment ! "S R -1A-9"N ! No other tab ! 32@I%% ! Add a space ! ' ' ' 1V L ! "1"--:FC returns an unwanted value ! Q.A-1"= T ! If just one line, show next ! ' > | ! Negative--take out tab ! 0L -Q.A< ! Do Q.A lines ! 1^Q-2"> C D ! Take out tab; not on blank lines ! :@FC%!% !% ! Add tab before any comment ! ' 1V L ! "1"--:FC returns an unwanted value ! Q.A+1"= T ! If just one line, show next ! ' > ' ~ ! M8: Print a listing of present capabilities ! @^U8~ @^A/Present functions: MQ - Make backup 1MQ - Quit, position marked -1MQ - Front of file [n]M1 - Delete word(s) [n]M2 - 132 col, n line scroll (def: 8) m,nM3 - Cut to Q0 [n]M4 - Cut until nth occurrence of char (n<0: append) M5 - Get last word G0 - Retrieve most recent cut [n]M6 - Fix indentation / ~ !CMDOPS! ! Operations on the command line ! ! Check the file name. If it exists and doesn't include a dot, ! ! assume a .B2S file type and /B2 editing format. ! J :@S%^ES^N/% ! Is there a space (not before switch)? ! "S ! Yes -- beginning of file name (TECO filnam) ! .U.A ! mark it ! :@S%.% ! Look for a dot ! "U ! If none... ! :@S%/% ! Look for a switch ! "S ! Found one ! .-Q.A"> ! If it's after the file name ! R ! then position pointer before it ! | ZJ ! else go to end of command line ! ' | ZJ ! No switches -- go to end of command line ! ' @I%.B2S/B2% ! No dot: assume .B2S type and /B2 continuation format ! ' ' ! Switch operations: check the buffer to see if any user-defined ! ! switches have been invoked. If so, delete and execute them. ! ! /W[:n] - Wide screen scrolling TECO. Equivalent to [n]M2 ! J :@S%/W% "S ! Found /W switch ! -2D ! Delete it ! ::@S%:% ! A colon modifier? ! "S \U.A ^S-1D ! Get and delete any number ! | 0U.A ! Else 0 ! ' Q.AM2 ! Execute M2 with appropriate number ! ' ! /S:"..." - Search (actually an N search) for the first occurrence of ! ! the given string. This then dovetails in with /X below. It was ! ! added basically because I would continually forget to give the N ! ! command when using /X. . . . ! J :@S%/S:% "S -3D ! Delete switch ! 0A@^U.A%% ! Store delimiter ! C .U.A ! Start of search string ! @S%Q.A% ! Look for end delimiter ! @^U.A%N% ! N search ! Q.A,.-1:X.A ! Add search string ! Q.A-1,.K ! Delete string and delimiters ! @O!FIL! ! Join /X operations below ! ' ! Note that /S and /X are mutually exclusive ! ! /X:... - The wild card. Execute the sequence of commands following ! ! once the file has been opened. No escapes can be embedded, since ! ! they will terminate the CCL command (use @-modified commands if ! ! necessary). However, the last command is automatically followed by ! ! an escape. Store the command in a file TECXnn.TMP (placed at the ! ! beginning of the directory), where nn is the job number, zero-filled ! ! (LOGOUT will automatically kill it when user leaves), then EI it, ! ! which won't actually execute until TECO.TEC is done. ! ! Note that MODE will not work under VMS, and the file naming scheme ! ! is only relevant if more than one person is using TECO in the same ! ! account simultaneously (to avoid conflicts in file names). ! J :@S%/X:% "S -3D ! Delete switch ! 0A@^U.A%% ! Store delimiter char ! C .U.A ! Mark beginning ! @S%Q.A% ! Search for end delimiter ! Q.A,.-1X.A Q.A-1,.K ! Store command, then wipe out it & delimiters ! !FIL! ! Build file name -- /S joins here ! @^U.B%TECX% ! Compatible with TMP killing by LOGOUT ! 0EJ-10"< @I%0% ! Leading zero if necessary for job number ! ' 0EJ\ ! Necessary to go through buffer because no ! ! way to make number into characters otherwise ! .-2,.:X.B -2D ! Append job number to q-reg B ! @:^U.B%.TMP/MODE:#3000% ! Mode 3000 (octal) -- front of directory ! @EW%Q.B% ! Open it (for output) ! .U.P G.A ! The commands ! @I/@EI\\/ ! Close off input stream ! 27@I// 27@I// ! Add double escape to execute it ! Q.P,.PW Q.P,.K ! Write to file and clean up ! EF ! Close file ! @EI%Q.B% ! and execute it ! @^A/Executing... / ' !EXIT!