#
#
# add_file "diff_colorizer.cc"
# content [517669de6f3104480f3df75c463c15a4b93257d0]
#
# add_file "diff_colorizer.hh"
# content [fa6402717dc47a53e79fabda1d94bb4a9cda655f]
#
# patch "Makefile.am"
# from [f782372bdf843356251f455a1ad1559cb464326f]
# to [ad74b99b817f166a80650aef587a4d65edecd482]
#
# patch "cmd_diff_log.cc"
# from [bd1b283c47bb14e7f561d1fae2d479cedc365ee2]
# to [7ab2f84093a7130644a11f740eae685a192b3db7]
#
# patch "cmd_files.cc"
# from [0e0f670c8b91d458f67261ddd56c7623bde50d71]
# to [c259141b2dfdf62efb777b1c33e3ba84f10e4ddf]
#
# patch "diff_output.cc"
# from [746af1eeaa7fee943bf1264dc88ddd6e218c7866]
# to [0bc645fe55f2baa35d8e77c6a8be521a8347248b]
#
# patch "diff_output.hh"
# from [9125ccd0d0fa725782c9910b5f34e844048d2da8]
# to [47ea2a783e32e6183fe07204e957269cd02c6677]
#
# patch "options_list.hh"
# from [8a5da3dc9c861616ba52de164348285ea902e432]
# to [78f2f099c82e0e175a3aa64c0e44865be32b2a2a]
#
============================================================
--- diff_colorizer.cc 517669de6f3104480f3df75c463c15a4b93257d0
+++ diff_colorizer.cc 517669de6f3104480f3df75c463c15a4b93257d0
@@ -0,0 +1,48 @@
+// Copyright (C) 2010 Thomas Keller
+//
+// This program is made available under the GNU GPL version 2.0 or
+// greater. See the accompanying file COPYING for details.
+//
+// This program is distributed WITHOUT ANY WARRANTY; without even the
+// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE.
+
+#include "base.hh"
+#include "diff_colorizer.hh"
+#include "platform.hh"
+
+using std::string;
+using std::map;
+using std::make_pair;
+
+diff_colorizer::diff_colorizer(bool enable)
+{
+ if (!have_smart_terminal())
+ enable = false;
+
+ if (enable)
+ {
+ colormap.insert(std::make_pair(normal, ""));
+ colormap.insert(std::make_pair(encloser, "\033[36m"));
+ colormap.insert(std::make_pair(add, "\033[32m"));
+ colormap.insert(std::make_pair(del, "\033[31m"));
+ colormap.insert(std::make_pair(change, "\033[33m"));
+ colormap.insert(std::make_pair(reset, "\033[m"));
+ }
+}
+
+string
+diff_colorizer::colorize(string const & in, purpose p) const
+{
+ if (colormap.find(p) == colormap.end())
+ return in;
+ return colormap.find(p)->second + in + colormap.find(reset)->second;
+}
+
+// Local Variables:
+// mode: C++
+// fill-column: 76
+// c-file-style: "gnu"
+// indent-tabs-mode: nil
+// End:
+// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
============================================================
--- diff_colorizer.hh fa6402717dc47a53e79fabda1d94bb4a9cda655f
+++ diff_colorizer.hh fa6402717dc47a53e79fabda1d94bb4a9cda655f
@@ -0,0 +1,37 @@
+// Copyright (C) 2010 Thomas Keller
+//
+// This program is made available under the GNU GPL version 2.0 or
+// greater. See the accompanying file COPYING for details.
+//
+// This program is distributed WITHOUT ANY WARRANTY; without even the
+// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE.
+
+#ifndef __DIFF_COLORIZER_HH__
+#define __DIFF_COLORIZER_HH__
+
+#include "vocab.hh"
+#include