mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
Made prompt_toolkit's mouse_support optional
Introducing a new environment variable MOUSE_SUPPORT for this, which can either be True or False. Default is False.
This commit is contained in:
parent
781f1b5f97
commit
3961310418
3 changed files with 16 additions and 6 deletions
|
@ -146,6 +146,13 @@ applicable.
|
||||||
* - XONSH_INTERACTIVE
|
* - XONSH_INTERACTIVE
|
||||||
-
|
-
|
||||||
- ``True`` if xonsh is running interactively, and ``False`` otherwise.
|
- ``True`` if xonsh is running interactively, and ``False`` otherwise.
|
||||||
|
* - MOUSE_SUPPORT
|
||||||
|
- ``False``
|
||||||
|
- Enable mouse support in the prompt_toolkit shell. This allows clicking
|
||||||
|
for positioning the cursor or selecting a completion. In some terminals
|
||||||
|
however, this disables the ability to scroll back through the history
|
||||||
|
of the terminal.
|
||||||
|
(Only usable with SHELL_TYPE=prompt_toolkit)
|
||||||
* - XONSH_SHOW_TRACEBACK
|
* - XONSH_SHOW_TRACEBACK
|
||||||
- ``False`` but not set
|
- ``False`` but not set
|
||||||
- Controls if a traceback is shown exceptions occur in the shell. Set ``True``
|
- Controls if a traceback is shown exceptions occur in the shell. Set ``True``
|
||||||
|
|
|
@ -62,6 +62,7 @@ DEFAULT_ENSURERS = {
|
||||||
'CASE_SENSITIVE_COMPLETIONS': (is_bool, to_bool, bool_to_str),
|
'CASE_SENSITIVE_COMPLETIONS': (is_bool, to_bool, bool_to_str),
|
||||||
'BASH_COMPLETIONS': (is_env_path, str_to_env_path, env_path_to_str),
|
'BASH_COMPLETIONS': (is_env_path, str_to_env_path, env_path_to_str),
|
||||||
'TEEPTY_PIPE_DELAY': (is_float, float, str),
|
'TEEPTY_PIPE_DELAY': (is_float, float, str),
|
||||||
|
'MOUSE_SUPPORT': (is_bool, to_bool, bool_to_str),
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -75,7 +76,7 @@ def default_value(f):
|
||||||
def is_callable_default(x):
|
def is_callable_default(x):
|
||||||
"""Checks if a value is a callable default."""
|
"""Checks if a value is a callable default."""
|
||||||
return callable(x) and getattr(x, '_xonsh_callable_default', False)
|
return callable(x) and getattr(x, '_xonsh_callable_default', False)
|
||||||
|
|
||||||
DEFAULT_PROMPT = ('{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} '
|
DEFAULT_PROMPT = ('{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} '
|
||||||
'{cwd}{branch_color}{curr_branch} '
|
'{cwd}{branch_color}{curr_branch} '
|
||||||
'{BOLD_BLUE}${NO_COLOR} ')
|
'{BOLD_BLUE}${NO_COLOR} ')
|
||||||
|
@ -112,7 +113,7 @@ DEFAULT_VALUES = {
|
||||||
'AUTO_PUSHD': False,
|
'AUTO_PUSHD': False,
|
||||||
'BASH_COMPLETIONS': ('/usr/local/etc/bash_completion',
|
'BASH_COMPLETIONS': ('/usr/local/etc/bash_completion',
|
||||||
'/opt/local/etc/profile.d/bash_completion.sh') if ON_MAC \
|
'/opt/local/etc/profile.d/bash_completion.sh') if ON_MAC \
|
||||||
else ('/etc/bash_completion',
|
else ('/etc/bash_completion',
|
||||||
'/usr/share/bash-completion/completions/git'),
|
'/usr/share/bash-completion/completions/git'),
|
||||||
'CASE_SENSITIVE_COMPLETIONS': ON_LINUX,
|
'CASE_SENSITIVE_COMPLETIONS': ON_LINUX,
|
||||||
'CDPATH': (),
|
'CDPATH': (),
|
||||||
|
@ -581,6 +582,7 @@ BASE_ENV = {
|
||||||
'LC_MONETARY': locale.setlocale(locale.LC_MONETARY),
|
'LC_MONETARY': locale.setlocale(locale.LC_MONETARY),
|
||||||
'LC_NUMERIC': locale.setlocale(locale.LC_NUMERIC),
|
'LC_NUMERIC': locale.setlocale(locale.LC_NUMERIC),
|
||||||
'XONSH_VERSION': XONSH_VERSION,
|
'XONSH_VERSION': XONSH_VERSION,
|
||||||
|
'MOUSE_SUPPORT': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -590,11 +592,11 @@ except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def load_static_config(ctx):
|
def load_static_config(ctx):
|
||||||
"""Loads a static configuration file from a given context, rather than the
|
"""Loads a static configuration file from a given context, rather than the
|
||||||
current environment.
|
current environment.
|
||||||
"""
|
"""
|
||||||
env = {}
|
env = {}
|
||||||
env['XDG_CONFIG_HOME'] = ctx.get('XDG_CONFIG_HOME',
|
env['XDG_CONFIG_HOME'] = ctx.get('XDG_CONFIG_HOME',
|
||||||
DEFAULT_VALUES['XDG_CONFIG_HOME'])
|
DEFAULT_VALUES['XDG_CONFIG_HOME'])
|
||||||
env['XONSH_CONFIG_DIR'] = ctx['XONSH_CONFIG_DIR'] if 'XONSH_CONFIG_DIR' in ctx \
|
env['XONSH_CONFIG_DIR'] = ctx['XONSH_CONFIG_DIR'] if 'XONSH_CONFIG_DIR' in ctx \
|
||||||
else xonsh_config_dir(env)
|
else xonsh_config_dir(env)
|
||||||
|
@ -656,7 +658,7 @@ def default_env(env=None):
|
||||||
ctx.update(os.environ)
|
ctx.update(os.environ)
|
||||||
conf = load_static_config(ctx)
|
conf = load_static_config(ctx)
|
||||||
ctx.update(conf.get('env', ()))
|
ctx.update(conf.get('env', ()))
|
||||||
ctx.update(load_foreign_envs(shells=conf.get('foreign_shells', DEFAULT_SHELLS),
|
ctx.update(load_foreign_envs(shells=conf.get('foreign_shells', DEFAULT_SHELLS),
|
||||||
issue_warning=False))
|
issue_warning=False))
|
||||||
if ON_WINDOWS:
|
if ON_WINDOWS:
|
||||||
windows_env_fixes(ctx)
|
windows_env_fixes(ctx)
|
||||||
|
|
|
@ -59,11 +59,12 @@ class PromptToolkitShell(BaseShell):
|
||||||
"""Enters a loop that reads and execute input from user."""
|
"""Enters a loop that reads and execute input from user."""
|
||||||
if intro:
|
if intro:
|
||||||
print(intro)
|
print(intro)
|
||||||
|
mouse_support = builtins.__xonsh_env__.get('MOUSE_SUPPORT')
|
||||||
while not builtins.__xonsh_exit__:
|
while not builtins.__xonsh_exit__:
|
||||||
try:
|
try:
|
||||||
token_func, style_cls = self._get_prompt_tokens_and_style()
|
token_func, style_cls = self._get_prompt_tokens_and_style()
|
||||||
line = get_input(
|
line = get_input(
|
||||||
mouse_support=True,
|
mouse_support=mouse_support,
|
||||||
auto_suggest=AutoSuggestFromHistory(),
|
auto_suggest=AutoSuggestFromHistory(),
|
||||||
get_prompt_tokens=token_func,
|
get_prompt_tokens=token_func,
|
||||||
style=style_cls,
|
style=style_cls,
|
||||||
|
|
Loading…
Add table
Reference in a new issue