35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
"""Guarded chat input for the owned native test runner.
|
|
|
|
This tracks incomplete edits across an explicit queue pause/resume. It never
|
|
replays text and does not claim that a closed edit proves server delivery.
|
|
"""
|
|
|
|
|
|
class OwnedChatInput:
|
|
def __init__(self, ui):
|
|
self.ui = ui
|
|
self.partial = False
|
|
|
|
def send(self, display, window, text, *, paste=None):
|
|
ui = self.ui
|
|
ui.ensure_focus(display, window)
|
|
# A previous failure may have left command text in the native EditBox.
|
|
# Cancel before Return so it cannot submit an unrelated stale command.
|
|
if self.partial or ui.chat_edit_open(display, window):
|
|
self.partial = True
|
|
ui.key(display, 'Escape')
|
|
ui.wait_chat_edit(display, window, False)
|
|
self.partial = False
|
|
# Keep the incomplete state on any failure, including failure to open.
|
|
self.partial = True
|
|
ui.key(display, 'Return')
|
|
ui.wait_chat_edit(display, window, True)
|
|
ui.clear_edit_selection(display)
|
|
if paste is None:
|
|
ui.type_text(display, text)
|
|
else:
|
|
paste(text)
|
|
ui.key(display, 'Return')
|
|
ui.wait_chat_edit(display, window, False)
|
|
self.partial = False
|