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"""
47
48from __future__ import annotations
49
50from .containers import (
51 AnyContainer,
52 ColorColumn,
53 ConditionalContainer,
54 Container,
55 DynamicContainer,
56 Float,
57 FloatContainer,
58 HorizontalAlign,
59 HSplit,
60 ScrollOffsets,
61 VerticalAlign,
62 VSplit,
63 Window,
64 WindowAlign,
65 WindowRenderInfo,
66 is_container,
67 to_container,
68 to_window,
69)
70from .controls import (
71 BufferControl,
72 DummyControl,
73 FormattedTextControl,
74 SearchBufferControl,
75 UIContent,
76 UIControl,
77)
78from .dimension import (
79 AnyDimension,
80 D,
81 Dimension,
82 is_dimension,
83 max_layout_dimensions,
84 sum_layout_dimensions,
85 to_dimension,
86)
87from .layout import InvalidLayoutError, Layout, walk
88from .margins import (
89 ConditionalMargin,
90 Margin,
91 NumberedMargin,
92 PromptMargin,
93 ScrollbarMargin,
94)
95from .menus import CompletionsMenu, MultiColumnCompletionsMenu
96from .scrollable_pane import ScrollablePane
97
98__all__ = [
99 # Layout.
100 "Layout",
101 "InvalidLayoutError",
102 "walk",
103 # Dimensions.
104 "AnyDimension",
105 "Dimension",
106 "D",
107 "sum_layout_dimensions",
108 "max_layout_dimensions",
109 "to_dimension",
110 "is_dimension",
111 # Containers.
112 "AnyContainer",
113 "Container",
114 "HorizontalAlign",
115 "VerticalAlign",
116 "HSplit",
117 "VSplit",
118 "FloatContainer",
119 "Float",
120 "WindowAlign",
121 "Window",
122 "WindowRenderInfo",
123 "ConditionalContainer",
124 "ScrollOffsets",
125 "ColorColumn",
126 "to_container",
127 "to_window",
128 "is_container",
129 "DynamicContainer",
130 "ScrollablePane",
131 # Controls.
132 "BufferControl",
133 "SearchBufferControl",
134 "DummyControl",
135 "FormattedTextControl",
136 "UIControl",
137 "UIContent",
138 # Margins.
139 "Margin",
140 "NumberedMargin",
141 "ScrollbarMargin",
142 "ConditionalMargin",
143 "PromptMargin",
144 # Menus.
145 "CompletionsMenu",
146 "MultiColumnCompletionsMenu",
147]