|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +檢查 menuconfig.py 的顏色設定是否符合 mconf |
| 4 | +""" |
| 5 | + |
| 6 | +import re |
| 7 | + |
| 8 | +# 讀取 menuconfig.py 的顏色設定 |
| 9 | +with open("menuconfig.py", "r") as f: |
| 10 | + content = f.read() |
| 11 | + |
| 12 | +# 提取 _STYLES["default"] |
| 13 | +match = re.search(r'_STYLES = \{[^}]*"default": """([^"]+)"""', content, re.DOTALL) |
| 14 | +if match: |
| 15 | + styles = match.group(1) |
| 16 | + print("Kconfiglib 顏色設定:") |
| 17 | + print("=" * 60) |
| 18 | + for line in styles.strip().split("\n"): |
| 19 | + line = line.strip() |
| 20 | + if line: |
| 21 | + print(f" {line}") |
| 22 | + print() |
| 23 | + |
| 24 | +# mconf 顏色對照表 (from util.c:61-89) |
| 25 | +print("mconf bluetitle theme 對照:") |
| 26 | +print("=" * 60) |
| 27 | +mconf_colors = [ |
| 28 | + ("screen", "CYAN", "BLUE", "bold"), |
| 29 | + ("dialog", "BLACK", "WHITE", ""), |
| 30 | + ("title", "YELLOW", "WHITE", "bold"), |
| 31 | + ("border", "WHITE", "WHITE", "bold"), |
| 32 | + ("button_active", "WHITE", "BLUE", "bold"), |
| 33 | + ("button_inactive", "BLACK", "WHITE", ""), |
| 34 | + ("item", "BLACK", "WHITE", ""), |
| 35 | + ("item_selected", "WHITE", "BLUE", "bold"), |
| 36 | + ("tag", "YELLOW", "WHITE", "bold"), |
| 37 | + ("uarrow/darrow", "GREEN", "WHITE", "bold"), |
| 38 | + ("menubox", "BLACK", "WHITE", ""), |
| 39 | + ("menubox_border", "WHITE", "WHITE", "bold"), |
| 40 | +] |
| 41 | + |
| 42 | +for name, fg, bg, attr in mconf_colors: |
| 43 | + attr_str = f",{attr}" if attr else "" |
| 44 | + print(f" {name:20s} = fg:{fg.lower()},bg:{bg.lower()}{attr_str}") |
| 45 | + |
| 46 | +print() |
| 47 | +print("對應關係:") |
| 48 | +print("=" * 60) |
| 49 | +mappings = [ |
| 50 | + ("screen", "→", "螢幕背景 (_stdscr.bkgd)"), |
| 51 | + ("dialog/item", "→", "list (fg:black,bg:white)"), |
| 52 | + ("border", "→", "frame (fg:white,bg:white,bold)"), |
| 53 | + ("item_selected", "→", "selection (fg:white,bg:blue,bold)"), |
| 54 | + ("tag", "→", "path/help (fg:yellow,bg:white,bold)"), |
| 55 | + ("uarrow/darrow", "→", "arrow (fg:green,bg:white,bold)"), |
| 56 | + ("title", "→", "path (fg:yellow,bg:white,bold)"), |
| 57 | +] |
| 58 | + |
| 59 | +for mconf, arrow, kconfiglib in mappings: |
| 60 | + print(f" {mconf:20s} {arrow} {kconfiglib}") |
0 commit comments