summaryrefslogtreecommitdiff
path: root/python/highlight.py
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2017-01-05 09:14:31 -0500
committerPeter LaFosse <peter@vector35.com>2017-01-05 09:14:31 -0500
commit4761ea9c83104b872d8d49fcde45f17d17e7872d (patch)
tree0acca0d74701a834c36f85aebd7dd9955ecbfb8f /python/highlight.py
parent96acbed85902d8dfd43ef624afac72145ae6e577 (diff)
Modifying how enumerations are exposed and used, and a bunch of cleanup of existing plugins
Diffstat (limited to 'python/highlight.py')
-rw-r--r--python/highlight.py47
1 files changed, 24 insertions, 23 deletions
diff --git a/python/highlight.py b/python/highlight.py
index 98735166..6af1cf95 100644
--- a/python/highlight.py
+++ b/python/highlight.py
@@ -21,66 +21,67 @@
# Binary Ninja components
import _binaryninjacore as core
+from enums import HighlightColorStyle, HighlightStandardColor
class HighlightColor(object):
def __init__(self, color = None, mix_color = None, mix = None, red = None, green = None, blue = None, alpha = 255):
if (red is not None) and (green is not None) and (blue is not None):
- self.style = core.BNHighlightColorStyle.CustomHighlightColor
+ self.style = HighlightColorStyle.CustomHighlightColor
self.red = red
self.green = green
self.blue = blue
elif (mix_color is not None) and (mix is not None):
- self.style = core.BNHighlightColorStyle.MixedHighlightColor
+ self.style = HighlightColorStyle.MixedHighlightColor
if color is None:
- self.color = core.BNHighlightStandardColor.NoHighlightColor
+ self.color = HighlightStandardColor.NoHighlightColor
else:
self.color = color
self.mix_color = mix_color
self.mix = mix
else:
- self.style = core.BNHighlightColorStyle.StandardHighlightColor
+ self.style = HighlightColorStyle.StandardHighlightColor
if color is None:
- self.color = core.BNHighlightStandardColor.NoHighlightColor
+ self.color = HighlightStandardColor.NoHighlightColor
else:
self.color = color
self.alpha = alpha
def _standard_color_to_str(self, color):
- if color == core.BNHighlightStandardColor.NoHighlightColor:
+ if color == HighlightStandardColor.NoHighlightColor:
return "none"
- if color == core.BNHighlightStandardColor.BlueHighlightColor:
+ if color == HighlightStandardColor.BlueHighlightColor:
return "blue"
- if color == core.BNHighlightStandardColor.GreenHighlightColor:
+ if color == HighlightStandardColor.GreenHighlightColor:
return "green"
- if color == core.BNHighlightStandardColor.CyanHighlightColor:
+ if color == HighlightStandardColor.CyanHighlightColor:
return "cyan"
- if color == core.BNHighlightStandardColor.RedHighlightColor:
+ if color == HighlightStandardColor.RedHighlightColor:
return "red"
- if color == core.BNHighlightStandardColor.MagentaHighlightColor:
+ if color == HighlightStandardColor.MagentaHighlightColor:
return "magenta"
- if color == core.BNHighlightStandardColor.YellowHighlightColor:
+ if color == HighlightStandardColor.YellowHighlightColor:
return "yellow"
- if color == core.BNHighlightStandardColor.OrangeHighlightColor:
+ if color == HighlightStandardColor.OrangeHighlightColor:
return "orange"
- if color == core.BNHighlightStandardColor.WhiteHighlightColor:
+ if color == HighlightStandardColor.WhiteHighlightColor:
return "white"
- if color == core.BNHighlightStandardColor.BlackHighlightColor:
+ if color == HighlightStandardColor.BlackHighlightColor:
return "black"
return "%d" % color
def __repr__(self):
- if self.style == core.BNHighlightColorStyle.StandardHighlightColor:
+ if self.style == HighlightColorStyle.StandardHighlightColor:
if self.alpha == 255:
return "<color: %s>" % self._standard_color_to_str(self.color)
return "<color: %s, alpha %d>" % (self._standard_color_to_str(self.color), self.alpha)
- if self.style == core.BNHighlightColorStyle.MixedHighlightColor:
+ if self.style == HighlightColorStyle.MixedHighlightColor:
if self.alpha == 255:
return "<color: mix %s to %s factor %d>" % (self._standard_color_to_str(self.color),
self._standard_color_to_str(self.mix_color), self.mix)
return "<color: mix %s to %s factor %d, alpha %d>" % (self._standard_color_to_str(self.color),
self._standard_color_to_str(self.mix_color), self.mix, self.alpha)
- if self.style == core.BNHighlightColorStyle.CustomHighlightColor:
+ if self.style == HighlightColorStyle.CustomHighlightColor:
if self.alpha == 255:
return "<color: #%.2x%.2x%.2x>" % (self.red, self.green, self.blue)
return "<color: #%.2x%.2x%.2x, alpha %d>" % (self.red, self.green, self.blue, self.alpha)
@@ -89,21 +90,21 @@ class HighlightColor(object):
def _get_core_struct(self):
result = core.BNHighlightColor()
result.style = self.style
- result.color = core.BNHighlightStandardColor.NoHighlightColor
- result.mix_color = core.BNHighlightStandardColor.NoHighlightColor
+ result.color = HighlightStandardColor.NoHighlightColor
+ result.mix_color = HighlightStandardColor.NoHighlightColor
result.mix = 0
result.r = 0
result.g = 0
result.b = 0
result.alpha = self.alpha
- if self.style == core.BNHighlightColorStyle.StandardHighlightColor:
+ if self.style == HighlightColorStyle.StandardHighlightColor:
result.color = self.color
- elif self.style == core.BNHighlightColorStyle.MixedHighlightColor:
+ elif self.style == HighlightColorStyle.MixedHighlightColor:
result.color = self.color
result.mixColor = self.mix_color
result.mix = self.mix
- elif self.style == core.BNHighlightColorStyle.CustomHighlightColor:
+ elif self.style == HighlightColorStyle.CustomHighlightColor:
result.r = self.red
result.g = self.green
result.b = self.blue