# Path: androguard/core/bytecodes/dvm_types.py
# class Kind(IntEnum):
#     """
#     This Enum is used to determine the kind of argument
#     inside an Dalvik instruction.
# 
#     It is used to reference the actual item instead of the refernece index
#     from the :class:`ClassManager` when disassembling the bytecode.
#     """
#     # Indicates a method reference
#     METH = 0
#     # Indicates that opcode argument is a string index
#     STRING = 1
#     # Indicates a field reference
#     FIELD = 2
#     # Indicates a type reference
#     TYPE = 3
#     # indicates a prototype reference
#     PROTO = 9
#     # indicates method reference and proto reference (invoke-polymorphic)
#     METH_PROTO = 10
#     # indicates call site item
#     CALL_SITE = 11
# 
#     # TODO: not very well documented
#     VARIES = 4
#     # inline lined stuff
#     INLINE_METHOD = 5
#     # static linked stuff
#     VTABLE_OFFSET = 6
#     FIELD_OFFSET = 7
#     RAW_STRING = 8
# 
# class Operand(IntEnum):
#     """
#     Enumeration used for the operand type of opcodes
#     """
#     REGISTER = 0
#     LITERAL = 1
#     RAW = 2
#     OFFSET = 3
#     # FIXME: KIND is used in combination with others, ie the Kind enum, therefore it is 0x100...
#     # thus we could use an IntFlag here as well
#     KIND = 0x100
# 
# Path: androguard/gui/cemu.py
# class Cursor:
# class ConsoleEmulator:
#     def __init__(self, x, y):
#     def move(self, dx, dy):
#     def moveAbsolute(self, x, y):
#     def getPosition(self):
# def enum(**enums):
#     def __init__(self, qp, rows, cols):
#     def incrementPosition(self):
#     def newLine(self):
#     def LF(self):
#     def CR(self):
#     def _validatePosition(self, x, y):
#     def write(self, s, noBackgroudOnSpaces=False):
#     def write_c(self, c, noBackgroudOnSpaces=False):
#     def getXY(self):
#     def writeAt(self, x, y, s, noBackgroudOnSpaces=False):
#     def writeAt_c(self, x, y, c, noBackgroudOnSpaces=False):
#     def writeLn(self):
#     def gotoXY(self, x, y):


from PyQt5 import QtGui, QtCore
from androguard.core.bytecodes.dvm_types import Kind, Operand
from androguard.gui import TextSelection
from androguard.gui.ViewMode import ViewMode
from androguard.gui.cemu import ConsoleEmulator, Directions
import logging

            if dy < 0:
                tsize = sum([asm.get_length() for asm in self.OPCODES])

                if self.dataModel.getOffset() + tsize == self.dataModel.getDataSize():
                    log.debug('END')
                    return

            self.scroll_v(dy, cachePix, pageOffset)

    def moveCursor(self, direction):
        cursorX, cursorY = self.cursor.getPosition()

        if direction == Directions.Left:
            asm = self.OPCODES[cursorY]

            if cursorX == 0:
                if cursorY == 0:
                    # if first line, scroll
                    self.scroll(0, 1)
                    self.cursor.moveAbsolute(0, 0)
                else:
                    # move to last token from previous line
                    asm_prev = self.OPCODES[cursorY - 1]
                    idx = asm_prev.getEndCursor()
                    self.cursor.moveAbsolute(idx, cursorY - 1)
            else:
                x, dy = asm.getNextCursor(cursorX, direction=Directions.Left)
                self.cursor.move(-(cursorX - x), dy)


# Path: androguard/core/bytecodes/dvm_types.py
# class Kind(IntEnum):
#     """
#     This Enum is used to determine the kind of argument
#     inside an Dalvik instruction.
# 
#     It is used to reference the actual item instead of the refernece index
#     from the :class:`ClassManager` when disassembling the bytecode.
#     """
#     # Indicates a method reference
#     METH = 0
#     # Indicates that opcode argument is a string index
#     STRING = 1
#     # Indicates a field reference
#     FIELD = 2
#     # Indicates a type reference
#     TYPE = 3
#     # indicates a prototype reference
#     PROTO = 9
#     # indicates method reference and proto reference (invoke-polymorphic)
#     METH_PROTO = 10
#     # indicates call site item
#     CALL_SITE = 11
# 
#     # TODO: not very well documented
#     VARIES = 4
#     # inline lined stuff
#     INLINE_METHOD = 5
#     # static linked stuff
#     VTABLE_OFFSET = 6
#     FIELD_OFFSET = 7
#     RAW_STRING = 8
# 
# class Operand(IntEnum):
#     """
#     Enumeration used for the operand type of opcodes
#     """
#     REGISTER = 0
#     LITERAL = 1
#     RAW = 2
#     OFFSET = 3
#     # FIXME: KIND is used in combination with others, ie the Kind enum, therefore it is 0x100...
#     # thus we could use an IntFlag here as well
#     KIND = 0x100
# 
# Path: androguard/gui/cemu.py
# class Cursor:
# class ConsoleEmulator:
#     def __init__(self, x, y):
#     def move(self, dx, dy):
#     def moveAbsolute(self, x, y):
#     def getPosition(self):
# def enum(**enums):
#     def __init__(self, qp, rows, cols):
#     def incrementPosition(self):
#     def newLine(self):
#     def LF(self):
#     def CR(self):
#     def _validatePosition(self, x, y):
#     def write(self, s, noBackgroudOnSpaces=False):
#     def write_c(self, c, noBackgroudOnSpaces=False):
#     def getXY(self):
#     def writeAt(self, x, y, s, noBackgroudOnSpaces=False):
#     def writeAt_c(self, x, y, c, noBackgroudOnSpaces=False):
#     def writeLn(self):
#     def gotoXY(self, x, y):


# Path: androguard/gui/DisasmViewMode.py
from PyQt5 import QtGui, QtCore
from androguard.core.bytecodes.dvm_types import Kind, Operand
from androguard.gui import TextSelection
from androguard.gui.ViewMode import ViewMode
from androguard.gui.cemu import ConsoleEmulator, Directions
import logging


            if dy < 0:
                tsize = sum([asm.get_length() for asm in self.OPCODES])

                if self.dataModel.getOffset() + tsize == self.dataModel.getDataSize():
                    log.debug('END')
                    return

            self.scroll_v(dy, cachePix, pageOffset)

    def moveCursor(self, direction):
        cursorX, cursorY = self.cursor.getPosition()

        if direction == Directions.Left:
            asm = self.OPCODES[cursorY]

            if cursorX == 0:
                if cursorY == 0:
                    # if first line, scroll
                    self.scroll(0, 1)
                    self.cursor.moveAbsolute(0, 0)
                else:
                    # move to last token from previous line
                    asm_prev = self.OPCODES[cursorY - 1]
                    idx = asm_prev.getEndCursor()
                    self.cursor.moveAbsolute(idx, cursorY - 1)
            else:
                x, dy = asm.getNextCursor(cursorX, direction=Directions.Left)
                self.cursor.move(-(cursorX - x), dy)


        if direction == Directions.Right: