Daily Archives: 2013-03-22

Fixing Shifted-Arrow Keys in 256-Color Terminals on Linux

The terminfo entry for “xterm-256color” that ships by default as part of ncurses-base on Debian Linux and its derivatives is a bit annoying. In particular, shifted up-arrow key presses work fine in some programs, but fail in others. It’s a bit of a gamble if Shift-Up works in joe, pico, vim, emacs, mutt, slrn, or what have you.

THis afternoon I got bored enough of losing my selected region in Emacs, because I forgot that I was typing in a terminal launched by a Linux desktop. SO I thought “what the heck… let’s give the FreeBSD termcap entry for xterm-256color a try”:

keramida> scp bsd:/etc/termcap /tmp/termcap-bsd
keramida> captoinfo -e $(                                  \
  echo $( grep '^xterm' termcap | sed -e 's/[:|].*//' ) |  \
  sed -e 's/ /,/g'                                         \
  ) /tmp/termcap  > /tmp/terminfo.src
keramida> tic /tmp/terminfo.src

Restarted my terminal, and quite unsurprisingly, the problem of Shift-Up keys was gone.

The broken xterm-256color terminfo entry from /lib/terminfo/x/xterm-256color is now shadowed by ~/.terminfo/x/xterm-256color, and I can happily keep typing without having to worry about losing mental state because of this annoying little misfeature of Linux terminfo entries.

The official terminfo database sources[1], also work fine. So now I think some extra digging is required to see what ncurses-base ships with. There’s definitely something broken in the terminfo entry of ncurses-base, but it will be nice to know which terminal capabilities the Linux package botched.

Notes:
[1] http://invisible-island.net/ncurses/ncurses.faq.html#which_terminfo

Avoid Double Negatives Like the Plague

Double negatives are very confusing. They probably classify as one of the most confusing things in written or spoken communication, if not as the one, most confusing thing ever.

A particularly striking example of a double negative that I’ve seen in the wild is:

gutter (true/false) — If false, the line numbering on the left side will be hidden. Defaults to true.”

WordPress Documentation
Source Code Posting Instructions

Now read quickly through the help of the “gutter” option, and then try to answer the following questions:

  • Can you understand immediately if setting gutter=true hides or shows the line numbering bits?
  • Is it entirely obvious why the default is true, with just a quick glance at this sentence?

The reason why the original sentences are confusing is that there’s a hidden double negative right in the middle of the first sentence. The combination of “false” and “hidden” works against the intention of the documenter, muddling the waters and effectively hiding the real information behind a barrier of miscommunication. The reader must first scale the obstacle of noticing the false-hidden combination; then read the following sentence; realize that this works as a negation of something that is true by default; combine all bits together to form an actual understanding of what the gutter option is all about.

The larger the context we have to keep in our head, the more difficult it is to understand the actual meaning. More importantly, this is true for both written and spoken communication. The double negative in the first of these sentences renders the first sentence difficult to parse and leaves the reader hanging for more context, provided much later then necessary, by the second sentence of the group.

Rewriting the first sentence, to remove the double negative, vastly improves our ability to grasp its meaning with one glance:

gutter (true/false) — Show line numbers on the left side. Defaults to true.”

As a bonus point the first sentence is now smaller too. Removing the noisy and confusing double negative — which, amusingly enough, had the gall to mask as an attempt to “clarify” things — resulted in a more compact, but also cleaner, easier to read sentence; one with arguably higher informational content!