本文整理汇总了Python中prompt_toolkit.enums.SEARCH_BUFFER属性的典型用法代码示例。如果您正苦于以下问题:Python enums.SEARCH_BUFFER属性的具体用法?Python enums.SEARCH_BUFFER怎么用?Python enums.SEARCH_BUFFER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类prompt_toolkit.enums
的用法示例。
在下文中一共展示了enums.SEARCH_BUFFER属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_isearch_tokens
# 需要导入模块: from prompt_toolkit import enums [as 别名]
# 或者: from prompt_toolkit.enums import SEARCH_BUFFER [as 别名]
def _get_isearch_tokens(cli):
def before():
if cli.search_state.direction == IncrementalSearchDirection.BACKWARD:
text = 'reverse-i-search'
else:
text = 'i-search'
return [(Token.Prompt.Search, '(%s)`' % text)]
def text():
return [(Token.Prompt.Search.Text, cli.buffers[SEARCH_BUFFER].text)]
def after():
return [(Token.Prompt.Search, '`: ')]
return before() + text() + after()
示例2: __init__
# 需要导入模块: from prompt_toolkit import enums [as 别名]
# 或者: from prompt_toolkit.enums import SEARCH_BUFFER [as 别名]
def __init__(self, vi_mode=False):
token = Token.Toolbar.Search
def get_before_input(cli):
if not cli.is_searching:
text = ''
elif cli.search_state.direction == IncrementalSearchDirection.BACKWARD:
text = ('?' if vi_mode else 'I-search backward: ')
else:
text = ('/' if vi_mode else 'I-search: ')
return [(token, text)]
super(SearchToolbarControl, self).__init__(
buffer_name=SEARCH_BUFFER,
input_processors=[BeforeInput(get_before_input)],
default_char=Char(token=token),
lexer=SimpleLexer(token=token.Text))
示例3: _create_search_buffer
# 需要导入模块: from prompt_toolkit import enums [as 别名]
# 或者: from prompt_toolkit.enums import SEARCH_BUFFER [as 别名]
def _create_search_buffer(self) -> Buffer:
return Buffer(name=SEARCH_BUFFER)
示例4: reverse_search_history
# 需要导入模块: from prompt_toolkit import enums [as 别名]
# 或者: from prompt_toolkit.enums import SEARCH_BUFFER [as 别名]
def reverse_search_history(event):
"""
Search backward starting at the current line and moving `up` through
the history as necessary. This is an incremental search.
"""
event.cli.current_search_state.direction = IncrementalSearchDirection.BACKWARD
event.cli.push_focus(SEARCH_BUFFER)
#
# Commands for changing text
#
示例5: __init__
# 需要导入模块: from prompt_toolkit import enums [as 别名]
# 或者: from prompt_toolkit.enums import SEARCH_BUFFER [as 别名]
def __init__(self, preview_search=False, search_buffer_name=SEARCH_BUFFER,
get_search_state=None):
self.preview_search = to_cli_filter(preview_search)
self.search_buffer_name = search_buffer_name
self.get_search_state = get_search_state or (lambda cli: cli.search_state)
示例6: __init__
# 需要导入模块: from prompt_toolkit import enums [as 别名]
# 或者: from prompt_toolkit.enums import SEARCH_BUFFER [as 别名]
def __init__(self,
buffer_name=DEFAULT_BUFFER,
input_processors=None,
lexer=None,
preview_search=False,
search_buffer_name=SEARCH_BUFFER,
get_search_state=None,
menu_position=None,
default_char=None,
focus_on_click=False):
assert input_processors is None or all(isinstance(i, Processor) for i in input_processors)
assert menu_position is None or callable(menu_position)
assert lexer is None or isinstance(lexer, Lexer)
assert get_search_state is None or callable(get_search_state)
assert default_char is None or isinstance(default_char, Char)
self.preview_search = to_cli_filter(preview_search)
self.get_search_state = get_search_state
self.focus_on_click = to_cli_filter(focus_on_click)
self.input_processors = input_processors or []
self.buffer_name = buffer_name
self.menu_position = menu_position
self.lexer = lexer or SimpleLexer()
self.default_char = default_char or Char(token=Token.Transparent)
self.search_buffer_name = search_buffer_name
#: Cache for the lexer.
#: Often, due to cursor movement, undo/redo and window resizing
#: operations, it happens that a short time, the same document has to be
#: lexed. This is a faily easy way to cache such an expensive operation.
self._token_cache = SimpleCache(maxsize=8)
self._xy_to_cursor_position = None
self._last_click_timestamp = None
self._last_get_processed_line = None