Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106983

Re: Convert input to upper case on screen as it is typed

From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: Convert input to upper case on screen as it is typed
Date 2016-04-14 18:37 +1000
Message-ID <mailman.97.1460623092.15650.python-list@python.org> (permalink)
References <85oa9cyiqt.fsf@benfinney.id.au> <mailman.90.1460604334.15650.python-list@python.org> <nen5jj$hvi$1@dont-email.me> <85bn5cy6bz.fsf@benfinney.id.au> <8537qoy49y.fsf@benfinney.id.au>

Show all headers | View raw


Ben Finney <ben+python@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-14 13:25 +1000
  Re: Convert input to upper case on screen as it is typed Dan Sommers <dan@tombstonezero.net> - 2016-04-14 04:16 +0000
    Re: Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-14 15:17 +1000
      Re: Convert input to upper case on screen as it is typed Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-14 18:35 +1200
    Re: Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-14 17:53 +1000
      Re: Convert input to upper case on screen as it is typed Steven D'Aprano <steve@pearwood.info> - 2016-04-14 21:43 +1000
    Re: Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-14 18:37 +1000
      Re: Convert input to upper case on screen as it is typed Marko Rauhamaa <marko@pacujo.net> - 2016-04-14 12:22 +0300
    Re: Convert input to upper case on screen as it is typed Chris Angelico <rosuav@gmail.com> - 2016-04-14 18:45 +1000
    Re: Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-19 05:11 +1000
      Re: Convert input to upper case on screen as it is typed Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-19 17:46 +1200

csiph-web