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/editor/minimap.py
ADDED
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
"""Codis - MiniMap: mapa em miniatura do conteúdo do editor.
|
|
2
|
+
|
|
3
|
+
Renderiza tokens reais por linha usando tokenizador regex simples,
|
|
4
|
+
com:
|
|
5
|
+
- Segmentos coloridos por tipo de token (keyword, string, número, comentário)
|
|
6
|
+
- Destaque da linha do cursor
|
|
7
|
+
- Indicador de viewport arrastável
|
|
8
|
+
- Marcadores de lint e resultados de busca na borda direita
|
|
9
|
+
- Redimensionamento e escala automáticos
|
|
10
|
+
|
|
11
|
+
Performance:
|
|
12
|
+
- Renderização incremental: apenas linhas *dirty* são re-tokenizadas/redesenhadas
|
|
13
|
+
- Zero delete("all"): o canvas é mantido entre frames; items são movidos/recolorados
|
|
14
|
+
- Tags numéricas por linha: cada linha tem seus próprios canvas-items reusáveis
|
|
15
|
+
- Color cache por tema: _build_color_cache só recalcula quando o tema muda
|
|
16
|
+
- Dirty-line tracking por hash de string: só re-tokeniza linhas modificadas
|
|
17
|
+
- Debounce inteligente: 80ms para conteúdo, 16ms para viewport (≈60fps)
|
|
18
|
+
- Viewport rectangle: coordenadas atualizadas com coords() - sem recriação
|
|
19
|
+
- LRU simples no token cache para limitar memória
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import contextlib
|
|
25
|
+
import keyword
|
|
26
|
+
import logging
|
|
27
|
+
import re
|
|
28
|
+
import tkinter as tk
|
|
29
|
+
from typing import Any
|
|
30
|
+
|
|
31
|
+
from src.constants import MINIMAP_WIDTH
|
|
32
|
+
from src.lint.manager import Diag
|
|
33
|
+
from src.theme.utils import alpha_blend_hex
|
|
34
|
+
|
|
35
|
+
logger = logging.getLogger("Codis")
|
|
36
|
+
|
|
37
|
+
_RE_COMMENT_LINE = re.compile(r"^\s*(#|//|--|/\*|\*)")
|
|
38
|
+
_RE_STR_DOUBLE = re.compile(r'f?"(?:[^"\\\\]|\\\\.)*"')
|
|
39
|
+
_RE_STR_SINGLE = re.compile(r"f?'(?:[^'\\\\]|\\\\.)*'")
|
|
40
|
+
_RE_STR_BACK = re.compile(r"`(?:[^`\\\\]|\\\\.)*`")
|
|
41
|
+
_RE_NUMBER = re.compile(
|
|
42
|
+
r"\b(?:0x[0-9a-fA-F]+|0b[01]+|0o[0-7]+|\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)\b"
|
|
43
|
+
)
|
|
44
|
+
_RE_DECORATOR = re.compile(r"@[A-Za-z_]\w*")
|
|
45
|
+
_RE_FUNC_DEF = re.compile(
|
|
46
|
+
r"\b(?:def|function|fn|func|sub|constructor|method)\s+([A-Za-z_]\w*)",
|
|
47
|
+
)
|
|
48
|
+
_RE_CLASS_DEF = re.compile(
|
|
49
|
+
r"\b(?:class|struct|interface|trait|enum|type|protocol)\s+([A-Za-z_]\w*)",
|
|
50
|
+
)
|
|
51
|
+
_RE_WORD = re.compile(r"\b[A-Za-z_]\w*\b")
|
|
52
|
+
|
|
53
|
+
_KEYWORDS: frozenset[str] = frozenset(keyword.kwlist) | frozenset(
|
|
54
|
+
{
|
|
55
|
+
"self",
|
|
56
|
+
"cls",
|
|
57
|
+
"const",
|
|
58
|
+
"let",
|
|
59
|
+
"var",
|
|
60
|
+
"function",
|
|
61
|
+
"new",
|
|
62
|
+
"this",
|
|
63
|
+
"typeof",
|
|
64
|
+
"instanceof",
|
|
65
|
+
"export",
|
|
66
|
+
"default",
|
|
67
|
+
"extends",
|
|
68
|
+
"implements",
|
|
69
|
+
"interface",
|
|
70
|
+
"enum",
|
|
71
|
+
"type",
|
|
72
|
+
"abstract",
|
|
73
|
+
"override",
|
|
74
|
+
"readonly",
|
|
75
|
+
"public",
|
|
76
|
+
"private",
|
|
77
|
+
"protected",
|
|
78
|
+
"static",
|
|
79
|
+
"switch",
|
|
80
|
+
"case",
|
|
81
|
+
"throw",
|
|
82
|
+
"catch",
|
|
83
|
+
"of",
|
|
84
|
+
"fn",
|
|
85
|
+
"pub",
|
|
86
|
+
"use",
|
|
87
|
+
"mod",
|
|
88
|
+
"impl",
|
|
89
|
+
"trait",
|
|
90
|
+
"struct",
|
|
91
|
+
"match",
|
|
92
|
+
"mut",
|
|
93
|
+
"ref",
|
|
94
|
+
"where",
|
|
95
|
+
"crate",
|
|
96
|
+
"dyn",
|
|
97
|
+
"loop",
|
|
98
|
+
"move",
|
|
99
|
+
"unsafe",
|
|
100
|
+
"extern",
|
|
101
|
+
"package",
|
|
102
|
+
"func",
|
|
103
|
+
"go",
|
|
104
|
+
"chan",
|
|
105
|
+
"defer",
|
|
106
|
+
"range",
|
|
107
|
+
"select",
|
|
108
|
+
"val",
|
|
109
|
+
"fun",
|
|
110
|
+
"when",
|
|
111
|
+
"then",
|
|
112
|
+
"unless",
|
|
113
|
+
"until",
|
|
114
|
+
"rescue",
|
|
115
|
+
"ensure",
|
|
116
|
+
"require",
|
|
117
|
+
"include",
|
|
118
|
+
"module",
|
|
119
|
+
"proc",
|
|
120
|
+
"begin",
|
|
121
|
+
"end",
|
|
122
|
+
"nil",
|
|
123
|
+
"true",
|
|
124
|
+
"false",
|
|
125
|
+
"null",
|
|
126
|
+
"undefined",
|
|
127
|
+
"void",
|
|
128
|
+
"bool",
|
|
129
|
+
"int",
|
|
130
|
+
"float",
|
|
131
|
+
"string",
|
|
132
|
+
"char",
|
|
133
|
+
"byte",
|
|
134
|
+
"rune",
|
|
135
|
+
"any",
|
|
136
|
+
"object",
|
|
137
|
+
"unit",
|
|
138
|
+
"never",
|
|
139
|
+
"unknown",
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class MiniMap(tk.Canvas):
|
|
145
|
+
"""
|
|
146
|
+
Mapa em miniatura do arquivo exibido à direita do editor.
|
|
147
|
+
|
|
148
|
+
Mantém canvas-items persistentes por linha e só recria/move o que mudou,
|
|
149
|
+
eliminando o flickering causado por delete("all") + redraw completo.
|
|
150
|
+
"""
|
|
151
|
+
|
|
152
|
+
CHAR_W = 2
|
|
153
|
+
LINE_H = 2
|
|
154
|
+
MAX_CHARS = 120
|
|
155
|
+
PADDING = 3
|
|
156
|
+
GUTTER_W = 4
|
|
157
|
+
|
|
158
|
+
def __init__(self, parent: tk.Widget, text_widget: tk.Text, tmgr) -> None:
|
|
159
|
+
super().__init__(parent, width=MINIMAP_WIDTH, bd=0, highlightthickness=0)
|
|
160
|
+
self._txt_ref = text_widget
|
|
161
|
+
self._tmgr = tmgr
|
|
162
|
+
self._suspended = False
|
|
163
|
+
|
|
164
|
+
self._job: str | None = None
|
|
165
|
+
self._vp_job: str | None = None
|
|
166
|
+
self._drag_y: int | None = None
|
|
167
|
+
|
|
168
|
+
self._lint_lines: dict[int, str] = {}
|
|
169
|
+
self._search_lines: set[int] = set()
|
|
170
|
+
|
|
171
|
+
self._token_cache: dict[int, tuple[int, list[str]]] = {}
|
|
172
|
+
self._TOKEN_CACHE_MAX = 3000
|
|
173
|
+
|
|
174
|
+
self._line_items: dict[int, list[int]] = {}
|
|
175
|
+
|
|
176
|
+
self._bg_item: int | None = None
|
|
177
|
+
self._cursor_items: dict[int, int] = {}
|
|
178
|
+
self._gutter_items: dict[int, int] = {}
|
|
179
|
+
self._vp_item: int | None = None
|
|
180
|
+
|
|
181
|
+
self._color_cache: dict[str, str] = {}
|
|
182
|
+
self._color_cache_theme_id: int = -1
|
|
183
|
+
|
|
184
|
+
self._prev_lines: list[str] = []
|
|
185
|
+
self._prev_total: int = 0
|
|
186
|
+
self._prev_cursor_ln: int = -1
|
|
187
|
+
self._prev_first_vis: float = -1.0
|
|
188
|
+
self._prev_last_vis: float = -1.0
|
|
189
|
+
self._prev_cw: int = 0
|
|
190
|
+
self._prev_ch: int = 0
|
|
191
|
+
self._prev_lh: int = 0
|
|
192
|
+
|
|
193
|
+
self._apply_theme()
|
|
194
|
+
self.bind("<Button-1>", self._on_click)
|
|
195
|
+
self.bind("<B1-Motion>", self._on_drag)
|
|
196
|
+
self.bind("<ButtonRelease-1>",
|
|
197
|
+
lambda _: setattr(self, "_drag_y", None))
|
|
198
|
+
self.bind("<Configure>", self._on_resize)
|
|
199
|
+
|
|
200
|
+
for ev in ("<MouseWheel>", "<Configure>"):
|
|
201
|
+
with contextlib.suppress(tk.TclError):
|
|
202
|
+
self._txt_ref.bind(ev, self._schedule_viewport_update, add="+")
|
|
203
|
+
|
|
204
|
+
for ev in ("<<Modified>>", "<KeyRelease>"):
|
|
205
|
+
with contextlib.suppress(tk.TclError):
|
|
206
|
+
self._txt_ref.bind(ev, self._schedule_redraw, add="+")
|
|
207
|
+
|
|
208
|
+
def _apply_theme(self) -> None:
|
|
209
|
+
t = self._tmgr.theme
|
|
210
|
+
self.config(bg=t.minimap_bg)
|
|
211
|
+
|
|
212
|
+
def update_theme(self) -> None:
|
|
213
|
+
self._apply_theme()
|
|
214
|
+
self._color_cache_theme_id = -1
|
|
215
|
+
self._token_cache.clear()
|
|
216
|
+
self._prev_lines = []
|
|
217
|
+
self._invalidate_all_canvas_items()
|
|
218
|
+
self._schedule_redraw()
|
|
219
|
+
|
|
220
|
+
def _get_colors(self) -> dict[str, str]:
|
|
221
|
+
"""Retorna cache de cores, recalculando apenas quando o tema mudou."""
|
|
222
|
+
t = self._tmgr.theme
|
|
223
|
+
tid = id(t)
|
|
224
|
+
if tid != self._color_cache_theme_id:
|
|
225
|
+
vp = getattr(t, "minimap_viewport", t.sel_bg)
|
|
226
|
+
bg = getattr(t, "minimap_bg", t.editor_bg)
|
|
227
|
+
self._color_cache = {
|
|
228
|
+
"bg": bg,
|
|
229
|
+
"viewport": vp,
|
|
230
|
+
"vp_borda": getattr(t, "scroll_hover", t.accent),
|
|
231
|
+
"cursor_hl": _alpha_blend(vp, bg, 0.5),
|
|
232
|
+
"comment": getattr(t, "t_comment", "#6a9955"),
|
|
233
|
+
"string": getattr(t, "t_string", "#a6d4a6"),
|
|
234
|
+
"number": getattr(t, "t_number", "#e8a07a"),
|
|
235
|
+
"keyword": getattr(t, "t_keyword", "#9b9bef"),
|
|
236
|
+
"func": getattr(t, "t_func", "#78b4fa"),
|
|
237
|
+
"klass": getattr(t, "t_type", "#f38b8b"),
|
|
238
|
+
"decorator": getattr(t, "t_decorator", "#f9e2af"),
|
|
239
|
+
"normal": getattr(t, "fg_dim", "#4a4a6a"),
|
|
240
|
+
"ws": bg,
|
|
241
|
+
}
|
|
242
|
+
self._color_cache_theme_id = tid
|
|
243
|
+
return self._color_cache
|
|
244
|
+
|
|
245
|
+
def _schedule_redraw(self, _e: Any = None) -> None:
|
|
246
|
+
if not self.winfo_exists() or self._suspended:
|
|
247
|
+
return
|
|
248
|
+
if self._job:
|
|
249
|
+
with contextlib.suppress(tk.TclError):
|
|
250
|
+
self.after_cancel(self._job)
|
|
251
|
+
self._job = self.after(80, self._incremental_redraw)
|
|
252
|
+
|
|
253
|
+
def _schedule_viewport_update(self, _e: Any = None) -> None:
|
|
254
|
+
if not self.winfo_exists() or self._suspended:
|
|
255
|
+
return
|
|
256
|
+
if self._vp_job:
|
|
257
|
+
with contextlib.suppress(tk.TclError):
|
|
258
|
+
self.after_cancel(self._vp_job)
|
|
259
|
+
self._vp_job = self.after(16, self._update_viewport)
|
|
260
|
+
|
|
261
|
+
def _on_resize(self, _e: Any = None) -> None:
|
|
262
|
+
"""Resize força redraw completo pois lh e escala mudam."""
|
|
263
|
+
if not self.winfo_exists() or self._suspended:
|
|
264
|
+
return
|
|
265
|
+
self._prev_cw = 0
|
|
266
|
+
self._schedule_redraw()
|
|
267
|
+
|
|
268
|
+
def suspend(self) -> None:
|
|
269
|
+
self._suspended = True
|
|
270
|
+
for job_attr in ("_job", "_vp_job"):
|
|
271
|
+
job = getattr(self, job_attr, None)
|
|
272
|
+
if job:
|
|
273
|
+
with contextlib.suppress(tk.TclError):
|
|
274
|
+
self.after_cancel(job)
|
|
275
|
+
setattr(self, job_attr, None)
|
|
276
|
+
|
|
277
|
+
def resume(self) -> None:
|
|
278
|
+
self._suspended = False
|
|
279
|
+
self._schedule_redraw()
|
|
280
|
+
|
|
281
|
+
def set_lint_lines(self, diags: list[Diag]) -> None:
|
|
282
|
+
self._lint_lines = {}
|
|
283
|
+
for d in diags:
|
|
284
|
+
color = {
|
|
285
|
+
1: self._tmgr.theme.minimap_err,
|
|
286
|
+
2: self._tmgr.theme.minimap_warn,
|
|
287
|
+
}.get(d.severity)
|
|
288
|
+
if color:
|
|
289
|
+
self._lint_lines[d.line] = color
|
|
290
|
+
self._schedule_redraw()
|
|
291
|
+
|
|
292
|
+
def _invalidate_all_canvas_items(self) -> None:
|
|
293
|
+
"""Remove todos os canvas-items gerenciados (sem delete("all"))."""
|
|
294
|
+
with contextlib.suppress(tk.TclError):
|
|
295
|
+
for items in self._line_items.values():
|
|
296
|
+
for iid in items:
|
|
297
|
+
self.delete(iid)
|
|
298
|
+
for iid in self._cursor_items.values():
|
|
299
|
+
self.delete(iid)
|
|
300
|
+
for iid in self._gutter_items.values():
|
|
301
|
+
self.delete(iid)
|
|
302
|
+
if self._bg_item is not None:
|
|
303
|
+
self.delete(self._bg_item)
|
|
304
|
+
if self._vp_item is not None:
|
|
305
|
+
self.delete(self._vp_item)
|
|
306
|
+
self._line_items.clear()
|
|
307
|
+
self._cursor_items.clear()
|
|
308
|
+
self._gutter_items.clear()
|
|
309
|
+
self._bg_item = None
|
|
310
|
+
self._vp_item = None
|
|
311
|
+
|
|
312
|
+
def _incremental_redraw(self, _e: Any = None) -> None:
|
|
313
|
+
"""
|
|
314
|
+
Redesenho incremental: detecta dirty lines e só re-renderiza o necessário.
|
|
315
|
+
|
|
316
|
+
Não usa delete("all") - mantém items existentes e os atualiza.
|
|
317
|
+
Elimina o flickering completamente.
|
|
318
|
+
"""
|
|
319
|
+
self._job = None
|
|
320
|
+
if not self.winfo_exists():
|
|
321
|
+
return
|
|
322
|
+
|
|
323
|
+
color = self._get_colors()
|
|
324
|
+
cw = self.winfo_width()
|
|
325
|
+
ch = self.winfo_height()
|
|
326
|
+
if cw < 6 or ch < 6:
|
|
327
|
+
return
|
|
328
|
+
|
|
329
|
+
try:
|
|
330
|
+
content = self._txt_ref.get("1.0", "end-1c")
|
|
331
|
+
first_vis = float(self._txt_ref.yview()[0])
|
|
332
|
+
last_vis = float(self._txt_ref.yview()[1])
|
|
333
|
+
cursor_ln = int(self._txt_ref.index("insert").split(".")[0])
|
|
334
|
+
except tk.TclError:
|
|
335
|
+
return
|
|
336
|
+
|
|
337
|
+
lines = content.split("\n")
|
|
338
|
+
total_linhas = max(len(lines), 1)
|
|
339
|
+
espaco = ch - self.PADDING * 2
|
|
340
|
+
lh = max(1, min(self.LINE_H, espaco // total_linhas))
|
|
341
|
+
util_w = cw - self.GUTTER_W - self.PADDING * 2
|
|
342
|
+
|
|
343
|
+
geometry_changed = (
|
|
344
|
+
cw != self._prev_cw or ch != self._prev_ch or lh != self._prev_lh
|
|
345
|
+
)
|
|
346
|
+
if geometry_changed:
|
|
347
|
+
self._invalidate_all_canvas_items()
|
|
348
|
+
self._prev_lines = []
|
|
349
|
+
self._prev_cursor_ln = -1
|
|
350
|
+
|
|
351
|
+
if self._bg_item is None:
|
|
352
|
+
self._bg_item = self.create_rectangle(
|
|
353
|
+
0, 0, cw, ch, fill=color["bg"], outline="", tags="bg"
|
|
354
|
+
)
|
|
355
|
+
self.tag_lower("bg")
|
|
356
|
+
else:
|
|
357
|
+
with contextlib.suppress(tk.TclError):
|
|
358
|
+
self.coords(self._bg_item, 0, 0, cw, ch)
|
|
359
|
+
self.itemconfig(self._bg_item, fill=color["bg"])
|
|
360
|
+
|
|
361
|
+
prev = self._prev_lines
|
|
362
|
+
dirty: set[int] = set()
|
|
363
|
+
|
|
364
|
+
if len(lines) != len(prev):
|
|
365
|
+
dirty = set(range(1, total_linhas + 1))
|
|
366
|
+
for n in list(self._line_items):
|
|
367
|
+
if n > total_linhas:
|
|
368
|
+
for iid in self._line_items.pop(n):
|
|
369
|
+
with contextlib.suppress(tk.TclError):
|
|
370
|
+
self.delete(iid)
|
|
371
|
+
for n in list(self._cursor_items):
|
|
372
|
+
if n > total_linhas:
|
|
373
|
+
with contextlib.suppress(tk.TclError):
|
|
374
|
+
self.delete(self._cursor_items.pop(n))
|
|
375
|
+
for n in list(self._gutter_items):
|
|
376
|
+
if n > total_linhas:
|
|
377
|
+
with contextlib.suppress(tk.TclError):
|
|
378
|
+
self.delete(self._gutter_items.pop(n))
|
|
379
|
+
else:
|
|
380
|
+
for i, (cur, prv) in enumerate(zip(lines, prev, strict=False)):
|
|
381
|
+
if cur != prv:
|
|
382
|
+
dirty.add(i + 1)
|
|
383
|
+
|
|
384
|
+
if cursor_ln != self._prev_cursor_ln:
|
|
385
|
+
dirty.add(self._prev_cursor_ln)
|
|
386
|
+
dirty.add(cursor_ln)
|
|
387
|
+
|
|
388
|
+
self._prev_lines = lines
|
|
389
|
+
self._prev_total = total_linhas
|
|
390
|
+
self._prev_cursor_ln = cursor_ln
|
|
391
|
+
self._prev_cw = cw
|
|
392
|
+
self._prev_ch = ch
|
|
393
|
+
self._prev_lh = lh
|
|
394
|
+
|
|
395
|
+
for i, linha_texto in enumerate(lines):
|
|
396
|
+
y = self.PADDING + i * lh
|
|
397
|
+
n_linha = i + 1
|
|
398
|
+
if y > ch:
|
|
399
|
+
if n_linha in self._line_items:
|
|
400
|
+
for iid in self._line_items.pop(n_linha):
|
|
401
|
+
with contextlib.suppress(tk.TclError):
|
|
402
|
+
self.delete(iid)
|
|
403
|
+
continue
|
|
404
|
+
|
|
405
|
+
if n_linha not in dirty:
|
|
406
|
+
continue
|
|
407
|
+
|
|
408
|
+
gutter_color = self._lint_lines.get(n_linha) or (
|
|
409
|
+
self._tmgr.theme.minimap_find if n_linha in self._search_lines else None
|
|
410
|
+
)
|
|
411
|
+
if gutter_color:
|
|
412
|
+
if n_linha in self._gutter_items:
|
|
413
|
+
with contextlib.suppress(tk.TclError):
|
|
414
|
+
self.coords(
|
|
415
|
+
self._gutter_items[n_linha],
|
|
416
|
+
cw - self.GUTTER_W,
|
|
417
|
+
y,
|
|
418
|
+
cw,
|
|
419
|
+
y + max(1, lh),
|
|
420
|
+
)
|
|
421
|
+
self.itemconfig(
|
|
422
|
+
self._gutter_items[n_linha], fill=gutter_color)
|
|
423
|
+
else:
|
|
424
|
+
self._gutter_items[n_linha] = self.create_rectangle(
|
|
425
|
+
cw - self.GUTTER_W,
|
|
426
|
+
y,
|
|
427
|
+
cw,
|
|
428
|
+
y + max(1, lh),
|
|
429
|
+
fill=gutter_color,
|
|
430
|
+
outline="",
|
|
431
|
+
)
|
|
432
|
+
else:
|
|
433
|
+
if n_linha in self._gutter_items:
|
|
434
|
+
with contextlib.suppress(tk.TclError):
|
|
435
|
+
self.delete(self._gutter_items.pop(n_linha))
|
|
436
|
+
|
|
437
|
+
if n_linha == cursor_ln:
|
|
438
|
+
hl_color = color["cursor_hl"]
|
|
439
|
+
if n_linha in self._cursor_items:
|
|
440
|
+
with contextlib.suppress(tk.TclError):
|
|
441
|
+
self.coords(
|
|
442
|
+
self._cursor_items[n_linha],
|
|
443
|
+
0,
|
|
444
|
+
y,
|
|
445
|
+
cw - self.GUTTER_W,
|
|
446
|
+
y + max(2, lh),
|
|
447
|
+
)
|
|
448
|
+
self.itemconfig(
|
|
449
|
+
self._cursor_items[n_linha], fill=hl_color)
|
|
450
|
+
else:
|
|
451
|
+
self._cursor_items[n_linha] = self.create_rectangle(
|
|
452
|
+
0,
|
|
453
|
+
y,
|
|
454
|
+
cw - self.GUTTER_W,
|
|
455
|
+
y + max(2, lh),
|
|
456
|
+
fill=hl_color,
|
|
457
|
+
outline="",
|
|
458
|
+
)
|
|
459
|
+
else:
|
|
460
|
+
if n_linha in self._cursor_items:
|
|
461
|
+
with contextlib.suppress(tk.TclError):
|
|
462
|
+
self.delete(self._cursor_items.pop(n_linha))
|
|
463
|
+
|
|
464
|
+
if n_linha in self._line_items:
|
|
465
|
+
for iid in self._line_items.pop(n_linha):
|
|
466
|
+
with contextlib.suppress(tk.TclError):
|
|
467
|
+
self.delete(iid)
|
|
468
|
+
|
|
469
|
+
if not linha_texto.strip():
|
|
470
|
+
self._line_items[n_linha] = []
|
|
471
|
+
continue
|
|
472
|
+
|
|
473
|
+
colors = self._tokenize(linha_texto, n_linha, color)
|
|
474
|
+
|
|
475
|
+
new_items = self._draw_linha(
|
|
476
|
+
colors, linha_texto, y, lh, util_w, cw, color)
|
|
477
|
+
self._line_items[n_linha] = new_items
|
|
478
|
+
|
|
479
|
+
self._draw_or_update_viewport(
|
|
480
|
+
first_vis, last_vis, cw, ch, total_linhas, lh, color
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
self._prev_first_vis = first_vis
|
|
484
|
+
self._prev_last_vis = last_vis
|
|
485
|
+
|
|
486
|
+
def _update_viewport(self) -> None:
|
|
487
|
+
"""Atualização ultra-leve: apenas reposiciona o retângulo de viewport."""
|
|
488
|
+
self._vp_job = None
|
|
489
|
+
if not self.winfo_exists():
|
|
490
|
+
return
|
|
491
|
+
try:
|
|
492
|
+
first_vis = float(self._txt_ref.yview()[0])
|
|
493
|
+
last_vis = float(self._txt_ref.yview()[1])
|
|
494
|
+
except tk.TclError:
|
|
495
|
+
return
|
|
496
|
+
|
|
497
|
+
cw = self.winfo_width()
|
|
498
|
+
ch = self.winfo_height()
|
|
499
|
+
if cw < 6 or ch < 6:
|
|
500
|
+
return
|
|
501
|
+
|
|
502
|
+
if self._bg_item is None:
|
|
503
|
+
self._schedule_redraw()
|
|
504
|
+
return
|
|
505
|
+
|
|
506
|
+
try:
|
|
507
|
+
total_linhas = max(self._prev_total, 1)
|
|
508
|
+
except tk.TclError:
|
|
509
|
+
return
|
|
510
|
+
|
|
511
|
+
espaco = ch - self.PADDING * 2
|
|
512
|
+
lh = max(1, min(self.LINE_H, espaco // total_linhas))
|
|
513
|
+
color = self._get_colors()
|
|
514
|
+
|
|
515
|
+
self._draw_or_update_viewport(
|
|
516
|
+
first_vis, last_vis, cw, ch, total_linhas, lh, color
|
|
517
|
+
)
|
|
518
|
+
self._prev_first_vis = first_vis
|
|
519
|
+
self._prev_last_vis = last_vis
|
|
520
|
+
|
|
521
|
+
def _draw_or_update_viewport(
|
|
522
|
+
self,
|
|
523
|
+
first_vis: float,
|
|
524
|
+
last_vis: float,
|
|
525
|
+
cw: int,
|
|
526
|
+
ch: int,
|
|
527
|
+
total_linhas: int,
|
|
528
|
+
lh: int,
|
|
529
|
+
color: dict[str, str],
|
|
530
|
+
) -> None:
|
|
531
|
+
content_h = min(ch, self.PADDING + total_linhas * lh)
|
|
532
|
+
vy1 = max(0, int(first_vis * content_h))
|
|
533
|
+
vy2 = min(content_h, int(last_vis * content_h))
|
|
534
|
+
vy2 = max(vy2, vy1 + 4)
|
|
535
|
+
|
|
536
|
+
with contextlib.suppress(tk.TclError):
|
|
537
|
+
if self._vp_item is not None and self.find_withtag(self._vp_item):
|
|
538
|
+
self.coords(self._vp_item, 0, vy1, cw - self.GUTTER_W, vy2)
|
|
539
|
+
self.itemconfig(
|
|
540
|
+
self._vp_item,
|
|
541
|
+
fill=color["viewport"],
|
|
542
|
+
stipple="gray50",
|
|
543
|
+
outline=color["vp_borda"],
|
|
544
|
+
)
|
|
545
|
+
else:
|
|
546
|
+
self._vp_item = self.create_rectangle(
|
|
547
|
+
0,
|
|
548
|
+
vy1,
|
|
549
|
+
cw - self.GUTTER_W,
|
|
550
|
+
vy2,
|
|
551
|
+
fill=color["viewport"],
|
|
552
|
+
outline=color["vp_borda"],
|
|
553
|
+
width=1,
|
|
554
|
+
stipple="gray50",
|
|
555
|
+
tags="viewport",
|
|
556
|
+
)
|
|
557
|
+
self.tag_raise(self._vp_item)
|
|
558
|
+
|
|
559
|
+
def _tokenize(
|
|
560
|
+
self,
|
|
561
|
+
line: str,
|
|
562
|
+
n_linha: int,
|
|
563
|
+
color: dict[str, str],
|
|
564
|
+
) -> list[str]:
|
|
565
|
+
"""Tokeniza uma linha e retorna lista de cores por caractere, com cache.
|
|
566
|
+
|
|
567
|
+
Usa slice-assignment em vez de loops por caractere para minimizar
|
|
568
|
+
o custo de atribuição em linhas longas.
|
|
569
|
+
"""
|
|
570
|
+
n = min(len(line), self.MAX_CHARS)
|
|
571
|
+
lhash = hash(line)
|
|
572
|
+
|
|
573
|
+
cached = self._token_cache.get(n_linha)
|
|
574
|
+
if cached and cached[0] == lhash:
|
|
575
|
+
return cached[1]
|
|
576
|
+
|
|
577
|
+
norm_color = color["normal"]
|
|
578
|
+
colors = [norm_color] * n
|
|
579
|
+
|
|
580
|
+
if _RE_COMMENT_LINE.match(line):
|
|
581
|
+
c = color["comment"]
|
|
582
|
+
colors[:] = [c] * n
|
|
583
|
+
else:
|
|
584
|
+
str_color = color["string"]
|
|
585
|
+
for regex in (_RE_STR_DOUBLE, _RE_STR_SINGLE, _RE_STR_BACK):
|
|
586
|
+
for m in regex.finditer(line[:n]):
|
|
587
|
+
a, b = m.start(), min(m.end(), n)
|
|
588
|
+
colors[a:b] = [str_color] * (b - a)
|
|
589
|
+
|
|
590
|
+
num_color = color["number"]
|
|
591
|
+
for m in _RE_NUMBER.finditer(line[:n]):
|
|
592
|
+
a, b = m.start(), min(m.end(), n)
|
|
593
|
+
if colors[a] != str_color:
|
|
594
|
+
colors[a:b] = [num_color] * (b - a)
|
|
595
|
+
|
|
596
|
+
dec_color = color["decorator"]
|
|
597
|
+
for m in _RE_DECORATOR.finditer(line[:n]):
|
|
598
|
+
a, b = m.start(), min(m.end(), n)
|
|
599
|
+
if colors[a] == norm_color:
|
|
600
|
+
colors[a:b] = [dec_color] * (b - a)
|
|
601
|
+
|
|
602
|
+
fn_color = color["func"]
|
|
603
|
+
for m in _RE_FUNC_DEF.finditer(line[:n]):
|
|
604
|
+
a, b = m.start(), min(m.end(), n)
|
|
605
|
+
if colors[a] == norm_color:
|
|
606
|
+
colors[a:b] = [fn_color] * (b - a)
|
|
607
|
+
|
|
608
|
+
cls_color = color["klass"]
|
|
609
|
+
for m in _RE_CLASS_DEF.finditer(line[:n]):
|
|
610
|
+
a, b = m.start(), min(m.end(), n)
|
|
611
|
+
if colors[a] == norm_color:
|
|
612
|
+
colors[a:b] = [cls_color] * (b - a)
|
|
613
|
+
|
|
614
|
+
kw_color = color["keyword"]
|
|
615
|
+
for m in _RE_WORD.finditer(line[:n]):
|
|
616
|
+
if m.group() in _KEYWORDS:
|
|
617
|
+
a, b = m.start(), min(m.end(), n)
|
|
618
|
+
if colors[a] == norm_color:
|
|
619
|
+
colors[a:b] = [kw_color] * (b - a)
|
|
620
|
+
|
|
621
|
+
ws_color = color["ws"]
|
|
622
|
+
for k, ch_char in enumerate(line[:n]):
|
|
623
|
+
if ch_char in (" ", "\t"):
|
|
624
|
+
colors[k] = ws_color
|
|
625
|
+
|
|
626
|
+
if len(self._token_cache) >= self._TOKEN_CACHE_MAX:
|
|
627
|
+
oldest = next(iter(self._token_cache))
|
|
628
|
+
del self._token_cache[oldest]
|
|
629
|
+
self._token_cache[n_linha] = (lhash, colors)
|
|
630
|
+
return colors
|
|
631
|
+
|
|
632
|
+
def _draw_linha(
|
|
633
|
+
self,
|
|
634
|
+
colors: list[str],
|
|
635
|
+
line: str,
|
|
636
|
+
y: int,
|
|
637
|
+
lh: int,
|
|
638
|
+
util_w: int,
|
|
639
|
+
cw: int,
|
|
640
|
+
color: dict[str, str],
|
|
641
|
+
) -> list[int]:
|
|
642
|
+
"""Desenha runs de mesma cor para uma linha; retorna lista de item-ids."""
|
|
643
|
+
n = min(len(line), self.MAX_CHARS)
|
|
644
|
+
height = max(1, lh - 1)
|
|
645
|
+
scale = util_w / max(self.MAX_CHARS * self.CHAR_W, 1)
|
|
646
|
+
ws_c = color["ws"]
|
|
647
|
+
items: list[int] = []
|
|
648
|
+
|
|
649
|
+
k = 0
|
|
650
|
+
while k < n:
|
|
651
|
+
c_cur = colors[k]
|
|
652
|
+
start = k
|
|
653
|
+
while k < n and colors[k] == c_cur:
|
|
654
|
+
k += 1
|
|
655
|
+
if c_cur == ws_c:
|
|
656
|
+
continue
|
|
657
|
+
x1 = self.PADDING + int(start * self.CHAR_W * scale)
|
|
658
|
+
x2 = self.PADDING + int(k * self.CHAR_W * scale)
|
|
659
|
+
x2 = min(x2, cw - self.GUTTER_W - 2)
|
|
660
|
+
if x2 <= x1:
|
|
661
|
+
x2 = x1 + 1
|
|
662
|
+
iid = self.create_rectangle(
|
|
663
|
+
x1, y, x2, y + height, fill=c_cur, outline="")
|
|
664
|
+
items.append(iid)
|
|
665
|
+
|
|
666
|
+
return items
|
|
667
|
+
|
|
668
|
+
def redraw(self, _e: Any = None) -> None:
|
|
669
|
+
"""Alias público; delega para incremental_redraw."""
|
|
670
|
+
self._prev_lines = []
|
|
671
|
+
self._invalidate_all_canvas_items()
|
|
672
|
+
self._schedule_redraw()
|
|
673
|
+
|
|
674
|
+
def _on_click(self, e: Any) -> None:
|
|
675
|
+
self._drag_y = e.y
|
|
676
|
+
self._scroll_to(e.y)
|
|
677
|
+
|
|
678
|
+
def _on_drag(self, e: Any) -> None:
|
|
679
|
+
self._scroll_to(e.y)
|
|
680
|
+
self._drag_y = e.y
|
|
681
|
+
|
|
682
|
+
def _scroll_to(self, y: int) -> None:
|
|
683
|
+
ch = self.winfo_height()
|
|
684
|
+
if ch <= 0:
|
|
685
|
+
return
|
|
686
|
+
frac = max(0.0, min(1.0, y / ch))
|
|
687
|
+
with contextlib.suppress(tk.TclError):
|
|
688
|
+
self._txt_ref.yview_moveto(frac)
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
_alpha_blend = alpha_blend_hex
|