diff --git a/share/tools/web_config/js/controllers.js b/share/tools/web_config/js/controllers.js index 439d7ba15..03ff85516 100644 --- a/share/tools/web_config/js/controllers.js +++ b/share/tools/web_config/js/controllers.js @@ -143,6 +143,10 @@ controllers.controller("colorsController", function($scope, $http) { "fish_pager_color_progress" ]; var remaining = settingNames.length; + postdata = { + "theme" : $scope.selectedColorScheme["name"], + "colors": [], + } for (name of settingNames) { var selected; // Skip colors undefined in the current theme @@ -157,17 +161,16 @@ controllers.controller("colorsController", function($scope, $http) { } else { selected = $scope.selectedColorScheme[name]; } - var postData = "what=" + name + "&color=" + selected + "&background_color=&bold=&underline=&dim=&reverse=&italics="; - $http.post("set_color/", postData, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(function(arg) { - if (arg.status == 200) { - remaining -= 1; - if (remaining == 0) { - /* All styles set! */ - $scope.saveThemeButtonTitle = "Theme Set!"; - } - } - }) + postdata.colors.push({ + "what" : name, + "color" : selected, + }); } + $http.post("set_color/", postdata, { headers: {'Content-Type': 'application/json'} }).then(function(arg) { + if (arg.status == 200) { + $scope.saveThemeButtonTitle = "Theme Set!"; + } + }) }; $scope.getCurrentTheme(); diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index f1890eb6e..30fc79701 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -1075,9 +1075,11 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): return out def do_set_color_for_variable( - self, name, color, background_color, bold, underline, italics, dim, reverse + self, name, color ): "Sets a color for a fish color name, like 'autosuggestion'" + if not name: + raise ValueError if not color: color = "normal" varname = "fish_color_" + name @@ -1087,20 +1089,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): varname = name # TODO: Check if the varname is allowable. command = "set -U " + varname - if color: - command += " " + color - if background_color: - command += " --background=" + background_color - if bold: - command += " --bold" - if underline: - command += " --underline" - if italics: - command += " --italics" - if dim: - command += " --dim" - if reverse: - command += " --reverse" + command += " " + color out, err = run_fish_cmd(command) return out @@ -1368,27 +1357,16 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): postvars = {} if p == "/set_color/": - what = postvars.get("what") - color = postvars.get("color") - background_color = postvars.get("background_color") - bold = postvars.get("bold") - italics = postvars.get("italics") - reverse = postvars.get("reverse") - dim = postvars.get("dim") - underline = postvars.get("underline") + print("# Colorscheme: " + postvars.get("theme")) + for item in postvars.get("colors"): + what = item.get("what") + color = item.get("color") - if what: - # Not sure why we get lists here? - output = self.do_set_color_for_variable( - what[0], - color[0], - background_color[0], - parse_bool(bold[0]), - parse_bool(underline[0]), - parse_bool(italics[0]), - parse_bool(dim[0]), - parse_bool(reverse[0]), - ) + if what: + output = self.do_set_color_for_variable( + what, + color, + ) else: output = "Bad request" elif p == "/get_function/":