[sf-lug] box-drawing character mode switch.

Michael Paoli Michael.Paoli at cal.berkeley.edu
Tue Oct 3 02:12:08 PDT 2017

Hmmmm, ... context?

I mean, e.g., if you're looking to produce this to put in some
static output (e.g. email) consumed by a bunch of different
displays, that's one thing, ... but ... if you're looking to have
it display in an application, that's quite another.

In the latter case, one generally should use the ncurses library
routines.  That way, one will generally get reasonable display/output
regardless of the terminal type or emulation used ... at least to
the extent the terminal can handle such.  E.g. it's how many
programs, such as vi, emacs, top, etc. deal reasonably with
proper output (including, e.g. cursor positioning, redrawing of
screen, highlighting, etc.) on any of the many hundreds or
thousands or more terminal types Linux (and Unix, etc.) supports.
I bet otherwise your terminal line drawing characters won't
work or display reasonably on my Cromemco 3102 terminal
or my Qume QVT-101 terminals.  But with use of ncurses, they'd
probably still display at least reasonably.  :-)

It's best not to make improper assumptions about the display
device.  E.g. I remember some ancient BBS software that would send
some relatively arbitrary escape/control sequences to try to "test"
the terminal type ("Do you see a blue square?") or some nonsense
like that.  And ... some such sequences would crash my
Cromemco 3102 terminal (it's a very "smart" programmable
terminal ... includes capabilities such as interpret the
following as hex data to load into RAM and execute it ... and, yeah,
given some dodo-headed program making bad assumptions about terminal
and sending such ... bad things would happen (the terminal would crash
and I'd have to reset or power cycle it)).
So ... best not to crash people's terminals.  Also not friendly
to scramble their screens or set 'em into modes they may not know
how to recover from (not all users necessarily know how to do
useful things like:
^Q^Q^Jstty sane^Jtput reset
along with any other incantations that may be needed to get
their terminal/emulation back into a sane state if
some output has quite messed up the state/display
(such as having done cat on a binary file ... "oops")).

So, yes, ... Linux(/Unix/...) supports many hundreds, if not
thousands of terminal types/emulations ... really an arbitrary
number, as one can always write the relevant terminal descriptions
(terminfo, etc.) to handle whatever arbitrary terminal or emulation
one comes up with or creates.

> From: "Ken Shaffer" <kenshaffer80 at gmail.com>
> Subject: [sf-lug] box-drawing character mode switch.
> Date: Mon, 2 Oct 2017 16:57:37 -0700

> At the Sun. meeting Aaron and I were discussing the line-drawing
> characters, and I had trouble making the sequence work -- of course,
> at home, it works perfectly;^O
>   The escape sequence in s gnome terminal or xterm to switch to the
> box characters is:
> echo -e "\x1b(0"
> and to turn back, the sequence
> echo -e "\x1b(B"
> or use the terminal tab/reset in the gnome terminal
> Ken

More information about the sf-lug mailing list