codis 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codis-1.1.1.dist-info/METADATA +194 -0
- codis-1.1.1.dist-info/RECORD +329 -0
- codis-1.1.1.dist-info/WHEEL +5 -0
- codis-1.1.1.dist-info/entry_points.txt +5 -0
- codis-1.1.1.dist-info/licenses/LICENSE +21 -0
- codis-1.1.1.dist-info/top_level.txt +2 -0
- run.py +190 -0
- src/__init__.py +1 -0
- src/__main__.py +81 -0
- src/_app_build.py +1507 -0
- src/_app_editor.py +1274 -0
- src/_app_kui.py +825 -0
- src/_app_lsp.py +625 -0
- src/_app_recovery.py +189 -0
- src/_app_settings.py +1385 -0
- src/_app_tools.py +2471 -0
- src/_app_webpreview.py +126 -0
- src/_font_safety.py +127 -0
- src/_shells.py +172 -0
- src/app.py +1488 -0
- src/chat/__init__.py +1 -0
- src/chat/adapters/__init__.py +33 -0
- src/chat/adapters/base.py +209 -0
- src/chat/adapters/discord.py +190 -0
- src/chat/adapters/http.py +78 -0
- src/chat/adapters/irc.py +360 -0
- src/chat/adapters/matrix.py +219 -0
- src/chat/adapters/mattermost.py +178 -0
- src/chat/adapters/mqtt.py +165 -0
- src/chat/adapters/slack.py +204 -0
- src/chat/adapters/telegram.py +117 -0
- src/chat/adapters/ws.py +154 -0
- src/chat/adapters/xmpp.py +337 -0
- src/chat/history.py +76 -0
- src/chat/models.py +207 -0
- src/chat/probe.py +79 -0
- src/chat/session.py +446 -0
- src/chat/util.py +125 -0
- src/collab/__init__.py +1 -0
- src/collab/net.py +411 -0
- src/collab/ot.py +311 -0
- src/collab/session.py +141 -0
- src/collab/tk_adapter.py +134 -0
- src/config.py +335 -0
- src/constants.py +2552 -0
- src/dep_catalog.py +446 -0
- src/diff/__init__.py +1 -0
- src/diff/engine.py +247 -0
- src/dpi.py +30 -0
- src/editor/__init__.py +1 -0
- src/editor/_pane_lsp.py +2937 -0
- src/editor/_pane_utils.py +171 -0
- src/editor/autocomplete.py +607 -0
- src/editor/code_folding.py +836 -0
- src/editor/color_preview.py +382 -0
- src/editor/complexity_lens.py +281 -0
- src/editor/diff_pane.py +623 -0
- src/editor/file_watcher.py +144 -0
- src/editor/focus_block.py +236 -0
- src/editor/heatmap.py +141 -0
- src/editor/inlay_hints.py +366 -0
- src/editor/inline_blame.py +429 -0
- src/editor/kdocs.py +3376 -0
- src/editor/large_file.py +488 -0
- src/editor/ligatures.py +180 -0
- src/editor/line_numbers.py +598 -0
- src/editor/minimap.py +691 -0
- src/editor/multi_cursor.py +269 -0
- src/editor/pane.py +2082 -0
- src/editor/rhythm.py +206 -0
- src/editor/save_hooks.py +43 -0
- src/editor/smart_selection.py +425 -0
- src/editor/smart_tips.py +719 -0
- src/editor/snippets.py +411 -0
- src/editor/sticky_note_gutter.py +410 -0
- src/editor/sticky_scroll.py +385 -0
- src/editor/suggest.py +464 -0
- src/editor/text_transforms.py +310 -0
- src/editor/vim_mode.py +1074 -0
- src/events/__init__.py +84 -0
- src/events/bus.py +427 -0
- src/events/correlator.py +244 -0
- src/events/kinds.py +125 -0
- src/events/pipeline.py +264 -0
- src/events/stream.py +416 -0
- src/events/window.py +204 -0
- src/extcompat/__init__.py +19 -0
- src/extcompat/code/__init__.py +13 -0
- src/extcompat/code/consent.py +162 -0
- src/extcompat/code/host.py +353 -0
- src/extcompat/code/hosts/py_host.py +763 -0
- src/extcompat/code/locate.py +105 -0
- src/extcompat/code/manager.py +325 -0
- src/extcompat/code/permissions.py +154 -0
- src/extcompat/code/sandbox.py +60 -0
- src/extcompat/colors.py +131 -0
- src/extcompat/common.py +184 -0
- src/extcompat/cson.py +269 -0
- src/extcompat/formats/__init__.py +22 -0
- src/extcompat/formats/_tm.py +189 -0
- src/extcompat/formats/_util.py +31 -0
- src/extcompat/formats/base16.py +66 -0
- src/extcompat/formats/brackets.py +172 -0
- src/extcompat/formats/eclipse.py +193 -0
- src/extcompat/formats/emacs.py +361 -0
- src/extcompat/formats/geany.py +147 -0
- src/extcompat/formats/generic.py +184 -0
- src/extcompat/formats/gtksource.py +117 -0
- src/extcompat/formats/helix.py +91 -0
- src/extcompat/formats/jetbrains.py +343 -0
- src/extcompat/formats/kate.py +130 -0
- src/extcompat/formats/micro.py +131 -0
- src/extcompat/formats/nano.py +111 -0
- src/extcompat/formats/notepadpp.py +140 -0
- src/extcompat/formats/pulsar.py +165 -0
- src/extcompat/formats/pyides.py +163 -0
- src/extcompat/formats/sublime.py +340 -0
- src/extcompat/jsonc.py +65 -0
- src/extcompat/lessish.py +128 -0
- src/extcompat/manager.py +122 -0
- src/extcompat/market/__init__.py +63 -0
- src/extcompat/market/sources.py +211 -0
- src/extcompat/model.py +88 -0
- src/extcompat/net.py +228 -0
- src/extcompat/openvsx.py +63 -0
- src/extcompat/readers.py +362 -0
- src/extcompat/registry.py +73 -0
- src/extcompat/safexml.py +63 -0
- src/extcompat/sexp.py +187 -0
- src/extcompat/sources.py +105 -0
- src/extcompat/store.py +276 -0
- src/extcompat/textmate.py +214 -0
- src/extcompat/themes.py +487 -0
- src/extcompat/yamlite.py +294 -0
- src/fileio.py +94 -0
- src/fs_ops.py +106 -0
- src/i18n.py +233 -0
- src/ia/__init__.py +1 -0
- src/ia/actions.py +295 -0
- src/ia/approval_gate.py +672 -0
- src/ia/checkpoints.py +308 -0
- src/ia/context_builder.py +921 -0
- src/ia/dialdiff.py +408 -0
- src/ia/iaspace.py +2078 -0
- src/ia/pair.py +296 -0
- src/ia/providers.py +954 -0
- src/ia/session.py +335 -0
- src/ia/toolbox.py +2524 -0
- src/launcher_actions.py +204 -0
- src/lint/__init__.py +1 -0
- src/lint/manager.py +1058 -0
- src/locales/.translate_manifest.json +64170 -0
- src/locales/de.json +4936 -0
- src/locales/en.json +4936 -0
- src/locales/es.json +4936 -0
- src/locales/fr.json +4936 -0
- src/locales/it.json +4936 -0
- src/locales/ja.json +4936 -0
- src/locales/ko.json +4936 -0
- src/locales/nl.json +4936 -0
- src/locales/pl.json +4936 -0
- src/locales/pt-BR.json +4936 -0
- src/locales/ru.json +4936 -0
- src/locales/tr.json +4936 -0
- src/locales/uk.json +4936 -0
- src/locales/zh-CN.json +4936 -0
- src/lsp/__init__.py +26 -0
- src/lsp/client.py +2300 -0
- src/lsp/dap_client.py +480 -0
- src/lsp/edits.py +84 -0
- src/lsp/framing.py +73 -0
- src/lsp/protocol.py +931 -0
- src/main.py +260 -0
- src/memtrim.py +91 -0
- src/plugins/__init__.py +1 -0
- src/plugins/api.py +1761 -0
- src/plugins/loader.py +571 -0
- src/plugins/process_runner.py +519 -0
- src/plugins/registry.py +342 -0
- src/plugins/safety.py +367 -0
- src/plugins/startup.py +195 -0
- src/plugins/store.py +1178 -0
- src/proc_registry.py +278 -0
- src/pyexec.py +394 -0
- src/recovery.py +259 -0
- src/stall_trace.py +92 -0
- src/standalone.py +1070 -0
- src/startup_profile.py +35 -0
- src/syntax/__init__.py +1 -0
- src/syntax/highlighter.py +776 -0
- src/syntax/patterns.py +584 -0
- src/system_profile.py +430 -0
- src/terminal/backends.py +658 -0
- src/terminal/internal.py +346 -0
- src/terminal/keys.py +138 -0
- src/terminal/palette.py +67 -0
- src/terminal/session.py +283 -0
- src/terminal/shells.py +79 -0
- src/terminal/view.py +489 -0
- src/terminal/vt.py +870 -0
- src/textfmt.py +22 -0
- src/theme/__init__.py +1 -0
- src/theme/base.py +1281 -0
- src/theme/colors.py +49 -0
- src/theme/manager.py +602 -0
- src/theme/utils.py +312 -0
- src/toolbox.py +329 -0
- src/trash_core.py +531 -0
- src/ui/__init__.py +1 -0
- src/ui/_perf_utils.py +285 -0
- src/ui/_persistence_utils.py +93 -0
- src/ui/accessibility.py +843 -0
- src/ui/activity_bar.py +860 -0
- src/ui/app_embed.py +434 -0
- src/ui/archive_panel.py +608 -0
- src/ui/bookmarks.py +314 -0
- src/ui/breadcrumb.py +383 -0
- src/ui/calculator_panel.py +982 -0
- src/ui/calendar_panel.py +1218 -0
- src/ui/chat_panel.py +1271 -0
- src/ui/chat_profile_dialog.py +278 -0
- src/ui/chat_render.py +128 -0
- src/ui/clock_panel.py +810 -0
- src/ui/code_outline.py +364 -0
- src/ui/code_runner.py +729 -0
- src/ui/code_stats.py +546 -0
- src/ui/collab_panel.py +1009 -0
- src/ui/color_picker.py +547 -0
- src/ui/command_palette.py +452 -0
- src/ui/cursor_manager.py +750 -0
- src/ui/custom_keywords_panel.py +413 -0
- src/ui/debug_panel.py +1037 -0
- src/ui/dependency_graph.py +692 -0
- src/ui/diff_panel.py +381 -0
- src/ui/docs_panel.py +514 -0
- src/ui/doom_embed.py +349 -0
- src/ui/dropdown.py +321 -0
- src/ui/easter_eggs.py +979 -0
- src/ui/env_manager.py +666 -0
- src/ui/extcode_bridge.py +215 -0
- src/ui/extcode_dialogs.py +412 -0
- src/ui/extcompat_dialog.py +583 -0
- src/ui/file_timeline.py +319 -0
- src/ui/file_tree.py +1208 -0
- src/ui/find_in_files.py +1355 -0
- src/ui/flowchart_panel.py +727 -0
- src/ui/formatter_panel.py +490 -0
- src/ui/git_auth.py +763 -0
- src/ui/git_clone_dialog.py +487 -0
- src/ui/git_panel.py +1483 -0
- src/ui/grab_safe.py +84 -0
- src/ui/internal_python_dialog.py +98 -0
- src/ui/k_ui/__init__.py +1305 -0
- src/ui/k_ui/_bgrenderer.py +317 -0
- src/ui/k_ui/_colors.py +213 -0
- src/ui/k_ui/_dock.py +545 -0
- src/ui/k_ui/_easter.py +290 -0
- src/ui/k_ui/_engine.py +5448 -0
- src/ui/k_ui/_perf.py +333 -0
- src/ui/k_ui/_tkutil.py +7 -0
- src/ui/k_ui/_tooltip.py +365 -0
- src/ui/k_ui/_widgets.py +1204 -0
- src/ui/k_ui/_world.py +837 -0
- src/ui/key_remapper.py +856 -0
- src/ui/launcher.py +1252 -0
- src/ui/lazy_panel.py +73 -0
- src/ui/macro_recorder.py +610 -0
- src/ui/menu_bar.py +898 -0
- src/ui/output_panel.py +321 -0
- src/ui/paint_canvas.py +1000 -0
- src/ui/paint_engine.py +535 -0
- src/ui/paint_panel.py +888 -0
- src/ui/panel_detach.py +112 -0
- src/ui/performance_panel.py +861 -0
- src/ui/pip_manager.py +1758 -0
- src/ui/plugin_panel.py +1586 -0
- src/ui/pomodoro_panel.py +447 -0
- src/ui/problems.py +566 -0
- src/ui/process_manager.py +1657 -0
- src/ui/project_templates.py +775 -0
- src/ui/recovery_dialog.py +122 -0
- src/ui/regex_playground.py +304 -0
- src/ui/remote_adapters.py +1398 -0
- src/ui/remote_browser.py +1224 -0
- src/ui/remote_profile_dialog.py +342 -0
- src/ui/render_panel.py +1293 -0
- src/ui/rest_client.py +549 -0
- src/ui/scratchpad.py +548 -0
- src/ui/search_bar.py +1274 -0
- src/ui/settings_editor.py +3349 -0
- src/ui/settings_window.py +1554 -0
- src/ui/snippets_panel.py +597 -0
- src/ui/sql_studio.py +1815 -0
- src/ui/status_bar.py +438 -0
- src/ui/tab_bar.py +654 -0
- src/ui/task_manager.py +1773 -0
- src/ui/terminal.py +525 -0
- src/ui/theme_preview_panel.py +851 -0
- src/ui/thread_safe_tk.py +152 -0
- src/ui/time_tracker.py +574 -0
- src/ui/tkbind.py +43 -0
- src/ui/todo_panel.py +358 -0
- src/ui/toolbox_panels.py +658 -0
- src/ui/trash_manager.py +657 -0
- src/ui/ui_scale.py +294 -0
- src/ui/ux_enhancements.py +41 -0
- src/ui/web_preview.py +397 -0
- src/ui/webdev.py +630 -0
- src/ui/welcome.py +567 -0
- src/ui/window_embed.py +1500 -0
- src/ui/wizard.py +1550 -0
- src/ui/workspace_switcher.py +418 -0
- src/ui/workspace_trust.py +370 -0
- src/ui/zen_audio.py +354 -0
- src/ui/zen_media.py +2271 -0
- src/ui/zen_media_client.py +303 -0
- src/ui/zen_media_host.py +329 -0
- src/ui/zen_player.py +907 -0
- src/ui/zen_player_widgets.py +700 -0
- src/updater/__init__.py +11 -0
- src/updater/assets.py +145 -0
- src/updater/backup.py +101 -0
- src/updater/channel.py +221 -0
- src/updater/dialog.py +492 -0
- src/updater/integrity.py +111 -0
- src/updater/manager.py +727 -0
- src/updater/result.py +114 -0
- src/venv_runtime.py +531 -0
- src/workspace_state.py +25 -0
src/ui/easter_eggs.py
ADDED
|
@@ -0,0 +1,979 @@
|
|
|
1
|
+
"""Codis - Easter Eggs.
|
|
2
|
+
|
|
3
|
+
Níveis de dificuldade:
|
|
4
|
+
★☆☆☆☆ Trivial - basta digitar algo óbvio
|
|
5
|
+
★★☆☆☆ Fácil - um pouco escondido
|
|
6
|
+
★★★☆☆ Médio - exige conhecer o código
|
|
7
|
+
★★★★☆ Difícil - sequências de teclas obscuras ou dependentes de tempo
|
|
8
|
+
★★★★★ Lendário - combinar vários ovos ou fazer engenharia reversa
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import contextlib
|
|
14
|
+
import logging
|
|
15
|
+
import random
|
|
16
|
+
import threading
|
|
17
|
+
import time
|
|
18
|
+
import tkinter as tk
|
|
19
|
+
from collections.abc import Callable
|
|
20
|
+
from typing import Any
|
|
21
|
+
|
|
22
|
+
from src.i18n import _t
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger("Codis.Eggs")
|
|
25
|
+
|
|
26
|
+
_TERMINAL_PREFIX = "/codis "
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SequenceWatcher:
|
|
30
|
+
"""Despacha easter eggs via comando de terminal (/codis <código>).
|
|
31
|
+
|
|
32
|
+
NÃO intercepta mais digitação no editor - zero risco de interferir
|
|
33
|
+
com código sendo escrito pelo desenvolvedor.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self) -> None:
|
|
37
|
+
self._triggers: dict[str, Callable] = {}
|
|
38
|
+
self._arg_triggers: dict[str, Callable[[str], None]] = {}
|
|
39
|
+
|
|
40
|
+
def register(self, sequence: str, cb: Callable) -> None:
|
|
41
|
+
"""Registra um código e seu callback correspondente.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
sequence: Código secreto (sem o prefixo /codis).
|
|
45
|
+
cb: Função de callback invocada ao reconhecer o código.
|
|
46
|
+
"""
|
|
47
|
+
self._triggers[sequence.lower()] = cb
|
|
48
|
+
|
|
49
|
+
def register_args(self, sequence: str, cb: Callable[[str], None]) -> None:
|
|
50
|
+
"""Registra um comando que aceita argumentos (``/codis app notepad.exe``)."""
|
|
51
|
+
self._arg_triggers[sequence.lower()] = cb
|
|
52
|
+
|
|
53
|
+
def dispatch(self, raw_cmd: str) -> bool:
|
|
54
|
+
"""Processa um comando de terminal; retorna True se foi um easter egg.
|
|
55
|
+
|
|
56
|
+
Deve ser chamado apenas pelo TerminalPanel quando o usuário pressiona
|
|
57
|
+
Enter. Comandos que não começam com o prefixo são ignorados.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
raw_cmd: Texto completo digitado no terminal antes do Enter.
|
|
61
|
+
"""
|
|
62
|
+
cmd = raw_cmd.strip()
|
|
63
|
+
if not cmd.lower().startswith(_TERMINAL_PREFIX):
|
|
64
|
+
return False
|
|
65
|
+
code = cmd[len(_TERMINAL_PREFIX):].strip().lower()
|
|
66
|
+
cb = self._triggers.get(code)
|
|
67
|
+
if cb is None:
|
|
68
|
+
head, _, rest = code.partition(" ")
|
|
69
|
+
arg_cb = self._arg_triggers.get(head)
|
|
70
|
+
if arg_cb is None:
|
|
71
|
+
return False
|
|
72
|
+
raw_rest = cmd[len(_TERMINAL_PREFIX):].strip().partition(" ")[2].strip()
|
|
73
|
+
try:
|
|
74
|
+
arg_cb(raw_rest)
|
|
75
|
+
except Exception as e:
|
|
76
|
+
logger.debug("Easter egg error: %s", e)
|
|
77
|
+
return True
|
|
78
|
+
try:
|
|
79
|
+
cb()
|
|
80
|
+
except Exception as e:
|
|
81
|
+
logger.debug("Easter egg error: %s", e)
|
|
82
|
+
return True
|
|
83
|
+
|
|
84
|
+
@staticmethod
|
|
85
|
+
def feed(char: str) -> None:
|
|
86
|
+
"""Descontinuado: easter eggs não são mais ativados por digitação."""
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _matrix_rain(root: tk.Tk, _tmgr) -> None:
|
|
90
|
+
"""★★☆☆☆ Chuva Matrix. Digite 'matrix' para ativar."""
|
|
91
|
+
overlay = tk.Toplevel(root)
|
|
92
|
+
overlay.wm_overrideredirect(True)
|
|
93
|
+
overlay.wm_attributes("-topmost", True)
|
|
94
|
+
overlay.wm_attributes("-alpha", 0.88)
|
|
95
|
+
overlay.geometry(
|
|
96
|
+
f"{root.winfo_width()}x{root.winfo_height()}+{root.winfo_rootx()}+{root.winfo_rooty()}"
|
|
97
|
+
)
|
|
98
|
+
overlay.configure(bg="#000000")
|
|
99
|
+
|
|
100
|
+
canvas = tk.Canvas(overlay, bg="#000000", highlightthickness=0)
|
|
101
|
+
canvas.pack(fill="both", expand=True)
|
|
102
|
+
|
|
103
|
+
cols = root.winfo_width() // 14
|
|
104
|
+
drops = [random.randint(-40, 0) for _ in range(cols)]
|
|
105
|
+
chars = list(
|
|
106
|
+
"ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン0123456789")
|
|
107
|
+
stop = [False]
|
|
108
|
+
|
|
109
|
+
def draw():
|
|
110
|
+
if stop[0]:
|
|
111
|
+
return
|
|
112
|
+
canvas.delete("all")
|
|
113
|
+
for i, drop in enumerate(drops):
|
|
114
|
+
if drop > 0:
|
|
115
|
+
ch = random.choice(chars)
|
|
116
|
+
x = i * 14 + 7
|
|
117
|
+
y = drop * 16
|
|
118
|
+
canvas.create_text(
|
|
119
|
+
x, y, text=ch, fill="#00ff41", font=("Courier", 11, "bold")
|
|
120
|
+
)
|
|
121
|
+
drops[i] += 1
|
|
122
|
+
if drops[i] * 16 > root.winfo_height() and random.random() > 0.975:
|
|
123
|
+
drops[i] = 0
|
|
124
|
+
overlay.after(45, draw)
|
|
125
|
+
|
|
126
|
+
overlay.bind(
|
|
127
|
+
"<Button-1>", lambda _: (stop.__setitem__(0, True), overlay.destroy()))
|
|
128
|
+
overlay.bind("<Escape>", lambda _: (
|
|
129
|
+
stop.__setitem__(0, True), overlay.destroy()))
|
|
130
|
+
|
|
131
|
+
overlay.after(
|
|
132
|
+
12000,
|
|
133
|
+
lambda: (
|
|
134
|
+
stop.__setitem__(0, True),
|
|
135
|
+
overlay.destroy() if overlay.winfo_exists() else None,
|
|
136
|
+
),
|
|
137
|
+
)
|
|
138
|
+
draw()
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _konami_code(root: tk.Tk, _tmgr) -> None:
|
|
142
|
+
"""★★★☆☆ Código Konami: ↑↑↓↓ <- -> <- -> BA - mostra tela de +30 vidas."""
|
|
143
|
+
dlg = tk.Toplevel(root)
|
|
144
|
+
dlg.title("🎮 CHEAT ACTIVATED")
|
|
145
|
+
dlg.configure(bg="#000000")
|
|
146
|
+
dlg.geometry("440x260")
|
|
147
|
+
dlg.transient(root)
|
|
148
|
+
|
|
149
|
+
frames = [
|
|
150
|
+
("★ ★ ★ +30 LIVES ★ ★ ★", "#ffff00", 40),
|
|
151
|
+
("KONAMI CODE ACCEPTED", "#00ff00", 18),
|
|
152
|
+
("↑ ↑ ↓ ↓ ← → ← → B A", "#ffffff", 14),
|
|
153
|
+
("You found the secret!", "#aaaaaa", 12),
|
|
154
|
+
]
|
|
155
|
+
for text, color, size in frames:
|
|
156
|
+
tk.Label(
|
|
157
|
+
dlg, text=text, bg="#000000", fg=color, font=("Courier New", size, "bold")
|
|
158
|
+
).pack(pady=4)
|
|
159
|
+
|
|
160
|
+
tk.Button(
|
|
161
|
+
dlg,
|
|
162
|
+
text=_t("hc.easter_eggs.insert_coin"),
|
|
163
|
+
bg="#ffff00",
|
|
164
|
+
fg="#000000",
|
|
165
|
+
font=("Courier New", 12, "bold"),
|
|
166
|
+
command=dlg.destroy,
|
|
167
|
+
).pack(pady=12)
|
|
168
|
+
dlg.after(6000, lambda: dlg.destroy() if dlg.winfo_exists() else None)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _uwu_mode(root: tk.Tk, tmgr, editor_getter) -> None:
|
|
172
|
+
"""★☆☆☆☆ Type 'uwu' - transforms code text to uwu-speak briefly."""
|
|
173
|
+
editor = editor_getter()
|
|
174
|
+
if not editor:
|
|
175
|
+
return
|
|
176
|
+
|
|
177
|
+
UWU = {
|
|
178
|
+
"r": "w",
|
|
179
|
+
"l": "w",
|
|
180
|
+
"R": "W",
|
|
181
|
+
"L": "W",
|
|
182
|
+
"th": "d",
|
|
183
|
+
"Th": "D",
|
|
184
|
+
"TH": "D",
|
|
185
|
+
}
|
|
186
|
+
original = editor.text.get("1.0", "end-1c")
|
|
187
|
+
uwu_text = original
|
|
188
|
+
for k, v in UWU.items():
|
|
189
|
+
uwu_text = uwu_text.replace(k, v)
|
|
190
|
+
|
|
191
|
+
editor.text.config(state="normal")
|
|
192
|
+
editor.text.delete("1.0", "end")
|
|
193
|
+
editor.text.insert("1.0", uwu_text)
|
|
194
|
+
|
|
195
|
+
def restore():
|
|
196
|
+
time.sleep(5)
|
|
197
|
+
with contextlib.suppress(tk.TclError):
|
|
198
|
+
editor.text.after(
|
|
199
|
+
0,
|
|
200
|
+
lambda: (
|
|
201
|
+
editor.text.delete("1.0", "end"),
|
|
202
|
+
editor.text.insert("1.0", original),
|
|
203
|
+
),
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
threading.Thread(target=restore, daemon=True).start()
|
|
207
|
+
|
|
208
|
+
t = tmgr.theme
|
|
209
|
+
dlg = tk.Toplevel(root)
|
|
210
|
+
dlg.wm_overrideredirect(True)
|
|
211
|
+
dlg.wm_attributes("-topmost", True)
|
|
212
|
+
dlg.configure(bg=t.floating_bg, pady=8, padx=12)
|
|
213
|
+
dlg.geometry(f"+{root.winfo_rootx() + 40}+{root.winfo_rooty() + 40}")
|
|
214
|
+
tk.Label(
|
|
215
|
+
dlg,
|
|
216
|
+
text=_t("hc.easter_eggs.owo_uwu_mode_activated_5s"),
|
|
217
|
+
bg=t.floating_bg,
|
|
218
|
+
fg="#ff79c6",
|
|
219
|
+
font=("Segoe UI", 11, "bold"),
|
|
220
|
+
).pack()
|
|
221
|
+
dlg.after(5000, lambda: dlg.destroy() if dlg.winfo_exists() else None)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def _birthday_mode(root: tk.Tk, tmgr) -> None:
|
|
225
|
+
"""★★☆☆☆ Abra no seu aniversário - chuva de confetes."""
|
|
226
|
+
|
|
227
|
+
t = tmgr.theme
|
|
228
|
+
overlay = tk.Toplevel(root)
|
|
229
|
+
overlay.wm_overrideredirect(True)
|
|
230
|
+
overlay.wm_attributes("-topmost", True)
|
|
231
|
+
overlay.wm_attributes("-alpha", 0.85)
|
|
232
|
+
overlay.geometry(
|
|
233
|
+
f"{root.winfo_width()}x{root.winfo_height()}+{root.winfo_rootx()}+{root.winfo_rooty()}"
|
|
234
|
+
)
|
|
235
|
+
overlay.configure(bg=t.editor_bg)
|
|
236
|
+
|
|
237
|
+
canvas = tk.Canvas(overlay, bg=t.editor_bg, highlightthickness=0)
|
|
238
|
+
canvas.pack(fill="both", expand=True)
|
|
239
|
+
|
|
240
|
+
tk.Label(
|
|
241
|
+
overlay,
|
|
242
|
+
text=_t("hc.easter_eggs.happy_birthday_coder"),
|
|
243
|
+
bg=t.editor_bg,
|
|
244
|
+
fg=t.t_func,
|
|
245
|
+
font=("Segoe UI", 22, "bold"),
|
|
246
|
+
).place(relx=0.5, rely=0.45, anchor="center")
|
|
247
|
+
tk.Label(
|
|
248
|
+
overlay,
|
|
249
|
+
text=_t("hc.easter_eggs.may_your_code_be_bug_free_and_"),
|
|
250
|
+
bg=t.editor_bg,
|
|
251
|
+
fg=t.fg_muted,
|
|
252
|
+
font=("Segoe UI", 11),
|
|
253
|
+
).place(relx=0.5, rely=0.55, anchor="center")
|
|
254
|
+
|
|
255
|
+
COLORS = ["#ff6b6b", "#ffd93d", "#6bcb77", "#4d96ff", "#ff6bff", "#ff9f1c"]
|
|
256
|
+
particles = [
|
|
257
|
+
{
|
|
258
|
+
"x": random.uniform(0, 1),
|
|
259
|
+
"y": random.uniform(-0.2, 0),
|
|
260
|
+
"vx": random.uniform(-0.003, 0.003),
|
|
261
|
+
"vy": random.uniform(0.004, 0.012),
|
|
262
|
+
"color": random.choice(COLORS),
|
|
263
|
+
"size": random.randint(4, 10),
|
|
264
|
+
"shape": random.choice(["rect", "oval"]),
|
|
265
|
+
}
|
|
266
|
+
for _ in range(80)
|
|
267
|
+
]
|
|
268
|
+
stop = [False]
|
|
269
|
+
|
|
270
|
+
def animate():
|
|
271
|
+
if stop[0]:
|
|
272
|
+
return
|
|
273
|
+
canvas.delete("confetti")
|
|
274
|
+
h = overlay.winfo_height()
|
|
275
|
+
w = overlay.winfo_width()
|
|
276
|
+
for p in particles:
|
|
277
|
+
p["x"] += p["vx"]
|
|
278
|
+
p["y"] += p["vy"]
|
|
279
|
+
if p["y"] > 1.1:
|
|
280
|
+
p["y"] = -0.05
|
|
281
|
+
p["x"] = random.uniform(0, 1)
|
|
282
|
+
x1, y1 = int(p["x"] * w), int(p["y"] * h)
|
|
283
|
+
x2, y2 = x1 + p["size"], y1 + p["size"]
|
|
284
|
+
if p["shape"] == "rect":
|
|
285
|
+
canvas.create_rectangle(
|
|
286
|
+
x1, y1, x2, y2, fill=p["color"], outline="", tags="confetti"
|
|
287
|
+
)
|
|
288
|
+
else:
|
|
289
|
+
canvas.create_oval(
|
|
290
|
+
x1, y1, x2, y2, fill=p["color"], outline="", tags="confetti"
|
|
291
|
+
)
|
|
292
|
+
overlay.after(30, animate)
|
|
293
|
+
|
|
294
|
+
overlay.bind(
|
|
295
|
+
"<Button-1>", lambda _: (stop.__setitem__(0, True), overlay.destroy()))
|
|
296
|
+
overlay.after(
|
|
297
|
+
8000,
|
|
298
|
+
lambda: (
|
|
299
|
+
stop.__setitem__(0, True),
|
|
300
|
+
overlay.destroy() if overlay.winfo_exists() else None,
|
|
301
|
+
),
|
|
302
|
+
)
|
|
303
|
+
animate()
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def _deep_thought(root: tk.Tk, _tmgr) -> None:
|
|
307
|
+
"""★★★★☆ Digite a resposta para a vida, o universo e tudo mais: '42'
|
|
308
|
+
- revela o Deep Thought."""
|
|
309
|
+
dlg = tk.Toplevel(root)
|
|
310
|
+
dlg.title("Deep Thought")
|
|
311
|
+
dlg.configure(bg="#000033")
|
|
312
|
+
dlg.geometry("500x300")
|
|
313
|
+
dlg.transient(root)
|
|
314
|
+
|
|
315
|
+
lines = [
|
|
316
|
+
("", 0),
|
|
317
|
+
("The Answer to the Ultimate Question of", 800),
|
|
318
|
+
("Life, the Universe, and Everything is...", 1600),
|
|
319
|
+
("", 2200),
|
|
320
|
+
(" 42", 2800),
|
|
321
|
+
("", 3400),
|
|
322
|
+
("- Deep Thought, HGTTG", 4000),
|
|
323
|
+
]
|
|
324
|
+
|
|
325
|
+
frame = tk.Frame(dlg, bg="#000033")
|
|
326
|
+
frame.pack(expand=True)
|
|
327
|
+
|
|
328
|
+
for text, delay in lines:
|
|
329
|
+
label = tk.Label(
|
|
330
|
+
frame,
|
|
331
|
+
text=text,
|
|
332
|
+
bg="#000033",
|
|
333
|
+
fg="#00ffaa" if "42" in text else "#aaffcc",
|
|
334
|
+
font=(
|
|
335
|
+
"Courier New",
|
|
336
|
+
18 if "42" in text else 12,
|
|
337
|
+
"bold" if "42" in text else "normal",
|
|
338
|
+
),
|
|
339
|
+
)
|
|
340
|
+
label.pack(pady=2)
|
|
341
|
+
if delay:
|
|
342
|
+
label.config(fg="#000033")
|
|
343
|
+
dlg.after(
|
|
344
|
+
delay,
|
|
345
|
+
lambda lbl=label, txt=text: lbl.config(
|
|
346
|
+
fg="#00ffaa" if "42" in txt else "#aaffcc"
|
|
347
|
+
),
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
dlg.after(8000, lambda: dlg.destroy() if dlg.winfo_exists() else None)
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def _sudo_mode(root: tk.Tk, tmgr) -> None:
|
|
354
|
+
"""★★★☆☆ Digite 'sudo' - mostra escalada de privilégio falsa."""
|
|
355
|
+
|
|
356
|
+
dlg = tk.Toplevel(root)
|
|
357
|
+
dlg.title("sudo")
|
|
358
|
+
dlg.configure(bg="#000000")
|
|
359
|
+
dlg.geometry("500x240")
|
|
360
|
+
dlg.transient(root)
|
|
361
|
+
dlg.wm_attributes("-topmost", True)
|
|
362
|
+
|
|
363
|
+
output = tk.Text(
|
|
364
|
+
dlg,
|
|
365
|
+
bg="#000000",
|
|
366
|
+
fg="#00ff00",
|
|
367
|
+
font=("Courier New", 10),
|
|
368
|
+
relief="flat",
|
|
369
|
+
state="normal",
|
|
370
|
+
insertbackground="#00ff00",
|
|
371
|
+
)
|
|
372
|
+
output.pack(fill="both", expand=True, padx=8, pady=8)
|
|
373
|
+
|
|
374
|
+
lines = [
|
|
375
|
+
("[sudo] password for user: ", 0.4),
|
|
376
|
+
("*****\n", 1.2),
|
|
377
|
+
("Verifying credentials...\n", 1.6),
|
|
378
|
+
("✓ Root access granted\n", 2.4),
|
|
379
|
+
("Loading god-mode settings...\n", 2.9),
|
|
380
|
+
("Activating unlimited coffee mode ☕\n", 3.5),
|
|
381
|
+
("Making all bugs features™\n", 4.2),
|
|
382
|
+
("DONE. You may now code omnipotently.\n", 5.0),
|
|
383
|
+
]
|
|
384
|
+
|
|
385
|
+
def type_line(idx=0):
|
|
386
|
+
if idx >= len(lines) or not dlg.winfo_exists():
|
|
387
|
+
return
|
|
388
|
+
text, delay = lines[idx]
|
|
389
|
+
output.insert("end", text)
|
|
390
|
+
output.see("end")
|
|
391
|
+
dlg.after(int(delay * 1000), lambda: type_line(idx + 1))
|
|
392
|
+
|
|
393
|
+
type_line()
|
|
394
|
+
dlg.after(8000, lambda: dlg.destroy() if dlg.winfo_exists() else None)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
def _dev_console(root: tk.Tk, tmgr) -> None:
|
|
398
|
+
"""★★★★★ Type 'xyzzy' (classic Colossal Cave) - opens secret dev console."""
|
|
399
|
+
t = tmgr.theme
|
|
400
|
+
dlg = tk.Toplevel(root)
|
|
401
|
+
dlg.title("✦ Secret Dev Console ✦")
|
|
402
|
+
dlg.configure(bg=t.floating_bg)
|
|
403
|
+
dlg.geometry("560x380")
|
|
404
|
+
dlg.transient(root)
|
|
405
|
+
|
|
406
|
+
tk.Label(
|
|
407
|
+
dlg,
|
|
408
|
+
text=_t("hc.easter_eggs.xyzzy_secret_dev_console"),
|
|
409
|
+
bg=t.floating_bg,
|
|
410
|
+
fg=t.t_func,
|
|
411
|
+
font=("Courier New", 12, "bold"),
|
|
412
|
+
).pack(pady=(12, 4))
|
|
413
|
+
tk.Label(
|
|
414
|
+
dlg,
|
|
415
|
+
text="A hollow voice says: 'PLUGH'\nYou are in a maze of twisty passages, all alike.",
|
|
416
|
+
bg=t.floating_bg,
|
|
417
|
+
fg=t.fg_muted,
|
|
418
|
+
font=("Courier New", 9),
|
|
419
|
+
justify="center",
|
|
420
|
+
).pack()
|
|
421
|
+
|
|
422
|
+
frame = tk.Frame(dlg, bg=t.editor_bg)
|
|
423
|
+
frame.pack(fill="both", expand=True, padx=12, pady=8)
|
|
424
|
+
out = tk.Text(
|
|
425
|
+
frame,
|
|
426
|
+
bg=t.editor_bg,
|
|
427
|
+
fg=t.t_string,
|
|
428
|
+
font=("Courier New", 9),
|
|
429
|
+
relief="flat",
|
|
430
|
+
state="disabled",
|
|
431
|
+
)
|
|
432
|
+
out.pack(fill="both", expand=True)
|
|
433
|
+
|
|
434
|
+
entry_var = tk.StringVar()
|
|
435
|
+
entry = tk.Entry(
|
|
436
|
+
dlg,
|
|
437
|
+
textvariable=entry_var,
|
|
438
|
+
bg=t.input_bg,
|
|
439
|
+
fg=t.fg,
|
|
440
|
+
insertbackground=t.cursor,
|
|
441
|
+
font=("Courier New", 10),
|
|
442
|
+
relief="flat",
|
|
443
|
+
)
|
|
444
|
+
entry.pack(fill="x", padx=12, pady=(0, 8))
|
|
445
|
+
entry.focus_set()
|
|
446
|
+
|
|
447
|
+
RESPONSES = {
|
|
448
|
+
"help": "Commands: look, inventory, go north/south/east/west, take <item>, codis, quit",
|
|
449
|
+
"look": "You see a dimly lit terminal. A pile of uncommented code lies in the corner.\n"
|
|
450
|
+
"Exits: north (Stack Overflow), south (GitHub), east (Documentation), west (Void).",
|
|
451
|
+
"inventory": "You are carrying: 1x Cold Coffee, 3x Rubber Ducks, 1x Stack Trace",
|
|
452
|
+
"go north": "You head north towards Stack Overflow.\n'Duplicate question! -5 rep' a voice cries.",
|
|
453
|
+
"go south": "You venture to GitHub. A wild PR request appears!",
|
|
454
|
+
"go east": "Documentation? It reads: 'TODO: write docs'. Typical.",
|
|
455
|
+
"go west": "You stare into the Void. The Void stares back with a SegFault.",
|
|
456
|
+
"codis": "✨ You are already inside Codis! Inception-level awareness +100.",
|
|
457
|
+
"xyzzy": "A hollow voice says nothing. Try PLUGH.",
|
|
458
|
+
"plugh": "A hollow voice says: 'PLUGH'. You have been transported... nowhere.",
|
|
459
|
+
"take rubber duck": "You pick up a rubber duck and explain your bug to it.\nBug solved! (somehow)",
|
|
460
|
+
"take coffee": "It's cold. You drink it anyway. Programmer power +5.",
|
|
461
|
+
"quit": "You cannot leave. The code must be written.",
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
def run_cmd(_=None):
|
|
465
|
+
cmd = entry_var.get().strip().lower()
|
|
466
|
+
entry_var.set("")
|
|
467
|
+
response = RESPONSES.get(
|
|
468
|
+
cmd, f"I don't understand '{cmd}'. Type 'help'.")
|
|
469
|
+
out.config(state="normal")
|
|
470
|
+
out.insert("end", f"\n> {cmd}\n{response}\n")
|
|
471
|
+
out.config(state="disabled")
|
|
472
|
+
out.see("end")
|
|
473
|
+
|
|
474
|
+
entry.bind("<Return>", run_cmd)
|
|
475
|
+
out.config(state="normal")
|
|
476
|
+
out.insert(
|
|
477
|
+
"1.0",
|
|
478
|
+
"═══════════════════════════════════════\n"
|
|
479
|
+
" COLOSSAL CODIS (c) 1977–2025 Codis \n"
|
|
480
|
+
"═══════════════════════════════════════\n"
|
|
481
|
+
"You are standing at the end of a road before\n"
|
|
482
|
+
"a small brick building. Around you is a forest.\n"
|
|
483
|
+
"A small stream flows out of the building and down a gully.\n\n"
|
|
484
|
+
"Type 'help' for commands.\n",
|
|
485
|
+
)
|
|
486
|
+
out.config(state="disabled")
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
def _nyan_cat(root: tk.Tk, _tmgr) -> None:
|
|
490
|
+
"""★★★★☆ Digite 'nyan' - animação ASCII Nyan Cat."""
|
|
491
|
+
overlay = tk.Toplevel(root)
|
|
492
|
+
overlay.wm_overrideredirect(True)
|
|
493
|
+
overlay.wm_attributes("-topmost", True)
|
|
494
|
+
overlay.wm_attributes("-alpha", 0.92)
|
|
495
|
+
h = 120
|
|
496
|
+
overlay.geometry(
|
|
497
|
+
f"{root.winfo_width()}x{h}"
|
|
498
|
+
f"+{root.winfo_rootx()}+{root.winfo_rooty() + root.winfo_height() - h}"
|
|
499
|
+
)
|
|
500
|
+
overlay.configure(bg="#000000")
|
|
501
|
+
|
|
502
|
+
NYAN_FRAMES = [
|
|
503
|
+
"+ ,------, \n"
|
|
504
|
+
"|\\_,-~/ |\n"
|
|
505
|
+
"/ _ _ |,-, | |\n"
|
|
506
|
+
"(6--\\ Y )-/ |\n"
|
|
507
|
+
"| } |/| / |\n"
|
|
508
|
+
"| / _/| | / |\n"
|
|
509
|
+
" |/-' |/ \\ |\n"
|
|
510
|
+
" `--' | | `--.",
|
|
511
|
+
]
|
|
512
|
+
RAINBOW = ["#ff0000", "#ff7700", "#ffff00",
|
|
513
|
+
"#00ff00", "#0000ff", "#8800ff"]
|
|
514
|
+
x_pos = [0]
|
|
515
|
+
stop = [False]
|
|
516
|
+
canvas = tk.Canvas(overlay, bg="#000000", highlightthickness=0)
|
|
517
|
+
canvas.pack(fill="both", expand=True)
|
|
518
|
+
|
|
519
|
+
def animate(frame_idx=0):
|
|
520
|
+
if stop[0] or not overlay.winfo_exists():
|
|
521
|
+
return
|
|
522
|
+
canvas.delete("all")
|
|
523
|
+
|
|
524
|
+
for i in range(x_pos[0], 0, -8):
|
|
525
|
+
color = RAINBOW[(i // 8) % 6]
|
|
526
|
+
canvas.create_rectangle(i - 8, 20, i, 80, fill=color, outline="")
|
|
527
|
+
|
|
528
|
+
canvas.create_text(
|
|
529
|
+
x_pos[0] + 10,
|
|
530
|
+
h // 2,
|
|
531
|
+
text=NYAN_FRAMES[0],
|
|
532
|
+
fill="#ffffff",
|
|
533
|
+
font=("Courier", 7),
|
|
534
|
+
anchor="w",
|
|
535
|
+
)
|
|
536
|
+
x_pos[0] = (x_pos[0] + 6) % (root.winfo_width() + 200)
|
|
537
|
+
overlay.after(40, lambda: animate((frame_idx + 1) % len(NYAN_FRAMES)))
|
|
538
|
+
|
|
539
|
+
overlay.bind(
|
|
540
|
+
"<Button-1>", lambda _: (stop.__setitem__(0, True), overlay.destroy()))
|
|
541
|
+
overlay.after(
|
|
542
|
+
7000,
|
|
543
|
+
lambda: (
|
|
544
|
+
stop.__setitem__(0, True),
|
|
545
|
+
overlay.destroy() if overlay.winfo_exists() else None,
|
|
546
|
+
),
|
|
547
|
+
)
|
|
548
|
+
animate()
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
class EasterEggManager:
|
|
552
|
+
"""
|
|
553
|
+
Central manager. Attach to app, registers all eggs.
|
|
554
|
+
|
|
555
|
+
Eggs:
|
|
556
|
+
'matrix' -> ★★☆☆☆ Matrix rain
|
|
557
|
+
'uwu' -> ★☆☆☆☆ UWU mode
|
|
558
|
+
'happybirthday' -> ★★☆☆☆ Confetti
|
|
559
|
+
'42' -> ★★★★☆ Deep Thought
|
|
560
|
+
'sudo' -> ★★★☆☆ Fake sudo
|
|
561
|
+
'xyzzy' -> ★★★★★ Text adventure
|
|
562
|
+
'nyan' -> ★★★★☆ Nyan Cat
|
|
563
|
+
|
|
564
|
+
Konami code watcher on root window:
|
|
565
|
+
↑↑↓↓ <- -> <- -> BA -> ★★★☆☆ +30 lives
|
|
566
|
+
"""
|
|
567
|
+
|
|
568
|
+
KONAMI = ["Up", "Up", "Down", "Down", "Left",
|
|
569
|
+
"Right", "Left", "Right", "b", "a"]
|
|
570
|
+
|
|
571
|
+
def __init__(
|
|
572
|
+
self,
|
|
573
|
+
root: tk.Tk,
|
|
574
|
+
tmgr,
|
|
575
|
+
editor_getter,
|
|
576
|
+
status_notify: Callable[[str], None],
|
|
577
|
+
editor_container_getter: Callable | None = None,
|
|
578
|
+
cfg: Any | None = None,
|
|
579
|
+
) -> None:
|
|
580
|
+
"""Inicializa o gerenciador de easter eggs.
|
|
581
|
+
|
|
582
|
+
Easter eggs são ativados EXCLUSIVAMENTE via terminal integrado usando
|
|
583
|
+
o prefixo ``/codis <código>``. Nenhuma digitação no editor é monitorada.
|
|
584
|
+
|
|
585
|
+
Args:
|
|
586
|
+
root: Janela raiz Tkinter.
|
|
587
|
+
tmgr: Gerenciador de temas.
|
|
588
|
+
editor_getter: Callable que retorna o editor ativo.
|
|
589
|
+
status_notify: Callable para exibir mensagens na status bar.
|
|
590
|
+
editor_container_getter: Callable que retorna o tk.Frame do editor (para embed DOOM).
|
|
591
|
+
cfg: Configuração do app (``get(chave, padrão)``), usada pelo DOOM
|
|
592
|
+
(``doom_engine_path``, ``doom_iwad_path``, ``doom_extra_args``).
|
|
593
|
+
"""
|
|
594
|
+
self._root = root
|
|
595
|
+
self._tmgr = tmgr
|
|
596
|
+
self._get_ed = editor_getter
|
|
597
|
+
self._notify = status_notify
|
|
598
|
+
self._get_container = editor_container_getter
|
|
599
|
+
self._cfg = cfg
|
|
600
|
+
self._doom_panel: Any | None = None
|
|
601
|
+
self._embed_panel: Any | None = None
|
|
602
|
+
self._watcher = SequenceWatcher()
|
|
603
|
+
self._register_all()
|
|
604
|
+
|
|
605
|
+
def handle_terminal_command(self, cmd: str) -> bool:
|
|
606
|
+
"""Processa um comando digitado no terminal integrado.
|
|
607
|
+
|
|
608
|
+
Deve ser chamado pelo TerminalPanel antes de enviar o comando ao shell.
|
|
609
|
+
Retorna True se o comando era um easter egg (e não deve ser enviado ao
|
|
610
|
+
shell), False caso contrário.
|
|
611
|
+
|
|
612
|
+
Args:
|
|
613
|
+
cmd: Texto completo da linha de comando (ex: '/codis matrix').
|
|
614
|
+
"""
|
|
615
|
+
return self._watcher.dispatch(cmd)
|
|
616
|
+
|
|
617
|
+
def attach_terminal_konami(self, terminal_widget: tk.Widget) -> None:
|
|
618
|
+
"""Vincula o Konami code ao widget de input do terminal.
|
|
619
|
+
|
|
620
|
+
Deve ser chamado pelo TerminalPanel após sua construção para que as
|
|
621
|
+
setas do teclado sejam rastreadas apenas quando o terminal tem foco.
|
|
622
|
+
|
|
623
|
+
Args:
|
|
624
|
+
terminal_widget: Widget Entry do terminal (self._input no TerminalPanel).
|
|
625
|
+
"""
|
|
626
|
+
konami_buf: list = []
|
|
627
|
+
expected = [k.lower() for k in self.KONAMI]
|
|
628
|
+
|
|
629
|
+
def _on_key(event: tk.Event) -> None:
|
|
630
|
+
sym = event.keysym
|
|
631
|
+
konami_buf.append(sym.lower() if len(sym) > 1 else sym)
|
|
632
|
+
del konami_buf[: -len(self.KONAMI)]
|
|
633
|
+
if konami_buf == expected:
|
|
634
|
+
konami_buf.clear()
|
|
635
|
+
self._fire(_konami_code)
|
|
636
|
+
|
|
637
|
+
terminal_widget.bind("<Key>", _on_key, add=True)
|
|
638
|
+
|
|
639
|
+
def _register_all(self) -> None:
|
|
640
|
+
"""Registra todos os easter eggs disponíveis no gerenciador de eventos."""
|
|
641
|
+
self._watcher.register("matrix", lambda: self._fire(_matrix_rain))
|
|
642
|
+
self._watcher.register(
|
|
643
|
+
"uwu", lambda: self._fire(_uwu_mode, self._get_ed))
|
|
644
|
+
self._watcher.register(
|
|
645
|
+
"happybirthday", lambda: self._fire(_birthday_mode))
|
|
646
|
+
self._watcher.register("42", lambda: self._fire(_deep_thought))
|
|
647
|
+
self._watcher.register("sudo", lambda: self._fire(_sudo_mode))
|
|
648
|
+
self._watcher.register("xyzzy", lambda: self._fire(_dev_console))
|
|
649
|
+
self._watcher.register("nyan", lambda: self._fire(_nyan_cat))
|
|
650
|
+
|
|
651
|
+
self._watcher.register("1123581321", self._fibonacci_egg)
|
|
652
|
+
|
|
653
|
+
self._watcher.register("20250101", self._codis_birthday)
|
|
654
|
+
|
|
655
|
+
self._watcher.register("opensesame", self._open_sesame)
|
|
656
|
+
|
|
657
|
+
self._watcher.register("doom", self._doom_egg)
|
|
658
|
+
self._watcher.register("app", lambda: self._app_embed_egg(""))
|
|
659
|
+
self._watcher.register_args("app", self._app_embed_egg)
|
|
660
|
+
|
|
661
|
+
def _fire(self, fn, *extra_args) -> None:
|
|
662
|
+
args = [self._root, self._tmgr] + list(extra_args)
|
|
663
|
+
try:
|
|
664
|
+
fn(*args)
|
|
665
|
+
except Exception as e:
|
|
666
|
+
logger.debug("Egg fire error: %s", e)
|
|
667
|
+
|
|
668
|
+
def _fibonacci_egg(self) -> None:
|
|
669
|
+
"""★★★★☆ Type '1123581321' -> Fibonacci spiral animation."""
|
|
670
|
+
t = self._tmgr.theme
|
|
671
|
+
dlg = tk.Toplevel(self._root)
|
|
672
|
+
dlg.title("🌀 Fibonacci")
|
|
673
|
+
dlg.configure(bg=t.editor_bg)
|
|
674
|
+
dlg.geometry("420x420")
|
|
675
|
+
canvas = tk.Canvas(
|
|
676
|
+
dlg, bg=t.editor_bg, highlightthickness=0, width=400, height=400
|
|
677
|
+
)
|
|
678
|
+
canvas.pack(padx=10, pady=10)
|
|
679
|
+
|
|
680
|
+
fib = [1, 1]
|
|
681
|
+
for _ in range(12):
|
|
682
|
+
fib.append(fib[-1] + fib[-2])
|
|
683
|
+
|
|
684
|
+
colors = [
|
|
685
|
+
"#cba6f7",
|
|
686
|
+
"#f38ba8",
|
|
687
|
+
"#fab387",
|
|
688
|
+
"#f9e2af",
|
|
689
|
+
"#a6e3a1",
|
|
690
|
+
"#89dceb",
|
|
691
|
+
"#89b4fa",
|
|
692
|
+
"#b4befe",
|
|
693
|
+
]
|
|
694
|
+
angle = [0]
|
|
695
|
+
step = [0]
|
|
696
|
+
stop = [False]
|
|
697
|
+
cx, cy = 200, 200
|
|
698
|
+
|
|
699
|
+
def draw():
|
|
700
|
+
if stop[0] or not dlg.winfo_exists() or step[0] >= len(fib):
|
|
701
|
+
return
|
|
702
|
+
r = fib[step[0]] * 6
|
|
703
|
+
color = colors[step[0] % len(colors)]
|
|
704
|
+
canvas.create_arc(
|
|
705
|
+
cx - r,
|
|
706
|
+
cy - r,
|
|
707
|
+
cx + r,
|
|
708
|
+
cy + r,
|
|
709
|
+
start=angle[0],
|
|
710
|
+
extent=90,
|
|
711
|
+
style="arc",
|
|
712
|
+
outline=color,
|
|
713
|
+
width=2,
|
|
714
|
+
)
|
|
715
|
+
angle[0] = (angle[0] + 90) % 360
|
|
716
|
+
step[0] += 1
|
|
717
|
+
dlg.after(120, draw)
|
|
718
|
+
|
|
719
|
+
draw()
|
|
720
|
+
dlg.bind("<Escape>", lambda _: (
|
|
721
|
+
stop.__setitem__(0, True), dlg.destroy()))
|
|
722
|
+
self._notify("🌀 Fibonacci sequence discovered!")
|
|
723
|
+
|
|
724
|
+
def _codis_birthday(self) -> None:
|
|
725
|
+
"""★★★★★ Type '20250101' (Codis launch date) -> special message."""
|
|
726
|
+
t = self._tmgr.theme
|
|
727
|
+
dlg = tk.Toplevel(self._root)
|
|
728
|
+
dlg.title("🎂 Codis Birthday")
|
|
729
|
+
dlg.configure(bg=t.floating_bg)
|
|
730
|
+
dlg.geometry("420x220")
|
|
731
|
+
|
|
732
|
+
for text, color, size in (
|
|
733
|
+
("Happy Birthday, Codis! 🎂", t.t_func, 16),
|
|
734
|
+
("Born: January 1st, 2025", t.fg, 11),
|
|
735
|
+
("You found the origin date easter egg!", t.t_string, 10),
|
|
736
|
+
("★★★★★ Legendary ★★★★★", t.warn_fg, 10),
|
|
737
|
+
):
|
|
738
|
+
tk.Label(
|
|
739
|
+
dlg, text=text, bg=t.floating_bg, fg=color, font=(
|
|
740
|
+
"Segoe UI", size)
|
|
741
|
+
).pack(pady=4)
|
|
742
|
+
|
|
743
|
+
tk.Button(
|
|
744
|
+
dlg,
|
|
745
|
+
text=_t("hc.easter_eggs.celebrate"),
|
|
746
|
+
bg=t.btn_primary,
|
|
747
|
+
fg="#000",
|
|
748
|
+
font=("Segoe UI", 10, "bold"),
|
|
749
|
+
command=dlg.destroy,
|
|
750
|
+
).pack(pady=8)
|
|
751
|
+
self._notify("★★★★★ Legendary egg found: Codis Birthday!")
|
|
752
|
+
|
|
753
|
+
def _doom_manifesto_dialog(self) -> None:
|
|
754
|
+
"""Diálogo exibido quando nenhum motor de DOOM foi encontrado."""
|
|
755
|
+
dlg = tk.Toplevel(self._root)
|
|
756
|
+
dlg.title("DOOM NOT FOUND - The Manifesto")
|
|
757
|
+
dlg.configure(bg="#1a0000")
|
|
758
|
+
dlg.wm_attributes("-topmost", True)
|
|
759
|
+
dlg.geometry("560x480")
|
|
760
|
+
tk.Label(
|
|
761
|
+
dlg,
|
|
762
|
+
text="THINGS THAT RUN DOOM",
|
|
763
|
+
bg="#1a0000",
|
|
764
|
+
fg="#ff2200",
|
|
765
|
+
font=("Courier New", 16, "bold"),
|
|
766
|
+
).pack(pady=(14, 2))
|
|
767
|
+
tk.Label(
|
|
768
|
+
dlg,
|
|
769
|
+
text="(mas o Codis ainda nao tinha o executavel instalado)",
|
|
770
|
+
bg="#1a0000",
|
|
771
|
+
fg="#883300",
|
|
772
|
+
font=("Courier New", 8),
|
|
773
|
+
).pack(pady=(0, 8))
|
|
774
|
+
LISTA = [
|
|
775
|
+
" ATM bancario (Hyosung)",
|
|
776
|
+
" Impressora HP LaserJet",
|
|
777
|
+
" Camera de seguranca Hikvision",
|
|
778
|
+
" Relogio inteligente Apple Watch",
|
|
779
|
+
" Teclado mecanico (Wooting)",
|
|
780
|
+
" Osciloscopio Rigol DS1054Z",
|
|
781
|
+
" Calculadora TI-84",
|
|
782
|
+
" Piano digital MIDI",
|
|
783
|
+
" Mamografia (equipamento medico)",
|
|
784
|
+
" Escova de dentes Oral-B",
|
|
785
|
+
" Tela de aviao Boeing",
|
|
786
|
+
" Caixao inteligente (nao pergunte)",
|
|
787
|
+
" Geladeira Samsung SmartThings",
|
|
788
|
+
" Codis IDE <- PROXIMO DA LISTA",
|
|
789
|
+
]
|
|
790
|
+
lf = tk.Frame(dlg, bg="#000000")
|
|
791
|
+
lf.pack(fill="both", expand=True, padx=14, pady=4)
|
|
792
|
+
for item in LISTA:
|
|
793
|
+
c = "#ff4400" if "Codis" in item else "#cc3300"
|
|
794
|
+
w = "bold" if "Codis" in item else "normal"
|
|
795
|
+
tk.Label(
|
|
796
|
+
lf,
|
|
797
|
+
text=item,
|
|
798
|
+
bg="#000000",
|
|
799
|
+
fg=c,
|
|
800
|
+
font=("Courier New", 9, w),
|
|
801
|
+
anchor="w",
|
|
802
|
+
).pack(fill="x", padx=8, pady=1)
|
|
803
|
+
tk.Label(
|
|
804
|
+
dlg,
|
|
805
|
+
text=_t("doom.err_no_engine"),
|
|
806
|
+
wraplength=520,
|
|
807
|
+
bg="#1a0000",
|
|
808
|
+
fg="#664400",
|
|
809
|
+
font=("Courier New", 8),
|
|
810
|
+
).pack(pady=4)
|
|
811
|
+
tk.Button(
|
|
812
|
+
dlg,
|
|
813
|
+
text="I'll install DOOM right now",
|
|
814
|
+
bg="#550000",
|
|
815
|
+
fg="#ff4400",
|
|
816
|
+
font=("Courier New", 10, "bold"),
|
|
817
|
+
relief="flat",
|
|
818
|
+
cursor="hand2",
|
|
819
|
+
command=dlg.destroy,
|
|
820
|
+
).pack(pady=8)
|
|
821
|
+
dlg.after(25_000, lambda: dlg.destroy() if dlg.winfo_exists() else None)
|
|
822
|
+
|
|
823
|
+
def _doom_egg(self) -> None:
|
|
824
|
+
"""Legendary /codis doom - embute uma janela nativa do DOOM no editor.
|
|
825
|
+
|
|
826
|
+
A janela do motor (gzdoom, chocolate-doom...) é reparentada de verdade ao
|
|
827
|
+
frame do editor (``SetParent`` no Windows, ``XReparentWindow`` no X11);
|
|
828
|
+
veja :mod:`src.ui.doom_embed` e :mod:`src.ui.window_embed`.
|
|
829
|
+
"""
|
|
830
|
+
from src.ui import doom_embed
|
|
831
|
+
|
|
832
|
+
panel = self._doom_panel
|
|
833
|
+
if panel is not None:
|
|
834
|
+
with contextlib.suppress(tk.TclError):
|
|
835
|
+
if panel.winfo_exists():
|
|
836
|
+
panel.focus_game()
|
|
837
|
+
return
|
|
838
|
+
self._doom_panel = None
|
|
839
|
+
|
|
840
|
+
try:
|
|
841
|
+
plan = doom_embed.resolve_plan(self._cfg)
|
|
842
|
+
except doom_embed.DoomLaunchError as exc:
|
|
843
|
+
if exc.kind == "engine":
|
|
844
|
+
self._doom_manifesto_dialog()
|
|
845
|
+
self._notify(str(exc))
|
|
846
|
+
return
|
|
847
|
+
|
|
848
|
+
container = self._get_container() if self._get_container else None
|
|
849
|
+
if container is not None:
|
|
850
|
+
try:
|
|
851
|
+
self._doom_panel = doom_embed.start_embedded(
|
|
852
|
+
container,
|
|
853
|
+
plan,
|
|
854
|
+
on_status=self._notify,
|
|
855
|
+
on_close=self._on_doom_closed,
|
|
856
|
+
)
|
|
857
|
+
return
|
|
858
|
+
except doom_embed.DoomLaunchError as exc:
|
|
859
|
+
logger.info("[DOOM] sem embutir (%s) - usando janela externa", exc)
|
|
860
|
+
self._notify(str(exc))
|
|
861
|
+
|
|
862
|
+
try:
|
|
863
|
+
doom_embed.launch_external(plan)
|
|
864
|
+
except doom_embed.DoomLaunchError as exc:
|
|
865
|
+
self._notify(str(exc))
|
|
866
|
+
|
|
867
|
+
def _app_embed_egg(self, args: str) -> None:
|
|
868
|
+
"""``/codis app`` - incorpora qualquer programa (ver :mod:`src.ui.app_embed`).
|
|
869
|
+
|
|
870
|
+
Sem argumentos abre o seletor (janelas em execução / iniciar .exe).
|
|
871
|
+
``/codis app notepad.exe`` adota a janela do processo; ``/codis app
|
|
872
|
+
C:\\caminho\\prog.exe [args]`` inicia e incorpora.
|
|
873
|
+
"""
|
|
874
|
+
from src.ui import app_embed
|
|
875
|
+
from src.ui import window_embed as we
|
|
876
|
+
|
|
877
|
+
panel = self._embed_panel
|
|
878
|
+
if panel is not None:
|
|
879
|
+
with contextlib.suppress(tk.TclError):
|
|
880
|
+
if panel.winfo_exists():
|
|
881
|
+
self._notify(_t("embed.already", "Já há um programa incorporado; devolva-o antes."))
|
|
882
|
+
panel.focus_game()
|
|
883
|
+
return
|
|
884
|
+
self._embed_panel = None
|
|
885
|
+
|
|
886
|
+
container = self._get_container() if self._get_container else None
|
|
887
|
+
backend = we.get_backend()
|
|
888
|
+
|
|
889
|
+
def _closed() -> None:
|
|
890
|
+
self._embed_panel = None
|
|
891
|
+
|
|
892
|
+
def _adopt(name: str, win: Any | None) -> None:
|
|
893
|
+
if container is None or backend is None:
|
|
894
|
+
self._notify(_t("embed.status_external", "Incorporar janelas não é possível neste ambiente."))
|
|
895
|
+
return
|
|
896
|
+
try:
|
|
897
|
+
self._embed_panel = app_embed.start_adopt(
|
|
898
|
+
container, exe_name=name, window=win, backend=backend,
|
|
899
|
+
on_status=self._notify, on_close=_closed)
|
|
900
|
+
except we.EmbedError as exc:
|
|
901
|
+
self._notify(str(exc))
|
|
902
|
+
|
|
903
|
+
def _launch(spec: Any) -> None:
|
|
904
|
+
if container is not None and backend is not None:
|
|
905
|
+
try:
|
|
906
|
+
self._embed_panel = app_embed.start_launch(
|
|
907
|
+
container, spec, backend=backend, on_status=self._notify, on_close=_closed)
|
|
908
|
+
return
|
|
909
|
+
except we.EmbedError as exc:
|
|
910
|
+
self._notify(str(exc))
|
|
911
|
+
try:
|
|
912
|
+
app_embed.launch_external(spec)
|
|
913
|
+
except we.EmbedError as exc:
|
|
914
|
+
self._notify(str(exc))
|
|
915
|
+
|
|
916
|
+
args = args.strip()
|
|
917
|
+
if args:
|
|
918
|
+
from pathlib import Path
|
|
919
|
+
|
|
920
|
+
candidate = Path(args.strip('"')).expanduser()
|
|
921
|
+
if candidate.is_file():
|
|
922
|
+
_launch(app_embed.AppSpec(candidate))
|
|
923
|
+
else:
|
|
924
|
+
_adopt(args.strip('"'), None)
|
|
925
|
+
return
|
|
926
|
+
app_embed.AppEmbedDialog(
|
|
927
|
+
self._root, self._tmgr, backend, _adopt, _launch, self._cfg)
|
|
928
|
+
|
|
929
|
+
def _on_doom_closed(self) -> None:
|
|
930
|
+
"""Callback do painel: libera a referência ao encerrar o jogo."""
|
|
931
|
+
self._doom_panel = None
|
|
932
|
+
|
|
933
|
+
def _open_sesame(self) -> None:
|
|
934
|
+
"""★★★★★ Type 'opensesame' -> unlocks a joke hidden settings panel."""
|
|
935
|
+
t = self._tmgr.theme
|
|
936
|
+
dlg = tk.Toplevel(self._root)
|
|
937
|
+
dlg.title("🗝 Open Sesame - Secret Settings")
|
|
938
|
+
dlg.configure(bg=t.floating_bg)
|
|
939
|
+
dlg.geometry("400x320")
|
|
940
|
+
|
|
941
|
+
tk.Label(
|
|
942
|
+
dlg,
|
|
943
|
+
text=_t("hc.easter_eggs.secret_settings_unlocked"),
|
|
944
|
+
bg=t.floating_bg,
|
|
945
|
+
fg=t.t_func,
|
|
946
|
+
font=("Courier New", 13, "bold"),
|
|
947
|
+
).pack(pady=(14, 6))
|
|
948
|
+
|
|
949
|
+
settings = [
|
|
950
|
+
("☕ Infinite coffee mode", True),
|
|
951
|
+
("🦆 Rubber duck debug assistant", True),
|
|
952
|
+
("🚀 10x developer boost", True),
|
|
953
|
+
("😴 Auto-naptime after 2am", False),
|
|
954
|
+
("🎲 Randomly rename variables", False),
|
|
955
|
+
("🌈 Syntax highlighting in Comic Sans", False),
|
|
956
|
+
]
|
|
957
|
+
|
|
958
|
+
for label, default in settings:
|
|
959
|
+
var = tk.BooleanVar(value=default)
|
|
960
|
+
tk.Checkbutton(
|
|
961
|
+
dlg,
|
|
962
|
+
text=label,
|
|
963
|
+
variable=var,
|
|
964
|
+
bg=t.floating_bg,
|
|
965
|
+
fg=t.fg,
|
|
966
|
+
selectcolor=t.input_bg,
|
|
967
|
+
activebackground=t.floating_bg,
|
|
968
|
+
font=("Segoe UI", 9),
|
|
969
|
+
).pack(anchor="w", padx=20)
|
|
970
|
+
|
|
971
|
+
tk.Button(
|
|
972
|
+
dlg,
|
|
973
|
+
text=_t("hc.easter_eggs.apply_does_nothing_lol"),
|
|
974
|
+
bg=t.btn_bg,
|
|
975
|
+
fg=t.fg,
|
|
976
|
+
font=("Segoe UI", 9),
|
|
977
|
+
command=dlg.destroy,
|
|
978
|
+
).pack(pady=12)
|
|
979
|
+
self._notify("🗝 Open Sesame! Secret settings revealed.")
|