[smuxi: 4/7] Frontend-STFL: Ensure text color contrast (closes #1033).
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi: 4/7] Frontend-STFL: Ensure text color contrast (closes #1033).
- Date: Sun, 15 Mar 2015 09:29:04 +0000 (UTC)
commit 662e3aa1aca8da6d7a5afae85395fa8594b9fb7b
Author: Ondřej Hošek <ondra hosek gmail com>
Date: Sat Mar 14 21:56:44 2015 +0100
Frontend-STFL: Ensure text color contrast (closes #1033).
Make the terminal background color configurable as
STFL/Interface/TerminalBackgroundColor and use GetBestTextColor to ensure
sufficient contrast.
src/Frontend-STFL/Frontend.cs | 3 +++
src/Frontend-STFL/Views/ChatView.cs | 10 +++++++++-
2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/Frontend-STFL/Frontend.cs b/src/Frontend-STFL/Frontend.cs
index 360511a..63706e3 100644
--- a/src/Frontend-STFL/Frontend.cs
+++ b/src/Frontend-STFL/Frontend.cs
@@ -157,6 +157,9 @@ namespace Smuxi.Frontend.Stfl
_FrontendConfig = new FrontendConfig(UIName);
// loading and setting defaults
_FrontendConfig.Load();
+ if (_FrontendConfig[Frontend.UIName + "/Interface/TerminalBackgroundColor"] == null) {
+ _FrontendConfig[Frontend.UIName + "/Interface/TerminalBackgroundColor"] = "#000000";
+ }
_FrontendConfig.Save();
if (_FrontendConfig.IsCleanConfig) {
diff --git a/src/Frontend-STFL/Views/ChatView.cs b/src/Frontend-STFL/Views/ChatView.cs
index 9a24106..950aa76 100644
--- a/src/Frontend-STFL/Views/ChatView.cs
+++ b/src/Frontend-STFL/Views/ChatView.cs
@@ -271,8 +271,16 @@ namespace Smuxi.Frontend.Stfl
var tags = new List<string>();
if (txtPart.ForegroundColor != TextColor.None) {
var palette = TextColorPalettes.LinuxConsole;
+ var foregroundColor = txtPart.ForegroundColor;
+ var backgroundColorString = (string)Frontend.FrontendConfig[Frontend.UIName +
"/Interface/TerminalBackgroundColor"];
+ if (!String.IsNullOrEmpty(backgroundColorString)) {
+ foregroundColor = TextColorTools.GetBestTextColor(
+ foregroundColor,
+ TextColor.Parse(backgroundColorString)
+ );
+ }
var color = TextColorTools.GetNearestColor(
- txtPart.ForegroundColor,
+ foregroundColor,
palette
);
var colorNumber = palette.IndexOf(color);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]