From 235581e8dc32a089fcafb96a456cb1139db885ad Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 13 Dec 2021 20:21:34 +0100 Subject: [PATCH] webconfig: Allow setting most pager colors I'm not sure this ever worked before for most of these. It currently still doesn't set the background, and the secondary colors have a weird fallback. --- share/tools/web_config/js/controllers.js | 21 ++++++++++++++++++--- share/tools/web_config/webconfig.py | 9 ++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/share/tools/web_config/js/controllers.js b/share/tools/web_config/js/controllers.js index b29de6d47..a6708861d 100644 --- a/share/tools/web_config/js/controllers.js +++ b/share/tools/web_config/js/controllers.js @@ -82,7 +82,7 @@ controllers.controller("colorsController", function($scope, $http) { $scope.colorSchemes = []; isValidColor = function(col) { - // Check if preferred_background is actually a valid color + if (col == "normal") return true; var s = new Option().style; s.color = col; return !!s.color; @@ -140,10 +140,25 @@ controllers.controller("colorsController", function($scope, $http) { "user", "host", "cancel", + // Cheesy hardcoded variable names ahoy! + // These are all the pager vars, + // we should really just save all these in a dictionary. + "fish_pager_color_background", + "fish_pager_color_prefix", + "fish_pager_color_progress", "fish_pager_color_completion", "fish_pager_color_description", - "fish_pager_color_prefix", - "fish_pager_color_progress" + "fish_pager_color_selected_background", + "fish_pager_color_selected_prefix", + "fish_pager_color_selected_completion", + "fish_pager_color_selected_description", + // TODO: Setting these to empty currently makes them weird. Figure out why! + /* + "fish_pager_color_secondary_background", + "fish_pager_color_secondary_prefix", + "fish_pager_color_secondary_completion", + "fish_pager_color_secondary_description", + */ ]; var remaining = settingNames.length; var postdata = { diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 3759f7c09..a4af0a9c6 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -970,8 +970,10 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): extrainfo[key] = value - for match in re.finditer(r"^fish_color_(\S+) ?(.*)", line): - color_name, color_value = [x.strip() for x in match.group(1, 2)] + for match in re.finditer(r"^fish_(pager_)?color_(\S+) ?(.*)", line): + color_name, color_value = [x.strip() for x in match.group(2, 3)] + if match.group(1): + color_name = "fish_pager_color_" + color_name color_desc = descriptions.get(color_name, "") data = {"name": color_name, "description": color_desc} data.update(parse_color(color_value)) @@ -1112,7 +1114,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): raise ValueError if not color and not color == "": color = "normal" - varname = "fish_color_" + name + if not name.startswith("fish_pager_color_"): + varname = "fish_color_" + name # If the name already starts with "fish_", use it as the varname # This is needed for 'fish_pager_color' vars. if name.startswith("fish_"):