:: krowemoh

Thursday | 26 DEC 2024
Posts Links Other About Now

previous
next

EVA - Go to the End of a Line

2024-01-28
EVA, pick, editor, basic

I updated the $ command to go to the end of a multiline line. This involved adding a bit of logic to move the cursor to the last line and to use that line to move the cursor to the end.

      END ELSE IF CHR = '$' THEN
         REAL.LINE.NUMBER = LINE.NUMBERS<CURRENT.LINE>
         NUMBER.OF.LINES = DCOUNT(LINES,@AM)
*
         Y.POS = Y.POS - 1
         FOR LS.POS = CURRENT.LINE TO NUMBER.OF.LINES
            IF LINE.NUMBERS<LS.POS> = REAL.LINE.NUMBER THEN
               Y.POS = Y.POS + 1
            END ELSE
               EXIT
            END
         NEXT LS.POS
*
         CURRENT.LINE = LS.POS - 1
         LINE.LEN = LEN(LINES<CURRENT.LINE>)
*
         X.POS = MARGIN.LEFT + LINE.LEN - 1
         PRINT @(X.POS,Y.POS) :
*

I have a 2 arrays of lines. One is the raw data and one is the lines split up for displaying. The set of display lines is tied to another array of line numbers where lines that are split can be tracked by keeping the real line number the same for each of the lines.

This way I can loop through and find all the line numbers that are the same and related to the current line. This will tell me how long that real line is. The logic then moves the cursor to the last line and this works perfectly for both single line lines and multiline lines.

Lines lines lines.