MCPcopy Index your code
hub / github.com/prompt-toolkit/ptpython / load_confirm_exit_bindings

Function load_confirm_exit_bindings

src/ptpython/key_bindings.py:280–307  ·  view source on GitHub ↗

Handle yes/no key presses when the exit confirmation is shown.

(python_input: PythonInput)

Source from the content-addressed store, hash-verified

278
279
280def load_confirm_exit_bindings(python_input: PythonInput) -> KeyBindings:
281 """
282 Handle yes/no key presses when the exit confirmation is shown.
283 """
284 bindings = KeyBindings()
285
286 handle = bindings.add
287 confirmation_visible = Condition(lambda: python_input.show_exit_confirmation)
288
289 @handle("y", filter=confirmation_visible)
290 @handle("Y", filter=confirmation_visible)
291 @handle("enter", filter=confirmation_visible)
292 @handle("c-d", filter=confirmation_visible)
293 def _(event: E) -> None:
294 """
295 Really quit.
296 """
297 event.app.exit(exception=EOFError, style="class:exiting")
298
299 @handle(Keys.Any, filter=confirmation_visible)
300 def _(event: E) -> None:
301 """
302 Cancel exit.
303 """
304 python_input.show_exit_confirmation = False
305 python_input.app.layout.focus_previous()
306
307 return bindings
308
309
310def auto_newline(buffer: Buffer) -> None:

Callers 1

_create_applicationMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected