codis 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codis-1.1.1.dist-info/METADATA +194 -0
- codis-1.1.1.dist-info/RECORD +329 -0
- codis-1.1.1.dist-info/WHEEL +5 -0
- codis-1.1.1.dist-info/entry_points.txt +5 -0
- codis-1.1.1.dist-info/licenses/LICENSE +21 -0
- codis-1.1.1.dist-info/top_level.txt +2 -0
- run.py +190 -0
- src/__init__.py +1 -0
- src/__main__.py +81 -0
- src/_app_build.py +1507 -0
- src/_app_editor.py +1274 -0
- src/_app_kui.py +825 -0
- src/_app_lsp.py +625 -0
- src/_app_recovery.py +189 -0
- src/_app_settings.py +1385 -0
- src/_app_tools.py +2471 -0
- src/_app_webpreview.py +126 -0
- src/_font_safety.py +127 -0
- src/_shells.py +172 -0
- src/app.py +1488 -0
- src/chat/__init__.py +1 -0
- src/chat/adapters/__init__.py +33 -0
- src/chat/adapters/base.py +209 -0
- src/chat/adapters/discord.py +190 -0
- src/chat/adapters/http.py +78 -0
- src/chat/adapters/irc.py +360 -0
- src/chat/adapters/matrix.py +219 -0
- src/chat/adapters/mattermost.py +178 -0
- src/chat/adapters/mqtt.py +165 -0
- src/chat/adapters/slack.py +204 -0
- src/chat/adapters/telegram.py +117 -0
- src/chat/adapters/ws.py +154 -0
- src/chat/adapters/xmpp.py +337 -0
- src/chat/history.py +76 -0
- src/chat/models.py +207 -0
- src/chat/probe.py +79 -0
- src/chat/session.py +446 -0
- src/chat/util.py +125 -0
- src/collab/__init__.py +1 -0
- src/collab/net.py +411 -0
- src/collab/ot.py +311 -0
- src/collab/session.py +141 -0
- src/collab/tk_adapter.py +134 -0
- src/config.py +335 -0
- src/constants.py +2552 -0
- src/dep_catalog.py +446 -0
- src/diff/__init__.py +1 -0
- src/diff/engine.py +247 -0
- src/dpi.py +30 -0
- src/editor/__init__.py +1 -0
- src/editor/_pane_lsp.py +2937 -0
- src/editor/_pane_utils.py +171 -0
- src/editor/autocomplete.py +607 -0
- src/editor/code_folding.py +836 -0
- src/editor/color_preview.py +382 -0
- src/editor/complexity_lens.py +281 -0
- src/editor/diff_pane.py +623 -0
- src/editor/file_watcher.py +144 -0
- src/editor/focus_block.py +236 -0
- src/editor/heatmap.py +141 -0
- src/editor/inlay_hints.py +366 -0
- src/editor/inline_blame.py +429 -0
- src/editor/kdocs.py +3376 -0
- src/editor/large_file.py +488 -0
- src/editor/ligatures.py +180 -0
- src/editor/line_numbers.py +598 -0
- src/editor/minimap.py +691 -0
- src/editor/multi_cursor.py +269 -0
- src/editor/pane.py +2082 -0
- src/editor/rhythm.py +206 -0
- src/editor/save_hooks.py +43 -0
- src/editor/smart_selection.py +425 -0
- src/editor/smart_tips.py +719 -0
- src/editor/snippets.py +411 -0
- src/editor/sticky_note_gutter.py +410 -0
- src/editor/sticky_scroll.py +385 -0
- src/editor/suggest.py +464 -0
- src/editor/text_transforms.py +310 -0
- src/editor/vim_mode.py +1074 -0
- src/events/__init__.py +84 -0
- src/events/bus.py +427 -0
- src/events/correlator.py +244 -0
- src/events/kinds.py +125 -0
- src/events/pipeline.py +264 -0
- src/events/stream.py +416 -0
- src/events/window.py +204 -0
- src/extcompat/__init__.py +19 -0
- src/extcompat/code/__init__.py +13 -0
- src/extcompat/code/consent.py +162 -0
- src/extcompat/code/host.py +353 -0
- src/extcompat/code/hosts/py_host.py +763 -0
- src/extcompat/code/locate.py +105 -0
- src/extcompat/code/manager.py +325 -0
- src/extcompat/code/permissions.py +154 -0
- src/extcompat/code/sandbox.py +60 -0
- src/extcompat/colors.py +131 -0
- src/extcompat/common.py +184 -0
- src/extcompat/cson.py +269 -0
- src/extcompat/formats/__init__.py +22 -0
- src/extcompat/formats/_tm.py +189 -0
- src/extcompat/formats/_util.py +31 -0
- src/extcompat/formats/base16.py +66 -0
- src/extcompat/formats/brackets.py +172 -0
- src/extcompat/formats/eclipse.py +193 -0
- src/extcompat/formats/emacs.py +361 -0
- src/extcompat/formats/geany.py +147 -0
- src/extcompat/formats/generic.py +184 -0
- src/extcompat/formats/gtksource.py +117 -0
- src/extcompat/formats/helix.py +91 -0
- src/extcompat/formats/jetbrains.py +343 -0
- src/extcompat/formats/kate.py +130 -0
- src/extcompat/formats/micro.py +131 -0
- src/extcompat/formats/nano.py +111 -0
- src/extcompat/formats/notepadpp.py +140 -0
- src/extcompat/formats/pulsar.py +165 -0
- src/extcompat/formats/pyides.py +163 -0
- src/extcompat/formats/sublime.py +340 -0
- src/extcompat/jsonc.py +65 -0
- src/extcompat/lessish.py +128 -0
- src/extcompat/manager.py +122 -0
- src/extcompat/market/__init__.py +63 -0
- src/extcompat/market/sources.py +211 -0
- src/extcompat/model.py +88 -0
- src/extcompat/net.py +228 -0
- src/extcompat/openvsx.py +63 -0
- src/extcompat/readers.py +362 -0
- src/extcompat/registry.py +73 -0
- src/extcompat/safexml.py +63 -0
- src/extcompat/sexp.py +187 -0
- src/extcompat/sources.py +105 -0
- src/extcompat/store.py +276 -0
- src/extcompat/textmate.py +214 -0
- src/extcompat/themes.py +487 -0
- src/extcompat/yamlite.py +294 -0
- src/fileio.py +94 -0
- src/fs_ops.py +106 -0
- src/i18n.py +233 -0
- src/ia/__init__.py +1 -0
- src/ia/actions.py +295 -0
- src/ia/approval_gate.py +672 -0
- src/ia/checkpoints.py +308 -0
- src/ia/context_builder.py +921 -0
- src/ia/dialdiff.py +408 -0
- src/ia/iaspace.py +2078 -0
- src/ia/pair.py +296 -0
- src/ia/providers.py +954 -0
- src/ia/session.py +335 -0
- src/ia/toolbox.py +2524 -0
- src/launcher_actions.py +204 -0
- src/lint/__init__.py +1 -0
- src/lint/manager.py +1058 -0
- src/locales/.translate_manifest.json +64170 -0
- src/locales/de.json +4936 -0
- src/locales/en.json +4936 -0
- src/locales/es.json +4936 -0
- src/locales/fr.json +4936 -0
- src/locales/it.json +4936 -0
- src/locales/ja.json +4936 -0
- src/locales/ko.json +4936 -0
- src/locales/nl.json +4936 -0
- src/locales/pl.json +4936 -0
- src/locales/pt-BR.json +4936 -0
- src/locales/ru.json +4936 -0
- src/locales/tr.json +4936 -0
- src/locales/uk.json +4936 -0
- src/locales/zh-CN.json +4936 -0
- src/lsp/__init__.py +26 -0
- src/lsp/client.py +2300 -0
- src/lsp/dap_client.py +480 -0
- src/lsp/edits.py +84 -0
- src/lsp/framing.py +73 -0
- src/lsp/protocol.py +931 -0
- src/main.py +260 -0
- src/memtrim.py +91 -0
- src/plugins/__init__.py +1 -0
- src/plugins/api.py +1761 -0
- src/plugins/loader.py +571 -0
- src/plugins/process_runner.py +519 -0
- src/plugins/registry.py +342 -0
- src/plugins/safety.py +367 -0
- src/plugins/startup.py +195 -0
- src/plugins/store.py +1178 -0
- src/proc_registry.py +278 -0
- src/pyexec.py +394 -0
- src/recovery.py +259 -0
- src/stall_trace.py +92 -0
- src/standalone.py +1070 -0
- src/startup_profile.py +35 -0
- src/syntax/__init__.py +1 -0
- src/syntax/highlighter.py +776 -0
- src/syntax/patterns.py +584 -0
- src/system_profile.py +430 -0
- src/terminal/backends.py +658 -0
- src/terminal/internal.py +346 -0
- src/terminal/keys.py +138 -0
- src/terminal/palette.py +67 -0
- src/terminal/session.py +283 -0
- src/terminal/shells.py +79 -0
- src/terminal/view.py +489 -0
- src/terminal/vt.py +870 -0
- src/textfmt.py +22 -0
- src/theme/__init__.py +1 -0
- src/theme/base.py +1281 -0
- src/theme/colors.py +49 -0
- src/theme/manager.py +602 -0
- src/theme/utils.py +312 -0
- src/toolbox.py +329 -0
- src/trash_core.py +531 -0
- src/ui/__init__.py +1 -0
- src/ui/_perf_utils.py +285 -0
- src/ui/_persistence_utils.py +93 -0
- src/ui/accessibility.py +843 -0
- src/ui/activity_bar.py +860 -0
- src/ui/app_embed.py +434 -0
- src/ui/archive_panel.py +608 -0
- src/ui/bookmarks.py +314 -0
- src/ui/breadcrumb.py +383 -0
- src/ui/calculator_panel.py +982 -0
- src/ui/calendar_panel.py +1218 -0
- src/ui/chat_panel.py +1271 -0
- src/ui/chat_profile_dialog.py +278 -0
- src/ui/chat_render.py +128 -0
- src/ui/clock_panel.py +810 -0
- src/ui/code_outline.py +364 -0
- src/ui/code_runner.py +729 -0
- src/ui/code_stats.py +546 -0
- src/ui/collab_panel.py +1009 -0
- src/ui/color_picker.py +547 -0
- src/ui/command_palette.py +452 -0
- src/ui/cursor_manager.py +750 -0
- src/ui/custom_keywords_panel.py +413 -0
- src/ui/debug_panel.py +1037 -0
- src/ui/dependency_graph.py +692 -0
- src/ui/diff_panel.py +381 -0
- src/ui/docs_panel.py +514 -0
- src/ui/doom_embed.py +349 -0
- src/ui/dropdown.py +321 -0
- src/ui/easter_eggs.py +979 -0
- src/ui/env_manager.py +666 -0
- src/ui/extcode_bridge.py +215 -0
- src/ui/extcode_dialogs.py +412 -0
- src/ui/extcompat_dialog.py +583 -0
- src/ui/file_timeline.py +319 -0
- src/ui/file_tree.py +1208 -0
- src/ui/find_in_files.py +1355 -0
- src/ui/flowchart_panel.py +727 -0
- src/ui/formatter_panel.py +490 -0
- src/ui/git_auth.py +763 -0
- src/ui/git_clone_dialog.py +487 -0
- src/ui/git_panel.py +1483 -0
- src/ui/grab_safe.py +84 -0
- src/ui/internal_python_dialog.py +98 -0
- src/ui/k_ui/__init__.py +1305 -0
- src/ui/k_ui/_bgrenderer.py +317 -0
- src/ui/k_ui/_colors.py +213 -0
- src/ui/k_ui/_dock.py +545 -0
- src/ui/k_ui/_easter.py +290 -0
- src/ui/k_ui/_engine.py +5448 -0
- src/ui/k_ui/_perf.py +333 -0
- src/ui/k_ui/_tkutil.py +7 -0
- src/ui/k_ui/_tooltip.py +365 -0
- src/ui/k_ui/_widgets.py +1204 -0
- src/ui/k_ui/_world.py +837 -0
- src/ui/key_remapper.py +856 -0
- src/ui/launcher.py +1252 -0
- src/ui/lazy_panel.py +73 -0
- src/ui/macro_recorder.py +610 -0
- src/ui/menu_bar.py +898 -0
- src/ui/output_panel.py +321 -0
- src/ui/paint_canvas.py +1000 -0
- src/ui/paint_engine.py +535 -0
- src/ui/paint_panel.py +888 -0
- src/ui/panel_detach.py +112 -0
- src/ui/performance_panel.py +861 -0
- src/ui/pip_manager.py +1758 -0
- src/ui/plugin_panel.py +1586 -0
- src/ui/pomodoro_panel.py +447 -0
- src/ui/problems.py +566 -0
- src/ui/process_manager.py +1657 -0
- src/ui/project_templates.py +775 -0
- src/ui/recovery_dialog.py +122 -0
- src/ui/regex_playground.py +304 -0
- src/ui/remote_adapters.py +1398 -0
- src/ui/remote_browser.py +1224 -0
- src/ui/remote_profile_dialog.py +342 -0
- src/ui/render_panel.py +1293 -0
- src/ui/rest_client.py +549 -0
- src/ui/scratchpad.py +548 -0
- src/ui/search_bar.py +1274 -0
- src/ui/settings_editor.py +3349 -0
- src/ui/settings_window.py +1554 -0
- src/ui/snippets_panel.py +597 -0
- src/ui/sql_studio.py +1815 -0
- src/ui/status_bar.py +438 -0
- src/ui/tab_bar.py +654 -0
- src/ui/task_manager.py +1773 -0
- src/ui/terminal.py +525 -0
- src/ui/theme_preview_panel.py +851 -0
- src/ui/thread_safe_tk.py +152 -0
- src/ui/time_tracker.py +574 -0
- src/ui/tkbind.py +43 -0
- src/ui/todo_panel.py +358 -0
- src/ui/toolbox_panels.py +658 -0
- src/ui/trash_manager.py +657 -0
- src/ui/ui_scale.py +294 -0
- src/ui/ux_enhancements.py +41 -0
- src/ui/web_preview.py +397 -0
- src/ui/webdev.py +630 -0
- src/ui/welcome.py +567 -0
- src/ui/window_embed.py +1500 -0
- src/ui/wizard.py +1550 -0
- src/ui/workspace_switcher.py +418 -0
- src/ui/workspace_trust.py +370 -0
- src/ui/zen_audio.py +354 -0
- src/ui/zen_media.py +2271 -0
- src/ui/zen_media_client.py +303 -0
- src/ui/zen_media_host.py +329 -0
- src/ui/zen_player.py +907 -0
- src/ui/zen_player_widgets.py +700 -0
- src/updater/__init__.py +11 -0
- src/updater/assets.py +145 -0
- src/updater/backup.py +101 -0
- src/updater/channel.py +221 -0
- src/updater/dialog.py +492 -0
- src/updater/integrity.py +111 -0
- src/updater/manager.py +727 -0
- src/updater/result.py +114 -0
- src/venv_runtime.py +531 -0
- src/workspace_state.py +25 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"""Codis - ColorPreview: exibição de swatches de cor inline no editor.
|
|
2
|
+
|
|
3
|
+
Renderiza pequenos retângulos coloridos ao lado de valores de cor no código
|
|
4
|
+
(hex, rgb, rgba, hsl, hsla, named CSS colors). Funciona em arquivos CSS,
|
|
5
|
+
SCSS, LESS, HTML, JS, TS, Python e qualquer linguagem com strings de cor.
|
|
6
|
+
|
|
7
|
+
Clicar em um swatch abre o Color Picker do sistema para editar a cor
|
|
8
|
+
diretamente no código.
|
|
9
|
+
|
|
10
|
+
Implementação: usa tags Tkinter com background colorido em um caractere
|
|
11
|
+
unicode de bloco sólido (█) inserido como texto de leitura, sem modificar
|
|
12
|
+
o conteúdo real do editor.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import colorsys
|
|
18
|
+
import contextlib
|
|
19
|
+
import logging
|
|
20
|
+
import re
|
|
21
|
+
import tkinter as tk
|
|
22
|
+
import tkinter.colorchooser as tkcc
|
|
23
|
+
from typing import TYPE_CHECKING
|
|
24
|
+
|
|
25
|
+
from src.i18n import _t
|
|
26
|
+
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
from src.theme.base import Theme
|
|
29
|
+
|
|
30
|
+
logger = logging.getLogger("Codis")
|
|
31
|
+
|
|
32
|
+
_COLOR_PATTERNS: list[tuple[re.Pattern, str]] = [
|
|
33
|
+
(
|
|
34
|
+
re.compile(
|
|
35
|
+
r"#([0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b"),
|
|
36
|
+
"hex",
|
|
37
|
+
),
|
|
38
|
+
(
|
|
39
|
+
re.compile(
|
|
40
|
+
r"rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})"
|
|
41
|
+
r"(?:\s*,\s*[\d.]+)?\s*\)"
|
|
42
|
+
),
|
|
43
|
+
"rgb",
|
|
44
|
+
),
|
|
45
|
+
(
|
|
46
|
+
re.compile(
|
|
47
|
+
r"hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%"
|
|
48
|
+
r"(?:\s*,\s*[\d.]+)?\s*\)"
|
|
49
|
+
),
|
|
50
|
+
"hsl",
|
|
51
|
+
),
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
_NAMED_COLORS: dict[str, str] = {
|
|
55
|
+
"red": "#ff0000",
|
|
56
|
+
"green": "#008000",
|
|
57
|
+
"blue": "#0000ff",
|
|
58
|
+
"white": "#ffffff",
|
|
59
|
+
"black": "#000000",
|
|
60
|
+
"yellow": "#ffff00",
|
|
61
|
+
"orange": "#ffa500",
|
|
62
|
+
"purple": "#800080",
|
|
63
|
+
"pink": "#ffc0cb",
|
|
64
|
+
"cyan": "#00ffff",
|
|
65
|
+
"magenta": "#ff00ff",
|
|
66
|
+
"lime": "#00ff00",
|
|
67
|
+
"teal": "#008080",
|
|
68
|
+
"navy": "#000080",
|
|
69
|
+
"gray": "#808080",
|
|
70
|
+
"grey": "#808080",
|
|
71
|
+
"silver": "#c0c0c0",
|
|
72
|
+
"maroon": "#800000",
|
|
73
|
+
"olive": "#808000",
|
|
74
|
+
"coral": "#ff7f50",
|
|
75
|
+
"salmon": "#fa8072",
|
|
76
|
+
"gold": "#ffd700",
|
|
77
|
+
"khaki": "#f0e68c",
|
|
78
|
+
"violet": "#ee82ee",
|
|
79
|
+
"indigo": "#4b0082",
|
|
80
|
+
"crimson": "#dc143c",
|
|
81
|
+
"turquoise": "#40e0d0",
|
|
82
|
+
"transparent": "#808080",
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
_SWATCH_TAG_PREFIX = "color_swatch_"
|
|
86
|
+
|
|
87
|
+
_SWATCH_CHAR = "█"
|
|
88
|
+
|
|
89
|
+
_DEBOUNCE_MS = 300
|
|
90
|
+
|
|
91
|
+
_MAX_SWATCHES = 500
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _hex_to_rgb(hex_color: str) -> tuple[int, int, int] | None:
|
|
95
|
+
"""Converte string hex para tupla (r, g, b).
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
hex_color: String hex com ou sem '#', 3, 4, 6 ou 8 dígitos.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
tuple[int, int, int] | None: Componentes RGB (0-255) ou None se inválido.
|
|
102
|
+
"""
|
|
103
|
+
h = hex_color.lstrip("#")
|
|
104
|
+
try:
|
|
105
|
+
if len(h) in (3, 4):
|
|
106
|
+
r, g, b = int(h[0] * 2, 16), int(h[1] * 2, 16), int(h[2] * 2, 16)
|
|
107
|
+
elif len(h) in (6, 8):
|
|
108
|
+
r, g, b = int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16)
|
|
109
|
+
else:
|
|
110
|
+
return None
|
|
111
|
+
return (r, g, b)
|
|
112
|
+
except ValueError:
|
|
113
|
+
return None
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _rgb_to_hex(r: int, g: int, b: int) -> str:
|
|
117
|
+
"""Converte componentes RGB para string hex.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
r: Canal vermelho (0-255).
|
|
121
|
+
g: Canal verde (0-255).
|
|
122
|
+
b: Canal azul (0-255).
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
str: String hex no formato '#rrggbb'.
|
|
126
|
+
"""
|
|
127
|
+
return f"#{r:02x}{g:02x}{b:02x}"
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _contrast_fg(r: int, g: int, b: int) -> str:
|
|
131
|
+
"""Calcula a cor de texto com melhor contraste (preto ou branco).
|
|
132
|
+
|
|
133
|
+
Usa luminância relativa segundo WCAG 2.1 para garantir legibilidade.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
r: Canal vermelho (0-255).
|
|
137
|
+
g: Canal verde (0-255).
|
|
138
|
+
b: Canal azul (0-255).
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
str: '#000000' ou '#ffffff'.
|
|
142
|
+
"""
|
|
143
|
+
lum = 0.2126 * (r / 255) + 0.7152 * (g / 255) + 0.0722 * (b / 255)
|
|
144
|
+
return "#000000" if lum > 0.5 else "#ffffff"
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _parse_color(match_text: str, kind: str) -> str | None:
|
|
148
|
+
"""Parseia um match de cor para hex canônico.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
match_text: Texto completo do match (ex: '#ff0000', 'rgb(255,0,0)').
|
|
152
|
+
kind: Tipo do match ('hex', 'rgb', 'hsl').
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
str | None: Hex no formato '#rrggbb' ou None se não parseável.
|
|
156
|
+
"""
|
|
157
|
+
if kind == "hex":
|
|
158
|
+
return (
|
|
159
|
+
_rgb_to_hex(*(_hex_to_rgb(match_text) or (0, 0, 0)))
|
|
160
|
+
if _hex_to_rgb(match_text)
|
|
161
|
+
else None
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
if kind == "rgb":
|
|
165
|
+
m = re.search(r"(\d+),\s*(\d+),\s*(\d+)", match_text)
|
|
166
|
+
if m:
|
|
167
|
+
r, g, b = int(m.group(1)), int(m.group(2)), int(m.group(3))
|
|
168
|
+
return _rgb_to_hex(min(r, 255), min(g, 255), min(b, 255))
|
|
169
|
+
|
|
170
|
+
if kind == "hsl":
|
|
171
|
+
m = re.search(r"(\d+),\s*(\d+)%,\s*(\d+)%", match_text)
|
|
172
|
+
if m:
|
|
173
|
+
h, s, l_ = (
|
|
174
|
+
int(m.group(1)) / 360,
|
|
175
|
+
int(m.group(2)) / 100,
|
|
176
|
+
int(m.group(3)) / 100,
|
|
177
|
+
)
|
|
178
|
+
r, g, b = colorsys.hls_to_rgb(h, l_, s)
|
|
179
|
+
return _rgb_to_hex(int(r * 255), int(g * 255), int(b * 255))
|
|
180
|
+
|
|
181
|
+
return None
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class ColorPreview:
|
|
185
|
+
"""Gerencia swatches de cor inline no widget de texto do editor.
|
|
186
|
+
|
|
187
|
+
Varre o documento periodicamente para detectar valores de cor e insere
|
|
188
|
+
pequenos blocos coloridos ao lado de cada ocorrência. Clicar em um
|
|
189
|
+
swatch abre o color picker para edição direta.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
txt: Widget tk.Text do editor.
|
|
193
|
+
theme: Tema visual ativo.
|
|
194
|
+
on_edit_callback: Callback(old_text, new_text, line, col) acionado
|
|
195
|
+
quando o usuário edita uma cor pelo color picker.
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
def __init__(
|
|
199
|
+
self,
|
|
200
|
+
txt: tk.Text,
|
|
201
|
+
theme: Theme,
|
|
202
|
+
on_edit_callback: callable | None = None,
|
|
203
|
+
) -> None:
|
|
204
|
+
self._txt = txt
|
|
205
|
+
self._theme = theme
|
|
206
|
+
self._on_edit = on_edit_callback
|
|
207
|
+
self._enabled = False
|
|
208
|
+
self._after_id: str | None = None
|
|
209
|
+
|
|
210
|
+
self._swatches: dict[str, tuple[int, int, str, str]] = {}
|
|
211
|
+
self._swatch_counter = 0
|
|
212
|
+
|
|
213
|
+
def set_enabled(self, enabled: bool) -> None:
|
|
214
|
+
"""Habilita ou desabilita os swatches de cor."""
|
|
215
|
+
self._enabled = enabled
|
|
216
|
+
if enabled:
|
|
217
|
+
self._schedule_scan()
|
|
218
|
+
else:
|
|
219
|
+
self.clear()
|
|
220
|
+
|
|
221
|
+
def notify_change(self) -> None:
|
|
222
|
+
"""Notifica que o conteúdo do editor mudou - re-escaneia com debounce."""
|
|
223
|
+
if self._enabled:
|
|
224
|
+
self._schedule_scan()
|
|
225
|
+
|
|
226
|
+
def clear(self) -> None:
|
|
227
|
+
"""Remove todos os marcadores de prévia de cor do widget de texto."""
|
|
228
|
+
for tag in list(self._swatches.keys()):
|
|
229
|
+
self._remove_swatch(tag)
|
|
230
|
+
self._swatches.clear()
|
|
231
|
+
|
|
232
|
+
def apply_theme(self, theme: Theme) -> None:
|
|
233
|
+
"""Aplica novo tema e re-renderiza os swatches.
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
theme: Novo objeto Theme com as cores atualizadas.
|
|
237
|
+
"""
|
|
238
|
+
self._theme = theme
|
|
239
|
+
if self._enabled:
|
|
240
|
+
self.clear()
|
|
241
|
+
self._schedule_scan()
|
|
242
|
+
|
|
243
|
+
def _schedule_scan(self) -> None:
|
|
244
|
+
"""Agenda varredura com debounce."""
|
|
245
|
+
if self._after_id:
|
|
246
|
+
with contextlib.suppress(tk.TclError):
|
|
247
|
+
self._txt.after_cancel(self._after_id)
|
|
248
|
+
self._after_id = self._txt.after(_DEBOUNCE_MS, self._scan)
|
|
249
|
+
|
|
250
|
+
def _scan(self) -> None:
|
|
251
|
+
"""Varre o documento por valores de cor e renderiza swatches."""
|
|
252
|
+
self._after_id = None
|
|
253
|
+
if not self._txt.winfo_exists():
|
|
254
|
+
return
|
|
255
|
+
if not self._enabled:
|
|
256
|
+
return
|
|
257
|
+
|
|
258
|
+
try:
|
|
259
|
+
content = self._txt.get("1.0", "end-1c")
|
|
260
|
+
except tk.TclError:
|
|
261
|
+
return
|
|
262
|
+
|
|
263
|
+
self.clear()
|
|
264
|
+
|
|
265
|
+
lines = content.splitlines()
|
|
266
|
+
swatch_count = 0
|
|
267
|
+
|
|
268
|
+
for line_idx, line in enumerate(lines):
|
|
269
|
+
if swatch_count >= _MAX_SWATCHES:
|
|
270
|
+
break
|
|
271
|
+
line_num = line_idx + 1
|
|
272
|
+
|
|
273
|
+
for pattern, kind in _COLOR_PATTERNS:
|
|
274
|
+
for m in pattern.finditer(line):
|
|
275
|
+
if swatch_count >= _MAX_SWATCHES:
|
|
276
|
+
break
|
|
277
|
+
col = m.start()
|
|
278
|
+
hex_color = _parse_color(m.group(0), kind)
|
|
279
|
+
if hex_color:
|
|
280
|
+
self._insert_swatch(
|
|
281
|
+
line_num, col, m.group(0), hex_color)
|
|
282
|
+
swatch_count += 1
|
|
283
|
+
|
|
284
|
+
for name, hex_color in _NAMED_COLORS.items():
|
|
285
|
+
pattern = re.compile(rf"\b{re.escape(name)}\b", re.IGNORECASE)
|
|
286
|
+
for m in pattern.finditer(line):
|
|
287
|
+
if swatch_count >= _MAX_SWATCHES:
|
|
288
|
+
break
|
|
289
|
+
self._insert_swatch(line_num, m.start(),
|
|
290
|
+
m.group(0), hex_color)
|
|
291
|
+
swatch_count += 1
|
|
292
|
+
|
|
293
|
+
def _insert_swatch(
|
|
294
|
+
self,
|
|
295
|
+
line: int,
|
|
296
|
+
col: int,
|
|
297
|
+
original_text: str,
|
|
298
|
+
hex_color: str,
|
|
299
|
+
) -> None:
|
|
300
|
+
"""Aplica tag de cor de fundo sobre o próprio texto da cor (sem inserir caracteres).
|
|
301
|
+
|
|
302
|
+
Não modifica o conteúdo do editor - apenas aplica uma tag Tkinter
|
|
303
|
+
sobre o span do valor de cor para exibir a cor como fundo do texto.
|
|
304
|
+
|
|
305
|
+
Args:
|
|
306
|
+
line: Número da linha (1-based).
|
|
307
|
+
col: Coluna de início do valor de cor (0-based).
|
|
308
|
+
original_text: Texto original da cor (para substituição posterior).
|
|
309
|
+
hex_color: Cor em formato '#rrggbb'.
|
|
310
|
+
"""
|
|
311
|
+
rgb = _hex_to_rgb(hex_color)
|
|
312
|
+
if not rgb:
|
|
313
|
+
return
|
|
314
|
+
|
|
315
|
+
if hex_color in ("#808080",) and original_text.lower() == "transparent":
|
|
316
|
+
return
|
|
317
|
+
|
|
318
|
+
fg = _contrast_fg(*rgb)
|
|
319
|
+
tag = f"{_SWATCH_TAG_PREFIX}{self._swatch_counter}"
|
|
320
|
+
self._swatch_counter += 1
|
|
321
|
+
|
|
322
|
+
end_col = col + len(original_text)
|
|
323
|
+
with contextlib.suppress(tk.TclError):
|
|
324
|
+
self._txt.tag_configure(
|
|
325
|
+
tag, background=hex_color, foreground=fg, relief="raised", borderwidth=1
|
|
326
|
+
)
|
|
327
|
+
self._txt.tag_add(tag, f"{line}.{col}", f"{line}.{end_col}")
|
|
328
|
+
|
|
329
|
+
self._swatches[tag] = (line, col, original_text, hex_color)
|
|
330
|
+
|
|
331
|
+
self._txt.tag_bind(
|
|
332
|
+
tag, "<Button-1>", lambda _e, t=tag: self._on_swatch_click(t)
|
|
333
|
+
)
|
|
334
|
+
self._txt.tag_bind(
|
|
335
|
+
tag, "<Enter>", lambda _e, t=tag: self._txt.config(
|
|
336
|
+
cursor="hand2")
|
|
337
|
+
)
|
|
338
|
+
self._txt.tag_bind(
|
|
339
|
+
tag, "<Leave>", lambda _e: self._txt.config(cursor=""))
|
|
340
|
+
|
|
341
|
+
def _remove_swatch(self, tag: str) -> None:
|
|
342
|
+
"""Remove um swatch específico (apenas a tag, sem deletar conteúdo).
|
|
343
|
+
|
|
344
|
+
Args:
|
|
345
|
+
tag: Nome da tag Tkinter do swatch a remover.
|
|
346
|
+
"""
|
|
347
|
+
with contextlib.suppress(tk.TclError):
|
|
348
|
+
self._txt.tag_remove(tag, "1.0", "end")
|
|
349
|
+
self._txt.tag_delete(tag)
|
|
350
|
+
|
|
351
|
+
def _on_swatch_click(self, tag: str) -> None:
|
|
352
|
+
"""Abre o color picker ao clicar em um swatch.
|
|
353
|
+
|
|
354
|
+
Args:
|
|
355
|
+
tag: Nome da tag Tkinter do swatch clicado.
|
|
356
|
+
"""
|
|
357
|
+
info = self._swatches.get(tag)
|
|
358
|
+
if not info:
|
|
359
|
+
return
|
|
360
|
+
|
|
361
|
+
line, col, original_text, current_hex = info
|
|
362
|
+
|
|
363
|
+
result = tkcc.askcolor(
|
|
364
|
+
color=current_hex,
|
|
365
|
+
title=_t("color.picker_title", "Escolher cor"),
|
|
366
|
+
initialcolor=current_hex,
|
|
367
|
+
)
|
|
368
|
+
if result and result[1]:
|
|
369
|
+
new_hex = result[1]
|
|
370
|
+
if new_hex != current_hex and self._on_edit:
|
|
371
|
+
with contextlib.suppress(tk.TclError, AttributeError):
|
|
372
|
+
self._on_edit(original_text, new_hex, line, col)
|
|
373
|
+
|
|
374
|
+
if self._enabled:
|
|
375
|
+
self._schedule_scan()
|
|
376
|
+
|
|
377
|
+
def destroy(self) -> None:
|
|
378
|
+
"""Cancela jobs pendentes e remove o overlay de prévia de cor."""
|
|
379
|
+
if self._after_id:
|
|
380
|
+
with contextlib.suppress(tk.TclError):
|
|
381
|
+
self._txt.after_cancel(self._after_id)
|
|
382
|
+
self.clear()
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"""Codis - ComplexityLens: badge flutuante de complexidade ciclomática.
|
|
2
|
+
|
|
3
|
+
Exibe em tempo real a complexidade ciclomática de funções e métodos Python
|
|
4
|
+
à medida que o cursor se move pelo código. O badge aparece discretamente no
|
|
5
|
+
canto superior direito do editor - mostrando nível, nome da função e um
|
|
6
|
+
indicador visual de cor (verde/amarelo/vermelho) proporcional à complexidade.
|
|
7
|
+
|
|
8
|
+
Complexidade ciclomática (McCabe):
|
|
9
|
+
- 1-5 : Simples -> verde
|
|
10
|
+
- 6-10 : Moderada -> amarelo
|
|
11
|
+
- 11-15 : Alta -> laranja
|
|
12
|
+
- 16+ : Muito alta -> vermelho
|
|
13
|
+
|
|
14
|
+
A análise é feita via AST e nunca bloqueia a UI - é agendada com debounce
|
|
15
|
+
de 300ms após cada movimento de cursor.
|
|
16
|
+
|
|
17
|
+
Uso::
|
|
18
|
+
|
|
19
|
+
from src.editor.complexity_lens import ComplexityLens
|
|
20
|
+
lens = ComplexityLens(text_widget, theme)
|
|
21
|
+
lens.on_cursor_move() # chame nos eventos de cursor
|
|
22
|
+
lens.destroy()
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import ast
|
|
28
|
+
import contextlib
|
|
29
|
+
import logging
|
|
30
|
+
import tkinter as tk
|
|
31
|
+
from dataclasses import dataclass
|
|
32
|
+
from typing import TYPE_CHECKING
|
|
33
|
+
|
|
34
|
+
from src.i18n import _t
|
|
35
|
+
|
|
36
|
+
if TYPE_CHECKING:
|
|
37
|
+
from src.theme.base import Theme
|
|
38
|
+
|
|
39
|
+
logger = logging.getLogger("Codis")
|
|
40
|
+
|
|
41
|
+
_CC_LOW = 5
|
|
42
|
+
_CC_MEDIUM = 10
|
|
43
|
+
_CC_HIGH = 15
|
|
44
|
+
|
|
45
|
+
_DEBOUNCE_MS = 300
|
|
46
|
+
_BADGE_PAD_X = 10
|
|
47
|
+
_BADGE_PAD_Y = 8
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _cyclomatic_complexity(node: ast.FunctionDef | ast.AsyncFunctionDef) -> int:
|
|
51
|
+
"""Calcula a complexidade ciclomática de McCabe para um nó função/método.
|
|
52
|
+
|
|
53
|
+
Conta 1 (base) + 1 para cada ponto de decisão: if/elif/for/while/except/
|
|
54
|
+
with/assert/comprehension/ternary/bool-op (and/or).
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
node: Nó AST de função ou método.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
int: Complexidade ciclomática (mínimo 1).
|
|
61
|
+
"""
|
|
62
|
+
complexity = 1
|
|
63
|
+
for child in ast.walk(node):
|
|
64
|
+
if isinstance(
|
|
65
|
+
child,
|
|
66
|
+
(
|
|
67
|
+
ast.If,
|
|
68
|
+
ast.For,
|
|
69
|
+
ast.While,
|
|
70
|
+
ast.ExceptHandler,
|
|
71
|
+
ast.With,
|
|
72
|
+
ast.Assert,
|
|
73
|
+
ast.comprehension,
|
|
74
|
+
),
|
|
75
|
+
):
|
|
76
|
+
complexity += 1
|
|
77
|
+
elif isinstance(child, ast.BoolOp):
|
|
78
|
+
complexity += len(child.values) - 1
|
|
79
|
+
elif isinstance(child, ast.IfExp):
|
|
80
|
+
complexity += 1
|
|
81
|
+
return complexity
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@dataclass
|
|
85
|
+
class _FuncInfo:
|
|
86
|
+
name: str
|
|
87
|
+
start: int
|
|
88
|
+
end: int
|
|
89
|
+
complexity: int
|
|
90
|
+
is_method: bool = False
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _analyse_functions(source: str) -> list[_FuncInfo]:
|
|
94
|
+
"""Extrai todas as funções/métodos e suas complexidades via AST.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
source: Código-fonte Python.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Lista de _FuncInfo, ordenada por linha de início.
|
|
101
|
+
"""
|
|
102
|
+
try:
|
|
103
|
+
tree = ast.parse(source)
|
|
104
|
+
except SyntaxError:
|
|
105
|
+
return []
|
|
106
|
+
|
|
107
|
+
results: list[_FuncInfo] = []
|
|
108
|
+
method_nodes: set[int] = set()
|
|
109
|
+
for node in ast.walk(tree):
|
|
110
|
+
if isinstance(node, ast.ClassDef):
|
|
111
|
+
for item in ast.walk(node):
|
|
112
|
+
if isinstance(item, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
113
|
+
method_nodes.add(id(item))
|
|
114
|
+
|
|
115
|
+
for node in ast.walk(tree):
|
|
116
|
+
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
117
|
+
end = getattr(node, "end_lineno", node.lineno)
|
|
118
|
+
cc = _cyclomatic_complexity(node)
|
|
119
|
+
results.append(
|
|
120
|
+
_FuncInfo(
|
|
121
|
+
name=node.name,
|
|
122
|
+
start=node.lineno,
|
|
123
|
+
end=end,
|
|
124
|
+
complexity=cc,
|
|
125
|
+
is_method=id(node) in method_nodes,
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
return sorted(results, key=lambda f: f.start)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class ComplexityLens:
|
|
133
|
+
"""Badge flutuante de complexidade ciclomática para o editor.
|
|
134
|
+
|
|
135
|
+
Analisa o arquivo atual com AST e mostra, para a função sob o cursor,
|
|
136
|
+
um badge colorido com nome e nível de complexidade.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
txt: Widget tk.Text do editor.
|
|
140
|
+
theme: Tema visual ativo.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
def __init__(self, txt: tk.Text, theme: Theme) -> None:
|
|
144
|
+
self._txt = txt
|
|
145
|
+
self._theme = theme
|
|
146
|
+
self._after_id: str | None = None
|
|
147
|
+
self._badge: tk.Label | None = None
|
|
148
|
+
self._funcs: list[_FuncInfo] = []
|
|
149
|
+
self._enabled = True
|
|
150
|
+
|
|
151
|
+
self._txt.bind("<KeyRelease>", self._schedule, add=True)
|
|
152
|
+
self._txt.bind("<ButtonRelease>", self._schedule, add=True)
|
|
153
|
+
self._txt.bind("<FocusIn>", self._schedule, add=True)
|
|
154
|
+
|
|
155
|
+
def apply_theme(self, theme: Theme) -> None:
|
|
156
|
+
"""Atualiza o tema e redesenha o badge se visível."""
|
|
157
|
+
self._theme = theme
|
|
158
|
+
if self._badge and self._badge.winfo_exists():
|
|
159
|
+
self._badge.destroy()
|
|
160
|
+
self._badge = None
|
|
161
|
+
|
|
162
|
+
def set_enabled(self, value: bool) -> None:
|
|
163
|
+
"""Ativa ou desativa o complexity lens."""
|
|
164
|
+
self._enabled = value
|
|
165
|
+
if not value:
|
|
166
|
+
self._hide_badge()
|
|
167
|
+
|
|
168
|
+
def destroy(self) -> None:
|
|
169
|
+
"""Cancela timers e destrói o badge."""
|
|
170
|
+
if self._after_id:
|
|
171
|
+
with contextlib.suppress(tk.TclError):
|
|
172
|
+
self._txt.after_cancel(self._after_id)
|
|
173
|
+
self._hide_badge()
|
|
174
|
+
|
|
175
|
+
def _schedule(self, _e=None) -> None:
|
|
176
|
+
if not self._enabled:
|
|
177
|
+
return
|
|
178
|
+
if self._after_id:
|
|
179
|
+
with contextlib.suppress(tk.TclError):
|
|
180
|
+
self._txt.after_cancel(self._after_id)
|
|
181
|
+
self._after_id = self._txt.after(_DEBOUNCE_MS, self._analyse_and_show)
|
|
182
|
+
|
|
183
|
+
def _analyse_and_show(self) -> None:
|
|
184
|
+
self._after_id = None
|
|
185
|
+
if not self._txt.winfo_exists():
|
|
186
|
+
return
|
|
187
|
+
try:
|
|
188
|
+
source = self._txt.get("1.0", "end-1c")
|
|
189
|
+
cursor = self._txt.index(tk.INSERT)
|
|
190
|
+
cur_line = int(cursor.split(".")[0])
|
|
191
|
+
except tk.TclError:
|
|
192
|
+
return
|
|
193
|
+
|
|
194
|
+
self._funcs = _analyse_functions(source)
|
|
195
|
+
|
|
196
|
+
func = self._func_at_line(cur_line)
|
|
197
|
+
if func is None:
|
|
198
|
+
self._hide_badge()
|
|
199
|
+
return
|
|
200
|
+
|
|
201
|
+
self._show_badge(func)
|
|
202
|
+
|
|
203
|
+
def _func_at_line(self, line: int) -> _FuncInfo | None:
|
|
204
|
+
"""Retorna a função mais específica (mais aninhada) que contém a linha."""
|
|
205
|
+
candidates = [f for f in self._funcs if f.start <= line <= f.end]
|
|
206
|
+
if not candidates:
|
|
207
|
+
return None
|
|
208
|
+
return min(candidates, key=lambda f: f.end - f.start)
|
|
209
|
+
|
|
210
|
+
def _cc_color(self, cc: int) -> str:
|
|
211
|
+
if cc <= _CC_LOW:
|
|
212
|
+
return "#4ade80"
|
|
213
|
+
if cc <= _CC_MEDIUM:
|
|
214
|
+
return "#facc15"
|
|
215
|
+
if cc <= _CC_HIGH:
|
|
216
|
+
return "#fb923c"
|
|
217
|
+
return "#f87171"
|
|
218
|
+
|
|
219
|
+
def _cc_label(self, cc: int) -> str:
|
|
220
|
+
if cc <= _CC_LOW:
|
|
221
|
+
return _t("complexity.low", default="Simples")
|
|
222
|
+
if cc <= _CC_MEDIUM:
|
|
223
|
+
return _t("complexity.medium", default="Moderada")
|
|
224
|
+
if cc <= _CC_HIGH:
|
|
225
|
+
return _t("complexity.high", default="Alta")
|
|
226
|
+
return _t("complexity.very_high", default="Muito alta")
|
|
227
|
+
|
|
228
|
+
def _show_badge(self, func: _FuncInfo) -> None:
|
|
229
|
+
"""Cria/atualiza o badge flutuante com dados da função."""
|
|
230
|
+
cc = func.complexity
|
|
231
|
+
color = self._cc_color(cc)
|
|
232
|
+
label = self._cc_label(cc)
|
|
233
|
+
kind = (
|
|
234
|
+
_t("complexity.method", default="método")
|
|
235
|
+
if func.is_method
|
|
236
|
+
else _t("complexity.func", default="função")
|
|
237
|
+
)
|
|
238
|
+
cc_meter = self._cc_meter(cc)
|
|
239
|
+
|
|
240
|
+
text = f" {cc_meter} {func.name} ({kind}) - CC {cc} ({label}) "
|
|
241
|
+
|
|
242
|
+
parent = self._txt.master if self._txt.master else self._txt
|
|
243
|
+
|
|
244
|
+
if self._badge is None or not self._badge.winfo_exists():
|
|
245
|
+
self._badge = tk.Label(
|
|
246
|
+
parent,
|
|
247
|
+
text=text,
|
|
248
|
+
font=("TkFixedFont", 9),
|
|
249
|
+
relief="flat",
|
|
250
|
+
bd=0,
|
|
251
|
+
padx=4,
|
|
252
|
+
pady=2,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
t = self._theme
|
|
256
|
+
bg = getattr(t, "panel_bg", "#1e1e2e")
|
|
257
|
+
fg = color
|
|
258
|
+
|
|
259
|
+
self._badge.config(
|
|
260
|
+
text=text,
|
|
261
|
+
bg=bg,
|
|
262
|
+
fg=fg,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
with contextlib.suppress(tk.TclError):
|
|
266
|
+
x = self._txt.winfo_width() - _BADGE_PAD_X
|
|
267
|
+
y = _BADGE_PAD_Y
|
|
268
|
+
self._badge.place(in_=self._txt, x=x, y=y, anchor="ne")
|
|
269
|
+
self._badge.lift()
|
|
270
|
+
|
|
271
|
+
def _hide_badge(self) -> None:
|
|
272
|
+
if self._badge and self._badge.winfo_exists():
|
|
273
|
+
with contextlib.suppress(tk.TclError):
|
|
274
|
+
self._badge.place_forget()
|
|
275
|
+
|
|
276
|
+
@staticmethod
|
|
277
|
+
def _cc_meter(cc: int) -> str:
|
|
278
|
+
"""Retorna uma mini barra Unicode representando o nível de complexidade."""
|
|
279
|
+
blocks = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]
|
|
280
|
+
idx = min(len(blocks) - 1, max(0, (cc - 1) * len(blocks) // 20))
|
|
281
|
+
return blocks[idx]
|