[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone.colored-diff: f9c07b6791783
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone.colored-diff: f9c07b67917833501d4e5110553dc2a9799bf8e8 |
Date: |
Sun, 10 Apr 2011 19:26:39 +0200 (CEST) |
revision: f9c07b67917833501d4e5110553dc2a9799bf8e8
date: 2011-04-10T11:30:45
author: Richard Hopkins <address@hidden>
branch: net.venge.monotone.colored-diff
changelog:
Added invariant to make sure the requested purpose is actually mapped
This is good because it means that if the purpose is being output, then we
know the user has a chance to configure it via the lua hook. Before, it was
possible (but didn't happen) that the purpose was intended to be output,
but only the text was.
manifest:
format_version "1"
new_manifest [d72281df742b0bb8bde64853eb545aea1f16771a]
old_revision [69d8be9ae7a295bde86e3ae74f622ace78a2c0fd]
patch "src/colorizer.cc"
from [70f28456415ac886e8449d8ffc5596bfa267b2ef]
to [4b57f12e6d30074c90950efffc34652d30c11c3e]
patch "src/colorizer.hh"
from [8daedb1c6b54672327e57b5f39dd4c69631969b1]
to [1c5ed11f8631a859c5788782b05f2e7117b8ff8a]
============================================================
--- src/colorizer.cc 70f28456415ac886e8449d8ffc5596bfa267b2ef
+++ src/colorizer.cc 4b57f12e6d30074c90950efffc34652d30c11c3e
@@ -134,12 +134,13 @@ colorizer::colorizer(bool enable, lua_ho
}
colorizer::colorizer(bool enable, lua_hooks & lh)
- : lua(lh)
+ : lua(lh),
+ enabled(enable)
{
if (!have_smart_terminal())
- enable = false;
+ enabled = false;
- if (enable)
+ if (enabled)
{
colormap.insert(map_output_color(normal));
colormap.insert(map_output_color(reset));
@@ -161,10 +162,13 @@ colorizer::colorize(string const & in, p
string
colorizer::colorize(string const & in, purpose p) const
{
- if (colormap.find(p) == colormap.end())
+ if (enabled)
+ {
+ I(colormap.find(p) != colormap.end());
+ return change_format(p) + in + change_format(reset);
+ }
+ else
return in;
-
- return change_format(p) + in + change_format(reset);
}
string
============================================================
--- src/colorizer.hh 8daedb1c6b54672327e57b5f39dd4c69631969b1
+++ src/colorizer.hh 1c5ed11f8631a859c5788782b05f2e7117b8ff8a
@@ -43,6 +43,7 @@ private:
std::map<purpose, boost::tuple<std::string, std::string, std::string> >
colormap;
lua_hooks & lua;
+ bool enabled;
std::pair<purpose, boost::tuple<std::string, std::string, std::string> >
map_output_color(purpose const p);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone.colored-diff: f9c07b67917833501d4e5110553dc2a9799bf8e8,
code <=