Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Although the moon is smaller than the earth, it is farther away.


devel / comp.lang.python / Re: How to Add ANSI Color to User Response

SubjectAuthor
o Re: How to Add ANSI Color to User ResponseDavid

1
Re: How to Add ANSI Color to User Response

<mailman.92.1712802339.3468.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=29838&group=comp.lang.python#29838

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: bouncingcats@gmail.com (David)
Newsgroups: comp.lang.python
Subject: Re: How to Add ANSI Color to User Response
Date: Thu, 11 Apr 2024 02:24:59 +0000
Lines: 32
Message-ID: <mailman.92.1712802339.3468.python-list@python.org>
References: <E07728FE-3599-462D-B572-107C5D53C72F@yahoo.com>
<CAMPXz=okfOSOxkwUoT=vUESq8hBAFNCUsoigdX4HiRdtC4aZPw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de cHAOWg1SjoDFWkpj9fWEtgrpCh7186tYTHdNguCvoFvA==
Cancel-Lock: sha1:UP3OZX0hrIzvWXgifZ4I1HSgcRw= sha256:EXfYHoxob77eZ52z2LA1yvnmHsRHWfvnjm/EBIoEBhs=
Return-Path: <bouncingcats@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=lgv40b6H;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.010
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Add': 0.04;
'settings.': 0.05; 'ansi': 0.09; 'prints': 0.09; 'terminal': 0.09;
'url:post': 0.09; "'\\n": 0.16; '2024': 0.16; 'enabling': 0.16;
'it."': 0.16; 'jython': 0.16; 'sentence,': 0.16; 'subject:User':
0.16; 'wrote:': 0.16; 'python': 0.16; 'instead': 0.17; 'to:addr
:python-list': 0.20; 'input': 0.21; 'code': 0.23; 'subject:How':
0.23; 'url:wiki': 0.23; 'else': 0.27; 'approach': 0.31; 'python-
list': 0.32; 'to:name:python': 0.32; 'message-id:@mail.gmail.com':
0.32; 'there': 0.33; 'particular': 0.33; 'someone': 0.34; 'header
:In-Reply-To:1': 0.34; 'received:google.com': 0.34; 'question.':
0.35; 'following': 0.35; 'from:addr:gmail.com': 0.35; 'system,':
0.36; 'special': 0.37; 'way': 0.38; 'use': 0.39; 'decide': 0.39;
'wed,': 0.39; '(see': 0.40; 'color': 0.62; 'your': 0.64;
'conditions': 0.70; 'url:wikipedia': 0.70; 'skip:f 20': 0.75;
'choice': 0.76; 'url-ip:199/8': 0.84; 'subject:Color': 0.84;
'subject:Response': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1712802336; x=1713407136; darn=python.org;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=m14YkrNn0E3aisyyaxRzm1RW13R6rkI2ua9y7GXfGcs=;
b=lgv40b6H6/10iz8n/DUsAJGgGnK1vmk7wqFU6FSYG/py48ukGyf6hAjOsDP0ypbupM
AYQb1GF4KJBU8jQyVxDtppw9DcpEPIytBurkoOwW0I+nCHM3LpR8VX7gi+nKSTyXJz2I
nCouaER58LeVTogbRzN1Kl7NIqkpbTndCZJcvO77QKPtJsDolxUPKOJS5ka/yGZDKX7h
BhtqFWM1VALTtfW/XdjY2niDVLEcN7mWFfLBrlY97qvVgXjtXE84MhOe0Q1zOdb4YJdt
nVq3yHRqbX98mzGBabMozBWYhcRI2LEvkbITvB8F2VvE8NY0LqPcW5gXFJKwCEW87lH2
i/hg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1712802336; x=1713407136;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=m14YkrNn0E3aisyyaxRzm1RW13R6rkI2ua9y7GXfGcs=;
b=r0QMLVJRog2gtDp/TtgpbOS9Mr4R1m/2J4FfUWEOQOXL7EXUYDcbq3xG751gcNnTrP
wzRObrmMTmT0wIBCIqWa1+EeCq6oyNdnoAf29OKokgmnKcmXoZo417v+uwLy+n3Vwxr3
j0VryxvE2LLufZ2x/uZZscT44zZKwhSFKzRc1wkuz35bH/JilfHp44ZQkHmwWZek88Ut
aRDKRpS3AfijQ/yWk59X8UYVXnFdMOD+Y8WEKIEODTBfomz9nhlU7qT6XFhaEVMf+gp3
UQwe/6EbCvb68nIYr+TDG1u+r8FOqW2Y6RcfpnllVGQBGm9CmCd5Iv9bBdqE79QuGJU+
uRqQ==
X-Gm-Message-State: AOJu0Yxs1z6jslvzd1ai+NxfUrZNSbXUTYpiqplvtOwUqIwytmmFMIgH
5JD0JJwxOPEuVKgN+VgR6dIvvuZ22l/IH1dEyvn1qTsm6k+Ai3ifiz2KM5oYR/DZ0HxLAmCbuJf
GSUng9TtIQQWjZSWR6YfuQPMyAeeaD4f1
X-Google-Smtp-Source: AGHT+IGPJ7S50Tg5f1FD9yARvhSK7TdDIf8NfbFdf5yNc2BCKV3f0w+FAhh0riqKXxU1B+9W6jT20fJsjlhlSz68vrE=
X-Received: by 2002:a05:6902:c06:b0:de0:ea71:9ec9 with SMTP id
fs6-20020a0569020c0600b00de0ea719ec9mr5317425ybb.1.1712802336051; Wed, 10 Apr
2024 19:25:36 -0700 (PDT)
In-Reply-To: <E07728FE-3599-462D-B572-107C5D53C72F@yahoo.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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: <CAMPXz=okfOSOxkwUoT=vUESq8hBAFNCUsoigdX4HiRdtC4aZPw@mail.gmail.com>
X-Mailman-Original-References: <E07728FE-3599-462D-B572-107C5D53C72F@yahoo.com>
 by: David - Thu, 11 Apr 2024 02:24 UTC

On Wed, 10 Apr 2024 at 18:51, WordWeaver Evangelist via Python-list
<python-list@python.org> wrote:

> I have a simple question. I use the following textPrompt in some of my
> Jython modules:

> '\n [1;33mYour choice is? (A B C D E): ', maxChars=1, autoAccept=False, forceUppercase=True)

> Is there a way to add an ANSI color code to the end where the conditions
> are, so that the color of the user’s input is of a color of my choosing,
> instead of just white?

Hi Bill,

Here's a tutorial:
https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html
Note the sentence: "once you print out the special code enabling a color,
the color persists forever until someone else prints out the code for
a different color, or prints out the Reset code to disable it."

Here's a more detailed specification:
https://en.wikipedia.org/wiki/ANSI_escape_code

And here's a conversation:
http://mywiki.wooledge.org/BashFAQ/037
(see the first sentence, and then under the heading "Discussion")
that might help you decide whether this approach will satisy your need in
your particular circumstances of operating system, Python version, and
terminal settings.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor