From 4761ea9c83104b872d8d49fcde45f17d17e7872d Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Thu, 5 Jan 2017 09:14:31 -0500 Subject: Modifying how enumerations are exposed and used, and a bunch of cleanup of existing plugins --- python/highlight.py | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'python/highlight.py') 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 "" % self._standard_color_to_str(self.color) return "" % (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 "" % (self._standard_color_to_str(self.color), self._standard_color_to_str(self.mix_color), self.mix) return "" % (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 "" % (self.red, self.green, self.blue) return "" % (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 -- cgit v1.3.1