mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-06 01:10:57 +01:00
shells use PromptFormatter
This commit is contained in:
parent
c712fefebc
commit
7d9a47a0fe
2 changed files with 7 additions and 8 deletions
|
@ -13,7 +13,6 @@ from pygments.token import Token
|
|||
|
||||
from xonsh.base_shell import BaseShell
|
||||
from xonsh.tools import print_exception
|
||||
from xonsh.prompt.base import partial_format_prompt
|
||||
from xonsh.pyghooks import (XonshLexer, partial_color_tokenize,
|
||||
xonsh_style_proxy)
|
||||
from xonsh.ptk.completer import PromptToolkitCompleter
|
||||
|
@ -138,7 +137,7 @@ class PromptToolkitShell(BaseShell):
|
|||
"""Returns a list of (token, str) tuples for the current prompt."""
|
||||
p = builtins.__xonsh_env__.get('PROMPT')
|
||||
try:
|
||||
p = partial_format_prompt(p)
|
||||
p = self.prompt_formatter.format_prompt(p)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
print_exception()
|
||||
toks = partial_color_tokenize(p)
|
||||
|
@ -150,13 +149,13 @@ class PromptToolkitShell(BaseShell):
|
|||
prompt.
|
||||
"""
|
||||
p = builtins.__xonsh_env__.get('RIGHT_PROMPT')
|
||||
# partial_format_prompt does handle empty strings properly,
|
||||
# self.prompt_formatter.format_prompt does handle empty strings properly,
|
||||
# but this avoids descending into it in the common case of
|
||||
# $RIGHT_PROMPT == ''.
|
||||
if isinstance(p, str) and len(p) == 0:
|
||||
return []
|
||||
try:
|
||||
p = partial_format_prompt(p)
|
||||
p = self.prompt_formatter.format_prompt(p)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
print_exception()
|
||||
toks = partial_color_tokenize(p)
|
||||
|
@ -167,13 +166,13 @@ class PromptToolkitShell(BaseShell):
|
|||
toolbar.
|
||||
"""
|
||||
p = builtins.__xonsh_env__.get('BOTTOM_TOOLBAR')
|
||||
# partial_format_prompt does handle empty strings properly,
|
||||
# self.prompt_formatter.format_prompt does handle empty strings properly,
|
||||
# but this avoids descending into it in the common case of
|
||||
# $TOOLBAR == ''.
|
||||
if isinstance(p, str) and len(p) == 0:
|
||||
return []
|
||||
try:
|
||||
p = partial_format_prompt(p)
|
||||
p = self.prompt_formatter.format_prompt(p)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
print_exception()
|
||||
toks = partial_color_tokenize(p)
|
||||
|
|
|
@ -24,7 +24,7 @@ from xonsh.lazyjson import LazyJSON
|
|||
from xonsh.lazyasd import LazyObject
|
||||
from xonsh.base_shell import BaseShell
|
||||
from xonsh.ansi_colors import ansi_partial_color_format, ansi_color_style_names, ansi_color_style
|
||||
from xonsh.prompt.base import partial_format_prompt, multiline_prompt
|
||||
from xonsh.prompt.base import multiline_prompt
|
||||
from xonsh.tools import print_exception
|
||||
from xonsh.platform import ON_WINDOWS, ON_CYGWIN, ON_DARWIN
|
||||
from xonsh.lazyimps import pygments, pyghooks
|
||||
|
@ -420,7 +420,7 @@ class ReadlineShell(BaseShell, cmd.Cmd):
|
|||
env = builtins.__xonsh_env__ # pylint: disable=no-member
|
||||
p = env.get('PROMPT')
|
||||
try:
|
||||
p = partial_format_prompt(p)
|
||||
p = self.prompt_formatter.format_prompt(p)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
print_exception()
|
||||
hide = True if self._force_hide is None else self._force_hide
|
||||
|
|
Loading…
Add table
Reference in a new issue