mirror of
https://github.com/meshcore-dev/meshcore-cli.git
synced 2026-04-20 22:13:48 +00:00
esc leaves completion
This commit is contained in:
parent
fcac20319f
commit
a2c6e55d68
1 changed files with 13 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ from prompt_toolkit.shortcuts import CompleteStyle
|
||||||
from prompt_toolkit.completion import NestedCompleter
|
from prompt_toolkit.completion import NestedCompleter
|
||||||
from prompt_toolkit.history import FileHistory
|
from prompt_toolkit.history import FileHistory
|
||||||
from prompt_toolkit.formatted_text import ANSI
|
from prompt_toolkit.formatted_text import ANSI
|
||||||
|
from prompt_toolkit.key_binding import KeyBindings
|
||||||
|
|
||||||
from meshcore import TCPConnection, BLEConnection, SerialConnection
|
from meshcore import TCPConnection, BLEConnection, SerialConnection
|
||||||
from meshcore import MeshCore, EventType, logger
|
from meshcore import MeshCore, EventType, logger
|
||||||
|
|
@ -227,6 +228,13 @@ Line starting with \"$\" or \".\" will issue a meshcli command.
|
||||||
mouse_support=True,
|
mouse_support=True,
|
||||||
complete_style=CompleteStyle.MULTI_COLUMN)
|
complete_style=CompleteStyle.MULTI_COLUMN)
|
||||||
|
|
||||||
|
bindings = KeyBindings()
|
||||||
|
|
||||||
|
# Add our own key binding.
|
||||||
|
@bindings.add("escape")
|
||||||
|
def _(event):
|
||||||
|
event.app.current_buffer.cancel_completion()
|
||||||
|
|
||||||
last_ack = True
|
last_ack = True
|
||||||
while True:
|
while True:
|
||||||
prompt = ""
|
prompt = ""
|
||||||
|
|
@ -237,7 +245,11 @@ Line starting with \"$\" or \".\" will issue a meshcli command.
|
||||||
if not process_event_message.color :
|
if not process_event_message.color :
|
||||||
prompt=escape_ansi(prompt)
|
prompt=escape_ansi(prompt)
|
||||||
|
|
||||||
line = await session.prompt_async(ANSI(prompt), complete_while_typing=False)
|
session.app.ttimeoutlen = 0.2
|
||||||
|
session.app.timeoutlen = 0.2
|
||||||
|
|
||||||
|
line = await session.prompt_async(ANSI(prompt), complete_while_typing=False,
|
||||||
|
key_bindings=bindings)
|
||||||
|
|
||||||
if line == "" : # blank line
|
if line == "" : # blank line
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue