Skip to content

Customise keybinds/text for window close confirmation #4545

@cwqt

Description

@cwqt

Is your feature request related to a problem? Please describe.
I use confirm_os_window_close -1 to stop myself from accidentally closing windows while in vim. To cancel/confirm you have to either press y/n which are a bit out of the way.

Describe the solution you'd like
It'd be great if there was an option to rebind these to enter/escape (or any other keys really) for faster confirm/cancelling.

Something like this?

def confirm(
    self,
    msg: str,
    callback: Callable[..., None],
    *args: Any,
    window: Optional[Window] = None,
    confirm_on_cancel: bool = False
) -> None:
    confirm_key = self.confirm_os_window_close_confirm_key or 'y'
    cancel_key = self.confirm_os_window_close_cancel_key or 'n'

    def callback_(res: Dict[str, Any], x: int, boss: Boss) -> None:
        callback(res.get("response") == confirm_key, *args)

    self._run_kitten(
        "ask",
        ["--type=yesno", "--message", msg],
        window=window,
        custom_callback=callback_,
        default_data={"response": confirm_key if confirm_on_cancel else cancel_key},
    )

def confirm(self, msg: str, callback: Callable[..., None], *args: Any,

I'm not so much fussed about faster confirming and more for the faster cancelling, since the context switch can be a bit annoying.


It'd also be neat if there was a way to customise the text shown in the window, since with no terminal padding it gets a bit clipped - I'd just add a \n and some spaces to shift the message a bit more down & to the right -- maybe a confirm_os_window_close_padding yes?

image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions