From ab9e88bad5a4f940c13dc4b4ccbd2b7406b6e9ca Mon Sep 17 00:00:00 2001 From: spy Date: Wed, 16 Mar 2022 17:23:37 +0000 Subject: [PATCH] better buffer loading --- lambda.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lambda.py b/lambda.py index fabe9ba..e6a4a91 100755 --- a/lambda.py +++ b/lambda.py @@ -74,19 +74,26 @@ def start(stdscr, buffer_name, buffer_list): def main(): - parser = argparse.ArgumentParser(description="Process some integers.") + parser = argparse.ArgumentParser(description="Next generation hackable text editor for nerds.") parser.add_argument("file", metavar="file", type=str, nargs="?", - help="File to open") + help="The name of a file for lambda to open") args = parser.parse_args() # Check if a file name has been inputted if args.file: buffer_name = args.file - buffer_list = files.open_file(buffer_name) - # Convert each line into a list of lists with each element of the sublist representing one character - for index, line in enumerate(buffer_list): - buffer_list[index] = list(line) + # Only if the file exists + if os.path.exists(args.file): + # Load the file into the buffer + buffer_list = files.open_file(buffer_name) + + # Convert each line into a list of lists with each element of the sublist representing one character + for index, line in enumerate(buffer_list): + buffer_list[index] = list(line) + + else: + buffer_list = [[""]] else: buffer_name = "[No Name]"