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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""GNU nano: arquivos ``.nanorc`` com ``syntax`` e ``color``. A cor em si não diz o papel; ele é deduzido do regex."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
import shlex
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from .. import registry, textmate
|
|
10
|
+
from ..common import decode, title_of
|
|
11
|
+
from ..model import Extension, LanguageSpec
|
|
12
|
+
from ..registry import Format
|
|
13
|
+
from ..sources import Bundle
|
|
14
|
+
from ..themes import slug
|
|
15
|
+
|
|
16
|
+
_MAX_FILES = 300
|
|
17
|
+
_WORDS = re.compile(r"^\\[<b]\(?[\w|\\.\-]+\)?\\[>b]$")
|
|
18
|
+
_EXT = re.compile(r"\\\.\(?([\w|]+)\)?\$")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _files(bundle: Bundle) -> list[str]:
|
|
22
|
+
out = []
|
|
23
|
+
for rel in bundle.with_suffix(".nanorc", ".nanorc.in")[:_MAX_FILES]:
|
|
24
|
+
if b"syntax" in (bundle.read(rel) or b""):
|
|
25
|
+
out.append(rel)
|
|
26
|
+
return out
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _is_nano(root: Path) -> bool:
|
|
30
|
+
return bool(_files(Bundle(root)))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _posix(regex: str) -> str:
|
|
34
|
+
"""Do regex estendido do nano (``\\<``, ``\\>``, classes POSIX) para o do Python."""
|
|
35
|
+
regex = regex.replace("\\<", "\\b").replace("\\>", "\\b")
|
|
36
|
+
for name, cls in (("alpha", "A-Za-z"), ("digit", "0-9"), ("alnum", "A-Za-z0-9"), ("upper", "A-Z"), ("lower", "a-z"), ("space", r"\s"), ("blank", r" \t")):
|
|
37
|
+
regex = regex.replace(f"[:{name}:]", cls)
|
|
38
|
+
return regex
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _scope(regex: str, comment: str) -> str | None:
|
|
42
|
+
if _WORDS.match(regex):
|
|
43
|
+
return "keyword.control"
|
|
44
|
+
if comment and regex.startswith(re.escape(comment)[:2]):
|
|
45
|
+
return "comment.line"
|
|
46
|
+
if regex.startswith(("#", "//", "--", "/\\*", "\\/\\/")):
|
|
47
|
+
return "comment.line"
|
|
48
|
+
if regex.startswith(('"', "'", '\\"', "\\'")) or "\\\"" in regex[:6]:
|
|
49
|
+
return "string.quoted"
|
|
50
|
+
if re.fullmatch(r"[\\\[\]0-9a-zA-Z.+*?()|_\-x ]*(?:0-9|\\d)[\\\[\]0-9a-zA-Z.+*?()|_\-x ]*", regex) and "[0-9" in regex + "[":
|
|
51
|
+
return "constant.numeric"
|
|
52
|
+
return None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def language_from_nanorc(text: str, known: set[str]) -> LanguageSpec | None:
|
|
56
|
+
name, exts, comment = "", [], ""
|
|
57
|
+
patterns: list[dict[str, str]] = []
|
|
58
|
+
for raw in text.splitlines():
|
|
59
|
+
line = raw.strip()
|
|
60
|
+
if not line or line.startswith("#"):
|
|
61
|
+
continue
|
|
62
|
+
try:
|
|
63
|
+
parts = shlex.split(line, posix=True)
|
|
64
|
+
except ValueError:
|
|
65
|
+
continue
|
|
66
|
+
if not parts:
|
|
67
|
+
continue
|
|
68
|
+
head = parts[0]
|
|
69
|
+
if head == "syntax" and len(parts) >= 2 and not name:
|
|
70
|
+
name = parts[1]
|
|
71
|
+
for rx in parts[2:]:
|
|
72
|
+
for e in _EXT.findall(rx):
|
|
73
|
+
exts.extend(f".{x.lower()}" for x in e.split("|"))
|
|
74
|
+
elif head == "comment" and len(parts) >= 2:
|
|
75
|
+
comment = parts[1].strip()
|
|
76
|
+
elif head in ("color", "icolor") and len(parts) >= 3:
|
|
77
|
+
rest = parts[2:]
|
|
78
|
+
if rest[0].startswith("start="):
|
|
79
|
+
start = rest[0][6:].strip('"')
|
|
80
|
+
end = next((r[4:].strip('"') for r in rest if r.startswith("end=")), "")
|
|
81
|
+
scope = _scope(start, comment) or None
|
|
82
|
+
if scope and end:
|
|
83
|
+
patterns.append({"name": scope, "begin": _posix(start), "end": _posix(end)})
|
|
84
|
+
continue
|
|
85
|
+
for rx in rest:
|
|
86
|
+
scope = _scope(rx, comment)
|
|
87
|
+
if scope:
|
|
88
|
+
patterns.append({"name": scope, "match": _posix(rx)})
|
|
89
|
+
lid = slug(name).replace("_", "-")
|
|
90
|
+
if not lid or lid in known or not exts or lid == "default":
|
|
91
|
+
return None
|
|
92
|
+
spec = LanguageSpec(id=lid, label=name or title_of(lid), extensions=sorted(set(exts)), comment=comment or None)
|
|
93
|
+
spec.patterns, spec.keywords = textmate.grammar_to_tokens({"patterns": patterns})
|
|
94
|
+
return spec
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def load_nano(root: Path, known: set[str]) -> Extension:
|
|
98
|
+
bundle = Bundle(root)
|
|
99
|
+
ext = Extension(id=f"nano.{slug(root.name)}", name=root.name, version="0", kind="nano", path=root)
|
|
100
|
+
for rel in _files(bundle):
|
|
101
|
+
lang = language_from_nanorc(decode(bundle.read(rel) or b""), known)
|
|
102
|
+
if lang and not any(x.id == lang.id for x in ext.languages):
|
|
103
|
+
ext.languages.append(lang)
|
|
104
|
+
elif lang is None:
|
|
105
|
+
ext.warnings.append(f"{Path(rel).name}: sem extensões de arquivo ou realce reconhecível")
|
|
106
|
+
return ext
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
registry.register(Format(
|
|
110
|
+
"nano", "GNU nano", _is_nano, load_nano, priority=67, suffixes=(".nanorc",), provides="sintaxes (realce por regex)",
|
|
111
|
+
))
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"""Notepad++: temas (``themes/*.xml``) e linguagens definidas pelo usuário (``userDefineLang.xml``)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from .. import registry
|
|
9
|
+
from ..common import simple_tokens, title_of
|
|
10
|
+
from ..model import Extension, LanguageSpec, ThemeSpec
|
|
11
|
+
from ..registry import Format
|
|
12
|
+
from ..safexml import child, children, descendants, parse_xml
|
|
13
|
+
from ..sources import Bundle
|
|
14
|
+
from ..themes import assemble, slug
|
|
15
|
+
|
|
16
|
+
_MAX_FILES = 150
|
|
17
|
+
_WORDS = {
|
|
18
|
+
"t_keyword": ("KEYWORDS", "INSTRUCTION WORD", "WORD", "KEYWORD", "STATEMENT"),
|
|
19
|
+
"t_comment": ("COMMENT LINE", "COMMENT", "COMMENTLINE", "COMMENT BLOCK", "COMMENTS"),
|
|
20
|
+
"t_string": ("STRING", "DOUBLE QUOTE STRING", "STRING1"),
|
|
21
|
+
"t_number": ("NUMBER", "NUMBERS"),
|
|
22
|
+
"t_class": ("CLASS NAME", "TYPE WORD", "CLASSNAME"),
|
|
23
|
+
"t_type": ("TYPE WORD", "CLASS NAME", "TYPES"),
|
|
24
|
+
"t_func": ("DEF NAME", "FUNCTION NAME", "FUNCTION", "FUNCTIONS"),
|
|
25
|
+
"t_operator": ("OPERATOR", "OPERATORS"),
|
|
26
|
+
"t_decorator": ("DECORATOR", "PREPROCESSOR"),
|
|
27
|
+
"t_builtin": ("KEYWORDS 2", "WORD2", "KEYWORD2", "BUILTIN"),
|
|
28
|
+
}
|
|
29
|
+
_PREFERRED_LEXERS = ("python", "cpp", "javascript", "java")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _head(bundle: Bundle, rel: str) -> bytes:
|
|
33
|
+
return (bundle.read(rel) or b"")[:4000]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _files(bundle: Bundle) -> list[str]:
|
|
37
|
+
return [r for r in bundle.with_suffix(".xml")[:400] if b"<NotepadPlus" in _head(bundle, r)]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _is_npp(root: Path) -> bool:
|
|
41
|
+
bundle = Bundle(root)
|
|
42
|
+
return bool(_files(bundle))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _color(value: str | None) -> str | None:
|
|
46
|
+
value = (value or "").strip()
|
|
47
|
+
return f"#{value}" if re.fullmatch(r"[0-9A-Fa-f]{6}", value) else None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def from_theme(raw: bytes, *, theme_id: str, fallback: str) -> ThemeSpec | None:
|
|
51
|
+
root = parse_xml(raw)
|
|
52
|
+
if root is None:
|
|
53
|
+
return None
|
|
54
|
+
widgets = {w.get("name"): w for w in descendants(root, "WidgetStyle")}
|
|
55
|
+
|
|
56
|
+
def widget(name: str, attr: str) -> str | None:
|
|
57
|
+
el = widgets.get(name)
|
|
58
|
+
return _color(el.get(attr)) if el is not None else None
|
|
59
|
+
|
|
60
|
+
default = widgets.get("Default Style")
|
|
61
|
+
if default is None:
|
|
62
|
+
default = widgets.get("Global override")
|
|
63
|
+
if default is None:
|
|
64
|
+
return None
|
|
65
|
+
fields: dict[str, str | None] = {
|
|
66
|
+
"fg": _color(default.get("fgColor")), "bg": _color(default.get("bgColor")),
|
|
67
|
+
"editor_bg": _color(default.get("bgColor")),
|
|
68
|
+
"line_hl": widget("Current line background colour", "bgColor"),
|
|
69
|
+
"sel_bg": widget("Selected text colour", "bgColor"), "sel_fg": widget("Selected text colour", "fgColor"),
|
|
70
|
+
"cursor": widget("Caret colour", "fgColor"), "gutter_fg": widget("Line number margin", "fgColor"),
|
|
71
|
+
}
|
|
72
|
+
lexers = {lx.get("name"): lx for lx in descendants(root, "LexerType")}
|
|
73
|
+
lexer = next((lexers[n] for n in _PREFERRED_LEXERS if n in lexers), next(iter(lexers.values()), None))
|
|
74
|
+
if lexer is not None:
|
|
75
|
+
styles = {(w.get("name") or "").upper(): w for w in children(lexer, "WordsStyle")}
|
|
76
|
+
for target, names in _WORDS.items():
|
|
77
|
+
for name in names:
|
|
78
|
+
if name in styles and _color(styles[name].get("fgColor")):
|
|
79
|
+
fields[target] = _color(styles[name].get("fgColor"))
|
|
80
|
+
break
|
|
81
|
+
if not (fields["bg"] and fields["fg"]):
|
|
82
|
+
return None
|
|
83
|
+
return assemble(theme_id, fallback, fields)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def languages_from_udl(raw: bytes, known: set[str]) -> list[LanguageSpec]:
|
|
87
|
+
root = parse_xml(raw)
|
|
88
|
+
out: list[LanguageSpec] = []
|
|
89
|
+
for lang in descendants(root, "UserLang") if root is not None else []:
|
|
90
|
+
name = lang.get("name") or ""
|
|
91
|
+
lid = slug(name).replace("_", "-")
|
|
92
|
+
exts = [f".{e.lstrip('.').lower()}" for e in (lang.get("ext") or "").split() if e.strip(". ")]
|
|
93
|
+
if not lid or lid in known or not exts:
|
|
94
|
+
continue
|
|
95
|
+
lists = child(lang, "KeywordLists")
|
|
96
|
+
line, block_open, block_close = None, None, None
|
|
97
|
+
words: list[str] = []
|
|
98
|
+
for kw in children(lists, "Keywords") if lists is not None else []:
|
|
99
|
+
text = kw.text or ""
|
|
100
|
+
if kw.get("name") == "Comments":
|
|
101
|
+
for num, value in re.findall(r"0([0-6])(\S*)", text):
|
|
102
|
+
if num == "0" and value:
|
|
103
|
+
line = value
|
|
104
|
+
elif num == "3" and value:
|
|
105
|
+
block_open = value
|
|
106
|
+
elif num == "4" and value:
|
|
107
|
+
block_close = value
|
|
108
|
+
elif (kw.get("name") or "").startswith("Keywords"):
|
|
109
|
+
words.extend(w for w in text.split() if w.isidentifier())
|
|
110
|
+
block = (block_open, block_close) if block_open and block_close else None
|
|
111
|
+
tokens, kws = simple_tokens(line_comment=line, block_comment=block, keywords=words)
|
|
112
|
+
out.append(LanguageSpec(id=lid, label=name or title_of(lid), extensions=exts, comment=line,
|
|
113
|
+
comment_block=block, patterns=tokens, keywords=kws))
|
|
114
|
+
return out
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def load_npp(root: Path, known: set[str]) -> Extension:
|
|
118
|
+
bundle = Bundle(root)
|
|
119
|
+
ext = Extension(id=f"notepadpp.{slug(root.name)}", name=root.name, version="0", kind="notepadpp", path=root)
|
|
120
|
+
used: set[str] = set()
|
|
121
|
+
for rel in _files(bundle)[:_MAX_FILES]:
|
|
122
|
+
raw = bundle.read(rel) or b""
|
|
123
|
+
stem = Path(rel).stem
|
|
124
|
+
if b"<UserLang" in raw:
|
|
125
|
+
ext.languages.extend(lg for lg in languages_from_udl(raw, known) if not any(x.id == lg.id for x in ext.languages))
|
|
126
|
+
if b"<LexerStyles" in raw:
|
|
127
|
+
theme_id = f"npp_{slug(stem)}"
|
|
128
|
+
spec = from_theme(raw, theme_id=theme_id, fallback=stem)
|
|
129
|
+
if spec and spec.id not in used:
|
|
130
|
+
used.add(spec.id)
|
|
131
|
+
ext.themes.append(spec)
|
|
132
|
+
elif spec is None:
|
|
133
|
+
ext.warnings.append(f"{Path(rel).name}: tema sem estilo padrão")
|
|
134
|
+
return ext
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
registry.register(Format(
|
|
138
|
+
"notepadpp", "Notepad++", _is_npp, load_npp, priority=60, suffixes=(".xml",),
|
|
139
|
+
provides="temas e linguagens definidas pelo usuário",
|
|
140
|
+
))
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""Pulsar e Atom: temas de sintaxe e de interface (LESS), gramáticas, snippets e comentários (CSON/JSON)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import re
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from .. import cson, lessish, registry
|
|
11
|
+
from ..common import decode, scope_lang
|
|
12
|
+
from ..jsonc import as_dict
|
|
13
|
+
from ..model import Extension, SnippetSpec
|
|
14
|
+
from ..registry import Format
|
|
15
|
+
from ..sources import Bundle
|
|
16
|
+
from ..themes import from_scope_rules, slug
|
|
17
|
+
from . import _tm
|
|
18
|
+
|
|
19
|
+
_MAX_FILES = 300
|
|
20
|
+
_SYNTAX_VARS = {
|
|
21
|
+
"fg": "syntax-text-color", "bg": "syntax-background-color", "editor_bg": "syntax-background-color",
|
|
22
|
+
"cursor": "syntax-cursor-color", "sel_bg": "syntax-selection-color", "line_hl": "syntax-cursor-line",
|
|
23
|
+
"gutter_fg": "syntax-gutter-text-color", "gutter_active_fg": "syntax-gutter-text-color-selected",
|
|
24
|
+
}
|
|
25
|
+
_UI_VARS = {
|
|
26
|
+
"sidebar_bg": "tool-panel-background-color", "tabbar_bg": "tab-bar-background-color",
|
|
27
|
+
"tab_act_bg": "tab-background-color-active", "border": "base-border-color",
|
|
28
|
+
"input_bg": "input-background-color", "btn_bg": "button-background-color",
|
|
29
|
+
"panel_bg": "base-background-color", "floating_bg": "overlay-background-color",
|
|
30
|
+
"accent": "background-color-info",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _package_json(bundle: Bundle) -> dict[str, Any]:
|
|
35
|
+
raw = bundle.read("package.json")
|
|
36
|
+
try:
|
|
37
|
+
return as_dict(json.loads(decode(raw))) if raw else {}
|
|
38
|
+
except ValueError:
|
|
39
|
+
return {}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _is_pulsar(root: Path) -> bool:
|
|
43
|
+
bundle = Bundle(root)
|
|
44
|
+
pkg = _package_json(bundle)
|
|
45
|
+
engines = as_dict(pkg.get("engines"))
|
|
46
|
+
if "atom" in engines or "pulsar" in engines:
|
|
47
|
+
return True
|
|
48
|
+
return bool(pkg) and (
|
|
49
|
+
bool(bundle.glob("grammars/*.cson", "snippets/*.cson", "styles/syntax-variables.less"))
|
|
50
|
+
or pkg.get("theme") in ("syntax", "ui")
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _class_scope(selector: str) -> str | None:
|
|
55
|
+
"""Escopo TextMate para o último seletor composto: ``.syntax--keyword.syntax--control`` -> ``keyword.control``."""
|
|
56
|
+
last = selector.strip().split()[-1] if selector.strip() else ""
|
|
57
|
+
last = last.split(":")[0]
|
|
58
|
+
classes = [c.removeprefix("syntax--") for c in re.findall(r"\.([\w-]+)", last)]
|
|
59
|
+
classes = [c for c in classes if c not in ("source", "text", "editor", "shell-session")]
|
|
60
|
+
return ".".join(classes) if classes else None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def theme_from_less(files: dict[str, str], *, theme_id: str, name: str):
|
|
64
|
+
"""Tema a partir dos arquivos LESS do pacote (variáveis ``@syntax-*`` e regras ``.syntax--*``)."""
|
|
65
|
+
table: dict[str, str] = {}
|
|
66
|
+
for text in files.values():
|
|
67
|
+
table.update(lessish.variables(text))
|
|
68
|
+
fields: dict[str, str | None] = {}
|
|
69
|
+
for target, var in {**_UI_VARS, **_SYNTAX_VARS}.items():
|
|
70
|
+
if var in table:
|
|
71
|
+
fields[target] = table[var]
|
|
72
|
+
rules: list[tuple[list[str], str]] = []
|
|
73
|
+
for text in files.values():
|
|
74
|
+
for selector, decl in lessish.parse_rules(text, table):
|
|
75
|
+
color = decl.get("color")
|
|
76
|
+
for sel in selector.split(","):
|
|
77
|
+
scope = _class_scope(sel)
|
|
78
|
+
if scope and color and lessish.col.parse(color) is not None and "syntax--" in sel + "." + scope:
|
|
79
|
+
rules.append(([scope], color))
|
|
80
|
+
if not (fields.get("bg") or fields.get("fg")):
|
|
81
|
+
return None
|
|
82
|
+
return from_scope_rules(theme_id, name, fields=fields, rules=rules)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _snippet_specs(data: Any) -> list[SnippetSpec]:
|
|
86
|
+
out: list[SnippetSpec] = []
|
|
87
|
+
for selector, entries in as_dict(data).items():
|
|
88
|
+
lang = scope_lang(str(selector))
|
|
89
|
+
if not lang:
|
|
90
|
+
continue
|
|
91
|
+
for title, entry in as_dict(entries).items():
|
|
92
|
+
entry = as_dict(entry)
|
|
93
|
+
prefix, body = entry.get("prefix"), entry.get("body")
|
|
94
|
+
if isinstance(prefix, str) and isinstance(body, str) and prefix and body:
|
|
95
|
+
out.append(SnippetSpec(lang, prefix, body, str(title)))
|
|
96
|
+
return out
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _read_data(bundle: Bundle, rel: str) -> Any:
|
|
100
|
+
raw = bundle.read(rel)
|
|
101
|
+
if raw is None:
|
|
102
|
+
raise ValueError("arquivo grande demais ou ilegível")
|
|
103
|
+
text = decode(raw)
|
|
104
|
+
return json.loads(text) if rel.lower().endswith(".json") else cson.loads(text)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def load_pulsar(root: Path, known: set[str]) -> Extension:
|
|
108
|
+
bundle = Bundle(root)
|
|
109
|
+
pkg = _package_json(bundle)
|
|
110
|
+
name = str(pkg.get("name") or root.name)
|
|
111
|
+
ext = Extension(
|
|
112
|
+
id=f"pulsar.{slug(name)}", name=name, version=str(pkg.get("version") or "0"), kind="pulsar", path=root,
|
|
113
|
+
publisher=str(as_dict(pkg.get("author")).get("name") or pkg.get("author") or "") if pkg.get("author") else "",
|
|
114
|
+
description=str(pkg.get("description") or ""),
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
less = {rel: bundle.text(rel) or "" for rel in bundle.with_suffix(".less", ".css")[:_MAX_FILES] if rel.startswith(("styles/", "index"))}
|
|
118
|
+
if pkg.get("theme") in ("syntax", "ui") or any("syntax-variables" in r for r in less):
|
|
119
|
+
spec = theme_from_less(less, theme_id=f"pulsar_{slug(name)}", name=name)
|
|
120
|
+
if spec:
|
|
121
|
+
ext.themes.append(spec)
|
|
122
|
+
else:
|
|
123
|
+
ext.warnings.append("tema sem cores literais; paletas montadas por funções do LESS não são avaliadas")
|
|
124
|
+
|
|
125
|
+
comments: dict[str, tuple[str | None, tuple[str, str] | None]] = {}
|
|
126
|
+
for rel in bundle.glob("settings/*.cson", "settings/*.json")[:_MAX_FILES]:
|
|
127
|
+
try:
|
|
128
|
+
data = _read_data(bundle, rel)
|
|
129
|
+
except (ValueError, RecursionError):
|
|
130
|
+
continue
|
|
131
|
+
for selector, conf in as_dict(data).items():
|
|
132
|
+
editor = as_dict(as_dict(conf).get("editor"))
|
|
133
|
+
start = editor.get("commentStart")
|
|
134
|
+
if isinstance(start, str) and start.strip():
|
|
135
|
+
end = editor.get("commentEnd")
|
|
136
|
+
block = (start.strip(), str(end).strip()) if isinstance(end, str) and end.strip() else None
|
|
137
|
+
comments[str(selector).lstrip(".")] = (None if block else start.strip(), block)
|
|
138
|
+
|
|
139
|
+
for rel in bundle.glob("grammars/*.cson", "grammars/*.json")[:_MAX_FILES]:
|
|
140
|
+
try:
|
|
141
|
+
grammar = _read_data(bundle, rel)
|
|
142
|
+
if not isinstance(grammar, dict):
|
|
143
|
+
raise ValueError("gramática não é um objeto")
|
|
144
|
+
_tm.language_from_grammar(grammar, ext, known, fallback=Path(rel).stem, comments=comments)
|
|
145
|
+
except (ValueError, RecursionError) as exc:
|
|
146
|
+
ext.warnings.append(f"gramática ilegível: {Path(rel).name} ({exc})")
|
|
147
|
+
|
|
148
|
+
for rel in bundle.glob("snippets/*.cson", "snippets/*.json")[:_MAX_FILES]:
|
|
149
|
+
try:
|
|
150
|
+
ext.snippets.extend(_snippet_specs(_read_data(bundle, rel)))
|
|
151
|
+
except (ValueError, RecursionError):
|
|
152
|
+
ext.warnings.append(f"snippets ilegíveis: {Path(rel).name}")
|
|
153
|
+
|
|
154
|
+
if pkg.get("main") or bundle.has("lib/main.js") or bundle.has("lib/main.coffee"):
|
|
155
|
+
ext.ignored.append("código JavaScript/CoffeeScript do pacote (usa a API do Atom, não é executado)")
|
|
156
|
+
if bundle.glob("keymaps/*", "menus/*"):
|
|
157
|
+
ext.ignored.append("atalhos e menus")
|
|
158
|
+
return ext
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
registry.register(Format(
|
|
162
|
+
"pulsar", "Pulsar / Atom", _is_pulsar, load_pulsar, priority=10,
|
|
163
|
+
suffixes=(),
|
|
164
|
+
provides="temas, gramáticas, snippets e comentários",
|
|
165
|
+
))
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""IDEs feitas em Python: temas de realce do IDLE (``config-highlight.cfg``) e do Thonny (plugins).
|
|
2
|
+
|
|
3
|
+
O código do plugin do Thonny não é executado: o tema é lido da árvore sintática (``ast``), de
|
|
4
|
+
dicionários escritos por extenso.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import ast
|
|
10
|
+
import configparser
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
from .. import registry
|
|
15
|
+
from ..common import decode
|
|
16
|
+
from ..model import Extension, ThemeSpec
|
|
17
|
+
from ..registry import Format
|
|
18
|
+
from ..sources import Bundle
|
|
19
|
+
from ..themes import assemble, slug
|
|
20
|
+
|
|
21
|
+
_MAX_FILES = 200
|
|
22
|
+
_IDLE_TOKENS = {
|
|
23
|
+
"t_keyword": "keyword", "t_string": "string", "t_comment": "comment", "t_builtin": "builtin",
|
|
24
|
+
"t_func": "definition", "t_constant": "hit",
|
|
25
|
+
}
|
|
26
|
+
_THONNY_TOKENS = {
|
|
27
|
+
"t_keyword": "keyword", "t_string": "string", "t_comment": "comment", "t_number": "number",
|
|
28
|
+
"t_builtin": "builtin", "t_func": "definition", "t_regex": "string3", "t_class": "definition",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _idle_files(bundle: Bundle) -> list[str]:
|
|
33
|
+
out = []
|
|
34
|
+
for rel in bundle.with_suffix(".cfg", ".def")[:_MAX_FILES]:
|
|
35
|
+
raw = bundle.read(rel)
|
|
36
|
+
if raw and b"normal-foreground" in raw and b"keyword-foreground" in raw:
|
|
37
|
+
out.append(rel)
|
|
38
|
+
return out
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _thonny_files(bundle: Bundle) -> list[str]:
|
|
42
|
+
out = []
|
|
43
|
+
for rel in bundle.with_suffix(".py")[:_MAX_FILES]:
|
|
44
|
+
raw = bundle.read(rel)
|
|
45
|
+
if raw and b"add_syntax_theme" in raw:
|
|
46
|
+
out.append(rel)
|
|
47
|
+
return out
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def from_idle(text: str, *, prefix: str) -> list[ThemeSpec]:
|
|
51
|
+
parser = configparser.ConfigParser(interpolation=None, strict=False)
|
|
52
|
+
try:
|
|
53
|
+
parser.read_string(text)
|
|
54
|
+
except configparser.Error:
|
|
55
|
+
return []
|
|
56
|
+
specs: list[ThemeSpec] = []
|
|
57
|
+
for section in parser.sections():
|
|
58
|
+
get = lambda key, _s=section: parser.get(_s, key, fallback="").strip() or None # noqa: E731
|
|
59
|
+
if not get("normal-foreground"):
|
|
60
|
+
continue
|
|
61
|
+
fields: dict[str, str | None] = {
|
|
62
|
+
"fg": get("normal-foreground"), "bg": get("normal-background"), "editor_bg": get("normal-background"),
|
|
63
|
+
"cursor": get("cursor-foreground"), "sel_bg": get("hilite-background"), "sel_fg": get("hilite-foreground"),
|
|
64
|
+
}
|
|
65
|
+
for target, token in _IDLE_TOKENS.items():
|
|
66
|
+
fields[target] = get(f"{token}-foreground")
|
|
67
|
+
specs.append(assemble(f"{prefix}_{slug(section)}", section, fields))
|
|
68
|
+
return specs
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _literal(node: ast.AST) -> Any:
|
|
72
|
+
try:
|
|
73
|
+
return ast.literal_eval(node)
|
|
74
|
+
except (ValueError, SyntaxError, TypeError, MemoryError, RecursionError):
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def from_thonny(source: str, *, prefix: str) -> list[ThemeSpec]:
|
|
79
|
+
"""Temas de ``add_syntax_theme(nome, pai, configurações)`` com dicionários literais."""
|
|
80
|
+
try:
|
|
81
|
+
tree = ast.parse(source)
|
|
82
|
+
except (SyntaxError, ValueError, RecursionError):
|
|
83
|
+
return []
|
|
84
|
+
functions = {n.name: n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)}
|
|
85
|
+
|
|
86
|
+
def settings_of(node: ast.AST) -> dict[str, Any] | None:
|
|
87
|
+
value = _literal(node)
|
|
88
|
+
if isinstance(value, dict):
|
|
89
|
+
return value
|
|
90
|
+
if isinstance(node, ast.Name) and node.id in functions:
|
|
91
|
+
for stmt in ast.walk(functions[node.id]):
|
|
92
|
+
if isinstance(stmt, ast.Return) and stmt.value is not None:
|
|
93
|
+
value = _literal(stmt.value)
|
|
94
|
+
if isinstance(value, dict):
|
|
95
|
+
return value
|
|
96
|
+
if isinstance(node, ast.Lambda):
|
|
97
|
+
value = _literal(node.body)
|
|
98
|
+
return value if isinstance(value, dict) else None
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
specs: list[ThemeSpec] = []
|
|
102
|
+
for call in (n for n in ast.walk(tree) if isinstance(n, ast.Call)):
|
|
103
|
+
func = call.func
|
|
104
|
+
if not (isinstance(func, ast.Attribute) and func.attr == "add_syntax_theme") or len(call.args) < 3:
|
|
105
|
+
continue
|
|
106
|
+
name, settings = _literal(call.args[0]), settings_of(call.args[2])
|
|
107
|
+
if not isinstance(name, str) or settings is None:
|
|
108
|
+
continue
|
|
109
|
+
text = settings.get("TEXT") if isinstance(settings.get("TEXT"), dict) else {}
|
|
110
|
+
fields: dict[str, str | None] = {"fg": text.get("foreground"), "bg": text.get("background"), "editor_bg": text.get("background"), "cursor": text.get("insertbackground")}
|
|
111
|
+
for key, target in (("current_line", "line_hl"), ("SELECTION", "sel_bg")):
|
|
112
|
+
entry = settings.get(key)
|
|
113
|
+
if isinstance(entry, dict):
|
|
114
|
+
fields[target] = entry.get("background")
|
|
115
|
+
gutter = settings.get("GUTTER")
|
|
116
|
+
if isinstance(gutter, dict):
|
|
117
|
+
fields["gutter_fg"] = gutter.get("foreground")
|
|
118
|
+
for target, token in _THONNY_TOKENS.items():
|
|
119
|
+
entry = settings.get(token)
|
|
120
|
+
if isinstance(entry, dict) and isinstance(entry.get("foreground"), str):
|
|
121
|
+
fields[target] = entry["foreground"]
|
|
122
|
+
if fields["bg"] or fields["fg"]:
|
|
123
|
+
specs.append(assemble(f"{prefix}_{slug(name)}", name, {k: v for k, v in fields.items() if isinstance(v, str)}))
|
|
124
|
+
return specs
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _is_idle(root: Path) -> bool:
|
|
128
|
+
return bool(_idle_files(Bundle(root)))
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _is_thonny(root: Path) -> bool:
|
|
132
|
+
return bool(_thonny_files(Bundle(root)))
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def load_idle(root: Path, known: set[str]) -> Extension:
|
|
136
|
+
bundle = Bundle(root)
|
|
137
|
+
ext = Extension(id=f"idle.{slug(root.name)}", name=root.name, version="0", kind="idle", path=root)
|
|
138
|
+
for rel in _idle_files(bundle):
|
|
139
|
+
ext.themes.extend(from_idle(decode(bundle.read(rel) or b""), prefix=f"idle_{slug(root.name)}"))
|
|
140
|
+
if not ext.themes:
|
|
141
|
+
ext.warnings.append("nenhum tema de realce encontrado")
|
|
142
|
+
return ext
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def load_thonny(root: Path, known: set[str]) -> Extension:
|
|
146
|
+
bundle = Bundle(root)
|
|
147
|
+
ext = Extension(id=f"thonny.{slug(root.name)}", name=root.name, version="0", kind="thonny", path=root)
|
|
148
|
+
for rel in _thonny_files(bundle):
|
|
149
|
+
ext.themes.extend(from_thonny(decode(bundle.read(rel) or b""), prefix=f"thonny_{slug(root.name)}"))
|
|
150
|
+
if not ext.themes:
|
|
151
|
+
ext.warnings.append("temas montados por código (não por dicionários literais) não são lidos")
|
|
152
|
+
ext.ignored.append("o restante do código Python do plugin (não é executado)")
|
|
153
|
+
return ext
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
registry.register(Format(
|
|
157
|
+
"idle", "IDLE", _is_idle, load_idle, priority=50, suffixes=(".cfg",),
|
|
158
|
+
provides="temas de realce de sintaxe",
|
|
159
|
+
))
|
|
160
|
+
registry.register(Format(
|
|
161
|
+
"thonny", "Thonny", _is_thonny, load_thonny, priority=51, suffixes=(".py",),
|
|
162
|
+
provides="temas de sintaxe de plugins",
|
|
163
|
+
))
|