Velocity/mode/command.py

33 lines
843 B
Python
Raw Normal View History

2022-03-19 15:13:28 +00:00
from core import utils
def execute(instance, commands):
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:
# Write
if command == "w":
# Write to the file
pass
2022-03-19 15:13:28 +00:00
2022-03-19 15:41:40 +00:00
# Quit
elif command == "q":
# Load a goodbye prompt
utils.goodbye(instance)
2022-03-19 15:13:28 +00:00
2022-03-19 15:41:40 +00:00
# Unknown command
else:
utils.error(instance, f"not an editor 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"