# 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:
                RowsToDraw.append((-row - 1, newins))

        log.debug('ROW TO DRAW %s', RowsToDraw)
        if len(RowsToDraw) < abs(dy):
            # maybe we couldn't draw dy rows (possible we reached the beginning of the data to early), recalculate dy
            dy = len(RowsToDraw) * dy / abs(dy)
            factor = abs(dy)

        if not cachePix:
            self.qpix.scroll(0, dy * self.fontHeight, self.qpix.rect())

        qp = QtGui.QPainter()
        if cachePix:
            qp.begin(cachePix)
        else:
            qp.begin(self.qpix)

        qp.setFont(self.font)
        qp.setPen(self.textPen)

        # erase rows that will disappear
        if dy < 0:
            qp.fillRect(0, (self.ROWS - factor) * self.fontHeight, self.fontWidth * self.COLUMNS,
                        factor * self.fontHeight, self.backgroundBrush)

        if dy > 0:
            qp.fillRect(0, 0, self.fontWidth * self.COLUMNS, factor * self.fontHeight, self.backgroundBrush)


# 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:
                RowsToDraw.append((-row - 1, newins))

        log.debug('ROW TO DRAW %s', RowsToDraw)
        if len(RowsToDraw) < abs(dy):
            # maybe we couldn't draw dy rows (possible we reached the beginning of the data to early), recalculate dy
            dy = len(RowsToDraw) * dy / abs(dy)
            factor = abs(dy)

        if not cachePix:
            self.qpix.scroll(0, dy * self.fontHeight, self.qpix.rect())

        qp = QtGui.QPainter()
        if cachePix:
            qp.begin(cachePix)
        else:
            qp.begin(self.qpix)

        qp.setFont(self.font)
        qp.setPen(self.textPen)

        # erase rows that will disappear
        if dy < 0:
            qp.fillRect(0, (self.ROWS - factor) * self.fontHeight, self.fontWidth * self.COLUMNS,
                        factor * self.fontHeight, self.backgroundBrush)

        if dy > 0:
            qp.fillRect(0, 0, self.fontWidth * self.COLUMNS, factor * self.fontHeight, self.backgroundBrush)


        cemu = ConsoleEmulator(qp, self.ROWS, self.COLUMNS)