Velocity/mode/normal.py

42 lines
1.1 KiB
Python
Raw Normal View History

2022-03-19 15:13:28 +00:00
from core import cursors, modes
from mode import insert
from mode import command
def execute(instance, key):
if key == ord("j"):
# Move the cursor down
instance.cursor = cursors.cursor_push(instance.cursor, "down")
elif key == ord("k"):
# Move the cursor up
instance.cursor = cursors.cursor_push(instance.cursor, "up")
elif key == ord("l"):
# Move the cursor right
instance.cursor = cursors.cursor_push(instance.cursor, "right")
elif key == ord("h"):
# Move the cursor left
instance.cursor = cursors.cursor_push(instance.cursor, "left")
elif key == ord("i"):
# Activate insert mode
2022-03-19 15:41:40 +00:00
modes.activate(instance, "insert")
2022-03-19 15:13:28 +00:00
elif key == ord("I"):
# Move the cursor to the right
instance.cursor = cursors.cursor_push(instance.cursor, "right")
# Then activate insert mode
2022-03-19 15:41:40 +00:00
modes.activate(instance, "insert")
2022-03-19 15:13:28 +00:00
elif key in (ord(":"), ord(";")):
# Activate command mode
2022-03-19 15:41:40 +00:00
modes.activate(instance, "command")
2022-03-19 15:13:28 +00:00
2022-03-19 15:41:40 +00:00
def activate():
2022-03-19 15:13:28 +00:00
# Switch the cursor to a block
cursors.cursor_mode("block")