Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: Convert input to upper case on screen as it is typed Date: Thu, 14 Apr 2016 18:37:45 +1000 Lines: 31 Message-ID: References: <85oa9cyiqt.fsf@benfinney.id.au> <85bn5cy6bz.fsf@benfinney.id.au> <8537qoy49y.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 NPH59Ghr+tgkTZW9TknOxgo4ng+mat4avyVYPNjn3l+w== Cancel-Lock: sha1:y/3eI7a2fjgDW8jnFKyVRTwOWRI= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'restored': 0.09; 'python': 0.10; 'output': 0.13; '8bit%:26': 0.16; 'attributes,': 0.16; 'attributes.': 0.16; 'brothers': 0.16; 'quoted': 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; 'uppercase': 0.16; 'attribute': 0.18; 'input': 0.18; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'converting': 0.27; 'dan': 0.29; 'preserve': 0.29; 'solution,': 0.29; 'regardless': 0.31; 'addresses': 0.32; 'stream': 0.33; 'wrap': 0.33; 'behind': 0.35; 'could': 0.35; 'text': 0.35; 'library.': 0.35; 'problem.': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'setting': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'suggestion': 0.37; 'enough': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'some': 0.40; 'easy': 0.60; 'more': 0.63; 'upper': 0.76; 'hoping': 0.77; 'low': 0.83; 'satisfied': 0.83; '_o__)': 0.84; 'received:125': 0.84; 'tastes.': 0.84; 'scenes': 0.91; 'works!': 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <8537qoy49y.fsf@benfinney.id.au> X-Mailman-Original-References: <85oa9cyiqt.fsf@benfinney.id.au> <85bn5cy6bz.fsf@benfinney.id.au> Xref: csiph.com comp.lang.python:106983 Ben Finney 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