google / ci_edit

A terminal text editor with mouse support and ctrl+Q to quit.
Apache License 2.0
223 stars 54 forks source link

Confirmation on quit #185

Open shubhodeep9 opened 5 years ago

shubhodeep9 commented 5 years ago

Note: This is a possible suggestion.

Suggestion: It can wait for user to hit enter after writing the command, gives a bit more subtlety.

adityaxdiwakar commented 5 years ago

The way that the confirmation models are made, this isn't possible (as far as I can see):

Here's the snippet of code that strictly deals with the confirmations for closing:

class ConfirmClose(app.controller.Controller):
    """Ask about closing a file with unsaved changes."""

    def __init__(self, view):
        app.controller.Controller.__init__(self, view, 'confirmClose')

    def setTextBuffer(self, textBuffer):
        app.controller.Controller.setTextBuffer(self, textBuffer)
        commandSet = initCommandSet(self, textBuffer)
        commandSet.update({
            ord('n'): self.closeFile,
            ord('N'): self.closeFile,
            ord('y'): self.saveOrChangeToSaveAs,
            ord('Y'): self.saveOrChangeToSaveAs,
        })
        self.commandSet = commandSet
        self.commandDefault = self.confirmationPromptFinish

As you can see, it's looking for only n, N, y, or Y and this is the same for many other parts of the program, so adding a confirmation model would require a rewrite of all this, albeit still possible.