コード例 #1
0
    def open_textbox(self, screen, text):
        # TODO : cleanup !!!!!
        from lib.ui.inlineed import InlineEd
        (h, w) = screen.getmaxyx()

        ed = InlineEd(self, h, w, 0, 0, 0, text, True, 0, [], do_nothing=True)
        ed.print_curr_line = False
        ret = ed.start_view(screen)
        if not ret:
            return ""
        return "".join(ed.text)
コード例 #2
0
ファイル: visual.py プロジェクト: cherry-wb/reverse
    def view_inline_comment_editor(self, h, w):
        line = self.win_y + self.cursor_y
        if line not in self.output.line_addr:
            return True

        addr = self.output.line_addr[line]

        # The same address can be repeated on multiple lines
        # With this we are sure to everytime on the same line
        # example for mips:
        #   # 0x4002bc: lui $gp, 0x19
        #   # 0x4002c0: addiu $gp, $gp, -0x63dc
        #   0x4002bc: li $gp, 0x189c24
        new_line = self.output.addr_line[addr]

        if new_line != line:
            self.goto_line(new_line, h)
            line = new_line
            (h, w) = self.screen.getmaxyx()
            self.view_main_redraw(h, w)

        # xbegin is the first index just after all operands
        # So we need to add 1 to be at the index of ;
        xbegin, idx_token = self.output.index_end_inst[line]

        self.status_bar("-- INLINE COMMENT --", h)

        if addr in self.dis.user_inline_comments:
            text = self.dis.user_inline_comments[addr]
        else:
            text = ""

        is_new_token = addr not in self.dis.user_inline_comments

        ed = InlineEd(self, h, w, line, xbegin, idx_token, text,
                      is_new_token, COLOR_USER_COMMENT.val,
                      self.token_lines[line], prefix="; ")

        ret = ed.start_view(self.screen)

        if ret:
            self.gctx.db.modified = True

            if ed.text:
                self.dis.user_inline_comments[addr] = ed.text
                if is_new_token:
                    self.output.index_end_inst[line] = \
                            (xbegin, idx_token)

            elif not is_new_token:
                del self.dis.user_inline_comments[addr]

        return True
コード例 #3
0
ファイル: window.py プロジェクト: cherry-wb/reverse
    def open_textbox(self, screen, text):
        # TODO : cleanup !!!!!
        from lib.ui.inlineed import InlineEd
        (h, w) = screen.getmaxyx()

        ed = InlineEd(self, h, w, 0, 0, 0, text,
                      True, 0, [], do_nothing=True)
        ed.print_curr_line = False
        ret = ed.start_view(screen)
        if not ret:
            return ""
        return "".join(ed.text)
コード例 #4
0
ファイル: visual.py プロジェクト: zhangf911/reverse
    def view_inline_comment_editor(self, h, w):
        line = self.win_y + self.cursor_y
        if line not in self.output.line_addr:
            return True

        addr = self.output.line_addr[line]

        # The same address can be repeated on multiple lines
        # With this we are sure to everytime on the same line
        # example for mips:
        #   # 0x4002bc: lui $gp, 0x19
        #   # 0x4002c0: addiu $gp, $gp, -0x63dc
        #   0x4002bc: li $gp, 0x189c24
        new_line = self.output.addr_line[addr]

        if new_line != line:
            self.goto_line(new_line, h)
            line = new_line
            (h, w) = self.screen.getmaxyx()
            self.view_main_redraw(h, w)

        # xbegin is the first index just after all operands
        # So we need to add 1 to be at the index of ;
        xbegin, idx_token = self.output.index_end_inst[line]

        self.status_bar("-- INLINE COMMENT --", h)

        if addr in self.dis.user_inline_comments:
            text = self.dis.user_inline_comments[addr]
        else:
            text = ""

        is_new_token = addr not in self.dis.user_inline_comments

        ed = InlineEd(self,
                      h,
                      w,
                      line,
                      xbegin,
                      idx_token,
                      text,
                      is_new_token,
                      COLOR_USER_COMMENT.val,
                      self.token_lines[line],
                      prefix="; ")

        ret = ed.start_view(self.screen)

        if ret:
            self.console.ctx.db.modified = True

            if ed.text:
                self.dis.user_inline_comments[addr] = ed.text
                if is_new_token:
                    self.output.index_end_inst[line] = \
                            (xbegin, idx_token)

            elif not is_new_token:
                del self.dis.user_inline_comments[addr]

        return True