__init__.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. """
  2. Command line layout definitions
  3. -------------------------------
  4. The layout of a command line interface is defined by a Container instance.
  5. There are two main groups of classes here. Containers and controls:
  6. - A container can contain other containers or controls, it can have multiple
  7. children and it decides about the dimensions.
  8. - A control is responsible for rendering the actual content to a screen.
  9. A control can propose some dimensions, but it's the container who decides
  10. about the dimensions -- or when the control consumes more space -- which part
  11. of the control will be visible.
  12. Container classes::
  13. - Container (Abstract base class)
  14. |- HSplit (Horizontal split)
  15. |- VSplit (Vertical split)
  16. |- FloatContainer (Container which can also contain menus and other floats)
  17. `- Window (Container which contains one actual control
  18. Control classes::
  19. - UIControl (Abstract base class)
  20. |- FormattedTextControl (Renders formatted text, or a simple list of text fragments)
  21. `- BufferControl (Renders an input buffer.)
  22. Usually, you end up wrapping every control inside a `Window` object, because
  23. that's the only way to render it in a layout.
  24. There are some prepared toolbars which are ready to use::
  25. - SystemToolbar (Shows the 'system' input buffer, for entering system commands.)
  26. - ArgToolbar (Shows the input 'arg', for repetition of input commands.)
  27. - SearchToolbar (Shows the 'search' input buffer, for incremental search.)
  28. - CompletionsToolbar (Shows the completions of the current buffer.)
  29. - ValidationToolbar (Shows validation errors of the current buffer.)
  30. And one prepared menu:
  31. - CompletionsMenu
  32. """
  33. from __future__ import annotations
  34. from .containers import (
  35. AnyContainer,
  36. ColorColumn,
  37. ConditionalContainer,
  38. Container,
  39. DynamicContainer,
  40. Float,
  41. FloatContainer,
  42. HorizontalAlign,
  43. HSplit,
  44. ScrollOffsets,
  45. VerticalAlign,
  46. VSplit,
  47. Window,
  48. WindowAlign,
  49. WindowRenderInfo,
  50. is_container,
  51. to_container,
  52. to_window,
  53. )
  54. from .controls import (
  55. BufferControl,
  56. DummyControl,
  57. FormattedTextControl,
  58. SearchBufferControl,
  59. UIContent,
  60. UIControl,
  61. )
  62. from .dimension import (
  63. AnyDimension,
  64. D,
  65. Dimension,
  66. is_dimension,
  67. max_layout_dimensions,
  68. sum_layout_dimensions,
  69. to_dimension,
  70. )
  71. from .layout import InvalidLayoutError, Layout, walk
  72. from .margins import (
  73. ConditionalMargin,
  74. Margin,
  75. NumberedMargin,
  76. PromptMargin,
  77. ScrollbarMargin,
  78. )
  79. from .menus import CompletionsMenu, MultiColumnCompletionsMenu
  80. from .scrollable_pane import ScrollablePane
  81. __all__ = [
  82. # Layout.
  83. "Layout",
  84. "InvalidLayoutError",
  85. "walk",
  86. # Dimensions.
  87. "AnyDimension",
  88. "Dimension",
  89. "D",
  90. "sum_layout_dimensions",
  91. "max_layout_dimensions",
  92. "to_dimension",
  93. "is_dimension",
  94. # Containers.
  95. "AnyContainer",
  96. "Container",
  97. "HorizontalAlign",
  98. "VerticalAlign",
  99. "HSplit",
  100. "VSplit",
  101. "FloatContainer",
  102. "Float",
  103. "WindowAlign",
  104. "Window",
  105. "WindowRenderInfo",
  106. "ConditionalContainer",
  107. "ScrollOffsets",
  108. "ColorColumn",
  109. "to_container",
  110. "to_window",
  111. "is_container",
  112. "DynamicContainer",
  113. "ScrollablePane",
  114. # Controls.
  115. "BufferControl",
  116. "SearchBufferControl",
  117. "DummyControl",
  118. "FormattedTextControl",
  119. "UIControl",
  120. "UIContent",
  121. # Margins.
  122. "Margin",
  123. "NumberedMargin",
  124. "ScrollbarMargin",
  125. "ConditionalMargin",
  126. "PromptMargin",
  127. # Menus.
  128. "CompletionsMenu",
  129. "MultiColumnCompletionsMenu",
  130. ]