summaryrefslogtreecommitdiffstats
path: root/examples/full-screen/simple-demos
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xexamples/full-screen/simple-demos/alignment.py60
-rwxr-xr-xexamples/full-screen/simple-demos/autocompletion.py100
-rwxr-xr-xexamples/full-screen/simple-demos/colorcolumn.py63
-rwxr-xr-xexamples/full-screen/simple-demos/cursorcolumn-cursorline.py59
-rwxr-xr-xexamples/full-screen/simple-demos/float-transparency.py87
-rwxr-xr-xexamples/full-screen/simple-demos/floats.py116
-rwxr-xr-xexamples/full-screen/simple-demos/focus.py98
-rwxr-xr-xexamples/full-screen/simple-demos/horizontal-align.py209
-rwxr-xr-xexamples/full-screen/simple-demos/horizontal-split.py44
-rwxr-xr-xexamples/full-screen/simple-demos/line-prefixes.py111
-rwxr-xr-xexamples/full-screen/simple-demos/margins.py71
-rwxr-xr-xexamples/full-screen/simple-demos/vertical-align.py168
-rwxr-xr-xexamples/full-screen/simple-demos/vertical-split.py44
13 files changed, 1230 insertions, 0 deletions
diff --git a/examples/full-screen/simple-demos/alignment.py b/examples/full-screen/simple-demos/alignment.py
new file mode 100755
index 0000000..b20b43d
--- /dev/null
+++ b/examples/full-screen/simple-demos/alignment.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+"""
+Demo of the different Window alignment options.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import HSplit, Window, WindowAlign
+from prompt_toolkit.layout.controls import FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+
+LIPSUM = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas
+quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est bibendum
+mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat. In vel dictum ex, vulputate accumsan mi. Donec ut quam
+placerat massa tempor elementum. Sed tristique mauris ac suscipit euismod. Ut
+tempus vehicula augue non venenatis. Mauris aliquam velit turpis, nec congue
+risus aliquam sit amet. Pellentesque blandit scelerisque felis, faucibus
+consequat ante. Curabitur tempor tortor a imperdiet tincidunt. Nam sed justo
+sit amet odio bibendum congue. Quisque varius ligula nec ligula gravida, sed
+convallis augue faucibus. Nunc ornare pharetra bibendum. Praesent blandit ex
+quis sodales maximus."""
+
+# 1. The layout
+
+left_text = '\nLeft aligned text. - (Press "q" to quit)\n\n' + LIPSUM
+center_text = "Centered text.\n\n" + LIPSUM
+right_text = "Right aligned text.\n\n" + LIPSUM
+
+
+body = HSplit(
+ [
+ Window(FormattedTextControl(left_text), align=WindowAlign.LEFT),
+ Window(height=1, char="-"),
+ Window(FormattedTextControl(center_text), align=WindowAlign.CENTER),
+ Window(height=1, char="-"),
+ Window(FormattedTextControl(right_text), align=WindowAlign.RIGHT),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/autocompletion.py b/examples/full-screen/simple-demos/autocompletion.py
new file mode 100755
index 0000000..bcbb594
--- /dev/null
+++ b/examples/full-screen/simple-demos/autocompletion.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+"""
+An example of a BufferControl in a full screen layout that offers auto
+completion.
+
+Important is to make sure that there is a `CompletionsMenu` in the layout,
+otherwise the completions won't be visible.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.buffer import Buffer
+from prompt_toolkit.completion import WordCompleter
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import Float, FloatContainer, HSplit, Window
+from prompt_toolkit.layout.controls import BufferControl, FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+from prompt_toolkit.layout.menus import CompletionsMenu
+
+# The completer.
+animal_completer = WordCompleter(
+ [
+ "alligator",
+ "ant",
+ "ape",
+ "bat",
+ "bear",
+ "beaver",
+ "bee",
+ "bison",
+ "butterfly",
+ "cat",
+ "chicken",
+ "crocodile",
+ "dinosaur",
+ "dog",
+ "dolphin",
+ "dove",
+ "duck",
+ "eagle",
+ "elephant",
+ "fish",
+ "goat",
+ "gorilla",
+ "kangaroo",
+ "leopard",
+ "lion",
+ "mouse",
+ "rabbit",
+ "rat",
+ "snake",
+ "spider",
+ "turkey",
+ "turtle",
+ ],
+ ignore_case=True,
+)
+
+
+# The layout
+buff = Buffer(completer=animal_completer, complete_while_typing=True)
+
+body = FloatContainer(
+ content=HSplit(
+ [
+ Window(
+ FormattedTextControl('Press "q" to quit.'), height=1, style="reverse"
+ ),
+ Window(BufferControl(buffer=buff)),
+ ]
+ ),
+ floats=[
+ Float(
+ xcursor=True,
+ ycursor=True,
+ content=CompletionsMenu(max_height=16, scroll_offset=1),
+ )
+ ],
+)
+
+
+# Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+@kb.add("c-c")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/colorcolumn.py b/examples/full-screen/simple-demos/colorcolumn.py
new file mode 100755
index 0000000..054aa44
--- /dev/null
+++ b/examples/full-screen/simple-demos/colorcolumn.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+"""
+Colorcolumn example.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.buffer import Buffer
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import ColorColumn, HSplit, Window
+from prompt_toolkit.layout.controls import BufferControl, FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+
+LIPSUM = """
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas
+quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est bibendum
+mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat. In vel dictum ex, vulputate accumsan mi. Donec ut quam
+placerat massa tempor elementum. Sed tristique mauris ac suscipit euismod. Ut
+tempus vehicula augue non venenatis. Mauris aliquam velit turpis, nec congue
+risus aliquam sit amet. Pellentesque blandit scelerisque felis, faucibus
+consequat ante. Curabitur tempor tortor a imperdiet tincidunt. Nam sed justo
+sit amet odio bibendum congue. Quisque varius ligula nec ligula gravida, sed
+convallis augue faucibus. Nunc ornare pharetra bibendum. Praesent blandit ex
+quis sodales maximus."""
+
+# Create text buffers.
+buff = Buffer()
+buff.text = LIPSUM
+
+# 1. The layout
+color_columns = [
+ ColorColumn(50),
+ ColorColumn(80, style="bg:#ff0000"),
+ ColorColumn(10, style="bg:#ff0000"),
+]
+
+body = HSplit(
+ [
+ Window(FormattedTextControl('Press "q" to quit.'), height=1, style="reverse"),
+ Window(BufferControl(buffer=buff), colorcolumns=color_columns),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/cursorcolumn-cursorline.py b/examples/full-screen/simple-demos/cursorcolumn-cursorline.py
new file mode 100755
index 0000000..505b3ee
--- /dev/null
+++ b/examples/full-screen/simple-demos/cursorcolumn-cursorline.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+"""
+Cursorcolumn / cursorline example.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.buffer import Buffer
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import HSplit, Window
+from prompt_toolkit.layout.controls import BufferControl, FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+
+LIPSUM = """
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas
+quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est bibendum
+mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat. In vel dictum ex, vulputate accumsan mi. Donec ut quam
+placerat massa tempor elementum. Sed tristique mauris ac suscipit euismod. Ut
+tempus vehicula augue non venenatis. Mauris aliquam velit turpis, nec congue
+risus aliquam sit amet. Pellentesque blandit scelerisque felis, faucibus
+consequat ante. Curabitur tempor tortor a imperdiet tincidunt. Nam sed justo
+sit amet odio bibendum congue. Quisque varius ligula nec ligula gravida, sed
+convallis augue faucibus. Nunc ornare pharetra bibendum. Praesent blandit ex
+quis sodales maximus."""
+
+# Create text buffers. Cursorcolumn/cursorline are mostly combined with an
+# (editable) text buffers, where the user can move the cursor.
+
+buff = Buffer()
+buff.text = LIPSUM
+
+# 1. The layout
+body = HSplit(
+ [
+ Window(FormattedTextControl('Press "q" to quit.'), height=1, style="reverse"),
+ Window(BufferControl(buffer=buff), cursorcolumn=True, cursorline=True),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/float-transparency.py b/examples/full-screen/simple-demos/float-transparency.py
new file mode 100755
index 0000000..4dc38fc
--- /dev/null
+++ b/examples/full-screen/simple-demos/float-transparency.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+"""
+Example of the 'transparency' attribute of `Window' when used in a Float.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.formatted_text import HTML
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import Float, FloatContainer, Window
+from prompt_toolkit.layout.controls import FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+from prompt_toolkit.widgets import Frame
+
+LIPSUM = " ".join(
+ (
+ """Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+Maecenas quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est
+bibendum mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat. In vel dictum ex, vulputate accumsan mi. Donec ut quam
+placerat massa tempor elementum. Sed tristique mauris ac suscipit euismod. Ut
+tempus vehicula augue non venenatis. Mauris aliquam velit turpis, nec congue
+risus aliquam sit amet. Pellentesque blandit scelerisque felis, faucibus
+consequat ante. Curabitur tempor tortor a imperdiet tincidunt. Nam sed justo
+sit amet odio bibendum congue. Quisque varius ligula nec ligula gravida, sed
+convallis augue faucibus. Nunc ornare pharetra bibendum. Praesent blandit ex
+quis sodales maximus. """
+ * 100
+ ).split()
+)
+
+
+# 1. The layout
+left_text = HTML("<reverse>transparent=False</reverse>\n")
+right_text = HTML("<reverse>transparent=True</reverse>")
+quit_text = "Press 'q' to quit."
+
+
+body = FloatContainer(
+ content=Window(FormattedTextControl(LIPSUM), wrap_lines=True),
+ floats=[
+ # Important note: Wrapping the floating objects in a 'Frame' is
+ # only required for drawing the border around the
+ # floating text. We do it here to make the layout more
+ # obvious.
+ # Left float.
+ Float(
+ Frame(Window(FormattedTextControl(left_text), width=20, height=4)),
+ transparent=False,
+ left=0,
+ ),
+ # Right float.
+ Float(
+ Frame(Window(FormattedTextControl(right_text), width=20, height=4)),
+ transparent=True,
+ right=0,
+ ),
+ # Quit text.
+ Float(
+ Frame(
+ Window(FormattedTextControl(quit_text), width=18, height=1),
+ style="bg:#ff44ff #ffffff",
+ ),
+ top=1,
+ ),
+ ],
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/floats.py b/examples/full-screen/simple-demos/floats.py
new file mode 100755
index 0000000..0d45be9
--- /dev/null
+++ b/examples/full-screen/simple-demos/floats.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+"""
+Horizontal split example.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import Float, FloatContainer, Window
+from prompt_toolkit.layout.controls import FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+from prompt_toolkit.widgets import Frame
+
+LIPSUM = " ".join(
+ (
+ """Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+Maecenas quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est
+bibendum mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat. In vel dictum ex, vulputate accumsan mi. Donec ut quam
+placerat massa tempor elementum. Sed tristique mauris ac suscipit euismod. Ut
+tempus vehicula augue non venenatis. Mauris aliquam velit turpis, nec congue
+risus aliquam sit amet. Pellentesque blandit scelerisque felis, faucibus
+consequat ante. Curabitur tempor tortor a imperdiet tincidunt. Nam sed justo
+sit amet odio bibendum congue. Quisque varius ligula nec ligula gravida, sed
+convallis augue faucibus. Nunc ornare pharetra bibendum. Praesent blandit ex
+quis sodales maximus. """
+ * 100
+ ).split()
+)
+
+
+# 1. The layout
+left_text = "Floating\nleft"
+right_text = "Floating\nright"
+top_text = "Floating\ntop"
+bottom_text = "Floating\nbottom"
+center_text = "Floating\ncenter"
+quit_text = "Press 'q' to quit."
+
+
+body = FloatContainer(
+ content=Window(FormattedTextControl(LIPSUM), wrap_lines=True),
+ floats=[
+ # Important note: Wrapping the floating objects in a 'Frame' is
+ # only required for drawing the border around the
+ # floating text. We do it here to make the layout more
+ # obvious.
+ # Left float.
+ Float(
+ Frame(
+ Window(FormattedTextControl(left_text), width=10, height=2),
+ style="bg:#44ffff #ffffff",
+ ),
+ left=0,
+ ),
+ # Right float.
+ Float(
+ Frame(
+ Window(FormattedTextControl(right_text), width=10, height=2),
+ style="bg:#44ffff #ffffff",
+ ),
+ right=0,
+ ),
+ # Bottom float.
+ Float(
+ Frame(
+ Window(FormattedTextControl(bottom_text), width=10, height=2),
+ style="bg:#44ffff #ffffff",
+ ),
+ bottom=0,
+ ),
+ # Top float.
+ Float(
+ Frame(
+ Window(FormattedTextControl(top_text), width=10, height=2),
+ style="bg:#44ffff #ffffff",
+ ),
+ top=0,
+ ),
+ # Center float.
+ Float(
+ Frame(
+ Window(FormattedTextControl(center_text), width=10, height=2),
+ style="bg:#44ffff #ffffff",
+ )
+ ),
+ # Quit text.
+ Float(
+ Frame(
+ Window(FormattedTextControl(quit_text), width=18, height=1),
+ style="bg:#ff44ff #ffffff",
+ ),
+ top=6,
+ ),
+ ],
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/focus.py b/examples/full-screen/simple-demos/focus.py
new file mode 100755
index 0000000..9fe9b8f
--- /dev/null
+++ b/examples/full-screen/simple-demos/focus.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+"""
+Demonstration of how to programmatically focus a certain widget.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.buffer import Buffer
+from prompt_toolkit.document import Document
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import HSplit, VSplit, Window
+from prompt_toolkit.layout.controls import BufferControl, FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+
+# 1. The layout
+top_text = (
+ "Focus example.\n"
+ "[q] Quit [a] Focus left top [b] Right top [c] Left bottom [d] Right bottom."
+)
+
+LIPSUM = """Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+Maecenas quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est
+bibendum mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat. In vel dictum ex, vulputate accumsan mi. Donec ut quam
+placerat massa tempor elementum. Sed tristique mauris ac suscipit euismod. Ut
+tempus vehicula augue non venenatis. Mauris aliquam velit turpis, nec congue
+risus aliquam sit amet. Pellentesque blandit scelerisque felis, faucibus
+consequat ante. Curabitur tempor tortor a imperdiet tincidunt. Nam sed justo
+sit amet odio bibendum congue. Quisque varius ligula nec ligula gravida, sed
+convallis augue faucibus. Nunc ornare pharetra bibendum. Praesent blandit ex
+quis sodales maximus. """
+
+
+left_top = Window(BufferControl(Buffer(document=Document(LIPSUM))))
+left_bottom = Window(BufferControl(Buffer(document=Document(LIPSUM))))
+right_top = Window(BufferControl(Buffer(document=Document(LIPSUM))))
+right_bottom = Window(BufferControl(Buffer(document=Document(LIPSUM))))
+
+
+body = HSplit(
+ [
+ Window(FormattedTextControl(top_text), height=2, style="reverse"),
+ Window(height=1, char="-"), # Horizontal line in the middle.
+ VSplit([left_top, Window(width=1, char="|"), right_top]),
+ Window(height=1, char="-"), # Horizontal line in the middle.
+ VSplit([left_bottom, Window(width=1, char="|"), right_bottom]),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+@kb.add("a")
+def _(event):
+ event.app.layout.focus(left_top)
+
+
+@kb.add("b")
+def _(event):
+ event.app.layout.focus(right_top)
+
+
+@kb.add("c")
+def _(event):
+ event.app.layout.focus(left_bottom)
+
+
+@kb.add("d")
+def _(event):
+ event.app.layout.focus(right_bottom)
+
+
+@kb.add("tab")
+def _(event):
+ event.app.layout.focus_next()
+
+
+@kb.add("s-tab")
+def _(event):
+ event.app.layout.focus_previous()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/horizontal-align.py b/examples/full-screen/simple-demos/horizontal-align.py
new file mode 100755
index 0000000..f50b9e8
--- /dev/null
+++ b/examples/full-screen/simple-demos/horizontal-align.py
@@ -0,0 +1,209 @@
+#!/usr/bin/env python
+"""
+Horizontal align demo with HSplit.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.formatted_text import HTML
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import (
+ HorizontalAlign,
+ HSplit,
+ VerticalAlign,
+ VSplit,
+ Window,
+ WindowAlign,
+)
+from prompt_toolkit.layout.controls import FormattedTextControl
+from prompt_toolkit.layout.dimension import D
+from prompt_toolkit.layout.layout import Layout
+from prompt_toolkit.widgets import Frame
+
+TITLE = HTML(
+ """ <u>HSplit HorizontalAlign</u> example.
+ Press <b>'q'</b> to quit."""
+)
+
+LIPSUM = """\
+Lorem ipsum dolor
+sit amet, consectetur
+adipiscing elit.
+Maecenas quis
+interdum enim."""
+
+
+# 1. The layout
+body = HSplit(
+ [
+ Frame(
+ Window(FormattedTextControl(TITLE), height=2), style="bg:#88ff88 #000000"
+ ),
+ HSplit(
+ [
+ # Left alignment.
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(HTML("<u>LEFT</u>")),
+ width=10,
+ ignore_content_width=True,
+ style="bg:#ff3333 ansiblack",
+ align=WindowAlign.CENTER,
+ ),
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#888888",
+ align=HorizontalAlign.LEFT,
+ height=5,
+ padding_char="|",
+ ),
+ ]
+ ),
+ # Center alignment.
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(HTML("<u>CENTER</u>")),
+ width=10,
+ ignore_content_width=True,
+ style="bg:#ff3333 ansiblack",
+ align=WindowAlign.CENTER,
+ ),
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#888888",
+ align=HorizontalAlign.CENTER,
+ height=5,
+ padding_char="|",
+ ),
+ ]
+ ),
+ # Right alignment.
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(HTML("<u>RIGHT</u>")),
+ width=10,
+ ignore_content_width=True,
+ style="bg:#ff3333 ansiblack",
+ align=WindowAlign.CENTER,
+ ),
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ Window(
+ FormattedTextControl(LIPSUM),
+ height=4,
+ style="bg:#444488",
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#888888",
+ align=HorizontalAlign.RIGHT,
+ height=5,
+ padding_char="|",
+ ),
+ ]
+ ),
+ # Justify
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(HTML("<u>JUSTIFY</u>")),
+ width=10,
+ ignore_content_width=True,
+ style="bg:#ff3333 ansiblack",
+ align=WindowAlign.CENTER,
+ ),
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(LIPSUM), style="bg:#444488"
+ ),
+ Window(
+ FormattedTextControl(LIPSUM), style="bg:#444488"
+ ),
+ Window(
+ FormattedTextControl(LIPSUM), style="bg:#444488"
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#888888",
+ align=HorizontalAlign.JUSTIFY,
+ height=5,
+ padding_char="|",
+ ),
+ ]
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#ff3333 #ffffff",
+ padding_char=".",
+ align=VerticalAlign.TOP,
+ ),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/horizontal-split.py b/examples/full-screen/simple-demos/horizontal-split.py
new file mode 100755
index 0000000..0427e67
--- /dev/null
+++ b/examples/full-screen/simple-demos/horizontal-split.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+"""
+Horizontal split example.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import HSplit, Window
+from prompt_toolkit.layout.controls import FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+
+# 1. The layout
+left_text = "\nVertical-split example. Press 'q' to quit.\n\n(top pane.)"
+right_text = "\n(bottom pane.)"
+
+
+body = HSplit(
+ [
+ Window(FormattedTextControl(left_text)),
+ Window(height=1, char="-"), # Horizontal line in the middle.
+ Window(FormattedTextControl(right_text)),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/line-prefixes.py b/examples/full-screen/simple-demos/line-prefixes.py
new file mode 100755
index 0000000..ab47ef6
--- /dev/null
+++ b/examples/full-screen/simple-demos/line-prefixes.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+"""
+An example of a BufferControl in a full screen layout that offers auto
+completion.
+
+Important is to make sure that there is a `CompletionsMenu` in the layout,
+otherwise the completions won't be visible.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.buffer import Buffer
+from prompt_toolkit.completion import WordCompleter
+from prompt_toolkit.filters import Condition
+from prompt_toolkit.formatted_text import HTML
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import Float, FloatContainer, HSplit, Window
+from prompt_toolkit.layout.controls import BufferControl, FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+from prompt_toolkit.layout.menus import CompletionsMenu
+
+LIPSUM = """
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas
+quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est bibendum
+mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat. In vel dictum ex, vulputate accumsan mi. Donec ut quam
+placerat massa tempor elementum. Sed tristique mauris ac suscipit euismod. Ut
+tempus vehicula augue non venenatis. Mauris aliquam velit turpis, nec congue
+risus aliquam sit amet. Pellentesque blandit scelerisque felis, faucibus
+consequat ante. Curabitur tempor tortor a imperdiet tincidunt. Nam sed justo
+sit amet odio bibendum congue. Quisque varius ligula nec ligula gravida, sed
+convallis augue faucibus. Nunc ornare pharetra bibendum. Praesent blandit ex
+quis sodales maximus."""
+
+
+def get_line_prefix(lineno, wrap_count):
+ if wrap_count == 0:
+ return HTML('[%s] <style bg="orange" fg="black">--&gt;</style> ') % lineno
+
+ text = str(lineno) + "-" + "*" * (lineno // 2) + ": "
+ return HTML('[%s.%s] <style bg="ansigreen" fg="ansiblack">%s</style>') % (
+ lineno,
+ wrap_count,
+ text,
+ )
+
+
+# Global wrap lines flag.
+wrap_lines = True
+
+
+# The layout
+buff = Buffer(complete_while_typing=True)
+buff.text = LIPSUM
+
+
+body = FloatContainer(
+ content=HSplit(
+ [
+ Window(
+ FormattedTextControl(
+ 'Press "q" to quit. Press "w" to enable/disable wrapping.'
+ ),
+ height=1,
+ style="reverse",
+ ),
+ Window(
+ BufferControl(buffer=buff),
+ get_line_prefix=get_line_prefix,
+ wrap_lines=Condition(lambda: wrap_lines),
+ ),
+ ]
+ ),
+ floats=[
+ Float(
+ xcursor=True,
+ ycursor=True,
+ content=CompletionsMenu(max_height=16, scroll_offset=1),
+ )
+ ],
+)
+
+
+# Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+@kb.add("c-c")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+@kb.add("w")
+def _(event):
+ "Disable/enable wrapping."
+ global wrap_lines
+ wrap_lines = not wrap_lines
+
+
+# The `Application`
+application = Application(
+ layout=Layout(body), key_bindings=kb, full_screen=True, mouse_support=True
+)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/margins.py b/examples/full-screen/simple-demos/margins.py
new file mode 100755
index 0000000..467492d
--- /dev/null
+++ b/examples/full-screen/simple-demos/margins.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+"""
+Example of Window margins.
+
+This is mainly used for displaying line numbers and scroll bars, but it could
+be used to display any other kind of information as well.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.buffer import Buffer
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import HSplit, Window
+from prompt_toolkit.layout.controls import BufferControl, FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+from prompt_toolkit.layout.margins import NumberedMargin, ScrollbarMargin
+
+LIPSUM = (
+ """
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas
+quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est bibendum
+mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat. In vel dictum ex, vulputate accumsan mi. Donec ut quam
+placerat massa tempor elementum. Sed tristique mauris ac suscipit euismod. Ut
+tempus vehicula augue non venenatis. Mauris aliquam velit turpis, nec congue
+risus aliquam sit amet. Pellentesque blandit scelerisque felis, faucibus
+consequat ante. Curabitur tempor tortor a imperdiet tincidunt. Nam sed justo
+sit amet odio bibendum congue. Quisque varius ligula nec ligula gravida, sed
+convallis augue faucibus. Nunc ornare pharetra bibendum. Praesent blandit ex
+quis sodales maximus."""
+ * 40
+)
+
+# Create text buffers. The margins will update if you scroll up or down.
+
+buff = Buffer()
+buff.text = LIPSUM
+
+# 1. The layout
+body = HSplit(
+ [
+ Window(FormattedTextControl('Press "q" to quit.'), height=1, style="reverse"),
+ Window(
+ BufferControl(buffer=buff),
+ # Add margins.
+ left_margins=[NumberedMargin(), ScrollbarMargin()],
+ right_margins=[ScrollbarMargin(), ScrollbarMargin()],
+ ),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+@kb.add("c-c")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/vertical-align.py b/examples/full-screen/simple-demos/vertical-align.py
new file mode 100755
index 0000000..824695e
--- /dev/null
+++ b/examples/full-screen/simple-demos/vertical-align.py
@@ -0,0 +1,168 @@
+#!/usr/bin/env python
+"""
+Vertical align demo with VSplit.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.formatted_text import HTML
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import (
+ HSplit,
+ VerticalAlign,
+ VSplit,
+ Window,
+ WindowAlign,
+)
+from prompt_toolkit.layout.controls import FormattedTextControl
+from prompt_toolkit.layout.dimension import D
+from prompt_toolkit.layout.layout import Layout
+from prompt_toolkit.widgets import Frame
+
+TITLE = HTML(
+ """ <u>VSplit VerticalAlign</u> example.
+ Press <b>'q'</b> to quit."""
+)
+
+LIPSUM = """
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas
+quis interdum enim. Nam viverra, mauris et blandit malesuada, ante est bibendum
+mauris, ac dignissim dui tellus quis ligula. Aenean condimentum leo at
+dignissim placerat."""
+
+# 1. The layout
+body = HSplit(
+ [
+ Frame(
+ Window(FormattedTextControl(TITLE), height=2), style="bg:#88ff88 #000000"
+ ),
+ VSplit(
+ [
+ Window(
+ FormattedTextControl(HTML(" <u>VerticalAlign.TOP</u>")),
+ height=4,
+ ignore_content_width=True,
+ style="bg:#ff3333 #000000 bold",
+ align=WindowAlign.CENTER,
+ ),
+ Window(
+ FormattedTextControl(HTML(" <u>VerticalAlign.CENTER</u>")),
+ height=4,
+ ignore_content_width=True,
+ style="bg:#ff3333 #000000 bold",
+ align=WindowAlign.CENTER,
+ ),
+ Window(
+ FormattedTextControl(HTML(" <u>VerticalAlign.BOTTOM</u>")),
+ height=4,
+ ignore_content_width=True,
+ style="bg:#ff3333 #000000 bold",
+ align=WindowAlign.CENTER,
+ ),
+ Window(
+ FormattedTextControl(HTML(" <u>VerticalAlign.JUSTIFY</u>")),
+ height=4,
+ ignore_content_width=True,
+ style="bg:#ff3333 #000000 bold",
+ align=WindowAlign.CENTER,
+ ),
+ ],
+ height=1,
+ padding=1,
+ padding_style="bg:#ff3333",
+ ),
+ VSplit(
+ [
+ # Top alignment.
+ HSplit(
+ [
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#888888",
+ align=VerticalAlign.TOP,
+ padding_char="~",
+ ),
+ # Center alignment.
+ HSplit(
+ [
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#888888",
+ align=VerticalAlign.CENTER,
+ padding_char="~",
+ ),
+ # Bottom alignment.
+ HSplit(
+ [
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ Window(
+ FormattedTextControl(LIPSUM), height=4, style="bg:#444488"
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#888888",
+ align=VerticalAlign.BOTTOM,
+ padding_char="~",
+ ),
+ # Justify
+ HSplit(
+ [
+ Window(FormattedTextControl(LIPSUM), style="bg:#444488"),
+ Window(FormattedTextControl(LIPSUM), style="bg:#444488"),
+ Window(FormattedTextControl(LIPSUM), style="bg:#444488"),
+ ],
+ padding=1,
+ padding_style="bg:#888888",
+ align=VerticalAlign.JUSTIFY,
+ padding_char="~",
+ ),
+ ],
+ padding=1,
+ padding_style="bg:#ff3333 #ffffff",
+ padding_char=".",
+ ),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()
diff --git a/examples/full-screen/simple-demos/vertical-split.py b/examples/full-screen/simple-demos/vertical-split.py
new file mode 100755
index 0000000..b48d106
--- /dev/null
+++ b/examples/full-screen/simple-demos/vertical-split.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+"""
+Vertical split example.
+"""
+from prompt_toolkit.application import Application
+from prompt_toolkit.key_binding import KeyBindings
+from prompt_toolkit.layout.containers import VSplit, Window
+from prompt_toolkit.layout.controls import FormattedTextControl
+from prompt_toolkit.layout.layout import Layout
+
+# 1. The layout
+left_text = "\nVertical-split example. Press 'q' to quit.\n\n(left pane.)"
+right_text = "\n(right pane.)"
+
+
+body = VSplit(
+ [
+ Window(FormattedTextControl(left_text)),
+ Window(width=1, char="|"), # Vertical line in the middle.
+ Window(FormattedTextControl(right_text)),
+ ]
+)
+
+
+# 2. Key bindings
+kb = KeyBindings()
+
+
+@kb.add("q")
+def _(event):
+ "Quit application."
+ event.app.exit()
+
+
+# 3. The `Application`
+application = Application(layout=Layout(body), key_bindings=kb, full_screen=True)
+
+
+def run():
+ application.run()
+
+
+if __name__ == "__main__":
+ run()