mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
more lazy teepty
This commit is contained in:
parent
cf544148af
commit
2e7bb6ba77
2 changed files with 15 additions and 10 deletions
|
@ -3,7 +3,7 @@
|
|||
import os
|
||||
import random
|
||||
import builtins
|
||||
from warnings import warn
|
||||
import warnings
|
||||
|
||||
from xonsh.xontribs import update_context
|
||||
from xonsh.environ import xonshrc_context
|
||||
|
@ -54,11 +54,13 @@ class Shell(object):
|
|||
shell_type = random.choice(('readline', 'prompt_toolkit'))
|
||||
if shell_type == 'prompt_toolkit':
|
||||
if not has_prompt_toolkit():
|
||||
warn('prompt_toolkit is not available, using readline instead.')
|
||||
warnings.warn('prompt_toolkit is not available, using '
|
||||
'readline instead.')
|
||||
shell_type = 'readline'
|
||||
elif not ptk_version_is_supported():
|
||||
warn('prompt-toolkit version < v1.0.0 is not supported. '
|
||||
'Please update prompt-toolkit. Using readline instead.')
|
||||
warnings.warn('prompt-toolkit version < v1.0.0 is not '
|
||||
'supported. Please update prompt-toolkit. Using '
|
||||
'readline instead.')
|
||||
shell_type = 'readline'
|
||||
env['SHELL_TYPE'] = shell_type
|
||||
# actually make the shell
|
||||
|
|
|
@ -26,10 +26,15 @@ from xonsh.lazyasd import LazyObject
|
|||
# The following escape codes are xterm codes.
|
||||
# See http://rtfm.etla.org/xterm/ctlseq.html for more.
|
||||
MODE_NUMS = ('1049', '47', '1047')
|
||||
START_ALTERNATE_MODE = frozenset('\x1b[?{0}h'.format(i).encode() for i in MODE_NUMS)
|
||||
END_ALTERNATE_MODE = frozenset('\x1b[?{0}l'.format(i).encode() for i in MODE_NUMS)
|
||||
ALTERNATE_MODE_FLAGS = tuple(START_ALTERNATE_MODE) + tuple(END_ALTERNATE_MODE)
|
||||
|
||||
START_ALTERNATE_MODE = LazyObject(
|
||||
lambda: frozenset('\x1b[?{0}h'.format(i).encode() for i in MODE_NUMS),
|
||||
globals(), 'START_ALTERNATE_MODE')
|
||||
END_ALTERNATE_MODE = LazyObject(
|
||||
lambda: frozenset('\x1b[?{0}l'.format(i).encode() for i in MODE_NUMS),
|
||||
globals(), 'END_ALTERNATE_MODE')
|
||||
ALTERNATE_MODE_FLAGS = LazyObject(
|
||||
lambda: tuple(START_ALTERNATE_MODE) + tuple(END_ALTERNATE_MODE),
|
||||
globals(), 'ALTERNATE_MODE_FLAGS')
|
||||
RE_HIDDEN_BYTES = LazyObject(lambda: re.compile(b'(\001.*?\002)'),
|
||||
globals(), 'RE_HIDDEN')
|
||||
RE_COLOR = LazyObject(lambda: re.compile(b'\033\[\d+;?\d*m'),
|
||||
|
@ -334,5 +339,3 @@ def _teepty_main():
|
|||
print('-=-'*10)
|
||||
print('Returned with status {0}'.format(tpty.wcode))
|
||||
|
||||
if __name__ == '__main__':
|
||||
_teepty_main()
|
||||
|
|
Loading…
Add table
Reference in a new issue