mud/src/mudlib/commands/edit.py

29 lines
811 B
Python

"""Edit command for entering the text editor."""
from mudlib.commands import CommandDefinition, register
from mudlib.editor import Editor
from mudlib.player import Player
async def cmd_edit(player: Player, args: str) -> None:
"""Enter the text editor.
Args:
player: The player executing the command
args: Command arguments (unused for now)
"""
async def save_callback(content: str) -> None:
await player.send("Content saved.\r\n")
player.editor = Editor(
save_callback=save_callback,
content_type="text",
color_depth=player.color_depth,
)
player.mode_stack.append("editor")
await player.send("Entering editor. Type :h for help.\r\n")
# Register the edit command
register(CommandDefinition("edit", cmd_edit, mode="normal"))