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


Groups > comp.lang.python > #106979

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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
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 Thu, 14 Apr 2016 17:53:20 +1000
Lines 33
Message-ID <mailman.96.1460620413.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>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de DC647XaUruXNweUYZ7fmTQ8CDRwRHpr9QPpbkFa59M/Q==
Cancel-Lock sha1:SZNnyluYK6B9F4YiodBjSI0G9KA=
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'handler': 0.04; 'attributes': 0.07; 'lines.': 0.07; 'reason,': 0.07; 'exits': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'exception': 0.13; 'appropriate': 0.14; '8bit%:26': 0.16; 'attributes,': 0.16; 'attributes.': 0.16; 'gregory': 0.16; 'investigate': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:Convert': 0.16; 'subject:case': 0.16; 'subject:screen': 0.16; 'tty': 0.16; 'using,': 0.16; 'string': 0.17; 'attribute': 0.18; 'driver': 0.18; 'shell': 0.18; 'input': 0.18; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'linux': 0.26; 'dan': 0.29; 'mode.': 0.29; 'preserve': 0.29; 'up.': 0.32; 'run': 0.33; '8bit%:25': 0.33; "i'll": 0.33; 'that,': 0.34; 'saved': 0.35; 'something': 0.35; 'but': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'setting': 0.37; 'received:org': 0.37; 'suggestion': 0.37; 'thank': 0.38; 'sure': 0.39; 'does': 0.39; 'along': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; "you'll": 0.61; 'back': 0.62; "they're": 0.66; '_o__)': 0.84; 'messed': 0.84; 'received:125': 0.84; '\xe2\x80\x9csome': 0.84; 'careful': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-pubkey.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <85bn5cy6bz.fsf@benfinney.id.au>
X-Mailman-Original-References <85oa9cyiqt.fsf@benfinney.id.au> <mailman.90.1460604334.15650.python-list@python.org> <nen5jj$hvi$1@dont-email.me>
Xref csiph.com comp.lang.python:106979

Show key headers only | View raw


Dan Sommers <dan@tombstonezero.net> writes:

> I don't know which OS you're using, but if I run "stty olcuc" in my
> Linux shell, then the input driver does that for me.


Gregory Ewing <greg.ewing@canterbury.ac.nz> writes:

> You might be able to do something with the termios module
> to put the tty driver into the appropriate mode.
>
> If you do that, you'll have to be careful to set it back
> again before the program exits for any reason, otherwise
> your shell session will be messed up.


Thank you both.

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.

Then with a top-level exception handler I can clean up by restoring the
saved attributes with ‘termios.tcsetattr’.

I will investigate along those lines.

-- 
 \       “Some people have a problem, and they think “I know, I'll use |
  `\     Perl!”. Now they have some number of problems but they're not |
_o__)     sure whether it's a string or an integer.” —Benno Rice, 2011 |
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