[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone.colored-diff: bf3c86770c996
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone.colored-diff: bf3c86770c996ab2ae094f71e253fc9f17bdfc2f |
Date: |
Sun, 10 Apr 2011 19:26:38 +0200 (CEST) |
revision: bf3c86770c996ab2ae094f71e253fc9f17bdfc2f
date: 2011-04-10T17:26:20
author: Richard Hopkins <address@hidden>
branch: net.venge.monotone.colored-diff
changelog:
Implemented change_format for Win32
The format of the output should now change according to the standard
preferences of the lua hook - just like Unix/Linux.
However, Win32 colorizing is not yet complete, the colorizer needs access
to the output buffer so it can schedule the format change before outputting
the text.
manifest:
format_version "1"
new_manifest [694fc6b3115edc0685826944ba6c40cd15b5a8a8]
old_revision [752d2e719a619b986c2ac9658e828679379e6dc9]
patch "src/colorizer.cc"
from [288f70c817d98d6411dbfb246296373d4c939a58]
to [0a08fe6fb71f513041528ef6773ae9cfbfff99ee]
patch "src/colorizer.hh"
from [d2d13a1f10934408761287392b0ba094e898e58b]
to [4ca2bf29f0d731ce80d3136c7fb147a30b3b5139]
============================================================
--- src/colorizer.cc 288f70c817d98d6411dbfb246296373d4c939a58
+++ src/colorizer.cc 0a08fe6fb71f513041528ef6773ae9cfbfff99ee
@@ -236,7 +236,17 @@ colorizer::colorizer(bool enable, lua_ho
{
if (!have_smart_terminal())
enabled = false;
+#ifdef WIN32
+ win_out = GetStdHandle(STD_OUTPUT_HANDLE);
+ I(win_out != INVALID_HANDLE_VALUE);
+ CONSOLE_SCREEN_BUFFER_INFO bufinfo;
+ if (GetConsoleScreenBufferInfo(win_out, &bufinfo) == 0)
+ {
+ enabled = false;
+ }
+#endif
+
if (enabled)
{
#ifdef WIN32
@@ -273,7 +283,6 @@ colorizer::change_format(purpose const p
colorizer::change_format(purpose const p) const
{
#ifdef WIN32
- I(false); // FIXME: Needs implementing
// We will have to rely on Win32 API calls for the side effect of
// changing output, but to keep callers happy regardless of platform we
// will return an empty string so they can have code like
@@ -286,6 +295,8 @@ colorizer::change_format(purpose const p
// on everything else, this will become
// "<ANSI_CODE>new_file.txt<ANSI_CODE>" and the terminal will then display
// the properly formatted "new_file.txt"
+
+ SetConsoleTextAttribute(win_out, get_format<int>(p));
return "";
#else
return get_format<string>(p);
============================================================
--- src/colorizer.hh d2d13a1f10934408761287392b0ba094e898e58b
+++ src/colorizer.hh 4ca2bf29f0d731ce80d3136c7fb147a30b3b5139
@@ -52,6 +52,10 @@ private:
lua_hooks & lua;
bool enabled;
+#ifdef WIN32
+ HANDLE win_out;
+#endif
+
template<typename T> void init_colormap();
template<typename T>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone.colored-diff: bf3c86770c996ab2ae094f71e253fc9f17bdfc2f,
code <=