Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/prompt_toolkit/layout/dummy.py: 61%
18 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"""
2Dummy layout. Used when somebody creates an `Application` without specifying a
3`Layout`.
4"""
5from __future__ import annotations
7from prompt_toolkit.formatted_text import HTML
8from prompt_toolkit.key_binding import KeyBindings
9from prompt_toolkit.key_binding.key_processor import KeyPressEvent
11from .containers import Window
12from .controls import FormattedTextControl
13from .dimension import D
14from .layout import Layout
16__all__ = [
17 "create_dummy_layout",
18]
20E = KeyPressEvent
23def create_dummy_layout() -> Layout:
24 """
25 Create a dummy layout for use in an 'Application' that doesn't have a
26 layout specified. When ENTER is pressed, the application quits.
27 """
28 kb = KeyBindings()
30 @kb.add("enter")
31 def enter(event: E) -> None:
32 event.app.exit()
34 control = FormattedTextControl(
35 HTML("No layout specified. Press <reverse>ENTER</reverse> to quit."),
36 key_bindings=kb,
37 )
38 window = Window(content=control, height=D(min=1))
39 return Layout(container=window, focused_element=window)