codis 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codis-1.1.1.dist-info/METADATA +194 -0
- codis-1.1.1.dist-info/RECORD +329 -0
- codis-1.1.1.dist-info/WHEEL +5 -0
- codis-1.1.1.dist-info/entry_points.txt +5 -0
- codis-1.1.1.dist-info/licenses/LICENSE +21 -0
- codis-1.1.1.dist-info/top_level.txt +2 -0
- run.py +190 -0
- src/__init__.py +1 -0
- src/__main__.py +81 -0
- src/_app_build.py +1507 -0
- src/_app_editor.py +1274 -0
- src/_app_kui.py +825 -0
- src/_app_lsp.py +625 -0
- src/_app_recovery.py +189 -0
- src/_app_settings.py +1385 -0
- src/_app_tools.py +2471 -0
- src/_app_webpreview.py +126 -0
- src/_font_safety.py +127 -0
- src/_shells.py +172 -0
- src/app.py +1488 -0
- src/chat/__init__.py +1 -0
- src/chat/adapters/__init__.py +33 -0
- src/chat/adapters/base.py +209 -0
- src/chat/adapters/discord.py +190 -0
- src/chat/adapters/http.py +78 -0
- src/chat/adapters/irc.py +360 -0
- src/chat/adapters/matrix.py +219 -0
- src/chat/adapters/mattermost.py +178 -0
- src/chat/adapters/mqtt.py +165 -0
- src/chat/adapters/slack.py +204 -0
- src/chat/adapters/telegram.py +117 -0
- src/chat/adapters/ws.py +154 -0
- src/chat/adapters/xmpp.py +337 -0
- src/chat/history.py +76 -0
- src/chat/models.py +207 -0
- src/chat/probe.py +79 -0
- src/chat/session.py +446 -0
- src/chat/util.py +125 -0
- src/collab/__init__.py +1 -0
- src/collab/net.py +411 -0
- src/collab/ot.py +311 -0
- src/collab/session.py +141 -0
- src/collab/tk_adapter.py +134 -0
- src/config.py +335 -0
- src/constants.py +2552 -0
- src/dep_catalog.py +446 -0
- src/diff/__init__.py +1 -0
- src/diff/engine.py +247 -0
- src/dpi.py +30 -0
- src/editor/__init__.py +1 -0
- src/editor/_pane_lsp.py +2937 -0
- src/editor/_pane_utils.py +171 -0
- src/editor/autocomplete.py +607 -0
- src/editor/code_folding.py +836 -0
- src/editor/color_preview.py +382 -0
- src/editor/complexity_lens.py +281 -0
- src/editor/diff_pane.py +623 -0
- src/editor/file_watcher.py +144 -0
- src/editor/focus_block.py +236 -0
- src/editor/heatmap.py +141 -0
- src/editor/inlay_hints.py +366 -0
- src/editor/inline_blame.py +429 -0
- src/editor/kdocs.py +3376 -0
- src/editor/large_file.py +488 -0
- src/editor/ligatures.py +180 -0
- src/editor/line_numbers.py +598 -0
- src/editor/minimap.py +691 -0
- src/editor/multi_cursor.py +269 -0
- src/editor/pane.py +2082 -0
- src/editor/rhythm.py +206 -0
- src/editor/save_hooks.py +43 -0
- src/editor/smart_selection.py +425 -0
- src/editor/smart_tips.py +719 -0
- src/editor/snippets.py +411 -0
- src/editor/sticky_note_gutter.py +410 -0
- src/editor/sticky_scroll.py +385 -0
- src/editor/suggest.py +464 -0
- src/editor/text_transforms.py +310 -0
- src/editor/vim_mode.py +1074 -0
- src/events/__init__.py +84 -0
- src/events/bus.py +427 -0
- src/events/correlator.py +244 -0
- src/events/kinds.py +125 -0
- src/events/pipeline.py +264 -0
- src/events/stream.py +416 -0
- src/events/window.py +204 -0
- src/extcompat/__init__.py +19 -0
- src/extcompat/code/__init__.py +13 -0
- src/extcompat/code/consent.py +162 -0
- src/extcompat/code/host.py +353 -0
- src/extcompat/code/hosts/py_host.py +763 -0
- src/extcompat/code/locate.py +105 -0
- src/extcompat/code/manager.py +325 -0
- src/extcompat/code/permissions.py +154 -0
- src/extcompat/code/sandbox.py +60 -0
- src/extcompat/colors.py +131 -0
- src/extcompat/common.py +184 -0
- src/extcompat/cson.py +269 -0
- src/extcompat/formats/__init__.py +22 -0
- src/extcompat/formats/_tm.py +189 -0
- src/extcompat/formats/_util.py +31 -0
- src/extcompat/formats/base16.py +66 -0
- src/extcompat/formats/brackets.py +172 -0
- src/extcompat/formats/eclipse.py +193 -0
- src/extcompat/formats/emacs.py +361 -0
- src/extcompat/formats/geany.py +147 -0
- src/extcompat/formats/generic.py +184 -0
- src/extcompat/formats/gtksource.py +117 -0
- src/extcompat/formats/helix.py +91 -0
- src/extcompat/formats/jetbrains.py +343 -0
- src/extcompat/formats/kate.py +130 -0
- src/extcompat/formats/micro.py +131 -0
- src/extcompat/formats/nano.py +111 -0
- src/extcompat/formats/notepadpp.py +140 -0
- src/extcompat/formats/pulsar.py +165 -0
- src/extcompat/formats/pyides.py +163 -0
- src/extcompat/formats/sublime.py +340 -0
- src/extcompat/jsonc.py +65 -0
- src/extcompat/lessish.py +128 -0
- src/extcompat/manager.py +122 -0
- src/extcompat/market/__init__.py +63 -0
- src/extcompat/market/sources.py +211 -0
- src/extcompat/model.py +88 -0
- src/extcompat/net.py +228 -0
- src/extcompat/openvsx.py +63 -0
- src/extcompat/readers.py +362 -0
- src/extcompat/registry.py +73 -0
- src/extcompat/safexml.py +63 -0
- src/extcompat/sexp.py +187 -0
- src/extcompat/sources.py +105 -0
- src/extcompat/store.py +276 -0
- src/extcompat/textmate.py +214 -0
- src/extcompat/themes.py +487 -0
- src/extcompat/yamlite.py +294 -0
- src/fileio.py +94 -0
- src/fs_ops.py +106 -0
- src/i18n.py +233 -0
- src/ia/__init__.py +1 -0
- src/ia/actions.py +295 -0
- src/ia/approval_gate.py +672 -0
- src/ia/checkpoints.py +308 -0
- src/ia/context_builder.py +921 -0
- src/ia/dialdiff.py +408 -0
- src/ia/iaspace.py +2078 -0
- src/ia/pair.py +296 -0
- src/ia/providers.py +954 -0
- src/ia/session.py +335 -0
- src/ia/toolbox.py +2524 -0
- src/launcher_actions.py +204 -0
- src/lint/__init__.py +1 -0
- src/lint/manager.py +1058 -0
- src/locales/.translate_manifest.json +64170 -0
- src/locales/de.json +4936 -0
- src/locales/en.json +4936 -0
- src/locales/es.json +4936 -0
- src/locales/fr.json +4936 -0
- src/locales/it.json +4936 -0
- src/locales/ja.json +4936 -0
- src/locales/ko.json +4936 -0
- src/locales/nl.json +4936 -0
- src/locales/pl.json +4936 -0
- src/locales/pt-BR.json +4936 -0
- src/locales/ru.json +4936 -0
- src/locales/tr.json +4936 -0
- src/locales/uk.json +4936 -0
- src/locales/zh-CN.json +4936 -0
- src/lsp/__init__.py +26 -0
- src/lsp/client.py +2300 -0
- src/lsp/dap_client.py +480 -0
- src/lsp/edits.py +84 -0
- src/lsp/framing.py +73 -0
- src/lsp/protocol.py +931 -0
- src/main.py +260 -0
- src/memtrim.py +91 -0
- src/plugins/__init__.py +1 -0
- src/plugins/api.py +1761 -0
- src/plugins/loader.py +571 -0
- src/plugins/process_runner.py +519 -0
- src/plugins/registry.py +342 -0
- src/plugins/safety.py +367 -0
- src/plugins/startup.py +195 -0
- src/plugins/store.py +1178 -0
- src/proc_registry.py +278 -0
- src/pyexec.py +394 -0
- src/recovery.py +259 -0
- src/stall_trace.py +92 -0
- src/standalone.py +1070 -0
- src/startup_profile.py +35 -0
- src/syntax/__init__.py +1 -0
- src/syntax/highlighter.py +776 -0
- src/syntax/patterns.py +584 -0
- src/system_profile.py +430 -0
- src/terminal/backends.py +658 -0
- src/terminal/internal.py +346 -0
- src/terminal/keys.py +138 -0
- src/terminal/palette.py +67 -0
- src/terminal/session.py +283 -0
- src/terminal/shells.py +79 -0
- src/terminal/view.py +489 -0
- src/terminal/vt.py +870 -0
- src/textfmt.py +22 -0
- src/theme/__init__.py +1 -0
- src/theme/base.py +1281 -0
- src/theme/colors.py +49 -0
- src/theme/manager.py +602 -0
- src/theme/utils.py +312 -0
- src/toolbox.py +329 -0
- src/trash_core.py +531 -0
- src/ui/__init__.py +1 -0
- src/ui/_perf_utils.py +285 -0
- src/ui/_persistence_utils.py +93 -0
- src/ui/accessibility.py +843 -0
- src/ui/activity_bar.py +860 -0
- src/ui/app_embed.py +434 -0
- src/ui/archive_panel.py +608 -0
- src/ui/bookmarks.py +314 -0
- src/ui/breadcrumb.py +383 -0
- src/ui/calculator_panel.py +982 -0
- src/ui/calendar_panel.py +1218 -0
- src/ui/chat_panel.py +1271 -0
- src/ui/chat_profile_dialog.py +278 -0
- src/ui/chat_render.py +128 -0
- src/ui/clock_panel.py +810 -0
- src/ui/code_outline.py +364 -0
- src/ui/code_runner.py +729 -0
- src/ui/code_stats.py +546 -0
- src/ui/collab_panel.py +1009 -0
- src/ui/color_picker.py +547 -0
- src/ui/command_palette.py +452 -0
- src/ui/cursor_manager.py +750 -0
- src/ui/custom_keywords_panel.py +413 -0
- src/ui/debug_panel.py +1037 -0
- src/ui/dependency_graph.py +692 -0
- src/ui/diff_panel.py +381 -0
- src/ui/docs_panel.py +514 -0
- src/ui/doom_embed.py +349 -0
- src/ui/dropdown.py +321 -0
- src/ui/easter_eggs.py +979 -0
- src/ui/env_manager.py +666 -0
- src/ui/extcode_bridge.py +215 -0
- src/ui/extcode_dialogs.py +412 -0
- src/ui/extcompat_dialog.py +583 -0
- src/ui/file_timeline.py +319 -0
- src/ui/file_tree.py +1208 -0
- src/ui/find_in_files.py +1355 -0
- src/ui/flowchart_panel.py +727 -0
- src/ui/formatter_panel.py +490 -0
- src/ui/git_auth.py +763 -0
- src/ui/git_clone_dialog.py +487 -0
- src/ui/git_panel.py +1483 -0
- src/ui/grab_safe.py +84 -0
- src/ui/internal_python_dialog.py +98 -0
- src/ui/k_ui/__init__.py +1305 -0
- src/ui/k_ui/_bgrenderer.py +317 -0
- src/ui/k_ui/_colors.py +213 -0
- src/ui/k_ui/_dock.py +545 -0
- src/ui/k_ui/_easter.py +290 -0
- src/ui/k_ui/_engine.py +5448 -0
- src/ui/k_ui/_perf.py +333 -0
- src/ui/k_ui/_tkutil.py +7 -0
- src/ui/k_ui/_tooltip.py +365 -0
- src/ui/k_ui/_widgets.py +1204 -0
- src/ui/k_ui/_world.py +837 -0
- src/ui/key_remapper.py +856 -0
- src/ui/launcher.py +1252 -0
- src/ui/lazy_panel.py +73 -0
- src/ui/macro_recorder.py +610 -0
- src/ui/menu_bar.py +898 -0
- src/ui/output_panel.py +321 -0
- src/ui/paint_canvas.py +1000 -0
- src/ui/paint_engine.py +535 -0
- src/ui/paint_panel.py +888 -0
- src/ui/panel_detach.py +112 -0
- src/ui/performance_panel.py +861 -0
- src/ui/pip_manager.py +1758 -0
- src/ui/plugin_panel.py +1586 -0
- src/ui/pomodoro_panel.py +447 -0
- src/ui/problems.py +566 -0
- src/ui/process_manager.py +1657 -0
- src/ui/project_templates.py +775 -0
- src/ui/recovery_dialog.py +122 -0
- src/ui/regex_playground.py +304 -0
- src/ui/remote_adapters.py +1398 -0
- src/ui/remote_browser.py +1224 -0
- src/ui/remote_profile_dialog.py +342 -0
- src/ui/render_panel.py +1293 -0
- src/ui/rest_client.py +549 -0
- src/ui/scratchpad.py +548 -0
- src/ui/search_bar.py +1274 -0
- src/ui/settings_editor.py +3349 -0
- src/ui/settings_window.py +1554 -0
- src/ui/snippets_panel.py +597 -0
- src/ui/sql_studio.py +1815 -0
- src/ui/status_bar.py +438 -0
- src/ui/tab_bar.py +654 -0
- src/ui/task_manager.py +1773 -0
- src/ui/terminal.py +525 -0
- src/ui/theme_preview_panel.py +851 -0
- src/ui/thread_safe_tk.py +152 -0
- src/ui/time_tracker.py +574 -0
- src/ui/tkbind.py +43 -0
- src/ui/todo_panel.py +358 -0
- src/ui/toolbox_panels.py +658 -0
- src/ui/trash_manager.py +657 -0
- src/ui/ui_scale.py +294 -0
- src/ui/ux_enhancements.py +41 -0
- src/ui/web_preview.py +397 -0
- src/ui/webdev.py +630 -0
- src/ui/welcome.py +567 -0
- src/ui/window_embed.py +1500 -0
- src/ui/wizard.py +1550 -0
- src/ui/workspace_switcher.py +418 -0
- src/ui/workspace_trust.py +370 -0
- src/ui/zen_audio.py +354 -0
- src/ui/zen_media.py +2271 -0
- src/ui/zen_media_client.py +303 -0
- src/ui/zen_media_host.py +329 -0
- src/ui/zen_player.py +907 -0
- src/ui/zen_player_widgets.py +700 -0
- src/updater/__init__.py +11 -0
- src/updater/assets.py +145 -0
- src/updater/backup.py +101 -0
- src/updater/channel.py +221 -0
- src/updater/dialog.py +492 -0
- src/updater/integrity.py +111 -0
- src/updater/manager.py +727 -0
- src/updater/result.py +114 -0
- src/venv_runtime.py +531 -0
- src/workspace_state.py +25 -0
src/extcompat/themes.py
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
"""Tradução de temas de cores do VS Code, do Zed e do Vim/Neovim para o ``Theme`` do Codis."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from . import colors as col
|
|
9
|
+
from .jsonc import as_dict
|
|
10
|
+
from .model import ThemeSpec
|
|
11
|
+
|
|
12
|
+
# Campos de sintaxe do Theme e os escopos TextMate (prefixos) que os alimentam, do mais
|
|
13
|
+
# geral para o mais específico. O escopo mais específico presente no tema vence.
|
|
14
|
+
_SYNTAX_SCOPES: dict[str, tuple[str, ...]] = {
|
|
15
|
+
"t_comment": ("comment",),
|
|
16
|
+
"t_string": ("string",),
|
|
17
|
+
"t_number": ("constant.numeric",),
|
|
18
|
+
"t_keyword": ("keyword", "storage", "keyword.control"),
|
|
19
|
+
"t_operator": ("keyword.operator",),
|
|
20
|
+
"t_func": ("entity.name.function", "support.function", "meta.function-call"),
|
|
21
|
+
"t_type": ("entity.name.type", "support.type", "storage.type"),
|
|
22
|
+
"t_class": ("entity.name.class", "entity.name.type.class"),
|
|
23
|
+
"t_variable": ("variable",),
|
|
24
|
+
"t_decorator": ("meta.decorator", "entity.name.function.decorator", "storage.type.annotation"),
|
|
25
|
+
"t_constant": ("constant", "constant.language"),
|
|
26
|
+
"t_builtin": ("support.function", "support.class", "support.constant"),
|
|
27
|
+
"t_tag": ("entity.name.tag",),
|
|
28
|
+
"t_attr": ("entity.other.attribute-name",),
|
|
29
|
+
"t_heading": ("markup.heading", "entity.name.section"),
|
|
30
|
+
"t_regex": ("string.regexp",),
|
|
31
|
+
"t_escape": ("constant.character.escape",),
|
|
32
|
+
"t_link": ("markup.underline.link",),
|
|
33
|
+
"t_namespace": ("entity.name.namespace", "entity.name.module"),
|
|
34
|
+
"t_invalid": ("invalid",),
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_REQUIRED = (
|
|
38
|
+
"bg", "fg", "fg_muted", "editor_bg", "cursor", "sidebar_bg", "activity_bg", "tabbar_bg",
|
|
39
|
+
"tab_act_bg", "tab_act_fg", "tab_in_fg", "panel_bg", "floating_bg", "sel_bg", "sel_fg",
|
|
40
|
+
"input_bg", "border", "btn_bg", "btn_hover", "btn_fg", "btn_primary", "btn_primary_fg",
|
|
41
|
+
"scroll_bg", "scroll_thumb", "ok_fg", "warn_fg", "err_fg", "accent", "t_keyword",
|
|
42
|
+
"t_string", "t_comment", "t_number", "t_func", "t_type", "t_operator", "t_decorator",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def slug(text: str) -> str:
|
|
47
|
+
return re.sub(r"[^a-z0-9]+", "_", text.lower()).strip("_") or "tema"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def complete(fields: dict[str, str], dark: bool) -> dict[str, str]:
|
|
51
|
+
"""Deriva as cores que o tema de origem não definiu a partir de fundo e texto.
|
|
52
|
+
|
|
53
|
+
Sem isso, um campo ausente herdaria o padrão do ``Theme`` (Catppuccin) e destoaria.
|
|
54
|
+
"""
|
|
55
|
+
f = {k: v for k, v in fields.items() if col.parse(v) is not None}
|
|
56
|
+
bg = f.get("editor_bg") or f.get("bg") or ("#1e1e1e" if dark else "#ffffff")
|
|
57
|
+
fg = f.get("fg") or ("#d4d4d4" if dark else "#1f1f1f")
|
|
58
|
+
f.setdefault("bg", bg)
|
|
59
|
+
f.setdefault("editor_bg", bg)
|
|
60
|
+
f.setdefault("fg", fg)
|
|
61
|
+
|
|
62
|
+
def shade(amount: float) -> str:
|
|
63
|
+
return col.mix(bg, fg, amount)
|
|
64
|
+
|
|
65
|
+
d = {
|
|
66
|
+
"fg_muted": col.mix(bg, fg, 0.5),
|
|
67
|
+
"cursor": fg,
|
|
68
|
+
"sidebar_bg": shade(0.04),
|
|
69
|
+
"activity_bg": shade(0.07),
|
|
70
|
+
"tabbar_bg": shade(0.04),
|
|
71
|
+
"tab_act_bg": bg,
|
|
72
|
+
"tab_act_fg": fg,
|
|
73
|
+
"tab_in_fg": col.mix(bg, fg, 0.5),
|
|
74
|
+
"panel_bg": shade(0.03),
|
|
75
|
+
"floating_bg": shade(0.06),
|
|
76
|
+
"sel_bg": col.mix(bg, f.get("accent", "#3794ff"), 0.35),
|
|
77
|
+
"sel_fg": fg,
|
|
78
|
+
"input_bg": shade(0.08),
|
|
79
|
+
"border": shade(0.14),
|
|
80
|
+
"btn_bg": shade(0.1),
|
|
81
|
+
"btn_hover": shade(0.16),
|
|
82
|
+
"btn_fg": fg,
|
|
83
|
+
"btn_primary": f.get("accent", "#3794ff"),
|
|
84
|
+
"btn_primary_fg": "#ffffff" if dark else "#000000",
|
|
85
|
+
"scroll_bg": shade(0.03),
|
|
86
|
+
"scroll_thumb": shade(0.18),
|
|
87
|
+
"ok_fg": f.get("t_string", "#4ec9b0" if dark else "#008000"),
|
|
88
|
+
"warn_fg": f.get("t_number", "#cca700" if dark else "#bf8803"),
|
|
89
|
+
"err_fg": "#f14c4c" if dark else "#e51400",
|
|
90
|
+
"accent": f.get("btn_primary", "#3794ff"),
|
|
91
|
+
"t_keyword": "#569cd6" if dark else "#0000ff",
|
|
92
|
+
"t_string": "#ce9178" if dark else "#a31515",
|
|
93
|
+
"t_comment": col.mix(bg, fg, 0.45),
|
|
94
|
+
"t_number": "#b5cea8" if dark else "#098658",
|
|
95
|
+
"t_func": "#dcdcaa" if dark else "#795e26",
|
|
96
|
+
"t_type": "#4ec9b0" if dark else "#267f99",
|
|
97
|
+
"t_operator": fg,
|
|
98
|
+
"t_decorator": "#dcdcaa" if dark else "#795e26",
|
|
99
|
+
}
|
|
100
|
+
for key in _REQUIRED:
|
|
101
|
+
if key not in f:
|
|
102
|
+
f[key] = d[key]
|
|
103
|
+
return f
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _syntax_from_rules(rules: list[tuple[list[str], str]]) -> dict[str, str]:
|
|
107
|
+
"""Resolve cada campo ``t_*`` pelo escopo mais específico; empate vai para a regra mais tardia."""
|
|
108
|
+
out: dict[str, str] = {}
|
|
109
|
+
for target, prefixes in _SYNTAX_SCOPES.items():
|
|
110
|
+
best: tuple[int, int, str] | None = None
|
|
111
|
+
for order, (scopes, color) in enumerate(rules):
|
|
112
|
+
for scope in scopes:
|
|
113
|
+
for wanted in prefixes:
|
|
114
|
+
if scope == wanted or wanted.startswith(scope + "."):
|
|
115
|
+
weight = len(scope) * 2 + 1 # regra geral que cobre o alvo
|
|
116
|
+
elif scope.startswith(wanted + "."):
|
|
117
|
+
weight = len(wanted) # regra mais específica: só se nada melhor existir
|
|
118
|
+
else:
|
|
119
|
+
continue
|
|
120
|
+
cand = (weight, order, color)
|
|
121
|
+
if best is None or cand[:2] >= best[:2]:
|
|
122
|
+
best = cand
|
|
123
|
+
if best:
|
|
124
|
+
out[target] = best[2]
|
|
125
|
+
return out
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def from_vscode(
|
|
129
|
+
data: dict[str, Any], *, theme_id: str, name: str, ui_theme: str = ""
|
|
130
|
+
) -> ThemeSpec:
|
|
131
|
+
"""Tema de cores do VS Code (``colors`` + ``tokenColors``)."""
|
|
132
|
+
colors = as_dict(data.get("colors"))
|
|
133
|
+
ui = ui_theme or str(data.get("type", ""))
|
|
134
|
+
bg_raw = colors.get("editor.background")
|
|
135
|
+
if col.parse(bg_raw) is not None:
|
|
136
|
+
dark = col.is_dark(col.normalize(bg_raw) or "#000000")
|
|
137
|
+
else:
|
|
138
|
+
dark = "light" not in ui and ui != "vs"
|
|
139
|
+
bg = col.normalize(bg_raw) or ("#1e1e1e" if dark else "#ffffff")
|
|
140
|
+
|
|
141
|
+
def pick(*keys: str, over: str | None = None) -> str | None:
|
|
142
|
+
for key in keys:
|
|
143
|
+
value = col.normalize(colors.get(key), over or bg)
|
|
144
|
+
if value:
|
|
145
|
+
return value
|
|
146
|
+
return None
|
|
147
|
+
|
|
148
|
+
fg = pick("editor.foreground", "foreground") or ("#d4d4d4" if dark else "#333333")
|
|
149
|
+
fields: dict[str, str] = {"bg": bg, "editor_bg": bg, "fg": fg}
|
|
150
|
+
mapping = {
|
|
151
|
+
"fg_muted": ("descriptionForeground", "editorLineNumber.foreground"),
|
|
152
|
+
"cursor": ("editorCursor.foreground",),
|
|
153
|
+
"sidebar_bg": ("sideBar.background",),
|
|
154
|
+
"activity_bg": ("activityBar.background",),
|
|
155
|
+
"tabbar_bg": ("editorGroupHeader.tabsBackground",),
|
|
156
|
+
"tab_act_bg": ("tab.activeBackground",),
|
|
157
|
+
"tab_act_fg": ("tab.activeForeground",),
|
|
158
|
+
"tab_in_fg": ("tab.inactiveForeground",),
|
|
159
|
+
"panel_bg": ("panel.background",),
|
|
160
|
+
"floating_bg": ("editorWidget.background", "menu.background", "dropdown.background"),
|
|
161
|
+
"sel_bg": ("editor.selectionBackground", "list.activeSelectionBackground"),
|
|
162
|
+
"sel_fg": ("editor.selectionForeground", "list.activeSelectionForeground"),
|
|
163
|
+
"input_bg": ("input.background",),
|
|
164
|
+
"border": ("panel.border", "editorGroup.border", "contrastBorder"),
|
|
165
|
+
"btn_bg": ("button.secondaryBackground", "dropdown.background"),
|
|
166
|
+
"btn_hover": ("button.secondaryHoverBackground", "list.hoverBackground"),
|
|
167
|
+
"btn_fg": ("button.secondaryForeground",),
|
|
168
|
+
"btn_primary": ("button.background",),
|
|
169
|
+
"btn_primary_fg": ("button.foreground",),
|
|
170
|
+
"scroll_thumb": ("scrollbarSlider.background",),
|
|
171
|
+
"ok_fg": ("terminal.ansiGreen", "gitDecoration.addedResourceForeground"),
|
|
172
|
+
"warn_fg": ("editorWarning.foreground", "list.warningForeground"),
|
|
173
|
+
"err_fg": ("editorError.foreground", "errorForeground"),
|
|
174
|
+
"accent": ("focusBorder", "textLink.foreground", "button.background"),
|
|
175
|
+
"statusbar_bg": ("statusBar.background",),
|
|
176
|
+
"statusbar_fg": ("statusBar.foreground",),
|
|
177
|
+
"gutter_fg": ("editorLineNumber.foreground",),
|
|
178
|
+
"gutter_active_fg": ("editorLineNumber.activeForeground",),
|
|
179
|
+
"line_hl": ("editor.lineHighlightBackground",),
|
|
180
|
+
"terminal_bg": ("terminal.background",),
|
|
181
|
+
"terminal_fg": ("terminal.foreground",),
|
|
182
|
+
}
|
|
183
|
+
for field_name, keys in mapping.items():
|
|
184
|
+
value = pick(*keys)
|
|
185
|
+
if value:
|
|
186
|
+
fields[field_name] = value
|
|
187
|
+
|
|
188
|
+
rules: list[tuple[list[str], str]] = []
|
|
189
|
+
for entry in data.get("tokenColors") or []:
|
|
190
|
+
if not isinstance(entry, dict):
|
|
191
|
+
continue
|
|
192
|
+
settings = entry.get("settings") or {}
|
|
193
|
+
color = col.normalize(settings.get("foreground"), bg)
|
|
194
|
+
scope = entry.get("scope")
|
|
195
|
+
if not color:
|
|
196
|
+
continue
|
|
197
|
+
if scope is None:
|
|
198
|
+
fields.setdefault("fg", color)
|
|
199
|
+
continue
|
|
200
|
+
raw = scope if isinstance(scope, list) else str(scope).split(",")
|
|
201
|
+
scopes = [s.strip().split()[-1] for s in raw if isinstance(s, str) and s.strip()]
|
|
202
|
+
rules.append((scopes, color))
|
|
203
|
+
fields.update(_syntax_from_rules(rules))
|
|
204
|
+
return ThemeSpec(theme_id, name, dark, complete(fields, dark))
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def from_zed(doc: dict[str, Any], *, prefix: str) -> list[ThemeSpec]:
|
|
208
|
+
"""Família de temas do Zed (``themes/*.json``): cada item de ``themes`` vira um tema."""
|
|
209
|
+
specs: list[ThemeSpec] = []
|
|
210
|
+
for item in doc.get("themes") or []:
|
|
211
|
+
if not isinstance(item, dict):
|
|
212
|
+
continue
|
|
213
|
+
style = as_dict(item.get("style"))
|
|
214
|
+
name = str(item.get("name") or "Zed")
|
|
215
|
+
dark = str(item.get("appearance", "dark")).lower() != "light"
|
|
216
|
+
bg = col.normalize(style.get("editor.background") or style.get("background")) or (
|
|
217
|
+
"#1e1e1e" if dark else "#ffffff"
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
def get(*keys: str, _s=style, _bg=bg) -> str | None:
|
|
221
|
+
for key in keys:
|
|
222
|
+
value = col.normalize(_s.get(key), _bg)
|
|
223
|
+
if value:
|
|
224
|
+
return value
|
|
225
|
+
return None
|
|
226
|
+
|
|
227
|
+
fields: dict[str, str] = {"bg": bg, "editor_bg": bg}
|
|
228
|
+
table = {
|
|
229
|
+
"fg": ("editor.foreground", "text"),
|
|
230
|
+
"fg_muted": ("text.muted", "text.disabled"),
|
|
231
|
+
"sidebar_bg": ("surface.background", "panel.background"),
|
|
232
|
+
"activity_bg": ("title_bar.background", "surface.background"),
|
|
233
|
+
"tabbar_bg": ("tab_bar.background",),
|
|
234
|
+
"tab_act_bg": ("tab.active_background",),
|
|
235
|
+
"tab_in_fg": ("text.muted",),
|
|
236
|
+
"panel_bg": ("panel.background",),
|
|
237
|
+
"floating_bg": ("elevated_surface.background",),
|
|
238
|
+
"sel_bg": ("element.selected",),
|
|
239
|
+
"input_bg": ("element.background",),
|
|
240
|
+
"border": ("border",),
|
|
241
|
+
"btn_bg": ("element.background",),
|
|
242
|
+
"btn_hover": ("element.hover",),
|
|
243
|
+
"scroll_thumb": ("scrollbar.thumb.background",),
|
|
244
|
+
"ok_fg": ("success", "created"),
|
|
245
|
+
"warn_fg": ("warning",),
|
|
246
|
+
"err_fg": ("error",),
|
|
247
|
+
"accent": ("text.accent",),
|
|
248
|
+
"statusbar_bg": ("status_bar.background",),
|
|
249
|
+
"gutter_fg": ("editor.line_number",),
|
|
250
|
+
"gutter_active_fg": ("editor.active_line_number",),
|
|
251
|
+
"line_hl": ("editor.active_line.background",),
|
|
252
|
+
"terminal_bg": ("terminal.background",),
|
|
253
|
+
"terminal_fg": ("terminal.foreground",),
|
|
254
|
+
}
|
|
255
|
+
for field_name, keys in table.items():
|
|
256
|
+
value = get(*keys)
|
|
257
|
+
if value:
|
|
258
|
+
fields[field_name] = value
|
|
259
|
+
players = style.get("players")
|
|
260
|
+
if isinstance(players, list) and players and isinstance(players[0], dict):
|
|
261
|
+
cur = col.normalize(players[0].get("cursor"), bg)
|
|
262
|
+
sel = col.normalize(players[0].get("selection"), bg)
|
|
263
|
+
if cur:
|
|
264
|
+
fields["cursor"] = cur
|
|
265
|
+
if sel:
|
|
266
|
+
fields.setdefault("sel_bg", sel)
|
|
267
|
+
syntax = as_dict(style.get("syntax"))
|
|
268
|
+
|
|
269
|
+
def syn(*keys: str, _x=syntax, _bg=bg) -> str | None:
|
|
270
|
+
for key in keys:
|
|
271
|
+
entry = _x.get(key)
|
|
272
|
+
if isinstance(entry, dict):
|
|
273
|
+
value = col.normalize(entry.get("color"), _bg)
|
|
274
|
+
if value:
|
|
275
|
+
return value
|
|
276
|
+
return None
|
|
277
|
+
|
|
278
|
+
syntax_map = {
|
|
279
|
+
"t_keyword": ("keyword",),
|
|
280
|
+
"t_string": ("string",),
|
|
281
|
+
"t_comment": ("comment",),
|
|
282
|
+
"t_number": ("number",),
|
|
283
|
+
"t_func": ("function",),
|
|
284
|
+
"t_type": ("type",),
|
|
285
|
+
"t_operator": ("operator",),
|
|
286
|
+
"t_decorator": ("attribute", "preproc"),
|
|
287
|
+
"t_class": ("constructor", "type"),
|
|
288
|
+
"t_variable": ("variable",),
|
|
289
|
+
"t_constant": ("constant", "boolean"),
|
|
290
|
+
"t_tag": ("tag",),
|
|
291
|
+
"t_attr": ("attribute", "property"),
|
|
292
|
+
"t_heading": ("title",),
|
|
293
|
+
"t_regex": ("string.regex",),
|
|
294
|
+
"t_escape": ("string.escape",),
|
|
295
|
+
"t_link": ("link_uri", "link_text"),
|
|
296
|
+
"t_namespace": ("namespace",),
|
|
297
|
+
}
|
|
298
|
+
for field_name, keys in syntax_map.items():
|
|
299
|
+
value = syn(*keys)
|
|
300
|
+
if value:
|
|
301
|
+
fields[field_name] = value
|
|
302
|
+
specs.append(ThemeSpec(f"{prefix}_{slug(name)}", name, dark, complete(fields, dark)))
|
|
303
|
+
return specs
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
_VIM_GROUPS: dict[str, str] = {
|
|
307
|
+
"Comment": "t_comment", "String": "t_string", "Character": "t_string",
|
|
308
|
+
"Number": "t_number", "Float": "t_number", "Boolean": "t_constant",
|
|
309
|
+
"Constant": "t_constant", "Function": "t_func", "Keyword": "t_keyword",
|
|
310
|
+
"Statement": "t_keyword", "Conditional": "t_keyword", "Repeat": "t_keyword",
|
|
311
|
+
"Exception": "t_keyword", "Type": "t_type", "Structure": "t_type",
|
|
312
|
+
"StorageClass": "t_keyword", "Operator": "t_operator", "PreProc": "t_decorator",
|
|
313
|
+
"Macro": "t_decorator", "Define": "t_decorator", "Include": "t_keyword",
|
|
314
|
+
"Identifier": "t_variable", "Special": "t_escape", "SpecialChar": "t_escape",
|
|
315
|
+
"Tag": "t_tag", "Title": "t_heading", "Underlined": "t_link", "Directory": "t_link",
|
|
316
|
+
"Error": "t_invalid", "Delimiter": "t_operator",
|
|
317
|
+
"@keyword": "t_keyword", "@string": "t_string", "@comment": "t_comment",
|
|
318
|
+
"@number": "t_number", "@function": "t_func", "@type": "t_type",
|
|
319
|
+
"@operator": "t_operator", "@variable": "t_variable", "@constant": "t_constant",
|
|
320
|
+
"@tag": "t_tag", "@attribute": "t_attr", "@property": "t_attr",
|
|
321
|
+
"@string.escape": "t_escape", "@string.regex": "t_regex", "@namespace": "t_namespace",
|
|
322
|
+
"@markup.heading": "t_heading", "@markup.link": "t_link", "@module": "t_namespace",
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
_HL = re.compile(r"^\s*hi(?:ghlight)?!?\s+(?!clear\b|link\b|def\b)(@?[\w.@]+)\s+(.*)$", re.I)
|
|
326
|
+
_LINK = re.compile(r"^\s*hi(?:ghlight)?!?\s+(?:def\s+)?link\s+(@?[\w.@]+)\s+(@?[\w.@]+)", re.I)
|
|
327
|
+
_ATTR = re.compile(r"\b(guifg|guibg|gui)\s*=\s*(\S+)", re.I)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def _vim_groups_to_spec(
|
|
331
|
+
groups: dict[str, dict[str, str]], *, theme_id: str, name: str, dark_hint: bool | None
|
|
332
|
+
) -> ThemeSpec | None:
|
|
333
|
+
def color(group: str, key: str) -> str | None:
|
|
334
|
+
return col.normalize(groups.get(group, {}).get(key))
|
|
335
|
+
|
|
336
|
+
bg, fg = color("Normal", "bg"), color("Normal", "fg")
|
|
337
|
+
if not (bg or fg):
|
|
338
|
+
return None
|
|
339
|
+
dark = dark_hint if dark_hint is not None else (col.is_dark(bg) if bg else True)
|
|
340
|
+
bg = bg or ("#1e1e1e" if dark else "#ffffff")
|
|
341
|
+
fields: dict[str, str] = {"bg": bg, "editor_bg": bg}
|
|
342
|
+
if fg:
|
|
343
|
+
fields["fg"] = fg
|
|
344
|
+
pairs = {
|
|
345
|
+
"sel_bg": ("Visual", "bg"),
|
|
346
|
+
"line_hl": ("CursorLine", "bg"),
|
|
347
|
+
"gutter_fg": ("LineNr", "fg"),
|
|
348
|
+
"gutter_active_fg": ("CursorLineNr", "fg"),
|
|
349
|
+
"cursor": ("Cursor", "bg"),
|
|
350
|
+
"statusbar_bg": ("StatusLine", "bg"),
|
|
351
|
+
"statusbar_fg": ("StatusLine", "fg"),
|
|
352
|
+
"floating_bg": ("Pmenu", "bg"),
|
|
353
|
+
"border": ("VertSplit", "fg"),
|
|
354
|
+
"err_fg": ("ErrorMsg", "fg"),
|
|
355
|
+
"warn_fg": ("WarningMsg", "fg"),
|
|
356
|
+
"fg_muted": ("NonText", "fg"),
|
|
357
|
+
"accent": ("Directory", "fg"),
|
|
358
|
+
"sidebar_bg": ("NormalFloat", "bg"),
|
|
359
|
+
}
|
|
360
|
+
for field_name, (group, key) in pairs.items():
|
|
361
|
+
value = color(group, key)
|
|
362
|
+
if value:
|
|
363
|
+
fields[field_name] = value
|
|
364
|
+
for group, target in _VIM_GROUPS.items():
|
|
365
|
+
value = color(group, "fg")
|
|
366
|
+
if value and (target not in fields or not group.startswith("@")):
|
|
367
|
+
fields.setdefault(target, value)
|
|
368
|
+
return ThemeSpec(theme_id, name, dark, complete(fields, dark))
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def from_vim(text: str, *, theme_id: str, name: str) -> ThemeSpec | None:
|
|
372
|
+
"""Esquema de cores ``.vim`` simples: linhas ``hi Grupo guifg=#... guibg=#...``."""
|
|
373
|
+
groups: dict[str, dict[str, str]] = {}
|
|
374
|
+
links: dict[str, str] = {}
|
|
375
|
+
dark_hint: bool | None = None
|
|
376
|
+
for line in text.splitlines():
|
|
377
|
+
stripped = line.strip()
|
|
378
|
+
if stripped.startswith('"'):
|
|
379
|
+
continue
|
|
380
|
+
bg_set = re.match(r"set\s+background\s*=\s*(dark|light)", stripped, re.I)
|
|
381
|
+
if bg_set:
|
|
382
|
+
dark_hint = bg_set.group(1).lower() == "dark"
|
|
383
|
+
continue
|
|
384
|
+
link = _LINK.match(line)
|
|
385
|
+
if link:
|
|
386
|
+
links[link.group(1)] = link.group(2)
|
|
387
|
+
continue
|
|
388
|
+
m = _HL.match(line)
|
|
389
|
+
if not m:
|
|
390
|
+
continue
|
|
391
|
+
attrs = {k.lower(): v for k, v in _ATTR.findall(m.group(2))}
|
|
392
|
+
entry = groups.setdefault(m.group(1), {})
|
|
393
|
+
if "guifg" in attrs:
|
|
394
|
+
entry["fg"] = attrs["guifg"]
|
|
395
|
+
if "guibg" in attrs:
|
|
396
|
+
entry["bg"] = attrs["guibg"]
|
|
397
|
+
for src, dst in links.items():
|
|
398
|
+
if src not in groups and dst in groups:
|
|
399
|
+
groups[src] = dict(groups[dst])
|
|
400
|
+
return _vim_groups_to_spec(groups, theme_id=theme_id, name=name, dark_hint=dark_hint)
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
_LUA_HL = re.compile(r"""['"]([@\w.]+)['"]\s*,\s*\{([^{}]*)\}""")
|
|
404
|
+
_LUA_ATTR = re.compile(r"""\b(fg|bg|foreground|background)\s*=\s*['"](#[0-9a-fA-F]{3,8})['"]""")
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def from_nvim_lua(text: str, *, theme_id: str, name: str) -> ThemeSpec | None:
|
|
408
|
+
"""Esquema Neovim em Lua escrito com cores literais (``nvim_set_hl(0, "Grupo", { fg = "#..." })``).
|
|
409
|
+
|
|
410
|
+
Paletas montadas por variáveis ou funções não são avaliadas: nada de Lua é executado.
|
|
411
|
+
"""
|
|
412
|
+
groups: dict[str, dict[str, str]] = {}
|
|
413
|
+
for group, body in _LUA_HL.findall(text):
|
|
414
|
+
attrs = dict(_LUA_ATTR.findall(body))
|
|
415
|
+
fg = attrs.get("fg") or attrs.get("foreground")
|
|
416
|
+
bg = attrs.get("bg") or attrs.get("background")
|
|
417
|
+
entry = groups.setdefault(group, {})
|
|
418
|
+
if fg:
|
|
419
|
+
entry["fg"] = fg
|
|
420
|
+
if bg:
|
|
421
|
+
entry["bg"] = bg
|
|
422
|
+
dark_hint = None
|
|
423
|
+
m = re.search(r"vim\.o\.background\s*=\s*['\"](dark|light)['\"]", text)
|
|
424
|
+
if m:
|
|
425
|
+
dark_hint = m.group(1) == "dark"
|
|
426
|
+
return _vim_groups_to_spec(groups, theme_id=theme_id, name=name, dark_hint=dark_hint)
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def assemble(theme_id: str, name: str, fields: dict[str, str | None], dark: bool | None = None) -> ThemeSpec:
|
|
430
|
+
"""Monta o ``ThemeSpec`` a partir de campos já mapeados (cores em qualquer formato aceito).
|
|
431
|
+
|
|
432
|
+
Cores com alfa são misturadas sobre o fundo e os campos ausentes são derivados dele; ``dark``
|
|
433
|
+
sai da luminosidade do fundo quando não for informado.
|
|
434
|
+
"""
|
|
435
|
+
raw_bg = fields.get("editor_bg") or fields.get("bg")
|
|
436
|
+
bg = col.normalize(raw_bg) if raw_bg else None
|
|
437
|
+
if dark is None:
|
|
438
|
+
dark = col.is_dark(bg) if bg else True
|
|
439
|
+
base = bg or ("#1e1e1e" if dark else "#ffffff")
|
|
440
|
+
clean: dict[str, str] = {}
|
|
441
|
+
for key, value in fields.items():
|
|
442
|
+
color = col.normalize(value, base) if value else None
|
|
443
|
+
if color:
|
|
444
|
+
clean[key] = color
|
|
445
|
+
clean["bg"] = clean.get("bg", base)
|
|
446
|
+
clean["editor_bg"] = clean.get("editor_bg", clean["bg"])
|
|
447
|
+
return ThemeSpec(theme_id, name, dark, complete(clean, dark))
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
def from_scope_rules(
|
|
451
|
+
theme_id: str,
|
|
452
|
+
name: str,
|
|
453
|
+
*,
|
|
454
|
+
fields: dict[str, str | None],
|
|
455
|
+
rules: list[tuple[list[str], str]],
|
|
456
|
+
dark: bool | None = None,
|
|
457
|
+
) -> ThemeSpec:
|
|
458
|
+
"""Tema de formatos baseados em escopos TextMate (Sublime, Atom): UI em ``fields``, realce em ``rules``."""
|
|
459
|
+
raw_bg = fields.get("editor_bg") or fields.get("bg")
|
|
460
|
+
bg = col.normalize(raw_bg) if raw_bg else None
|
|
461
|
+
cleaned: list[tuple[list[str], str]] = []
|
|
462
|
+
for scopes, color in rules:
|
|
463
|
+
normal = col.normalize(color, bg)
|
|
464
|
+
if normal:
|
|
465
|
+
cleaned.append((scopes, normal))
|
|
466
|
+
merged: dict[str, str | None] = {**_syntax_from_rules(cleaned), **fields}
|
|
467
|
+
return assemble(theme_id, name, merged, dark)
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
def selector_scopes(selector: str) -> list[str]:
|
|
471
|
+
"""Escopos de um seletor do Sublime/TextMate: o último termo de cada alternativa, sem exclusões."""
|
|
472
|
+
scopes: list[str] = []
|
|
473
|
+
for alt in selector.split(","):
|
|
474
|
+
terms: list[str] = []
|
|
475
|
+
skip_next = False
|
|
476
|
+
for token in alt.split():
|
|
477
|
+
if skip_next:
|
|
478
|
+
skip_next = False
|
|
479
|
+
elif token in ("-", "&", "|"):
|
|
480
|
+
skip_next = True
|
|
481
|
+
elif token[0] in "-&|(":
|
|
482
|
+
continue
|
|
483
|
+
elif not token.startswith("meta."):
|
|
484
|
+
terms.append(token)
|
|
485
|
+
if terms:
|
|
486
|
+
scopes.append(terms[-1].lstrip("."))
|
|
487
|
+
return scopes
|