Convert input to upper case on screen as it is typed

Ben Finney ben+python at benfinney.id.au
Thu Apr 14 04:37:45 EDT 2016


Ben Finney <ben+python at benfinney.id.au> writes:

> Okay, ‘termios.tcgetattr’ will let me preserve the attributes, and
> with Dan Sommers's suggestion of which attribute to use, I may have a
> shot at setting the terminal attributes.

This works!

I can get the current attributes, and preserve them; then, later, force
uppercase of all terminal output regardless what the user types; then,
later, request the flag be restored to its prior setting.

This only addresses how the terminal shows its output. The input is
still received by Python as it was typed. However, converting text
behind the scenes to uppercase is a simple problem.

I had been hoping that I could simply wrap some stream in a simple
“convert what they actually type so it's upper case” text codec, without
fiddling at such a low operating-system specific level. This is rather
more esoteric than I had hoped.

But it is a working solution, and easy enough to hide in a library.

Thanks again.

-- 
 \         “I have the simplest tastes. I am always satisfied with the |
  `\    best.” —Oscar Wilde, quoted in _Chicago Brothers of the Book_, |
_o__)                                                             1917 |
Ben Finney




More information about the Python-list mailing list