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,583 @@
|
|
|
1
|
+
"""Diálogo das extensões de outros editores (VS Code, Sublime, JetBrains, Emacs, Eclipse, Pulsar e outros)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import contextlib
|
|
6
|
+
import logging
|
|
7
|
+
import threading
|
|
8
|
+
import tkinter as tk
|
|
9
|
+
from collections.abc import Callable
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from tkinter import filedialog, messagebox
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
from src.constants import FONT_UI
|
|
15
|
+
from src.extcompat import Extension, ExtensionRuntime, ExtensionStore, InstallError, registry
|
|
16
|
+
from src.extcompat.code import HostError, permissions
|
|
17
|
+
from src.extcompat.code import locate as code_locate
|
|
18
|
+
from src.extcompat.market import Listing, search_many
|
|
19
|
+
from src.extcompat.market.sources import default_sources
|
|
20
|
+
from src.i18n import _t
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger("Codis.ExtCompat")
|
|
23
|
+
|
|
24
|
+
_PACKAGE_PATTERNS = ("*.vsix", "*.zip", "*.jar", "*.sublime-package", "*.tar", "*.tgz", "*.tar.gz")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _run_bg(widget: tk.Misc, work: Callable[[], Any], done: Callable[[Any, Exception | None], None]) -> None:
|
|
28
|
+
"""Roda ``work`` numa thread e entrega o resultado em ``done`` na thread da interface."""
|
|
29
|
+
|
|
30
|
+
def target() -> None:
|
|
31
|
+
try:
|
|
32
|
+
result, error = work(), None
|
|
33
|
+
except Exception as exc: # o erro é mostrado ao usuário em ``done``
|
|
34
|
+
result, error = None, exc
|
|
35
|
+
|
|
36
|
+
def deliver() -> None:
|
|
37
|
+
if widget.winfo_exists():
|
|
38
|
+
done(result, error)
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
widget.after(0, deliver)
|
|
42
|
+
except (tk.TclError, RuntimeError):
|
|
43
|
+
logger.debug("Diálogo de extensões fechado antes do fim da operação")
|
|
44
|
+
|
|
45
|
+
threading.Thread(target=target, daemon=True, name="extcompat-bg").start()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ExtCompatDialog(tk.Toplevel):
|
|
49
|
+
def __init__(
|
|
50
|
+
self, parent: tk.Misc, tmgr: Any, store: ExtensionStore, runtime: ExtensionRuntime, app: Any = None,
|
|
51
|
+
code: Any = None,
|
|
52
|
+
) -> None:
|
|
53
|
+
super().__init__(parent)
|
|
54
|
+
self._t = tmgr.theme
|
|
55
|
+
self._store, self._runtime, self._app, self._code = store, runtime, app, code
|
|
56
|
+
self._items: list[Extension] = []
|
|
57
|
+
t = self._t
|
|
58
|
+
self.title(_t("extcompat.title", "Extensões de outros editores"))
|
|
59
|
+
self.configure(bg=t.floating_bg)
|
|
60
|
+
self.geometry("820x580")
|
|
61
|
+
self.minsize(640, 420)
|
|
62
|
+
self.transient(parent)
|
|
63
|
+
|
|
64
|
+
tk.Label(
|
|
65
|
+
self, anchor="w", justify="left", bg=t.floating_bg, fg=t.fg_muted, font=(FONT_UI, 9), wraplength=780,
|
|
66
|
+
text=_t(
|
|
67
|
+
"extcompat.intro",
|
|
68
|
+
"Importa o que extensões de dezenas de editores declaram (VS Code, Sublime, JetBrains, Emacs, Eclipse, "
|
|
69
|
+
"Pulsar, Notepad++, Geany, Kate, gedit, Helix e outros): temas, snippets, linguagens e gramáticas. "
|
|
70
|
+
"O código das extensões só roda se você liberar, e com confirmação expressa.",
|
|
71
|
+
),
|
|
72
|
+
).pack(fill="x", padx=14, pady=(12, 6))
|
|
73
|
+
|
|
74
|
+
bar = tk.Frame(self, bg=t.floating_bg)
|
|
75
|
+
bar.pack(fill="x", padx=14, pady=(0, 8))
|
|
76
|
+
for text, cmd in (
|
|
77
|
+
(_t("extcompat.install_file", "Instalar de arquivo..."), self._install_file),
|
|
78
|
+
(_t("extcompat.install_folder", "Instalar de pasta..."), self._install_folder),
|
|
79
|
+
(_t("extcompat.search", "Buscar na internet..."), self._open_search),
|
|
80
|
+
):
|
|
81
|
+
self._button(bar, text, cmd).pack(side="left", padx=(0, 6))
|
|
82
|
+
if code is not None:
|
|
83
|
+
self._gate_btn = self._button(bar, "", self._toggle_gate)
|
|
84
|
+
self._gate_btn.pack(side="right")
|
|
85
|
+
|
|
86
|
+
body = tk.Frame(self, bg=t.floating_bg)
|
|
87
|
+
body.pack(fill="both", expand=True, padx=14)
|
|
88
|
+
self._list = tk.Listbox(
|
|
89
|
+
body, width=34, exportselection=False, activestyle="none", bd=0, highlightthickness=1,
|
|
90
|
+
highlightbackground=t.border, bg=t.input_bg, fg=t.fg, selectbackground=t.sel_bg,
|
|
91
|
+
selectforeground=t.sel_fg, font=(FONT_UI, 10),
|
|
92
|
+
)
|
|
93
|
+
self._list.pack(side="left", fill="y")
|
|
94
|
+
self._list.bind("<<ListboxSelect>>", lambda _e: self._show_details())
|
|
95
|
+
self._details = tk.Text(
|
|
96
|
+
body, wrap="word", state="disabled", bd=0, highlightthickness=1, highlightbackground=t.border,
|
|
97
|
+
bg=t.input_bg, fg=t.fg, font=(FONT_UI, 10), padx=10, pady=8,
|
|
98
|
+
)
|
|
99
|
+
self._details.pack(side="left", fill="both", expand=True, padx=(8, 0))
|
|
100
|
+
|
|
101
|
+
self._status = tk.Label(self, anchor="w", bg=t.floating_bg, fg=t.fg_muted, font=(FONT_UI, 9))
|
|
102
|
+
self._status.pack(fill="x", padx=14, pady=(6, 0))
|
|
103
|
+
foot = tk.Frame(self, bg=t.floating_bg)
|
|
104
|
+
foot.pack(fill="x", padx=14, pady=10)
|
|
105
|
+
self._button(foot, _t("extcompat.close", "Fechar"), self.destroy).pack(side="right")
|
|
106
|
+
self._button(foot, _t("extcompat.remove", "Remover"), self._remove).pack(side="left")
|
|
107
|
+
self._toggle_btn = self._button(foot, _t("extcompat.disable", "Desativar"), self._toggle)
|
|
108
|
+
self._toggle_btn.pack(side="left", padx=6)
|
|
109
|
+
if app is not None:
|
|
110
|
+
self._button(
|
|
111
|
+
foot, _t("extcompat.themes", "Abrir seletor de temas"), self._open_theme_selector
|
|
112
|
+
).pack(side="left")
|
|
113
|
+
if code is not None:
|
|
114
|
+
code_bar = tk.Frame(self, bg=t.floating_bg)
|
|
115
|
+
code_bar.pack(fill="x", padx=14, pady=(0, 8), before=foot)
|
|
116
|
+
self._code_btn = self._button(code_bar, "", self._toggle_code)
|
|
117
|
+
self._code_btn.pack(side="left")
|
|
118
|
+
self._perm_btn = self._button(code_bar, _t("extcode.permissions", "Permissões..."), self._edit_permissions)
|
|
119
|
+
self._perm_btn.pack(side="left", padx=6)
|
|
120
|
+
self._button(code_bar, _t("extcode.output", "Ver saída"), self._show_code_output).pack(side="left")
|
|
121
|
+
self._button(code_bar, _t("extcode.runtime", "Escolher executável..."), self._pick_runtime).pack(side="left", padx=6)
|
|
122
|
+
self.bind("<Escape>", lambda _e: self.destroy())
|
|
123
|
+
self._refresh()
|
|
124
|
+
|
|
125
|
+
def _button(self, parent: tk.Misc, text: str, command: Callable[[], None]) -> tk.Button:
|
|
126
|
+
t = self._t
|
|
127
|
+
return tk.Button(
|
|
128
|
+
parent, text=text, command=command, relief="flat", cursor="hand2", padx=12, pady=4,
|
|
129
|
+
bg=t.btn_bg, fg=t.btn_fg, activebackground=t.btn_hover, activeforeground=t.btn_fg, font=(FONT_UI, 9),
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# --- lista e detalhes -------------------------------------------------------------------
|
|
133
|
+
|
|
134
|
+
def _selected(self) -> Extension | None:
|
|
135
|
+
sel = self._list.curselection()
|
|
136
|
+
return self._items[sel[0]] if sel and sel[0] < len(self._items) else None
|
|
137
|
+
|
|
138
|
+
def _refresh(self, select: str | None = None) -> None:
|
|
139
|
+
self._items = self._store.installed()
|
|
140
|
+
self._list.delete(0, "end")
|
|
141
|
+
for ext in self._items:
|
|
142
|
+
mark = "●" if self._store.is_enabled(ext.id) else "○"
|
|
143
|
+
self._list.insert("end", f"{mark} {ext.name} ({registry.label(ext.kind)})")
|
|
144
|
+
index = next((i for i, e in enumerate(self._items) if e.id == select), 0 if self._items else -1)
|
|
145
|
+
if index >= 0:
|
|
146
|
+
self._list.selection_set(index)
|
|
147
|
+
self._show_details()
|
|
148
|
+
|
|
149
|
+
def _write(self, text: str) -> None:
|
|
150
|
+
self._details.configure(state="normal")
|
|
151
|
+
self._details.delete("1.0", "end")
|
|
152
|
+
self._details.insert("1.0", text)
|
|
153
|
+
self._details.configure(state="disabled")
|
|
154
|
+
|
|
155
|
+
def _sync_code_buttons(self, ext: Extension | None) -> None:
|
|
156
|
+
if self._code is None:
|
|
157
|
+
return
|
|
158
|
+
on = self._code.state.enabled
|
|
159
|
+
self._gate_btn.configure(
|
|
160
|
+
text=_t("extcode.gate_off", "Desligar execução de código") if on else _t("extcode.gate_on", "Execução de código...")
|
|
161
|
+
)
|
|
162
|
+
status = self._code.status(ext) if ext is not None else None
|
|
163
|
+
running = status is not None and status.state in ("active", "running")
|
|
164
|
+
self._code_btn.configure(
|
|
165
|
+
text=_t("extcode.stop", "Parar código") if running else _t("extcode.run", "Executar código..."),
|
|
166
|
+
state="normal" if status is not None and status.state != "none" else "disabled",
|
|
167
|
+
)
|
|
168
|
+
self._perm_btn.configure(
|
|
169
|
+
state="normal" if status is not None and status.state in ("ready", "active", "running") else "disabled"
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
def _show_details(self) -> None:
|
|
173
|
+
ext = self._selected()
|
|
174
|
+
self._sync_code_buttons(ext)
|
|
175
|
+
if ext is None:
|
|
176
|
+
self._write(_t("extcompat.empty", "Nenhuma extensão instalada. Use os botões acima para importar uma."))
|
|
177
|
+
self._toggle_btn.configure(text=_t("extcompat.disable", "Desativar"))
|
|
178
|
+
return
|
|
179
|
+
enabled = self._store.is_enabled(ext.id)
|
|
180
|
+
self._toggle_btn.configure(
|
|
181
|
+
text=_t("extcompat.disable", "Desativar") if enabled else _t("extcompat.enable", "Ativar")
|
|
182
|
+
)
|
|
183
|
+
c = ext.counts()
|
|
184
|
+
lines = [
|
|
185
|
+
f"{ext.name} {ext.version}",
|
|
186
|
+
f"{registry.label(ext.kind)} · {ext.id}"
|
|
187
|
+
+ (f" · {ext.publisher}" if ext.publisher and ext.kind != "vscode" else ""),
|
|
188
|
+
"",
|
|
189
|
+
ext.description,
|
|
190
|
+
"",
|
|
191
|
+
_t("extcompat.imported", "Importado: {themes} tema(s), {snippets} snippet(s), {languages} linguagem(ns).", **c),
|
|
192
|
+
_t("extcompat.state_on", "Estado: ativa") if enabled else _t("extcompat.state_off", "Estado: desativada"),
|
|
193
|
+
]
|
|
194
|
+
if ext.themes:
|
|
195
|
+
lines += ["", _t("extcompat.themes_title", "Temas:")] + [f" • {th.name}" for th in ext.themes]
|
|
196
|
+
if ext.languages:
|
|
197
|
+
lines += ["", _t("extcompat.langs_title", "Linguagens:")] + [
|
|
198
|
+
f" • {lg.label} ({', '.join(lg.extensions)})" for lg in ext.languages
|
|
199
|
+
]
|
|
200
|
+
if ext.code is not None and self._code is not None:
|
|
201
|
+
lines += ["", _t("extcode.status_title", "Código ({n} comando(s)):", n=len(ext.code.commands)),
|
|
202
|
+
f" {self._code.status(ext).text}",
|
|
203
|
+
_t("extcode.perms_line", " Permissões: {list}", list=permissions.describe(self._code.permissions(ext)))]
|
|
204
|
+
if ext.ignored:
|
|
205
|
+
lines += ["", _t("extcompat.ignored_title", "Não suportado (ignorado):")] + [f" • {i}" for i in ext.ignored]
|
|
206
|
+
if ext.warnings:
|
|
207
|
+
lines += ["", _t("extcompat.warnings_title", "Avisos:")] + [f" • {w}" for w in ext.warnings]
|
|
208
|
+
self._write("\n".join(lines))
|
|
209
|
+
|
|
210
|
+
# --- ações ----------------------------------------------------------------------------------
|
|
211
|
+
|
|
212
|
+
def _apply_runtime(self) -> None:
|
|
213
|
+
self._runtime.activate_all()
|
|
214
|
+
if self._app is not None:
|
|
215
|
+
try:
|
|
216
|
+
self._app._rebuild_theme_menu()
|
|
217
|
+
except Exception:
|
|
218
|
+
logger.debug("Não foi possível atualizar o menu de temas", exc_info=True)
|
|
219
|
+
|
|
220
|
+
def _finish_install(self, ext: Extension | None, error: Exception | None) -> None:
|
|
221
|
+
if error is not None:
|
|
222
|
+
msg = str(error) if isinstance(error, InstallError) else f"{type(error).__name__}: {error}"
|
|
223
|
+
messagebox.showerror(_t("extcompat.title", "Extensões de outros editores"), msg, parent=self)
|
|
224
|
+
self._status.configure(text="", fg=self._t.fg_muted)
|
|
225
|
+
return
|
|
226
|
+
if ext is None:
|
|
227
|
+
return
|
|
228
|
+
self._apply_runtime()
|
|
229
|
+
self._refresh(select=ext.id)
|
|
230
|
+
self._status.configure(
|
|
231
|
+
text=_t("extcompat.installed", "Instalada: {name}.", name=ext.name), fg=self._t.ok_fg
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
def _install_path(self, path: Path) -> None:
|
|
235
|
+
self._status.configure(text=_t("extcompat.installing", "Instalando..."), fg=self._t.fg_muted)
|
|
236
|
+
_run_bg(self, lambda: self._store.install(path), self._finish_install)
|
|
237
|
+
|
|
238
|
+
@staticmethod
|
|
239
|
+
def _file_patterns() -> str:
|
|
240
|
+
singles = [f"*{sfx}" for sfx in registry.file_suffixes()]
|
|
241
|
+
return " ".join(dict.fromkeys([*_PACKAGE_PATTERNS, "*.vim", "*.lua", *singles]))
|
|
242
|
+
|
|
243
|
+
def _install_file(self) -> None:
|
|
244
|
+
picked = filedialog.askopenfilename(
|
|
245
|
+
parent=self, title=_t("extcompat.install_file", "Instalar de arquivo..."),
|
|
246
|
+
filetypes=[
|
|
247
|
+
(_t("extcompat.filetypes", "Extensões e esquemas"), self._file_patterns()),
|
|
248
|
+
(_t("extcompat.all_files", "Todos"), "*.*"),
|
|
249
|
+
],
|
|
250
|
+
)
|
|
251
|
+
if picked:
|
|
252
|
+
self._install_path(Path(picked))
|
|
253
|
+
|
|
254
|
+
def _install_folder(self) -> None:
|
|
255
|
+
picked = filedialog.askdirectory(parent=self, title=_t("extcompat.install_folder", "Instalar de pasta..."))
|
|
256
|
+
if picked:
|
|
257
|
+
self._install_path(Path(picked))
|
|
258
|
+
|
|
259
|
+
def _toggle(self) -> None:
|
|
260
|
+
ext = self._selected()
|
|
261
|
+
if ext is None:
|
|
262
|
+
return
|
|
263
|
+
self._store.set_enabled(ext.id, not self._store.is_enabled(ext.id))
|
|
264
|
+
self._apply_runtime()
|
|
265
|
+
self._refresh(select=ext.id)
|
|
266
|
+
|
|
267
|
+
def _remove(self) -> None:
|
|
268
|
+
ext = self._selected()
|
|
269
|
+
if ext is None:
|
|
270
|
+
return
|
|
271
|
+
if not messagebox.askyesno(
|
|
272
|
+
_t("extcompat.title", "Extensões de outros editores"),
|
|
273
|
+
_t("extcompat.confirm_remove", "Remover \"{name}\"?", name=ext.name), parent=self,
|
|
274
|
+
):
|
|
275
|
+
return
|
|
276
|
+
self._runtime.deactivate(ext.id)
|
|
277
|
+
if self._code is not None:
|
|
278
|
+
self._code.forget(ext.id)
|
|
279
|
+
self._store.remove(ext.id)
|
|
280
|
+
self._apply_runtime()
|
|
281
|
+
self._refresh()
|
|
282
|
+
|
|
283
|
+
# --- execução de código ---------------------------------------------------------------------
|
|
284
|
+
|
|
285
|
+
def _toggle_gate(self) -> None:
|
|
286
|
+
from src.ui.extcode_dialogs import ask_global_risk
|
|
287
|
+
|
|
288
|
+
code = self._code
|
|
289
|
+
if code.state.enabled:
|
|
290
|
+
if messagebox.askyesno(
|
|
291
|
+
_t("extcode.gate_title", "Execução de código"),
|
|
292
|
+
_t("extcode.gate_off_ask", "Desligar a execução de código? Os processos em andamento serão encerrados e os "
|
|
293
|
+
"comandos saem da paleta. As confirmações por extensão ficam guardadas."), parent=self,
|
|
294
|
+
):
|
|
295
|
+
for ext_id in code.state.active_ids():
|
|
296
|
+
code.deactivate(ext_id)
|
|
297
|
+
code.state.set_active(ext_id, True) # volta a ficar ativa se o recurso for religado
|
|
298
|
+
code.stop_all()
|
|
299
|
+
for ext in self._items:
|
|
300
|
+
code.sink.remove(f"ext:{ext.id}")
|
|
301
|
+
code.state.set_enabled(False)
|
|
302
|
+
elif ask_global_risk(self, self._t):
|
|
303
|
+
code.state.set_enabled(True)
|
|
304
|
+
self._show_details()
|
|
305
|
+
|
|
306
|
+
def _toggle_code(self) -> None:
|
|
307
|
+
ext, code = self._selected(), self._code
|
|
308
|
+
if ext is None or ext.code is None:
|
|
309
|
+
return
|
|
310
|
+
status = code.status(ext)
|
|
311
|
+
title = _t("extcode.gate_title", "Execução de código")
|
|
312
|
+
if status.state in ("active", "running"):
|
|
313
|
+
code.deactivate(ext.id)
|
|
314
|
+
elif status.state == "off":
|
|
315
|
+
messagebox.showinfo(title, _t("extcode.need_gate", "Libere primeiro a execução de código (botão no alto da janela)."), parent=self)
|
|
316
|
+
elif status.state == "no_runtime":
|
|
317
|
+
self._pick_runtime()
|
|
318
|
+
else:
|
|
319
|
+
if status.can_confirm:
|
|
320
|
+
chosen = self._ask_permissions(ext, status)
|
|
321
|
+
if chosen is None:
|
|
322
|
+
return
|
|
323
|
+
code.confirm(ext, chosen)
|
|
324
|
+
try:
|
|
325
|
+
code.activate(ext)
|
|
326
|
+
except HostError as exc:
|
|
327
|
+
messagebox.showerror(title, str(exc), parent=self)
|
|
328
|
+
return
|
|
329
|
+
self._status.configure(
|
|
330
|
+
text=_t("extcode.activated", "Código ativo: os comandos estão na paleta (inicia ao usar um)."), fg=self._t.ok_fg
|
|
331
|
+
)
|
|
332
|
+
self._refresh(select=ext.id)
|
|
333
|
+
|
|
334
|
+
def _ask_permissions(self, ext: Extension, status: Any, current: frozenset[str] = frozenset()) -> frozenset[str] | None:
|
|
335
|
+
"""Testa o runtime e abre a confirmação com as permissões; ``None`` se algo falhou ou o usuário desistiu."""
|
|
336
|
+
from src.ui.extcode_dialogs import ask_extension_consent
|
|
337
|
+
|
|
338
|
+
code = self._code
|
|
339
|
+
title = _t("extcode.gate_title", "Execução de código")
|
|
340
|
+
digest = code.fingerprint(ext)
|
|
341
|
+
if digest is None:
|
|
342
|
+
messagebox.showerror(title, _t("extcode.too_big", "O código é grande demais para ser auditado; recusado."), parent=self)
|
|
343
|
+
return None
|
|
344
|
+
self._status.configure(text=_t("extcode.testing", "Testando o runtime..."), fg=self._t.fg_muted)
|
|
345
|
+
self.update_idletasks()
|
|
346
|
+
check = code.check_runtime(status.runtime)
|
|
347
|
+
self._status.configure(text="")
|
|
348
|
+
if check.problem:
|
|
349
|
+
messagebox.showerror(
|
|
350
|
+
title, _t("extcode.runtime_failed", "O runtime não conseguiu iniciar o host:\n\n{problem}", problem=check.problem),
|
|
351
|
+
parent=self,
|
|
352
|
+
)
|
|
353
|
+
return None
|
|
354
|
+
return ask_extension_consent(
|
|
355
|
+
self, self._t, ext, check.runtime, digest, lambda chosen: code.launch_plan(check.runtime, chosen), current
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
def _edit_permissions(self) -> None:
|
|
359
|
+
ext, code = self._selected(), self._code
|
|
360
|
+
if ext is None or ext.code is None:
|
|
361
|
+
return
|
|
362
|
+
status = code.status(ext)
|
|
363
|
+
if status.state not in ("ready", "active", "running"):
|
|
364
|
+
messagebox.showinfo(
|
|
365
|
+
_t("extcode.gate_title", "Execução de código"),
|
|
366
|
+
_t("extcode.need_confirm", "Confirme a execução do código desta extensão primeiro (botão Executar código)."), parent=self,
|
|
367
|
+
)
|
|
368
|
+
return
|
|
369
|
+
chosen = self._ask_permissions(ext, status, code.permissions(ext))
|
|
370
|
+
if chosen is not None:
|
|
371
|
+
code.confirm(ext, chosen)
|
|
372
|
+
self._refresh(select=ext.id)
|
|
373
|
+
|
|
374
|
+
def _show_code_output(self) -> None:
|
|
375
|
+
from src.ui.extcode_dialogs import show_output
|
|
376
|
+
|
|
377
|
+
ext = self._selected()
|
|
378
|
+
if ext is not None:
|
|
379
|
+
show_output(self, self._t, f"{ext.name}: {_t('extcode.output', 'Ver saída')}", self._code.output(ext.id))
|
|
380
|
+
|
|
381
|
+
def _pick_runtime(self) -> None:
|
|
382
|
+
ext = self._selected()
|
|
383
|
+
if ext is None or ext.code is None:
|
|
384
|
+
return
|
|
385
|
+
kind = ext.code.runtime
|
|
386
|
+
picked = filedialog.askopenfilename(
|
|
387
|
+
parent=self, title=_t("extcode.pick_runtime", "Escolha o executável ({kind})", kind=kind)
|
|
388
|
+
)
|
|
389
|
+
if not picked:
|
|
390
|
+
return
|
|
391
|
+
if code_locate.find(kind, picked) is None or code_locate.find(kind, picked).path != picked:
|
|
392
|
+
messagebox.showerror(
|
|
393
|
+
_t("extcode.gate_title", "Execução de código"),
|
|
394
|
+
_t("extcode.bad_runtime", "Esse arquivo não é um {kind} utilizável (Node 18+ ou Python 3.8+).", kind=kind), parent=self,
|
|
395
|
+
)
|
|
396
|
+
return
|
|
397
|
+
self._code.state.set_runtime_path(kind, picked)
|
|
398
|
+
self._refresh(select=ext.id)
|
|
399
|
+
|
|
400
|
+
def _open_theme_selector(self) -> None:
|
|
401
|
+
try:
|
|
402
|
+
self._app._open_theme_panel()
|
|
403
|
+
except Exception:
|
|
404
|
+
logger.debug("Não foi possível abrir o seletor de temas", exc_info=True)
|
|
405
|
+
|
|
406
|
+
def _open_search(self) -> None:
|
|
407
|
+
_MarketSearch(self, self._t, self._store, self._finish_install_from_search, self._code)
|
|
408
|
+
|
|
409
|
+
def _finish_install_from_search(self, ext: Extension | None, error: Exception | None) -> None:
|
|
410
|
+
self._finish_install(ext, error)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
class _MarketSearch(tk.Toplevel):
|
|
414
|
+
"""Busca em vários catálogos (Open VSX, JetBrains, Pulsar, MELPA, GitHub); só usa a rede quando o usuário pede."""
|
|
415
|
+
|
|
416
|
+
SEARCH_DEADLINE_MS = 55_000
|
|
417
|
+
INSTALL_DEADLINE_MS = 150_000
|
|
418
|
+
|
|
419
|
+
def __init__(
|
|
420
|
+
self, parent: ExtCompatDialog, theme: Any, store: ExtensionStore, on_done: Callable, code: Any = None
|
|
421
|
+
) -> None:
|
|
422
|
+
super().__init__(parent)
|
|
423
|
+
t = theme
|
|
424
|
+
self._store, self._on_done, self._code = store, on_done, code
|
|
425
|
+
self._sources = default_sources()
|
|
426
|
+
self._vars = {s.id: tk.BooleanVar(value=True) for s in self._sources}
|
|
427
|
+
self._results: list[Listing] = []
|
|
428
|
+
self._by_source: dict[str, list[Listing]] = {}
|
|
429
|
+
self._report: dict[str, str] = {}
|
|
430
|
+
self._token = 0
|
|
431
|
+
self._busy = False
|
|
432
|
+
self.title(_t("extcompat.search_title", "Buscar extensões e temas"))
|
|
433
|
+
self.configure(bg=t.floating_bg)
|
|
434
|
+
self.geometry("720x520")
|
|
435
|
+
self.transient(parent)
|
|
436
|
+
row = tk.Frame(self, bg=t.floating_bg)
|
|
437
|
+
row.pack(fill="x", padx=12, pady=(12, 4))
|
|
438
|
+
self._query = tk.Entry(row, bg=t.input_bg, fg=t.fg, insertbackground=t.fg, relief="flat", font=(FONT_UI, 10))
|
|
439
|
+
self._query.pack(side="left", fill="x", expand=True, ipady=4)
|
|
440
|
+
self._query.bind("<Return>", lambda _e: self._search())
|
|
441
|
+
self._query.focus_set()
|
|
442
|
+
tk.Button(
|
|
443
|
+
row, text=_t("extcompat.search_go", "Buscar"), command=self._search, relief="flat", cursor="hand2", padx=12,
|
|
444
|
+
bg=t.btn_primary, fg=t.btn_primary_fg, font=(FONT_UI, 9),
|
|
445
|
+
).pack(side="left", padx=(6, 0))
|
|
446
|
+
srcs = tk.Frame(self, bg=t.floating_bg)
|
|
447
|
+
srcs.pack(fill="x", padx=12)
|
|
448
|
+
for src in self._sources:
|
|
449
|
+
tk.Checkbutton(
|
|
450
|
+
srcs, text=src.label, variable=self._vars[src.id], bg=t.floating_bg, fg=t.fg, selectcolor=t.input_bg,
|
|
451
|
+
activebackground=t.floating_bg, activeforeground=t.fg, font=(FONT_UI, 9),
|
|
452
|
+
).pack(side="left", padx=(0, 8))
|
|
453
|
+
self._list = tk.Listbox(
|
|
454
|
+
self, activestyle="none", bd=0, highlightthickness=1, highlightbackground=t.border, bg=t.input_bg,
|
|
455
|
+
fg=t.fg, selectbackground=t.sel_bg, selectforeground=t.sel_fg, font=(FONT_UI, 10),
|
|
456
|
+
)
|
|
457
|
+
self._list.pack(fill="both", expand=True, padx=12, pady=(8, 0))
|
|
458
|
+
self._list.bind("<Double-Button-1>", lambda _e: self._install())
|
|
459
|
+
self._status = tk.Label(
|
|
460
|
+
self, anchor="w", bg=t.floating_bg, fg=t.fg_muted, font=(FONT_UI, 9), wraplength=680, justify="left"
|
|
461
|
+
)
|
|
462
|
+
self._status.pack(fill="x", padx=12, pady=(6, 0))
|
|
463
|
+
tk.Button(
|
|
464
|
+
self, text=_t("extcompat.search_install", "Instalar selecionada"), command=self._install, relief="flat",
|
|
465
|
+
cursor="hand2", padx=12, pady=4, bg=t.btn_bg, fg=t.btn_fg, font=(FONT_UI, 9),
|
|
466
|
+
).pack(anchor="e", padx=12, pady=10)
|
|
467
|
+
self.bind("<Escape>", lambda _e: self._close())
|
|
468
|
+
self.protocol("WM_DELETE_WINDOW", self._close)
|
|
469
|
+
|
|
470
|
+
def _close(self) -> None:
|
|
471
|
+
self._token += 1 # respostas que chegarem depois são descartadas
|
|
472
|
+
self.destroy()
|
|
473
|
+
|
|
474
|
+
# --- busca ---------------------------------------------------------------------------------
|
|
475
|
+
|
|
476
|
+
def _search(self) -> None:
|
|
477
|
+
query = self._query.get().strip()
|
|
478
|
+
chosen = [s for s in self._sources if self._vars[s.id].get()]
|
|
479
|
+
if not query or not chosen:
|
|
480
|
+
return
|
|
481
|
+
self._token += 1
|
|
482
|
+
token = self._token
|
|
483
|
+
self._by_source, self._report = {}, {s.id: _t("extcompat.waiting", "aguardando...") for s in chosen}
|
|
484
|
+
self._results = []
|
|
485
|
+
self._list.delete(0, "end")
|
|
486
|
+
self._render_status()
|
|
487
|
+
|
|
488
|
+
def on_source(src: Any, items: list[Listing] | None, error: Exception | None) -> None:
|
|
489
|
+
with contextlib.suppress(tk.TclError, RuntimeError):
|
|
490
|
+
self.after(0, lambda: self._source_done(token, src, items, error))
|
|
491
|
+
|
|
492
|
+
search_many(chosen, query, 25, on_source)
|
|
493
|
+
self.after(self.SEARCH_DEADLINE_MS, lambda: self._deadline(token, chosen))
|
|
494
|
+
|
|
495
|
+
def _source_done(self, token: int, src: Any, items: list[Listing] | None, error: Exception | None) -> None:
|
|
496
|
+
if token != self._token or not self.winfo_exists():
|
|
497
|
+
return
|
|
498
|
+
if error is not None:
|
|
499
|
+
logger.info("Busca em %s falhou: %s", src.id, error)
|
|
500
|
+
self._report[src.id] = _t("extcompat.source_error", "erro: {e}", e=str(error))
|
|
501
|
+
else:
|
|
502
|
+
self._by_source[src.id] = items or []
|
|
503
|
+
self._report[src.id] = _t("extcompat.source_count", "{n} resultado(s)", n=len(items or []))
|
|
504
|
+
self._refill()
|
|
505
|
+
|
|
506
|
+
def _deadline(self, token: int, chosen: list[Any]) -> None:
|
|
507
|
+
if token != self._token or not self.winfo_exists():
|
|
508
|
+
return
|
|
509
|
+
for src in chosen:
|
|
510
|
+
if src.id not in self._by_source and not self._report.get(src.id, "").startswith(_t("extcompat.source_error", "erro: {e}", e="")):
|
|
511
|
+
self._report[src.id] = _t("extcompat.source_timeout", "sem resposta a tempo")
|
|
512
|
+
self._refill()
|
|
513
|
+
|
|
514
|
+
def _refill(self) -> None:
|
|
515
|
+
self._results = [item for s in self._sources for item in self._by_source.get(s.id, [])]
|
|
516
|
+
self._list.delete(0, "end")
|
|
517
|
+
for item in self._results:
|
|
518
|
+
label = next((s.label for s in self._sources if s.id == item.source), item.source)
|
|
519
|
+
stars = f" ({item.downloads:,})" if item.downloads else ""
|
|
520
|
+
self._list.insert("end", f"[{label}] {item.title} {item.version}{stars} - {item.description[:70]}")
|
|
521
|
+
self._render_status()
|
|
522
|
+
|
|
523
|
+
def _render_status(self) -> None:
|
|
524
|
+
parts = [f"{next((s.label for s in self._sources if s.id == sid), sid)}: {text}" for sid, text in self._report.items()]
|
|
525
|
+
hint = _t("extcompat.results_hint", "Duplo clique para instalar.") if self._results else ""
|
|
526
|
+
self._status.configure(text="\n".join([*parts, hint]).strip())
|
|
527
|
+
|
|
528
|
+
# --- instalação ----------------------------------------------------------------------------
|
|
529
|
+
|
|
530
|
+
def _install(self) -> None:
|
|
531
|
+
sel = self._list.curselection()
|
|
532
|
+
if not sel or self._busy:
|
|
533
|
+
return
|
|
534
|
+
item = self._results[sel[0]]
|
|
535
|
+
src = next(s for s in self._sources if s.id == item.source)
|
|
536
|
+
if self._code is not None and self._code.state.enabled and not messagebox.askokcancel(
|
|
537
|
+
_t("extcode.download_title", "Antes de baixar"),
|
|
538
|
+
_t(
|
|
539
|
+
"extcode.download_warning",
|
|
540
|
+
"{id} é código de terceiros e, com a execução de código ligada, você poderá executá-lo.\n\n"
|
|
541
|
+
"Audite-o ANTES de baixar: leia o repositório, as dependências e o histórico do autor.\n"
|
|
542
|
+
"Página: {page}\n\nBaixar mesmo assim?",
|
|
543
|
+
id=item.title, page=item.page or "-",
|
|
544
|
+
),
|
|
545
|
+
parent=self,
|
|
546
|
+
):
|
|
547
|
+
return
|
|
548
|
+
self._busy = True
|
|
549
|
+
token = self._token
|
|
550
|
+
self._status.configure(text=_t("extcompat.downloading", "Baixando {id}...", id=item.title))
|
|
551
|
+
|
|
552
|
+
def work() -> Extension:
|
|
553
|
+
archive = src.download(item)
|
|
554
|
+
try:
|
|
555
|
+
return self._store.install(archive)
|
|
556
|
+
finally:
|
|
557
|
+
archive.unlink(missing_ok=True)
|
|
558
|
+
with contextlib.suppress(OSError):
|
|
559
|
+
archive.parent.rmdir()
|
|
560
|
+
|
|
561
|
+
def done(ext: Extension | None, error: Exception | None) -> None:
|
|
562
|
+
self._busy = False
|
|
563
|
+
if token != self._token or not self.winfo_exists():
|
|
564
|
+
return
|
|
565
|
+
self._on_done(ext, error)
|
|
566
|
+
if error is None:
|
|
567
|
+
self.destroy()
|
|
568
|
+
else:
|
|
569
|
+
self._status.configure(text=str(error))
|
|
570
|
+
|
|
571
|
+
_run_bg(self, work, done)
|
|
572
|
+
self.after(self.INSTALL_DEADLINE_MS, lambda: self._install_deadline(token))
|
|
573
|
+
|
|
574
|
+
def _install_deadline(self, token: int) -> None:
|
|
575
|
+
if token == self._token and self._busy and self.winfo_exists():
|
|
576
|
+
self._busy = False
|
|
577
|
+
self._status.configure(text=_t("extcompat.install_timeout", "O download demorou demais; tente de novo."))
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
def open_dialog(
|
|
581
|
+
parent: tk.Misc, tmgr: Any, store: ExtensionStore, runtime: ExtensionRuntime, app: Any = None, code: Any = None
|
|
582
|
+
) -> ExtCompatDialog:
|
|
583
|
+
return ExtCompatDialog(parent, tmgr, store, runtime, app, code)
|