Skip to content

Commit

Permalink
Added command to remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
robmcmullen committed Apr 11, 2016
1 parent 7dac118 commit 24ad132
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
33 changes: 33 additions & 0 deletions omnivore/tasks/hex_edit/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion omnivore/tasks/hex_edit/grid_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
1 change: 1 addition & 0 deletions omnivore/tasks/hex_edit/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def get_actions_Menu_Segments_SegmentParserGroup(self):
MarkSelectionAsCodeAction(),
MarkSelectionAsDataAction(),
AddCommentAction(),
RemoveCommentAction(),
]

def get_actions_Menu_Segments_SegmentGroup(self):
Expand Down

0 comments on commit 24ad132

Please sign in to comment.