Enhance CLI layout with floating completion menu
- Updated the layout in HermesCLI to include a floating completion menu, improving user experience by providing real-time suggestions as users type. - Refactored the layout structure to utilize FloatContainer, ensuring the input area remains accessible while displaying the completion menu dynamically.
This commit is contained in:
parent
50ef18644b
commit
225ae32e7a
1 changed files with 17 additions and 7 deletions
18
cli.py
18
cli.py
|
|
@ -32,8 +32,9 @@ from prompt_toolkit.history import FileHistory
|
||||||
from prompt_toolkit.styles import Style as PTStyle
|
from prompt_toolkit.styles import Style as PTStyle
|
||||||
from prompt_toolkit.patch_stdout import patch_stdout
|
from prompt_toolkit.patch_stdout import patch_stdout
|
||||||
from prompt_toolkit.application import Application
|
from prompt_toolkit.application import Application
|
||||||
from prompt_toolkit.layout import Layout, HSplit, Window, FormattedTextControl
|
from prompt_toolkit.layout import Layout, HSplit, Window, FormattedTextControl, Float, FloatContainer
|
||||||
from prompt_toolkit.layout.dimension import Dimension
|
from prompt_toolkit.layout.dimension import Dimension
|
||||||
|
from prompt_toolkit.layout.menus import CompletionsMenu
|
||||||
from prompt_toolkit.widgets import TextArea
|
from prompt_toolkit.widgets import TextArea
|
||||||
from prompt_toolkit.key_binding import KeyBindings
|
from prompt_toolkit.key_binding import KeyBindings
|
||||||
from prompt_toolkit.completion import Completer, Completion
|
from prompt_toolkit.completion import Completer, Completion
|
||||||
|
|
@ -1654,13 +1655,22 @@ class HermesCLI:
|
||||||
height=get_hint_height,
|
height=get_hint_height,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Layout with dynamic spacer and input at bottom
|
# Layout with dynamic spacer, input at bottom, and floating completion menu
|
||||||
layout = Layout(
|
layout = Layout(
|
||||||
HSplit([
|
FloatContainer(
|
||||||
|
content=HSplit([
|
||||||
Window(height=0), # Expands to push everything to bottom
|
Window(height=0), # Expands to push everything to bottom
|
||||||
spacer,
|
spacer,
|
||||||
input_area,
|
input_area,
|
||||||
])
|
]),
|
||||||
|
floats=[
|
||||||
|
Float(
|
||||||
|
xcursor=True,
|
||||||
|
ycursor=True,
|
||||||
|
content=CompletionsMenu(max_height=12, scroll_offset=1),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Style for the application
|
# Style for the application
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue