Velocity/mode/command.py

36 lines
1.1 KiB
Python
Raw Normal View History

2022-03-19 15:13:28 +00:00
from core import utils
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:
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
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)}")
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
else: # Invalid command
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"