# # # add_file "color.cc" # content [045ae12ed4b5738fee9e7e68973f35329f03b40d] # # add_file "color.hh" # content [0dc771680ae06dc7399a1641bbcf97552502fce4] # # patch "diff_patch.cc" # from [cc30eb557fae84b48fd261d199d25ff25f355111] # to [02df140f859d8df26fb3e0948045f0b78b84fd86] # ============================================================ --- color.cc 045ae12ed4b5738fee9e7e68973f35329f03b40d +++ color.cc 045ae12ed4b5738fee9e7e68973f35329f03b40d @@ -0,0 +1,19 @@ +namespace color { + +const char * std = "\033[0m"; +const char * strong = "\033[1m"; + +const char * blue = "\033[31m"; +const char * green = "\033[32m"; +const char * yellow = "\033[33m"; +const char * red = "\033[34m"; +const char * purple = "\033[35m"; +const char * cyan = "\033[36m"; +const char * gray = "\033[37m"; + +const char * diff_add = blue; +const char * diff_del = red; +const char * diff_conflict = purple; +const char * comment = gray; + +} ============================================================ --- color.hh 0dc771680ae06dc7399a1641bbcf97552502fce4 +++ color.hh 0dc771680ae06dc7399a1641bbcf97552502fce4 @@ -0,0 +1,11 @@ +namespace color { + +extern const char * std; +extern const char * strong; + +extern const char * diff_add; +extern const char * diff_del; +extern const char * diff_conflict; +extern const char * comment; + +} ============================================================ --- diff_patch.cc cc30eb557fae84b48fd261d199d25ff25f355111 +++ diff_patch.cc 02df140f859d8df26fb3e0948045f0b78b84fd86 @@ -930,13 +930,13 @@ void unidiff_hunk_writer::insert_at(size void unidiff_hunk_writer::insert_at(size_t b_pos) { b_len++; - hunk.push_back(string(color::add) + string("+") + b[b_pos] + string(color::std)); + hunk.push_back(string(color::diff_add) + string("+") + b[b_pos] + string(color::std)); } void unidiff_hunk_writer::delete_at(size_t a_pos) { a_len++; - hunk.push_back(string(color::del) + string("-") + a[a_pos] + string(color::std)); + hunk.push_back(string(color::diff_del) + string("-") + a[a_pos] + string(color::std)); } void unidiff_hunk_writer::flush_hunk(size_t pos) @@ -1154,11 +1154,11 @@ void cxtdiff_hunk_writer::flush_pending_ // if we have just insertions to flush, prefix them with "+"; if // just deletions, prefix with "-"; if both, prefix with "!" if (inserts.empty() && !deletes.empty()) - prefix = string(color::del) + string("-"); + prefix = string(color::diff_del) + string("-"); else if (deletes.empty() && !inserts.empty()) - prefix = string(color::add) + string("+"); + prefix = string(color::diff_add) + string("+"); else - prefix = string(color::conflict) + string("!"); + prefix = string(color::diff_conflict) + string("!"); for (vector::const_iterator i = deletes.begin(); i != deletes.end(); ++i) @@ -1325,8 +1325,8 @@ make_diff(string const & filename1, { case unified_diff: { - ost << color::del << "--- " << filename1 << '\t' << id1 << '\n'; - ost << color::add << "+++ " << filename2 << '\t' << id2 << '\n'; + ost << color::diff_del << "--- " << filename1 << '\t' << id1 << '\n'; + ost << color::diff_add << "+++ " << filename2 << '\t' << id2 << '\n'; ost << color::std; unidiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern); @@ -1335,8 +1335,8 @@ make_diff(string const & filename1, } case context_diff: { - ost << color::del << "*** " << filename1 << '\t' << id1 << '\n'; - ost << color::add << "--- " << filename2 << '\t' << id2 << '\n'; + ost << color::diff_del << "*** " << filename1 << '\t' << id1 << '\n'; + ost << color::diff_add << "--- " << filename2 << '\t' << id2 << '\n'; ost << color::std; cxtdiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern);