Re: Tools to help with text mode (i.e. non-GUI) input

Liste des GroupesRevenir à cl python 
Sujet : Re: Tools to help with text mode (i.e. non-GUI) input
De : grant.b.edwards (at) *nospam* gmail.com (Grant Edwards)
Groupes : comp.lang.python
Date : 17. Jan 2025, 22:09:14
Autres entêtes
Message-ID : <mailman.84.1737148154.2912.python-list@python.org>
References : 1 2 3 4 5 6
User-Agent : slrn/1.0.3 (Linux)
On 2025-01-17, Alan Gauld via Python-list <python-list@python.org> wrote:
On 15/01/2025 00:41, Keith Thompson via Python-list wrote:
Alan Gauld <learn2program@gmail.com> writes:
On 11/01/2025 14:28, Chris Green via Python-list wrote:
I'm looking for Python packages that can help with text mode input,
>
The standard package for this is curses which comes as part
of the standard library on *nix distros.
 
The thing about curses (which may or may not be a problem) is that, by
design, it takes over the whole screen.  If you want to do simpler text
manipulations (showing a dismissible message, showing bold text, etc.)
without interfering with existing text, curses can't do it, at least not
easily.
>
It's not that difficult to use the terminfo codes directly.

It's easy to do, but it's tricky to do it right.

https://github.com/GrantEdwards/Python-curses-and-terminfo

[...]
>
Here is "hello world" in bold...
>
import curses
curses.setupterm()
bold = curses.tigetstr('bold').decode('ascii')
normal = curses.tigetstr('sgr0').decode('ascii')
>
print(bold, 'Hello world', normal)

Don't forget to use tparm() to parameterize strings for things like
"move curser".

Once you've parameterized the string (if needed), you've _might_ need
to worry about the stuff in the string that's meant to be interpreted
by tputs/putp:

Quoting man tparm(3)

   All terminfo strings [including the output of tparm] should be
   printed with tputs or putp.

That's becuase terminfo strings can contain escape sequences that are
filterd out and interpreted by tputs/putp. The approach above only
works if you only care about certain terminals, and you know that none
of the terminfo strings you're using have those interal terminfo
escape sequences in them [AFAIK, that's true for the linux console,
xterm and the like, but not for many serial terminals.]

--
Grant



Date Sujet#  Auteur
13 Jan 25 * Re: Tools to help with text mode (i.e. non-GUI) input6Alan Gauld
15 Jan 25 `* Re: Tools to help with text mode (i.e. non-GUI) input5Keith Thompson
17 Jan 25  +* Re: Tools to help with text mode (i.e. non-GUI) input3Alan Gauld
17 Jan 25  i`* Re: Tools to help with text mode (i.e. non-GUI) input2Keith Thompson
17 Jan 25  i `- Re: Tools to help with text mode (i.e. non-GUI) input1Mats Wichmann
17 Jan 25  `- Re: Tools to help with text mode (i.e. non-GUI) input1Grant Edwards

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal