From bd87ff40e73929e761e1233aa812a6736cacbed1 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 8 Dec 2024 05:22:17 +0300 Subject: implemented the ^Q command for converting between line and glyph positions * As known from DEC TECO, but extended to convert absolute positions to line numbers as well. :^Q returns the current line. * Especially useful in macros that accept line arguments, as it is much shorter than something like ^E@ES/LINEFROMPOSITION//+Q.l@ES/POSITIONFROMLINE//:^E-. * On the other hand, the fact that ^Q checks the line range means we cannot easily replace lexer.checkheader with something like [:J 0,^Q::S...$ ]: Using SCI_POSITIONFROMLINE still has the advantage that it returns `Z` for out-of-bounds ranges which would be cumbersome to write with the current ^Q. * Perhaps there should be a separate command for converting between absolute lines and positions and :^Q should be repurposed to return a failure boolean for out-of-range values? * fnkeys.tes could be simplified. --- lib/fnkeys.tes | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/fnkeys.tes') diff --git a/lib/fnkeys.tes b/lib/fnkeys.tes index fd6b332..ab78025 100644 --- a/lib/fnkeys.tes +++ b/lib/fnkeys.tes @@ -36,7 +36,7 @@ *! @[HOME]{ - ESLINEFROMPOSITIONESPOSITIONFROMLINE:U.p + 0+.U.p Q.pU.l Q.pESGETCOLUMN,4EJ Q.p-.M#c @@ -45,7 +45,7 @@ 1U[ HOME] @[END]{ - ESLINEFROMPOSITIONESGETLINEENDPOSITIONU.p + :-1ESGETLINEENDPOSITIONU.p Q.pESGETCOLUMN,4EJ Q.p:-.M#c } @@ -54,7 +54,7 @@ @[NPAGE]{ 0,4EJ - ESLINEFROMPOSITION+(ESLINESONSCREEN) + :-1+ESLINESONSCREEN ESPOSITIONFROMLINEU.p Q.p"< Z | Q.p: '-.M#c } @@ -63,7 +63,7 @@ @[PPAGE]{ 0,4EJ - ESLINEFROMPOSITION-(ESLINESONSCREEN)U.l + :-1-ESLINESONSCREENU.l Q.l"< 0 | Q.lESPOSITIONFROMLINE: '-.M#c } @[ PPAGE]{(M[PPAGE]} @@ -102,13 +102,13 @@ 1U[ SRIGHT] @[UP]{ - 4EJ(ESLINEFROMPOSITION-1)ESFINDCOLUMN:-.M#c + 4EJ,:-2ESFINDCOLUMN:-.M#c } @[ UP]{(M[UP]} 1U[ UP] @[DOWN]{ - 4EJ(ESLINEFROMPOSITION+1)ESFINDCOLUMN:-.M#c + 4EJ,:ESFINDCOLUMN:-.M#c } @[ DOWN]{(M[DOWN]} 1U[ DOWN] -- cgit v1.2.3