本文整理汇总了Python中prompt_toolkit.filters.Always方法的典型用法代码示例。如果您正苦于以下问题:Python filters.Always方法的具体用法?Python filters.Always怎么用?Python filters.Always使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.filters
的用法示例。
在下文中一共展示了filters.Always方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _fix_unecessary_blank_lines
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def _fix_unecessary_blank_lines(ps: PromptSession) -> None:
"""This is a fix for additional empty lines added by prompt toolkit.
This assumes the layout of the default session doesn't change, if it
does, this needs an update."""
default_container = ps.layout.container
default_buffer_window = (
default_container.get_children()[0].content.get_children()[1].content
)
assert isinstance(default_buffer_window, Window)
# this forces the main window to stay as small as possible, avoiding
# empty lines in selections
default_buffer_window.dont_extend_height = Always()
示例2: main
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def main():
"""
Start the Slack Client
"""
os.system("clear; figlet 'Slack Gitsin' | lolcat")
history = FileHistory(os.path.expanduser("~/.slackHistory"))
while True:
text = prompt("slack> ", history=history,
auto_suggest=AutoSuggestFromHistory(),
on_abort=AbortAction.RETRY,
style=DocumentStyle,
completer=Completer(fuzzy_match=False,
text_utils=TextUtils()),
complete_while_typing=Always(),
get_bottom_toolbar_tokens=get_bottom_toolbar_tokens,
key_bindings_registry=manager.registry,
accept_action=AcceptAction.RETURN_DOCUMENT
)
slack = Slack(text)
slack.run_command()
示例3: create_application
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def create_application(self, full_layout=True):
""" makes the application object and the buffers """
if full_layout:
layout = create_layout(self.lexer, ExampleLexer, ToolbarLexer)
else:
layout = create_tutorial_layout(self.lexer)
buffers = {
DEFAULT_BUFFER: Buffer(is_multiline=True),
'description': Buffer(is_multiline=True, read_only=True),
'parameter' : Buffer(is_multiline=True, read_only=True),
'examples' : Buffer(is_multiline=True, read_only=True),
'bottom_toolbar' : Buffer(is_multiline=True),
'example_line' : Buffer(is_multiline=True),
'default_values' : Buffer(),
'symbols' : Buffer()
}
writing_buffer = Buffer(
history=self.history,
auto_suggest=AutoSuggestFromHistory(),
enable_history_search=True,
completer=self.completer,
complete_while_typing=Always()
)
return Application(
mouse_support=False,
style=self.styles,
buffer=writing_buffer,
on_input_timeout=self.on_input_timeout,
key_bindings_registry=registry,
layout=layout,
buffers=buffers,
)
示例4: create_tutorial_layout
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def create_tutorial_layout(lex):
""" layout for example tutorial """
lexer, _, _ = get_lexers(lex, None, None)
layout_full = HSplit([
FloatContainer(
Window(
BufferControl(
input_processors=input_processors,
lexer=lexer,
preview_search=Always()),
get_height=get_height),
[
Float(xcursor=True,
ycursor=True,
content=CompletionsMenu(
max_height=MAX_COMPLETION,
scroll_offset=1,
extra_filter=(HasFocus(DEFAULT_BUFFER))))]),
ConditionalContainer(
HSplit([
get_hline(),
get_param(lexer),
get_hline(),
Window(
content=BufferControl(
buffer_name='example_line',
lexer=lexer
),
),
Window(
TokenListControl(
get_tutorial_tokens,
default_char=Char(' ', Token.Toolbar)),
height=D.exact(1)),
]),
filter=~IsDone() & RendererHeightIsKnown()
)
])
return layout_full
示例5: test_always
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def test_always():
assert Always()()
示例6: test_invert
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def test_invert():
assert not (~Always())()
assert ~Never()()
c = ~Condition(lambda: False)
assert c()
示例7: create_buffer
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def create_buffer(self, completer, history):
return Buffer(
history=history,
auto_suggest=AutoSuggestFromHistory(),
enable_history_search=True,
completer=completer,
complete_while_typing=Always(),
accept_action=AcceptAction.RETURN_DOCUMENT)
示例8: __init__
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def __init__(self, get_tokens, filter=Always(), **kw):
super(TokenListToolbar, self).__init__(
content=Window(
TokenListControl(get_tokens, **kw),
height=LayoutDimension.exact(1)),
filter=filter)
示例9: build_propmpt
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Always [as 别名]
def build_propmpt(self) -> pt_shortcuts.PromptSession:
history = pt_history.FileHistory(
os.path.expanduser('~/.edgedbhistory'))
bindings = pt_key_binding.KeyBindings()
handle = bindings.add
@handle('f3') # type: ignore
def _mode_toggle(event: Any) -> None:
self.context.toggle_query_mode()
@handle('f4') # type: ignore
def _implicit_toggle(event: Any) -> None:
self.context.toggle_implicit()
@handle('f5') # type: ignore
def _introspect_toggle(event: Any) -> None:
self.context.toggle_introspect_types()
if self.context.introspect_types:
self.ensure_connection()
self.introspect_db(self.connection)
else:
self.context.typenames = None
@handle('tab') # type: ignore
def _tab(event: Any) -> None:
b = prompt.app.current_buffer
before_cursor = b.document.current_line_before_cursor
if b.text and (not before_cursor or before_cursor.isspace()):
b.insert_text(' ')
prompt = pt_shortcuts.PromptSession(
lexer=pt_lexers.PygmentsLexer(eql_pygments.EdgeQLLexer),
include_default_pygments_style=False,
completer=pt_complete.DummyCompleter(),
reserve_space_for_menu=6,
message=self.get_prompt_tokens,
prompt_continuation=self.get_continuation_tokens,
bottom_toolbar=self.get_toolbar_tokens,
multiline=is_multiline,
history=history,
complete_while_typing=pt_filters.Always(),
key_bindings=bindings,
style=self.style,
editing_mode=pt_enums.EditingMode.VI,
search_ignore_case=True,
)
return prompt