about summary refs log tree commit diff stats
path: root/miasm/core/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'miasm/core/utils.py')
-rw-r--r--miasm/core/utils.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/miasm/core/utils.py b/miasm/core/utils.py
index cfe96de4..41bf78c1 100644
--- a/miasm/core/utils.py
+++ b/miasm/core/utils.py
@@ -1,4 +1,5 @@
 from __future__ import print_function
+import re
 import sys
 from builtins import range
 import struct
@@ -16,6 +17,28 @@ from future.utils import viewitems
 
 import collections
 
+COLOR_INT = "azure4"
+COLOR_ID = "forestgreen"#"chartreuse3"
+COLOR_MEM = "deeppink4"
+COLOR_OP_FUNC = "blue1"
+COLOR_LOC = "darkslateblue"
+COLOR_OP = "black"
+
+COLOR_MNEMO = "blue1"
+
+ESCAPE_CHARS = re.compile('[' + re.escape('{}') + '&|<>' + ']')
+
+def set_html_text_color(text, color):
+    return '<font color="%s">%s</font>' % (color, text)
+
+
+def _fix_chars(token):
+    return "&#%04d;" % ord(token.group())
+
+
+def fix_html_chars(text):
+    return ESCAPE_CHARS.sub(_fix_chars, str(text))
+
 upck8 = lambda x: struct.unpack('B', x)[0]
 upck16 = lambda x: struct.unpack('H', x)[0]
 upck32 = lambda x: struct.unpack('I', x)[0]
@@ -261,3 +284,4 @@ class BoundedDict(DictMixin):
 
     def __iter__(self):
         return iter(self._data)
+