# Path: cemu/utils.py
# def format_address(addr, mode):
#     if mode.ptrsize == 2:
#         return "%#.4x" % (addr & 0xFFFF)
#     elif mode.ptrsize == 4:
#         return "%#.8x" % (addr & 0xFFFFFFFF)
#     elif mode.ptrsize == 8:
#         return "%#.16x" % (addr & 0xFFFFFFFFFFFFFFFF)


from typing import Dict
from PyQt5.QtWidgets import (
    QVBoxLayout,
    QHBoxLayout,
    QTableWidget,
    QLabel,
    QTableWidgetItem,
    QWidget,
    QDockWidget,
)
from PyQt5.QtGui import(
    QFont,
    QColor
)
from PyQt5.QtCore import (
    Qt,
    pyqtSignal,
    QEvent,
)
from ..utils import format_address






class RegistersWidget(QDockWidget):

    refreshRegisterGridSignal = pyqtSignal()

    def __init__(self, parent, *args, **kwargs):
        super(RegistersWidget, self).__init__("Registers", parent)
        self.root = self.parentWidget()
        self.log = self.root.log
        self.emulator = self.root.emulator
        self.__row_size = 15
        self.__old_register_values = {}
        layout = QVBoxLayout()
        self.__values = QTableWidget(10, 2)
        self.__values.horizontalHeader().setStretchLastSection(True)

# Path: cemu/utils.py
# def format_address(addr, mode):
#     if mode.ptrsize == 2:
#         return "%#.4x" % (addr & 0xFFFF)
#     elif mode.ptrsize == 4:
#         return "%#.8x" % (addr & 0xFFFFFFFF)
#     elif mode.ptrsize == 8:
#         return "%#.16x" % (addr & 0xFFFFFFFFFFFFFFFF)


# Path: cemu/ui/registers.py
from typing import Dict
from PyQt5.QtWidgets import (
    QVBoxLayout,
    QHBoxLayout,
    QTableWidget,
    QLabel,
    QTableWidgetItem,
    QWidget,
    QDockWidget,
)
from PyQt5.QtGui import(
    QFont,
    QColor
)
from PyQt5.QtCore import (
    Qt,
    pyqtSignal,
    QEvent,
)
from ..utils import format_address







class RegistersWidget(QDockWidget):

    refreshRegisterGridSignal = pyqtSignal()

    def __init__(self, parent, *args, **kwargs):
        super(RegistersWidget, self).__init__("Registers", parent)
        self.root = self.parentWidget()
        self.log = self.root.log
        self.emulator = self.root.emulator
        self.__row_size = 15
        self.__old_register_values = {}
        layout = QVBoxLayout()
        self.__values = QTableWidget(10, 2)
        self.__values.horizontalHeader().setStretchLastSection(True)

        self.__values.setHorizontalHeaderLabels(["Register", "Value"])