本文整理汇总了Python中prompt_toolkit.styles.PygmentsStyle.from_defaults方法的典型用法代码示例。如果您正苦于以下问题:Python PygmentsStyle.from_defaults方法的具体用法?Python PygmentsStyle.from_defaults怎么用?Python PygmentsStyle.from_defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.styles.PygmentsStyle
的用法示例。
在下文中一共展示了PygmentsStyle.from_defaults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: style_factory
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def style_factory(name):
try:
style = pygments.styles.get_style_by_name(name)
except ClassNotFound:
style = pygments.styles.get_style_by_name('native')
styles = {}
styles.update(style.styles)
styles.update(default_style_extensions)
styles.update({
Token.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000',
Token.Menu.Completions.Completion: 'bg:#008888 #ffffff',
Token.Menu.Completions.ProgressButton: 'bg:#003333',
Token.Menu.Completions.ProgressBar: 'bg:#00aaaa',
Token.Toolbar: 'bg:#222222 #cccccc',
Token.Toolbar.Off: 'bg:#222222 #004444',
Token.Toolbar.On: 'bg:#222222 #ffffff',
Token.Toolbar.Search: 'noinherit bold',
Token.Toolbar.Search.Text: 'nobold',
Token.Toolbar.System: 'noinherit bold',
Token.Toolbar.Arg: 'noinherit bold',
Token.Toolbar.Arg.Text: 'nobold'
})
return PygmentsStyle.from_defaults(style_dict=styles)
示例2: _make_style_from_name
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def _make_style_from_name(self, name):
"""
Small wrapper that make an IPython compatible style from a style name
We need that to add style for prompt ... etc.
"""
style_cls = get_style_by_name(name)
style_overrides = {
Token.Prompt: style_cls.styles.get( Token.Keyword, '#009900'),
Token.PromptNum: style_cls.styles.get( Token.Literal.Number, '#00ff00 bold')
}
if name is 'default':
style_cls = get_style_by_name('default')
# The default theme needs to be visible on both a dark background
# and a light background, because we can't tell what the terminal
# looks like. These tweaks to the default theme help with that.
style_overrides.update({
Token.Number: '#007700',
Token.Operator: 'noinherit',
Token.String: '#BB6622',
Token.Name.Function: '#2080D0',
Token.Name.Class: 'bold #2080D0',
Token.Name.Namespace: 'bold #2080D0',
})
style_overrides.update(self.highlighting_style_overrides)
style = PygmentsStyle.from_defaults(pygments_style_cls=style_cls,
style_dict=style_overrides)
return style
示例3: _make_style_from_name
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def _make_style_from_name(self, name):
"""
Small wrapper that make an IPython compatible style from a style name
We need that to add style for prompt ... etc.
"""
style_cls = get_style_by_name(name)
style_overrides = {
Token.Prompt: "#009900",
Token.PromptNum: "#00ff00 bold",
Token.OutPrompt: "#990000",
Token.OutPromptNum: "#ff0000 bold",
}
if name == "default":
style_cls = get_style_by_name("default")
# The default theme needs to be visible on both a dark background
# and a light background, because we can't tell what the terminal
# looks like. These tweaks to the default theme help with that.
style_overrides.update(
{
Token.Number: "#007700",
Token.Operator: "noinherit",
Token.String: "#BB6622",
Token.Name.Function: "#2080D0",
Token.Name.Class: "bold #2080D0",
Token.Name.Namespace: "bold #2080D0",
}
)
style_overrides.update(self.highlighting_style_overrides)
style = PygmentsStyle.from_defaults(pygments_style_cls=style_cls, style_dict=style_overrides)
return style
示例4: style_factory
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def style_factory(name, cli_style):
try:
style = pygments.styles.get_style_by_name(name)
except ClassNotFound:
style = pygments.styles.get_style_by_name('native')
custom_styles = dict([(string_to_tokentype(x), y)
for x, y in cli_style.items()])
return PygmentsStyle.from_defaults(style_dict=custom_styles,
pygments_style_cls=style)
示例5: main
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def main():
style = PygmentsStyle.from_defaults(style_dict={
Token.Hello: '#ff0066',
Token.World: '#44ff44 italic',
})
tokens = [
(Token.Hello, 'Hello '),
(Token.World, 'World'),
(Token, '\n'),
]
print_tokens(tokens, style=style)
示例6: _make_style_from_name_or_cls
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def _make_style_from_name_or_cls(self, name_or_cls):
"""
Small wrapper that make an IPython compatible style from a style name
We need that to add style for prompt ... etc.
"""
style_overrides = {}
if name_or_cls == 'legacy':
legacy = self.colors.lower()
if legacy == 'linux':
style_cls = get_style_by_name('monokai')
style_overrides = _style_overrides_linux
elif legacy == 'lightbg':
style_overrides = _style_overrides_light_bg
style_cls = get_style_by_name('pastie')
elif legacy == 'neutral':
# The default theme needs to be visible on both a dark background
# and a light background, because we can't tell what the terminal
# looks like. These tweaks to the default theme help with that.
style_cls = get_style_by_name('default')
style_overrides.update({
Token.Number: '#007700',
Token.Operator: 'noinherit',
Token.String: '#BB6622',
Token.Name.Function: '#2080D0',
Token.Name.Class: 'bold #2080D0',
Token.Name.Namespace: 'bold #2080D0',
Token.Prompt: '#009900',
Token.PromptNum: '#00ff00 bold',
Token.OutPrompt: '#990000',
Token.OutPromptNum: '#ff0000 bold',
})
elif legacy =='nocolor':
style_cls=_NoStyle
style_overrides = {}
else :
raise ValueError('Got unknown colors: ', legacy)
else :
if isinstance(name_or_cls, string_types):
style_cls = get_style_by_name(name_or_cls)
else:
style_cls = name_or_cls
style_overrides = {
Token.Prompt: '#009900',
Token.PromptNum: '#00ff00 bold',
Token.OutPrompt: '#990000',
Token.OutPromptNum: '#ff0000 bold',
}
style_overrides.update(self.highlighting_style_overrides)
style = PygmentsStyle.from_defaults(pygments_style_cls=style_cls,
style_dict=style_overrides)
return style
示例7: loop
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def loop(cmd, history_file):
key_binding_manager = KeyBindingManager(
enable_search=True,
enable_abort_and_exit_bindings=True
)
layout = create_prompt_layout(
message=u'cr> ',
multiline=True,
lexer=SqlLexer,
extra_input_processors=[
ConditionalProcessor(
processor=HighlightMatchingBracketProcessor(chars='[](){}'),
filter=HasFocus(DEFAULT_BUFFER) & ~IsDone())
]
)
buffer = CrashBuffer(
history=TruncatedFileHistory(history_file, max_length=MAX_HISTORY_LENGTH),
accept_action=AcceptAction.RETURN_DOCUMENT,
completer=SQLCompleter(cmd)
)
buffer.complete_while_typing = lambda cli=None: cmd.should_autocomplete()
application = Application(
layout=layout,
buffer=buffer,
style=PygmentsStyle.from_defaults(pygments_style_cls=CrateStyle),
key_bindings_registry=key_binding_manager.registry,
editing_mode=_get_editing_mode(),
on_exit=AbortAction.RAISE_EXCEPTION,
on_abort=AbortAction.RETRY,
)
eventloop = create_eventloop()
output = create_output()
cli = CommandLineInterface(
application=application,
eventloop=eventloop,
output=output
)
def get_num_columns_override():
return output.get_size().columns
cmd.get_num_columns = get_num_columns_override
while True:
try:
doc = cli.run(reset_current_buffer=True)
if doc:
cmd.process(doc.text)
except KeyboardInterrupt:
cmd.logger.warn("Query not cancelled. Run KILL <jobId> to cancel it")
except EOFError:
cmd.logger.warn(u'Bye!')
return
示例8: _make_style_from_name
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def _make_style_from_name(self, name):
"""
Small wrapper that make an IPython compatible style from a style name
We need that to add style for prompt ... etc.
"""
style_overrides = {}
if name == "legacy":
legacy = self.colors.lower()
if legacy == "linux":
style_cls = get_style_by_name("monokai")
style_overrides = _style_overrides_linux
elif legacy == "lightbg":
style_overrides = _style_overrides_light_bg
style_cls = get_style_by_name("pastie")
elif legacy == "neutral":
# The default theme needs to be visible on both a dark background
# and a light background, because we can't tell what the terminal
# looks like. These tweaks to the default theme help with that.
style_cls = get_style_by_name("default")
style_overrides.update(
{
Token.Number: "#007700",
Token.Operator: "noinherit",
Token.String: "#BB6622",
Token.Name.Function: "#2080D0",
Token.Name.Class: "bold #2080D0",
Token.Name.Namespace: "bold #2080D0",
Token.Prompt: "#009900",
Token.PromptNum: "#00ff00 bold",
Token.OutPrompt: "#990000",
Token.OutPromptNum: "#ff0000 bold",
}
)
elif legacy == "nocolor":
style_cls = _NoStyle
style_overrides = {}
else:
raise ValueError("Got unknown colors: ", legacy)
else:
style_cls = get_style_by_name(name)
style_overrides = {
Token.Prompt: "#009900",
Token.PromptNum: "#00ff00 bold",
Token.OutPrompt: "#990000",
Token.OutPromptNum: "#ff0000 bold",
}
style_overrides.update(self.highlighting_style_overrides)
style = PygmentsStyle.from_defaults(pygments_style_cls=style_cls, style_dict=style_overrides)
return style
示例9: loop
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def loop(cmd, history_file):
key_binding_manager = KeyBindingManager(
enable_search=True,
enable_abort_and_exit_bindings=True,
enable_system_bindings=True,
enable_open_in_editor=True
)
bind_keys(key_binding_manager.registry)
layout = create_layout(
multiline=True,
lexer=SqlLexer,
extra_input_processors=[
ConditionalProcessor(
processor=HighlightMatchingBracketProcessor(chars='[](){}'),
filter=HasFocus(DEFAULT_BUFFER) & ~IsDone())
],
get_bottom_toolbar_tokens=lambda cli: get_toolbar_tokens(cmd),
get_prompt_tokens=lambda cli: [(Token.Prompt, 'cr> ')]
)
application = Application(
layout=layout,
buffer=create_buffer(cmd, history_file),
style=PygmentsStyle.from_defaults(pygments_style_cls=CrateStyle),
key_bindings_registry=key_binding_manager.registry,
editing_mode=_get_editing_mode(),
on_exit=AbortAction.RAISE_EXCEPTION,
on_abort=AbortAction.RETRY,
)
eventloop = create_eventloop()
output = create_output()
cli = CommandLineInterface(
application=application,
eventloop=eventloop,
output=output
)
def get_num_columns_override():
return output.get_size().columns
cmd.get_num_columns = get_num_columns_override
while True:
try:
doc = cli.run(reset_current_buffer=True)
if doc:
cmd.process(doc.text)
except ProgrammingError as e:
if '401' in e.message:
username = cmd.username
password = cmd.password
cmd.username = input('Username: ')
cmd.password = getpass()
try:
cmd.process(doc.text)
except ProgrammingError as ex:
# fallback to existing user/pw
cmd.username = username
cmd.password = password
cmd.logger.warn(str(ex))
else:
cmd.logger.warn(str(e))
except KeyboardInterrupt:
cmd.logger.warn("Query not cancelled. Run KILL <jobId> to cancel it")
except EOFError:
cmd.logger.warn('Bye!')
return
示例10: _
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
from prompt_toolkit.styles import PygmentsStyle
from pygments.token import Token
from prompt_toolkit.key_binding.manager import KeyBindingManager
from prompt_toolkit.keys import Keys
from datetime import datetime
import os
import subprocess
import random
import sys
manager = KeyBindingManager.for_prompt()
toolbar_style = PygmentsStyle.from_defaults({
Token.Toolbar: '#ffffff bg:#333333',
Token.SCM: '#FF1A00 bg:#333333',
Token.QUIT: '#ffffff bg:#ff0000'
})
# GIT COMMANDS
GIT_STATUS = ['git', 'status', '--porcelain']
GIT_BRANCH = ['git', 'rev-parse', '--abbrev-ref', 'HEAD']
GIT_MODIFICATIONS = ['git', '--no-pager', 'diff', '--numstat', 'HEAD']
GIT_AUTHORS = ["git", "log", "--format=%aN"]
@manager.registry.add_binding(Keys.ControlC)
@manager.registry.add_binding(Keys.ControlD)
def _(event):
def quit_it():
if getattr(event.cli, 'quit', False) is True:
示例11: __init__
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def __init__(self):
self.pygments_style = PygmentsStyle.from_defaults(style_dict=ui_style)
self._token_to_attrs_dict = None
示例12: init_prompt_toolkit_cli
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def init_prompt_toolkit_cli(self):
if 'JUPYTER_CONSOLE_TEST' in os.environ:
# Simple restricted interface for tests so we can find prompts with
# pexpect. Multi-line input not supported.
def prompt():
return cast_unicode_py2(input('In [%d]: ' % self.execution_count))
self.prompt_for_code = prompt
self.print_out_prompt = \
lambda: print('Out[%d]: ' % self.execution_count, end='')
return
kbmanager = KeyBindingManager.for_prompt()
insert_mode = ViInsertMode() | EmacsInsertMode()
# Ctrl+J == Enter, seemingly
@kbmanager.registry.add_binding(Keys.ControlJ,
filter=(HasFocus(DEFAULT_BUFFER)
& ~HasSelection()
& insert_mode
))
def _(event):
b = event.current_buffer
d = b.document
if not (d.on_last_line or d.cursor_position_row >= d.line_count
- d.empty_line_count_at_the_end()):
b.newline()
return
more, indent = self.check_complete(d.text)
if (not more) and b.accept_action.is_returnable:
b.accept_action.validate_and_handle(event.cli, b)
else:
b.insert_text('\n' + indent)
@kbmanager.registry.add_binding(Keys.ControlC, filter=HasFocus(DEFAULT_BUFFER))
def _(event):
event.current_buffer.reset()
# Pre-populate history from IPython's history database
history = InMemoryHistory()
last_cell = u""
for _, _, cell in self.history_manager.get_tail(self.history_load_length,
include_latest=True):
# Ignore blank lines and consecutive duplicates
cell = cell.rstrip()
if cell and (cell != last_cell):
history.append(cell)
style_overrides = {
Token.Prompt: '#009900',
Token.PromptNum: '#00ff00 bold',
Token.OutPrompt: '#ff2200',
Token.OutPromptNum: '#ff0000 bold',
}
if self.highlighting_style:
style_cls = get_style_by_name(self.highlighting_style)
else:
style_cls = get_style_by_name('default')
# The default theme needs to be visible on both a dark background
# and a light background, because we can't tell what the terminal
# looks like. These tweaks to the default theme help with that.
style_overrides.update({
Token.Number: '#007700',
Token.Operator: 'noinherit',
Token.String: '#BB6622',
Token.Name.Function: '#2080D0',
Token.Name.Class: 'bold #2080D0',
Token.Name.Namespace: 'bold #2080D0',
})
style_overrides.update(self.highlighting_style_overrides)
style = PygmentsStyle.from_defaults(pygments_style_cls=style_cls,
style_dict=style_overrides)
editing_mode = getattr(EditingMode, self.editing_mode.upper())
langinfo = self.kernel_info.get('language_info', {})
lexer = langinfo.get('pygments_lexer', langinfo.get('name', 'text'))
app = create_prompt_application(multiline=True,
editing_mode=editing_mode,
lexer=PygmentsLexer(get_pygments_lexer(lexer)),
get_prompt_tokens=self.get_prompt_tokens,
get_continuation_tokens=self.get_continuation_tokens,
key_bindings_registry=kbmanager.registry,
history=history,
completer=JupyterPTCompleter(self.Completer),
enable_history_search=True,
style=style,
)
self._eventloop = create_eventloop()
self.pt_cli = CommandLineInterface(app,
eventloop=self._eventloop,
output=create_output(true_color=self.true_color),
)
示例13: init_prompt_toolkit_cli
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
def init_prompt_toolkit_cli(self):
if not sys.stdin.isatty():
# Piped input - e.g. for tests. Fall back to plain non-interactive
# output. This is very limited, and only accepts a single line.
def prompt():
return cast_unicode_py2(input('In [%d]: ' % self.execution_count))
self.prompt_for_code = prompt
return
kbmanager = KeyBindingManager.for_prompt(enable_vi_mode=self.vi_mode)
insert_mode = ViStateFilter(kbmanager.get_vi_state, InputMode.INSERT)
# Ctrl+J == Enter, seemingly
@kbmanager.registry.add_binding(Keys.ControlJ,
filter=(HasFocus(DEFAULT_BUFFER)
& ~HasSelection()
& insert_mode
))
def _(event):
b = event.current_buffer
d = b.document
if not (d.on_last_line or d.cursor_position_row >= d.line_count
- d.empty_line_count_at_the_end()):
b.newline()
return
status, indent = self.input_splitter.check_complete(d.text)
if (status != 'incomplete') and b.accept_action.is_returnable:
b.accept_action.validate_and_handle(event.cli, b)
else:
b.insert_text('\n' + (' ' * (indent or 0)))
@kbmanager.registry.add_binding(Keys.ControlC)
def _(event):
event.current_buffer.reset()
# Pre-populate history from IPython's history database
history = InMemoryHistory()
last_cell = u""
for _, _, cell in self.history_manager.get_tail(self.history_load_length,
include_latest=True):
# Ignore blank lines and consecutive duplicates
cell = cell.rstrip()
if cell and (cell != last_cell):
history.append(cell)
style_overrides = {
Token.Prompt: '#009900',
Token.PromptNum: '#00ff00 bold',
}
if self.highlighting_style:
style_cls = get_style_by_name(self.highlighting_style)
else:
style_cls = get_style_by_name('default')
# The default theme needs to be visible on both a dark background
# and a light background, because we can't tell what the terminal
# looks like. These tweaks to the default theme help with that.
style_overrides.update({
Token.Number: '#007700',
Token.Operator: 'noinherit',
Token.String: '#BB6622',
Token.Name.Function: '#2080D0',
Token.Name.Class: 'bold #2080D0',
Token.Name.Namespace: 'bold #2080D0',
})
style_overrides.update(self.highlighting_style_overrides)
style = PygmentsStyle.from_defaults(pygments_style_cls=style_cls,
style_dict=style_overrides)
app = create_prompt_application(multiline=True,
lexer=PygmentsLexer(Python3Lexer if PY3 else PythonLexer),
get_prompt_tokens=self.get_prompt_tokens,
get_continuation_tokens=self.get_continuation_tokens,
key_bindings_registry=kbmanager.registry,
history=history,
completer=IPythonPTCompleter(self.Completer),
enable_history_search=True,
style=style,
mouse_support=self.mouse_support,
)
self.pt_cli = CommandLineInterface(app,
eventloop=create_eventloop(self.inputhook))
示例14: main
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
#!/usr/bin/env python
"""
Simple example showing a bottom toolbar.
"""
from __future__ import unicode_literals
from prompt_toolkit import prompt
from prompt_toolkit.styles import PygmentsStyle
from pygments.token import Token
test_style = PygmentsStyle.from_defaults({
Token.Toolbar: '#ffffff bg:#333333',
})
def main():
def get_bottom_toolbar_tokens(cli):
return [(Token.Toolbar, ' This is a toolbar. ')]
text = prompt('Say something: ',
get_bottom_toolbar_tokens=get_bottom_toolbar_tokens,
style=test_style)
print('You said: %s' % text)
if __name__ == '__main__':
main()
示例15: __init__
# 需要导入模块: from prompt_toolkit.styles import PygmentsStyle [as 别名]
# 或者: from prompt_toolkit.styles.PygmentsStyle import from_defaults [as 别名]
#.........这里部分代码省略.........
self.lexers = {
'node_command': SimpleLexer(Token.Keyword),
'command': SimpleLexer(Token.Keyword),
'helpable': SimpleLexer(Token.Keyword),
'load_plugins': SimpleLexer(Token.Keyword),
'load': SimpleLexer(Token.Keyword),
'node_or_cli': SimpleLexer(Token.Keyword),
'arg1': SimpleLexer(Token.Name),
'node_name': SimpleLexer(Token.Name),
'more_nodes': SimpleLexer(Token.Name),
'simple': SimpleLexer(Token.Keyword),
'client_command': SimpleLexer(Token.Keyword),
'add_key': SimpleLexer(Token.Keyword),
'verkey': SimpleLexer(Token.Literal),
'for_client': SimpleLexer(Token.Keyword),
'identifier': SimpleLexer(Token.Name),
}
self.clientWC = WordCompleter([])
self.completers = {
'node_command': WordCompleter(self.nodeCmds),
'client_command': WordCompleter(self.cliCmds),
'client': WordCompleter(['client']),
'command': WordCompleter(self.commands),
'node_or_cli': WordCompleter(self.node_or_cli),
'node_name': WordCompleter(self.nodeNames),
'more_nodes': WordCompleter(self.nodeNames),
'helpable': WordCompleter(self.helpablesCommands),
'load_plugins': WordCompleter(['load plugins from']),
'client_name': self.clientWC,
'cli_action': WordCompleter(self.cliActions),
'simple': WordCompleter(self.simpleCmds),
'add_key': WordCompleter(['add key']),
'for_client': WordCompleter(['for client']),
}
self.initializeGrammar()
self.initializeGrammarLexer()
self.initializeGrammarCompleter()
self.style = PygmentsStyle.from_defaults({
Token.Operator: '#33aa33 bold',
Token.Number: '#aa3333 bold',
Token.Name: '#ffff00 bold',
Token.Heading: 'bold',
Token.TrailingInput: 'bg:#662222 #ffffff',
Token.BoldGreen: '#33aa33 bold',
Token.BoldOrange: '#ff4f2f bold',
Token.BoldBlue: '#095cab bold'})
self.functionMappings = self.createFunctionMappings()
self.voidMsg = "<none>"
# Create an asyncio `EventLoop` object. This is a wrapper around the
# asyncio loop that can be passed into prompt_toolkit.
eventloop = create_asyncio_eventloop(looper.loop)
pers_hist = FileHistory('.{}-cli-history'.format(self.name))
# Create interface.
app = create_prompt_application('{}> '.format(self.name),
lexer=self.grammarLexer,
completer=self.grammarCompleter,
style=self.style,
history=pers_hist)
if output:
out = output
else:
if is_windows():
if is_conemu_ansi():
out = ConEmuOutput(sys.__stdout__)
else:
out = Win32Output(sys.__stdout__)
else:
out = CustomOutput.from_pty(sys.__stdout__, true_color=True)
self.cli = CommandLineInterface(
application=app,
eventloop=eventloop,
output=out)
# Patch stdout in something that will always print *above* the prompt
# when something is written to stdout.
sys.stdout = self.cli.stdout_proxy()
setupLogging(TRACE_LOG_LEVEL,
Console.Wordage.mute,
filename=logFileName)
self.logger = getlogger("cli")
self.print("\n{}-CLI (c) 2016 Evernym, Inc.".format(self.properName))
self.print("Node registry loaded.")
self.print("None of these are created or running yet.")
self.showNodeRegistry()
self.print("Type 'help' for more information.")