
Estoy tratando de entender el siguiente problema. Considere el siguiente programa ncurses:
#include <curses.h>
int main() {
initscr(); noecho(); printw("0000000"); getch();
}
La compilación es:
$ gcc -o t t.c -lncurses
Esto es lo que veo usando la configuración predeterminada (la línea ejecutiva es simplemente $ ./t
):
0
Lo cual parece extraño. Puedo verificar esto usando script
. Esto es lo que obtengo:
$ teseq typescript
|Script started on 2020-04-02 08:52:58+02:00 [TERM="xterm-256color" TTY="/de|-
-|v/pts/0" COLUMNS="211" LINES="46"]|.
: Esc ]
& OSC: OPERATING SYSTEM COMMAND
|0;malat@remote: /tmp|
. BEL/^G
: Esc [ 1 ; 32 m
& SGR: SELECT GRAPHIC RENDITION
" Set bold text.
" Set foreground color green.
|malat@remote|
: Esc [ 0 m
& SGR: SELECT GRAPHIC RENDITION
" Clear graphic rendition to defaults.
|:|
: Esc [ 1 ; 34 m
& SGR: SELECT GRAPHIC RENDITION
" Set bold text.
" Set foreground color blue.
|/tmp|
: Esc [ 0 m
& SGR: SELECT GRAPHIC RENDITION
" Clear graphic rendition to defaults.
|$ ./t|
. CR/^M LF/^J
: Esc [ ? 1049 h
& SM: SET MODE (private params)
" (Xterm) Save the cursor position and use the alternate screen buffer,
" clearing it first.
: Esc [ 22 ; 0 ; 0 t
: Esc [ 1 ; 46 r
" (DEC) Set the scrolling region to from line 1 to line 46.
: Esc ( B
& GZD4: G0-DESIGNATE 94-SET
" Designate 94-character set B (US-ASCII) to G0.
: Esc [ m
& SGR: SELECT GRAPHIC RENDITION
" Clear graphic rendition to defaults.
: Esc [ 4 l
& RM: RESET MODE
" INSERTION REPLACEMENT MODE (IRM) -> REPLACE
: Esc [ ? 7 h
& SM: SET MODE (private params)
" (DEC) Text auto-wrap mode.
: Esc [ H
& CUP: CURSOR POSITION
" Move the cursor to line 1, column 1.
: Esc [ 2 J
& ED: ERASE IN PAGE
" Clear the screen.
|0|
: Esc [ 6 b
& REP: REPEAT
: Esc [ 46 ; 1 H
& CUP: CURSOR POSITION
" Move the cursor to line 46, column 1.
: Esc [ ? 1049 l
& RM: RESET MODE (private params)
" (Xterm) Leave the alternate screen buffer and restore the cursor.
: Esc [ 23 ; 0 ; 0 t
. CR/^M
: Esc [ ? 1 l
& RM: RESET MODE (private params)
" (DEC) Cursor key mode off.
: Esc >
& DECKPNM: KEYPAD NORMAL MODE
: Esc ]
& OSC: OPERATING SYSTEM COMMAND
|0;malat@remote: /tmp|
. BEL/^G
: Esc [ 1 ; 32 m
& SGR: SELECT GRAPHIC RENDITION
" Set bold text.
" Set foreground color green.
|malat@remote|
: Esc [ 0 m
& SGR: SELECT GRAPHIC RENDITION
" Clear graphic rendition to defaults.
|:|
: Esc [ 1 ; 34 m
& SGR: SELECT GRAPHIC RENDITION
" Set bold text.
" Set foreground color blue.
|/tmp|
: Esc [ 0 m
& SGR: SELECT GRAPHIC RENDITION
" Clear graphic rendition to defaults.
|$ exit|
. CR/^M LF/^J LF/^J
|Script done on 2020-04-02 08:53:04+02:00 [COMMAND_EXIT_CODE="1"]|.
Sin embargo, cuando lo hago ahora:
$ TERM=xterm-color ./t
Puedo ver el resultado esperado:
0000000
Que me estoy perdiendo aqui ?
Respuesta1
Resulta que este es un problema conocido con la secuencia de escape REP (repetir carácter anterior). Ver también:
Esto se ha solucionado de la manera más difícil en Debian: