On Mon, Dec 15, 2025 at 03:18:04PM +0100, Dirk Gouders wrote: > Hello, > > I have problems to understand how the capability u6 (cursor position > report) is supposed to being used. > > My naive expectation was that I output a u7 (cursor position request), > then read the result and use u6 for a *scanf() function. But, in my > case, because of the %i in "\E[%i%d;%dR" a *scanf() fails.
The comment in terminfo.src does say "scanf":
# The cursor position report (<u6>) string must contain two scanf(3)-style
# %d format elements. The first of these must correspond to the Y coordinate
# and the second to the %d. If the string contains the sequence %i, it is
# taken as an instruction to decrement each value after reading it (this is
# the inverse sense from the cup string). The typical CPR value is
# \E[%i%d;%dR (on VT100/ANSI/ECMA-48-compatible terminals).
#
# These capabilities are used by tack(1m), the terminfo action checker
# (distributed with ncurses 5.0).
but it would be more accurate to say, "tparm". The description was by
Eric Raymond in 1995, probably meant to use terms familiar to the reader.
(I knew what was meant, and because of familiarity, overlooked this...)
Interestingly enough, tack tests u8 and u9, but not u6 and u7.
ncurses 6.5 does have a use for u6 and u7, but only in a special case
where it matches common variants of that particular string:
20231001
+ modify setupterm to provide for using ANSI cursor-position report (in
user6/user7 terminfo capabilities) to obtain screensize if neither
environment variables or ioctl is used. The ncurses test-program
with options "-E -T" demonstrates this feature.
(it corresponds to the only testable case at hand: VT100-compatibles).
In the current terminfo.src, I see u6/u7 used only in 9 places
(ansi+cpr is in turn used by 16 other places, and beterm, cit101e-rv,
minitel2-80 though long gone are equivalents). The other 4 aren't
found in the wild anymore.
ansi+cpr|ncurses extension for ANSI CPR,
u6=\E[%i%d;%dR, u7=\E[6n,
beterm|BeOS Terminal,
sgr0=\E[0;10m, smkx=\E[?4h, u6=\E[%i%p1%d;%p2%dR,
xterm-8bit|xterm terminal emulator 8-bit controls (X Window System),
tbc=\2333g, u6=\233[%i%d;%dR, u8=\233[?%[;0123456789]c,
hp98550-color|hp98550a-color|HP 9000 Series 300 color console (Trusler),
smul=\E&dD, tbc=\E3, u6=\Ea%dc%dR\r, u7=\Ea,
tvi912b-unk|tvi912c-unk|TeleVideo TVI-912B or TVI-912C (no attributes),
mc5=\E@, rs1=\Ek\010\Em\010\Eq\032, tbc=\E3, u6=%c%c\r,
cit101e-rv|C. Itoh CIT-101e (sets reverse video),
u6=\E[%i%p1%d;%p2%dR, u8=\E[?6c, use=ansi+enq,
minitel1|minitel 1,
u6=\037%c%'A'%-%c%'A'%-, u7=\Ea,
minitel2-80|minitel 2 (80cols) avec filets VT100 (DEC),
enacs=\E)0, rmacs=^O, smacs=^N, u6=\E[%i%d;%dR,
minitel12-80|minitel 12 (80cols),
civis=\E[<1h, cnorm=\E[<1l, is2=\E[12h, u6=\E[%i%d;%dH,
> In util-linux (term-utils/setterm.c) and also ncurses
> (ncurses/tty/tty_update.c) such results ares scanned using a constant
> format "\033[%d;%dR" -- no tigetstr() happens.
>
> Regards,
>
> Dirk
--
Thomas E. Dickey <[email protected]>
https://invisible-island.net
signature.asc
Description: PGP signature
