コード例 #1
0
ファイル: decompiler.py プロジェクト: iGio90/r2dwarf
 def __init__(self, parent=None, debug_panel=None):
     super().__init__(parent=parent)
     self._debug_panel = debug_panel
     self.setStyleSheet('a { color: #666; text-decoration: none; }')
     self.setLineWrapMode(0)
     self.setFont(utils.get_os_monospace_font())
     self.setReadOnly(True)
コード例 #2
0
    def __init__(self,
                 parent=None,
                 input_placeholder='',
                 function_box=False,
                 has_input=True,
                 completer=True):
        super().__init__(parent=parent)

        self.app_window = parent

        layout = QVBoxLayout()

        self.function_content = ''
        self.script_file = None

        self.setContentsMargins(QMargins(0, 0, 0, 0))
        layout.setContentsMargins(QMargins(0, 0, 0, 0))

        # use textedit to allow copy contents
        self.output = QPlainTextEdit()
        self.output.setFont(get_os_monospace_font())
        self.output.setReadOnly(True)
        self.output.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        layout.addWidget(self.output)

        if has_input:
            box = QHBoxLayout()
            box.setContentsMargins(QMargins(3, 3, 3, 3))

            self.input = DwarfConsoleInput(self, completer=completer)
            self.input.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
            self.input.setPlaceholderText(input_placeholder)
            self.input.onEnterKeyPressed.connect(self._enter_pressed)
            box.addWidget(self.input)

            if function_box:
                function_btn = QPushButton('ƒ')
                function_btn.setMinimumWidth(25)
                function_btn.clicked.connect(self.js_function_box)
                box.addWidget(function_btn)

            box_widget = QWidget()
            box_widget.setLayout(box)
            layout.addWidget(box_widget)

        self.setLayout(layout)
コード例 #3
0
    def __init__(self, parent=None):
        super(JavaTraceView, self).__init__(parent=parent)

        self.data = []
        self.search_result = []

        # setting font
        self.font = utils.get_os_monospace_font()
        self.font.setFixedPitch(True)
        self.setFont(self.font)

        self._char_width = self.fontMetrics().width("2")
        self._char_height = self.fontMetrics().height()
        self._base_line = self.fontMetrics().ascent()
        self._has_scrolled = False

        self._data_height = 0

        self.verticalScrollBar().rangeChanged.connect(self._scroll_bottom)
        self.verticalScrollBar().valueChanged.connect(self._check_scroll)
コード例 #4
0
ファイル: code_editor.py プロジェクト: xiaobfly/Dwarf
    def __init__(self, parent=None, show_linenumes=False, completer=True):
        super(JsCodeEditor, self).__init__(parent)

        self.setFont(get_os_monospace_font())

        self._show_linenums = show_linenumes

        keywords = []
        keywords_path = home_path() + 'keywords.json'
        if os.path.exists(keywords_path):
            with open(keywords_path, 'r') as f:
                try:
                    keywords = json.load(f)
                except:
                    pass

        if self._show_linenums:
            self.ui_line_numbers = JsCodeEditLineNums(self)
            self.blockCountChanged.connect(self.update_linenum_width)
            self.updateRequest.connect(self.update_line_numbers)
            self.update_linenum_width(0)

        self.setAutoFillBackground(True)
        # default distance is 80
        self.setTabStopDistance(self.fontMetrics().width('9999'))

        self.highlighter = JsHighlighter(keywords, parent=self.document())

        if completer:
            # code completion
            self.completer = DwarfCompleter(keywords)
            self.completer.setWidget(self)
            self.completer.setCompletionMode(QCompleter.PopupCompletion)
            self.completer.setCaseSensitivity(Qt.CaseInsensitive)
            self.completer.insertText.connect(self.insertCompletion)
        else:
            self.completer = None
コード例 #5
0
    def __init__(self, parent=None):
        super(DisassemblyView, self).__init__(parent=parent)

        _prefs = Prefs()
        self._uppercase_hex = (_prefs.get('dwarf_ui_hexstyle',
                                          'upper').lower() == 'upper')

        self._app_window = parent
        self.debug_panel = None

        self.setAutoFillBackground(True)
        self._running_disasm = False

        # setting font
        self.font = utils.get_os_monospace_font()
        self.font.setFixedPitch(True)
        self.setFont(self.font)

        self._char_width = QFontMetricsF(self.font).width(
            '#')  # self.fontMetrics().width("#")
        if (self._char_width % 1) < .5:
            self.font.setLetterSpacing(QFont.AbsoluteSpacing,
                                       -(self._char_width % 1.0))
            self._char_width -= self._char_width % 1.0
        else:
            self.font.setLetterSpacing(QFont.AbsoluteSpacing,
                                       1.0 - (self._char_width % 1.0))
            self._char_width += 1.0 - (self._char_width % 1.0)

        self._char_height = self.fontMetrics().height()
        self._base_line = self.fontMetrics().ascent()

        self._history = []
        self._lines = []
        self._longest_bytes = 0
        self._longest_mnemonic = 0

        self._ctrl_colors = {
            'background': QColor('#181818'),
            'foreground': QColor('#666'),
            'jump_arrows': QColor('#444'),
            'jump_arrows_hover': QColor('#ef5350'),
            'divider': QColor('#666'),
            'line': QColor('#111'),
            'selection_fg': QColor(Qt.white),
            'selection_bg': QColor('#630000')
        }

        self._jump_color = QColor('#39a')
        self._header_height = 0
        self._ver_spacing = 2

        self._dash_pen = QPen(self._ctrl_colors['jump_arrows'], 2.0,
                              Qt.DashLine)
        self._solid_pen = QPen(self._ctrl_colors['jump_arrows'], 2.0,
                               Qt.SolidLine)
        self._line_pen = QPen(self._ctrl_colors['divider'], 0, Qt.SolidLine)

        self._breakpoint_linewidth = 5
        self._jumps_width = 100

        self.setMouseTracking(True)
        self.current_jump = -1
        self._current_line = -1
        self._highlighted_line = -1

        self._display_jumps = True
        self._follow_jumps = True

        self.pos = 0