From aa1513ed92deb690d65009549da0ac2c1a1a2683 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 7 Apr 2020 21:24:11 +0100 Subject: [PATCH] Directory listings: Update to use nscolour. --- content/dirlist.c | 76 +++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 55 deletions(-) diff --git a/content/dirlist.c b/content/dirlist.c index d34d3ffcd..3f79e658d 100644 --- a/content/dirlist.c +++ b/content/dirlist.c @@ -27,6 +27,7 @@ #include "utils/nsurl.h" #include "utils/messages.h" +#include "utils/nscolour.h" #include "netsurf/types.h" #include "netsurf/plot_style.h" @@ -140,38 +141,18 @@ bool dirlist_generate_hide_columns(int flags, char *buffer, int buffer_length) bool dirlist_generate_title(const char *title, char *buffer, int buffer_length) { + const char *stylesheet; nserror err; int error; - colour bg; - colour fg; - colour odd; - colour even; - colour border; - - err = ns_system_colour_char("Window", &bg); - if (err != NSERROR_OK) { - return false; - } - - err = ns_system_colour_char("WindowText", &fg); - if (err != NSERROR_OK) { - return false; - } - - odd = mix_colour(fg, bg, 0x18); - even = mix_colour(fg, bg, 0x0c); - border = mix_colour(fg, bg, 0x40); - - bg = colour_rb_swap(bg); - fg = colour_rb_swap(fg); - odd = colour_rb_swap(odd); - even = colour_rb_swap(even); - border = colour_rb_swap(border); - if (title == NULL) title = ""; + err = nscolour_get_stylesheet(&stylesheet); + if (err != NSERROR_OK) { + return false; + } + error = snprintf(buffer, buffer_length, "\n" "%s\n" @@ -179,29 +160,14 @@ bool dirlist_generate_title(const char *title, char *buffer, int buffer_length) "html {\n" "\tbackground-color: #%06x;\n" "}\n" - "body {\n" - "\tcolor: #%06x;\n" - "\tbackground-color: #%06x;\n" - "\tborder-color: #%06x;\n" - "}\n" - "body#dirlist h1 {\n" - "\tborder-color: #%06x;\n" - "}\n" - "body#dirlist a.odd {\n" - "\tbackground-color: #%06x;\n" - "}\n" - "body#dirlist a.even {\n" - "\tbackground-color: #%06x;\n" - "}\n" - "body#dirlist a + a>span {\n" - "\tborder-color: #%06x;\n" - "}\n" + "%s" "\n" "\n" - "\n" - "

%s

\n", - title, even, fg, bg, border, border, odd, - even, border, title); + "\n" + "

%s

\n", + title, + colour_rb_swap(nscolours[NSCOLOUR_WIN_ODD_BG]), + stylesheet, title); if (error < 0 || error >= buffer_length) /* Error or buffer too small */ return false; @@ -338,14 +304,14 @@ bool dirlist_generate_row(bool even, bool directory, nsurl *url, char *name, error = snprintf(buffer, buffer_length, "\n" - "\t%s\n" - "\t%s\n" - "\t%s" - "%s\n" - "\t%s\n" - "\t%s\n" - "\n", - nsurl_access(url), even ? "even" : "odd", + "\t%s\n" + "\t%s\n" + "\t%s" + "%s\n" + "\t%s\n" + "\t%s\n" + "\n", nsurl_access(url), + even ? "even ns-even-bg" : "odd ns-odd-bg", directory ? "dir" : "file", name, mimetype, size_string, unit, date, time); if (error < 0 || error >= buffer_length)