From 3cab727f5304462f28d46c830773fe70c54ee7de Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 24 Jan 2016 07:11:52 +0000 Subject: [PATCH] Add gdb pretty printing for Kakoune::Color --- gdb/kakoune.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gdb/kakoune.py b/gdb/kakoune.py index f47be8fee..70b019a73 100644 --- a/gdb/kakoune.py +++ b/gdb/kakoune.py @@ -131,6 +131,18 @@ class LineCount: def to_string(self): return self.val["m_value"] +class Color: + """Print a Color""" + + def __init__(self, val): + self.val = val + + def to_string(self): + if self.val["color"] == gdb.lookup_type("Kakoune::Color::NamedColor")["Kakoune::Color::RGB"].enumval: + return "%s #%02x%02x%02x" % (self.val["color"], self.val["r"], self.val["g"], self.val["b"]) + else: + return self.val["color"] + def build_pretty_printer(): pp = gdb.printing.RegexpCollectionPrettyPrinter("kakoune") pp.add_printer('ArrayView', '^Kakoune::ArrayView<.*>$', ArrayView) @@ -147,5 +159,6 @@ def build_pretty_printer(): pp.add_printer('LineCount', '^Kakoune::LineCount$', LineCount) pp.add_printer('CharCount', '^Kakoune::CharCount$', CharCount) pp.add_printer('ByteCount', '^Kakoune::ByteCount$', ByteCount) + pp.add_printer('Color', '^Kakoune::Color$', Color) return pp