mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
many readline updates
This commit is contained in:
parent
cbe756a2c6
commit
f2d3163749
3 changed files with 32 additions and 2 deletions
|
@ -73,6 +73,7 @@ Current Developments
|
|||
at execution time rather than passing through a literal string.
|
||||
* Fixed environment variables from os.environ not beeing loaded when a running
|
||||
a script
|
||||
* The readline shell will now load the inputrc files.
|
||||
* Fixed bug that prevented `source-alias` from working.
|
||||
* Now able to ``^C`` the xonfig wizard on start up.
|
||||
* Fixed deadlock on Windows when runing subprocess that generates enough output
|
||||
|
|
|
@ -394,7 +394,10 @@ DEFAULT_DOCS = {
|
|||
'TERM': VarDocs(
|
||||
'TERM is sometimes set by the terminal emulator. This is used (when '
|
||||
"valid) to determine whether or not to set the title. Users shouldn't "
|
||||
"need to set this themselves.", configurable=False),
|
||||
"need to set this themselves. Note that this variable cannot be set from "
|
||||
"within xonsh itself; you need to see this from the program that launches "
|
||||
"xonsh. On posix systems, this can be performed by using env, e.g. "
|
||||
"'/usr/bin/env TERM=xterm-color xonsh' or similar.", configurable=False),
|
||||
'TITLE': VarDocs(
|
||||
'The title text for the window in which xonsh is running. Formatted '
|
||||
"in the same manner as $PROMPT, see 'Customizing the Prompt' "
|
||||
|
|
|
@ -23,6 +23,7 @@ readline = None
|
|||
RL_COMPLETION_SUPPRESS_APPEND = RL_LIB = RL_STATE = None
|
||||
RL_CAN_RESIZE = False
|
||||
RL_DONE = None
|
||||
RL_VARIABLE_VALUE = None
|
||||
_RL_STATE_DONE = 0x1000000
|
||||
_RL_STATE_ISEARCH = 0x0000080
|
||||
|
||||
|
@ -67,6 +68,8 @@ def setup_readline():
|
|||
readline.parse_and_bind("bind ^I rl_complete")
|
||||
else:
|
||||
readline.parse_and_bind("tab: complete")
|
||||
# load custom user settings
|
||||
readline.read_init_file()
|
||||
|
||||
|
||||
def teardown_readline():
|
||||
|
@ -109,6 +112,28 @@ def rl_completion_suppress_append(val=1):
|
|||
RL_COMPLETION_SUPPRESS_APPEND.value = val
|
||||
|
||||
|
||||
def rl_variable_dumper(readable=True):
|
||||
"""Dumps the currently set readline variables. If readable is True, then this
|
||||
output may be used in an inputrc file.
|
||||
"""
|
||||
RL_LIB.rl_variable_dumper(int(readable))
|
||||
|
||||
|
||||
def rl_variable_value(variable):
|
||||
"""Returns the currently set value for a readline configuration variable."""
|
||||
global RL_VARIABLE_VALUE
|
||||
if RL_VARIABLE_VALUE is None:
|
||||
import ctypes
|
||||
RL_VARIABLE_VALUE = RL_LIB.rl_variable_value
|
||||
RL_VARIABLE_VALUE.restype = ctypes.c_char_p
|
||||
env = builtins.__xonsh_env__
|
||||
enc, errors = env.get('XONSH_ENCODING'), env.get('XONSH_ENCODING_ERRORS')
|
||||
if isinstance(variable, str):
|
||||
variable = variable.encode(encoding=enc, errors=errors)
|
||||
rtn = RL_VARIABLE_VALUE(variable)
|
||||
return rtn.decode(encoding=enc, errors=errors)
|
||||
|
||||
|
||||
def _insert_text_func(s, readline):
|
||||
"""Creates a function to insert text via readline."""
|
||||
def inserter():
|
||||
|
@ -124,11 +149,11 @@ class ReadlineShell(BaseShell, Cmd):
|
|||
"""The readline based xonsh shell."""
|
||||
|
||||
def __init__(self, completekey='tab', stdin=None, stdout=None, **kwargs):
|
||||
setup_readline()
|
||||
super().__init__(completekey=completekey,
|
||||
stdin=stdin,
|
||||
stdout=stdout,
|
||||
**kwargs)
|
||||
setup_readline()
|
||||
self._current_indent = ''
|
||||
self._current_prompt = ''
|
||||
self.cmdqueue = deque()
|
||||
|
@ -353,6 +378,7 @@ class ReadlineShell(BaseShell, Cmd):
|
|||
style = style=builtins.__xonsh_env__.get('XONSH_COLOR_STYLE')
|
||||
return color_style(style=style)
|
||||
|
||||
|
||||
class ReadlineHistoryAdder(Thread):
|
||||
|
||||
def __init__(self, wait_for_gc=True, *args, **kwargs):
|
||||
|
|
Loading…
Add table
Reference in a new issue