我有这个荧光灯
from rich.console import Console
import rich.prompt
from rich.highlighter import RegexHighlighter
from rich.theme import Theme
class Highlighter(RegexHighlighter):
base_style = "help."
highlights = [r"(?P<cmd>!help\b)", r"(?P<cmd2>\'|\"[\w]+\"|\')"]
theme = Theme({"help.cmd": "bold magenta", "help.cmd2": "bold green"})
console = Console(highlighter=Highlighter(), theme=theme)
如果我执行类似console.print()
的操作,它会提供自定义高亮显示,但不会为rich.prompt.Prompt.ask()
提供自定义高亮显示
prompt = rich.prompt.Prompt(console=console)
text = prompt.ask("\'Enter text\'\n")
console.print(text)
我怎样才能得到rich.prompt.Prompt.ask()
的荧光灯
您是否希望输入的文本在键入时高亮显示
里奇没有那种能力。您可能想查看一下提示工具包
相关问题 更多 >
编程相关推荐