Skip to content

Commit

Permalink
Comment actions now display correct labels instead of indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
robmcmullen committed Apr 11, 2016
1 parent 9c1be0c commit 25bdfa8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions omnivore/tasks/hex_edit/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,11 @@ def perform(self, event):
s = e.segment
if event.popup_data["in_selection"]:
ranges = s.get_style_ranges(selected=True)
desc = "Enter comment for range %s" % str(ranges)
desc = "Enter comment for range %s" % e.get_label_of_ranges(ranges)
else:
index = event.popup_data["index"]
ranges = [(index, index+1)]
desc = "Enter comment for location %s" % index
desc = "Enter comment for location %s" % e.get_label_at_index(index)
if ranges:
prompt_for_comment(e, s, ranges, desc)

Expand Down
9 changes: 9 additions & 0 deletions omnivore/tasks/hex_edit/hex_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,15 @@ def convert_ranges(self, from_style, to_style):
self.selected_ranges = s.get_style_ranges(selected=True)
self.document.change_count += 1

def get_label_at_index(self, index):
return self.control.table.get_label_at_index(index)

def get_label_of_ranges(self, ranges):
labels = []
for start, end in ranges:
labels.append("%s-%s" % (self.get_label_at_index(start), self.get_label_at_index(end)))
return ", ".join(labels)

def get_segment_from_selection(self):
# Since we can't handle segments with discontinuous chunks, we'll
# create a contiguous segment from the first byte of the first range
Expand Down

0 comments on commit 25bdfa8

Please sign in to comment.