diff --git a/modes/__pycache__/command.cpython-310.pyc b/modes/__pycache__/command.cpython-310.pyc deleted file mode 100644 index 365f3f3..0000000 Binary files a/modes/__pycache__/command.cpython-310.pyc and /dev/null differ diff --git a/modes/__pycache__/command_mode.cpython-310.pyc b/modes/__pycache__/command_mode.cpython-310.pyc deleted file mode 100644 index b2ba55f..0000000 Binary files a/modes/__pycache__/command_mode.cpython-310.pyc and /dev/null differ diff --git a/modes/__pycache__/insert.cpython-310.pyc b/modes/__pycache__/insert.cpython-310.pyc deleted file mode 100644 index 8e3c4c6..0000000 Binary files a/modes/__pycache__/insert.cpython-310.pyc and /dev/null differ diff --git a/modes/__pycache__/normal.cpython-310.pyc b/modes/__pycache__/normal.cpython-310.pyc deleted file mode 100644 index cc97c67..0000000 Binary files a/modes/__pycache__/normal.cpython-310.pyc and /dev/null differ diff --git a/modes/command.py b/modes/command.py deleted file mode 100644 index a85f827..0000000 --- a/modes/command.py +++ /dev/null @@ -1,90 +0,0 @@ -from core import statusbar, utils -import curses - - -def execute(screen, data, commands): - if not commands: - # Quit if there are no commands, don't check anything - return data - - for command in commands: - if command == "w": - # Write to the file - pass - - elif command == "q": - # Goodbye prompt - utils.goodbye(screen, data) - - elif command == "t": - # Theme switcher - if data["statusbar_theme"] == "filled": - data["statusbar_theme"] = "bare" - - else: - data["statusbar_theme"] = "filled" - - else: - utils.error(screen, data, f"Not an editor command: '{command}'") - - return data - - -def activate(screen, data): - # Initialise variables - commands = [] - - # Visibly switch to command mode - statusbar.refresh(screen, data) - screen.addstr(data["height"]-1, 0, ":") - screen.move(data["height"]-1, 1) - - # Main loop - while True: - # Get a key inputted by the user - key = screen.getch() - - # Handle subtracting a key (backspace) - if key == curses.KEY_BACKSPACE: - # Write whitespace over characters to refresh it - screen.addstr(data["height"]-1, 1, " " * len(commands)) - - if commands: - # Subtract a character - commands.pop() - else: - # Exit command mode and enter normal mode if there is nothing left - data["mode"] = "normal" - return data - - elif key == 27: - # Exit command mode and enter normal mode if "esc" is pressed - data["mode"] = "normal" - return data - - elif key in (curses.KEY_ENTER, ord('\n'), ord('\r'), ord(":"), ord(";")): - # Execute commands - data = execute(screen, data, commands) - - # Clear the bottom bar - screen.addstr(data["height"] - 1, 0, " " * (data["width"] - 1)) - - # Return to normal mode after executing a command - data["mode"] = "normal" - return data - - else: - # If any other key is typed, append it - # As long as the key is in the valid list - valid = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ!" - if chr(key) in valid and len(commands) < (data["width"] - 2): - commands.append(chr(key)) - - # Join the commands together for visibility on the screen - friendly_command = "".join(commands) - - # Write the commands to the screen - screen.addstr(data["height"]-1, 1, friendly_command) - - # Move the cursor the end of the commands - screen.move(data["height"]-1, len(commands)+1) diff --git a/modes/insert.py b/modes/insert.py deleted file mode 100644 index 71f4252..0000000 --- a/modes/insert.py +++ /dev/null @@ -1,33 +0,0 @@ -from core import statusbar, cursor - - -def execute(data, key): - return data - - -def activate(screen, data): - # Refresh the status bar with a different colour for insert - data["statusbar_colors"] = [8, 12, 14, 2] - statusbar.refresh(screen, data) - - # Refresh the status bar - statusbar.refresh(screen, data) - - # Move the cursor - cursor.move(screen, data) - - # Switch to a line cursor - cursor.cursor_mode("line") - - # Wait for and capture a key press from the user - key = screen.getch() - - # Exit insert mode - if key == 27: - data["mode"] = "normal" - return data - - # Check keybindings - data = execute(data, key) - - return data diff --git a/modes/normal.py b/modes/normal.py deleted file mode 100644 index b727a59..0000000 --- a/modes/normal.py +++ /dev/null @@ -1,54 +0,0 @@ -from core import statusbar, cursor -import curses - - -def execute(data, key): - if key == ord("j"): - # Move the cursor down - data["cursor_y"] += 1 - - elif key == ord("k"): - # Move the cursor up - data["cursor_y"] -= 1 - - elif key == ord("l"): - # Move the cursor right - data["cursor_x"] += 1 - - elif key == ord("h"): - # Move the cursor left - data["cursor_x"] -= 1 - - elif key == ord("i"): - # Exit normal mode and enter insert mode - data["mode"] = "insert" - - elif key == ord("I"): - # Exit normal mode and enter insert mode - data["cursor_x"] += 1 - data["mode"] = "insert" - - elif key in (ord(":"), ord(";")): - # Exit normal mode and enter command mode - data["mode"] = "command" - - return data - - -def activate(screen, data): - # Refresh the status bar - statusbar.refresh(screen, data) - - # Move the cursor - cursor.move(screen, data) - - # Switch the cursor to a block - cursor.cursor_mode("block") - - # Wait for and capture a key press from the user - key = screen.getch() - - # Check against the keybindings - data = execute(data, key) - - return data