2022-03-19 15:13:28 +00:00
|
|
|
from core import utils
|
|
|
|
|
|
|
|
|
2022-04-15 13:44:24 +01:00
|
|
|
def execute(instance, commands: list):
|
2022-03-19 15:41:40 +00:00
|
|
|
# Only if commands are given
|
|
|
|
if commands:
|
|
|
|
# Check each command in the list of commands
|
|
|
|
for command in commands:
|
2022-04-15 13:44:24 +01:00
|
|
|
if command == "w": # Write
|
2022-03-19 15:41:40 +00:00
|
|
|
# Write to the file
|
|
|
|
pass
|
2022-03-19 15:13:28 +00:00
|
|
|
|
2022-04-15 13:44:24 +01:00
|
|
|
if command == "d": # Debug
|
|
|
|
# Create the debug prompt
|
|
|
|
utils.prompt(instance, f"*Whawt awe uwu doing tuwu me mastew?* "
|
|
|
|
f"Cursor: {instance.cursor} Raw: {instance.raw_cursor} "
|
|
|
|
f"Len: {len(instance.buffer.data)}")
|
2022-04-14 18:24:45 +01:00
|
|
|
|
2022-04-15 13:44:24 +01:00
|
|
|
elif command == "q": # Quit
|
|
|
|
# Create a goodbye prompt
|
2022-03-19 15:41:40 +00:00
|
|
|
utils.goodbye(instance)
|
2022-03-19 15:13:28 +00:00
|
|
|
|
2022-04-15 13:44:24 +01:00
|
|
|
else: # Invalid command
|
2022-04-14 18:24:45 +01:00
|
|
|
utils.error(instance, f"invalid command: '{command}'")
|
2022-03-19 15:13:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
def activate(instance):
|
2022-03-19 15:41:40 +00:00
|
|
|
# Create a prompt, which returns the input (commands)
|
2022-03-19 15:13:28 +00:00
|
|
|
commands = utils.prompt(instance, ":")
|
|
|
|
|
2022-03-19 15:41:40 +00:00
|
|
|
# Execute the commands given
|
|
|
|
execute(instance, commands)
|
2022-03-19 15:13:28 +00:00
|
|
|
|
2022-03-19 15:41:40 +00:00
|
|
|
# Return to normal mode once all commands are executed
|
2022-03-19 15:13:28 +00:00
|
|
|
instance.mode = "normal"
|