# Path: vii/AbstractAction.py
# class AbstractAction:
#     def act(self, callback = None): pass
# 
#     def finish(self):
#         self.dispatcher.logHistory()
#         self.dispatcher.reset()
# 
#     def skipToIdle(self):
#         self.finish()
#         return "normal", self.actionManager.action("normal", "idle")
# 
#     def moveAndFinshToIdle(self, motion):
#         if motion: motion = motion.forceLimits()
#         self.cursor.move(motion)
#         self.finish()
#         return "normal", self.actionManager.action("normal", "idle")
# 
#     def deleteAndRegister(self, motion):
#         string = self.buffer.delete(motion)
#         self.registerManager.shift(string, motion.isLines())
# 
# Path: vii/Range.py
# class Position(Range):
#     def __init__(self, x, y):
#         super().__init__(x, y, isPosition = True)


from .Logger import *
from .AbstractAction import AbstractAction
from .Range import Position
import importlib
    def __init__(self):
        self.dispatcher = None
        self.windowManager =  None
        self.registerManager = None
        self.actionMaps = dict()

    def addMap(self, mode, map):
        self.actionMaps[mode] = self.parseMap(map)

    def action(self, mode, operator):
        try:
            action = self.actionMaps[mode][operator]
            moduleName, className = action.rsplit(".", 1)
            Action = getattr(
                importlib.import_module(moduleName),
                className)
            action = Action()
        except KeyError:
            debug("Key Error: %s %s" % (mode, operator))
            self.dispatcher.reset()
            action = DummyAction()
        action.dispatcher = self.dispatcher
        action.command = self.dispatcher.currentCommand
        action.windowManager = self.windowManager
        action.actionManager = self
        action.registerManager = self.registerManager
        action.globalVariables = self.globalVariables
        if mode == "command":
            action.window = self.windowManager.commandLine
            action.window.buffer.insert(Position(1,1), "\n")

# Path: vii/AbstractAction.py
# class AbstractAction:
#     def act(self, callback = None): pass
# 
#     def finish(self):
#         self.dispatcher.logHistory()
#         self.dispatcher.reset()
# 
#     def skipToIdle(self):
#         self.finish()
#         return "normal", self.actionManager.action("normal", "idle")
# 
#     def moveAndFinshToIdle(self, motion):
#         if motion: motion = motion.forceLimits()
#         self.cursor.move(motion)
#         self.finish()
#         return "normal", self.actionManager.action("normal", "idle")
# 
#     def deleteAndRegister(self, motion):
#         string = self.buffer.delete(motion)
#         self.registerManager.shift(string, motion.isLines())
# 
# Path: vii/Range.py
# class Position(Range):
#     def __init__(self, x, y):
#         super().__init__(x, y, isPosition = True)


# Path: vii/ActionManager.py
from .Logger import *
from .AbstractAction import AbstractAction
from .Range import Position
import importlib

    def __init__(self):
        self.dispatcher = None
        self.windowManager =  None
        self.registerManager = None
        self.actionMaps = dict()

    def addMap(self, mode, map):
        self.actionMaps[mode] = self.parseMap(map)

    def action(self, mode, operator):
        try:
            action = self.actionMaps[mode][operator]
            moduleName, className = action.rsplit(".", 1)
            Action = getattr(
                importlib.import_module(moduleName),
                className)
            action = Action()
        except KeyError:
            debug("Key Error: %s %s" % (mode, operator))
            self.dispatcher.reset()
            action = DummyAction()
        action.dispatcher = self.dispatcher
        action.command = self.dispatcher.currentCommand
        action.windowManager = self.windowManager
        action.actionManager = self
        action.registerManager = self.registerManager
        action.globalVariables = self.globalVariables
        if mode == "command":
            action.window = self.windowManager.commandLine
            action.window.buffer.insert(Position(1,1), "\n")

            action.window.cursor.move(Position(1,0))