Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/prompt_toolkit/filters/__init__.py: 100%
8 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
1"""
2Filters decide whether something is active or not (they decide about a boolean
3state). This is used to enable/disable features, like key bindings, parts of
4the layout and other stuff. For instance, we could have a `HasSearch` filter
5attached to some part of the layout, in order to show that part of the user
6interface only while the user is searching.
8Filters are made to avoid having to attach callbacks to all event in order to
9propagate state. However, they are lazy, they don't automatically propagate the
10state of what they are observing. Only when a filter is called (it's actually a
11callable), it will calculate its value. So, its not really reactive
12programming, but it's made to fit for this framework.
14Filters can be chained using ``&`` and ``|`` operations, and inverted using the
15``~`` operator, for instance::
17 filter = has_focus('default') & ~ has_selection
18"""
19from __future__ import annotations
21from .app import *
22from .base import Always, Condition, Filter, FilterOrBool, Never
23from .cli import *
24from .utils import is_true, to_filter
26__all__ = [
27 # app
28 "has_arg",
29 "has_completions",
30 "completion_is_selected",
31 "has_focus",
32 "buffer_has_focus",
33 "has_selection",
34 "has_validation_error",
35 "is_done",
36 "is_read_only",
37 "is_multiline",
38 "renderer_height_is_known",
39 "in_editing_mode",
40 "in_paste_mode",
41 "vi_mode",
42 "vi_navigation_mode",
43 "vi_insert_mode",
44 "vi_insert_multiple_mode",
45 "vi_replace_mode",
46 "vi_selection_mode",
47 "vi_waiting_for_text_object_mode",
48 "vi_digraph_mode",
49 "vi_recording_macro",
50 "emacs_mode",
51 "emacs_insert_mode",
52 "emacs_selection_mode",
53 "shift_selection_mode",
54 "is_searching",
55 "control_is_searchable",
56 "vi_search_direction_reversed",
57 # base.
58 "Filter",
59 "Never",
60 "Always",
61 "Condition",
62 "FilterOrBool",
63 # utils.
64 "is_true",
65 "to_filter",
66]
68from .cli import __all__ as cli_all
70__all__.extend(cli_all)