2022-03-19 15:13:28 +00:00
|
|
|
from core import cursors, modes
|
|
|
|
|
|
|
|
|
|
|
|
def execute(instance, key):
|
|
|
|
if key == ord("j"):
|
|
|
|
# Move the cursor down
|
2022-03-19 19:19:25 +00:00
|
|
|
cursors.push(instance, "down")
|
2022-03-19 15:13:28 +00:00
|
|
|
|
|
|
|
elif key == ord("k"):
|
|
|
|
# Move the cursor up
|
2022-03-19 19:19:25 +00:00
|
|
|
cursors.push(instance, "up")
|
2022-03-19 15:13:28 +00:00
|
|
|
|
|
|
|
elif key == ord("l"):
|
|
|
|
# Move the cursor right
|
2022-03-19 19:19:25 +00:00
|
|
|
cursors.push(instance, "right")
|
2022-03-19 15:13:28 +00:00
|
|
|
|
|
|
|
elif key == ord("h"):
|
|
|
|
# Move the cursor left
|
2022-03-19 19:19:25 +00:00
|
|
|
cursors.push(instance, "left")
|
2022-03-19 15:13:28 +00:00
|
|
|
|
|
|
|
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
|
2022-03-19 19:19:25 +00:00
|
|
|
cursors.push(instance, "right")
|
2022-03-19 15:13:28 +00:00
|
|
|
|
|
|
|
# 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
|
2022-03-19 19:19:25 +00:00
|
|
|
cursors.mode("block")
|