Trailing-Edge
-
PDP-10 Archives
-
steco_19840320_1er_E35
-
10,5676/teco/macros/line.tco
There is 1 other file named line.tco in the archive. Click here to see a list.
!;This macro returns the number of the current line in the text buffer. !
!;This number is defined as 1+(number of EOL characters to the left of !
!;the pointer). An EOL character is a line feed, vertical tab, or !
!;form feed. !
!;The best way to use this macro is to place it into Q-register L. !
!;The command !
!; EPTED:LINE$[*]L !
!;will do this. The above command can be placed in your TECO.INI !
!;file so that it will be done automatically each time you enter TECO. !
!;After that, the command "ML=" will print out your current line number.!
!;Note that if you go to the end of the buffer with a ZJ command, ML= !
!;will type out the number of lines in the buffer plus 1, since you are !
!;actually positioned at the beginning of the n+1st line. !
[0 [1 !;save contents of q-regisiters 0 & 1!
.U1 !;store the current value of the pointer into Q-reg 1!
0U0 !;initialize Q-reg 0 (our line counter) to 0!
< !;start a loop!
-SL; !;search from this point backwards for an end-of-line!
!;character. If no more, jump out of loop!
R !;back up over the one we just found, so we don't count!
!;it again!
%0 !;add 1 to Q-reg 0!
> !;loop for more!
Q1J !;restore our pointer (now at the beginning of the file)!
!;to its original position!
]1 !;restore the original contents of Q-reg 1!
Q0+(]0 1) !;Return Q0+1, and restore Q0!