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
def open_textbox(self, screen, text): from reverse.lib.ui.inlineed import InlineEd (h, w) = screen.getmaxyx() ed = InlineEd(self, h, w, 0, 0, 0, text, True, 0, [], do_nothing=True) # TODO: fix self.cursor_x >= w self.cursor_x = len(text) if self.cursor_x >= w: self.cursor_x = w - 1 ed.print_curr_line = False ret = ed.start_view(screen) if not ret: return "" return "".join(ed.text)