2020-07-27 11:20:41 +00:00
|
|
|
# Copyright 2020 Canonical, Ltd.
|
2017-09-08 01:00:18 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-11-21 22:26:47 +00:00
|
|
|
|
|
|
|
COLORS = [
|
2018-04-18 22:33:51 +00:00
|
|
|
# black
|
2017-11-22 00:28:08 +00:00
|
|
|
("bg", (0x11, 0x11, 0x11)),
|
2020-07-27 11:20:41 +00:00
|
|
|
# dark red
|
2018-03-12 01:28:34 +00:00
|
|
|
("danger", (0xFF, 0x00, 0x00)),
|
2018-04-18 22:33:51 +00:00
|
|
|
# dark green
|
2017-11-22 00:28:08 +00:00
|
|
|
("good", (0x0E, 0x84, 0x20)),
|
2018-04-18 22:33:51 +00:00
|
|
|
# brown
|
|
|
|
("orange", (0xE9, 0x54, 0x20)),
|
|
|
|
# dark blue
|
2017-11-22 00:28:08 +00:00
|
|
|
("neutral", (0x00, 0x7A, 0xA6)),
|
2018-04-18 22:33:51 +00:00
|
|
|
# dark magenta
|
2017-11-22 00:28:08 +00:00
|
|
|
("brand", (0x33, 0x33, 0x33)),
|
2018-04-18 22:33:51 +00:00
|
|
|
# dark cyan
|
2022-08-24 13:00:07 +00:00
|
|
|
("gray", (0x80, 0x80, 0x80)),
|
2018-04-18 22:33:51 +00:00
|
|
|
# light gray
|
2017-11-21 22:26:47 +00:00
|
|
|
("fg", (0xFF, 0xFF, 0xFF)),
|
|
|
|
]
|
2017-09-28 13:28:21 +00:00
|
|
|
|
2020-07-27 11:20:41 +00:00
|
|
|
PALETTE_COLOR = [
|
2019-09-25 01:29:44 +00:00
|
|
|
("frame_header_fringe", "orange", "bg"),
|
2017-09-28 13:28:21 +00:00
|
|
|
("frame_header", "fg", "orange"),
|
|
|
|
("body", "fg", "bg"),
|
2017-11-21 21:16:04 +00:00
|
|
|
("done_button", "fg", "bg"),
|
|
|
|
("danger_button", "fg", "bg"),
|
|
|
|
("other_button", "fg", "bg"),
|
2017-11-22 00:28:08 +00:00
|
|
|
("done_button focus", "fg", "good"),
|
|
|
|
("danger_button focus", "fg", "danger"),
|
|
|
|
("other_button focus", "fg", "gray"),
|
|
|
|
("menu_button", "fg", "bg"),
|
|
|
|
("menu_button focus", "fg", "gray"),
|
2019-09-25 02:25:11 +00:00
|
|
|
("frame_button", "fg", "orange"),
|
|
|
|
("frame_button focus", "orange", "fg"),
|
2017-09-28 13:28:21 +00:00
|
|
|
("info_primary", "fg", "bg"),
|
|
|
|
("info_minor", "gray", "bg"),
|
2019-02-05 00:55:17 +00:00
|
|
|
("info_minor header", "gray", "orange"),
|
2017-09-28 13:28:21 +00:00
|
|
|
("info_error", "danger", "bg"),
|
2017-11-22 00:28:08 +00:00
|
|
|
("string_input", "bg", "fg"),
|
|
|
|
("string_input focus", "fg", "gray"),
|
|
|
|
("progress_incomplete", "fg", "gray"),
|
|
|
|
("progress_complete", "fg", "neutral"),
|
2018-06-18 09:24:23 +00:00
|
|
|
("scrollbar", "brand", "bg"),
|
|
|
|
("scrollbar focus", "gray", "bg"),
|
2019-01-31 08:48:34 +00:00
|
|
|
("verified", "good", "bg"),
|
|
|
|
("verified focus", "good", "gray"),
|
2022-05-04 09:47:34 +00:00
|
|
|
("verified invisible", "bg", "bg"),
|
|
|
|
("verified inv focus", "gray", "gray"),
|
2022-05-06 09:37:48 +00:00
|
|
|
("starred", "orange", "bg"),
|
|
|
|
("starred focus", "orange", "gray"),
|
2022-06-03 17:59:43 +00:00
|
|
|
("user_code", "fg", "good"),
|
2017-09-08 01:00:18 +00:00
|
|
|
]
|
|
|
|
|
2020-07-27 11:20:41 +00:00
|
|
|
PALETTE_MONO = [
|
2019-10-03 09:47:14 +00:00
|
|
|
("frame_header_fringe", "white", "black"),
|
|
|
|
("frame_header", "black", "white"),
|
2017-11-23 22:23:26 +00:00
|
|
|
("body", "white", "black"),
|
|
|
|
("done_button", "white", "black"),
|
|
|
|
("danger_button", "white", "black"),
|
|
|
|
("other_button", "white", "black"),
|
|
|
|
("done_button focus", "black", "white"),
|
|
|
|
("danger_button focus", "black", "white"),
|
|
|
|
("other_button focus", "black", "white"),
|
|
|
|
("menu_button", "white", "black"),
|
|
|
|
("menu_button focus", "black", "white"),
|
2019-10-03 09:47:14 +00:00
|
|
|
("frame_button", "black", "white"),
|
|
|
|
("frame_button focus", "white", "black"),
|
2017-11-23 22:23:26 +00:00
|
|
|
("info_primary", "white", "black"),
|
|
|
|
("info_minor", "white", "black"),
|
2019-10-03 09:47:14 +00:00
|
|
|
("info_minor header", "black", "white"),
|
2017-11-23 22:23:26 +00:00
|
|
|
("info_error", "white", "black"),
|
|
|
|
("string_input", "white", "black"),
|
|
|
|
("string_input focus", "black", "white"),
|
|
|
|
("progress_incomplete", "white", "black"),
|
|
|
|
("progress_complete", "black", "white"),
|
|
|
|
("scrollbar_fg", "white", "black"),
|
|
|
|
("scrollbar_bg", "white", "black"),
|
2022-05-04 08:18:16 +00:00
|
|
|
("verified", "white", "black"),
|
|
|
|
("verified focus", "black", "white"),
|
2022-05-04 09:47:34 +00:00
|
|
|
("verified invisible", "white", "black"),
|
|
|
|
("verified inv focus", "black", "white"),
|
2022-05-06 09:37:48 +00:00
|
|
|
("starred", "white", "black"),
|
|
|
|
("starred focus", "black", "white"),
|
2022-06-03 17:59:43 +00:00
|
|
|
("user_code", "white", "black"),
|
2017-09-08 01:00:18 +00:00
|
|
|
]
|
2020-07-27 11:20:41 +00:00
|
|
|
|
|
|
|
urwid_8_names = (
|
|
|
|
"black",
|
|
|
|
"dark red",
|
|
|
|
"dark green",
|
|
|
|
"brown",
|
|
|
|
"dark blue",
|
|
|
|
"dark magenta",
|
|
|
|
"dark cyan",
|
|
|
|
"light gray",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def _urwidize_palette(colors, styles):
|
|
|
|
"""Return a palette to be passed to MainLoop.
|
|
|
|
|
|
|
|
colors is a list of exactly 8 tuples (name, (r, g, b))
|
|
|
|
|
|
|
|
styles is a list of tuples (stylename, fg_color, bg_color) where
|
|
|
|
fg_color and bg_color are defined in 'colors'
|
|
|
|
"""
|
|
|
|
# The part that makes this "fun" is that urwid insists on referring
|
|
|
|
# to the basic colors by their "standard" names but we overwrite
|
|
|
|
# these colors to mean different things. So we convert styles into
|
|
|
|
# an urwid palette by mapping the names in colors to the standard
|
|
|
|
# name.
|
|
|
|
if len(colors) != 8:
|
|
|
|
raise Exception("make_palette must be passed a list of exactly 8 colors")
|
|
|
|
urwid_name = dict(zip([c[0] for c in colors], urwid_8_names))
|
|
|
|
|
|
|
|
urwid_palette = []
|
|
|
|
for name, fg, bg in styles:
|
|
|
|
urwid_fg, urwid_bg = urwid_name[fg], urwid_name[bg]
|
|
|
|
urwid_palette.append((name, urwid_fg, urwid_bg))
|
|
|
|
|
|
|
|
return urwid_palette
|
|
|
|
|
|
|
|
|
|
|
|
PALETTE_COLOR = _urwidize_palette(COLORS, PALETTE_COLOR)
|