本文整理汇总了Python中prompt_toolkit.layout.lexers.PygmentsLexer方法的典型用法代码示例。如果您正苦于以下问题:Python lexers.PygmentsLexer方法的具体用法?Python lexers.PygmentsLexer怎么用?Python lexers.PygmentsLexer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.layout.lexers
的用法示例。
在下文中一共展示了lexers.PygmentsLexer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prompt
# 需要导入模块: from prompt_toolkit.layout import lexers [as 别名]
# 或者: from prompt_toolkit.layout.lexers import PygmentsLexer [as 别名]
def prompt(self, msg):
"""Get input using prompt_toolkit."""
try:
# prompt_toolkit v2
prompt = prompt_toolkit.PromptSession(history=self.history).prompt
except AttributeError:
# prompt_toolkit v1
prompt = partial(prompt_toolkit.prompt, history=self.history)
return prompt(
msg,
multiline=self.multiline,
vi_mode=self.vi_mode,
wrap_lines=self.wrap_lines,
enable_history_search=self.history_search,
lexer=PygmentsLexer(CoconutLexer),
style=style_from_pygments_cls(
pygments.styles.get_style_by_name(self.style),
),
)
示例2: get_lexers
# 需要导入模块: from prompt_toolkit.layout import lexers [as 别名]
# 或者: from prompt_toolkit.layout.lexers import PygmentsLexer [as 别名]
def get_lexers(main_lex, exam_lex, tool_lex):
""" gets all the lexer wrappers """
if not main_lex:
return None, None, None
lexer = None
if issubclass(main_lex, PromptLex):
lexer = main_lex
elif issubclass(main_lex, PygLex):
lexer = PygmentsLexer(main_lex)
if exam_lex:
if issubclass(exam_lex, PygLex):
exam_lex = PygmentsLexer(exam_lex)
if tool_lex:
if issubclass(tool_lex, PygLex):
tool_lex = PygmentsLexer(tool_lex)
return lexer, exam_lex, tool_lex
示例3: __init__
# 需要导入模块: from prompt_toolkit.layout import lexers [as 别名]
# 或者: from prompt_toolkit.layout.lexers import PygmentsLexer [as 别名]
def __init__(self, parser, engine, options=None):
self.parser = parser
self.engine = engine
self.options = options if options is not None else {}
util.ensure_data_dir_exists()
application = create_prompt_application(
message='> ',
lexer=PygmentsLexer(SqlLexer),
history=FileHistory(os.path.expanduser('~/.aq/history')),
completer=AqCompleter(schemas=engine.available_schemas, tables=engine.available_tables),
auto_suggest=AutoSuggestFromHistory(),
validator=QueryValidator(parser),
on_abort=AbortAction.RETRY,
)
loop = create_eventloop()
self.cli = CommandLineInterface(application=application, eventloop=loop)
self.patch_context = self.cli.patch_stdout_context()