6.7. Line Draw Characters without VGA Fonts

X terminals can be switched into line draw mode on the fly with the appropriate escape sequence. You'll need to switch back after you've output the characters you wanted or any text following it will be garbled. Prompts based on these codes don't work on the console, instead printing just the letter code. Both on the console and in an X terminal, these codes don't play well with a VGA font, again just printing the letter.

These codes are ANSI escape sequences. tput probably has this capability, but I'm not familiar with it.

As you'll see in a later section, some fonts include line draw characters without the need for this trick: but installing those fonts and/or relying on their presence is another layer of complexity: this method of getting at line draw characters seems more reliable to me than counting on having specialty fonts installed. If you use VGA fonts and use prompts including these characters, they will NOT display properly.

To start a sequence of line draw characters, use an echo -e and the \033(0 escape sequence. Most of the characters worth using are in the range lower case "a" through "z". Terminate the string with another escape sequence, \033(B . As with any other non-printing escape sequence in the prompt, these must be surrounded by \[ and \] or input you enter after the prompt will be mangled on the command line.

The best method I've found for testing this is shown in the image below: use the escgen script mentioned earlier in the HOWTO to show the 100 to 200 octal range, echo the first escape sequence, run the escgen script for the same range, and echo the closing escape sequence. The image also shows how to use this in a prompt.

Using escape sequences in xterm (also works in RXVT derivatives) to produce line draw characters. The "escgen" script used above is given earlier in the HOWTO.