nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] when the terminfo info does not match the terminal


From: Benno Schulenberg
Subject: Re: [Nano-devel] when the terminfo info does not match the terminal
Date: Sun, 23 Dec 2018 19:37:46 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

Op 20-12-18 om 22:20 schreef David Ramsey:
> Benno Schulenberg:
>> There are quite a few terminals where kdch1=^?, but when so, then
>> always kbs=^H.
> 
> Right, because ^? being Delete is also an ASCII standard.

But did the ASCII standard specify exactly what "delete" means?  It
seems not: "The original ASCII standard used only short descriptive
phrases for each control character. The ambiguity this caused was
sometimes [...] accidental, for example with the meaning of "delete".
(https://en.wikipedia.org/wiki/ASCII)

Anyway...  When the terminal description matches the terminal, there
never is any problem: ncurses will correctly translate whatever the
<Delete> key produces to KEY_DC, and what the <Backspace> key produces
to KEY_BACKSPACE.  But there are two possible mismatches:

a) The <Delete> key produces ^? but the terminfo entry says that
kbs=^?.  So ncurses will translate ^? to KEY_BACKSPACE and nano
will do a backspace when the user presses <Delete>.  To correct
this, the user will have to pass both -K (so ^? will pass through
ncurses untranslated) and -d (so ^? will do a delete instead of the
default backspace).

b)  The <Backspace> key produces ^? but the terminfo entry says that
kdch1=^?.  So ncurses will translate ^? to KEY_DC and nano will do
a delete when the user presses <Backspace>.  To correct this, the
user will have to pass -K (so ^? will pass untranslated through
ncurses and will result in its default backspace action).

So... when wanting to compensate for a mismatching terminfo entry,
the user has to pass either -K plus -d, or just -K.  But see below.

Ad a)  When <Delete> produces ^?, then <Backspace> will produce ^H.
Nano does a backspace for ^H by default, so for the <Backspace> key
itself there is no problem when the <Delete> key behaves like a
backspace too.

Ad b)  When <Backspace> produces ^?, then <Delete> will produce some
escape sequence.  Most likely the mistaken terminfo entry does not
assign any meaning to this sequence, so it will pass untranslated
through ncurses, and nano will recognize the sequence and do a delete.
So for the <Delete> key itself there is no problem when the <Backspace>
key behaves like delete too.

>> when the info is wrong, and the <Delete> key does a backspace,
>> never --rebinddelete by itself will correct the problem.

Maybe we should change that.  Proposed patch is coming up.  With that
patch applied, whenever the terminfo entry mismatches the terminal,
the user only needs to use -d to get it corrected, in either direction.
(That is: when the only mismatch is the Del/Bsp assignment.)

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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