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/_app_kui.py
ADDED
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
"""Mixin ``_AppKuiMixin`` - integração da interface KUI (K-UI) no Codis.
|
|
2
|
+
|
|
3
|
+
Gerencia a ativação, configuração e comunicação entre a interface tradicional
|
|
4
|
+
Tkinter e o engine de renderização KUI.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import contextlib
|
|
10
|
+
import logging
|
|
11
|
+
import tkinter as tk
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from tkinter import messagebox
|
|
14
|
+
from typing import TYPE_CHECKING
|
|
15
|
+
|
|
16
|
+
from src.constants import FONT_UI
|
|
17
|
+
from src.editor.vim_mode import VimMode
|
|
18
|
+
from src.i18n import _t
|
|
19
|
+
from src.theme.base import THEMES
|
|
20
|
+
from src.ui.grab_safe import safe_grab_set
|
|
21
|
+
from src.ui.k_ui import KUI
|
|
22
|
+
from src.ui.zen_media import ZenMediaDialog, ZenMediaPlayer, ZenMiniOrb
|
|
23
|
+
from src.ui.zen_player import ZenPlayerHost
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
logger = logging.getLogger("Codis")
|
|
29
|
+
|
|
30
|
+
__all__ = ["_AppKuiMixin"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class _AppKuiMixin:
|
|
34
|
+
"""Mixin de Kui do CodisApp."""
|
|
35
|
+
|
|
36
|
+
def _connect_terminal_easter_eggs(self) -> None:
|
|
37
|
+
"""Conecta o terminal integrado ao sistema de easter eggs.
|
|
38
|
+
|
|
39
|
+
Deve ser chamado apos a construcao completa da UI. Vincula o handler
|
|
40
|
+
de /codis e o Konami code ao widget de input do terminal.
|
|
41
|
+
"""
|
|
42
|
+
if not self._easter_eggs:
|
|
43
|
+
return
|
|
44
|
+
term = getattr(self, "_terminal", None)
|
|
45
|
+
if term is None:
|
|
46
|
+
return
|
|
47
|
+
with contextlib.suppress(AttributeError, tk.TclError):
|
|
48
|
+
term.set_easter_egg_handler(
|
|
49
|
+
self._easter_eggs.handle_terminal_command)
|
|
50
|
+
|
|
51
|
+
self._easter_eggs.attach_terminal_konami(term._input)
|
|
52
|
+
|
|
53
|
+
def _open_zen_media_config(self) -> None:
|
|
54
|
+
"""Abre o diálogo de configuração da mídia Zen (playlist, autoplay).
|
|
55
|
+
|
|
56
|
+
Garante que o player exista antes de exibir o diálogo.
|
|
57
|
+
Após fechar reconecta o HUD caso o player tenha sido recriado.
|
|
58
|
+
"""
|
|
59
|
+
if not self._zen_media_player:
|
|
60
|
+
self._zen_media_player = ZenMediaPlayer(tk_root=self._root)
|
|
61
|
+
ZenMediaDialog(self._root, self._tmgr,
|
|
62
|
+
self._zen_media_player, self._cfg)
|
|
63
|
+
self._root.after(100, self._rewire_zen_media_callbacks)
|
|
64
|
+
|
|
65
|
+
def _zen_player_host(self) -> ZenPlayerHost | None:
|
|
66
|
+
"""Cria (uma vez) o host do Zen Player: janela flutuante ou dock."""
|
|
67
|
+
if not self._zen_media_player:
|
|
68
|
+
self._zen_media_player = ZenMediaPlayer(tk_root=self._root)
|
|
69
|
+
if self._zen_player is None:
|
|
70
|
+
self._zen_player = ZenPlayerHost(
|
|
71
|
+
self._root,
|
|
72
|
+
self._zen_media_player,
|
|
73
|
+
self._cfg,
|
|
74
|
+
self._tmgr,
|
|
75
|
+
dock_before=self._h_paned,
|
|
76
|
+
on_minimize=self._zen_media_show_orb,
|
|
77
|
+
)
|
|
78
|
+
return self._zen_player
|
|
79
|
+
|
|
80
|
+
def _toggle_zen_player(self) -> None:
|
|
81
|
+
"""Mostra/esconde o Zen Player (menu Workspace)."""
|
|
82
|
+
host = self._zen_player_host()
|
|
83
|
+
if host is None:
|
|
84
|
+
return
|
|
85
|
+
with contextlib.suppress(tk.TclError):
|
|
86
|
+
if self._zen_media_orb and self._zen_media_orb.winfo_exists():
|
|
87
|
+
self._zen_media_orb.hide()
|
|
88
|
+
host.toggle()
|
|
89
|
+
|
|
90
|
+
def _rewire_zen_media_callbacks(self) -> None:
|
|
91
|
+
"""Exibe o player após fechar o diálogo de configuração, se houver faixas."""
|
|
92
|
+
if not self._zen_media_player:
|
|
93
|
+
return
|
|
94
|
+
if self._zen_media_player.is_playing or self._zen_media_player.track_count > 0:
|
|
95
|
+
host = self._zen_player_host()
|
|
96
|
+
if host is not None:
|
|
97
|
+
host.show()
|
|
98
|
+
|
|
99
|
+
def _zen_media_autoplay(self) -> None:
|
|
100
|
+
"""Chamado ao entrar no modo Zen - inicia a reprodução se configurado.
|
|
101
|
+
|
|
102
|
+
Respeita a opção ``zen_media_autoplay`` salva na configuração.
|
|
103
|
+
"""
|
|
104
|
+
if not self._zen_media_player:
|
|
105
|
+
return
|
|
106
|
+
if self._zen_media_player.track_count > 0:
|
|
107
|
+
host = self._zen_player_host()
|
|
108
|
+
if host is not None and not host.visible:
|
|
109
|
+
host.show()
|
|
110
|
+
# Depois de mostrar o player: a superfície de vídeo já existe quando a
|
|
111
|
+
# faixa abre, e ela não precisa ser reiniciada logo em seguida.
|
|
112
|
+
if self._cfg.get("zen_media_autoplay", False):
|
|
113
|
+
self._zen_media_player.play()
|
|
114
|
+
|
|
115
|
+
def _zen_media_stop_hud(self) -> None:
|
|
116
|
+
"""Esconde a bolinha ao sair do modo Zen.
|
|
117
|
+
|
|
118
|
+
O player (janela ou dock) continua como o usuário deixou; a música
|
|
119
|
+
não é interrompida.
|
|
120
|
+
"""
|
|
121
|
+
if self._zen_media_orb and self._zen_media_orb.winfo_exists():
|
|
122
|
+
self._zen_media_orb.hide()
|
|
123
|
+
|
|
124
|
+
def _zen_media_show_orb(self) -> None:
|
|
125
|
+
"""Exibe a bolinha flutuante (ZenMiniOrb) quando o player é minimizado.
|
|
126
|
+
|
|
127
|
+
Posiciona a bolinha no canto inferior direito da tela.
|
|
128
|
+
Clicar nela chama :meth:`_zen_media_expand_hud`.
|
|
129
|
+
"""
|
|
130
|
+
if not self._zen_media_player:
|
|
131
|
+
return
|
|
132
|
+
with contextlib.suppress(tk.TclError):
|
|
133
|
+
sw = self._root.winfo_screenwidth()
|
|
134
|
+
sh = self._root.winfo_screenheight()
|
|
135
|
+
orb_size = 58
|
|
136
|
+
ox = sw - orb_size - 12
|
|
137
|
+
oy = sh - orb_size - 48
|
|
138
|
+
if not self._zen_media_orb or not self._zen_media_orb.winfo_exists():
|
|
139
|
+
self._zen_media_orb = ZenMiniOrb(
|
|
140
|
+
self._root,
|
|
141
|
+
self._zen_media_player,
|
|
142
|
+
on_expand=self._zen_media_expand_hud,
|
|
143
|
+
tmgr=self._tmgr,
|
|
144
|
+
)
|
|
145
|
+
self._zen_media_orb.move_to(ox, oy)
|
|
146
|
+
self._zen_media_orb.show()
|
|
147
|
+
|
|
148
|
+
def _zen_media_expand_hud(self) -> None:
|
|
149
|
+
"""Expande da bolinha de volta para o player."""
|
|
150
|
+
with contextlib.suppress(tk.TclError):
|
|
151
|
+
if self._zen_media_orb and self._zen_media_orb.winfo_exists():
|
|
152
|
+
self._zen_media_orb.hide()
|
|
153
|
+
host = self._zen_player_host()
|
|
154
|
+
if host is not None:
|
|
155
|
+
host.show()
|
|
156
|
+
|
|
157
|
+
def _toggle_vim_mode(self) -> None:
|
|
158
|
+
"""Alterna o modo Vim."""
|
|
159
|
+
if self._vim_enabled:
|
|
160
|
+
self._disable_vim_mode()
|
|
161
|
+
else:
|
|
162
|
+
self._enable_vim_mode()
|
|
163
|
+
|
|
164
|
+
def _enable_vim_mode(self) -> None:
|
|
165
|
+
"""Ativa o modo Vim no editor ativo."""
|
|
166
|
+
if self._kui_enabled:
|
|
167
|
+
self._disable_kui()
|
|
168
|
+
|
|
169
|
+
ed = self._e()
|
|
170
|
+
if not ed:
|
|
171
|
+
self._vim_enabled = True
|
|
172
|
+
self._cfg.set("vim_mode", True)
|
|
173
|
+
self._status.notify(_t("kui.vim_mode_on"))
|
|
174
|
+
return
|
|
175
|
+
self._vim_enabled = True
|
|
176
|
+
self._cfg.set("vim_mode", True)
|
|
177
|
+
self._cfg.save()
|
|
178
|
+
|
|
179
|
+
def on_mode_change(mode: str, cmd: str = "") -> None:
|
|
180
|
+
"""Atualiza a status bar e o K-UI com o modo Vim atual."""
|
|
181
|
+
mode_icons = {
|
|
182
|
+
"NORMAL": "⬛ NORMAL",
|
|
183
|
+
"INSERT": "▮ INSERT",
|
|
184
|
+
"VISUAL": "█ VISUAL",
|
|
185
|
+
"V-LINE": "█ V-LINE",
|
|
186
|
+
"REPLACE": "░ REPLACE",
|
|
187
|
+
"COMMAND": f":{cmd}",
|
|
188
|
+
}
|
|
189
|
+
label = mode_icons.get(mode, mode)
|
|
190
|
+
self._status.notify(f"⌨ Vim {label}")
|
|
191
|
+
if self._kui:
|
|
192
|
+
self._kui.set_vim_mode(mode, cmd)
|
|
193
|
+
|
|
194
|
+
self._vim_mode = VimMode(
|
|
195
|
+
ed,
|
|
196
|
+
on_mode_change,
|
|
197
|
+
quit_cb=self._disable_vim_mode,
|
|
198
|
+
save_cb=self.save_file,
|
|
199
|
+
)
|
|
200
|
+
self._vim_mode.enable()
|
|
201
|
+
|
|
202
|
+
with contextlib.suppress(tk.TclError):
|
|
203
|
+
if self._kui:
|
|
204
|
+
self._kui.toast(
|
|
205
|
+
"⌨ Vim activated - i insert Esc normal :q quit",
|
|
206
|
+
kind="info",
|
|
207
|
+
duration_ms=4000,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
def _disable_vim_mode(self) -> None:
|
|
211
|
+
"""Desativa o modo Vim."""
|
|
212
|
+
self._vim_enabled = False
|
|
213
|
+
self._cfg.set("vim_mode", False)
|
|
214
|
+
self._cfg.save()
|
|
215
|
+
if self._vim_mode:
|
|
216
|
+
self._vim_mode.disable()
|
|
217
|
+
self._vim_mode = None
|
|
218
|
+
self._status.notify(_t("kui.vim_mode_off"))
|
|
219
|
+
|
|
220
|
+
def _toggle_kui(self) -> None:
|
|
221
|
+
"""Alterna a interface K-UI."""
|
|
222
|
+
if self._kui_enabled:
|
|
223
|
+
self._disable_kui()
|
|
224
|
+
else:
|
|
225
|
+
self._enable_kui()
|
|
226
|
+
|
|
227
|
+
def _enable_kui(self) -> None:
|
|
228
|
+
"""Ativa a interface K-UI (idempotente: a partida a agenda mais de uma vez)."""
|
|
229
|
+
if self._kui is not None and getattr(self._kui, "_enabled", False):
|
|
230
|
+
return
|
|
231
|
+
if self._vim_enabled:
|
|
232
|
+
self._disable_vim_mode()
|
|
233
|
+
|
|
234
|
+
self._kui_enabled = True
|
|
235
|
+
self._cfg.set("kui_enabled", True)
|
|
236
|
+
self._cfg.save()
|
|
237
|
+
|
|
238
|
+
commands = [
|
|
239
|
+
("📄", _t("kui.cmd.new_file"), self.new_file),
|
|
240
|
+
("📂", _t("kui.cmd.open_file"), self.open_file_dialog),
|
|
241
|
+
("🗂", _t("kui.cmd.open_folder"), self.open_folder_dialog),
|
|
242
|
+
("💾", _t("kui.cmd.save"), self.save_file),
|
|
243
|
+
("💾", _t("kui.cmd.save_as"), self.save_as),
|
|
244
|
+
("💾", _t("kui.cmd.save_all"), self.save_all),
|
|
245
|
+
("🔁", _t("kui.cmd.revert"), self.revert_file),
|
|
246
|
+
("✕", _t("kui.cmd.close_tab"), self._close_active_tab),
|
|
247
|
+
("✕", _t("kui.cmd.close_all_tabs"), self._close_all_tabs),
|
|
248
|
+
("↩", _t("edit.undo"), self._undo),
|
|
249
|
+
("↪", _t("edit.redo"), self._redo),
|
|
250
|
+
("✂", _t("edit.cut"), self._cut),
|
|
251
|
+
("📋", _t("edit.copy"), self._copy),
|
|
252
|
+
("📋", _t("edit.paste"), self._paste),
|
|
253
|
+
("🔲", _t("edit.select_all"), self._select_all),
|
|
254
|
+
("🔍", _t("kui.cmd.find"), self._show_find),
|
|
255
|
+
("🔍", _t("kui.cmd.find_replace"), self._show_replace),
|
|
256
|
+
("🔍", _t("kui.cmd.find_files"), self._show_find_files),
|
|
257
|
+
("💬", _t("edit.toggle_comment"), self._toggle_comment),
|
|
258
|
+
("📋", _t("edit.duplicate_line"), self._duplicate_line),
|
|
259
|
+
("🗑", _t("edit.delete_line"), self._delete_line),
|
|
260
|
+
("⬆", _t("edit.move_line_up"), self._move_line_up),
|
|
261
|
+
("⬇", _t("edit.move_line_down"), self._move_line_down),
|
|
262
|
+
("🔀", _t("kui.cmd.sort_asc"), lambda: self._sort_lines(False)),
|
|
263
|
+
("🔀", _t("kui.cmd.sort_desc"), lambda: self._sort_lines(True)),
|
|
264
|
+
("✂", _t("edit.trim_trailing"), self._trim_trailing),
|
|
265
|
+
("🗑", _t("edit.remove_dupes"), self._remove_duplicate_lines),
|
|
266
|
+
("📋", _t("edit.paste_history"), self._paste_history_dialog),
|
|
267
|
+
("▶", _t("run.run_file"), self._run_file),
|
|
268
|
+
("F", _t("run.format_document"), self._format_document),
|
|
269
|
+
("🔍", _t("kui.cmd.lint"), self._lint_file),
|
|
270
|
+
("🔧", _t("kui.cmd.fix_all"), self._fix_all),
|
|
271
|
+
("T", _t("kui.cmd.theme"), self._show_theme_picker),
|
|
272
|
+
("✦", _t("kui.cmd.disable"), self._disable_kui),
|
|
273
|
+
("P", _t("kui.cmd.perf"), self._show_kui_perf_picker),
|
|
274
|
+
("👁", _t("kui.cmd.word_wrap"), self._toggle_word_wrap),
|
|
275
|
+
("🗺", _t("kui.cmd.minimap"), self._toggle_minimap),
|
|
276
|
+
("🔲", _t("kui.cmd.breadcrumbs"), self._toggle_breadcrumbs),
|
|
277
|
+
("🔍", _t("kui.cmd.zoom_in"), lambda: self._zoom(+1)),
|
|
278
|
+
("🔍", _t("kui.cmd.zoom_out"), lambda: self._zoom(-1)),
|
|
279
|
+
("🔲", _t("kui.cmd.zoom_reset"), lambda: self._zoom(0)),
|
|
280
|
+
("🖥", _t("kui.cmd.fullscreen"), self._toggle_fullscreen),
|
|
281
|
+
("📐", _t("kui.cmd.split"), self._split_editor),
|
|
282
|
+
("🏠", _t("kui.cmd.welcome"), self._show_welcome),
|
|
283
|
+
("G", _t("kui.cmd.goto_line"), self._goto_line),
|
|
284
|
+
("S", _t("kui.cmd.goto_symbol"), self._goto_symbol),
|
|
285
|
+
("⚠", _t("kui.cmd.next_problem"), self._next_problem),
|
|
286
|
+
("⚠", _t("kui.cmd.prev_problem"), self._prev_problem),
|
|
287
|
+
("➡", _t("kui.cmd.next_tab"), self._next_tab),
|
|
288
|
+
("⬅", _t("kui.cmd.prev_tab"), self._prev_tab),
|
|
289
|
+
("⚠", _t("kui.cmd.problems"), lambda: self._show_panel("problems")),
|
|
290
|
+
("🖥", _t("kui.cmd.terminal"), lambda: self._show_panel("terminal")),
|
|
291
|
+
("📤", _t("kui.cmd.output"), lambda: self._show_panel("output")),
|
|
292
|
+
("📤", _t("kui.cmd.git_panel"), lambda: self._show_panel("git")),
|
|
293
|
+
("D", _t("kui.cmd.diff"), lambda: self._show_panel("diff")),
|
|
294
|
+
("🐛", _t("kui.cmd.debug"), lambda: self._show_panel("debug")),
|
|
295
|
+
("⑆", _t("kui.cmd.regex"), lambda: self._show_panel("regex")),
|
|
296
|
+
("🖥", _t("kui.cmd.new_terminal"), self._new_terminal),
|
|
297
|
+
("📁", _t("kui.cmd.explorer"), lambda: self._activity("explorer")),
|
|
298
|
+
("🔍", _t("kui.cmd.search"), lambda: self._activity("search")),
|
|
299
|
+
("🌿", _t("kui.cmd.source_ctrl"), lambda: self._activity("git")),
|
|
300
|
+
("🔌", _t("kui.cmd.extensions"), lambda: self._activity("extensions")),
|
|
301
|
+
("📝", _t("kui.cmd.outline"), lambda: self._activity("outline")),
|
|
302
|
+
("🔖", _t("kui.cmd.bookmarks"), lambda: self._activity("bookmarks")),
|
|
303
|
+
("📝", _t("kui.cmd.scratchpad"), lambda: self._activity("scratchpad")),
|
|
304
|
+
("📊", _t("kui.cmd.stats"), lambda: self._activity("codestats")),
|
|
305
|
+
("✅", _t("kui.cmd.todo"), lambda: self._activity("todo")),
|
|
306
|
+
("🌍", _t("kui.cmd.rest"), lambda: self._activity("restclient")),
|
|
307
|
+
("🌐", _t("kui.cmd.preview"), lambda: self._activity("preview")),
|
|
308
|
+
("⏱", _t("kui.cmd.pomodoro"), lambda: self._activity("pomodoro")),
|
|
309
|
+
("✂", _t("kui.cmd.snippets"), lambda: self._activity("snippets")),
|
|
310
|
+
("🔀", _t("kui.cmd.flowchart"), lambda: self._activity("flowchart")),
|
|
311
|
+
("C", _t("kui.cmd.color_picker"), self._open_color_picker),
|
|
312
|
+
("📝", _t("kui.cmd.session_notes"), self._open_session_notes),
|
|
313
|
+
("🔖", _t("kui.cmd.bookmark_add"), self._add_bookmark),
|
|
314
|
+
("🕒", _t("kui.cmd.file_timeline"), self._open_file_timeline),
|
|
315
|
+
("📊", _t("kui.cmd.word_count"), self._word_count_dialog),
|
|
316
|
+
("🔑", _t("kui.cmd.base64_enc"), self._base64_encode),
|
|
317
|
+
("🔑", _t("kui.cmd.base64_dec"), self._base64_decode),
|
|
318
|
+
("🔗", _t("kui.cmd.url_enc"), self._url_encode),
|
|
319
|
+
("🔗", _t("kui.cmd.url_dec"), self._url_decode),
|
|
320
|
+
("🔐", _t("kui.cmd.hash_md5"), lambda: self._hash_selection("md5")),
|
|
321
|
+
("🔐", _t("kui.cmd.hash_sha256"),
|
|
322
|
+
lambda: self._hash_selection("sha256")),
|
|
323
|
+
("🔢", _t("kui.cmd.insert_seq"), self._insert_sequence_dialog),
|
|
324
|
+
("D", _t("kui.cmd.diff_file"), self._show_file_diff),
|
|
325
|
+
("D", _t("kui.cmd.diff_two"), self._show_diff_two_files),
|
|
326
|
+
("🎵", _t("kui.cmd.zen_media"), self._open_zen_media_config),
|
|
327
|
+
("⌨", _t("kui.cmd.vim"), self._toggle_vim_mode),
|
|
328
|
+
("🌌", _t("kui.cmd.zen"), self._toggle_zen_mode),
|
|
329
|
+
("👁", _t("kui.cmd.focus_mode"), self._toggle_focus_mode),
|
|
330
|
+
("🔒", _t("kui.cmd.read_only"), self._toggle_read_only),
|
|
331
|
+
(
|
|
332
|
+
"🔍",
|
|
333
|
+
_t("kui.cmd.lsp_goto_def"),
|
|
334
|
+
lambda: self._e().lsp_goto_definition() if self._e() else None,
|
|
335
|
+
),
|
|
336
|
+
(
|
|
337
|
+
"🔗",
|
|
338
|
+
_t("kui.cmd.lsp_refs"),
|
|
339
|
+
lambda: self._e().lsp_find_references() if self._e() else None,
|
|
340
|
+
),
|
|
341
|
+
(
|
|
342
|
+
"✏",
|
|
343
|
+
_t("kui.cmd.lsp_rename"),
|
|
344
|
+
lambda: self._e().lsp_rename_symbol() if self._e() else None,
|
|
345
|
+
),
|
|
346
|
+
("⊞", _t("kui.detach.terminal"),
|
|
347
|
+
lambda: self._detach_panel("terminal")),
|
|
348
|
+
("⊞", _t("kui.detach.output"), lambda: self._detach_panel("output")),
|
|
349
|
+
("⊞", _t("kui.detach.git"), lambda: self._detach_panel("git")),
|
|
350
|
+
("⊞", _t("kui.detach.debug"), lambda: self._detach_panel("debug")),
|
|
351
|
+
("⊞", _t("kui.detach.regex"), lambda: self._detach_panel("regex")),
|
|
352
|
+
("⊞", _t("kui.detach.problems"),
|
|
353
|
+
lambda: self._detach_panel("problems")),
|
|
354
|
+
("📌", _t("kui.cmd.float_sidebar"), self._kui_toggle_sidebar),
|
|
355
|
+
("⚙", _t("kui.cmd.settings"), self._show_settings),
|
|
356
|
+
("❓", _t("kui.cmd.keybindings"), self._keybindings_dialog),
|
|
357
|
+
("ℹ", _t("kui.cmd.about"), self._about_dialog),
|
|
358
|
+
("📦", _t("kui.cmd.plugins_manage"),
|
|
359
|
+
lambda: self._activity("extensions")),
|
|
360
|
+
("🔄", _t("kui.cmd.plugins_reload"), self._load_plugins),
|
|
361
|
+
]
|
|
362
|
+
|
|
363
|
+
ribbon_actions = [
|
|
364
|
+
(
|
|
365
|
+
"F",
|
|
366
|
+
_t("kui.cmd.format"),
|
|
367
|
+
lambda: self._e().format_document() if self._e() else None,
|
|
368
|
+
),
|
|
369
|
+
(
|
|
370
|
+
"💬",
|
|
371
|
+
_t("edit.toggle_comment"),
|
|
372
|
+
lambda: (
|
|
373
|
+
self._toggle_comment() if hasattr(self, "_toggle_comment") else None
|
|
374
|
+
),
|
|
375
|
+
),
|
|
376
|
+
("🔍", _t("kui.cmd.find"), self._show_find),
|
|
377
|
+
("📋", _t("edit.copy"), self._copy),
|
|
378
|
+
("📌", _t("kui.cmd.bookmark_add"), self._add_bookmark),
|
|
379
|
+
]
|
|
380
|
+
|
|
381
|
+
with contextlib.suppress(AttributeError, tk.TclError):
|
|
382
|
+
self._panel_detach.set_factories(self._build_panel_factories())
|
|
383
|
+
self._panel_detach.set_dark(
|
|
384
|
+
getattr(self._tmgr.theme, "dark", True))
|
|
385
|
+
|
|
386
|
+
self._kui = KUI(
|
|
387
|
+
self._root,
|
|
388
|
+
self._tmgr,
|
|
389
|
+
self._e,
|
|
390
|
+
commands,
|
|
391
|
+
ribbon_actions,
|
|
392
|
+
hide_sidebar_cb=self._hide_sidebar,
|
|
393
|
+
show_sidebar_cb=self._show_sidebar,
|
|
394
|
+
_hide_activity_cb=lambda: [
|
|
395
|
+
self._h_paned.paneconfigure(self._actbar, minsize=0, width=0),
|
|
396
|
+
self._h_paned.sash_place(0, 0, 0),
|
|
397
|
+
],
|
|
398
|
+
_show_activity_cb=lambda: [
|
|
399
|
+
self._h_paned.paneconfigure(
|
|
400
|
+
self._actbar, minsize=48, width=48),
|
|
401
|
+
self._h_paned.sash_place(0, 48, 0),
|
|
402
|
+
],
|
|
403
|
+
tabbar_widget=getattr(self, "_tabbar", None),
|
|
404
|
+
breadcrumb_widget=getattr(self, "_breadcrumb", None),
|
|
405
|
+
statusbar_widget=getattr(self, "_status", None),
|
|
406
|
+
menubar_ref=getattr(self, "_menubar", None),
|
|
407
|
+
content_frame=getattr(self, "_content_frame", None),
|
|
408
|
+
editor_container=getattr(self, "_editor_container", None),
|
|
409
|
+
h_paned=getattr(self, "_h_paned", None),
|
|
410
|
+
v_paned=getattr(self, "_v_paned", None),
|
|
411
|
+
hide_bottom_cb=self._hide_bottom_panel,
|
|
412
|
+
show_bottom_cb=self._show_bottom_panel,
|
|
413
|
+
sidebar_dock=getattr(self, "_dock", None),
|
|
414
|
+
is_sidebar_visible=lambda: self._sidebar_visible,
|
|
415
|
+
show_welcome_cb=self._show_welcome,
|
|
416
|
+
hide_classic_welcome_cb=self._hide_classic_welcome,
|
|
417
|
+
actbar_widget=getattr(self, "_actbar", None),
|
|
418
|
+
panel_factories=self._build_panel_factories(),
|
|
419
|
+
perf_profile=self._cfg.get("kui_perf", "balanced"),
|
|
420
|
+
detach_manager=getattr(self, "_panel_detach", None),
|
|
421
|
+
)
|
|
422
|
+
self._kui.enable()
|
|
423
|
+
|
|
424
|
+
with contextlib.suppress(tk.TclError):
|
|
425
|
+
if hasattr(self, "_detach_btn"):
|
|
426
|
+
self._detach_btn.pack(
|
|
427
|
+
side="right", padx=(0, 2), before=self._panel_tabs.get("problems")
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
recent = [str(p) for p in self._cfg.get_recent_files()[:12]]
|
|
431
|
+
self._kui.show_welcome(
|
|
432
|
+
on_new=self.new_file,
|
|
433
|
+
on_open=self.open_file_dialog,
|
|
434
|
+
on_folder=self.open_folder_dialog,
|
|
435
|
+
on_recent=self._open_file,
|
|
436
|
+
recent_files=recent,
|
|
437
|
+
)
|
|
438
|
+
|
|
439
|
+
self._apply_kui_colors()
|
|
440
|
+
self._status.notify(_t("kui.enabled"))
|
|
441
|
+
|
|
442
|
+
self._root.bind("<<KUITabSelect>>", self._on_kui_tab_select, add=True)
|
|
443
|
+
self._root.bind("<<KUITabClose>>", self._on_kui_tab_close, add=True)
|
|
444
|
+
self._root.bind("<<KUITabDual>>", self._on_kui_tab_dual, add=True)
|
|
445
|
+
|
|
446
|
+
def _apply_kui_colors(self) -> None:
|
|
447
|
+
"""Pinta frames com void após ativar K-UI (preserva sashwidth=4).
|
|
448
|
+
|
|
449
|
+
Usa _pal() do K-UI, que retorna void escuro em ambos os modos
|
|
450
|
+
(dark=#020209, light=#0d0d2b), em vez de ``t.bg``.
|
|
451
|
+
"""
|
|
452
|
+
from src.ui.k_ui import _pal as _kui_pal
|
|
453
|
+
|
|
454
|
+
t = self._tmgr.theme
|
|
455
|
+
p = _kui_pal(getattr(t, "dark", True))
|
|
456
|
+
void = p["void"]
|
|
457
|
+
editor_bg = p["text_bg"]
|
|
458
|
+
editor_fg = p["text_fg"]
|
|
459
|
+
cursor = p["text_cur"]
|
|
460
|
+
sel_bg = p["text_sel"]
|
|
461
|
+
sel_fg = p["text_fg"]
|
|
462
|
+
|
|
463
|
+
with contextlib.suppress(tk.TclError):
|
|
464
|
+
self._root.config(bg=void)
|
|
465
|
+
|
|
466
|
+
for pw in (getattr(self, "_h_paned", None), getattr(self, "_v_paned", None)):
|
|
467
|
+
if pw:
|
|
468
|
+
with contextlib.suppress(tk.TclError):
|
|
469
|
+
pw.config(bg=void)
|
|
470
|
+
|
|
471
|
+
for attr in (
|
|
472
|
+
"_content_frame",
|
|
473
|
+
"_editor_container",
|
|
474
|
+
"_sidebar",
|
|
475
|
+
"_sidebar_stack",
|
|
476
|
+
"_bottom_frame",
|
|
477
|
+
"_panel_content",
|
|
478
|
+
):
|
|
479
|
+
w = getattr(self, attr, None)
|
|
480
|
+
if w:
|
|
481
|
+
with contextlib.suppress(tk.TclError):
|
|
482
|
+
w.config(bg=void)
|
|
483
|
+
|
|
484
|
+
for e in self._editors:
|
|
485
|
+
with contextlib.suppress(tk.TclError):
|
|
486
|
+
e.text.config(
|
|
487
|
+
bg=editor_bg,
|
|
488
|
+
fg=editor_fg,
|
|
489
|
+
insertbackground=cursor,
|
|
490
|
+
selectbackground=sel_bg,
|
|
491
|
+
selectforeground=sel_fg,
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
def _detach_panel(self, panel_key: str) -> None:
|
|
495
|
+
"""Destaca um painel inferior para uma janela flutuante.
|
|
496
|
+
|
|
497
|
+
Funciona tanto no modo clássico quanto no modo K-UI,
|
|
498
|
+
delegando ao ``PanelDetachManager`` compartilhado do ``CodisApp``.
|
|
499
|
+
"""
|
|
500
|
+
with contextlib.suppress(AttributeError, tk.TclError):
|
|
501
|
+
self._panel_detach.detach(panel_key)
|
|
502
|
+
|
|
503
|
+
def _kui_toggle_sidebar(self) -> None:
|
|
504
|
+
"""Alterna a K-UI Dock (apenas modo K-UI)."""
|
|
505
|
+
if self._kui:
|
|
506
|
+
with contextlib.suppress(tk.TclError):
|
|
507
|
+
self._kui.toggle_sidebar()
|
|
508
|
+
|
|
509
|
+
def _build_panel_factories(self) -> dict:
|
|
510
|
+
"""Constrói fábricas para cada painel destacável.
|
|
511
|
+
|
|
512
|
+
Importante: o ``cwd`` do terminal é resolvido dentro do lambda (no
|
|
513
|
+
momento do detach), não aqui, porque esta função é chamada uma
|
|
514
|
+
única vez na inicialização do app (para alimentar o
|
|
515
|
+
``PanelDetachManager`` compartilhado) - usar ``self._workspace`` no
|
|
516
|
+
corpo do lambda garante que sempre reflita a pasta aberta mais
|
|
517
|
+
recente, mesmo que tenha mudado depois da construção das fábricas.
|
|
518
|
+
"""
|
|
519
|
+
factories: dict = {}
|
|
520
|
+
|
|
521
|
+
with contextlib.suppress(tk.TclError):
|
|
522
|
+
from src.ui.terminal import TerminalPanel as _TerminalPanel
|
|
523
|
+
|
|
524
|
+
factories["terminal"] = lambda parent: _TerminalPanel(
|
|
525
|
+
parent,
|
|
526
|
+
self._tmgr,
|
|
527
|
+
self._cfg,
|
|
528
|
+
cwd=str(self._workspace) if self._workspace else str(
|
|
529
|
+
Path.home()),
|
|
530
|
+
app=self,
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
with contextlib.suppress(tk.TclError):
|
|
534
|
+
from src.ui.output_panel import OutputPanel as _OutputPanel
|
|
535
|
+
|
|
536
|
+
factories["output"] = lambda parent: _OutputPanel(
|
|
537
|
+
parent, self._tmgr, self._cfg
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
with contextlib.suppress(tk.TclError):
|
|
541
|
+
from src.ui.git_panel import GitPanel as _GitPanel
|
|
542
|
+
|
|
543
|
+
factories["git"] = lambda parent: _GitPanel(
|
|
544
|
+
parent,
|
|
545
|
+
self._tmgr,
|
|
546
|
+
self._cfg,
|
|
547
|
+
root_path=self._workspace,
|
|
548
|
+
on_refresh=self._on_git_refresh,
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
with contextlib.suppress(tk.TclError):
|
|
552
|
+
from src.ui.debug_panel import DebugPanel as _DebugPanel
|
|
553
|
+
|
|
554
|
+
factories["debug"] = lambda parent: _DebugPanel(
|
|
555
|
+
parent, self._tmgr, self._cfg, get_editor=self._active_editor
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
with contextlib.suppress(tk.TclError):
|
|
559
|
+
from src.ui.regex_playground import RegexPlayground as _RegexPlayground
|
|
560
|
+
|
|
561
|
+
factories["regex"] = lambda parent: _RegexPlayground(
|
|
562
|
+
parent,
|
|
563
|
+
self._tmgr,
|
|
564
|
+
get_text=lambda: self._e().get_content() if self._e() else "",
|
|
565
|
+
apply_replace=self._regex_replace,
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
with contextlib.suppress(tk.TclError):
|
|
569
|
+
from src.ui.problems import ProblemsPanel as _ProblemsPanel
|
|
570
|
+
|
|
571
|
+
factories["problems"] = lambda parent: _ProblemsPanel(
|
|
572
|
+
parent,
|
|
573
|
+
self._tmgr,
|
|
574
|
+
on_goto=self._goto_problem_pos,
|
|
575
|
+
on_apply_fix=self._apply_problem_fix,
|
|
576
|
+
on_fix_all=self._apply_problem_fix_all,
|
|
577
|
+
)
|
|
578
|
+
|
|
579
|
+
with contextlib.suppress(tk.TclError):
|
|
580
|
+
from src.editor.diff_pane import DiffPane as _DiffPane
|
|
581
|
+
|
|
582
|
+
def _make_diff_panel(parent: tk.Widget) -> _DiffPane:
|
|
583
|
+
"""Cria uma DiffPane flutuante pré-carregada com o diff atual.
|
|
584
|
+
|
|
585
|
+
O DiffPane embutido (``self._diff_pane``) é alimentado por
|
|
586
|
+
chamadas externas (ex.: comparar arquivos, ver diff do git) e
|
|
587
|
+
não por uma fábrica - então, ao destacar, copiamos o estado
|
|
588
|
+
que ele já tem (original/modified/nomes) para a nova janela
|
|
589
|
+
flutuante em vez de abrir algo vazio.
|
|
590
|
+
"""
|
|
591
|
+
dp = _DiffPane(
|
|
592
|
+
parent,
|
|
593
|
+
self._tmgr,
|
|
594
|
+
self._cfg,
|
|
595
|
+
on_close=lambda: self._panel_detach.reattach("diff"),
|
|
596
|
+
)
|
|
597
|
+
src = getattr(self, "_diff_pane", None)
|
|
598
|
+
if src is not None:
|
|
599
|
+
with contextlib.suppress(tk.TclError):
|
|
600
|
+
dp.show(
|
|
601
|
+
getattr(src, "_original", ""),
|
|
602
|
+
getattr(src, "_modified", ""),
|
|
603
|
+
getattr(src, "_orig_name", ""),
|
|
604
|
+
getattr(src, "_mod_name", ""),
|
|
605
|
+
)
|
|
606
|
+
return dp
|
|
607
|
+
|
|
608
|
+
factories["diff"] = _make_diff_panel
|
|
609
|
+
|
|
610
|
+
try:
|
|
611
|
+
from src.ui.sql_studio import SQLStudioPanel as _SQLStudioPanel
|
|
612
|
+
|
|
613
|
+
factories["sql"] = lambda parent: _SQLStudioPanel(
|
|
614
|
+
parent, self._tmgr, self._cfg
|
|
615
|
+
)
|
|
616
|
+
except Exception as exc:
|
|
617
|
+
logger.debug("SQL Studio indisponível para detach: %s", exc)
|
|
618
|
+
|
|
619
|
+
return factories
|
|
620
|
+
|
|
621
|
+
def _disable_kui(self) -> None:
|
|
622
|
+
"""Desativa a interface K-UI e restaura as cores do tema atual."""
|
|
623
|
+
self._kui_enabled = False
|
|
624
|
+
self._cfg.set("kui_enabled", False)
|
|
625
|
+
self._cfg.save()
|
|
626
|
+
if self._kui:
|
|
627
|
+
self._kui.disable()
|
|
628
|
+
self._kui = None
|
|
629
|
+
|
|
630
|
+
with contextlib.suppress(tk.TclError):
|
|
631
|
+
self._root.unbind("<<KUITabSelect>>")
|
|
632
|
+
with contextlib.suppress(tk.TclError):
|
|
633
|
+
self._root.unbind("<<KUITabClose>>")
|
|
634
|
+
with contextlib.suppress(tk.TclError):
|
|
635
|
+
self._root.unbind("<<KUITabDual>>")
|
|
636
|
+
|
|
637
|
+
with contextlib.suppress(Exception):
|
|
638
|
+
self._on_theme_change(self._tmgr.theme)
|
|
639
|
+
|
|
640
|
+
self._status.notify(_t("kui.disabled"))
|
|
641
|
+
if not self._editors:
|
|
642
|
+
self._show_welcome()
|
|
643
|
+
|
|
644
|
+
def _on_kui_tab_select(self, _event: tk.Event) -> None:
|
|
645
|
+
"""Handler do evento <<KUITabSelect>> disparado pela KTabBar holográfica."""
|
|
646
|
+
if not self._kui:
|
|
647
|
+
return
|
|
648
|
+
action = getattr(self._kui, "_last_tab_action", None)
|
|
649
|
+
if not isinstance(action, tuple) or action[0] != "select":
|
|
650
|
+
return
|
|
651
|
+
idx = int(action[1])
|
|
652
|
+
self._kui._last_tab_action = None
|
|
653
|
+
open_files = getattr(self._kui, "_open_files", [])
|
|
654
|
+
if not 0 <= idx < len(open_files):
|
|
655
|
+
return
|
|
656
|
+
target_path = open_files[idx]
|
|
657
|
+
with contextlib.suppress(OSError):
|
|
658
|
+
existing = self._find_editor_for_path(Path(target_path))
|
|
659
|
+
if existing is not None:
|
|
660
|
+
self._select_tab(existing)
|
|
661
|
+
else:
|
|
662
|
+
self._open_file(target_path)
|
|
663
|
+
|
|
664
|
+
def _on_kui_tab_close(self, _event: tk.Event) -> None:
|
|
665
|
+
"""Handler do evento <<KUITabClose>> disparado pela KTabBar holográfica."""
|
|
666
|
+
if not self._kui:
|
|
667
|
+
return
|
|
668
|
+
action = getattr(self._kui, "_last_tab_action", None)
|
|
669
|
+
if not isinstance(action, tuple) or action[0] != "close":
|
|
670
|
+
return
|
|
671
|
+
idx = int(action[1])
|
|
672
|
+
self._kui._last_tab_action = None
|
|
673
|
+
open_files = getattr(self._kui, "_open_files", [])
|
|
674
|
+
if not 0 <= idx < len(open_files):
|
|
675
|
+
self._close_active_tab()
|
|
676
|
+
return
|
|
677
|
+
with contextlib.suppress(OSError):
|
|
678
|
+
existing = self._find_editor_for_path(Path(open_files[idx]))
|
|
679
|
+
if existing is not None:
|
|
680
|
+
self._close_tab(existing)
|
|
681
|
+
else:
|
|
682
|
+
self._close_active_tab()
|
|
683
|
+
|
|
684
|
+
def _on_kui_tab_dual(self, _event: tk.Event) -> None:
|
|
685
|
+
"""Handler do evento <<KUITabDual>> disparado pela KTabBar holográfica.
|
|
686
|
+
|
|
687
|
+
Abre a aba selecionada no lado direito do modo dual.
|
|
688
|
+
"""
|
|
689
|
+
if not self._kui:
|
|
690
|
+
return
|
|
691
|
+
action = getattr(self._kui, "_last_tab_action", None)
|
|
692
|
+
if not isinstance(action, tuple) or action[0] != "dual":
|
|
693
|
+
return
|
|
694
|
+
idx = int(action[1])
|
|
695
|
+
self._kui._last_tab_action = None
|
|
696
|
+
open_files = getattr(self._kui, "_open_files", [])
|
|
697
|
+
if 0 <= idx < len(open_files):
|
|
698
|
+
path = Path(open_files[idx])
|
|
699
|
+
self._split_tab_to_right(self._find_editor_for_path(path) or idx)
|
|
700
|
+
else:
|
|
701
|
+
self._split_editor()
|
|
702
|
+
|
|
703
|
+
def _show_kui_perf_picker(self) -> None:
|
|
704
|
+
"""Abre o seletor de perfil de performance da K-UI.
|
|
705
|
+
|
|
706
|
+
Modos ultra e quantum exibem diálogo de confirmação, pois podem
|
|
707
|
+
consumir bastante CPU devido aos cálculos e renderização intensivos.
|
|
708
|
+
"""
|
|
709
|
+
t = self._tmgr.theme
|
|
710
|
+
dlg = tk.Toplevel(self._root)
|
|
711
|
+
dlg.title(_t("ui.kui_perf_title"))
|
|
712
|
+
dlg.configure(bg=t.floating_bg)
|
|
713
|
+
dlg.transient(self._root)
|
|
714
|
+
dlg.resizable(False, False)
|
|
715
|
+
with contextlib.suppress(tk.TclError):
|
|
716
|
+
safe_grab_set(dlg)
|
|
717
|
+
|
|
718
|
+
current = self._cfg.get("kui_perf", "balanced")
|
|
719
|
+
|
|
720
|
+
labels = {
|
|
721
|
+
"quantum": "🌌 " + _t("kui.perf.quantum"),
|
|
722
|
+
"ultra": "🌌 " + _t("kui.perf.ultra"),
|
|
723
|
+
"balanced": "⚖️ " + _t("kui.perf.balanced"),
|
|
724
|
+
"power_saver": "🔋 " + _t("kui.perf.power_saver"),
|
|
725
|
+
"minimal": _t("kui.perf.minimal"),
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
tk.Label(
|
|
729
|
+
dlg,
|
|
730
|
+
text=_t("ui.kui_perf_header"),
|
|
731
|
+
bg=t.floating_bg,
|
|
732
|
+
fg=t.fg,
|
|
733
|
+
font=(FONT_UI, 11, "bold"),
|
|
734
|
+
anchor="w",
|
|
735
|
+
pady=8,
|
|
736
|
+
).pack(fill="x", padx=12)
|
|
737
|
+
|
|
738
|
+
var = tk.StringVar(value=current)
|
|
739
|
+
for key, label in labels.items():
|
|
740
|
+
rb = tk.Radiobutton(
|
|
741
|
+
dlg,
|
|
742
|
+
text=label,
|
|
743
|
+
variable=var,
|
|
744
|
+
value=key,
|
|
745
|
+
bg=t.floating_bg,
|
|
746
|
+
fg=t.fg,
|
|
747
|
+
selectcolor=t.input_bg,
|
|
748
|
+
activebackground=t.btn_hover,
|
|
749
|
+
activeforeground=t.fg,
|
|
750
|
+
anchor="w",
|
|
751
|
+
padx=16,
|
|
752
|
+
pady=4,
|
|
753
|
+
font=(FONT_UI, 10),
|
|
754
|
+
)
|
|
755
|
+
rb.pack(fill="x")
|
|
756
|
+
|
|
757
|
+
def _apply() -> None:
|
|
758
|
+
"""Aplica o perfil escolhido com confirmação obrigatória para ultra/quantum."""
|
|
759
|
+
profile = var.get()
|
|
760
|
+
|
|
761
|
+
if profile in ("ultra", "quantum"):
|
|
762
|
+
msg_key = (
|
|
763
|
+
"kui.confirm.quantum_msg"
|
|
764
|
+
if profile == "quantum"
|
|
765
|
+
else "kui.confirm.ultra_msg"
|
|
766
|
+
)
|
|
767
|
+
confirmed = messagebox.askyesno(
|
|
768
|
+
title=_t("kui.confirm.title"),
|
|
769
|
+
message=_t(msg_key),
|
|
770
|
+
icon=messagebox.WARNING,
|
|
771
|
+
default=messagebox.NO,
|
|
772
|
+
parent=dlg,
|
|
773
|
+
)
|
|
774
|
+
if not confirmed:
|
|
775
|
+
return
|
|
776
|
+
|
|
777
|
+
self._cfg.set("kui_perf", profile)
|
|
778
|
+
self._cfg.save()
|
|
779
|
+
if self._kui:
|
|
780
|
+
self._kui.set_perf_profile(profile)
|
|
781
|
+
self._status.notify(_t("ui.kui_perf_applied", profile=profile))
|
|
782
|
+
dlg.destroy()
|
|
783
|
+
|
|
784
|
+
btn_frame = tk.Frame(dlg, bg=t.floating_bg)
|
|
785
|
+
btn_frame.pack(fill="x", padx=12, pady=10)
|
|
786
|
+
tk.Button(
|
|
787
|
+
btn_frame,
|
|
788
|
+
text=_t("kui.perf.apply"),
|
|
789
|
+
command=_apply,
|
|
790
|
+
bg=t.btn_primary,
|
|
791
|
+
fg=t.btn_primary_fg,
|
|
792
|
+
relief="flat",
|
|
793
|
+
padx=16,
|
|
794
|
+
pady=4,
|
|
795
|
+
).pack(side="right")
|
|
796
|
+
tk.Button(
|
|
797
|
+
btn_frame,
|
|
798
|
+
text=_t("kui.confirm.cancel"),
|
|
799
|
+
command=dlg.destroy,
|
|
800
|
+
bg=t.btn_bg,
|
|
801
|
+
fg=t.btn_fg,
|
|
802
|
+
relief="flat",
|
|
803
|
+
padx=16,
|
|
804
|
+
pady=4,
|
|
805
|
+
).pack(side="right", padx=8)
|
|
806
|
+
|
|
807
|
+
def _show_theme_picker(self) -> None:
|
|
808
|
+
"""Seletor rápido de tema usado pelo spotlight."""
|
|
809
|
+
with contextlib.suppress(tk.TclError):
|
|
810
|
+
t = self._tmgr.theme
|
|
811
|
+
dlg = tk.Toplevel(self._root)
|
|
812
|
+
dlg.title("Theme")
|
|
813
|
+
dlg.configure(bg=t.floating_bg)
|
|
814
|
+
dlg.transient(self._root)
|
|
815
|
+
safe_grab_set(dlg)
|
|
816
|
+
for name in sorted(THEMES.keys()):
|
|
817
|
+
tk.Button(
|
|
818
|
+
dlg,
|
|
819
|
+
text=name,
|
|
820
|
+
command=lambda n=name: (self._set_theme(n), dlg.destroy()),
|
|
821
|
+
bg=t.btn_bg,
|
|
822
|
+
fg=t.fg,
|
|
823
|
+
relief="flat",
|
|
824
|
+
font=("Segoe UI", 9),
|
|
825
|
+
).pack(fill="x", padx=8, pady=1)
|