Comments (8)
As a quick fix, change TDUnitXConsoleLogger.SetConsoleDefaultColor() in DUnitX.Loggers.Console from:
FConsoleWriter.SetColour(ccDefault);
to:
FConsoleWriter.SetColour(ccWhite, ccBlack);
The other "SetColour" commands all explicitly specify black for the background, so setting the default to while on black makes the output look correct no matter the background color of the console. I tried it out and it works great.
from dunitx.
Is there a way to get the default console colour on startup? If so then we could use that to determine the correct colors to use.
from dunitx.
To get the current console color, use WinApi.Windows
function GetConsoleScreenBufferInfo(hConsoleOutput: THandle;
var lpConsoleScreenBufferInfo: TConsoleScreenBufferInfo): BOOL; stdcall;
The TConsoleScreenBufferInfo structure is documented here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
The wAttributes field contains the color info - but it is a tad archaic ...
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes
Basically it's an R, G, B and an intensity bit for background, and ditto for foreground.
Since console windows don't have more than 16 possible foreground and background colors, it's an option to create a static list of 4-5 foreground colors that give good contrast for each of the 16 background colors.
from dunitx.
It could be more complicated because the background color can be anything:
http://www.howtogeek.com/howto/16815/how-to-personalize-the-windows-command-prompt/
I wasn't aware it could even be changed without a hack, so documenting link here.
I have a couple of ideas, but I'll have to experiment first...
from dunitx.
More info: http://stackoverflow.com/questions/9509278/rgb-specific-console-text-color-c/9509664#9509664
Basically the colours are indexes into the colour table. The colour table can then have RGB values for each entry.
For now it would suffice to cope with the standard RGB values, as I've not yet seen people change those RGB values in practice.
from dunitx.
I thought I had already made this change in my local version, but apparently I didn't (or I accidentally merged it back in). Has anyone used the change in enough of a capacity to say it is a safe change to make permanently? I know in my testing it worked fine, but wanted more feedback if it was available.
from dunitx.
@rmcginty if you have a patch, let me know where the repo with that patch is and I'll test it. All my console Windows are black text on a white background.
from dunitx.
I already have an active PR and I really do not want to try a branch since I just got my GitHub repo all back to normal, but it literally is the single line change. Open DUnitX.Loggers.Console.pas and change line 447 to:
FConsoleWriter.SetColour(ccWhite, ccBlack);
That will keep it from resetting to the default colors, which is what keeps resetting your background to white. Honestly, if the system isn't going to detect background color and compensate (which is a bunch of work for little gain - especially using tools available on the console) then it should really just force a specific color scheme regardless of your default colors - just to keep it standard and readable.
If you notice no unintended side effects from this change, let me know and I'll clean up the file some, make the change, and attach it to my existing PR.
from dunitx.
Related Issues (20)
- Test project won't compile with XE2 and probably higher HOT 1
- fix commandline help documentation for exitbehavior HOT 1
- Assert.Pass(message) do not show anywhere the message
- Assert.AreEqual lacks currency support
- DUnitX xml does not set the namespace in the output properly HOT 3
- Proper support for TAlphaColor and TColor param HOT 1
- Recompling tests in Delphi 11.2 causes IO 105 errors HOT 3
- Android32 with incorrect TestCase parameters HOT 4
- WriteLn causing MemoryLeak using FastMM5
- Add argument 'ATrimValues: Boolean = False' to DUnitX.Attributes.TestCaseAttribute.Create HOT 1
- TestCaseAttribute does not work with parameters of type UInt64 and values > High(Int64)
- Integer compare always true HOT 1
- Problemas with TStringLIst instantiation HOT 1
- Change in FExitBehavior HOT 1
- TestCaseAttribute to support sets HOT 1
- Log elapsed time for each test in TDunitXConsoleMode
- IDE removes DUnitX.Loggers.Xml.NUnit from dpr
- StrToUInt64Def is not available in XE5 HOT 1
- SetupFixture method having an exception leads to "Duplicates not allowed" error or inconsistency.
- Cannot load package Expert HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dunitx.