mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-07-02 07:45:46 +00:00
[+] ANSI
This commit is contained in:
parent
613dfb741a
commit
cbb3fc8b29
@ -11,7 +11,7 @@ import inspect
|
|||||||
import logging
|
import logging
|
||||||
from typing import AnyStr
|
from typing import AnyStr
|
||||||
|
|
||||||
from prompt_toolkit import PromptSession, print_formatted_text, HTML
|
from prompt_toolkit import PromptSession, print_formatted_text, HTML, ANSI
|
||||||
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
||||||
from prompt_toolkit.completion import Completer, WordCompleter
|
from prompt_toolkit.completion import Completer, WordCompleter
|
||||||
from prompt_toolkit.document import Document
|
from prompt_toolkit.document import Document
|
||||||
@ -232,13 +232,17 @@ class Console:
|
|||||||
return self.__alias.copy()
|
return self.__alias.copy()
|
||||||
|
|
||||||
def _write(self, text):
|
def _write(self, text):
|
||||||
|
# https://python-prompt-toolkit.readthedocs.io/en/master/pages/printing_text.html#formatted-text
|
||||||
if self.__legacy_mode:
|
if self.__legacy_mode:
|
||||||
print(text)
|
print(text)
|
||||||
return
|
return
|
||||||
|
assert isinstance(text, str)
|
||||||
_type = text.split(":")[0]
|
_type = text.split(":")[0]
|
||||||
match _type:
|
match _type:
|
||||||
case "html":
|
case "html":
|
||||||
print_formatted_text(HTML(text[5:]))
|
print_formatted_text(HTML(text[5:]))
|
||||||
|
case "ansi":
|
||||||
|
print_formatted_text(ANSI(text[5:]))
|
||||||
case _:
|
case _:
|
||||||
print_formatted_text(text)
|
print_formatted_text(text)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user