Browse Source

Ticket #2170: Color collisions

Midnight Commander's color/skin engine often reuses the same color definition for multiple elements on the UI.
This unnecessarily limits the possibilities when playing with colors.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Egmont Koblinger 14 years ago
parent
commit
aa9cb6d320
10 changed files with 117 additions and 56 deletions
  1. 51 41
      lib/skin.h
  2. 9 0
      lib/skin/colors.c
  3. 1 1
      lib/tty/color.c
  4. 9 0
      misc/skins/darkfar.ini
  5. 10 0
      misc/skins/default.ini
  6. 9 0
      misc/skins/double-lines.ini
  7. 9 0
      misc/skins/featured.ini
  8. 9 0
      misc/skins/gotar.ini
  9. 7 12
      src/boxes.c
  10. 3 2
      src/command.c

+ 51 - 41
lib/skin.h

@@ -21,70 +21,80 @@
 #define DISABLED_COLOR            mc_skin_color__cache[5]
 #define REVERSE_COLOR             mc_skin_color__cache[6]
 #define COMMAND_MARK_COLOR        mc_skin_color__cache[7]
+#define HEADER_COLOR              mc_skin_color__cache[8]
 
 /* Dialog colors */
-#define COLOR_NORMAL              mc_skin_color__cache[8]
-#define COLOR_FOCUS               mc_skin_color__cache[9]
-#define COLOR_HOT_NORMAL          mc_skin_color__cache[10]
-#define COLOR_HOT_FOCUS           mc_skin_color__cache[11]
+#define COLOR_NORMAL              mc_skin_color__cache[9]
+#define COLOR_FOCUS               mc_skin_color__cache[10]
+#define COLOR_HOT_NORMAL          mc_skin_color__cache[11]
+#define COLOR_HOT_FOCUS           mc_skin_color__cache[12]
+#define COLOR_TITLE               mc_skin_color__cache[13]
 
 /* Error dialog colors */
-#define ERROR_COLOR               mc_skin_color__cache[12]
-#define ERROR_HOT_NORMAL          mc_skin_color__cache[13]
-#define ERROR_HOT_FOCUS           mc_skin_color__cache[14]
+#define ERROR_COLOR               mc_skin_color__cache[14]
+#define ERROR_FOCUS               mc_skin_color__cache[15]
+#define ERROR_HOT_NORMAL          mc_skin_color__cache[16]
+#define ERROR_HOT_FOCUS           mc_skin_color__cache[17]
+#define ERROR_TITLE               mc_skin_color__cache[18]
 
 /* Menu colors */
-#define MENU_ENTRY_COLOR          mc_skin_color__cache[15]
-#define MENU_SELECTED_COLOR       mc_skin_color__cache[16]
-#define MENU_HOT_COLOR            mc_skin_color__cache[17]
-#define MENU_HOTSEL_COLOR         mc_skin_color__cache[18]
-#define MENU_INACTIVE_COLOR       mc_skin_color__cache[19]
+#define MENU_ENTRY_COLOR          mc_skin_color__cache[19]
+#define MENU_SELECTED_COLOR       mc_skin_color__cache[20]
+#define MENU_HOT_COLOR            mc_skin_color__cache[21]
+#define MENU_HOTSEL_COLOR         mc_skin_color__cache[22]
+#define MENU_INACTIVE_COLOR       mc_skin_color__cache[23]
 
 /*
  * This should be selectable independently. Default has to be black background
  * foreground does not matter at all.
  */
-#define GAUGE_COLOR               mc_skin_color__cache[20]
-#define INPUT_COLOR               mc_skin_color__cache[21]
-#define INPUT_UNCHANGED_COLOR     mc_skin_color__cache[22]
-#define INPUT_MARK_COLOR          mc_skin_color__cache[23]
+#define GAUGE_COLOR               mc_skin_color__cache[24]
+#define INPUT_COLOR               mc_skin_color__cache[25]
+#define INPUT_UNCHANGED_COLOR     mc_skin_color__cache[26]
+#define INPUT_MARK_COLOR          mc_skin_color__cache[27]
+#define INPUT_HISTORY_COLOR       mc_skin_color__cache[28]
+#define COMMAND_HISTORY_COLOR     mc_skin_color__cache[29]
 
-#define HELP_NORMAL_COLOR         mc_skin_color__cache[24]
-#define HELP_ITALIC_COLOR         mc_skin_color__cache[25]
-#define HELP_BOLD_COLOR           mc_skin_color__cache[26]
-#define HELP_LINK_COLOR           mc_skin_color__cache[27]
-#define HELP_SLINK_COLOR          mc_skin_color__cache[28]
+#define HELP_NORMAL_COLOR         mc_skin_color__cache[30]
+#define HELP_ITALIC_COLOR         mc_skin_color__cache[31]
+#define HELP_BOLD_COLOR           mc_skin_color__cache[32]
+#define HELP_LINK_COLOR           mc_skin_color__cache[33]
+#define HELP_SLINK_COLOR          mc_skin_color__cache[34]
+#define HELP_TITLE_COLOR          mc_skin_color__cache[35]
 
-#define VIEW_UNDERLINED_COLOR     mc_skin_color__cache[29]
+
+#define VIEW_BOLD_COLOR           mc_skin_color__cache[36]
+#define VIEW_UNDERLINED_COLOR     mc_skin_color__cache[37]
+#define VIEW_SELECTED_COLOR       mc_skin_color__cache[38]
 
 /*
  * editor colors - only 4 for normal, search->found, select, and whitespace
  * respectively
  * Last is defined to view color.
  */
-#define EDITOR_NORMAL_COLOR       mc_skin_color__cache[30]
-#define EDITOR_BOLD_COLOR         mc_skin_color__cache[31]
-#define EDITOR_MARKED_COLOR       mc_skin_color__cache[32]
-#define EDITOR_WHITESPACE_COLOR   mc_skin_color__cache[33]
-#define EDITOR_RIGHT_MARGIN_COLOR mc_skin_color__cache[34]
+#define EDITOR_NORMAL_COLOR       mc_skin_color__cache[39]
+#define EDITOR_BOLD_COLOR         mc_skin_color__cache[40]
+#define EDITOR_MARKED_COLOR       mc_skin_color__cache[41]
+#define EDITOR_WHITESPACE_COLOR   mc_skin_color__cache[42]
+#define EDITOR_RIGHT_MARGIN_COLOR mc_skin_color__cache[43]
 /* color of left 8 char status per line */
-#define LINE_STATE_COLOR          mc_skin_color__cache[35]
-#define BOOK_MARK_COLOR           mc_skin_color__cache[36]
-#define BOOK_MARK_FOUND_COLOR     mc_skin_color__cache[37]
+#define LINE_STATE_COLOR          mc_skin_color__cache[44]
+#define BOOK_MARK_COLOR           mc_skin_color__cache[45]
+#define BOOK_MARK_FOUND_COLOR     mc_skin_color__cache[46]
 
-#define BUTTONBAR_HOTKEY_COLOR    mc_skin_color__cache[38]
-#define BUTTONBAR_BUTTON_COLOR    mc_skin_color__cache[39]
+#define BUTTONBAR_HOTKEY_COLOR    mc_skin_color__cache[47]
+#define BUTTONBAR_BUTTON_COLOR    mc_skin_color__cache[48]
 
 /* Diff colors */
-#define DFF_ADD_COLOR             mc_skin_color__cache[40]
-#define DFF_CHG_COLOR             mc_skin_color__cache[41]
-#define DFF_CHH_COLOR             mc_skin_color__cache[42]
-#define DFF_CHD_COLOR             mc_skin_color__cache[43]
-#define DFF_DEL_COLOR             mc_skin_color__cache[44]
-#define DFF_FOLDER_COLOR          mc_skin_color__cache[45]
-#define DFF_ERROR_COLOR           mc_skin_color__cache[46]
-
-#define MC_SKIN_COLOR_CACHE_COUNT 47
+#define DFF_ADD_COLOR             mc_skin_color__cache[49]
+#define DFF_CHG_COLOR             mc_skin_color__cache[50]
+#define DFF_CHH_COLOR             mc_skin_color__cache[51]
+#define DFF_CHD_COLOR             mc_skin_color__cache[52]
+#define DFF_DEL_COLOR             mc_skin_color__cache[53]
+#define DFF_FOLDER_COLOR          mc_skin_color__cache[54]
+#define DFF_ERROR_COLOR           mc_skin_color__cache[55]
+
+#define MC_SKIN_COLOR_CACHE_COUNT 56
 
 /*** enums ***************************************************************************************/
 

+ 9 - 0
lib/skin/colors.c

@@ -204,16 +204,20 @@ mc_skin_color_cache_init (void)
     MARKED_SELECTED_COLOR = mc_skin_color_get ("core", "markselect");
     DISABLED_COLOR =  mc_skin_color_get ("core", "disabled");
     REVERSE_COLOR = mc_skin_color_get ("core", "reverse");
+    HEADER_COLOR = mc_skin_color_get ("core", "header");
     COMMAND_MARK_COLOR = mc_skin_color_get ("core", "commandlinemark");
 
     COLOR_NORMAL = mc_skin_color_get ("dialog", "_default_");
     COLOR_FOCUS = mc_skin_color_get ("dialog", "dfocus");
     COLOR_HOT_NORMAL = mc_skin_color_get ("dialog", "dhotnormal");
     COLOR_HOT_FOCUS = mc_skin_color_get ("dialog", "dhotfocus");
+    COLOR_TITLE = mc_skin_color_get ("dialog", "dtitle");
 
     ERROR_COLOR = mc_skin_color_get ("error", "_default_");
+    ERROR_FOCUS = mc_skin_color_get ("error", "errdfocus");
     ERROR_HOT_NORMAL = mc_skin_color_get ("error", "errdhotnormal");
     ERROR_HOT_FOCUS = mc_skin_color_get ("error", "errdhotfocus");
+    ERROR_TITLE = mc_skin_color_get ("error", "errdtitle");
 
     MENU_ENTRY_COLOR = mc_skin_color_get ("menu", "_default_");
     MENU_SELECTED_COLOR = mc_skin_color_get ("menu", "menusel");
@@ -223,6 +227,8 @@ mc_skin_color_cache_init (void)
 
     GAUGE_COLOR = mc_skin_color_get ("core", "gauge");
     INPUT_COLOR = mc_skin_color_get ("core", "input");
+    INPUT_HISTORY_COLOR = mc_skin_color_get ("core", "inputhistory");
+    COMMAND_HISTORY_COLOR = mc_skin_color_get ("core", "commandhistory");
     INPUT_MARK_COLOR = mc_skin_color_get ("core", "inputmark");
     INPUT_UNCHANGED_COLOR = mc_skin_color_get ("core", "inputunchanged");
 
@@ -231,8 +237,11 @@ mc_skin_color_cache_init (void)
     HELP_BOLD_COLOR = mc_skin_color_get ("help", "helpbold");
     HELP_LINK_COLOR = mc_skin_color_get ("help", "helplink");
     HELP_SLINK_COLOR = mc_skin_color_get ("help", "helpslink");
+    HELP_TITLE_COLOR = mc_skin_color_get ("help", "helptitle");
 
+    VIEW_BOLD_COLOR = mc_skin_color_get ("viewer", "viewbold");
     VIEW_UNDERLINED_COLOR = mc_skin_color_get ("viewer", "viewunderline");
+    VIEW_SELECTED_COLOR = mc_skin_color_get ("viewer", "viewselected");
 
     EDITOR_NORMAL_COLOR = mc_skin_color_get ("editor", "_default_");
     EDITOR_BOLD_COLOR = mc_skin_color_get ("editor", "editbold");

+ 1 - 1
lib/tty/color.c

@@ -103,7 +103,7 @@ static int
 tty_color_get_next__color_pair_number (void)
 {
     const size_t cp_count = g_hash_table_size (mc_tty_color__hashtable);
-    int cp;
+    size_t cp;
 
     for (cp = 0; cp < cp_count; cp++)
         if (g_hash_table_find (mc_tty_color__hashtable, tty_color_get_next_cpn_cb,

+ 9 - 0
misc/skins/darkfar.ini

@@ -36,17 +36,23 @@
     disabled=gray;blue
     reverse=black;lightgray
     commandlinemark=black;lightgray
+    header=yellow;black
+    inputhistory=
+    commandhistory=
 
 [dialog]
     _default_=brightcyan;blue
     dfocus=blue;cyan
     dhotnormal=white;
     dhotfocus=white;cyan
+    dtitle=white;
 
 [error]
     _default_=white;red
+    errdfocus=black;lightgray
     errdhotnormal=yellow;red
     errdhotfocus=yellow;lightgray
+    errdtitle=yellow;red
 
 [filehighlight]
     directory=white;
@@ -77,6 +83,7 @@
     helpbold=blue;lightgray
     helplink=black;cyan
     helpslink=yellow;blue
+    helptitle=blue;lightgray
 
 [editor]
     _default_=lightgray;black
@@ -89,7 +96,9 @@
     editrightmargin=white;blue
 
 [viewer]
+    viewbold=yellow;black
     viewunderline=brightred;black
+    viewselected=yellow;cyan
 
 [diffviewer]
     added=white;green

+ 10 - 0
misc/skins/default.ini

@@ -36,17 +36,24 @@
     disabled=gray;lightgray
     reverse=black;lightgray
     commandlinemark=black;lightgray
+    header=yellow;blue
+    inputhistory=
+    commandhistory=
 
 [dialog]
     _default_=black;lightgray
     dfocus=black;cyan
     dhotnormal=blue;lightgray
     dhotfocus=blue;cyan
+    dtitle=blue;lightgray
 
 [error]
     _default_=white;red
+    errdfocus=black;lightgray
     errdhotnormal=yellow;red
+    errdtitle=yellow;red
     errdhotfocus=yellow;lightgray
+    errdtitle=yellow;red
 
 [filehighlight]
     directory=white;
@@ -81,6 +88,7 @@
     helpbold=blue;lightgray
     helplink=black;cyan
     helpslink=yellow;blue
+    helptitle=blue;lightgray
 
 [editor]
     _default_=lightgray;blue
@@ -93,7 +101,9 @@
     editrightmargin=brightblue;black
 
 [viewer]
+    viewbold=yellow;blue
     viewunderline=brightred;blue
+    viewselected=yellow;cyan
 
 [diffviewer]
     added=white;green

+ 9 - 0
misc/skins/double-lines.ini

@@ -36,17 +36,23 @@
     commandlinemark=black;lightgray
     disabled=gray;lightgray
     reverse=black;lightgray
+    header=yellow;blue
+    inputhistory=
+    commandhistory=
 
 [dialog]
     _default_=black;lightgray
     dfocus=black;cyan
     dhotnormal=blue;lightgray
     dhotfocus=blue;cyan
+    dtitle=blue;lightgray
 
 [error]
     _default_=white;red
+    errdfocus=black;lightgray
     errdhotnormal=yellow;red
     errdhotfocus=yellow;lightgray
+    errdtitle=yellow;red
 
 [filehighlight]
     directory=white;
@@ -77,6 +83,7 @@
     helpbold=blue;lightgray
     helplink=black;cyan
     helpslink=yellow;blue
+    helptitle=blue;lightgray
 
 [editor]
     _default_=lightgray;blue
@@ -89,7 +96,9 @@
     editrightmargin=brightblue;black
 
 [viewer]
+    viewbold=yellow;blue
     viewunderline=brightred;blue
+    viewselected=yellow;cyan
 
 [diffviewer]
     added=white;green

+ 9 - 0
misc/skins/featured.ini

@@ -38,17 +38,23 @@
     disabled=gray;lightgray
     reverse=black;lightgray
     commandlinemark=black;lightgray
+    header=yellow;blue
+    inputhistory=
+    commandhistory=
 
 [dialog]
     _default_=black;lightgray
     dfocus=black;cyan
     dhotnormal=blue;lightgray
     dhotfocus=blue;cyan
+    dtitle=blue;lightgray
 
 [error]
     _default_=white;red
+    errdfocus=black;lightgray
     errdhotnormal=yellow;red
     errdhotfocus=yellow;lightgray
+    errdtitle=yellow;red
 
 [filehighlight]
     directory=white;
@@ -83,6 +89,7 @@
     helpbold=blue;lightgray
     helplink=black;cyan
     helpslink=yellow;blue
+    helptitle=blue;lightgray
 
 [editor]
     _default_=lightgray;blue
@@ -95,7 +102,9 @@
     editrightmargin=brightblue;black
 
 [viewer]
+    viewbold=yellow;blue
     viewunderline=brightred;blue
+    viewselected=yellow;cyan
 
 [diffviewer]
     added=white;green

+ 9 - 0
misc/skins/gotar.ini

@@ -33,17 +33,23 @@
 	input=brightgreen;
 	disabled=gray;blue
 	reverse=brightgreen;blue
+	header=brightred;
+	inputhistory=
+	commandhistory=
 
 [dialog]
 	_default_=brightcyan;blue
 	dfocus=brightred;black
 	dhotnormal=brightred;
 	dhotfocus=yellow;black
+	dtitle=brightred;
 
 [error]
 	_default_=white;red
+	errdfocus=brightgreen;blue
 	errdhotnormal=yellow;
 	errdhotfocus=yellow;blue
+	errdtitle=yellow;
 
 [filehighlight]
 	directory=brightcyan;
@@ -74,6 +80,7 @@
 	helpbold=brightgreen;
 	helplink=white;
 	helpslink=yellow;blue
+	helptitle=brightgreen;
 
 [editor]
 	_default_=lightgray;black
@@ -86,7 +93,9 @@
 	editrightmargin=brightblue;blue
 
 [viewer]
+	viewbold=brightred;black
 	viewunderline=brightgreen;black
+	viewselected=yellow;black
 
 [diffviewer]
 	_default_=lightgray;black

+ 7 - 12
src/boxes.c

@@ -155,13 +155,6 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
     int dlg_width = 48, dlg_height = 15;
     Dlg_head *dd;
 
-    const int input_colors[3] =
-    {
-        INPUT_COLOR,
-        INPUT_UNCHANGED_COLOR,
-        INPUT_MARK_COLOR
-    };
-
     /* Controls whether the array strings have been translated */
     const char *displays[LIST_TYPES] = {
         N_("&Full file list"),
@@ -230,14 +223,14 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
     add_widget (dd, cancel_button);
     add_widget (dd, ok_button);
 
-    display_mini_status = input_new (10, 8, (int *) input_colors, dlg_width - 12, _status[radio_sel],
+    display_mini_status = input_new (10, 8, input_get_default_colors(), dlg_width - 12, _status[radio_sel],
                                      "mini-input", INPUT_COMPLETE_DEFAULT);
     add_widget (dd, display_mini_status);
 
     display_check_status = check_new (9, 4, _check_status, user_mini_status);
     add_widget (dd, display_check_status);
 
-    display_user_format = input_new (7, 8, (int *) input_colors, dlg_width - 12, init_text,
+    display_user_format = input_new (7, 8, input_get_default_colors(), dlg_width - 12, init_text,
                                      "user-fmt-input", INPUT_COMPLETE_DEFAULT);
     add_widget (dd, display_user_format);
 
@@ -1134,16 +1127,18 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c
 
     g_free (title);
 
-    in_user = input_new (5, istart, (int *) input_colors, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT);
+    in_user = input_new (5, istart, input_get_default_colors(), ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT);
     add_widget (auth_dlg, in_user);
 
-    in_domain = input_new (3, istart, (int *) input_colors, ilen, domain, "auth_domain", INPUT_COMPLETE_DEFAULT);
+    in_domain =
+        input_new (3, istart, input_get_default_colors(), ilen, domain, "auth_domain", INPUT_COMPLETE_DEFAULT);
 
     add_widget (auth_dlg, in_domain);
     add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON, buts[1], 0));
     add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON, buts[0], 0));
 
-    in_password  = input_new (7, istart, (int *) input_colors, ilen, "", "auth_password", INPUT_COMPLETE_DEFAULT);
+    in_password  =
+            input_new (7, istart, input_get_default_colors(), ilen, "", "auth_password", INPUT_COMPLETE_DEFAULT);
 
     in_password->completion_flags = 0;
     in_password->is_password = 1;

+ 3 - 2
src/command.c

@@ -308,11 +308,12 @@ WInput *
 command_new (int y, int x, int cols)
 {
     WInput *cmd;
-    const int command_colors[3] =
+    const input_colors_t command_colors =
     {
         DEFAULT_COLOR,
         DEFAULT_COLOR,
-        COMMAND_MARK_COLOR
+        DEFAULT_COLOR,
+        COMMAND_HISTORY_COLOR
     };
 
     cmd = input_new (y, x, (int *) command_colors, cols, "", "cmdline",

Some files were not shown because too many files changed in this diff