diff --git a/omnivore/tasks/hex_edit/actions.py b/omnivore/tasks/hex_edit/actions.py index 4c62ba25..1bc98a75 100644 --- a/omnivore/tasks/hex_edit/actions.py +++ b/omnivore/tasks/hex_edit/actions.py @@ -456,6 +456,39 @@ def perform(self, event): desc = "Enter comment for location %s" % index if ranges: prompt_for_comment(e, s, ranges, desc) + +class RemoveCommentAction(EditorAction): + name = 'Remove Comment' + accelerator = 'Ctrl+Alt+C' + + def perform(self, event): + e = self.active_editor + s = e.segment + if e.can_copy: + ranges = s.get_style_ranges(selected=True) + else: + index = e.cursor_index + ranges = [(index, index+1)] + if ranges: + s.clear_comment(ranges) + e.document.change_count += 1 + e.refresh_panes() + +class RemoveCommentPopupAction(EditorAction): + name = 'Remove Comment' + + def perform(self, event): + e = self.active_editor + s = e.segment + if event.popup_data["in_selection"]: + ranges = s.get_style_ranges(selected=True) + else: + index = event.popup_data["index"] + ranges = [(index, index+1)] + if ranges: + s.clear_comment(ranges) + e.document.change_count += 1 + e.refresh_panes() class DeleteUserSegmentAction(EditorAction): diff --git a/omnivore/tasks/hex_edit/grid_control.py b/omnivore/tasks/hex_edit/grid_control.py index c7df86a7..4c8ba362 100644 --- a/omnivore/tasks/hex_edit/grid_control.py +++ b/omnivore/tasks/hex_edit/grid_control.py @@ -235,4 +235,4 @@ def change_value(self, row, col, text): return False def get_popup_actions(self, r, c): - return [CutAction, CopyAction, PasteAction, None, SelectAllAction, SelectNoneAction, GetSegmentFromSelectionAction, MarkSelectionAsCodeAction, MarkSelectionAsDataAction, AddCommentPopupAction] + return [CutAction, CopyAction, PasteAction, None, SelectAllAction, SelectNoneAction, GetSegmentFromSelectionAction, MarkSelectionAsCodeAction, MarkSelectionAsDataAction, AddCommentPopupAction, RemoveCommentPopupAction] diff --git a/omnivore/tasks/hex_edit/task.py b/omnivore/tasks/hex_edit/task.py index c435a808..695dadf7 100644 --- a/omnivore/tasks/hex_edit/task.py +++ b/omnivore/tasks/hex_edit/task.py @@ -281,6 +281,7 @@ def get_actions_Menu_Segments_SegmentParserGroup(self): MarkSelectionAsCodeAction(), MarkSelectionAsDataAction(), AddCommentAction(), + RemoveCommentAction(), ] def get_actions_Menu_Segments_SegmentGroup(self):