|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +from pathlib import Path |
3 | 4 | from typing import TYPE_CHECKING |
4 | 5 |
|
5 | 6 | from je_editor import EditorWidget |
6 | 7 |
|
7 | 8 | if TYPE_CHECKING: |
8 | 9 | from automation_ide.automation_editor_ui.editor_main.main_ui import AutomationEditor |
9 | | -from PySide6.QtCore import QRegularExpression |
10 | | -from PySide6.QtGui import QTextCharFormat, QColor |
| 10 | +from PySide6.QtGui import QColor |
11 | 11 |
|
12 | 12 | from automation_ide.automation_editor_ui.syntax.syntax_keyword import \ |
13 | 13 | package_keyword_list |
14 | 14 | from automation_ide.utils.manager.package_manager.package_manager_class import package_manager |
15 | 15 |
|
16 | | -from je_editor import syntax_word_setting_dict |
| 16 | +from je_editor import syntax_extend_setting_dict |
17 | 17 |
|
18 | 18 |
|
19 | 19 | def syntax_extend_package(main_window: AutomationEditor) -> None: |
20 | | - widget = main_window.tab_widget.currentWidget() |
21 | | - if isinstance(widget, EditorWidget): |
22 | | - for package in package_manager.syntax_check_list: |
23 | | - text_char_format = QTextCharFormat() |
24 | | - text_char_format.setForeground(QColor(255, 255, 0)) |
25 | | - for word in package_keyword_list.get(package): |
26 | | - # Highlight |
27 | | - pattern = QRegularExpression(rf"\b{word}\b") |
28 | | - widget.code_edit.highlighter.highlight_rules.append((pattern, text_char_format)) |
| 20 | + syntax_extend_setting_dict.update({".json": {}}) |
29 | 21 | for package in package_manager.syntax_check_list: |
30 | | - syntax_word_setting_dict.update( |
| 22 | + syntax_extend_setting_dict.get(".json").update( |
31 | 23 | { |
32 | 24 | package: { |
33 | 25 | "words": set(package_keyword_list.get(package)), |
34 | 26 | "color": QColor(255, 255, 0) |
35 | 27 | } |
36 | 28 | } |
37 | 29 | ) |
| 30 | + widget = main_window.tab_widget.currentWidget() |
| 31 | + if isinstance(widget, EditorWidget): |
| 32 | + widget.code_edit.reset_highlighter() |
0 commit comments