diff --git a/core/utils.py b/core/utils.py index f7553f5..f5f02a8 100644 --- a/core/utils.py +++ b/core/utils.py @@ -186,10 +186,22 @@ def fatal_error(exception: Exception): def goodbye(instance): - choice = prompt(instance, "Really quit lambda? (y/n): ", 11) - if choice and choice[0] == "y": - curses.endwin() - sys.exit() + try: + # Confirm before exiting + choice = prompt(instance, "Really quit lambda? (y/n): ", 11) - else: - clear(instance, instance.height - 1, 0) + # If the user confirms, exit + if choice and choice[0] == "y": + gracefully_exit() + + # Clear the prompt if the user cancels + else: + clear(instance, instance.height - 1, 0) + + except KeyboardInterrupt: + # If the user presses Ctrl+C, just exit + gracefully_exit() + + except Exception as exception: + # If there is an error, print the error message and traceback + fatal_error(exception) diff --git a/install.sh b/install.sh index ab5886f..411b20a 100755 --- a/install.sh +++ b/install.sh @@ -1,12 +1,8 @@ #!/bin/sh # Copy lambda to ~/.local/share -rm -rf ~/.local/share/lambda -ln -sf "$(pwd)" ~/.local/share/lambda - -# Copy lambda to ~/.local/share -#mkdir -p ~/.local/share/lambda -#cp -rf . ~/.local/share/lambda +mkdir -p ~/.local/share/lambda +cp -rf . ~/.local/share/lambda # Copy lambda launcher chmod +x ./lambda diff --git a/main.py b/main.py index cc49725..df1fbc2 100644 --- a/main.py +++ b/main.py @@ -99,15 +99,15 @@ def main(): config = utils.load_config() # Load lambda with the buffer object - screen = Lambda(buffer, config) + instance = Lambda(buffer, config) # Start the screen, this will loop until exit try: - screen.start() + instance.start() # KeyboardInterrupt is thrown when is pressed (exit) except KeyboardInterrupt: - utils.gracefully_exit() + utils.goodbye(instance) # Excepts *any* errors that occur except Exception as exception: