pkgsrc-Users archive

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

Re: Proposed change to misc/tmux keep erase char as the user likes it

(sorry if elaborations seem a bit out-of-sequence, because I wrote it

On Sat 09 Nov 2019 at 20:46:29 -0500, Greg Troxel wrote:
> Olaf Seibert <> writes:
> > misc/tmux (and the tmux in base) both force the VERASE character to be
> > DELETE, instead of leaving it alone at the user's preference. It even
> > forcefully changes backspace into DELETE, breaking all my terminal
> > settings.
> >
> > For decades I have set backspace ^H as the erase character, and forced
> > my keyboards to produce the backspace character from the key which is
> > clearly marked backspace.
> This is humorous, as the key labeled backspace by the IBM-PC is clearly
> the key that ought to be labeled DEL, as on a VT52 which I'd expect you
> to be using with your VAX :-)

I think the VAX I used first (with 4.2BSD, later 4.3BSD) may have used
DEL as interrupt character.

> > Tmux seems to think it knows my preferences better than me and forces
> > its own ideas upon me.  My systems are consistent and tmux messes it up.
> > So I have local patches to fix it: it leaves the VERASE setting alone,
> > so it stays the way you like it. It also doesn't translate keys into DEL
> > any more.
> But in all seriousness I completely see your point that tmux should not
> be changing this.  I don't understand why it does, because it's
> operating at the type-ascii layer, and it would seem obvious that the
> ttys on each pty should be configured exactly as the original tty was on
> invocation.
> I guess there is an issue with the way the original tty was configured,
> when it started the tmux session, vs the way some other tty was
> configured, when it attached.  But as I think you mean, each person has
> a choice of two sane approaches:
>   make the key send DEL and configure VERASE to DEL, always
>   make the key send BS and configure VERASE to BS, always

Exactly. The default these days seems to be the former, but in the dim
past when I was forced to choose one, the latter made more sense.

> > If you like DEL as your erase character, there is of course no change
> > from the patch, as you will have set your terminals accordingly already.
> Agreed that having configured DEL needs to continue to work right.  I've
> been using tmux that way for almost 10 years and never noticed this...

It seems that using DEL has become more fashionable at some point,
probably ever since PCs send DEL with the key that is labeled BACKSPACE.
When I standardised on my settings, it was due to a mixed environment
where various ways to access my login(s) were inconsistent with each
other, so I was more or less forced to choose one way and forcefully
stick to it.

> > I want to add these patches to pkgsrc.  I would also like to patch the
> > base system tmux in the same way. Objections?
> I don't object to the content, but in pkgsrc we have a notion that bug
> fixes are supposed to be filed upstream, so that in theory they'd be
> fixed and we would not have to carry the patches indefinitely, and that
> a link to the bug tracker entry should be present in the patchfile.
> I am surprised about tmux behaving this way, as it seems to generally
> have good judgement.  So I wonder what they are thinking and if this is
> really as intentional and unreasonable as it seems.
> I wonder if you are willing to file a bug report, which could be
> referenced in the patches even if it's closed WONTFIX or ignored.

I have done so: see The author
doesn't seem to agree with me so far. He suggested some option in
the end which I'm trying out now ("bind -n BSpace send C-h"). In my
all-backspace environment that seems to work ok. (But I suspect that
when I try to login remotely from a "DEL environment", I will get the
problem that I can't type DEL when I really want to. Currently with
screen, I am in the situation that I have to find the key which actually
produces ^H to erase characters, which often is the cumbersome
control-H. So it exchanges one problem for another.)

> I would like to see comments that explain better; I mostly follow your
> patches but the second one is somewhat hard to understand.  If you mean
>   When initiaizing a tmux session, tmux forces the VERASE character for
>   all ttys created within the session to be DEL.  Change this to
>   preserve the VERASE value of the originating tty, similar to how the
>   values of other special characters are inherited.
> then it might be good to say that.  If I got it wrong, then you at least
> have a clue as to what someone might guess.

That is indeed what I mean.

> > $NetBSD$
> >
> > Don't mess up the erase character.
> >
> > --- window.c.orig	2017-05-29 07:12:06.000000000 +0000
> > +++ window.c
> > @@ -919,7 +919,9 @@ window_pane_spawn(struct window_pane *wp
> >  			fatal("tcgetattr failed");
> >  		if (tio != NULL)
> >  			memcpy(tio2.c_cc, tio->c_cc, sizeof tio2.c_cc);
> > +#if 0
> >  		tio2.c_cc[VERASE] = '\177';
> > +#endif
> >  #ifdef IUTF8
> >  		tio2.c_iflag |= IUTF8;
> >  #endif
> Here, it seems like the code is changing any key that matches the VERASE
> setting to BS, and that seems odd.  I don't understand why this doesn't
> hurt the use of DEL, and I don't understand why it breaks how you do
> things.

Keep in mind that what tmux calls BSPACE here is actually DEL (^?) in
the end.  Later on there is a table in input-keys.c which translates
KEYC_BSPACE into \177. I think it is this table that you can change with
the "bind" command.

Also you can connect to the tmux session multiple times from terminals
with different settings for VERASE. (That's what I use screen for, so
that I can leave my session at home running and still connect to it from

So the intention of the original code below here is to normalise
whatever is the VERASE character on the outside and translate it to DEL
to be used on the inside, which is always the VERASE character there.
The author said that this is to keep the terminal environment
consistent.  They have a point, up to a point. If the "outside" uses ^H
it always gets translated into ^? inside, and there is no way to type ^H
any more if you really need it for whatever reason (help in emacs or

On the other hand, with my patch you can always type both ^H and ^?. But
if I login from a "DEL environment" (where the backspace key produces
DEL and VERASE is set to match) then I type DEL when my programs inside
screen/tmux expect BS and that is confusing too.

I'm starting to think that there is no way to avoid both problems at the
same time.

> > $NetBSD$
> >
> > Don't mess up the erase character.
> >
> > --- tty-keys.c.orig	2017-05-16 13:10:11.000000000 +0000
> > +++ tty-keys.c
> > @@ -541,7 +541,9 @@ tty_keys_next(struct tty *tty)
> >  	struct timeval	 tv;
> >  	const char	*buf;
> >  	size_t		 len, size;
> > +#if 0
> >  	cc_t		 bspace;
> > +#endif
> >  	int		 delay, expired = 0, n;
> >  	key_code	 key;
> >  
> > @@ -654,6 +656,7 @@ partial_key:
> >  complete_key:
> >  	log_debug("%s: complete key %.*s %#llx", c->name, (int)size, buf, key);
> >  
> > +#if 0
> >  	/*
> >  	 * Check for backspace key using termios VERASE - the terminfo
> >  	 * kbs entry is extremely unreliable, so cannot be safely
> > @@ -662,6 +665,7 @@ complete_key:
> >  	bspace = tty->tio.c_cc[VERASE];
> >  	if (bspace != _POSIX_VDISABLE && (key & KEYC_MASK_KEY) == bspace)
> >  		key = (key & KEYC_MASK_MOD) | KEYC_BSPACE;
> > +#endif
> >  
> >  	/* Remove data from buffer. */
> >  	evbuffer_drain(tty->in, size);
> >
> > -Olaf.
Olaf 'Rhialto' Seibert -- rhialto at falu dot nl
___  Anyone who is capable of getting themselves made President should on
\X/  no account be allowed to do the job.       --Douglas Adams, "THGTTG"

Attachment: signature.asc
Description: PGP signature

Home | Main Index | Thread Index | Old Index