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.
This commit is contained in:
Fabian Homborg 2021-12-13 20:21:34 +01:00
parent c75ecf9b03
commit 235581e8dc
2 changed files with 24 additions and 6 deletions

View file

@ -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 = {

View file

@ -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_"):