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

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 18:37:45 +1000
Lines 31
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>
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 <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.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 <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 <8537qoy49y.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> <85bn5cy6bz.fsf@benfinney.id.au>
Xref csiph.com comp.lang.python:106983

Show key headers only | 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