meltygui 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. meltygui/__init__.py +107 -0
  2. meltygui/accounts/__init__.py +0 -0
  3. meltygui/accounts/internet_accounts.py +1355 -0
  4. meltygui/chat/__init__.py +91 -0
  5. meltygui/chat/activity.py +75 -0
  6. meltygui/chat/backends.py +36 -0
  7. meltygui/chat/chat_interface.py +732 -0
  8. meltygui/chat/chat_proxy.py +352 -0
  9. meltygui/chat/codex_proxy.py +592 -0
  10. meltygui/chat/codex_settings.py +100 -0
  11. meltygui/chat/codex_transport.py +60 -0
  12. meltygui/chat/command_parser.py +204 -0
  13. meltygui/chat/images.py +227 -0
  14. meltygui/chat/messages.py +417 -0
  15. meltygui/chat/metadata.py +139 -0
  16. meltygui/chat/writer_locks.py +64 -0
  17. meltygui/code/__init__.py +0 -0
  18. meltygui/code/basic_converters.py +533 -0
  19. meltygui/code/chain_converters.py +2111 -0
  20. meltygui/code/code_checks.py +2209 -0
  21. meltygui/code/core_syntax.py +1430 -0
  22. meltygui/code/file_converters.py +1933 -0
  23. meltygui/code/fileref.py +702 -0
  24. meltygui/code/hotswap_guard.py +144 -0
  25. meltygui/code/libcst_conversion.py +9724 -0
  26. meltygui/code/live_instrument.py +392 -0
  27. meltygui/code/live_view.py +2490 -0
  28. meltygui/code/melty_scan.py +2684 -0
  29. meltygui/code/new_codecs.py +1255 -0
  30. meltygui/code/new_converters.py +3017 -0
  31. meltygui/code/project_code.py +278 -0
  32. meltygui/code/source_context.py +63 -0
  33. meltygui/code/symbol_roster.py +1588 -0
  34. meltygui/code/syntax_check.py +34 -0
  35. meltygui/code/syntax_check_worker.py +114 -0
  36. meltygui/completion/__init__.py +0 -0
  37. meltygui/completion/fim.py +1232 -0
  38. meltygui/completion/fim_context.py +481 -0
  39. meltygui/completion/providers/__init__.py +0 -0
  40. meltygui/completion/providers/anthropic_oauth.py +446 -0
  41. meltygui/completion/providers/anthropic_requests.py +69 -0
  42. meltygui/completion/providers/claude.py +203 -0
  43. meltygui/completion/providers/claude_usage.py +499 -0
  44. meltygui/completion/providers/codex_accounts.py +180 -0
  45. meltygui/completion/providers/copilot.py +617 -0
  46. meltygui/completion/providers/oauth_popup.py +220 -0
  47. meltygui/completion/providers/ollama.py +320 -0
  48. meltygui/completion/providers/profiles.py +23 -0
  49. meltygui/core/README.md +88 -0
  50. meltygui/core/__init__.py +1 -0
  51. meltygui/core/automation/__init__.py +1 -0
  52. meltygui/core/automation/action_core.py +153 -0
  53. meltygui/core/automation/collection_action.py +45 -0
  54. meltygui/core/automation/mcp_eval.py +167 -0
  55. meltygui/core/automation/mcp_hotswap.py +107 -0
  56. meltygui/core/automation/mcp_query.py +552 -0
  57. meltygui/core/automation/mcp_server.py +657 -0
  58. meltygui/core/automation/orchestration_core.py +2636 -0
  59. meltygui/core/automation/query_core.py +124 -0
  60. meltygui/core/automation/search_core.py +26 -0
  61. meltygui/core/automation/selector_core.py +340 -0
  62. meltygui/core/automation/value_core.py +1752 -0
  63. meltygui/core/cache/__init__.py +1 -0
  64. meltygui/core/cache/cache_diagnostics.py +0 -0
  65. meltygui/core/cache/invalidation_decoration.py +153 -0
  66. meltygui/core/cache/invalidation_tracker.py +43 -0
  67. meltygui/core/cache/tile_cache.py +5968 -0
  68. meltygui/core/conversion/__init__.py +1 -0
  69. meltygui/core/conversion/bubbling.py +599 -0
  70. meltygui/core/conversion/cache_tree.py +188 -0
  71. meltygui/core/conversion/chain.py +113 -0
  72. meltygui/core/conversion/converter_register.py +145 -0
  73. meltygui/core/conversion/data_decoration.py +67 -0
  74. meltygui/core/conversion/dict_conversion.py +1815 -0
  75. meltygui/core/conversion/dict_conversion_util.py +177 -0
  76. meltygui/core/conversion/dynamic_obj.py +89 -0
  77. meltygui/core/conversion/graph_compare.py +183 -0
  78. meltygui/core/conversion/load_save_v2.py +1032 -0
  79. meltygui/core/conversion/missing_saved_class.py +39 -0
  80. meltygui/core/conversion/path_finder.py +606 -0
  81. meltygui/core/conversion/render_host.py +1083 -0
  82. meltygui/core/core_render.py +6537 -0
  83. meltygui/core/definition_hotswap.py +231 -0
  84. meltygui/core/diagnostics/__init__.py +1 -0
  85. meltygui/core/diagnostics/attribute_churn.py +38 -0
  86. meltygui/core/diagnostics/fps_counter.py +39 -0
  87. meltygui/core/diagnostics/gpu_frame_timer.py +103 -0
  88. meltygui/core/diagnostics/inspection_core.py +169 -0
  89. meltygui/core/diagnostics/monitor_core.py +105 -0
  90. meltygui/core/diagnostics/notifications.py +706 -0
  91. meltygui/core/diagnostics/perf_trace.py +281 -0
  92. meltygui/core/diagnostics/profile_decoration.py +88 -0
  93. meltygui/core/diagnostics/resize_trace.py +62 -0
  94. meltygui/core/diagnostics/screenshot_core.py +247 -0
  95. meltygui/core/diagnostics/session_status.py +98 -0
  96. meltygui/core/diagnostics/trace_core.py +445 -0
  97. meltygui/core/files/__init__.py +1 -0
  98. meltygui/core/files/file_core.py +208 -0
  99. meltygui/core/files/file_explorer_core.py +104 -0
  100. meltygui/core/files/file_tree_core.py +198 -0
  101. meltygui/core/files/file_watch_core.py +43 -0
  102. meltygui/core/files/import_graph_core.py +43 -0
  103. meltygui/core/files/metadata_core.py +51 -0
  104. meltygui/core/graphics/__init__.py +1 -0
  105. meltygui/core/graphics/cuda_context_core.py +166 -0
  106. meltygui/core/graphics/cuda_interop_core.py +136 -0
  107. meltygui/core/graphics/cuda_kernel_core.py +91 -0
  108. meltygui/core/graphics/framebuffer_recorder.py +337 -0
  109. meltygui/core/graphics/gl_state.py +658 -0
  110. meltygui/core/graphics/lut_core.py +52 -0
  111. meltygui/core/graphics/overlay_renderer.py +984 -0
  112. meltygui/core/graphics/scene_target.py +180 -0
  113. meltygui/core/graphics/screenshot.py +439 -0
  114. meltygui/core/graphics/shader_func.py +478 -0
  115. meltygui/core/graphics/tensor_core.py +45 -0
  116. meltygui/core/graphics/text_texture.py +329 -0
  117. meltygui/core/graphics/wayland_color.py +635 -0
  118. meltygui/core/input/__init__.py +1 -0
  119. meltygui/core/input/collision.py +165 -0
  120. meltygui/core/input/drag_drop_core.py +1525 -0
  121. meltygui/core/input/hypr_left_drag.py +323 -0
  122. meltygui/core/input/input_core.py +245 -0
  123. meltygui/core/input/input_handler.py +1101 -0
  124. meltygui/core/input/mouse_cursor.py +355 -0
  125. meltygui/core/input/pynput_backend.py +1054 -0
  126. meltygui/core/input/space_mouse.py +338 -0
  127. meltygui/core/input/touchpad_backend.py +393 -0
  128. meltygui/core/input/view_selection.py +177 -0
  129. meltygui/core/layout/__init__.py +1 -0
  130. meltygui/core/layout/column_core.py +2153 -0
  131. meltygui/core/layout/cursor_core.py +161 -0
  132. meltygui/core/layout/dropdown_core.py +278 -0
  133. meltygui/core/layout/edge_constraints.py +155 -0
  134. meltygui/core/layout/grid_core.py +117 -0
  135. meltygui/core/layout/header_core.py +23 -0
  136. meltygui/core/layout/header_runtime.py +67 -0
  137. meltygui/core/layout/layout_core.py +87 -0
  138. meltygui/core/layout/tile_manager_core.py +591 -0
  139. meltygui/core/melty.py +6726 -0
  140. meltygui/core/module_map.json +896 -0
  141. meltygui/core/module_names.py +19 -0
  142. meltygui/core/rendering/__init__.py +1 -0
  143. meltygui/core/rendering/core_decoration.py +431 -0
  144. meltygui/core/rendering/core_render_helpers.py +328 -0
  145. meltygui/core/rendering/func_metadata.py +398 -0
  146. meltygui/core/rendering/mode.py +818 -0
  147. meltygui/core/rendering/mode_defaults.py +41 -0
  148. meltygui/core/rendering/modes.py +136 -0
  149. meltygui/core/rendering/parameter_core.py +1665 -0
  150. meltygui/core/rendering/render_dispatch.py +1891 -0
  151. meltygui/core/rendering/render_funcs.py +273 -0
  152. meltygui/core/rendering/shaped.py +312 -0
  153. meltygui/core/rendering/window_decoration.py +25 -0
  154. meltygui/core/runtime/__init__.py +1 -0
  155. meltygui/core/runtime/app.py +735 -0
  156. meltygui/core/runtime/app_session.py +140 -0
  157. meltygui/core/runtime/background.py +564 -0
  158. meltygui/core/runtime/extensions.py +53 -0
  159. meltygui/core/runtime/gc_manager.py +1163 -0
  160. meltygui/core/runtime/lifecycle.py +21 -0
  161. meltygui/core/runtime/paths.py +27 -0
  162. meltygui/core/runtime/settings.py +14 -0
  163. meltygui/core/runtime/singleton.py +16 -0
  164. meltygui/core/runtime/thread_safe_bool.py +24 -0
  165. meltygui/core/runtime/thread_signal.py +30 -0
  166. meltygui/core/runtime/toggles.py +3115 -0
  167. meltygui/core/services/__init__.py +1 -0
  168. meltygui/core/services/account_core.py +10 -0
  169. meltygui/core/services/chat_core.py +19 -0
  170. meltygui/core/services/claude_terminal_core.py +346 -0
  171. meltygui/core/services/terminal_core.py +458 -0
  172. meltygui/core/services/terminal_runtime.py +78 -0
  173. meltygui/core/styling/__init__.py +1 -0
  174. meltygui/core/styling/color_core.py +46 -0
  175. meltygui/core/styling/fonts.py +639 -0
  176. meltygui/core/styling/global_style.py +338 -0
  177. meltygui/core/styling/style.py +198 -0
  178. meltygui/core/styling/style_core.py +522 -0
  179. meltygui/core/styling/warm_start.py +149 -0
  180. meltygui/core/windowing/__init__.py +1 -0
  181. meltygui/core/windowing/backends/PYIMGUI_LICENSE +28 -0
  182. meltygui/core/windowing/backends/__init__.py +1 -0
  183. meltygui/core/windowing/backends/imgui_renderer.py +138 -0
  184. meltygui/core/windowing/backends/native_wayland.py +850 -0
  185. meltygui/core/windowing/backends/protocols/xdg-decoration-unstable-v1.xml +156 -0
  186. meltygui/core/windowing/backends/protocols/xdg-shell.xml +1420 -0
  187. meltygui/core/windowing/backends/wayland_protocol.py +101 -0
  188. meltygui/core/windowing/dock_core.py +182 -0
  189. meltygui/core/windowing/frame_geometry.py +42 -0
  190. meltygui/core/windowing/geometry_feed.py +864 -0
  191. meltygui/core/windowing/glfw_utils.py +1343 -0
  192. meltygui/core/windowing/os_frame.py +1552 -0
  193. meltygui/core/windowing/surface.py +643 -0
  194. meltygui/core/windowing/titlebar.py +1560 -0
  195. meltygui/core/windowing/titlebar_buttons.py +281 -0
  196. meltygui/core/windowing/wayland_move.py +932 -0
  197. meltygui/core/windowing/window_api.py +62 -0
  198. meltygui/core/windowing/window_constants.py +339 -0
  199. meltygui/core/windowing/window_visibility.py +162 -0
  200. meltygui/debug/__init__.py +0 -0
  201. meltygui/debug/app_view_utils.py +9 -0
  202. meltygui/editor/__init__.py +0 -0
  203. meltygui/editor/bash_syntax.py +30 -0
  204. meltygui/editor/code_line_fast.py +152 -0
  205. meltygui/editor/diff.py +139 -0
  206. meltygui/editor/external_changes.py +159 -0
  207. meltygui/editor/file_header.py +41 -0
  208. meltygui/editor/live_usage.py +169 -0
  209. meltygui/editor/live_view_views.py +1803 -0
  210. meltygui/editor/pending_save.py +1351 -0
  211. meltygui/editor/roster_tints.py +547 -0
  212. meltygui/editor/source_preview.py +16 -0
  213. meltygui/editor/source_tools.py +10 -0
  214. meltygui/editor/source_ui.py +70 -0
  215. meltygui/editor/spell_check.py +77 -0
  216. meltygui/editor/text_editor.py +9076 -0
  217. meltygui/editor/usage_picker.py +538 -0
  218. meltygui/events/__init__.py +0 -0
  219. meltygui/events/example.py +118 -0
  220. meltygui/examples/__init__.py +0 -0
  221. meltygui/examples/columns_demo.py +33 -0
  222. meltygui/examples/columns_window_demo.py +60 -0
  223. meltygui/examples/context_menu_demo.py +24 -0
  224. meltygui/examples/context_menu_window_demo.py +49 -0
  225. meltygui/examples/gui_playground.py +127 -0
  226. meltygui/examples/live_view_playground.py +256 -0
  227. meltygui/examples/lora.py +43 -0
  228. meltygui/examples/lora_data.py +59 -0
  229. meltygui/examples/lora_policies.py +67 -0
  230. meltygui/examples/mode_demo.py +49 -0
  231. meltygui/examples/modifies_demo.py +119 -0
  232. meltygui/examples/scalar_policies.py +60 -0
  233. meltygui/examples/style_layouts.py +149 -0
  234. meltygui/examples/tile_manager_demo.py +74 -0
  235. meltygui/examples/tint_demo.py +160 -0
  236. meltygui/examples/tint_functions.py +56 -0
  237. meltygui/examples/trace_demo.py +88 -0
  238. meltygui/examples/two_windows.py +36 -0
  239. meltygui/files/__init__.py +0 -0
  240. meltygui/files/fast_file_explorer.py +439 -0
  241. meltygui/gnome_extension/lsd-window-geometry@latent-descent/extension.js +237 -0
  242. meltygui/gnome_extension/lsd-window-geometry@latent-descent/lsd-window-geometry@latent-descent.iml +9 -0
  243. meltygui/gnome_extension/lsd-window-geometry@latent-descent/metadata.json +7 -0
  244. meltygui/graphics/__init__.py +6 -0
  245. meltygui/graphics/base.py +85 -0
  246. meltygui/graphics/examples.py +507 -0
  247. meltygui/graphics/executor.py +520 -0
  248. meltygui/graphics/filter.py +667 -0
  249. meltygui/graphics/filter.pyi +856 -0
  250. meltygui/graphics/generate_stubs.py +22 -0
  251. meltygui/graphics/registry.py +203 -0
  252. meltygui/graphics/shader_compiler.py +155 -0
  253. meltygui/graphics/shaders.py +1302 -0
  254. meltygui/graphics/stub_generator.py +250 -0
  255. meltygui/graphics/texture_manager.py +170 -0
  256. meltygui/graphics/texture_min_max.py +295 -0
  257. meltygui/hdr_color.py +757 -0
  258. meltygui/image_load.py +308 -0
  259. meltygui/model/__init__.py +1 -0
  260. meltygui/model/account_model.py +142 -0
  261. meltygui/model/camera_model.py +159 -0
  262. meltygui/model/chat_model.py +86 -0
  263. meltygui/model/code_model.py +62 -0
  264. meltygui/model/code_proxy_model.py +876 -0
  265. meltygui/model/collection_model.py +41 -0
  266. meltygui/model/color_model.py +127 -0
  267. meltygui/model/cuda_tensor_model.py +36 -0
  268. meltygui/model/cuda_texture_model.py +149 -0
  269. meltygui/model/dropdown_model.py +137 -0
  270. meltygui/model/file_metadata_model.py +73 -0
  271. meltygui/model/file_model.py +289 -0
  272. meltygui/model/format_model.py +390 -0
  273. meltygui/model/graph_model.py +98 -0
  274. meltygui/model/icon_model.py +1024 -0
  275. meltygui/model/import_graph_model.py +468 -0
  276. meltygui/model/layout_model.py +15 -0
  277. meltygui/model/lut_model.py +266 -0
  278. meltygui/model/search_model.py +173 -0
  279. meltygui/model/tensor_model.py +402 -0
  280. meltygui/model/terminal_model.py +329 -0
  281. meltygui/model/texture_model.py +146 -0
  282. meltygui/model/tile_model.py +24 -0
  283. meltygui/model/trace_model.py +198 -0
  284. meltygui/model/trace_report_model.py +146 -0
  285. meltygui/models/__init__.py +0 -0
  286. meltygui/models/file_meta.py +613 -0
  287. meltygui/models/function_console.py +184 -0
  288. meltygui/models/orchestration.py +48 -0
  289. meltygui/pbr.py +1576 -0
  290. meltygui/png_unfilter.c +49 -0
  291. meltygui/resources/JetBrainsMono-Regular.ttf +0 -0
  292. meltygui/resources/THIRD_PARTY_NOTICES.md +21 -0
  293. meltygui/resources/dejavu/DejaVuSans-Bold.ttf +0 -0
  294. meltygui/resources/dejavu/DejaVuSans-ExtraLight.ttf +0 -0
  295. meltygui/resources/dejavu/DejaVuSans.ttf +0 -0
  296. meltygui/resources/dejavu/LICENSE.txt +78 -0
  297. meltygui/resources/fontawesome-LICENSE.txt +121 -0
  298. meltygui/resources/fontawesome-webfont.ttf +0 -0
  299. meltygui/resources/hdri/studio_small_09_1k.hdr +0 -0
  300. meltygui/resources/jetbrains-weights/JetBrainsMono-Bold.ttf +0 -0
  301. meltygui/resources/jetbrains-weights/JetBrainsMono-ExtraBold.ttf +0 -0
  302. meltygui/resources/jetbrains-weights/JetBrainsMono-ExtraLight.ttf +0 -0
  303. meltygui/resources/jetbrains-weights/JetBrainsMono-Light.ttf +0 -0
  304. meltygui/resources/jetbrains-weights/JetBrainsMono-Medium.ttf +0 -0
  305. meltygui/resources/jetbrains-weights/JetBrainsMono-SemiBold.ttf +0 -0
  306. meltygui/resources/jetbrains-weights/JetBrainsMono-Thin.ttf +0 -0
  307. meltygui/resources/jetbrains-weights/OFL.txt +93 -0
  308. meltygui/resources/jetbrains-weights/README.md +2 -0
  309. meltygui/state/__init__.py +0 -0
  310. meltygui/state/account_state.py +22 -0
  311. meltygui/state/animation_state.py +97 -0
  312. meltygui/state/annotation_state.py +22 -0
  313. meltygui/state/chat_state.py +36 -0
  314. meltygui/state/code_state.py +10 -0
  315. meltygui/state/core_enums.py +59 -0
  316. meltygui/state/core_markers.py +115 -0
  317. meltygui/state/core_undo.py +1075 -0
  318. meltygui/state/file_state.py +75 -0
  319. meltygui/state/graph_state.py +26 -0
  320. meltygui/state/inspection_state.py +47 -0
  321. meltygui/state/menu_state.py +10 -0
  322. meltygui/state/model_enums.py +11 -0
  323. meltygui/state/new_core_model.py +2394 -0
  324. meltygui/state/orchestration_state.py +14 -0
  325. meltygui/state/query_state.py +24 -0
  326. meltygui/state/tensor_state.py +10 -0
  327. meltygui/state/terminal_state.py +23 -0
  328. meltygui/state/trace_state.py +32 -0
  329. meltygui/state/voxel_state.py +12 -0
  330. meltygui/text_index.py +816 -0
  331. meltygui/utils/__init__.py +0 -0
  332. meltygui/utils/jump_to_code.py +344 -0
  333. meltygui/utils/pkl_inspect.py +90 -0
  334. meltygui/utils/render_utils.py +1419 -0
  335. meltygui/view/__init__.py +1 -0
  336. meltygui/view/account_view.py +524 -0
  337. meltygui/view/action_view.py +73 -0
  338. meltygui/view/chat_decoration_view.py +112 -0
  339. meltygui/view/chat_view.py +1703 -0
  340. meltygui/view/code_view.py +2677 -0
  341. meltygui/view/collection_view.py +1185 -0
  342. meltygui/view/color_view.py +824 -0
  343. meltygui/view/control_view.py +559 -0
  344. meltygui/view/decoration_view.py +439 -0
  345. meltygui/view/diagnostic_view.py +177 -0
  346. meltygui/view/dropdown_view.py +1082 -0
  347. meltygui/view/file_view.py +1599 -0
  348. meltygui/view/graph_cuda_view.py +105 -0
  349. meltygui/view/graph_view.py +882 -0
  350. meltygui/view/header_view.py +848 -0
  351. meltygui/view/input_view.py +238 -0
  352. meltygui/view/inspection_view.py +1783 -0
  353. meltygui/view/layout_view.py +596 -0
  354. meltygui/view/lut_view.py +45 -0
  355. meltygui/view/menu_view.py +212 -0
  356. meltygui/view/orchestration_view.py +658 -0
  357. meltygui/view/query_view.py +118 -0
  358. meltygui/view/search_view.py +342 -0
  359. meltygui/view/tab_view.py +258 -0
  360. meltygui/view/tensor_view.py +430 -0
  361. meltygui/view/terminal_view.py +355 -0
  362. meltygui/view/text_view.py +8031 -0
  363. meltygui/view/texture_view.py +480 -0
  364. meltygui/view/tile_view.py +38 -0
  365. meltygui/view/trace_view.py +923 -0
  366. meltygui/view/voxel_cuda_view.py +824 -0
  367. meltygui/view/voxel_view.py +1860 -0
  368. meltygui/view/window_view.py +111 -0
  369. meltygui-0.1.0.dist-info/METADATA +143 -0
  370. meltygui-0.1.0.dist-info/RECORD +372 -0
  371. meltygui-0.1.0.dist-info/WHEEL +4 -0
  372. meltygui-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,62 @@
1
+ """Window operations shared by native Wayland and GLFW surfaces.
2
+
3
+ GLFW's constants and callback signatures remain the compatibility vocabulary.
4
+ The selected backend owns all windows in an app's GL share group. Merely
5
+ importing this module does not initialize GLFW or connect to a display.
6
+ """
7
+ import importlib
8
+ import os
9
+ import sys
10
+ import meltygui.core.windowing.window_constants as window_constants
11
+
12
+ _state = globals().get('_state') or {'backend': None, 'selected': False}
13
+
14
+
15
+ def use_native_windows(enabled, environment=None, platform=None):
16
+ environment = os.environ if environment is None else environment
17
+ platform = sys.platform if platform is None else platform
18
+ return bool(enabled and platform.startswith('linux') and
19
+ (environment.get('WAYLAND_DISPLAY') or environment.get('WAYLAND_SOCKET')))
20
+
21
+
22
+ def select_backend(enabled):
23
+ if _state['selected']:
24
+ return backend_name()
25
+ if use_native_windows(enabled):
26
+ from meltygui.core.windowing.backends.native_wayland import Backend
27
+ _state['backend'] = Backend()
28
+ _state['selected'] = True
29
+ return backend_name()
30
+
31
+
32
+ def backend_name():
33
+ return 'wayland' if _state['backend'] is not None else 'glfw'
34
+
35
+
36
+ def is_native_window(window):
37
+ # Inspect the class marker, not a truthy instance attribute: MagicMock
38
+ # manufactures attributes and must never pass as a real window handle.
39
+ return getattr(type(window), 'native_wayland', False) is True
40
+
41
+
42
+ def terminate():
43
+ backend = _state['backend']
44
+ try:
45
+ (backend or importlib.import_module('glfw')).terminate()
46
+ finally:
47
+ _state.update(backend=None, selected=False)
48
+
49
+
50
+ def __getattr__(name):
51
+ # Source analysis and intros probe module metadata. Forwarding a missing
52
+ # __module__/__wrapped__/__path__ to GLFW loads its shared library merely
53
+ # to discover that GLFW does not supply such metadata either.
54
+ if name.startswith('__'):
55
+ raise AttributeError(name)
56
+ if name.isupper() and hasattr(window_constants, name):
57
+ return getattr(window_constants, name)
58
+ backend = _state['backend']
59
+ if backend is not None and not name.isupper() and not name.startswith('_'):
60
+ # Never send native handles to GLFW's C functions by accident.
61
+ return getattr(backend, name)
62
+ return getattr(importlib.import_module('glfw'), name)
@@ -0,0 +1,339 @@
1
+ """GLFW 3.4 numeric API constants used by the shared window facade.
2
+
3
+ Generated from pyGLFW 2.10.2. These protocol/API values do not require loading
4
+ GLFW's shared library. tests/test_native_windows.py checks them against pyGLFW;
5
+ update this table when adopting new GLFW API constants.
6
+ """
7
+
8
+ ACCUM_ALPHA_BITS = 135178
9
+ ACCUM_BLUE_BITS = 135177
10
+ ACCUM_GREEN_BITS = 135176
11
+ ACCUM_RED_BITS = 135175
12
+ ALPHA_BITS = 135172
13
+ ANGLE_PLATFORM_TYPE = 327682
14
+ ANGLE_PLATFORM_TYPE_D3D11 = 225285
15
+ ANGLE_PLATFORM_TYPE_D3D9 = 225284
16
+ ANGLE_PLATFORM_TYPE_METAL = 225288
17
+ ANGLE_PLATFORM_TYPE_NONE = 225281
18
+ ANGLE_PLATFORM_TYPE_OPENGL = 225282
19
+ ANGLE_PLATFORM_TYPE_OPENGLES = 225283
20
+ ANGLE_PLATFORM_TYPE_VULKAN = 225287
21
+ ANY_PLATFORM = 393216
22
+ ANY_POSITION = 2147483648
23
+ ANY_RELEASE_BEHAVIOR = 0
24
+ API_UNAVAILABLE = 65542
25
+ ARROW_CURSOR = 221185
26
+ AUTO_ICONIFY = 131078
27
+ AUX_BUFFERS = 135179
28
+ BLUE_BITS = 135171
29
+ CENTER_CURSOR = 131081
30
+ CLIENT_API = 139265
31
+ COCOA_CHDIR_RESOURCES = 331777
32
+ COCOA_FRAME_NAME = 143362
33
+ COCOA_GRAPHICS_SWITCHING = 143363
34
+ COCOA_MENUBAR = 331778
35
+ COCOA_RETINA_FRAMEBUFFER = 143361
36
+ CONNECTED = 262145
37
+ CONTEXT_CREATION_API = 139275
38
+ CONTEXT_DEBUG = 139271
39
+ CONTEXT_NO_ERROR = 139274
40
+ CONTEXT_RELEASE_BEHAVIOR = 139273
41
+ CONTEXT_REVISION = 139268
42
+ CONTEXT_ROBUSTNESS = 139269
43
+ CONTEXT_VERSION_MAJOR = 139266
44
+ CONTEXT_VERSION_MINOR = 139267
45
+ CROSSHAIR_CURSOR = 221187
46
+ CURSOR = 208897
47
+ CURSOR_CAPTURED = 212996
48
+ CURSOR_DISABLED = 212995
49
+ CURSOR_HIDDEN = 212994
50
+ CURSOR_NORMAL = 212993
51
+ CURSOR_UNAVAILABLE = 65547
52
+ DECORATED = 131077
53
+ DEPTH_BITS = 135173
54
+ DISCONNECTED = 262146
55
+ DONT_CARE = -1
56
+ DOUBLEBUFFER = 135184
57
+ EGL_CONTEXT_API = 221186
58
+ FALSE = 0
59
+ FEATURE_UNAVAILABLE = 65548
60
+ FEATURE_UNIMPLEMENTED = 65549
61
+ FLOATING = 131079
62
+ FOCUSED = 131073
63
+ FOCUS_ON_SHOW = 131084
64
+ FORMAT_UNAVAILABLE = 65545
65
+ GAMEPAD_AXIS_LAST = 5
66
+ GAMEPAD_AXIS_LEFT_TRIGGER = 4
67
+ GAMEPAD_AXIS_LEFT_X = 0
68
+ GAMEPAD_AXIS_LEFT_Y = 1
69
+ GAMEPAD_AXIS_RIGHT_TRIGGER = 5
70
+ GAMEPAD_AXIS_RIGHT_X = 2
71
+ GAMEPAD_AXIS_RIGHT_Y = 3
72
+ GAMEPAD_BUTTON_A = 0
73
+ GAMEPAD_BUTTON_B = 1
74
+ GAMEPAD_BUTTON_BACK = 6
75
+ GAMEPAD_BUTTON_CIRCLE = 1
76
+ GAMEPAD_BUTTON_CROSS = 0
77
+ GAMEPAD_BUTTON_DPAD_DOWN = 13
78
+ GAMEPAD_BUTTON_DPAD_LEFT = 14
79
+ GAMEPAD_BUTTON_DPAD_RIGHT = 12
80
+ GAMEPAD_BUTTON_DPAD_UP = 11
81
+ GAMEPAD_BUTTON_GUIDE = 8
82
+ GAMEPAD_BUTTON_LAST = 14
83
+ GAMEPAD_BUTTON_LEFT_BUMPER = 4
84
+ GAMEPAD_BUTTON_LEFT_THUMB = 9
85
+ GAMEPAD_BUTTON_RIGHT_BUMPER = 5
86
+ GAMEPAD_BUTTON_RIGHT_THUMB = 10
87
+ GAMEPAD_BUTTON_SQUARE = 2
88
+ GAMEPAD_BUTTON_START = 7
89
+ GAMEPAD_BUTTON_TRIANGLE = 3
90
+ GAMEPAD_BUTTON_X = 2
91
+ GAMEPAD_BUTTON_Y = 3
92
+ GREEN_BITS = 135170
93
+ HAND_CURSOR = 221188
94
+ HAT_CENTERED = 0
95
+ HAT_DOWN = 4
96
+ HAT_LEFT = 8
97
+ HAT_LEFT_DOWN = 12
98
+ HAT_LEFT_UP = 9
99
+ HAT_RIGHT = 2
100
+ HAT_RIGHT_DOWN = 6
101
+ HAT_RIGHT_UP = 3
102
+ HAT_UP = 1
103
+ HOVERED = 131083
104
+ HRESIZE_CURSOR = 221189
105
+ IBEAM_CURSOR = 221186
106
+ ICONIFIED = 131074
107
+ INVALID_ENUM = 65539
108
+ INVALID_VALUE = 65540
109
+ JOYSTICK_1 = 0
110
+ JOYSTICK_10 = 9
111
+ JOYSTICK_11 = 10
112
+ JOYSTICK_12 = 11
113
+ JOYSTICK_13 = 12
114
+ JOYSTICK_14 = 13
115
+ JOYSTICK_15 = 14
116
+ JOYSTICK_16 = 15
117
+ JOYSTICK_2 = 1
118
+ JOYSTICK_3 = 2
119
+ JOYSTICK_4 = 3
120
+ JOYSTICK_5 = 4
121
+ JOYSTICK_6 = 5
122
+ JOYSTICK_7 = 6
123
+ JOYSTICK_8 = 7
124
+ JOYSTICK_9 = 8
125
+ JOYSTICK_HAT_BUTTONS = 327681
126
+ JOYSTICK_LAST = 15
127
+ KEY_0 = 48
128
+ KEY_1 = 49
129
+ KEY_2 = 50
130
+ KEY_3 = 51
131
+ KEY_4 = 52
132
+ KEY_5 = 53
133
+ KEY_6 = 54
134
+ KEY_7 = 55
135
+ KEY_8 = 56
136
+ KEY_9 = 57
137
+ KEY_A = 65
138
+ KEY_APOSTROPHE = 39
139
+ KEY_B = 66
140
+ KEY_BACKSLASH = 92
141
+ KEY_BACKSPACE = 259
142
+ KEY_C = 67
143
+ KEY_CAPS_LOCK = 280
144
+ KEY_COMMA = 44
145
+ KEY_D = 68
146
+ KEY_DELETE = 261
147
+ KEY_DOWN = 264
148
+ KEY_E = 69
149
+ KEY_END = 269
150
+ KEY_ENTER = 257
151
+ KEY_EQUAL = 61
152
+ KEY_ESCAPE = 256
153
+ KEY_F = 70
154
+ KEY_F1 = 290
155
+ KEY_F10 = 299
156
+ KEY_F11 = 300
157
+ KEY_F12 = 301
158
+ KEY_F13 = 302
159
+ KEY_F14 = 303
160
+ KEY_F15 = 304
161
+ KEY_F16 = 305
162
+ KEY_F17 = 306
163
+ KEY_F18 = 307
164
+ KEY_F19 = 308
165
+ KEY_F2 = 291
166
+ KEY_F20 = 309
167
+ KEY_F21 = 310
168
+ KEY_F22 = 311
169
+ KEY_F23 = 312
170
+ KEY_F24 = 313
171
+ KEY_F25 = 314
172
+ KEY_F3 = 292
173
+ KEY_F4 = 293
174
+ KEY_F5 = 294
175
+ KEY_F6 = 295
176
+ KEY_F7 = 296
177
+ KEY_F8 = 297
178
+ KEY_F9 = 298
179
+ KEY_G = 71
180
+ KEY_GRAVE_ACCENT = 96
181
+ KEY_H = 72
182
+ KEY_HOME = 268
183
+ KEY_I = 73
184
+ KEY_INSERT = 260
185
+ KEY_J = 74
186
+ KEY_K = 75
187
+ KEY_KP_0 = 320
188
+ KEY_KP_1 = 321
189
+ KEY_KP_2 = 322
190
+ KEY_KP_3 = 323
191
+ KEY_KP_4 = 324
192
+ KEY_KP_5 = 325
193
+ KEY_KP_6 = 326
194
+ KEY_KP_7 = 327
195
+ KEY_KP_8 = 328
196
+ KEY_KP_9 = 329
197
+ KEY_KP_ADD = 334
198
+ KEY_KP_DECIMAL = 330
199
+ KEY_KP_DIVIDE = 331
200
+ KEY_KP_ENTER = 335
201
+ KEY_KP_EQUAL = 336
202
+ KEY_KP_MULTIPLY = 332
203
+ KEY_KP_SUBTRACT = 333
204
+ KEY_L = 76
205
+ KEY_LAST = 348
206
+ KEY_LEFT = 263
207
+ KEY_LEFT_ALT = 342
208
+ KEY_LEFT_BRACKET = 91
209
+ KEY_LEFT_CONTROL = 341
210
+ KEY_LEFT_SHIFT = 340
211
+ KEY_LEFT_SUPER = 343
212
+ KEY_M = 77
213
+ KEY_MENU = 348
214
+ KEY_MINUS = 45
215
+ KEY_N = 78
216
+ KEY_NUM_LOCK = 282
217
+ KEY_O = 79
218
+ KEY_P = 80
219
+ KEY_PAGE_DOWN = 267
220
+ KEY_PAGE_UP = 266
221
+ KEY_PAUSE = 284
222
+ KEY_PERIOD = 46
223
+ KEY_PRINT_SCREEN = 283
224
+ KEY_Q = 81
225
+ KEY_R = 82
226
+ KEY_RIGHT = 262
227
+ KEY_RIGHT_ALT = 346
228
+ KEY_RIGHT_BRACKET = 93
229
+ KEY_RIGHT_CONTROL = 345
230
+ KEY_RIGHT_SHIFT = 344
231
+ KEY_RIGHT_SUPER = 347
232
+ KEY_S = 83
233
+ KEY_SCROLL_LOCK = 281
234
+ KEY_SEMICOLON = 59
235
+ KEY_SLASH = 47
236
+ KEY_SPACE = 32
237
+ KEY_T = 84
238
+ KEY_TAB = 258
239
+ KEY_U = 85
240
+ KEY_UNKNOWN = -1
241
+ KEY_UP = 265
242
+ KEY_V = 86
243
+ KEY_W = 87
244
+ KEY_WORLD_1 = 161
245
+ KEY_WORLD_2 = 162
246
+ KEY_X = 88
247
+ KEY_Y = 89
248
+ KEY_Z = 90
249
+ LOCK_KEY_MODS = 208900
250
+ LOSE_CONTEXT_ON_RESET = 200706
251
+ MAXIMIZED = 131080
252
+ MOD_ALT = 4
253
+ MOD_CAPS_LOCK = 16
254
+ MOD_CONTROL = 2
255
+ MOD_NUM_LOCK = 32
256
+ MOD_SHIFT = 1
257
+ MOD_SUPER = 8
258
+ MOUSE_BUTTON_1 = 0
259
+ MOUSE_BUTTON_2 = 1
260
+ MOUSE_BUTTON_3 = 2
261
+ MOUSE_BUTTON_4 = 3
262
+ MOUSE_BUTTON_5 = 4
263
+ MOUSE_BUTTON_6 = 5
264
+ MOUSE_BUTTON_7 = 6
265
+ MOUSE_BUTTON_8 = 7
266
+ MOUSE_BUTTON_LAST = 7
267
+ MOUSE_BUTTON_LEFT = 0
268
+ MOUSE_BUTTON_MIDDLE = 2
269
+ MOUSE_BUTTON_RIGHT = 1
270
+ MOUSE_PASSTHROUGH = 131085
271
+ NATIVE_CONTEXT_API = 221185
272
+ NOT_ALLOWED_CURSOR = 221194
273
+ NOT_INITIALIZED = 65537
274
+ NO_API = 0
275
+ NO_CURRENT_CONTEXT = 65538
276
+ NO_ERROR = 0
277
+ NO_RESET_NOTIFICATION = 200705
278
+ NO_ROBUSTNESS = 0
279
+ NO_WINDOW_CONTEXT = 65546
280
+ OPENGL_ANY_PROFILE = 0
281
+ OPENGL_API = 196609
282
+ OPENGL_COMPAT_PROFILE = 204802
283
+ OPENGL_CORE_PROFILE = 204801
284
+ OPENGL_DEBUG_CONTEXT = 139271
285
+ OPENGL_ES_API = 196610
286
+ OPENGL_FORWARD_COMPAT = 139270
287
+ OPENGL_PROFILE = 139272
288
+ OSMESA_CONTEXT_API = 221187
289
+ OUT_OF_MEMORY = 65541
290
+ PLATFORM = 327683
291
+ PLATFORM_COCOA = 393218
292
+ PLATFORM_ERROR = 65544
293
+ PLATFORM_NULL = 393221
294
+ PLATFORM_UNAVAILABLE = 65550
295
+ PLATFORM_WAYLAND = 393219
296
+ PLATFORM_WIN32 = 393217
297
+ PLATFORM_X11 = 393220
298
+ POINTING_HAND_CURSOR = 221188
299
+ POSITION_X = 131086
300
+ POSITION_Y = 131087
301
+ PRESS = 1
302
+ RAW_MOUSE_MOTION = 208901
303
+ RED_BITS = 135169
304
+ REFRESH_RATE = 135183
305
+ RELEASE = 0
306
+ RELEASE_BEHAVIOR_FLUSH = 217089
307
+ RELEASE_BEHAVIOR_NONE = 217090
308
+ REPEAT = 2
309
+ RESIZABLE = 131075
310
+ RESIZE_ALL_CURSOR = 221193
311
+ RESIZE_EW_CURSOR = 221189
312
+ RESIZE_NESW_CURSOR = 221192
313
+ RESIZE_NS_CURSOR = 221190
314
+ RESIZE_NWSE_CURSOR = 221191
315
+ SAMPLES = 135181
316
+ SCALE_FRAMEBUFFER = 139277
317
+ SCALE_TO_MONITOR = 139276
318
+ SRGB_CAPABLE = 135182
319
+ STENCIL_BITS = 135174
320
+ STEREO = 135180
321
+ STICKY_KEYS = 208898
322
+ STICKY_MOUSE_BUTTONS = 208899
323
+ TRANSPARENT_FRAMEBUFFER = 131082
324
+ TRUE = 1
325
+ VERSION_MAJOR = 3
326
+ VERSION_MINOR = 4
327
+ VERSION_REVISION = 0
328
+ VERSION_UNAVAILABLE = 65543
329
+ VISIBLE = 131076
330
+ VRESIZE_CURSOR = 221190
331
+ WAYLAND_APP_ID = 155649
332
+ WAYLAND_DISABLE_LIBDECOR = 229378
333
+ WAYLAND_LIBDECOR = 339969
334
+ WAYLAND_PREFER_LIBDECOR = 229377
335
+ WIN32_KEYBOARD_MENU = 151553
336
+ WIN32_SHOWDEFAULT = 151554
337
+ X11_CLASS_NAME = 147457
338
+ X11_INSTANCE_NAME = 147458
339
+ X11_XCB_VULKAN_SURFACE = 335873
@@ -0,0 +1,162 @@
1
+ """Visibility contract shared by nested Melty and GLFW child windows."""
2
+
3
+
4
+ def requested_window_closed(closed, kwargs, *, first_request=False):
5
+ if first_request and 'open_requested' in kwargs:
6
+ closed = True
7
+ if kwargs.get('closed') is not None:
8
+ closed = bool(kwargs['closed'])
9
+ if kwargs.get('open_requested'):
10
+ closed = False
11
+ return closed
12
+
13
+
14
+ from meltygui.core.conversion.dict_conversion import DictConversion
15
+
16
+
17
+ class WindowOverrideState(DictConversion):
18
+ """View-local source tracking; automatic geometry corrections aren't edits."""
19
+ def __init__(self):
20
+ super().__init__()
21
+ self.position = None
22
+ self.comment_closed = None
23
+ self.pending_marker_closed = None
24
+ self.native_kwargs = None
25
+ self.comment_values = None
26
+
27
+
28
+ def override_state(draw_state):
29
+ state = draw_state.misc.get('window_overrides')
30
+ if state is None:
31
+ state = WindowOverrideState()
32
+ draw_state.misc['window_overrides'] = state
33
+ return state
34
+
35
+
36
+ def resolved_window_kwargs(draw_state, kwargs):
37
+ from meltygui.core.rendering.parameter_core import anywhere_value
38
+ resolved = kwargs
39
+ pending = getattr(draw_state, '_sa_pending', None) or {}
40
+ for name in ('closed', 'window_pos'):
41
+ if name in kwargs or name in pending:
42
+ if resolved is kwargs:
43
+ resolved = dict(kwargs)
44
+ resolved[name] = anywhere_value(name, draw_state, live_kwargs=kwargs)
45
+ return resolved
46
+
47
+
48
+ def _comment_value(value):
49
+ """Snapshot small annotation values without comparing opaque model data."""
50
+ if isinstance(value, (str, int, float, bool, type(None))):
51
+ return type(value), value
52
+ if isinstance(value, (tuple, list)):
53
+ return type(value), tuple(_comment_value(item) for item in value)
54
+ if isinstance(value, dict):
55
+ return tuple((key, _comment_value(item)) for key, item in value.items())
56
+ return type(value), id(value)
57
+
58
+
59
+ def invalidate_comment_edit(draw_state, comment_args, kwargs):
60
+ """Repaint a replayed live window once when its driving comment changes."""
61
+ from meltygui.core.melty import Melty
62
+ state = override_state(draw_state)
63
+ current = {key: _comment_value(value) for key, value in comment_args.items()
64
+ if key != 'closed' and not (isinstance(key, str) and key.startswith('__'))}
65
+ previous = state.comment_values
66
+ if previous is not None:
67
+ for key in previous.keys() - current.keys():
68
+ if key in kwargs and _comment_value(kwargs[key]) == previous[key]:
69
+ kwargs.pop(key)
70
+ if previous != current:
71
+ Melty.cache.invalidate_up(draw_state._tile_id, force=True, max_depth=8)
72
+ state.comment_values = current
73
+
74
+
75
+ def sync_live_comment_inputs(draw_state, kwargs):
76
+ root = draw_state.__dict__.get('live_root')
77
+ key = draw_state.__dict__.get('live_key')
78
+ if not isinstance(root, dict) or not key:
79
+ return
80
+ if draw_state.__dict__.get('_lv_locator') is not None:
81
+ from meltygui.editor.live_view_views import current_live_root
82
+ root = current_live_root(draw_state)
83
+ comment = root.get('__overrides__', {}).get(f'__{key}__') if isinstance(root, dict) else None
84
+ invalidate_comment_edit(draw_state, comment if isinstance(comment, dict) else {}, kwargs)
85
+
86
+
87
+ def adopt_window_position(draw_state, kwargs):
88
+ """Adopt changed source positions, not the same value on every frame.
89
+
90
+ In particular an off-screen rescue or pin collision stays local rather
91
+ than snapping back each frame or writing itself into source code.
92
+ """
93
+ position = kwargs.get('window_pos')
94
+ if position is None:
95
+ return
96
+ position = tuple(int(v) for v in position)
97
+ state = override_state(draw_state)
98
+ if state.position != position:
99
+ state.position = position
100
+ draw_state.window_pos = position
101
+
102
+
103
+ def user_window_closed(draw_state, closed):
104
+ """Only a user's close/open action writes back to the driving source."""
105
+ draw_state.locate_closed = bool(closed)
106
+ draw_state.closed = bool(closed)
107
+
108
+
109
+ def user_window_position(draw_state, position):
110
+ position = tuple(round(v) for v in position)
111
+ draw_state.locate_window_pos = position
112
+ draw_state.window_pos = position
113
+
114
+
115
+ def native_user_window_closed(draw_state, closed):
116
+ # The native surface renders an inline root with different kwargs. Source
117
+ # discovery for its controls must see the parent-side window request.
118
+ state = override_state(draw_state)
119
+ original = draw_state._kwargs
120
+ if state.native_kwargs is not None:
121
+ draw_state._kwargs = state.native_kwargs
122
+ try:
123
+ user_window_closed(draw_state, closed)
124
+ finally:
125
+ draw_state._kwargs = original
126
+
127
+
128
+ def native_user_window_position(draw_state, position):
129
+ state = override_state(draw_state)
130
+ original = draw_state._kwargs
131
+ if state.native_kwargs is not None:
132
+ draw_state._kwargs = state.native_kwargs
133
+ try:
134
+ draw_state.locate_window_pos = tuple(round(v) for v in position)
135
+ finally:
136
+ draw_state._kwargs = original
137
+
138
+
139
+ def marker_user_visibility(marker, closed):
140
+ state = override_state(marker)
141
+ window = getattr(marker, '_lv_window_ds', None)
142
+ if window is None:
143
+ state.pending_marker_closed = bool(closed)
144
+ else:
145
+ user_window_closed(window, closed)
146
+
147
+
148
+ def sync_marker_visibility(marker, comment_args):
149
+ state = override_state(marker)
150
+ closed = comment_args.pop('closed', None)
151
+ closed = None if closed is None else bool(closed)
152
+ if state.comment_closed != closed:
153
+ state.comment_closed = closed
154
+ marker._lv_open = None if closed is None else not closed
155
+ window = getattr(marker, '_lv_window_ds', None)
156
+ if window is not None:
157
+ window.closed = bool(closed)
158
+
159
+
160
+ def window_edit_is_local(draw_state, parameter):
161
+ source = (getattr(draw_state, '_sa_last_source', None) or {}).get(parameter)
162
+ return source in (None, 'draw state')
File without changes
@@ -0,0 +1,9 @@
1
+ from meltygui.core.styling.global_style import GlobalStyle
2
+
3
+
4
+ def should_exclude(name, root=None):
5
+
6
+ global_exclude = GlobalStyle.excluded_names
7
+
8
+ exclude = name.startswith('_') or name.endswith('_h') or name in global_exclude or name.startswith('p_')
9
+ return exclude
File without changes
@@ -0,0 +1,30 @@
1
+ """Bash tokens in the text editor's palette, cached by source identity."""
2
+ from bisect import bisect_right
3
+ from pygments.lexers import BashLexer
4
+ from pygments.token import Comment, Keyword, Name, Number, String
5
+
6
+
7
+ def window_tokens(state, text, offsets, first, last):
8
+ memo = getattr(state, '_bash_tokens', None)
9
+ if memo is None or memo[0] is not text:
10
+ tokens = []
11
+ for offset, kind, value in BashLexer().get_tokens_unprocessed(text):
12
+ color = ('comment' if kind in Comment else 'keyword' if kind in Keyword else
13
+ 'builtin' if kind in Name.Builtin else 'builtin_pseudo' if kind in Name.Variable else
14
+ 'string' if kind in String else 'number' if kind in Number else 'default')
15
+ tokens.append((offset, value, color))
16
+ memo = (text, tokens, [token[0] for token in tokens])
17
+ state._bash_tokens = memo
18
+ first = min(max(0, first), len(offsets) - 1)
19
+ last = min(last, len(offsets) - 1)
20
+ start = offsets[first]
21
+ end = offsets[last + 1] if last + 1 < len(offsets) else len(text)
22
+ result = []
23
+ for index in range(max(0, bisect_right(memo[2], start) - 1), len(memo[1])):
24
+ offset, value, color = memo[1][index]
25
+ if offset >= end:
26
+ break
27
+ part = value[max(0, start - offset):end - offset]
28
+ if part:
29
+ result.append((part, color))
30
+ return first, start, result