[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone.colored-diff: 973e5397a57f2f
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone.colored-diff: 973e5397a57f2f09b049cca8c368008cd8d1f05f |
Date: |
Mon, 11 Apr 2011 22:45:21 +0200 (CEST) |
revision: 973e5397a57f2f09b049cca8c368008cd8d1f05f
date: 2011-04-10T21:19:50
author: Richard Hopkins <address@hidden>
branch: net.venge.monotone.colored-diff
changelog:
Laying foundation for colorizer holding onto output
colorizer now requires an ostream in the constructor, which all output
should redirect to at the relevant time. The reason we need this is Win32
requires side-effects from API calls to change the output, so we need to
schedule text output at the correct time.
These changes are just the minimal necessary to get a compilable+working
copy of existing functionality, the passed in ostream is not used yet.
get_ostream is provided at the moment, so it can enable future changes to
remain readable
eg. existing code may look like
oss << color.colorize("something", add) << "\n";
which in the old code would be fine, as it only worked with ANSI codes, but
the new code aims to work with Win32. This means the buffering into oss, then
outputting into cout no longer works. get_ostream allows colorizer to
control the output, and callers to keep the ordering of output in sync - so
it could become
color.get_ostream() << color.colorize("something", add) << "\n";
manifest:
format_version "1"
new_manifest [a7864939e75c7158efc733453acadcad8dc3b5d0]
old_revision [8f80c57ab54c96547b551797d9f66abae284db23]
patch "src/asciik.cc"
from [64600c9969226fa55cd05982364147342d3b734e]
to [5a1eb92c8d5decd0e306c0fd7049f5364bda4b30]
patch "src/cmd_diff_log.cc"
from [66d959146c432421ca24988535a9b250aa860a36]
to [7cf82371ca7a3c7088a405c56cd1d0a933bc9b0f]
patch "src/cmd_files.cc"
from [3bb32dddf14bd79e630069837220aeb2e67d9346]
to [6cf73269611bf523766e05f6278e7aa70e84fea3]
patch "src/cmd_ws_commit.cc"
from [b22c4c8871fe38e55da487318326755c699d4873]
to [49428f1e66c32635cba685c13921f5904ed79d89]
patch "src/colorizer.cc"
from [0a08fe6fb71f513041528ef6773ae9cfbfff99ee]
to [faab445c678b6f93119254030a38bb905ab7d89e]
patch "src/colorizer.hh"
from [4ca2bf29f0d731ce80d3136c7fb147a30b3b5139]
to [68b9d31fbec0de86d5dca156523fae34e684845c]
============================================================
--- src/cmd_diff_log.cc 66d959146c432421ca24988535a9b250aa860a36
+++ src/cmd_diff_log.cc 7cf82371ca7a3c7088a405c56cd1d0a933bc9b0f
@@ -445,7 +445,7 @@ CMD(diff, "diff", "di", CMD_REF(informat
prepare_diff(app, db, old_roster, new_roster, args, old_from_db, new_from_db, revs);
- colorizer colorizer(app.opts.colorize, app.lua);
+ colorizer colorizer(app.opts.colorize, app.lua, cout);
if (app.opts.with_header)
{
@@ -488,7 +488,7 @@ CMD_AUTOMATE(content_diff, N_("[FILE [..
dummy_header);
// never colorize the diff output
- colorizer colorizer(false, app.lua);
+ colorizer colorizer(false, app.lua, output);
if (app.opts.with_header)
{
@@ -861,7 +861,7 @@ log_common (app_state & app,
set<revision_id> seen;
revision_t rev;
- colorizer color(app.opts.colorize && !automate, app.lua);
+ colorizer color(app.opts.colorize && !automate, app.lua, output);
// this is instantiated even when not used, but it's lightweight
asciik graph(output, color);
============================================================
--- src/cmd_files.cc 3bb32dddf14bd79e630069837220aeb2e67d9346
+++ src/cmd_files.cc 6cf73269611bf523766e05f6278e7aa70e84fea3
@@ -134,7 +134,7 @@ CMD(fdiff, "fdiff", "", CMD_REF(debug),
src_id, dst_id,
src.inner(), dst.inner(),
cout, app.opts.diff_format,
- pattern, colorizer(app.opts.colorize, app.lua));
+ pattern, colorizer(app.opts.colorize, app.lua, cout));
}
CMD(annotate, "annotate", "", CMD_REF(informative), N_("PATH"),
============================================================
--- src/cmd_ws_commit.cc b22c4c8871fe38e55da487318326755c699d4873
+++ src/cmd_ws_commit.cc 49428f1e66c32635cba685c13921f5904ed79d89
@@ -259,7 +259,7 @@ get_log_message_interactively(lua_hooks
}
utf8 summary;
- colorizer color(false, lua);
+ colorizer color(false, lua, cout);
revision_summary(rev, color, summary);
utf8 full_message(changelog() + cancel() + instructions() + editable() + ignored() +
@@ -966,7 +966,7 @@ CMD(status, "status", "", CMD_REF(inform
utf8 header;
utf8 summary;
- colorizer color(app.opts.colorize, app.lua);
+ colorizer color(app.opts.colorize, app.lua, cout);
revision_header(rid, rev, author, date_t::now(), app.opts.branch, changelog,
date_fmt, color, header);
============================================================
--- src/asciik.cc 64600c9969226fa55cd05982364147342d3b734e
+++ src/asciik.cc 5a1eb92c8d5decd0e306c0fd7049f5364bda4b30
@@ -390,7 +390,7 @@ CMD(asciik, "asciik", "", CMD_REF(debug)
toposort(db, revs, sorted);
reverse(sorted.begin(), sorted.end());
- asciik graph(std::cout, colorizer(app.opts.colorize, app.lua), 10);
+ asciik graph(std::cout, colorizer(app.opts.colorize, app.lua, std::cout), 10);
for (vector<revision_id>::const_iterator rev = sorted.begin();
rev != sorted.end(); ++rev)
============================================================
--- src/colorizer.cc 0a08fe6fb71f513041528ef6773ae9cfbfff99ee
+++ src/colorizer.cc faab445c678b6f93119254030a38bb905ab7d89e
@@ -14,8 +14,8 @@ using std::make_pair;
using std::string;
using std::map;
using std::make_pair;
+using std::ostream;
-
string colorizer::purpose_to_name(colorizer::purpose const p) const
{
switch (p)
@@ -230,9 +230,10 @@ colorizer::init_colormap()
colormap.insert(map_output_color<T>(unset));
}
-colorizer::colorizer(bool enable, lua_hooks & lh)
+colorizer::colorizer(bool enable, lua_hooks & lh, ostream & os)
: lua(lh),
- enabled(enable)
+ enabled(enable),
+ out(os)
{
if (!have_smart_terminal())
enabled = false;
============================================================
--- src/colorizer.hh 4ca2bf29f0d731ce80d3136c7fb147a30b3b5139
+++ src/colorizer.hh 68b9d31fbec0de86d5dca156523fae34e684845c
@@ -12,6 +12,7 @@
#include "lua_hooks.hh"
#include "vocab.hh"
+#include <iosfwd>
#include <map>
#include <boost/tuple/tuple.hpp>
#ifdef WIN32
@@ -37,11 +38,13 @@ struct colorizer
unset
} purpose;
- colorizer(bool enable, lua_hooks & lh);
+ colorizer(bool enable, lua_hooks & lh, std::ostream & os);
std::string
colorize(std::string const & in, purpose p = normal) const;
+ std::ostream const & get_ostream() const { return out; }
+
private:
#ifdef WIN32
std::map<purpose, boost::tuple<int, int, int> > colormap;
@@ -51,6 +54,7 @@ private:
#endif
lua_hooks & lua;
bool enabled;
+ std::ostream & out;
#ifdef WIN32
HANDLE win_out;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone.colored-diff: 973e5397a57f2f09b049cca8c368008cd8d1f05f,
code <=