Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/prompt_toolkit/filters/__init__.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

9 statements  

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. 

7 

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. 

13 

14Filters can be chained using ``&`` and ``|`` operations, and inverted using the 

15``~`` operator, for instance:: 

16 

17 filter = has_focus('default') & ~ has_selection 

18""" 

19 

20from __future__ import annotations 

21 

22from .app import * 

23from .base import Always, Condition, Filter, FilterOrBool, Never 

24from .cli import * 

25from .utils import is_true, to_filter 

26 

27__all__ = [ 

28 # app 

29 "has_arg", 

30 "has_completions", 

31 "completion_is_selected", 

32 "has_focus", 

33 "buffer_has_focus", 

34 "has_selection", 

35 "has_validation_error", 

36 "is_done", 

37 "is_read_only", 

38 "is_multiline", 

39 "renderer_height_is_known", 

40 "in_editing_mode", 

41 "in_paste_mode", 

42 "vi_mode", 

43 "vi_navigation_mode", 

44 "vi_insert_mode", 

45 "vi_insert_multiple_mode", 

46 "vi_replace_mode", 

47 "vi_selection_mode", 

48 "vi_waiting_for_text_object_mode", 

49 "vi_digraph_mode", 

50 "vi_recording_macro", 

51 "emacs_mode", 

52 "emacs_insert_mode", 

53 "emacs_selection_mode", 

54 "shift_selection_mode", 

55 "is_searching", 

56 "control_is_searchable", 

57 "vi_search_direction_reversed", 

58 # base. 

59 "Filter", 

60 "Never", 

61 "Always", 

62 "Condition", 

63 "FilterOrBool", 

64 # utils. 

65 "is_true", 

66 "to_filter", 

67] 

68 

69from .cli import __all__ as cli_all 

70 

71__all__.extend(cli_all)