Velocity/mode/command.py

38 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):
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
elif command == "d":
# Load a prompt with debug info
utils.prompt(instance, f"Cursor: {instance.cursor} | Raw: {instance.raw_cursor} | Len: {len(instance.buffer.data)}")
utils.prompt(instance, f"{len(instance.buffer.data[6])}")
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"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"