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/ui/problems.py
ADDED
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
"""Painel de problemas (erros e avisos) do Codis.
|
|
2
|
+
|
|
3
|
+
Provê ``ProblemsPanel``, que agrega e exibe diagnósticos LSP e de linters
|
|
4
|
+
em uma lista navegável, com filtragem por severidade e navegação direta
|
|
5
|
+
até a linha do problema no editor.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import contextlib
|
|
11
|
+
import logging
|
|
12
|
+
import tkinter as tk
|
|
13
|
+
from collections.abc import Callable
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from tkinter import ttk
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
from src.constants import FONT_UI
|
|
19
|
+
from src.i18n import _t
|
|
20
|
+
from src.lint.manager import Diag
|
|
21
|
+
from src.theme.base import Theme
|
|
22
|
+
from src.theme.manager import ThemeManager
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger("Codis")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ProblemsPanel(tk.Frame):
|
|
28
|
+
"""
|
|
29
|
+
Painel de diagnósticos:
|
|
30
|
+
- Agrupamento por arquivo com contadores
|
|
31
|
+
- Filtro de severidade com botões visuais pressionados/soltos
|
|
32
|
+
- Filtro textual por mensagem ou regra
|
|
33
|
+
- Clique/duplo-clique para navegar ao erro no editor
|
|
34
|
+
- Fix Action executável direto do painel (quando disponível)
|
|
35
|
+
- Tooltip com mensagem completa ao hover
|
|
36
|
+
- Contador por severidade na toolbar em tempo real
|
|
37
|
+
- apply_theme correto (reconfigurar Treeview + tags + toolbar)
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
_SEV_META = {
|
|
41
|
+
1: ("✖", "error", "err_fg"),
|
|
42
|
+
2: ("⚠", "warning", "warn_fg"),
|
|
43
|
+
3: ("ℹ", "info", "info_fg"),
|
|
44
|
+
4: ("-", "hint", "hint_fg"),
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
parent: tk.Widget,
|
|
50
|
+
tmgr: ThemeManager,
|
|
51
|
+
on_goto: Callable[[int, int], None],
|
|
52
|
+
on_apply_fix: Callable[[str, Diag], None] | None = None,
|
|
53
|
+
on_fix_all: Callable[[str, list[Diag]], None] | None = None,
|
|
54
|
+
) -> None:
|
|
55
|
+
"""Cria o painel de problemas (erros e avisos do lint/LSP).
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
parent: Widget pai Tkinter.
|
|
59
|
+
on_goto: Callback(path, line) para navegar até o problema.
|
|
60
|
+
on_apply_fix: Callback(file_path, diag) para aplicar um fix no editor.
|
|
61
|
+
on_fix_all: Callback(file_path, diags) para aplicar todos os fixes no editor.
|
|
62
|
+
"""
|
|
63
|
+
t = tmgr.theme
|
|
64
|
+
super().__init__(parent, bg=t.panel_bg)
|
|
65
|
+
self._tmgr = tmgr
|
|
66
|
+
self._on_goto = on_goto
|
|
67
|
+
self._on_apply_fix = on_apply_fix
|
|
68
|
+
self._on_fix_all = on_fix_all
|
|
69
|
+
self._diags: list[Diag] = []
|
|
70
|
+
self._file = ""
|
|
71
|
+
self._filter: set = {1, 2, 3, 4}
|
|
72
|
+
self._sev_btns: dict[int, tk.Label] = {}
|
|
73
|
+
self._tooltip_win: tk.Toplevel | None = None
|
|
74
|
+
|
|
75
|
+
self._diags_by_file: dict[str, list[Diag]] = {}
|
|
76
|
+
self._open_files_only: bool = True
|
|
77
|
+
self._open_paths: set = set()
|
|
78
|
+
self._build()
|
|
79
|
+
|
|
80
|
+
def _build(self) -> None:
|
|
81
|
+
t = self._tmgr.theme
|
|
82
|
+
|
|
83
|
+
tb = tk.Frame(self, bg=t.panel_bg, height=32)
|
|
84
|
+
tb.pack(fill="x")
|
|
85
|
+
tb.pack_propagate(False)
|
|
86
|
+
|
|
87
|
+
for sev, (icon, _tag, color_attr) in self._SEV_META.items():
|
|
88
|
+
_color = getattr(t, color_attr, t.fg)
|
|
89
|
+
btn = tk.Label(
|
|
90
|
+
tb,
|
|
91
|
+
text=f" {icon} 0 ",
|
|
92
|
+
bg=t.btn_active,
|
|
93
|
+
fg=_color,
|
|
94
|
+
font=(FONT_UI, 9, "bold"),
|
|
95
|
+
cursor="hand2",
|
|
96
|
+
relief="flat",
|
|
97
|
+
bd=0,
|
|
98
|
+
padx=4,
|
|
99
|
+
pady=2,
|
|
100
|
+
)
|
|
101
|
+
btn.pack(side="left", padx=1, pady=4)
|
|
102
|
+
btn.bind("<Button-1>", lambda _, s=sev: self._toggle_sev(s))
|
|
103
|
+
self._sev_btns[sev] = btn
|
|
104
|
+
|
|
105
|
+
tk.Frame(tb, bg=t.border, width=1).pack(
|
|
106
|
+
side="left", fill="y", padx=6, pady=4)
|
|
107
|
+
|
|
108
|
+
self._filter_var = tk.StringVar()
|
|
109
|
+
self._filter_var.trace_add("write", lambda *_: self._render())
|
|
110
|
+
fe = tk.Entry(
|
|
111
|
+
tb,
|
|
112
|
+
textvariable=self._filter_var,
|
|
113
|
+
bg=t.input_bg,
|
|
114
|
+
fg=t.fg,
|
|
115
|
+
insertbackground=t.cursor,
|
|
116
|
+
relief="flat",
|
|
117
|
+
bd=0,
|
|
118
|
+
width=20,
|
|
119
|
+
font=(FONT_UI, 9),
|
|
120
|
+
highlightthickness=1,
|
|
121
|
+
highlightbackground=t.border,
|
|
122
|
+
highlightcolor=t.accent,
|
|
123
|
+
)
|
|
124
|
+
fe.pack(side="left", padx=2, pady=4)
|
|
125
|
+
|
|
126
|
+
clr = tk.Label(
|
|
127
|
+
tb,
|
|
128
|
+
text="✕",
|
|
129
|
+
bg=t.panel_bg,
|
|
130
|
+
fg=t.fg_muted,
|
|
131
|
+
font=(FONT_UI, 9),
|
|
132
|
+
cursor="hand2",
|
|
133
|
+
padx=4,
|
|
134
|
+
)
|
|
135
|
+
clr.pack(side="left")
|
|
136
|
+
clr.bind("<Button-1>", lambda _: self._filter_var.set(""))
|
|
137
|
+
|
|
138
|
+
self._group_var = tk.BooleanVar(value=True)
|
|
139
|
+
group_cb = tk.Checkbutton(
|
|
140
|
+
tb,
|
|
141
|
+
text=_t("problems.group"),
|
|
142
|
+
variable=self._group_var,
|
|
143
|
+
command=self._render,
|
|
144
|
+
bg=t.panel_bg,
|
|
145
|
+
fg=t.fg_muted,
|
|
146
|
+
activebackground=t.panel_bg,
|
|
147
|
+
selectcolor=t.sel_bg,
|
|
148
|
+
font=(FONT_UI, 8),
|
|
149
|
+
)
|
|
150
|
+
group_cb.pack(side="right", padx=8)
|
|
151
|
+
|
|
152
|
+
self._open_only_var = tk.BooleanVar(value=True)
|
|
153
|
+
open_cb = tk.Checkbutton(
|
|
154
|
+
tb,
|
|
155
|
+
text=_t("problems.open_only"),
|
|
156
|
+
variable=self._open_only_var,
|
|
157
|
+
command=self._on_open_only_toggle,
|
|
158
|
+
bg=t.panel_bg,
|
|
159
|
+
fg=t.fg_muted,
|
|
160
|
+
activebackground=t.panel_bg,
|
|
161
|
+
selectcolor=t.sel_bg,
|
|
162
|
+
font=(FONT_UI, 8),
|
|
163
|
+
)
|
|
164
|
+
open_cb.pack(side="right", padx=2)
|
|
165
|
+
|
|
166
|
+
tk.Frame(self, bg=t.border, height=1).pack(fill="x")
|
|
167
|
+
|
|
168
|
+
style = ttk.Style()
|
|
169
|
+
style.configure(
|
|
170
|
+
"Problems.Treeview",
|
|
171
|
+
background=t.panel_bg,
|
|
172
|
+
foreground=t.fg,
|
|
173
|
+
fieldbackground=t.panel_bg,
|
|
174
|
+
borderwidth=0,
|
|
175
|
+
rowheight=20,
|
|
176
|
+
font=(FONT_UI, 9),
|
|
177
|
+
)
|
|
178
|
+
style.map(
|
|
179
|
+
"Problems.Treeview",
|
|
180
|
+
background=[("selected", t.sel_bg)],
|
|
181
|
+
foreground=[("selected", t.sel_fg)],
|
|
182
|
+
)
|
|
183
|
+
style.configure(
|
|
184
|
+
"Problems.Treeview.Heading",
|
|
185
|
+
background=t.panel_bg,
|
|
186
|
+
foreground=t.fg_muted,
|
|
187
|
+
relief="flat",
|
|
188
|
+
font=(FONT_UI, 9, "bold"),
|
|
189
|
+
borderwidth=0,
|
|
190
|
+
padding=(4, 4),
|
|
191
|
+
)
|
|
192
|
+
style.map(
|
|
193
|
+
"Problems.Treeview.Heading",
|
|
194
|
+
background=[("active", t.btn_hover)],
|
|
195
|
+
foreground=[("active", t.fg)],
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
list_frame = tk.Frame(self, bg=t.panel_bg)
|
|
199
|
+
list_frame.pack(fill="both", expand=True)
|
|
200
|
+
|
|
201
|
+
self._tree = ttk.Treeview(
|
|
202
|
+
list_frame,
|
|
203
|
+
columns=("message", "rule", "source"),
|
|
204
|
+
show="tree headings",
|
|
205
|
+
selectmode="browse",
|
|
206
|
+
style="Problems.Treeview",
|
|
207
|
+
)
|
|
208
|
+
self._tree.heading("#0", text=_t(
|
|
209
|
+
"problems.location"), command=lambda: None)
|
|
210
|
+
self._tree.heading("message", text=_t("problems.message"))
|
|
211
|
+
self._tree.heading("rule", text=_t("problems.rule"))
|
|
212
|
+
self._tree.heading("source", text=_t("problems.source"))
|
|
213
|
+
self._tree.column("#0", width=130, minwidth=80, stretch=False)
|
|
214
|
+
self._tree.column("message", width=320, minwidth=150)
|
|
215
|
+
self._tree.column("rule", width=100, minwidth=60)
|
|
216
|
+
self._tree.column("source", width=70, minwidth=40, stretch=False)
|
|
217
|
+
|
|
218
|
+
vsb = ttk.Scrollbar(
|
|
219
|
+
list_frame,
|
|
220
|
+
orient="vertical",
|
|
221
|
+
command=self._tree.yview,
|
|
222
|
+
style="Thin.Vertical.TScrollbar",
|
|
223
|
+
)
|
|
224
|
+
vsb.pack(side="right", fill="y")
|
|
225
|
+
self._tree.config(yscrollcommand=vsb.set)
|
|
226
|
+
self._tree.pack(fill="both", expand=True)
|
|
227
|
+
|
|
228
|
+
self._configure_tags(t)
|
|
229
|
+
|
|
230
|
+
self._tree.bind("<Double-Button-1>", self._on_double)
|
|
231
|
+
self._tree.bind("<Return>", self._on_double)
|
|
232
|
+
self._tree.bind("<Button-3>", self._on_ctx)
|
|
233
|
+
self._tree.bind("<Motion>", self._on_motion)
|
|
234
|
+
self._tree.bind("<Leave>", lambda _: self._hide_tooltip())
|
|
235
|
+
|
|
236
|
+
self._diag_map: dict[str, Diag] = {}
|
|
237
|
+
|
|
238
|
+
def _configure_tags(self, t: Theme) -> None:
|
|
239
|
+
self._tree.tag_configure("error", foreground=t.err_fg)
|
|
240
|
+
self._tree.tag_configure("warning", foreground=t.warn_fg)
|
|
241
|
+
self._tree.tag_configure("info", foreground=t.info_fg)
|
|
242
|
+
self._tree.tag_configure("hint", foreground=t.hint_fg)
|
|
243
|
+
self._tree.tag_configure(
|
|
244
|
+
"file", foreground=t.fg, font=(FONT_UI, 9, "bold"))
|
|
245
|
+
self._tree.tag_configure("fix", foreground=t.diff_add_fg)
|
|
246
|
+
|
|
247
|
+
def set_diags(self, diags: list[Diag], file: str = "") -> None:
|
|
248
|
+
"""Atualiza diagnósticos de um arquivo específico."""
|
|
249
|
+
if file:
|
|
250
|
+
self._diags_by_file[file] = diags
|
|
251
|
+
self._file = file
|
|
252
|
+
|
|
253
|
+
self._diags = [d for ds in self._diags_by_file.values() for d in ds]
|
|
254
|
+
self._render()
|
|
255
|
+
|
|
256
|
+
def clear_file_diags(self, file: str) -> None:
|
|
257
|
+
"""Remove diagnósticos de um arquivo (chamado ao fechar a aba)."""
|
|
258
|
+
if file and file in self._diags_by_file:
|
|
259
|
+
del self._diags_by_file[file]
|
|
260
|
+
self._diags = [d for ds in self._diags_by_file.values()
|
|
261
|
+
for d in ds]
|
|
262
|
+
self._render()
|
|
263
|
+
|
|
264
|
+
def set_open_files(self, open_paths: list[str]) -> None:
|
|
265
|
+
"""Recebe a lista de arquivos abertos para filtrar exibição."""
|
|
266
|
+
self._open_paths: set = set(open_paths)
|
|
267
|
+
self._render()
|
|
268
|
+
|
|
269
|
+
def _on_open_only_toggle(self) -> None:
|
|
270
|
+
self._open_files_only = self._open_only_var.get()
|
|
271
|
+
self._render()
|
|
272
|
+
|
|
273
|
+
def _render(self) -> None:
|
|
274
|
+
"""Renderiza o conteúdo no canvas ou widget."""
|
|
275
|
+
for item in self._tree.get_children():
|
|
276
|
+
self._tree.delete(item)
|
|
277
|
+
self._diag_map.clear()
|
|
278
|
+
|
|
279
|
+
q = self._filter_var.get().lower()
|
|
280
|
+
|
|
281
|
+
open_paths = getattr(self, "_open_paths", set())
|
|
282
|
+
if self._open_files_only and open_paths:
|
|
283
|
+
source_diags = [
|
|
284
|
+
d
|
|
285
|
+
for d in self._diags
|
|
286
|
+
if (getattr(d, "file", self._file) or self._file) in open_paths
|
|
287
|
+
]
|
|
288
|
+
else:
|
|
289
|
+
source_diags = self._diags
|
|
290
|
+
|
|
291
|
+
visible = [
|
|
292
|
+
d
|
|
293
|
+
for d in source_diags
|
|
294
|
+
if d.severity in self._filter
|
|
295
|
+
and (not q or q in d.message.lower() or q in d.rule.lower())
|
|
296
|
+
]
|
|
297
|
+
|
|
298
|
+
t = self._tmgr.theme
|
|
299
|
+
counts = {1: 0, 2: 0, 3: 0, 4: 0}
|
|
300
|
+
for d in self._diags:
|
|
301
|
+
counts[d.severity] = counts.get(d.severity, 0) + 1
|
|
302
|
+
for sev, btn in self._sev_btns.items():
|
|
303
|
+
icon, _, color_attr = self._SEV_META[sev]
|
|
304
|
+
color = getattr(t, color_attr, t.fg)
|
|
305
|
+
active = sev in self._filter
|
|
306
|
+
btn.config(
|
|
307
|
+
text=f" {icon} {counts[sev]} ",
|
|
308
|
+
bg=t.btn_active if active else t.panel_bg,
|
|
309
|
+
fg=color,
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
if self._group_var.get():
|
|
313
|
+
self._render_grouped(visible)
|
|
314
|
+
else:
|
|
315
|
+
self._render_flat(visible)
|
|
316
|
+
|
|
317
|
+
def _render_grouped(self, visible: list[Diag]) -> None:
|
|
318
|
+
groups: dict[str, list[Diag]] = {}
|
|
319
|
+
for d in visible:
|
|
320
|
+
src = getattr(d, "file", self._file) or self._file or "Unknown"
|
|
321
|
+
groups.setdefault(src, []).append(d)
|
|
322
|
+
|
|
323
|
+
for fname, diags in sorted(groups.items()):
|
|
324
|
+
diags_sorted = sorted(diags, key=lambda x: (x.severity, x.line))
|
|
325
|
+
err_c = sum(1 for d in diags if d.severity == 1)
|
|
326
|
+
wrn_c = sum(1 for d in diags if d.severity == 2)
|
|
327
|
+
badge = f" ✖{err_c}" if err_c else ""
|
|
328
|
+
if wrn_c:
|
|
329
|
+
badge += f" ⚠{wrn_c}"
|
|
330
|
+
short = Path(fname).name if fname else fname
|
|
331
|
+
node = self._tree.insert(
|
|
332
|
+
"", "end", text=f" 📄 {short}{badge}", tags=("file",), open=True
|
|
333
|
+
)
|
|
334
|
+
for d in diags_sorted:
|
|
335
|
+
self._insert_diag(node, d)
|
|
336
|
+
|
|
337
|
+
def _render_flat(self, visible: list[Diag]) -> None:
|
|
338
|
+
for d in sorted(visible, key=lambda x: (x.severity, x.line)):
|
|
339
|
+
self._insert_diag("", d)
|
|
340
|
+
|
|
341
|
+
def _insert_diag(self, parent: str, d: Diag) -> None:
|
|
342
|
+
_, tag, _ = self._SEV_META.get(d.severity, ("-", "info", "info_fg"))
|
|
343
|
+
icon = self._SEV_META[d.severity][0]
|
|
344
|
+
loc = f" {icon} {d.line}:{d.col + 1}"
|
|
345
|
+
fix_sfx = " [fix]" if d.fix else ""
|
|
346
|
+
iid = self._tree.insert(
|
|
347
|
+
parent,
|
|
348
|
+
"end",
|
|
349
|
+
text=loc,
|
|
350
|
+
values=(d.message + fix_sfx, d.rule, d.source),
|
|
351
|
+
tags=(tag, "fix") if d.fix else (tag,),
|
|
352
|
+
)
|
|
353
|
+
self._diag_map[iid] = d
|
|
354
|
+
|
|
355
|
+
def _toggle_sev(self, sev: int) -> None:
|
|
356
|
+
if sev in self._filter:
|
|
357
|
+
self._filter.discard(sev)
|
|
358
|
+
else:
|
|
359
|
+
self._filter.add(sev)
|
|
360
|
+
self._render()
|
|
361
|
+
|
|
362
|
+
def _on_double(self, _e: Any = None) -> None:
|
|
363
|
+
sel = self._tree.selection()
|
|
364
|
+
if not sel:
|
|
365
|
+
return
|
|
366
|
+
iid = sel[0]
|
|
367
|
+
d = self._diag_map.get(iid)
|
|
368
|
+
if d is None:
|
|
369
|
+
return
|
|
370
|
+
|
|
371
|
+
self._on_goto(d.line, d.col)
|
|
372
|
+
|
|
373
|
+
def _on_ctx(self, e: tk.Event) -> None:
|
|
374
|
+
item = self._tree.identify_row(e.y)
|
|
375
|
+
if not item:
|
|
376
|
+
return
|
|
377
|
+
self._tree.selection_set(item)
|
|
378
|
+
d = self._diag_map.get(item)
|
|
379
|
+
if not d:
|
|
380
|
+
return
|
|
381
|
+
t = self._tmgr.theme
|
|
382
|
+
menu = tk.Menu(
|
|
383
|
+
self,
|
|
384
|
+
tearoff=False,
|
|
385
|
+
bg=t.floating_bg,
|
|
386
|
+
fg=t.fg,
|
|
387
|
+
activebackground=t.sel_bg,
|
|
388
|
+
activeforeground=t.sel_fg,
|
|
389
|
+
relief="flat",
|
|
390
|
+
)
|
|
391
|
+
menu.add_command(
|
|
392
|
+
label=_t("problems.goto"), command=lambda: self._on_goto(d.line, d.col)
|
|
393
|
+
)
|
|
394
|
+
menu.add_command(
|
|
395
|
+
label=_t("problems.copy_msg"), command=lambda: self._copy_text(d.message)
|
|
396
|
+
)
|
|
397
|
+
menu.add_command(
|
|
398
|
+
label=_t("problems.copy_rule"), command=lambda: self._copy_text(d.rule)
|
|
399
|
+
)
|
|
400
|
+
if d.fix:
|
|
401
|
+
menu.add_separator()
|
|
402
|
+
menu.add_command(
|
|
403
|
+
label=_t("problems.apply_fix"), command=lambda: self._run_fix(d)
|
|
404
|
+
)
|
|
405
|
+
same_rule = [
|
|
406
|
+
x for x in self._diag_map.values() if x.fix and x.rule == d.rule
|
|
407
|
+
]
|
|
408
|
+
if len(same_rule) > 1:
|
|
409
|
+
label_rule = _t(
|
|
410
|
+
"problems.fix_all_rule",
|
|
411
|
+
default=f"Corrigir todas as falhas: {d.rule} ({len(same_rule)})",
|
|
412
|
+
rule=d.rule,
|
|
413
|
+
count=len(same_rule),
|
|
414
|
+
)
|
|
415
|
+
menu.add_command(
|
|
416
|
+
label=label_rule,
|
|
417
|
+
command=lambda diags=same_rule: self._run_fix_list(diags),
|
|
418
|
+
)
|
|
419
|
+
file_key = getattr(d, "file", self._file) or self._file
|
|
420
|
+
all_fixable = [
|
|
421
|
+
x for x in (self._diags_by_file.get(file_key) or self._diags) if x.fix
|
|
422
|
+
]
|
|
423
|
+
if all_fixable:
|
|
424
|
+
label_all = _t(
|
|
425
|
+
"problems.fix_all_file",
|
|
426
|
+
default=f"Corrigir todas as falhas do arquivo ({len(all_fixable)})",
|
|
427
|
+
count=len(all_fixable),
|
|
428
|
+
)
|
|
429
|
+
menu.add_command(
|
|
430
|
+
label=label_all,
|
|
431
|
+
command=lambda diags=all_fixable, f=file_key: self._run_fix_all_file(
|
|
432
|
+
f, diags
|
|
433
|
+
),
|
|
434
|
+
)
|
|
435
|
+
try:
|
|
436
|
+
menu.tk_popup(e.x_root, e.y_root)
|
|
437
|
+
finally:
|
|
438
|
+
menu.grab_release()
|
|
439
|
+
|
|
440
|
+
def _run_fix(self, d: Diag) -> None:
|
|
441
|
+
"""Aplica o fix de um diagnóstico via callback externo.
|
|
442
|
+
|
|
443
|
+
Args:
|
|
444
|
+
d: Diagnóstico com fix disponível.
|
|
445
|
+
"""
|
|
446
|
+
if not d.fix:
|
|
447
|
+
return
|
|
448
|
+
file_key = getattr(d, "file", self._file) or self._file
|
|
449
|
+
if self._on_apply_fix:
|
|
450
|
+
with contextlib.suppress(Exception):
|
|
451
|
+
self._on_apply_fix(file_key, d)
|
|
452
|
+
|
|
453
|
+
def _run_fix_list(self, diags: list[Diag]) -> None:
|
|
454
|
+
"""Aplica fixes de uma lista de diagnósticos em ordem reversa (preserva posições).
|
|
455
|
+
|
|
456
|
+
Args:
|
|
457
|
+
diags: Lista de diagnósticos a corrigir.
|
|
458
|
+
"""
|
|
459
|
+
if not diags or not self._on_apply_fix:
|
|
460
|
+
return
|
|
461
|
+
by_file: dict[str, list[Diag]] = {}
|
|
462
|
+
for d in diags:
|
|
463
|
+
if not d.fix:
|
|
464
|
+
continue
|
|
465
|
+
fk = getattr(d, "file", self._file) or self._file
|
|
466
|
+
by_file.setdefault(fk, []).append(d)
|
|
467
|
+
for fk, fdiags in by_file.items():
|
|
468
|
+
self._run_fix_all_file(fk, fdiags)
|
|
469
|
+
|
|
470
|
+
def _run_fix_all_file(self, file_key: str, diags: list[Diag]) -> None:
|
|
471
|
+
"""Aplica todos os fixes do arquivo via callback externo.
|
|
472
|
+
|
|
473
|
+
Args:
|
|
474
|
+
file_key: Caminho do arquivo.
|
|
475
|
+
diags: Lista de diagnósticos com fix.
|
|
476
|
+
"""
|
|
477
|
+
fixable = [d for d in diags if d.fix]
|
|
478
|
+
if not fixable or not self._on_fix_all:
|
|
479
|
+
return
|
|
480
|
+
with contextlib.suppress(Exception):
|
|
481
|
+
self._on_fix_all(file_key, fixable)
|
|
482
|
+
|
|
483
|
+
def _copy_text(self, text: str) -> None:
|
|
484
|
+
"""Copia o texto para área de transferência.
|
|
485
|
+
|
|
486
|
+
Args:
|
|
487
|
+
text: Dado textual a processar.
|
|
488
|
+
"""
|
|
489
|
+
with contextlib.suppress(tk.TclError):
|
|
490
|
+
self.clipboard_clear()
|
|
491
|
+
self.clipboard_append(text)
|
|
492
|
+
|
|
493
|
+
def _on_motion(self, e: tk.Event) -> None:
|
|
494
|
+
item = self._tree.identify_row(e.y)
|
|
495
|
+
d = self._diag_map.get(item)
|
|
496
|
+
if d:
|
|
497
|
+
self._show_tooltip(e, d.message)
|
|
498
|
+
else:
|
|
499
|
+
self._hide_tooltip()
|
|
500
|
+
|
|
501
|
+
def _show_tooltip(self, e: tk.Event, text: str) -> None:
|
|
502
|
+
self._hide_tooltip()
|
|
503
|
+
t = self._tmgr.theme
|
|
504
|
+
tw = tk.Toplevel(self)
|
|
505
|
+
tw.wm_overrideredirect(True)
|
|
506
|
+
tw.wm_attributes("-topmost", True)
|
|
507
|
+
f = tk.Frame(
|
|
508
|
+
tw,
|
|
509
|
+
bg=t.floating_bg,
|
|
510
|
+
highlightthickness=1,
|
|
511
|
+
highlightbackground=t.floating_border,
|
|
512
|
+
)
|
|
513
|
+
f.pack()
|
|
514
|
+
tk.Label(
|
|
515
|
+
f,
|
|
516
|
+
text=text,
|
|
517
|
+
bg=t.floating_bg,
|
|
518
|
+
fg=t.fg,
|
|
519
|
+
font=(FONT_UI, 9),
|
|
520
|
+
padx=8,
|
|
521
|
+
pady=4,
|
|
522
|
+
wraplength=360,
|
|
523
|
+
justify="left",
|
|
524
|
+
).pack()
|
|
525
|
+
tw.geometry(f"+{e.x_root + 12}+{e.y_root + 12}")
|
|
526
|
+
self._tooltip_win = tw
|
|
527
|
+
|
|
528
|
+
def _hide_tooltip(self) -> None:
|
|
529
|
+
"""Oculta o tooltip de detalhe do diagnóstico."""
|
|
530
|
+
if self._tooltip_win and self._tooltip_win.winfo_exists():
|
|
531
|
+
with contextlib.suppress(tk.TclError):
|
|
532
|
+
self._tooltip_win.destroy()
|
|
533
|
+
self._tooltip_win = None
|
|
534
|
+
|
|
535
|
+
def apply_theme(self, t: Theme) -> None:
|
|
536
|
+
"""Aplica o tema ao painel de problemas."""
|
|
537
|
+
self.config(bg=t.panel_bg)
|
|
538
|
+
style = ttk.Style()
|
|
539
|
+
style.configure(
|
|
540
|
+
"Problems.Treeview",
|
|
541
|
+
background=t.panel_bg,
|
|
542
|
+
foreground=t.fg,
|
|
543
|
+
fieldbackground=t.panel_bg,
|
|
544
|
+
font=(FONT_UI, 9),
|
|
545
|
+
)
|
|
546
|
+
style.map(
|
|
547
|
+
"Problems.Treeview",
|
|
548
|
+
background=[("selected", t.sel_bg)],
|
|
549
|
+
foreground=[("selected", t.sel_fg)],
|
|
550
|
+
)
|
|
551
|
+
style.configure(
|
|
552
|
+
"Problems.Treeview.Heading",
|
|
553
|
+
background=t.panel_bg,
|
|
554
|
+
foreground=t.fg_muted,
|
|
555
|
+
relief="flat",
|
|
556
|
+
font=(FONT_UI, 9, "bold"),
|
|
557
|
+
borderwidth=0,
|
|
558
|
+
padding=(4, 4),
|
|
559
|
+
)
|
|
560
|
+
style.map(
|
|
561
|
+
"Problems.Treeview.Heading",
|
|
562
|
+
background=[("active", t.btn_hover)],
|
|
563
|
+
foreground=[("active", t.fg)],
|
|
564
|
+
)
|
|
565
|
+
self._configure_tags(t)
|
|
566
|
+
self._render()
|