From cb5836c2e0bede63633371f0f655271773bdff1e Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Thu, 22 Oct 2009 09:29:24 +0000 Subject: [PATCH 1/2] Ticket #1667: Hardcoded colours Problem: BOOK_MARK_COLOR and BOOK_MARK_FOUND_COLOR are hardcoded in edit/edit-widget.h and so cannot be changed via skin. Solution: Now these colors will configure via skin-file. Like: Signed-off-by: Ilia Maslakov --- edit/edit-widget.h | 4 ---- edit/edit.c | 1 + edit/editcmd.c | 1 + misc/skins/default.ini | 2 ++ misc/skins/double-lines.ini | 2 ++ misc/skins/featured.ini | 2 ++ src/skin/colors.c | 4 ++++ src/skin/skin.h | 4 +++- 8 files changed, 15 insertions(+), 5 deletions(-) diff --git a/edit/edit-widget.h b/edit/edit-widget.h index 327a2dca2..f86864445 100644 --- a/edit/edit-widget.h +++ b/edit/edit-widget.h @@ -12,13 +12,9 @@ #include "edit-impl.h" #include "../src/keybind.h" - #define MAX_MACRO_LENGTH 1024 #define N_LINE_CACHES 32 -#define BOOK_MARK_COLOR ((25 << 8) | 5) -#define BOOK_MARK_FOUND_COLOR ((26 << 8) | 4) - struct _book_mark { int line; /* line number */ int c; /* color */ diff --git a/edit/edit.c b/edit/edit.c index 1384da5ef..9ee9d667e 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -49,6 +49,7 @@ #include "../src/tty/color.h" /* EDITOR_NORMAL_COLOR */ #include "../src/tty/tty.h" /* attrset() */ #include "../src/tty/key.h" /* is_idle() */ +#include "../src/skin/skin.h" /* mc_skin_color_get */ #include "../src/widget.h" /* buttonbar_redraw() */ #include "../src/cmd.h" /* view_other_cmd() */ diff --git a/edit/editcmd.c b/edit/editcmd.c index 78ef74598..2848137bd 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -60,6 +60,7 @@ #include "../src/selcodepage.h" #include "../src/strutil.h" /* utf string functions */ #include "../src/mcconfig/mcconfig.h" +#include "../src/skin/skin.h" /* mc_skin_color_get */ #include "../edit/edit-impl.h" #include "../edit/edit.h" diff --git a/misc/skins/default.ini b/misc/skins/default.ini index 7a758d154..d0f378fd3 100644 --- a/misc/skins/default.ini +++ b/misc/skins/default.ini @@ -72,6 +72,8 @@ editmarked=black;cyan editwhitespace=brightblue;blue linestate=white;cyan + bookmark=white;red + bookmarkfound=black;green [viewer] viewunderline=brightred;blue diff --git a/misc/skins/double-lines.ini b/misc/skins/double-lines.ini index fb6d935a8..c8225625b 100644 --- a/misc/skins/double-lines.ini +++ b/misc/skins/double-lines.ini @@ -72,6 +72,8 @@ editmarked=black;cyan editwhitespace=brightblue;blue linestate=white;cyan + bookmark=white;red + bookmarkfound=black;green [viewer] viewunderline=brightred;blue diff --git a/misc/skins/featured.ini b/misc/skins/featured.ini index 96850894b..e90ea3bcb 100644 --- a/misc/skins/featured.ini +++ b/misc/skins/featured.ini @@ -74,6 +74,8 @@ editmarked=black;cyan editwhitespace=brightblue;blue linestate=white;cyan + bookmark=white;red + bookmarkfound=black;green [viewer] viewunderline=brightred;blue diff --git a/src/skin/colors.c b/src/skin/colors.c index 2ba54d933..e6e9011a7 100644 --- a/src/skin/colors.c +++ b/src/skin/colors.c @@ -228,6 +228,10 @@ mc_skin_color_cache_init (void) EDITOR_MARKED_COLOR = mc_skin_color_get ("editor", "editmarked"); EDITOR_WHITESPACE_COLOR = mc_skin_color_get ("editor", "editwhitespace"); LINE_STATE_COLOR = mc_skin_color_get ("editor", "linestate"); + BOOK_MARK_COLOR = mc_skin_color_get ("editor", "bookmark"); + BOOK_MARK_FOUND_COLOR = mc_skin_color_get ("editor", "bookmarkfound"); + + } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/skin/skin.h b/src/skin/skin.h index 1bd026d39..42a509d49 100644 --- a/src/skin/skin.h +++ b/src/skin/skin.h @@ -63,8 +63,10 @@ #define EDITOR_WHITESPACE_COLOR mc_skin_color__cache[28] /* color of left 8 char status per line */ #define LINE_STATE_COLOR mc_skin_color__cache[29] +#define BOOK_MARK_COLOR mc_skin_color__cache[30] +#define BOOK_MARK_FOUND_COLOR mc_skin_color__cache[31] -#define MC_SKIN_COLOR_CACHE_COUNT 30 +#define MC_SKIN_COLOR_CACHE_COUNT 32 /*** enums ***************************************************************************************/ From 41c5b369deb565896c5b956def8f388961963118 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Thu, 22 Oct 2009 14:03:01 +0300 Subject: [PATCH 2/2] Fix colors showing for compile with S-Lang library Signed-off-by: Slava Zanko --- src/tty/color-slang.c | 12 +----------- src/tty/color-slang.h | 10 +++------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/tty/color-slang.c b/src/tty/color-slang.c index fa3c00212..3767fc7f9 100644 --- a/src/tty/color-slang.c +++ b/src/tty/color-slang.c @@ -142,17 +142,7 @@ tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair) void tty_setcolor (int color) { - if (!SLtt_Use_Ansi_Colors) - SLsmg_set_color (color); - else if ((color & A_BOLD) != 0) { - if (color == A_BOLD) - SLsmg_set_color (A_BOLD); - else - SLsmg_set_color ((color & (~A_BOLD)) + 8); - } else if (color == A_REVERSE) - SLsmg_set_color (A_REVERSE); - else - SLsmg_set_color (color); + SLsmg_set_color (color); } /* Set colorpair by index, don't interpret S-Lang "emulated attributes" */ diff --git a/src/tty/color-slang.h b/src/tty/color-slang.h index 371c29d3b..7b47d11df 100644 --- a/src/tty/color-slang.h +++ b/src/tty/color-slang.h @@ -22,13 +22,9 @@ enum { /* When using Slang with color, we have all the indexes free but * those defined here (A_BOLD, A_UNDERLINE, A_REVERSE, A_BOLD_REVERSE) */ -#define A_BOLD 0x40 -#define A_UNDERLINE 0x40 -#define A_REVERSE 0x20 -#define A_BOLD_REVERSE 0x21 -#ifndef A_NORMAL -# define A_NORMAL 0x00 -#endif +#ifndef A_BOLD +#define A_BOLD SLTT_BOLD_MASK +#endif /* A_BOLD */ #endif /* MC_COLOR_SLANG_H */