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

9 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-20 06:09 +0000

1""" 

2Command line layout definitions 

3------------------------------- 

4 

5The layout of a command line interface is defined by a Container instance. 

6There are two main groups of classes here. Containers and controls: 

7 

8- A container can contain other containers or controls, it can have multiple 

9 children and it decides about the dimensions. 

10- A control is responsible for rendering the actual content to a screen. 

11 A control can propose some dimensions, but it's the container who decides 

12 about the dimensions -- or when the control consumes more space -- which part 

13 of the control will be visible. 

14 

15 

16Container classes:: 

17 

18 - Container (Abstract base class) 

19 |- HSplit (Horizontal split) 

20 |- VSplit (Vertical split) 

21 |- FloatContainer (Container which can also contain menus and other floats) 

22 `- Window (Container which contains one actual control 

23 

24Control classes:: 

25 

26 - UIControl (Abstract base class) 

27 |- FormattedTextControl (Renders formatted text, or a simple list of text fragments) 

28 `- BufferControl (Renders an input buffer.) 

29 

30 

31Usually, you end up wrapping every control inside a `Window` object, because 

32that's the only way to render it in a layout. 

33 

34There are some prepared toolbars which are ready to use:: 

35 

36- SystemToolbar (Shows the 'system' input buffer, for entering system commands.) 

37- ArgToolbar (Shows the input 'arg', for repetition of input commands.) 

38- SearchToolbar (Shows the 'search' input buffer, for incremental search.) 

39- CompletionsToolbar (Shows the completions of the current buffer.) 

40- ValidationToolbar (Shows validation errors of the current buffer.) 

41 

42And one prepared menu: 

43 

44- CompletionsMenu 

45 

46""" 

47from __future__ import annotations 

48 

49from .containers import ( 

50 AnyContainer, 

51 ColorColumn, 

52 ConditionalContainer, 

53 Container, 

54 DynamicContainer, 

55 Float, 

56 FloatContainer, 

57 HorizontalAlign, 

58 HSplit, 

59 ScrollOffsets, 

60 VerticalAlign, 

61 VSplit, 

62 Window, 

63 WindowAlign, 

64 WindowRenderInfo, 

65 is_container, 

66 to_container, 

67 to_window, 

68) 

69from .controls import ( 

70 BufferControl, 

71 DummyControl, 

72 FormattedTextControl, 

73 SearchBufferControl, 

74 UIContent, 

75 UIControl, 

76) 

77from .dimension import ( 

78 AnyDimension, 

79 D, 

80 Dimension, 

81 is_dimension, 

82 max_layout_dimensions, 

83 sum_layout_dimensions, 

84 to_dimension, 

85) 

86from .layout import InvalidLayoutError, Layout, walk 

87from .margins import ( 

88 ConditionalMargin, 

89 Margin, 

90 NumberedMargin, 

91 PromptMargin, 

92 ScrollbarMargin, 

93) 

94from .menus import CompletionsMenu, MultiColumnCompletionsMenu 

95from .scrollable_pane import ScrollablePane 

96 

97__all__ = [ 

98 # Layout. 

99 "Layout", 

100 "InvalidLayoutError", 

101 "walk", 

102 # Dimensions. 

103 "AnyDimension", 

104 "Dimension", 

105 "D", 

106 "sum_layout_dimensions", 

107 "max_layout_dimensions", 

108 "to_dimension", 

109 "is_dimension", 

110 # Containers. 

111 "AnyContainer", 

112 "Container", 

113 "HorizontalAlign", 

114 "VerticalAlign", 

115 "HSplit", 

116 "VSplit", 

117 "FloatContainer", 

118 "Float", 

119 "WindowAlign", 

120 "Window", 

121 "WindowRenderInfo", 

122 "ConditionalContainer", 

123 "ScrollOffsets", 

124 "ColorColumn", 

125 "to_container", 

126 "to_window", 

127 "is_container", 

128 "DynamicContainer", 

129 "ScrollablePane", 

130 # Controls. 

131 "BufferControl", 

132 "SearchBufferControl", 

133 "DummyControl", 

134 "FormattedTextControl", 

135 "UIControl", 

136 "UIContent", 

137 # Margins. 

138 "Margin", 

139 "NumberedMargin", 

140 "ScrollbarMargin", 

141 "ConditionalMargin", 

142 "PromptMargin", 

143 # Menus. 

144 "CompletionsMenu", 

145 "MultiColumnCompletionsMenu", 

146]