richpl / PyBasic

Simple interactive BASIC interpreter written in Python
GNU General Public License v3.0
165 stars 45 forks source link

Ctrl-D improvement suggestion #17

Closed nerun closed 3 years ago

nerun commented 3 years ago

Hi again,

I know there is an "exit" command, but Ctrl-D is frequently used as an exit. You could add an extra try/except:

interpreter.py:

while True:
    stmt = input('> ')

Typical exit with Ctrl-D: ctrld

For a beautiful exit:

while True:
    try:
        stmt = input('> ')
    except EOFError:
        print("")
        quit()
JiFish commented 3 years ago

As an alternative you can use Ctrl-C to exit the interpreter in the same way as breaking a program.

richpl commented 3 years ago

Apologies for not replying sooner @Nerun about this. I quite obsessive about developing this software when I worked on it a couple if years ago, but haven't really returned to it since except to process PRs. But it's a good idea, I might add it at some point.