curses and processing terminal escape characters

Tim Harig usernet at ilthio.net
Sat Oct 30 17:57:25 CEST 2010


On 2010-10-30, Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> wrote:
> In message <iaf0l9$3h0$1 at speranza.aioe.org>, Tim Harig wrote:
>
>> Python could easily process the escape codes for any given terminal; but,
>> in general, you would want something that works for more then a single
>> terminal type.
>
> Does anyone still bother with anything other than VT1xx-type terminals?

1. Actually, most modern terminals and emulators have color which means
	that they must by in the VT2xx range or above.

2. Yes there are still hardware terminals being used and not all of them
	are VTxxxs.

3. Even assuming that the OP is only conserned about VTxxx terminals, it is
	still a better coding practice to use a layer of abstraction so as
	to keep the "magic numbers" out of his code.

4. Just because VTxxx style terminals and emulators currently dominate
	doesn't mean that they will do so forever.  It is quite possible
	that in an age where most terminals are emulated, that somebody
	will create a new style of terminal that fits in better to the
	virtual/graphical world in which they inhabit.

5. Although it is offtopic for this question, using the curses abstraction
	rather then hardcoded values, allows a visual text based program to
	work in places that do not act like a traditional terminal.
	Microsoft Windows console fits this description because formating
	commands are not sent in-band with the text data.  By using
	something like PDCurses, it is possible to run curses programs on
	non-terminal environments such as these.



More information about the Python-list mailing list