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.
Files changed (329) hide show
  1. codis-1.1.1.dist-info/METADATA +194 -0
  2. codis-1.1.1.dist-info/RECORD +329 -0
  3. codis-1.1.1.dist-info/WHEEL +5 -0
  4. codis-1.1.1.dist-info/entry_points.txt +5 -0
  5. codis-1.1.1.dist-info/licenses/LICENSE +21 -0
  6. codis-1.1.1.dist-info/top_level.txt +2 -0
  7. run.py +190 -0
  8. src/__init__.py +1 -0
  9. src/__main__.py +81 -0
  10. src/_app_build.py +1507 -0
  11. src/_app_editor.py +1274 -0
  12. src/_app_kui.py +825 -0
  13. src/_app_lsp.py +625 -0
  14. src/_app_recovery.py +189 -0
  15. src/_app_settings.py +1385 -0
  16. src/_app_tools.py +2471 -0
  17. src/_app_webpreview.py +126 -0
  18. src/_font_safety.py +127 -0
  19. src/_shells.py +172 -0
  20. src/app.py +1488 -0
  21. src/chat/__init__.py +1 -0
  22. src/chat/adapters/__init__.py +33 -0
  23. src/chat/adapters/base.py +209 -0
  24. src/chat/adapters/discord.py +190 -0
  25. src/chat/adapters/http.py +78 -0
  26. src/chat/adapters/irc.py +360 -0
  27. src/chat/adapters/matrix.py +219 -0
  28. src/chat/adapters/mattermost.py +178 -0
  29. src/chat/adapters/mqtt.py +165 -0
  30. src/chat/adapters/slack.py +204 -0
  31. src/chat/adapters/telegram.py +117 -0
  32. src/chat/adapters/ws.py +154 -0
  33. src/chat/adapters/xmpp.py +337 -0
  34. src/chat/history.py +76 -0
  35. src/chat/models.py +207 -0
  36. src/chat/probe.py +79 -0
  37. src/chat/session.py +446 -0
  38. src/chat/util.py +125 -0
  39. src/collab/__init__.py +1 -0
  40. src/collab/net.py +411 -0
  41. src/collab/ot.py +311 -0
  42. src/collab/session.py +141 -0
  43. src/collab/tk_adapter.py +134 -0
  44. src/config.py +335 -0
  45. src/constants.py +2552 -0
  46. src/dep_catalog.py +446 -0
  47. src/diff/__init__.py +1 -0
  48. src/diff/engine.py +247 -0
  49. src/dpi.py +30 -0
  50. src/editor/__init__.py +1 -0
  51. src/editor/_pane_lsp.py +2937 -0
  52. src/editor/_pane_utils.py +171 -0
  53. src/editor/autocomplete.py +607 -0
  54. src/editor/code_folding.py +836 -0
  55. src/editor/color_preview.py +382 -0
  56. src/editor/complexity_lens.py +281 -0
  57. src/editor/diff_pane.py +623 -0
  58. src/editor/file_watcher.py +144 -0
  59. src/editor/focus_block.py +236 -0
  60. src/editor/heatmap.py +141 -0
  61. src/editor/inlay_hints.py +366 -0
  62. src/editor/inline_blame.py +429 -0
  63. src/editor/kdocs.py +3376 -0
  64. src/editor/large_file.py +488 -0
  65. src/editor/ligatures.py +180 -0
  66. src/editor/line_numbers.py +598 -0
  67. src/editor/minimap.py +691 -0
  68. src/editor/multi_cursor.py +269 -0
  69. src/editor/pane.py +2082 -0
  70. src/editor/rhythm.py +206 -0
  71. src/editor/save_hooks.py +43 -0
  72. src/editor/smart_selection.py +425 -0
  73. src/editor/smart_tips.py +719 -0
  74. src/editor/snippets.py +411 -0
  75. src/editor/sticky_note_gutter.py +410 -0
  76. src/editor/sticky_scroll.py +385 -0
  77. src/editor/suggest.py +464 -0
  78. src/editor/text_transforms.py +310 -0
  79. src/editor/vim_mode.py +1074 -0
  80. src/events/__init__.py +84 -0
  81. src/events/bus.py +427 -0
  82. src/events/correlator.py +244 -0
  83. src/events/kinds.py +125 -0
  84. src/events/pipeline.py +264 -0
  85. src/events/stream.py +416 -0
  86. src/events/window.py +204 -0
  87. src/extcompat/__init__.py +19 -0
  88. src/extcompat/code/__init__.py +13 -0
  89. src/extcompat/code/consent.py +162 -0
  90. src/extcompat/code/host.py +353 -0
  91. src/extcompat/code/hosts/py_host.py +763 -0
  92. src/extcompat/code/locate.py +105 -0
  93. src/extcompat/code/manager.py +325 -0
  94. src/extcompat/code/permissions.py +154 -0
  95. src/extcompat/code/sandbox.py +60 -0
  96. src/extcompat/colors.py +131 -0
  97. src/extcompat/common.py +184 -0
  98. src/extcompat/cson.py +269 -0
  99. src/extcompat/formats/__init__.py +22 -0
  100. src/extcompat/formats/_tm.py +189 -0
  101. src/extcompat/formats/_util.py +31 -0
  102. src/extcompat/formats/base16.py +66 -0
  103. src/extcompat/formats/brackets.py +172 -0
  104. src/extcompat/formats/eclipse.py +193 -0
  105. src/extcompat/formats/emacs.py +361 -0
  106. src/extcompat/formats/geany.py +147 -0
  107. src/extcompat/formats/generic.py +184 -0
  108. src/extcompat/formats/gtksource.py +117 -0
  109. src/extcompat/formats/helix.py +91 -0
  110. src/extcompat/formats/jetbrains.py +343 -0
  111. src/extcompat/formats/kate.py +130 -0
  112. src/extcompat/formats/micro.py +131 -0
  113. src/extcompat/formats/nano.py +111 -0
  114. src/extcompat/formats/notepadpp.py +140 -0
  115. src/extcompat/formats/pulsar.py +165 -0
  116. src/extcompat/formats/pyides.py +163 -0
  117. src/extcompat/formats/sublime.py +340 -0
  118. src/extcompat/jsonc.py +65 -0
  119. src/extcompat/lessish.py +128 -0
  120. src/extcompat/manager.py +122 -0
  121. src/extcompat/market/__init__.py +63 -0
  122. src/extcompat/market/sources.py +211 -0
  123. src/extcompat/model.py +88 -0
  124. src/extcompat/net.py +228 -0
  125. src/extcompat/openvsx.py +63 -0
  126. src/extcompat/readers.py +362 -0
  127. src/extcompat/registry.py +73 -0
  128. src/extcompat/safexml.py +63 -0
  129. src/extcompat/sexp.py +187 -0
  130. src/extcompat/sources.py +105 -0
  131. src/extcompat/store.py +276 -0
  132. src/extcompat/textmate.py +214 -0
  133. src/extcompat/themes.py +487 -0
  134. src/extcompat/yamlite.py +294 -0
  135. src/fileio.py +94 -0
  136. src/fs_ops.py +106 -0
  137. src/i18n.py +233 -0
  138. src/ia/__init__.py +1 -0
  139. src/ia/actions.py +295 -0
  140. src/ia/approval_gate.py +672 -0
  141. src/ia/checkpoints.py +308 -0
  142. src/ia/context_builder.py +921 -0
  143. src/ia/dialdiff.py +408 -0
  144. src/ia/iaspace.py +2078 -0
  145. src/ia/pair.py +296 -0
  146. src/ia/providers.py +954 -0
  147. src/ia/session.py +335 -0
  148. src/ia/toolbox.py +2524 -0
  149. src/launcher_actions.py +204 -0
  150. src/lint/__init__.py +1 -0
  151. src/lint/manager.py +1058 -0
  152. src/locales/.translate_manifest.json +64170 -0
  153. src/locales/de.json +4936 -0
  154. src/locales/en.json +4936 -0
  155. src/locales/es.json +4936 -0
  156. src/locales/fr.json +4936 -0
  157. src/locales/it.json +4936 -0
  158. src/locales/ja.json +4936 -0
  159. src/locales/ko.json +4936 -0
  160. src/locales/nl.json +4936 -0
  161. src/locales/pl.json +4936 -0
  162. src/locales/pt-BR.json +4936 -0
  163. src/locales/ru.json +4936 -0
  164. src/locales/tr.json +4936 -0
  165. src/locales/uk.json +4936 -0
  166. src/locales/zh-CN.json +4936 -0
  167. src/lsp/__init__.py +26 -0
  168. src/lsp/client.py +2300 -0
  169. src/lsp/dap_client.py +480 -0
  170. src/lsp/edits.py +84 -0
  171. src/lsp/framing.py +73 -0
  172. src/lsp/protocol.py +931 -0
  173. src/main.py +260 -0
  174. src/memtrim.py +91 -0
  175. src/plugins/__init__.py +1 -0
  176. src/plugins/api.py +1761 -0
  177. src/plugins/loader.py +571 -0
  178. src/plugins/process_runner.py +519 -0
  179. src/plugins/registry.py +342 -0
  180. src/plugins/safety.py +367 -0
  181. src/plugins/startup.py +195 -0
  182. src/plugins/store.py +1178 -0
  183. src/proc_registry.py +278 -0
  184. src/pyexec.py +394 -0
  185. src/recovery.py +259 -0
  186. src/stall_trace.py +92 -0
  187. src/standalone.py +1070 -0
  188. src/startup_profile.py +35 -0
  189. src/syntax/__init__.py +1 -0
  190. src/syntax/highlighter.py +776 -0
  191. src/syntax/patterns.py +584 -0
  192. src/system_profile.py +430 -0
  193. src/terminal/backends.py +658 -0
  194. src/terminal/internal.py +346 -0
  195. src/terminal/keys.py +138 -0
  196. src/terminal/palette.py +67 -0
  197. src/terminal/session.py +283 -0
  198. src/terminal/shells.py +79 -0
  199. src/terminal/view.py +489 -0
  200. src/terminal/vt.py +870 -0
  201. src/textfmt.py +22 -0
  202. src/theme/__init__.py +1 -0
  203. src/theme/base.py +1281 -0
  204. src/theme/colors.py +49 -0
  205. src/theme/manager.py +602 -0
  206. src/theme/utils.py +312 -0
  207. src/toolbox.py +329 -0
  208. src/trash_core.py +531 -0
  209. src/ui/__init__.py +1 -0
  210. src/ui/_perf_utils.py +285 -0
  211. src/ui/_persistence_utils.py +93 -0
  212. src/ui/accessibility.py +843 -0
  213. src/ui/activity_bar.py +860 -0
  214. src/ui/app_embed.py +434 -0
  215. src/ui/archive_panel.py +608 -0
  216. src/ui/bookmarks.py +314 -0
  217. src/ui/breadcrumb.py +383 -0
  218. src/ui/calculator_panel.py +982 -0
  219. src/ui/calendar_panel.py +1218 -0
  220. src/ui/chat_panel.py +1271 -0
  221. src/ui/chat_profile_dialog.py +278 -0
  222. src/ui/chat_render.py +128 -0
  223. src/ui/clock_panel.py +810 -0
  224. src/ui/code_outline.py +364 -0
  225. src/ui/code_runner.py +729 -0
  226. src/ui/code_stats.py +546 -0
  227. src/ui/collab_panel.py +1009 -0
  228. src/ui/color_picker.py +547 -0
  229. src/ui/command_palette.py +452 -0
  230. src/ui/cursor_manager.py +750 -0
  231. src/ui/custom_keywords_panel.py +413 -0
  232. src/ui/debug_panel.py +1037 -0
  233. src/ui/dependency_graph.py +692 -0
  234. src/ui/diff_panel.py +381 -0
  235. src/ui/docs_panel.py +514 -0
  236. src/ui/doom_embed.py +349 -0
  237. src/ui/dropdown.py +321 -0
  238. src/ui/easter_eggs.py +979 -0
  239. src/ui/env_manager.py +666 -0
  240. src/ui/extcode_bridge.py +215 -0
  241. src/ui/extcode_dialogs.py +412 -0
  242. src/ui/extcompat_dialog.py +583 -0
  243. src/ui/file_timeline.py +319 -0
  244. src/ui/file_tree.py +1208 -0
  245. src/ui/find_in_files.py +1355 -0
  246. src/ui/flowchart_panel.py +727 -0
  247. src/ui/formatter_panel.py +490 -0
  248. src/ui/git_auth.py +763 -0
  249. src/ui/git_clone_dialog.py +487 -0
  250. src/ui/git_panel.py +1483 -0
  251. src/ui/grab_safe.py +84 -0
  252. src/ui/internal_python_dialog.py +98 -0
  253. src/ui/k_ui/__init__.py +1305 -0
  254. src/ui/k_ui/_bgrenderer.py +317 -0
  255. src/ui/k_ui/_colors.py +213 -0
  256. src/ui/k_ui/_dock.py +545 -0
  257. src/ui/k_ui/_easter.py +290 -0
  258. src/ui/k_ui/_engine.py +5448 -0
  259. src/ui/k_ui/_perf.py +333 -0
  260. src/ui/k_ui/_tkutil.py +7 -0
  261. src/ui/k_ui/_tooltip.py +365 -0
  262. src/ui/k_ui/_widgets.py +1204 -0
  263. src/ui/k_ui/_world.py +837 -0
  264. src/ui/key_remapper.py +856 -0
  265. src/ui/launcher.py +1252 -0
  266. src/ui/lazy_panel.py +73 -0
  267. src/ui/macro_recorder.py +610 -0
  268. src/ui/menu_bar.py +898 -0
  269. src/ui/output_panel.py +321 -0
  270. src/ui/paint_canvas.py +1000 -0
  271. src/ui/paint_engine.py +535 -0
  272. src/ui/paint_panel.py +888 -0
  273. src/ui/panel_detach.py +112 -0
  274. src/ui/performance_panel.py +861 -0
  275. src/ui/pip_manager.py +1758 -0
  276. src/ui/plugin_panel.py +1586 -0
  277. src/ui/pomodoro_panel.py +447 -0
  278. src/ui/problems.py +566 -0
  279. src/ui/process_manager.py +1657 -0
  280. src/ui/project_templates.py +775 -0
  281. src/ui/recovery_dialog.py +122 -0
  282. src/ui/regex_playground.py +304 -0
  283. src/ui/remote_adapters.py +1398 -0
  284. src/ui/remote_browser.py +1224 -0
  285. src/ui/remote_profile_dialog.py +342 -0
  286. src/ui/render_panel.py +1293 -0
  287. src/ui/rest_client.py +549 -0
  288. src/ui/scratchpad.py +548 -0
  289. src/ui/search_bar.py +1274 -0
  290. src/ui/settings_editor.py +3349 -0
  291. src/ui/settings_window.py +1554 -0
  292. src/ui/snippets_panel.py +597 -0
  293. src/ui/sql_studio.py +1815 -0
  294. src/ui/status_bar.py +438 -0
  295. src/ui/tab_bar.py +654 -0
  296. src/ui/task_manager.py +1773 -0
  297. src/ui/terminal.py +525 -0
  298. src/ui/theme_preview_panel.py +851 -0
  299. src/ui/thread_safe_tk.py +152 -0
  300. src/ui/time_tracker.py +574 -0
  301. src/ui/tkbind.py +43 -0
  302. src/ui/todo_panel.py +358 -0
  303. src/ui/toolbox_panels.py +658 -0
  304. src/ui/trash_manager.py +657 -0
  305. src/ui/ui_scale.py +294 -0
  306. src/ui/ux_enhancements.py +41 -0
  307. src/ui/web_preview.py +397 -0
  308. src/ui/webdev.py +630 -0
  309. src/ui/welcome.py +567 -0
  310. src/ui/window_embed.py +1500 -0
  311. src/ui/wizard.py +1550 -0
  312. src/ui/workspace_switcher.py +418 -0
  313. src/ui/workspace_trust.py +370 -0
  314. src/ui/zen_audio.py +354 -0
  315. src/ui/zen_media.py +2271 -0
  316. src/ui/zen_media_client.py +303 -0
  317. src/ui/zen_media_host.py +329 -0
  318. src/ui/zen_player.py +907 -0
  319. src/ui/zen_player_widgets.py +700 -0
  320. src/updater/__init__.py +11 -0
  321. src/updater/assets.py +145 -0
  322. src/updater/backup.py +101 -0
  323. src/updater/channel.py +221 -0
  324. src/updater/dialog.py +492 -0
  325. src/updater/integrity.py +111 -0
  326. src/updater/manager.py +727 -0
  327. src/updater/result.py +114 -0
  328. src/venv_runtime.py +531 -0
  329. src/workspace_state.py +25 -0
src/_app_build.py ADDED
@@ -0,0 +1,1507 @@
1
+ """Mixin ``_AppBuildMixin`` - construção dos painéis principais da UI do Codis.
2
+
3
+ Responsável por instanciar e conectar todos os painéis visuais (editor, terminal,
4
+ git, ferramentas IA, etc.) que compõem a janela principal da aplicação.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import contextlib
10
+ import logging
11
+ import sys
12
+ import tkinter as tk
13
+ import webbrowser
14
+ from pathlib import Path
15
+ from typing import TYPE_CHECKING, Any
16
+
17
+ from src.constants import (
18
+ APP_NAME,
19
+ CONFIG_FILE,
20
+ FONT_UI,
21
+ PLUGINS_DIR,
22
+ REPO_URL,
23
+ WINDOW_MIN,
24
+ WINDOW_SIZE,
25
+ )
26
+ from src.editor.diff_pane import DiffPane
27
+ from src.i18n import _t
28
+ from src.theme.base import THEME_ORDER
29
+ from src.ui.activity_bar import ActivityBar
30
+ from src.ui.bookmarks import BookmarksPanel
31
+ from src.ui.breadcrumb import BreadCrumb
32
+ from src.ui.code_outline import CodeOutline
33
+ from src.ui.code_stats import CodeStatsPanel
34
+ from src.ui.debug_panel import DebugPanel
35
+ from src.ui.docs_panel import DocsPanel
36
+ from src.ui.file_tree import FileTree
37
+ from src.ui.find_in_files import FindInFilesPanel
38
+ from src.ui.flowchart_panel import FlowchartPanel
39
+ from src.ui.git_panel import GitPanel
40
+ from src.ui.k_ui._dock import KDock
41
+ from src.ui.lazy_panel import LazyPanel
42
+ from src.ui.output_panel import OutputPanel
43
+ from src.ui.plugin_panel import PluginPanel
44
+ from src.ui.pomodoro_panel import PomodoroPanel
45
+ from src.ui.problems import ProblemsPanel
46
+ from src.ui.regex_playground import RegexPlayground
47
+ from src.ui.render_panel import RenderPanel
48
+ from src.ui.rest_client import RestClientPanel
49
+ from src.ui.scratchpad import ScratchpadPane
50
+ from src.ui.search_bar import SearchBar
51
+ from src.ui.settings_editor import SettingsEditor
52
+ from src.ui.snippets_panel import SnippetsPanel
53
+ from src.ui.status_bar import StatusBar
54
+ from src.ui.tab_bar import TabBar
55
+ from src.ui.terminal import TerminalPanel
56
+ from src.ui.todo_panel import TodoPanel
57
+
58
+ try:
59
+ from src.ui.sql_studio import SQLStudioPanel
60
+
61
+ _SQL_OK = True
62
+ except Exception:
63
+ SQLStudioPanel = None # type: ignore[assignment,misc]
64
+ _SQL_OK = False
65
+ try:
66
+ from src.ia.iaspace import PainelIA
67
+
68
+ _IA_OK = True
69
+ except Exception:
70
+ PainelIA = None # type: ignore[assignment,misc]
71
+ _IA_OK = False
72
+
73
+ if TYPE_CHECKING:
74
+ pass
75
+
76
+ logger = logging.getLogger("Codis")
77
+
78
+ __all__ = ["_AppBuildMixin"]
79
+
80
+
81
+ class _AppBuildMixin:
82
+ """Mixin de Build do CodisApp."""
83
+
84
+ def _show_settings_panel(self) -> None:
85
+ """Exibe o editor de configurações clássico na barra lateral."""
86
+
87
+ for w in self._sidebar_stack.winfo_children():
88
+ w.pack_forget()
89
+
90
+ self._settings_editor.pack(fill="both", expand=True)
91
+ self._current_sidebar = "settings"
92
+
93
+ if not self._sidebar_visible:
94
+ self._show_sidebar()
95
+
96
+ def _setup_window(self) -> None:
97
+ """Configura a janela principal (título, geometria, cores)."""
98
+ t = self._tmgr.theme
99
+ self._root.title(APP_NAME)
100
+ from src.ui.ui_scale import fit_window
101
+
102
+ w, h = fit_window(self._root, *WINDOW_SIZE)
103
+ self._root.geometry(f"{w}x{h}")
104
+ self._root.minsize(min(WINDOW_MIN[0], w), min(WINDOW_MIN[1], h))
105
+ self._root.config(bg=t.bg)
106
+ self._root.protocol("WM_DELETE_WINDOW", self._on_exit)
107
+ self._root.after(100, self._apply_titlebar_color)
108
+
109
+ def _apply_titlebar_color(self) -> None:
110
+ """Colorir a barra de título nativa do Windows de acordo com o tema ativo."""
111
+ if sys.platform != "win32":
112
+ return
113
+ try:
114
+ import ctypes
115
+
116
+ t = self._tmgr.theme
117
+
118
+ hex_col = getattr(t, "bg", "#1e1e2e").lstrip("#")
119
+ r = int(hex_col[0:2], 16)
120
+ g = int(hex_col[2:4], 16)
121
+ b = int(hex_col[4:6], 16)
122
+ colorref = (b << 16) | (g << 8) | r
123
+ hwnd = ctypes.windll.user32.GetParent(self._root.winfo_id())
124
+ if not hwnd:
125
+ hwnd = self._root.winfo_id()
126
+
127
+ ctypes.windll.dwmapi.DwmSetWindowAttribute(
128
+ hwnd, 35, ctypes.byref(ctypes.c_int(colorref)), 4
129
+ )
130
+ ctypes.windll.dwmapi.DwmSetWindowAttribute(
131
+ hwnd, 20, ctypes.byref(ctypes.c_int(1)), 4
132
+ )
133
+ except Exception as exc:
134
+ logger.debug(
135
+ "Não foi possível aplicar cor na barra de título: %s", exc)
136
+
137
+ def _build_layout(self) -> None:
138
+ """Constrói toda a estrutura de painéis.
139
+
140
+ Inclui activity bar, sidebar, área de editor e painel inferior.
141
+ """
142
+ t = self._tmgr.theme
143
+
144
+ self._status = StatusBar(self._root, self._tmgr, self._cfg)
145
+ self._status.pack(side="bottom", fill="x")
146
+ self._status.bind_callbacks(
147
+ git=self._toggle_git_panel,
148
+ problems=self._show_problems,
149
+ lang=self._pick_language,
150
+ eol=self._pick_eol,
151
+ encoding=self._pick_encoding,
152
+ indent=self._pick_indent,
153
+ zoom=self._reset_zoom,
154
+ )
155
+
156
+ self._h_paned = tk.PanedWindow(
157
+ self._root,
158
+ orient="horizontal",
159
+ bg=t.border,
160
+ sashwidth=6,
161
+ sashrelief="flat",
162
+ sashcursor="sb_h_double_arrow",
163
+ )
164
+ self._h_paned.pack(fill="both", expand=True)
165
+
166
+ self._actbar = ActivityBar(
167
+ self._h_paned, self._tmgr, self._on_activity, cfg=self._cfg
168
+ )
169
+ self._h_paned.add(self._actbar, width=48, minsize=48, stretch="never")
170
+
171
+ self._sidebar = tk.Frame(self._root, bg=t.sidebar_bg)
172
+ sw = max(60, self._cfg.get("sidebar_width", 220))
173
+ self._h_paned.add(self._sidebar, width=sw, minsize=60, stretch="never")
174
+ self._build_sidebar()
175
+ self._dock = KDock(
176
+ self._root,
177
+ self._h_paned,
178
+ self._sidebar,
179
+ self._actbar,
180
+ dark=getattr(t, "dark", True),
181
+ get_width=lambda: self._cfg.get("sidebar_width", 260),
182
+ set_width=lambda w: self._cfg.set("sidebar_width", w),
183
+ get_left=lambda: 0 if getattr(self, "_zen_mode", False) else 48,
184
+ get_top=self._dock_top,
185
+ reduce_motion=lambda: self._cfg.get("a11y_reduce_motion", False),
186
+ get_pinned=lambda: self._cfg.get("kui_dock_pinned", False),
187
+ set_pinned=lambda v: self._cfg.set("kui_dock_pinned", bool(v)),
188
+ on_change=self._on_dock_change,
189
+ on_raise=self._on_dock_raise,
190
+ )
191
+
192
+ self._actbar.add_plugin_item("sql", "🗄", _t("kui.cmd.sql"))
193
+ self._actbar.add_plugin_item("codestats", "📊", _t("kui.cmd.stats"))
194
+ self._actbar.add_plugin_item("todo", "✅", _t("kui.cmd.todo"))
195
+ self._actbar.add_plugin_item("restclient", "🌍", _t("kui.cmd.rest"))
196
+ self._actbar.add_plugin_item("preview", "🌐", _t("kui.cmd.preview"))
197
+ self._actbar.add_plugin_item("pomodoro", "⏱", _t("kui.cmd.pomodoro"))
198
+ self._actbar.add_plugin_item(
199
+ "flowchart", "🔀", _t("kui.cmd.flowchart"))
200
+ self._actbar.add_plugin_item("snippets", "✂️", _t("kui.cmd.snippets"))
201
+ self._actbar.add_plugin_item(
202
+ "time_tracker", "⏱", _t("actbar.time_tracker"))
203
+ self._actbar.add_plugin_item("dep_graph", "🔗", _t("actbar.dep_graph"))
204
+ self._actbar.add_plugin_item("docs", "📚", _t("kui.cmd.outline"))
205
+
206
+ _opt_items = [
207
+ ("remote_ssh", "🖧", "actbar.remote_ssh", "ssh_enabled"),
208
+ ("collab", "👥", "actbar.collab", "collab_enabled"),
209
+ ("accessibility", "♿", "actbar.accessibility", "a11y_screen_reader"),
210
+ ]
211
+ _vis = set(self._actbar._visible)
212
+ for _key, _icon, _label_key, _cfg_key in _opt_items:
213
+ if self._cfg.get(_cfg_key, False):
214
+ _vis.add(_key)
215
+ self._actbar._visible = _vis
216
+
217
+ self._content_frame = tk.Frame(self._h_paned, bg=t.bg)
218
+ self._h_paned.add(self._content_frame, stretch="always")
219
+ self._build_content(self._content_frame)
220
+
221
+ self._actbar._activate("explorer")
222
+
223
+ self._build_panel_toggle_buttons()
224
+
225
+ self._hide_sidebar()
226
+ self._hide_bottom_panel()
227
+
228
+ self._setup_smooth_resize()
229
+
230
+ def _setup_smooth_resize(self) -> None:
231
+ """Instala resize fluido nos PanedWindows e na janela principal.
232
+
233
+ Técnica:
234
+ - opaqueresize=True -> os painéis acompanham o mouse em tempo real
235
+ - Suspend/resume de minimap e syntax highlight durante o drag do
236
+ sash e durante o resize da janela, eliminando o lag visual
237
+ - <Configure> da raiz com debounce: overlays pesados só voltam
238
+ quando o resize para (150 ms sem eventos)
239
+ """
240
+
241
+ for paned in (self._h_paned, self._v_paned):
242
+ with contextlib.suppress(tk.TclError):
243
+ paned.config(opaqueresize=True)
244
+
245
+ self._resize_drag_job: str | None = None
246
+ self._resize_dragging = False
247
+
248
+ def _suspend_all() -> None:
249
+ """Suspende todos os overlays pesados do editor durante operações bloqueantes."""
250
+ for ed in self._editors:
251
+ with contextlib.suppress(Exception):
252
+ ed.minimap.suspend()
253
+ with contextlib.suppress(Exception):
254
+ ed.hl.suspend()
255
+ with contextlib.suppress(Exception):
256
+ if ed.color_preview:
257
+ ed.color_preview.set_enabled(False)
258
+ with contextlib.suppress(Exception):
259
+ if ed.inlay_hints:
260
+ ed.inlay_hints.set_enabled(False)
261
+ with contextlib.suppress(Exception):
262
+ if ed.inline_blame:
263
+ ed.inline_blame.set_enabled(False)
264
+
265
+ def _resume_all() -> None:
266
+ """Retoma todos os overlays pesados do editor após operações bloqueantes."""
267
+ for ed in self._editors:
268
+ with contextlib.suppress(Exception):
269
+ ed.minimap.resume()
270
+ with contextlib.suppress(Exception):
271
+ ed.hl.resume()
272
+ with contextlib.suppress(Exception):
273
+ if ed.color_preview and self._cfg.get("color_preview", True):
274
+ ed.color_preview.set_enabled(True)
275
+ with contextlib.suppress(Exception):
276
+ if ed.inlay_hints and self._cfg.get("inlay_hints", True):
277
+ ed.inlay_hints.set_enabled(True)
278
+ with contextlib.suppress(Exception):
279
+ if ed.inline_blame and self._cfg.get("inline_blame", True):
280
+ ed.inline_blame.set_enabled(True)
281
+
282
+ def _on_sash_press(_e: tk.Event) -> None:
283
+ if self._resize_dragging:
284
+ return
285
+ self._resize_dragging = True
286
+ _suspend_all()
287
+
288
+ def _on_sash_release(_e: tk.Event) -> None:
289
+ if not self._resize_dragging:
290
+ return
291
+ if self._resize_drag_job:
292
+ with contextlib.suppress(tk.TclError):
293
+ self._root.after_cancel(self._resize_drag_job)
294
+ self._resize_drag_job = self._root.after(100, _finish_resize)
295
+
296
+ def _finish_resize() -> None:
297
+ self._resize_drag_job = None
298
+ self._resize_dragging = False
299
+ _resume_all()
300
+ self._save_layout()
301
+
302
+ for paned in (self._h_paned, self._v_paned):
303
+ paned.bind("<ButtonPress-1>", _on_sash_press, add=True)
304
+ paned.bind("<ButtonRelease-1>", _on_sash_release, add=True)
305
+
306
+ self._win_resize_job: str | None = None
307
+ self._win_resizing = False
308
+ self._win_last_size = (0, 0)
309
+
310
+ def _end_window_resize() -> None:
311
+ self._win_resize_job = None
312
+ self._win_resizing = False
313
+ if not self._resize_dragging:
314
+ _resume_all()
315
+
316
+ def _on_root_configure(e: tk.Event) -> None:
317
+ if e.widget is not self._root:
318
+ return
319
+ size = (e.width, e.height)
320
+ if size == self._win_last_size:
321
+ return
322
+ first = self._win_last_size == (0, 0)
323
+ self._win_last_size = size
324
+ if first:
325
+ return
326
+ if not self._win_resizing:
327
+ self._win_resizing = True
328
+ if not self._resize_dragging:
329
+ _suspend_all()
330
+ if self._win_resize_job:
331
+ with contextlib.suppress(tk.TclError):
332
+ self._root.after_cancel(self._win_resize_job)
333
+ self._win_resize_job = self._root.after(150, _end_window_resize)
334
+
335
+ self._root.bind("<Configure>", _on_root_configure, add="+")
336
+
337
+ def _build_panel_toggle_buttons(self) -> None:
338
+ """Cria pequenos botões flutuantes para alternar sidebar e painel inferior."""
339
+ t = self._tmgr.theme
340
+
341
+ self._sidebar_toggle_btn = tk.Label(
342
+ self._root,
343
+ text="▶",
344
+ bg=t.tabbar_bg,
345
+ fg=t.fg,
346
+ font=(FONT_UI, 9, "bold"),
347
+ cursor="hand2",
348
+ padx=3,
349
+ pady=8,
350
+ relief="flat",
351
+ )
352
+ self._sidebar_toggle_btn.place(x=48, rely=0.5, anchor="w")
353
+ self._sidebar_toggle_btn.bind(
354
+ "<Button-1>", lambda _: self._toggle_sidebar())
355
+ self._sidebar_toggle_btn.bind(
356
+ "<Enter>", lambda _: self._sidebar_toggle_btn.config(bg=t.sel_bg)
357
+ )
358
+ self._sidebar_toggle_btn.bind(
359
+ "<Leave>", lambda _: self._sidebar_toggle_btn.config(
360
+ bg=t.tabbar_bg)
361
+ )
362
+ self._sidebar_toggle_btn.lift()
363
+
364
+ self._panel_toggle_btn = tk.Label(
365
+ self._root,
366
+ text="▲",
367
+ bg=t.tabbar_bg,
368
+ fg=t.fg,
369
+ font=(FONT_UI, 9, "bold"),
370
+ cursor="hand2",
371
+ padx=8,
372
+ pady=3,
373
+ relief="flat",
374
+ )
375
+ self._panel_toggle_btn.place(
376
+ relx=1.0, rely=1.0, anchor="se", x=-2, y=-26)
377
+ self._panel_toggle_btn.bind(
378
+ "<Button-1>", lambda _: self._toggle_panel())
379
+ self._panel_toggle_btn.bind(
380
+ "<Enter>", lambda _: self._panel_toggle_btn.config(bg=t.sel_bg)
381
+ )
382
+ self._panel_toggle_btn.bind(
383
+ "<Leave>", lambda _: self._panel_toggle_btn.config(bg=t.tabbar_bg)
384
+ )
385
+ self._panel_toggle_btn.lift()
386
+
387
+ def _dock_top(self) -> int:
388
+ """Y inicial do painel flutuante: abaixo da topbar e da tabbar K-UI."""
389
+ kui = getattr(self, "_kui", None)
390
+ return kui.chrome_top() if kui is not None else 0
391
+
392
+ def _on_dock_change(self, visible: bool) -> None:
393
+ """O dock abriu/fechou sozinho (✕, clique fora): sincroniza o estado do app."""
394
+ self._sidebar_visible = visible
395
+ self._update_panel_toggle_arrows()
396
+
397
+ def _on_dock_raise(self) -> None:
398
+ """Após elevar o painel, re-eleva as barras que devem ficar acima dele."""
399
+ kui = getattr(self, "_kui", None)
400
+ if kui is not None:
401
+ kui.raise_chrome()
402
+
403
+ def _update_panel_toggle_arrows(self) -> None:
404
+ """Atualiza a direção das setas flutuantes conforme o estado de visibilidade."""
405
+ with contextlib.suppress(tk.TclError):
406
+ if hasattr(self, "_sidebar_toggle_btn"):
407
+ actbar_w = 48 if not self._zen_mode else 0
408
+ dock = getattr(self, "_dock", None)
409
+ if dock is not None and dock.floating and self._sidebar_visible:
410
+ actbar_w = dock.right_edge()
411
+ self._sidebar_toggle_btn.config(
412
+ text="▶" if not self._sidebar_visible else "◀"
413
+ )
414
+ self._sidebar_toggle_btn.place(
415
+ x=actbar_w, rely=0.5, anchor="w")
416
+ self._sidebar_toggle_btn.lift()
417
+ with contextlib.suppress(tk.TclError):
418
+ if hasattr(self, "_panel_toggle_btn"):
419
+ self._panel_toggle_btn.config(
420
+ text="▲" if not self._panel_visible else "▼"
421
+ )
422
+ self._panel_toggle_btn.lift()
423
+
424
+ def _build_sidebar(self) -> None:
425
+ """Constrói o painel lateral com árvore de arquivos e painéis auxiliares."""
426
+ t = self._tmgr.theme
427
+ self._sidebar_stack = tk.Frame(self._sidebar, bg=t.sidebar_bg)
428
+ self._sidebar_stack.pack(fill="both", expand=True)
429
+
430
+ self._file_tree = FileTree(
431
+ self._sidebar_stack,
432
+ self._tmgr,
433
+ self._cfg,
434
+ on_open=self._open_file,
435
+ on_renamed=self._on_tree_path_renamed,
436
+ )
437
+
438
+ self._find_files = FindInFilesPanel(
439
+ self._sidebar_stack,
440
+ self._tmgr,
441
+ self._cfg,
442
+ get_root=lambda: self._workspace,
443
+ get_editor=self._active_editor,
444
+ on_open=self._open_file_at_line,
445
+ )
446
+
447
+ self._git_sidebar = GitPanel(
448
+ self._sidebar_stack,
449
+ self._tmgr,
450
+ self._cfg,
451
+ root_path=None,
452
+ on_refresh=self._on_git_refresh,
453
+ on_show_diff=self._show_file_diff_with_content,
454
+ on_commit=lambda msg: self._fire_hook("git_commit", msg),
455
+ )
456
+
457
+ self._plugin_panel = PluginPanel(
458
+ self._sidebar_stack, self._tmgr, self._plugin_loader
459
+ )
460
+
461
+ self._settings_editor = SettingsEditor(
462
+ self._sidebar_stack,
463
+ self._tmgr,
464
+ self._cfg,
465
+ on_change=self._on_setting_change,
466
+ )
467
+
468
+ self._code_outline = LazyPanel(
469
+ lambda: CodeOutline(
470
+ self._sidebar_stack,
471
+ self._tmgr,
472
+ get_editor=self._active_editor,
473
+ ),
474
+ '_code_outline',
475
+ )
476
+
477
+ self._bookmarks_panel = LazyPanel(
478
+ lambda: BookmarksPanel(
479
+ self._sidebar_stack,
480
+ self._tmgr,
481
+ mgr=self._bookmark_mgr,
482
+ on_goto=self._open_file_at_line,
483
+ ),
484
+ '_bookmarks_panel',
485
+ )
486
+
487
+ self._scratchpad_pane = LazyPanel(
488
+ lambda: ScratchpadPane(self._sidebar_stack, self._tmgr),
489
+ '_scratchpad_pane',
490
+ )
491
+
492
+ self._snippets_panel = LazyPanel(
493
+ lambda: SnippetsPanel(
494
+ self._sidebar_stack,
495
+ self._tmgr,
496
+ self._snippets,
497
+ get_editor=self._active_editor,
498
+ ),
499
+ '_snippets_panel',
500
+ )
501
+
502
+ self._docs_panel = LazyPanel(
503
+ lambda: DocsPanel(
504
+ self._sidebar_stack,
505
+ self._tmgr,
506
+ get_editor=self._active_editor,
507
+ on_goto=lambda ln: (
508
+ self._active_editor().goto_line(ln) if self._active_editor() else None
509
+ ),
510
+ ),
511
+ '_docs_panel',
512
+ )
513
+
514
+ self._code_stats_panel = LazyPanel(
515
+ lambda: CodeStatsPanel(
516
+ self._sidebar_stack, self._tmgr, self._cfg
517
+ ),
518
+ '_code_stats_panel',
519
+ )
520
+
521
+ self._todo_panel = LazyPanel(
522
+ lambda: TodoPanel(
523
+ self._sidebar_stack,
524
+ self._tmgr,
525
+ self._cfg,
526
+ open_file_at_line=self._open_file_at_line,
527
+ ),
528
+ '_todo_panel',
529
+ )
530
+
531
+ if _SQL_OK and SQLStudioPanel is not None:
532
+ self._sql_studio_panel: Any | None = SQLStudioPanel(
533
+ self._sidebar_stack, self._tmgr, self._cfg
534
+ )
535
+ else:
536
+ self._sql_studio_panel = None
537
+
538
+ self._rest_client_panel = LazyPanel(
539
+ lambda: RestClientPanel(
540
+ self._sidebar_stack, self._tmgr, self._cfg
541
+ ),
542
+ '_rest_client_panel',
543
+ )
544
+
545
+ self._render_panel = RenderPanel(
546
+ self._sidebar_stack, self._tmgr, self._cfg)
547
+ self._render_panel.set_advanced_callback(self._open_web_preview)
548
+ self._render_panel.set_selection_callback(
549
+ lambda: self._e().text.get(tk.SEL_FIRST, tk.SEL_LAST) if self._e() else ""
550
+ )
551
+
552
+ self._pomodoro_panel = LazyPanel(
553
+ lambda: PomodoroPanel(
554
+ self._sidebar_stack,
555
+ self._tmgr,
556
+ on_message=lambda msg, dur=3000: self._status.notify(
557
+ msg, duration=dur),
558
+ ),
559
+ '_pomodoro_panel',
560
+ )
561
+
562
+ self._flowchart_panel = LazyPanel(
563
+ lambda: FlowchartPanel(
564
+ self._sidebar_stack, self._tmgr, self._cfg
565
+ ),
566
+ '_flowchart_panel',
567
+ )
568
+
569
+ self._sidebar_problems = ProblemsPanel(
570
+ self._sidebar_stack,
571
+ self._tmgr,
572
+ on_goto=self._goto_problem_pos,
573
+ on_apply_fix=self._apply_problem_fix,
574
+ on_fix_all=self._apply_problem_fix_all,
575
+ )
576
+
577
+ if _IA_OK and PainelIA is not None:
578
+ self._painel_ia: Any | None = PainelIA(
579
+ self._sidebar_stack,
580
+ self._tmgr,
581
+ self._cfg,
582
+ get_editor=self._active_editor,
583
+ on_open_new_tab=self._create_tab_with_text,
584
+ get_workspace=lambda: self._workspace,
585
+ get_open_editors=lambda: list(self._editors),
586
+ )
587
+ else:
588
+ self._painel_ia = None
589
+
590
+ self._sidebar_placeholder = tk.Frame(
591
+ self._sidebar_stack, bg=t.sidebar_bg)
592
+ ph_inner = tk.Frame(self._sidebar_placeholder, bg=t.sidebar_bg)
593
+ ph_inner.place(relx=0.5, rely=0.5, anchor="center")
594
+ _ph_icon = tk.Label(
595
+ ph_inner, text="📂", bg=t.sidebar_bg, fg=t.fg_muted, font=("Segoe UI", 28)
596
+ )
597
+ _ph_icon.pack()
598
+ _ph_title = tk.Label(
599
+ ph_inner,
600
+ text=_t("sidebar.open_folder_hint"),
601
+ bg=t.sidebar_bg,
602
+ fg=t.fg_muted,
603
+ font=(FONT_UI, 9),
604
+ wraplength=180,
605
+ justify="center",
606
+ )
607
+ _ph_title.pack(pady=(6, 12))
608
+ _ph_btn = tk.Label(
609
+ ph_inner,
610
+ text=" " + _t("file.open_folder") + " ",
611
+ bg=t.btn_bg,
612
+ fg=t.fg,
613
+ font=(FONT_UI, 9),
614
+ cursor="hand2",
615
+ padx=8,
616
+ pady=5,
617
+ relief="flat",
618
+ )
619
+ _ph_btn.pack()
620
+ _ph_btn.bind("<Button-1>", lambda _: self.open_folder_dialog())
621
+ _ph_btn.bind("<Enter>", lambda _: _ph_btn.config(bg=t.sel_bg))
622
+ _ph_btn.bind("<Leave>", lambda _: _ph_btn.config(bg=t.btn_bg))
623
+
624
+ if self._workspace is None:
625
+ self._sidebar_placeholder.pack(fill="both", expand=True)
626
+ self._sidebar_current: tk.Widget | None = self._sidebar_placeholder
627
+ else:
628
+ self._file_tree.pack(fill="both", expand=True)
629
+ self._sidebar_current = self._file_tree
630
+
631
+ def _build_content(self, parent: tk.Widget) -> None:
632
+ """Constrói a área de conteúdo (editor + painel inferior)."""
633
+ t = self._tmgr.theme
634
+ self._v_paned = tk.PanedWindow(
635
+ parent,
636
+ orient="vertical",
637
+ bg=t.border,
638
+ sashwidth=6,
639
+ sashrelief="flat",
640
+ sashcursor="sb_v_double_arrow",
641
+ )
642
+ self._v_paned.pack(fill="both", expand=True)
643
+
644
+ editor_area = tk.Frame(self._v_paned, bg=t.bg)
645
+ self._v_paned.add(editor_area, stretch="always")
646
+ self._build_editor_area(editor_area)
647
+
648
+ ph = self._cfg.get("panel_height", 220)
649
+ self._bottom_frame = tk.Frame(self._v_paned, bg=t.panel_bg)
650
+ self._v_paned.add(self._bottom_frame, height=ph,
651
+ minsize=80, stretch="never")
652
+ self._build_bottom_panel()
653
+
654
+ def _build_editor_area(self, parent: tk.Widget) -> None:
655
+ """Constrói a área superior (tab bar, breadcrumb, search bar, container do editor)."""
656
+ t = self._tmgr.theme
657
+
658
+ self._tabbar = TabBar(
659
+ parent,
660
+ self._tmgr,
661
+ on_select=self._select_tab,
662
+ on_close=self._close_tab,
663
+ on_split_right=self._split_tab_to_right,
664
+ )
665
+ self._tabbar.pack(fill="x")
666
+
667
+ self._breadcrumb = BreadCrumb(
668
+ parent, self._tmgr, on_open=self._open_file)
669
+ if self._cfg.get("breadcrumbs", True):
670
+ self._breadcrumb.pack(fill="x")
671
+
672
+ self._editor_container = tk.Frame(parent, bg=t.editor_bg)
673
+ self._editor_container.pack(fill="both", expand=True)
674
+
675
+ self._search_bar = SearchBar(
676
+ parent,
677
+ self._tmgr,
678
+ self._cfg,
679
+ get_editor=self._active_editor,
680
+ pack_before=self._editor_container,
681
+ )
682
+
683
+ self._welcome = self._new_welcome()
684
+ self._welcome.pack(fill="both", expand=True)
685
+
686
+ def _build_bottom_panel(self) -> None:
687
+ """Constrói o painel inferior com abas para problems, terminal, output, etc.
688
+
689
+ Cada aba tem menu de contexto (clique direito) com a opção de
690
+ desplugagem para janela flutuante. O botão "⊞" ao lado das abas
691
+ desplugga o painel atualmente ativo. Disponível tanto no modo
692
+ clássico quanto no modo K-UI, via ``PanelDetachManager``
693
+ compartilhado (``self._panel_detach``).
694
+ """
695
+ t = self._tmgr.theme
696
+
697
+ self._panel_tabbar = tk.Frame(
698
+ self._bottom_frame, bg=t.tabbar_bg, height=28)
699
+ self._panel_tabbar.pack(fill="x")
700
+ self._panel_tabbar.pack_propagate(False)
701
+
702
+ self._panel_tabs: dict[str, tk.Label] = {}
703
+ for key, i18n_key in (
704
+ ("problems", "panel.problems"),
705
+ ("terminal", "panel.terminal"),
706
+ ("output", "panel.output"),
707
+ ("git", "panel.git"),
708
+ ("diff", "panel.diff"),
709
+ ("debug", "panel.debug"),
710
+ ("regex", "panel.regex"),
711
+ ("sql", "panel.sql"),
712
+ ):
713
+ lbl = tk.Label(
714
+ self._panel_tabbar,
715
+ text=f" {_t(i18n_key)} ",
716
+ bg=t.tabbar_bg,
717
+ fg=t.tab_in_fg,
718
+ font=(FONT_UI, 9),
719
+ cursor="hand2",
720
+ )
721
+ lbl.pack(side="left")
722
+ lbl.bind("<Button-1>", lambda _, k=key: self._show_panel(k))
723
+ self._panel_tabs[key] = lbl
724
+ self._bind_panel_tab_context_menu(key, lbl)
725
+
726
+ self._detach_btn = tk.Label(
727
+ self._panel_tabbar,
728
+ text=_t("hc.app.btn_split"),
729
+ bg=t.tabbar_bg,
730
+ fg=t.fg_muted,
731
+ font=(FONT_UI, 9),
732
+ cursor="hand2",
733
+ )
734
+ self._detach_btn.pack(side="right", padx=(0, 2))
735
+ self._detach_btn.bind(
736
+ "<Button-1>", lambda _: self._detach_current_panel())
737
+ self._detach_btn.bind(
738
+ "<Enter>",
739
+ lambda _: self._detach_btn.config(
740
+ fg=t.accent if hasattr(t, "accent") else "#7c4dff"
741
+ ),
742
+ )
743
+ self._detach_btn.bind(
744
+ "<Leave>", lambda _: self._detach_btn.config(fg=t.fg_muted)
745
+ )
746
+
747
+ close_btn = tk.Label(
748
+ self._panel_tabbar,
749
+ text=_t("hc.app.btn_close"),
750
+ bg=t.tabbar_bg,
751
+ fg=t.fg_muted,
752
+ font=(FONT_UI, 9),
753
+ cursor="hand2",
754
+ )
755
+ close_btn.pack(side="right")
756
+ close_btn.bind("<Button-1>", lambda _: self._toggle_panel())
757
+
758
+ tk.Frame(self._bottom_frame, bg=t.border, height=1).pack(fill="x")
759
+
760
+ self._panel_content = tk.Frame(self._bottom_frame, bg=t.panel_bg)
761
+ self._panel_content.pack(fill="both", expand=True)
762
+
763
+ cwd = str(self._workspace) if self._workspace else str(Path.home())
764
+
765
+ self._problems_panel = ProblemsPanel(
766
+ self._panel_content,
767
+ self._tmgr,
768
+ on_goto=self._goto_problem_pos,
769
+ on_apply_fix=self._apply_problem_fix,
770
+ on_fix_all=self._apply_problem_fix_all,
771
+ )
772
+
773
+ self._terminal = TerminalPanel(
774
+ self._panel_content, self._tmgr, self._cfg, cwd=cwd, app=self
775
+ )
776
+
777
+ self._output_panel = OutputPanel(
778
+ self._panel_content, self._tmgr, self._cfg)
779
+
780
+ self._attach_log_handler()
781
+
782
+ self._git_bottom = GitPanel(
783
+ self._panel_content,
784
+ self._tmgr,
785
+ self._cfg,
786
+ root_path=None,
787
+ on_refresh=self._on_git_refresh,
788
+ on_commit=lambda msg: self._fire_hook("git_commit", msg),
789
+ )
790
+
791
+ self._diff_pane = DiffPane(
792
+ self._panel_content,
793
+ self._tmgr,
794
+ self._cfg,
795
+ on_close=lambda: self._show_panel("problems"),
796
+ )
797
+
798
+ self._debug_panel = DebugPanel(
799
+ self._panel_content,
800
+ self._tmgr,
801
+ self._cfg,
802
+ get_editor=self._active_editor,
803
+ )
804
+
805
+ self._regex_panel = RegexPlayground(
806
+ self._panel_content,
807
+ self._tmgr,
808
+ get_text=lambda: self._e().get_content() if self._e() else "",
809
+ apply_replace=self._regex_replace,
810
+ )
811
+
812
+ if _SQL_OK and SQLStudioPanel is not None:
813
+ self._sql_bottom: Any | None = SQLStudioPanel(
814
+ self._panel_content, self._tmgr, self._cfg
815
+ )
816
+ else:
817
+ self._sql_bottom = None
818
+
819
+ self._show_panel("problems")
820
+
821
+ def _detach_current_panel(self) -> None:
822
+ """Destaca o painel inferior atualmente ativo para janela flutuante.
823
+
824
+ Funciona tanto no modo clássico quanto no modo K-UI, via
825
+ ``PanelDetachManager`` compartilhado. Painéis sem fábrica registrada
826
+ (ex.: diff, sql, que dependem de estado vivo do app) simplesmente
827
+ não fazem nada - eles ainda não suportam detach.
828
+ """
829
+ key = getattr(self, "_current_panel", "terminal")
830
+ if not key:
831
+ return
832
+ with contextlib.suppress(AttributeError, tk.TclError):
833
+ if self._panel_detach.can_detach(key):
834
+ self._panel_detach.detach(key)
835
+ else:
836
+ self._status.notify(_t("panel.detach_unsupported", panel=key))
837
+
838
+ def _mk_menu(self, parent, label, underline=0):
839
+ """Cria um submenu (MenuDef) e o adiciona ao parent (MenuBar ou MenuDef).
840
+
841
+ Tanto a MenuBar de nível superior quanto qualquer MenuDef de cascade
842
+ aceitam um MenuDef como filho - é a mesma estrutura de dados usada
843
+ para montar os dropdowns holográficos, então não há distinção
844
+ entre "menu de topo" e "submenu" na construção.
845
+ """
846
+ from src.ui.menu_bar import MenuDef
847
+
848
+ m = MenuDef()
849
+ parent.add_cascade(label=label, menu=m, underline=underline)
850
+ return m
851
+
852
+ @staticmethod
853
+ def _mc(m, label, cmd, accel=""):
854
+ """Adiciona um comando a um menu."""
855
+ m.add_command(label=label, command=cmd, accelerator=accel)
856
+
857
+ @staticmethod
858
+ def _ms(m):
859
+ """Adiciona separador visual ao menu."""
860
+ m.add_separator()
861
+
862
+ def _build_menus(self) -> None:
863
+ """Constrói a barra de menus principal - moderna, organizada e responsiva."""
864
+ t = self._tmgr.theme
865
+ _mk = self._mk_menu
866
+ _c = self._mc
867
+ _s = self._ms
868
+ _cb_kw = {
869
+ "background": t.floating_bg,
870
+ "foreground": t.fg,
871
+ "activebackground": t.sel_bg,
872
+ "activeforeground": t.sel_fg,
873
+ "selectcolor": t.accent,
874
+ }
875
+
876
+ from src.ui.menu_bar import MenuBar
877
+
878
+ mb_position = self._cfg.get("menubar_position", "top")
879
+ mb = MenuBar(self._root, self._tmgr, position=mb_position)
880
+ mb.pack_into(self._root)
881
+ self._menubar = mb
882
+ self._plugin_menu_cache = None
883
+
884
+ fm = _mk(mb, _t("menu.file"))
885
+ _c(fm, _t("file.new"), self.new_file, "Ctrl+N")
886
+ _c(fm, _t("file.new_window"), self._new_window)
887
+ _c(fm, _t("file.open_home", "Abrir Tela Inicial"), self._open_home)
888
+ _s(fm)
889
+ _c(fm, _t("file.open"), self.open_file_dialog, "Ctrl+O")
890
+ _c(fm, _t("file.open_folder"), self.open_folder_dialog)
891
+ self._recent_menu = _mk(fm, _t("file.open_recent"))
892
+ self._rebuild_recent_menu()
893
+ _s(fm)
894
+ _c(fm, _t("file.save"), self.save_file, "Ctrl+S")
895
+ _c(fm, _t("file.save_as"), self.save_as, "Ctrl+Shift+S")
896
+ _c(fm, _t("file.save_all"), self.save_all)
897
+ _c(fm, _t("file.revert"), self.revert_file)
898
+ _s(fm)
899
+ self._autosave_var = tk.BooleanVar(
900
+ value=self._cfg.get("autosave", False))
901
+ fm.add_checkbutton(
902
+ label=_t("file.autosave"),
903
+ variable=self._autosave_var,
904
+ command=self._toggle_autosave,
905
+ **_cb_kw,
906
+ )
907
+ _s(fm)
908
+ _c(fm, _t("file.close"), self._close_active_tab, "Ctrl+W")
909
+ _c(fm, _t("file.close_all"), self._close_all_tabs)
910
+ _s(fm)
911
+ _c(fm, _t("file.restart"), self._restart_process)
912
+ _c(fm, _t("file.exit"), self._on_exit, "Alt+F4")
913
+
914
+ em = _mk(mb, _t("menu.edit"))
915
+ _c(em, _t("edit.undo"), self._undo, "Ctrl+Z")
916
+ _c(em, _t("edit.redo"), self._redo, "Ctrl+Y")
917
+ _s(em)
918
+ _c(em, _t("edit.cut"), self._cut, "Ctrl+X")
919
+ _c(em, _t("edit.copy"), self._copy, "Ctrl+C")
920
+ _c(em, _t("edit.paste"), self._paste, "Ctrl+V")
921
+ _c(em, _t("edit.select_all"), self._select_all, "Ctrl+A")
922
+ _s(em)
923
+ _c(em, _t("edit.find"), self._show_find, "Ctrl+F")
924
+ _c(em, _t("edit.find_replace"), self._show_replace, "Ctrl+H")
925
+ _c(em, _t("edit.find_in_files"), self._show_find_files, "Ctrl+Shift+F")
926
+ _s(em)
927
+ lm = _mk(em, _t("hc.app.transform"))
928
+ _c(lm, _t("edit.transform_upper"), lambda: self._transform("upper"))
929
+ _c(lm, _t("edit.transform_lower"), lambda: self._transform("lower"))
930
+ _c(lm, "Title Case", lambda: self._transform("title"))
931
+ _s(lm)
932
+ _c(lm, _t("edit.sort_lines"), lambda: self._sort_lines(False))
933
+ _c(lm, _t("edit.sort_lines_desc"), lambda: self._sort_lines(True))
934
+ _c(lm, _t("edit.trim_trailing"), self._trim_trailing)
935
+ _c(lm, _t("edit.remove_dupes"), self._remove_duplicate_lines)
936
+ _c(em, _t("edit.toggle_comment"), self._toggle_comment, "Ctrl+/")
937
+ _c(em, _t("edit.duplicate_line"), self._duplicate_line, "Ctrl+D")
938
+ _c(em, _t("edit.delete_line"), self._delete_line, "Ctrl+Shift+K")
939
+ _c(em, _t("edit.move_line_up"), self._move_line_up, "Alt+Up")
940
+ _c(em, _t("edit.move_line_down"), self._move_line_down, "Alt+Down")
941
+ _c(em, _t("edit.join_lines"), self._join_lines)
942
+ _s(em)
943
+ _c(em, _t("edit.paste_history"), self._paste_history_dialog, "Ctrl+Shift+V")
944
+
945
+ sm = _mk(mb, _t("menu.selection"))
946
+ _c(sm, "Select Line", self._select_line, "Ctrl+L")
947
+ _c(sm, _t("edit.copy_line_up"), self._copy_line_up)
948
+ _c(sm, _t("edit.copy_line_down"), self._copy_line_down)
949
+
950
+ vm = _mk(mb, _t("menu.view"))
951
+ _c(vm, _t("view.command_palette"), self._command_palette, "Ctrl+Shift+P")
952
+ _s(vm)
953
+ sb_m = _mk(vm, "Barra Lateral")
954
+ _c(sb_m, "Explorer", lambda: self._activity("explorer"), "Ctrl+Shift+E")
955
+ _c(sb_m, "Pesquisar", lambda: self._activity("search"), "Ctrl+Shift+F")
956
+ _c(sb_m, "Git", lambda: self._activity("git"), "Ctrl+Shift+G")
957
+ _c(sb_m, "Extensions", lambda: self._activity("extensions"), "Ctrl+Shift+X")
958
+ if _IA_OK:
959
+ _c(sb_m, "Assistente IA", lambda: self._activity("ia"), "Ctrl+Shift+A")
960
+ pn_m = _mk(vm, "Paineis")
961
+ _c(
962
+ pn_m,
963
+ _t("view.problems"),
964
+ lambda: self._show_panel("problems"),
965
+ "Ctrl+Shift+M",
966
+ )
967
+ _c(pn_m, _t("view.terminal"), lambda: self._show_panel("terminal"), "Ctrl+`")
968
+ _c(pn_m, "Output", lambda: self._show_panel("output"))
969
+ _c(pn_m, "Debug", lambda: self._show_panel("debug"))
970
+ _c(pn_m, "Code Outline", lambda: self._activity("outline"))
971
+ _c(pn_m, "File Timeline", self._open_file_timeline)
972
+ _s(vm)
973
+ mbp_m = _mk(vm, _t("view.menubar_position"))
974
+ self._mbp_top_var = tk.BooleanVar(
975
+ value=self._cfg.get("menubar_position", "top") == "top"
976
+ )
977
+ self._mbp_bottom_var = tk.BooleanVar(
978
+ value=self._cfg.get("menubar_position", "top") == "bottom"
979
+ )
980
+ mbp_m.add_checkbutton(
981
+ label=_t("view.menubar_position_top"),
982
+ variable=self._mbp_top_var,
983
+ command=lambda: self._set_menubar_position("top"),
984
+ )
985
+ mbp_m.add_checkbutton(
986
+ label=_t("view.menubar_position_bottom"),
987
+ variable=self._mbp_bottom_var,
988
+ command=lambda: self._set_menubar_position("bottom"),
989
+ )
990
+ _s(vm)
991
+ t2 = self._tmgr.theme
992
+ vm.add_command(
993
+ label=_t("theme.open_selector", "Temas..."),
994
+ command=self._open_theme_panel,
995
+ background=t2.floating_bg,
996
+ foreground=t2.fg,
997
+ activebackground=t2.sel_bg,
998
+ activeforeground=t2.sel_fg,
999
+ )
1000
+ self._themes_menu = None
1001
+ _s(vm)
1002
+ self._wrap_var = tk.BooleanVar(value=self._cfg.get("word_wrap", False))
1003
+ self._minimap_var = tk.BooleanVar(value=self._cfg.get("minimap", True))
1004
+ self._bc_var = tk.BooleanVar(value=self._cfg.get("breadcrumbs", True))
1005
+ vm.add_checkbutton(
1006
+ label=_t("view.word_wrap"),
1007
+ variable=self._wrap_var,
1008
+ command=self._toggle_word_wrap,
1009
+ **_cb_kw,
1010
+ )
1011
+ vm.add_checkbutton(
1012
+ label=_t("view.minimap"),
1013
+ variable=self._minimap_var,
1014
+ command=self._toggle_minimap,
1015
+ **_cb_kw,
1016
+ )
1017
+ vm.add_checkbutton(
1018
+ label=_t("view.breadcrumbs"),
1019
+ variable=self._bc_var,
1020
+ command=self._toggle_breadcrumbs,
1021
+ **_cb_kw,
1022
+ )
1023
+ _s(vm)
1024
+ _c(vm, _t("view.zoom_in"), lambda: self._zoom(+1), "Ctrl+=")
1025
+ _c(vm, _t("view.zoom_out"), lambda: self._zoom(-1), "Ctrl+-")
1026
+ _c(vm, _t("view.zoom_reset"), lambda: self._zoom(0), "Ctrl+0")
1027
+ _s(vm)
1028
+ _c(vm, _t("view.ui_scale_up"), lambda: self._ui_scale_step(+1), "Ctrl+Alt+=")
1029
+ _c(vm, _t("view.ui_scale_down"), lambda: self._ui_scale_step(-1), "Ctrl+Alt+-")
1030
+ _c(vm, _t("view.ui_scale_auto"), self._ui_scale_auto, "Ctrl+Alt+0")
1031
+ _s(vm)
1032
+ _c(vm, _t("view.full_screen"), self._toggle_fullscreen, "F11")
1033
+ _c(vm, _t("view.split_editor"), self._split_editor, "Ctrl+\\")
1034
+
1035
+ gm = _mk(mb, _t("menu.go"))
1036
+ _c(gm, _t("go.to_line"), self._goto_line, "Ctrl+G")
1037
+ _c(gm, _t("go.to_symbol"), self._goto_symbol, "Ctrl+Shift+O")
1038
+ _s(gm)
1039
+ _c(gm, _t("go.next_problem"), self._next_problem, "F8")
1040
+ _c(gm, _t("go.prev_problem"), self._prev_problem, "Shift+F8")
1041
+ _s(gm)
1042
+ _c(gm, _t("go.next_tab"), self._next_tab, "Ctrl+Tab")
1043
+ _c(gm, _t("go.prev_tab"), self._prev_tab, "Ctrl+Shift+Tab")
1044
+ _c(gm, _t("go.matching_bracket"), self._goto_bracket)
1045
+
1046
+ rm = _mk(mb, _t("menu.run"))
1047
+ _c(rm, _t("run.run_file"), self._run_file, "F5")
1048
+ _c(rm, _t("run.format_document"), self._format_document, "Shift+Alt+F")
1049
+ _c(rm, _t("run.lint_file"), self._lint_file)
1050
+ _c(rm, _t("run.fix_all"), self._fix_all)
1051
+
1052
+ trm = _mk(mb, _t("menu.terminal"))
1053
+ _c(trm, _t("terminal.new"), self._new_terminal)
1054
+ _c(trm, _t("terminal.clear"), self._clear_terminal)
1055
+ _c(trm, _t("terminal.kill"), self._kill_terminal)
1056
+ _c(trm, _t("terminal.run_selection"), self._run_selection)
1057
+
1058
+ pm = _mk(mb, _t("menu.plugins"))
1059
+ _c(pm, _t("menu.plugins_manage"), lambda: self._activity("extensions"))
1060
+ _c(pm, _t("menu.plugins_install"), self._install_plugin)
1061
+ _c(pm, _t("menu.ext_compat", "Extensões de outros editores..."), self._open_ext_compat)
1062
+ _c(pm, _t("menu.plugins_folder"), lambda: self._open_extern(PLUGINS_DIR))
1063
+ self._plugin_menu_cache = pm
1064
+
1065
+ xm = _mk(mb, _t("menu.tools"))
1066
+
1067
+ txt_m = _mk(xm, "Texto & Arquivo")
1068
+ _c(txt_m, _t("tools.word_count"), self._word_count_dialog)
1069
+ _c(txt_m, _t("tools.insert_seq"), self._insert_sequence_dialog)
1070
+ _s(txt_m)
1071
+ _c(txt_m, _t("tools.session_notes"), self._open_session_notes)
1072
+ _c(txt_m, _t("tools.bookmark_add"), self._add_bookmark, "Ctrl+F2")
1073
+ _c(txt_m, _t("tools.bookmark_list"),
1074
+ lambda: self._activity("bookmarks"), "Ctrl+Shift+B")
1075
+
1076
+ enc_m = _mk(xm, "Encode & Hash")
1077
+ _c(enc_m, _t("tools.base64_enc"), self._base64_encode)
1078
+ _c(enc_m, _t("tools.base64_dec"), self._base64_decode)
1079
+ _s(enc_m)
1080
+ _c(enc_m, _t("tools.url_enc"), self._url_encode)
1081
+ _c(enc_m, _t("tools.url_dec"), self._url_decode)
1082
+ _s(enc_m)
1083
+ _c(enc_m, _t("tools.hash_md5"), lambda: self._hash_selection("md5"))
1084
+ _c(enc_m, _t("tools.hash_sha256"), lambda: self._hash_selection("sha256"))
1085
+
1086
+ prod_m = _mk(xm, _t("tools.cat_productivity", "Produtividade & Notas"))
1087
+ _c(
1088
+ prod_m,
1089
+ _t("file.scratchpad"),
1090
+ lambda: self._activity("scratchpad"),
1091
+ "Ctrl+Shift+N",
1092
+ )
1093
+ _c(
1094
+ prod_m,
1095
+ _t("snippets.title", "Snippets"),
1096
+ lambda: self._activity("snippets"),
1097
+ "Ctrl+Shift+J",
1098
+ )
1099
+ _c(prod_m, _t("todo.title", "Todo Tree"), lambda: self._activity("todo"))
1100
+ _c(
1101
+ prod_m,
1102
+ _t("tools.task_manager", "✅ Tarefas"),
1103
+ self._open_task_manager,
1104
+ "Ctrl+Alt+T",
1105
+ )
1106
+ _s(prod_m)
1107
+ _c(
1108
+ prod_m,
1109
+ _t("pomodoro.title", "Pomodoro"),
1110
+ lambda: self._activity("pomodoro"),
1111
+ "Ctrl+Alt+P",
1112
+ )
1113
+ _c(
1114
+ prod_m,
1115
+ _t("tools.time_tracker", "⏱ Code Time Tracker"),
1116
+ self._open_time_tracker,
1117
+ "Ctrl+Alt+W",
1118
+ )
1119
+
1120
+ dev_m = _mk(xm, _t("tools.cat_dev_utils",
1121
+ "Utilitários de Desenvolvimento"))
1122
+ _c(dev_m, _t("tools.color_picker"),
1123
+ self._open_color_picker, "Ctrl+Shift+C")
1124
+ _c(
1125
+ dev_m,
1126
+ _t("tools.regex_playground"),
1127
+ lambda: self._show_panel("regex"),
1128
+ "Ctrl+Shift+R",
1129
+ )
1130
+ _c(dev_m, _t("sql.title"), lambda: self._show_panel("sql"), "Ctrl+Shift+Q")
1131
+ _c(
1132
+ dev_m,
1133
+ _t("restclient.title", "REST Client"),
1134
+ lambda: self._activity("restclient"),
1135
+ )
1136
+ _c(
1137
+ dev_m,
1138
+ _t("tools.diff_viewer", "⇄ Diff Viewer"),
1139
+ self._open_diff,
1140
+ "Ctrl+Alt+D",
1141
+ )
1142
+ _c(
1143
+ dev_m,
1144
+ _t("tools.formatter", "{ } Formatador"),
1145
+ self._open_formatter,
1146
+ "Ctrl+Alt+F",
1147
+ )
1148
+ _c(dev_m, _t("tools.env_manager", "⚙ Variáveis de Env"), self._open_env_manager)
1149
+ _s(dev_m)
1150
+ _c(
1151
+ dev_m,
1152
+ _t("codestats.title", "Code Stats"),
1153
+ lambda: self._activity("codestats"),
1154
+ )
1155
+ _c(
1156
+ dev_m,
1157
+ _t("flowchart.title", "Flowchart"),
1158
+ lambda: self._activity("flowchart"),
1159
+ )
1160
+ _c(
1161
+ dev_m,
1162
+ _t("tools.dep_graph", "🔗 Grafo de Deps"),
1163
+ self._open_dependency_graph,
1164
+ )
1165
+
1166
+ sys_m = _mk(xm, _t("tools.cat_system", "Sistema & Processos"))
1167
+ _c(sys_m, _t("tools.pip_manager", "📦 Gerenciador Pip"), self._open_pip_manager)
1168
+ _c(
1169
+ sys_m,
1170
+ _t("tools.process_manager", "Gerenciador de Processos"),
1171
+ self._open_process_manager,
1172
+ "Ctrl+Alt+X",
1173
+ )
1174
+ _c(
1175
+ sys_m,
1176
+ _t("tools.performance_panel", "Modo Performance"),
1177
+ self._open_performance_panel,
1178
+ )
1179
+ _s(sys_m)
1180
+ _c(
1181
+ sys_m,
1182
+ _t("tools.open_paint", "Paint Integrado"),
1183
+ self._open_paint_panel,
1184
+ "Ctrl+Alt+B",
1185
+ )
1186
+ _c(sys_m, _t("preview.title", "Preview"),
1187
+ lambda: self._activity("preview"))
1188
+ _c(sys_m, _t("webpreview.menu", "Preview Web (navegador embutido)"),
1189
+ self._open_web_preview, "Ctrl+Alt+Y")
1190
+
1191
+ misc_m = _mk(xm, _t("tools.cat_personal", "Calendário & Pessoal"))
1192
+ _c(
1193
+ misc_m,
1194
+ _t("tools.calculator", "🔢 Calculadora"),
1195
+ self._open_calculator,
1196
+ "Ctrl+Alt+C",
1197
+ )
1198
+ _c(misc_m, _t("tools.calendar", "📅 Calendário"), self._open_calendar)
1199
+ _c(misc_m, _t("tools.clock", "🕐 Relógio"), self._open_clock, "Ctrl+Alt+K")
1200
+
1201
+ lsp_m = _mk(xm, "LSP - Navegacao de Codigo")
1202
+ _c(
1203
+ lsp_m,
1204
+ "Go to Definition",
1205
+ lambda: self._e().lsp_goto_definition() if self._e() else None,
1206
+ "F12",
1207
+ )
1208
+ _c(
1209
+ lsp_m,
1210
+ "Go to Declaration",
1211
+ lambda: self._e().lsp_goto_declaration() if self._e() else None,
1212
+ )
1213
+ _c(
1214
+ lsp_m,
1215
+ "Go to Type Definition",
1216
+ lambda: self._e().lsp_goto_type_definition() if self._e() else None,
1217
+ )
1218
+ _c(
1219
+ lsp_m,
1220
+ "Go to Implementation",
1221
+ lambda: self._e().lsp_goto_implementation() if self._e() else None,
1222
+ "Ctrl+F12",
1223
+ )
1224
+ _s(lsp_m)
1225
+ _c(
1226
+ lsp_m,
1227
+ "Find References",
1228
+ lambda: self._e().lsp_find_references() if self._e() else None,
1229
+ "Shift+F12",
1230
+ )
1231
+ _c(
1232
+ lsp_m,
1233
+ "Rename Symbol",
1234
+ lambda: self._e().lsp_rename_symbol() if self._e() else None,
1235
+ "F6",
1236
+ )
1237
+ _c(
1238
+ lsp_m,
1239
+ "Code Actions",
1240
+ lambda: self._e().lsp_code_action() if self._e() else None,
1241
+ "Ctrl+.",
1242
+ )
1243
+ _s(lsp_m)
1244
+ _c(
1245
+ lsp_m,
1246
+ "Incoming Calls",
1247
+ lambda: self._e().lsp_incoming_calls() if self._e() else None,
1248
+ )
1249
+ _c(
1250
+ lsp_m,
1251
+ "Outgoing Calls",
1252
+ lambda: self._e().lsp_outgoing_calls() if self._e() else None,
1253
+ )
1254
+ _s(lsp_m)
1255
+ _c(lsp_m, "Servidores LSP...", self._open_lsp_panel)
1256
+
1257
+ ws_m = _mk(xm, "Workspace & Editor")
1258
+ _c(ws_m, _t("ws.menu_item"), self._open_workspace_switcher, "Ctrl+Shift+W")
1259
+ _c(ws_m, _t("runner.menu_item"), self._open_code_runner_config)
1260
+ _c(ws_m, _t("macro.menu_item"), self._open_macro_toolbar, "Ctrl+Alt+R")
1261
+ _c(ws_m, _t("tmpl.menu_item"), self._open_project_template)
1262
+ _c(ws_m, _t("mc.menu_item"), self._toggle_multi_cursor, "Ctrl+Alt+M")
1263
+ _s(ws_m)
1264
+ _c(ws_m, "Vim Mode", self._toggle_vim_mode, "Ctrl+Alt+V")
1265
+ _c(ws_m, "K-UI", self._toggle_kui, "Ctrl+Alt+N")
1266
+ _c(ws_m, "K-UI: Performance", self._show_kui_perf_picker)
1267
+ _c(ws_m, "Zen Player", self._toggle_zen_player)
1268
+ _c(ws_m, "Zen Media Config...", self._open_zen_media_config)
1269
+ _s(ws_m)
1270
+ _c(ws_m, "Liberar memoria da aba", self._purge_active_tab_memory)
1271
+ _c(ws_m, "Limpar cache (GC)", self._global_gc)
1272
+
1273
+ rm2 = _mk(xm, _t("menu.remote_collab", "Remoto & Colaboração"))
1274
+ _c(
1275
+ rm2,
1276
+ _t("menu.remote_ssh", "SSH Remoto..."),
1277
+ self._open_remote_ssh,
1278
+ "Ctrl+Shift+H",
1279
+ )
1280
+ _c(rm2, _t("menu.collab", "Colaboração..."), self._open_collab)
1281
+ _c(rm2, _t("menu.chat", "Chat ao Vivo..."), self._open_chat, "Ctrl+Alt+L")
1282
+
1283
+ _s(xm)
1284
+ _c(xm, _t("tools.zen_mode"), self._toggle_zen_mode, "Ctrl+Alt+Z")
1285
+ _c(xm, _t("tools.focus_mode"), self._toggle_focus_mode)
1286
+ _c(xm, _t("tools.read_only"), self._toggle_read_only)
1287
+
1288
+ stm = _mk(mb, _t("menu.settings", "Configurações"))
1289
+ _c(
1290
+ stm,
1291
+ _t("settings.open", "Abrir Configurações..."),
1292
+ self._open_settings_window,
1293
+ "Ctrl+,",
1294
+ )
1295
+ _c(
1296
+ stm,
1297
+ _t("menu.accessibility", "Acessibilidade..."),
1298
+ self._open_accessibility,
1299
+ "Ctrl+Shift+U",
1300
+ )
1301
+ _c(
1302
+ stm,
1303
+ _t("keyremap.menu_item", "Atalhos de Teclado..."),
1304
+ self._open_key_remapper,
1305
+ )
1306
+ _s(stm)
1307
+
1308
+ rst_stm = _mk(stm, _t("settings.reset_menu", "Redefinir / Restaurar"))
1309
+ _c(
1310
+ rst_stm,
1311
+ _t("settings.reset_soft", "Soft Reset (apenas configurações)"),
1312
+ lambda: self._run_reset("soft"),
1313
+ )
1314
+ _c(
1315
+ rst_stm,
1316
+ _t("settings.reset_wizard", "Soft Reset + Forçar Setup Wizard"),
1317
+ lambda: self._run_reset("wizard"),
1318
+ )
1319
+ _c(
1320
+ rst_stm,
1321
+ _t("settings.reset_full", "Limpeza Completa"),
1322
+ lambda: self._run_reset("full"),
1323
+ )
1324
+ _s(rst_stm)
1325
+ _c(
1326
+ rst_stm,
1327
+ _t("settings.reset_by_key", "Redefinir Configuração Específica..."),
1328
+ self._reset_single_key,
1329
+ )
1330
+ _c(
1331
+ rst_stm,
1332
+ _t("settings.reset_session", "Limpar Sessão e Histórico"),
1333
+ self._reset_session_only,
1334
+ )
1335
+
1336
+ _s(stm)
1337
+ adv_stm = _mk(stm, _t("settings.advanced_group", "Avançado"))
1338
+ _c(
1339
+ adv_stm,
1340
+ _t("settings.advanced", "Editar JSON Diretamente..."),
1341
+ lambda: self._on_setting_change(
1342
+ "_open_json",
1343
+ str(CONFIG_FILE),
1344
+ ),
1345
+ )
1346
+ _c(
1347
+ adv_stm,
1348
+ _t("settings.open_cursor_editor", "Editar Cursor..."),
1349
+ self._open_settings_window_cursor,
1350
+ )
1351
+
1352
+ hm = _mk(mb, _t("menu.help"))
1353
+ _c(hm, _t("help.welcome"), self._show_welcome)
1354
+ _c(
1355
+ hm,
1356
+ _t("help.docs"),
1357
+ lambda: webbrowser.open(REPO_URL),
1358
+ )
1359
+ _c(
1360
+ hm,
1361
+ _t("help.shortcuts_reference", "Referência de Atalhos"),
1362
+ self._keybindings_dialog,
1363
+ )
1364
+ _s(hm)
1365
+ _c(
1366
+ hm,
1367
+ _t("help.check_updates", "Verificar Atualizações..."),
1368
+ self._check_for_updates,
1369
+ )
1370
+ _s(hm)
1371
+ _c(hm, "About Codis", self._about_dialog)
1372
+
1373
+ def _rebuild_theme_menu(self) -> None:
1374
+ """Reconstrói o submenu de temas no menu Exibir.
1375
+
1376
+ após a construção inicial do menu).
1377
+ """
1378
+ themes_menu: tk.Menu | None = getattr(self, "_themes_menu", None)
1379
+ if themes_menu is None:
1380
+ return
1381
+ try:
1382
+ t = self._tmgr.theme
1383
+ themes_menu.delete(0, "end")
1384
+ themes_menu.add_command(
1385
+ label=_t("theme.open_selector", "Abrir Seletor de Temas..."),
1386
+ command=self._open_theme_panel,
1387
+ background=t.floating_bg,
1388
+ foreground=t.fg,
1389
+ activebackground=t.sel_bg,
1390
+ activeforeground=t.sel_fg,
1391
+ )
1392
+ themes_menu.add_separator()
1393
+ for name in THEME_ORDER:
1394
+ themes_menu.add_command(
1395
+ label=name,
1396
+ command=lambda n=name: self._apply_theme_from_menu(n),
1397
+ background=t.floating_bg,
1398
+ foreground=t.fg,
1399
+ activebackground=t.sel_bg,
1400
+ activeforeground=t.sel_fg,
1401
+ )
1402
+ except tk.TclError as exc:
1403
+ logger.debug("_rebuild_theme_menu: %s", exc)
1404
+
1405
+ def _init_cursor_manager(self) -> None:
1406
+ """Inicializa o gerenciador de cursor customizável."""
1407
+ try:
1408
+ from src.ui.cursor_manager import CursorManager
1409
+
1410
+ self._cursor_mgr = CursorManager(self._root, self._tmgr, self._cfg)
1411
+ except Exception as exc:
1412
+ import logging
1413
+
1414
+ logging.getLogger("Codis").debug("CursorManager init: %s", exc)
1415
+ self._cursor_mgr = None
1416
+
1417
+ def _bind_shortcuts(self) -> None:
1418
+ """Registra todos os atalhos de teclado globais da aplicação."""
1419
+ b = self._root.bind
1420
+ b("<Control-n>", lambda _: self.new_file())
1421
+ b("<Control-o>", lambda _: self.open_file_dialog())
1422
+ b("<Control-s>", lambda _: self.save_file())
1423
+ b("<Control-S>", lambda _: self.save_as())
1424
+ b("<Control-w>", lambda _: self._close_active_tab())
1425
+ b("<Control-z>", lambda _: self._undo())
1426
+ b("<Control-y>", lambda _: self._redo())
1427
+ b("<Control-Z>", lambda _: self._redo())
1428
+ b("<Control-a>", lambda _: self._select_all())
1429
+
1430
+ b("<Control-c>", self._clipboard_copy)
1431
+ b("<Control-x>", self._clipboard_cut)
1432
+ b("<Control-v>", self._clipboard_paste)
1433
+ b("<Control-slash>", lambda _: self._toggle_comment())
1434
+ b("<Control-K>", lambda _: self._delete_line())
1435
+ b("<Alt-Up>", lambda _: self._move_line_up())
1436
+ b("<Alt-Down>", lambda _: self._move_line_down())
1437
+ b("<Control-f>", lambda _: self._show_find())
1438
+ b("<Control-h>", lambda _: self._show_replace())
1439
+ b("<Control-F>", lambda _: self._show_find_files())
1440
+ b("<F3>", lambda _: self._search_bar.next_match())
1441
+ b("<Shift-F3>", lambda _: self._search_bar.prev_match())
1442
+ b("<Escape>", self._on_escape)
1443
+ b("<Control-P>", lambda _: self._command_palette())
1444
+ b("<Control-p>", lambda _: self._quick_open())
1445
+ b("<Control-g>", lambda _: self._goto_line())
1446
+ b("<Control-grave>", lambda _: self._show_panel("terminal"))
1447
+ b("<F11>", lambda _: self._toggle_fullscreen())
1448
+ b("<Control-Tab>", lambda _: self._next_tab())
1449
+ b("<Control-Shift-Tab>", lambda _: self._prev_tab())
1450
+ b("<Control-Next>", lambda _: self._next_tab())
1451
+ b("<Control-Prior>", lambda _: self._prev_tab())
1452
+ b("<Control-Shift-T>", lambda _: self._reopen_closed_tab())
1453
+ for _n in range(1, 10):
1454
+ b(f"<Control-Key-{_n}>", lambda _e, n=_n: self._goto_tab_number(n))
1455
+ b("<F5>", lambda _: self._run_file())
1456
+ b("<Control-Alt-y>", lambda _: self._open_web_preview())
1457
+ b("<Shift-Alt-f>", lambda _: self._format_document())
1458
+ b("<F8>", lambda _: self._next_problem())
1459
+ b("<Shift-F8>", lambda _: self._prev_problem())
1460
+ b("<Control-equal>", lambda _: self._zoom(+1))
1461
+ b("<Control-H>", lambda _: self._open_remote_ssh())
1462
+ b("<Control-U>", lambda _: self._open_accessibility())
1463
+ b("<Control-minus>", lambda _: self._zoom(-1))
1464
+ b("<Control-0>", lambda _: self._zoom(0))
1465
+ b("<Control-Alt-equal>", lambda _: self._ui_scale_step(+1))
1466
+ b("<Control-Alt-plus>", lambda _: self._ui_scale_step(+1))
1467
+ b("<Control-Alt-minus>", lambda _: self._ui_scale_step(-1))
1468
+ b("<Control-Alt-Key-0>", lambda _: self._ui_scale_auto())
1469
+ b("<F7>", lambda _: self._next_hunk())
1470
+ b("<Shift-F7>", lambda _: self._prev_hunk())
1471
+ b("<Control-comma>", lambda _: self._activity("settings"))
1472
+ b("<Control-Shift-C>", lambda _: self._open_color_picker())
1473
+ b("<Control-Shift-R>", lambda _: self._show_panel("regex"))
1474
+ b("<Control-Shift-Q>", lambda _: self._show_panel("sql"))
1475
+ b("<Control-Shift-A>", lambda _: self._activity("ia"))
1476
+ b("<Control-Shift-N>", lambda _: self._activity("scratchpad"))
1477
+ b("<Control-Shift-J>", lambda _: self._activity("snippets"))
1478
+ b("<Control-F2>", lambda _: self._add_bookmark())
1479
+ b("<F2>", lambda _: self._next_bookmark())
1480
+ b("<Shift-F2>", lambda _: self._prev_bookmark())
1481
+ b("<Insert>", lambda _: self._toggle_overwrite_mode())
1482
+ b("<Control-Shift-V>", lambda _: self._paste_history_dialog())
1483
+ b("<Control-Shift-W>", lambda _: self._open_workspace_switcher())
1484
+ b("<Control-backslash>", lambda _: self._toggle_dual_focus())
1485
+
1486
+ # Painéis da barra lateral e do rodapé: Ctrl+Shift+<letra>
1487
+ b("<Control-Shift-E>", lambda _: self._activity("explorer"))
1488
+ b("<Control-Shift-G>", lambda _: self._activity("git"))
1489
+ b("<Control-Shift-D>", lambda _: self._activity("run"))
1490
+ b("<Control-Shift-X>", lambda _: self._activity("extensions"))
1491
+ b("<Control-Shift-B>", lambda _: self._activity("bookmarks"))
1492
+ b("<Control-Shift-M>", lambda _: self._show_panel("problems"))
1493
+ b("<Control-Shift-O>", lambda _: self._goto_symbol())
1494
+
1495
+ # Ferramentas, modos e janelas: Ctrl+Alt+<letra>
1496
+ b("<Control-Alt-l>", lambda _: self._open_chat())
1497
+ b("<Control-Alt-t>", lambda _: self._open_task_manager())
1498
+ b("<Control-Alt-w>", lambda _: self._open_time_tracker())
1499
+ b("<Control-Alt-d>", lambda _: self._open_diff())
1500
+ b("<Control-Alt-f>", lambda _: self._open_formatter())
1501
+ b("<Control-Alt-b>", lambda _: self._open_paint_panel())
1502
+ b("<Control-Alt-c>", lambda _: self._open_calculator())
1503
+ b("<Control-Alt-k>", lambda _: self._open_clock())
1504
+ b("<Control-Alt-r>", lambda _: self._open_macro_toolbar())
1505
+ b("<Control-Alt-m>", lambda _: self._toggle_multi_cursor())
1506
+ b("<Control-Alt-x>", lambda _: self._open_process_manager())
1507
+ b("<Control-Alt-z>", lambda _: self._toggle_zen_mode())