bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-ncurses] ANN: ncurses-6.4-20240120


From: Dr. Werner Fink
Subject: Re: [bug-ncurses] ANN: ncurses-6.4-20240120
Date: Tue, 23 Jan 2024 09:10:49 +0100

On 2024/01/22 20:23:11 -0500, Thomas Dickey wrote:
> 
> I checked on the command-line using "tput smkx" and before/after, used
> "cat -v" (with ^V to make the escape character literal) and see urxvt
> using only the normal cursor keys (\E[ rather than the application \EO).
> 
> Using strace, I can see that "less" is only getting the normal cursor keys.
> 
>       71502 19:47:50 read(3, "\33", 1)        = 1
>       71502 19:47:52 read(3, "[", 1)          = 1
>       71502 19:47:52 read(3, "B", 1)          = 1
>       71502 19:47:52 read(3, "\33", 1)        = 1
>       71502 19:47:52 read(3, "[", 1)          = 1
>       71502 19:47:52 read(3, "B", 1)          = 1
>       71502 19:47:52 read(3, "\33", 1)        = 1
>       71502 19:47:53 read(3, "[", 1)          = 1
>       71502 19:47:53 read(3, "C", 1)          = 1
>       71502 19:47:53 read(3, "\33", 1)        = 1

Hmmm ... here we have different results for less

 read(4, "#\n# hosts         This file desc"..., 256) = 256
 read(4, "#\n# hosts         This file desc"..., 8192) = 800
 read(3, "\33", 1)                       = 1
 read(3, "O", 1)                         = 1
 read(3, "D", 1)                         = 1
 read(3, "\33", 1)                       = 1
 read(3, "O", 1)                         = 1
 read(3, "A", 1)                         = 1
 read(3, "\33", 1)                       = 1
 read(3, "O", 1)                         = 1
 read(3, "B", 1)                         = 1
 read(3, "\33", 1)                       = 1
 read(3, "O", 1)                         = 1
 read(3, "C", 1)                         = 1
 read(3, ":", 1)                         = 1
 read(3, "q", 1)                         = 1

and less writes:

 write(1, "\33[?1049h\33[24;1H\33[?1h\33=\r", 23) = 23
 write(1, "#\n# hosts         This file desc"..., 738) = 738
 write(1, "\r\33[K \33[K:\10:", 11)      = 11
 write(1, "\33[Kq\10q\r\33[K\33[?1l\33>\33[r\33[?1049l", 28) = 28
 write(4, ".less-history-file:\n.search\n\"dir"..., 925) = 925

or

 \33[?1049h
 \33[24;1H
 \33[?1h
 \33=
 
this is with

 less 643 (POSIX regular expressions)
 Copyright (C) 1984-2023  Mark Nudelman

All for TERM=rxvt-unicode

From build on obs for OpenSUSE Slowroll I see 

 [   11s] checking for tgoto in -ltinfo... yes
 [   11s] checking for tgoto in -ltinfow... no
 [   11s] checking for initscr in -lxcurses... no
 [   11s] checking for initscr in -lncursesw... yes
 [   11s] checking for initscr in -lncurses... yes
 [   11s] checking for initscr in -lcurses... no
 [   11s] checking for tgetent in -ltermcap... no
 [   11s] checking for tgetent in -ltermlib... no

 [..]

 [   12s] checking for termcap.h... yes
 [   12s] checking for ncurses/termcap.h... yes
 [   12s] checking for ncursesw/termcap.h... yes
 [   12s] checking for termio.h... yes
 [   12s] checking for termios.h... yes

The SUSE version of less comes with a lesskey(.bin) since 1996 extended
by me 1999 to be forearmed for both cases of arrow key sequences.

> 
> But vim is different.  strace shows that it is reading application mode.
> 
>       71555 19:48:41 read(0, "\26", 4096)     = 1
>       71555 19:48:42 read(0, "\33OA", 4096)   = 3
>       71555 19:48:46 read(0, "\33", 4096)     = 1
>       71555 19:48:48 read(0, "o", 4096)       = 1
>       71555 19:48:49 read(0, "\26", 4096)     = 1
>       71555 19:48:50 read(0, "\33OD", 4096)   = 3
>       71555 19:48:52 read(0, "\r", 4096)      = 1
>       71555 19:48:53 read(0, "\26", 4096)     = 1
>       71555 19:48:53 read(0, "\33OC", 4096)   = 3
>       71555 19:48:54 read(0, "\33", 4096)     = 1
> 
> strace shows vim initializing the terminal:
> 
>       71555 19:48:35 write(1, 
> "\33[?1049h\33[>4;2m\33[?1h\33=\33[?2004h\33[?1004h", 38) = 38
> 
> or more readable (unmap):
> 
>       \E[?1000h
>       \E[?1049h
>       \E[>4;2m
>       \E[?1h
>       \E=
>       \E[?2004h
>       \E[?1004h
>       \E[1;24r
>       \E[?12h
>       \E[?12l
>       \E[22;2t
>       \E[22;1t
>       \E[27m
>       \E[23m
>       \E[29m
>       \E[m
>       \E[H
>       \E[2J
> 
> but little of that (perhaps none) comes from the terminfo.
> 
> In particular, 
> 
>       \E[?1h
> 
> which (xterm control sequences) shows where the application mode is set
> and reset:
> 
> CSI ? Pm h
>           DEC Private Mode Set (DECSET).
>             Ps = 1  -> Application Cursor Keys (DECCKM), VT100.
> 
> CSI ? Pm l
>           DEC Private Mode Reset (DECRST).
>             Ps = 1  -> Normal Cursor Keys (DECCKM), VT100.
> 
> Of course, rxvt/urxvt have some differences from xterm, but this happens
> to work in vim because these particular VT100-sequences are implemented.
> vim's using its compiled-in list of escape sequences:
> 
>       /*
>        * Builtin xterm with Vim-specific entries.
>        */
>       static tcap_entry_T builtin_xterm[] = {
> 
> in src/term.c, e.g.,
> 
>           {(int)KS_KS,        "\033[?1h\033="},
>           {(int)KS_KE,        "\033[?1l\033>"},
> 


-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]