je-editor 0.0.202__py3-none-any.whl → 0.0.228__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 (96) hide show
  1. je_editor/__init__.py +2 -2
  2. je_editor/code_scan/__init__.py +0 -0
  3. je_editor/code_scan/ruff_thread.py +58 -0
  4. je_editor/code_scan/watchdog_implement.py +56 -0
  5. je_editor/code_scan/watchdog_thread.py +78 -0
  6. je_editor/git_client/__init__.py +0 -0
  7. je_editor/git_client/commit_graph.py +77 -0
  8. je_editor/git_client/git_action.py +175 -0
  9. je_editor/git_client/git_cli.py +66 -0
  10. je_editor/pyside_ui/browser/browser_download_window.py +40 -4
  11. je_editor/pyside_ui/browser/browser_serach_lineedit.py +24 -0
  12. je_editor/pyside_ui/browser/browser_view.py +55 -6
  13. je_editor/pyside_ui/browser/browser_widget.py +62 -19
  14. je_editor/pyside_ui/browser/main_browser_widget.py +85 -0
  15. je_editor/pyside_ui/code/auto_save/auto_save_manager.py +33 -1
  16. je_editor/pyside_ui/code/auto_save/auto_save_thread.py +18 -5
  17. je_editor/pyside_ui/code/code_format/pep8_format.py +52 -7
  18. je_editor/pyside_ui/code/code_process/code_exec.py +118 -64
  19. je_editor/pyside_ui/code/plaintext_code_edit/code_edit_plaintext.py +115 -53
  20. je_editor/pyside_ui/code/running_process_manager.py +18 -0
  21. je_editor/pyside_ui/code/shell_process/shell_exec.py +99 -60
  22. je_editor/pyside_ui/code/syntax/python_syntax.py +44 -9
  23. je_editor/pyside_ui/code/syntax/syntax_setting.py +39 -11
  24. je_editor/pyside_ui/code/textedit_code_result/code_record.py +33 -11
  25. je_editor/pyside_ui/code/variable_inspector/__init__.py +0 -0
  26. je_editor/pyside_ui/code/variable_inspector/inspector_gui.py +172 -0
  27. je_editor/pyside_ui/dialog/ai_dialog/__init__.py +0 -0
  28. je_editor/pyside_ui/dialog/ai_dialog/set_ai_dialog.py +71 -0
  29. je_editor/pyside_ui/dialog/file_dialog/create_file_dialog.py +38 -4
  30. je_editor/pyside_ui/dialog/file_dialog/open_file_dialog.py +32 -4
  31. je_editor/pyside_ui/dialog/file_dialog/save_file_dialog.py +25 -2
  32. je_editor/pyside_ui/dialog/search_ui/search_error_box.py +27 -2
  33. je_editor/pyside_ui/dialog/search_ui/search_text_box.py +28 -3
  34. je_editor/pyside_ui/git_ui/__init__.py +0 -0
  35. je_editor/pyside_ui/git_ui/code_diff_compare/__init__.py +0 -0
  36. je_editor/pyside_ui/git_ui/code_diff_compare/code_diff_viewer_widget.py +90 -0
  37. je_editor/pyside_ui/git_ui/code_diff_compare/line_number_code_viewer.py +141 -0
  38. je_editor/pyside_ui/git_ui/code_diff_compare/multi_file_diff_viewer.py +88 -0
  39. je_editor/pyside_ui/git_ui/code_diff_compare/side_by_side_diff_widget.py +284 -0
  40. je_editor/pyside_ui/git_ui/git_client/__init__.py +0 -0
  41. je_editor/pyside_ui/git_ui/git_client/commit_table.py +65 -0
  42. je_editor/pyside_ui/git_ui/git_client/git_branch_tree_widget.py +156 -0
  43. je_editor/pyside_ui/git_ui/git_client/git_client_gui.py +799 -0
  44. je_editor/pyside_ui/git_ui/git_client/graph_view.py +218 -0
  45. je_editor/pyside_ui/main_ui/ai_widget/__init__.py +0 -0
  46. je_editor/pyside_ui/main_ui/ai_widget/ai_config.py +34 -0
  47. je_editor/pyside_ui/main_ui/ai_widget/ask_thread.py +36 -0
  48. je_editor/pyside_ui/main_ui/ai_widget/chat_ui.py +147 -0
  49. je_editor/pyside_ui/main_ui/ai_widget/langchain_interface.py +84 -0
  50. je_editor/pyside_ui/main_ui/console_widget/__init__.py +0 -0
  51. je_editor/pyside_ui/main_ui/console_widget/console_gui.py +162 -0
  52. je_editor/pyside_ui/main_ui/console_widget/qprocess_adapter.py +84 -0
  53. je_editor/pyside_ui/main_ui/dock/destroy_dock.py +32 -1
  54. je_editor/pyside_ui/main_ui/editor/editor_widget.py +113 -23
  55. je_editor/pyside_ui/main_ui/editor/editor_widget_dock.py +33 -6
  56. je_editor/pyside_ui/main_ui/editor/process_input.py +42 -10
  57. je_editor/pyside_ui/main_ui/ipython_widget/rich_jupyter.py +45 -10
  58. je_editor/pyside_ui/main_ui/main_editor.py +189 -49
  59. je_editor/pyside_ui/main_ui/menu/check_style_menu/build_check_style_menu.py +50 -27
  60. je_editor/pyside_ui/main_ui/menu/dock_menu/build_dock_menu.py +141 -30
  61. je_editor/pyside_ui/main_ui/menu/file_menu/build_file_menu.py +67 -17
  62. je_editor/pyside_ui/main_ui/menu/help_menu/build_help_menu.py +33 -3
  63. je_editor/pyside_ui/main_ui/menu/language_menu/build_language_server.py +39 -0
  64. je_editor/pyside_ui/main_ui/menu/python_env_menu/build_venv_menu.py +102 -40
  65. je_editor/pyside_ui/main_ui/menu/run_menu/build_run_menu.py +53 -6
  66. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_debug_menu.py +47 -3
  67. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_program_menu.py +45 -5
  68. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_shell_menu.py +41 -3
  69. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/utils.py +21 -0
  70. je_editor/pyside_ui/main_ui/menu/set_menu_bar.py +37 -11
  71. je_editor/pyside_ui/main_ui/menu/style_menu/build_style_menu.py +42 -6
  72. je_editor/pyside_ui/main_ui/menu/tab_menu/build_tab_menu.py +202 -27
  73. je_editor/pyside_ui/main_ui/menu/text_menu/build_text_menu.py +66 -0
  74. je_editor/pyside_ui/main_ui/save_settings/setting_utils.py +18 -1
  75. je_editor/pyside_ui/main_ui/save_settings/user_color_setting_file.py +32 -2
  76. je_editor/pyside_ui/main_ui/save_settings/user_setting_file.py +37 -10
  77. je_editor/pyside_ui/main_ui/system_tray/extend_system_tray.py +39 -0
  78. je_editor/start_editor.py +25 -0
  79. je_editor/utils/encodings/python_encodings.py +100 -97
  80. je_editor/utils/exception/exception_tags.py +11 -11
  81. je_editor/utils/file/open/open_file.py +35 -19
  82. je_editor/utils/file/save/save_file.py +34 -13
  83. je_editor/utils/json/json_file.py +29 -14
  84. je_editor/utils/json_format/json_process.py +32 -1
  85. je_editor/utils/logging/loggin_instance.py +37 -7
  86. je_editor/utils/multi_language/english.py +102 -6
  87. je_editor/utils/multi_language/multi_language_wrapper.py +28 -3
  88. je_editor/utils/multi_language/traditional_chinese.py +101 -10
  89. je_editor/utils/redirect_manager/redirect_manager_class.py +49 -11
  90. je_editor/utils/venv_check/check_venv.py +37 -14
  91. {je_editor-0.0.202.dist-info → je_editor-0.0.228.dist-info}/METADATA +12 -6
  92. je_editor-0.0.228.dist-info/RECORD +140 -0
  93. {je_editor-0.0.202.dist-info → je_editor-0.0.228.dist-info}/WHEEL +1 -1
  94. je_editor-0.0.202.dist-info/RECORD +0 -108
  95. {je_editor-0.0.202.dist-info → je_editor-0.0.228.dist-info/licenses}/LICENSE +0 -0
  96. {je_editor-0.0.202.dist-info → je_editor-0.0.228.dist-info}/top_level.txt +0 -0
@@ -4,51 +4,86 @@ from typing import TYPE_CHECKING
4
4
 
5
5
  from frontengine import FrontEngineMainUI
6
6
 
7
- from je_editor.pyside_ui.browser.browser_widget import BrowserWidget
7
+ from je_editor.pyside_ui.browser.main_browser_widget import MainBrowserWidget
8
+ from je_editor.pyside_ui.code.variable_inspector.inspector_gui import VariableInspector
9
+ # 匯入各種 UI 元件 (編輯器、瀏覽器、Git、變數檢查器、聊天、控制台、IPython、程式碼比對)
10
+ # Import various UI components (editor, browser, Git, variable inspector, chat, console, IPython, code diff)
11
+ from je_editor.pyside_ui.git_ui.code_diff_compare.code_diff_viewer_widget import DiffViewerWidget
12
+ from je_editor.pyside_ui.git_ui.git_client.git_branch_tree_widget import GitTreeViewGUI
13
+ from je_editor.pyside_ui.git_ui.git_client.git_client_gui import GitGui
14
+ from je_editor.pyside_ui.main_ui.ai_widget.chat_ui import ChatUI
15
+ from je_editor.pyside_ui.main_ui.console_widget.console_gui import ConsoleWidget
8
16
  from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
9
17
  from je_editor.pyside_ui.main_ui.ipython_widget.rich_jupyter import IpythonWidget
10
18
  from je_editor.utils.logging.loggin_instance import jeditor_logger
11
19
 
20
+ # 啟用未來的註解功能,允許在型別提示中使用字串形式的前向參照
21
+ # Enable future annotations, allowing forward references in type hints
22
+ # TYPE_CHECKING 用於避免在型別檢查時引入不必要的模組
23
+ # TYPE_CHECKING is used to avoid unnecessary imports during type checking
24
+ # 匯入 FrontEngine 主 UI
25
+ # Import the FrontEngine main UI
26
+ # 匯入日誌工具,用於記錄操作
27
+ # Import logger for recording operations
28
+
12
29
  if TYPE_CHECKING:
13
30
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
31
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
32
+ # Import EditorMain only for type checking to avoid circular imports
33
+
14
34
  from PySide6.QtGui import QAction
35
+ # 匯入 QAction,用於建立選單動作
36
+ # Import QAction for creating menu actions
37
+
15
38
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
16
39
 
17
40
 
41
+ # 匯入多語言包裝器,用於支援多語系 UI
42
+ # Import language wrapper for multilingual UI support
43
+
44
+
18
45
  def set_tab_menu(ui_we_want_to_set: EditorMain) -> None:
46
+ """
47
+ 設定主編輯器的分頁選單
48
+ Set up the tab menu for the main editor
49
+ """
19
50
  jeditor_logger.info(f"build_tab_menu.py set_tab_menu ui_we_want_to_set:{ui_we_want_to_set}")
20
- # Editor
51
+
52
+ # 建立 Tab 選單 (主容器)
53
+ # Create the Tab menu (main container)
21
54
  ui_we_want_to_set.tab_menu = ui_we_want_to_set.menu.addMenu(
22
55
  language_wrapper.language_word_dict.get("tab_menu_label")
23
56
  )
57
+
58
+ # === Editor 分頁 ===
59
+ # === Editor Tab ===
24
60
  ui_we_want_to_set.tab_menu.add_editor_action = QAction(
25
61
  language_wrapper.language_word_dict.get("tab_menu_add_editor_label"))
26
62
  ui_we_want_to_set.tab_menu.add_editor_action.triggered.connect(
27
63
  lambda: add_editor_tab(ui_we_want_to_set)
28
64
  )
29
- # Front Engine
30
65
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_editor_action)
66
+
67
+ # === Front Engine 分頁 ===
68
+ # === Front Engine Tab ===
31
69
  ui_we_want_to_set.tab_menu.add_frontengine_action = QAction(
32
70
  language_wrapper.language_word_dict.get("tab_menu_add_frontengine_label"))
33
71
  ui_we_want_to_set.tab_menu.add_frontengine_action.triggered.connect(
34
72
  lambda: add_frontengine_tab(ui_we_want_to_set)
35
73
  )
36
- # Web
37
74
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_frontengine_action)
75
+
76
+ # === Web 瀏覽器分頁 ===
77
+ # === Web Browser Tab ===
38
78
  ui_we_want_to_set.tab_menu.add_web_action = QAction(
39
79
  language_wrapper.language_word_dict.get("tab_menu_add_web_label"))
40
80
  ui_we_want_to_set.tab_menu.add_web_action.triggered.connect(
41
81
  lambda: add_web_tab(ui_we_want_to_set)
42
82
  )
43
83
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_web_action)
44
- # Stackoverflow
45
- ui_we_want_to_set.tab_menu.add_stackoverflow_action = QAction(
46
- language_wrapper.language_word_dict.get("tab_menu_add_stackoverflow_label"))
47
- ui_we_want_to_set.tab_menu.add_stackoverflow_action.triggered.connect(
48
- lambda: add_stackoverflow_tab(ui_we_want_to_set)
49
- )
50
- ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_stackoverflow_action)
51
- # IPython
84
+
85
+ # === IPython 分頁 ===
86
+ # === IPython Tab ===
52
87
  ui_we_want_to_set.tab_menu.add_ipython_action = QAction(
53
88
  language_wrapper.language_word_dict.get("tab_menu_ipython_tab_name"))
54
89
  ui_we_want_to_set.tab_menu.add_ipython_action.triggered.connect(
@@ -56,9 +91,68 @@ def set_tab_menu(ui_we_want_to_set: EditorMain) -> None:
56
91
  )
57
92
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_ipython_action)
58
93
 
94
+ # === Chat UI 分頁 ===
95
+ # === Chat UI Tab ===
96
+ ui_we_want_to_set.tab_menu.add_chat_ui_action = QAction(
97
+ language_wrapper.language_word_dict.get("tab_menu_chat_ui_tab_name"))
98
+ ui_we_want_to_set.tab_menu.add_chat_ui_action.triggered.connect(
99
+ lambda: add_chat_ui_tab(ui_we_want_to_set)
100
+ )
101
+ ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_chat_ui_action)
102
+
103
+ # === Git Client 分頁 ===
104
+ # === Git Client Tab ===
105
+ ui_we_want_to_set.tab_menu.add_git_client_ui_action = QAction(
106
+ language_wrapper.language_word_dict.get("tab_menu_git_client_tab_name"))
107
+ ui_we_want_to_set.tab_menu.add_git_client_ui_action.triggered.connect(
108
+ lambda: add_git_client_tab(ui_we_want_to_set)
109
+ )
110
+ ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_git_client_ui_action)
111
+
112
+ # === Git Branch Tree 分頁 ===
113
+ # === Git Branch Tree Tab ===
114
+ ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action = QAction(
115
+ language_wrapper.language_word_dict.get("tab_menu_git_branch_tree_view_tab_name"))
116
+ ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action.triggered.connect(
117
+ lambda: add_git_tree_view_tab(ui_we_want_to_set)
118
+ )
119
+ ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action)
120
+
121
+ # === Variable Inspector 分頁 ===
122
+ # === Variable Inspector Tab ===
123
+ ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action = QAction(
124
+ language_wrapper.language_word_dict.get("tab_menu_variable_inspector_tab_name"))
125
+ ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action.triggered.connect(
126
+ lambda: add_variable_inspector_tab(ui_we_want_to_set)
127
+ )
128
+ ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action)
129
+
130
+ # === Console 分頁 ===
131
+ # === Console Tab ===
132
+ ui_we_want_to_set.tab_menu.add_console_widget_ui_action = QAction(
133
+ language_wrapper.language_word_dict.get("tab_menu_console_widget_tab_name"))
134
+ ui_we_want_to_set.tab_menu.add_console_widget_ui_action.triggered.connect(
135
+ lambda: add_console_widget_tab(ui_we_want_to_set)
136
+ )
137
+ ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_console_widget_ui_action)
138
+
139
+ # === Code Diff Viewer 分頁 ===
140
+ # === Code Diff Viewer Tab ===
141
+ ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action = QAction(
142
+ language_wrapper.language_word_dict.get("tab_code_diff_viewer_tab_name"))
143
+ ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action.triggered.connect(
144
+ lambda: add_code_diff_compare_tab(ui_we_want_to_set)
145
+ )
146
+ ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action)
147
+
148
+
149
+ # === 以下為各分頁新增函式 ===
150
+ # === Functions to add each tab ===
59
151
 
60
152
  def add_editor_tab(ui_we_want_to_set: EditorMain):
61
- jeditor_logger.info(f"build_tab_menu.py add_editor_tab ui_we_want_to_set: {ui_we_want_to_set}")
153
+ # 新增 Editor 分頁
154
+ # Add Editor tab
155
+ jeditor_logger.info(f"build_tab_menu.py add editor tab ui_we_want_to_set: {ui_we_want_to_set}")
62
156
  widget = EditorWidget(ui_we_want_to_set)
63
157
  ui_we_want_to_set.tab_widget.addTab(
64
158
  widget,
@@ -68,7 +162,9 @@ def add_editor_tab(ui_we_want_to_set: EditorMain):
68
162
 
69
163
 
70
164
  def add_frontengine_tab(ui_we_want_to_set: EditorMain):
71
- jeditor_logger.info(f"build_tab_menu.py add_frontengine_tab ui_we_want_to_set: {ui_we_want_to_set}")
165
+ # 新增 FrontEngine 分頁
166
+ # Add FrontEngine tab
167
+ jeditor_logger.info(f"build_tab_menu.py add frontengine tab ui_we_want_to_set: {ui_we_want_to_set}")
72
168
  ui_we_want_to_set.tab_widget.addTab(
73
169
  FrontEngineMainUI(show_system_tray_ray=False, redirect_output=False),
74
170
  f"{language_wrapper.language_word_dict.get('tab_menu_frontengine_tab_name')} "
@@ -76,25 +172,104 @@ def add_frontengine_tab(ui_we_want_to_set: EditorMain):
76
172
 
77
173
 
78
174
  def add_web_tab(ui_we_want_to_set: EditorMain):
79
- jeditor_logger.info(f"build_tab_menu.py add_web_tab ui_we_want_to_set: {ui_we_want_to_set}")
175
+ # 紀錄日誌:新增 Web 分頁
176
+ # Log: add a Web tab
177
+ jeditor_logger.info(f"build_tab_menu.py add web tab ui_we_want_to_set: {ui_we_want_to_set}")
178
+ # 在主編輯器的 tab_widget 中新增一個瀏覽器分頁
179
+ # Add a browser tab into the main editor's tab_widget
80
180
  ui_we_want_to_set.tab_widget.addTab(
81
- BrowserWidget(),
181
+ MainBrowserWidget(), # 建立瀏覽器元件 / Create browser widget
82
182
  f"{language_wrapper.language_word_dict.get('tab_menu_web_tab_name')} "
83
- f"{ui_we_want_to_set.tab_widget.count()}")
183
+ f"{ui_we_want_to_set.tab_widget.count()}" # 分頁名稱包含序號 / Tab name with index
184
+ )
185
+
84
186
 
187
+ def add_ipython_tab(ui_we_want_to_set: EditorMain):
188
+ # 紀錄日誌:新增 IPython 分頁
189
+ # Log: add an IPython tab
190
+ jeditor_logger.info(f"build_tab_menu.py add ipython tab ui_we_want_to_set: {ui_we_want_to_set}")
191
+ # 在主編輯器中新增 IPython 互動式分頁
192
+ # Add an IPython interactive tab
193
+ ui_we_want_to_set.tab_widget.addTab(
194
+ IpythonWidget(ui_we_want_to_set), # 建立 IPython 元件 / Create IPython widget
195
+ f"{language_wrapper.language_word_dict.get('tab_menu_ipython_tab_name')} "
196
+ f"{ui_we_want_to_set.tab_widget.count()}"
197
+ )
85
198
 
86
- def add_stackoverflow_tab(ui_we_want_to_set: EditorMain):
87
- jeditor_logger.info(f"build_tab_menu.py add_stackoverflow_tab ui_we_want_to_set: {ui_we_want_to_set}")
199
+
200
+ def add_chat_ui_tab(ui_we_want_to_set: EditorMain):
201
+ # 紀錄日誌:新增 Chat UI 分頁
202
+ # Log: add a Chat UI tab
203
+ jeditor_logger.info(f"build_tab_menu.py add chat_ui tab ui_we_want_to_set: {ui_we_want_to_set}")
204
+ # 在主編輯器中新增聊天分頁
205
+ # Add a chat tab into the main editor
88
206
  ui_we_want_to_set.tab_widget.addTab(
89
- BrowserWidget(start_url="https://stackoverflow.com/", search_prefix="https://stackoverflow.com/search?q="),
90
- f"{language_wrapper.language_word_dict.get('tab_menu_stackoverflow_tab_name')} "
91
- f"{ui_we_want_to_set.tab_widget.count()}")
207
+ ChatUI(ui_we_want_to_set), # 建立聊天元件 / Create Chat UI widget
208
+ f"{language_wrapper.language_word_dict.get('tab_menu_chat_ui_tab_name')} "
209
+ f"{ui_we_want_to_set.tab_widget.count()}"
210
+ )
92
211
 
93
212
 
94
- def add_ipython_tab(ui_we_want_to_set: EditorMain):
95
- jeditor_logger.info(f"build_tab_menu.py add_ipython_tab ui_we_want_to_set: {ui_we_want_to_set}")
213
+ def add_git_client_tab(ui_we_want_to_set: EditorMain):
214
+ # 紀錄日誌:新增 Git Client 分頁
215
+ # Log: add a Git Client tab
216
+ jeditor_logger.info(f"build_tab_menu.py add git client tab ui_we_want_to_set: {ui_we_want_to_set}")
217
+ # 在主編輯器中新增 Git 客戶端分頁
218
+ # Add a Git client tab
96
219
  ui_we_want_to_set.tab_widget.addTab(
97
- IpythonWidget(ui_we_want_to_set),
98
- f"{language_wrapper.language_word_dict.get('tab_menu_ipython_tab_name')} "
99
- f"{ui_we_want_to_set.tab_widget.count()}")
220
+ GitGui(), # 建立 Git GUI 元件 / Create Git GUI widget
221
+ f"{language_wrapper.language_word_dict.get('tab_menu_git_client_tab_name')} "
222
+ f"{ui_we_want_to_set.tab_widget.count()}"
223
+ )
224
+
225
+
226
+ def add_git_tree_view_tab(ui_we_want_to_set: EditorMain):
227
+ # 紀錄日誌:新增 Git Branch Tree 分頁
228
+ # Log: add a Git Branch Tree tab
229
+ jeditor_logger.info(f"build_tab_menu.py add git tree view tab ui_we_want_to_set: {ui_we_want_to_set}")
230
+ # 在主編輯器中新增 Git 分支樹狀圖分頁
231
+ # Add a Git branch tree view tab
232
+ ui_we_want_to_set.tab_widget.addTab(
233
+ GitTreeViewGUI(), # 建立 Git Tree View 元件 / Create Git Tree View widget
234
+ f"{language_wrapper.language_word_dict.get('tab_menu_git_branch_tree_view_tab_name')} "
235
+ f"{ui_we_want_to_set.tab_widget.count()}"
236
+ )
237
+
238
+
239
+ def add_variable_inspector_tab(ui_we_want_to_set: EditorMain):
240
+ # 紀錄日誌:新增 Variable Inspector 分頁
241
+ # Log: add a Variable Inspector tab
242
+ jeditor_logger.info(f"build_tab_menu.py add variable inspector tab ui_we_want_to_set: {ui_we_want_to_set}")
243
+ # 在主編輯器中新增變數檢查器分頁
244
+ # Add a variable inspector tab
245
+ ui_we_want_to_set.tab_widget.addTab(
246
+ VariableInspector(), # 建立變數檢查器元件 / Create Variable Inspector widget
247
+ f"{language_wrapper.language_word_dict.get('tab_menu_variable_inspector_tab_name')} "
248
+ f"{ui_we_want_to_set.tab_widget.count()}"
249
+ )
250
+
100
251
 
252
+ def add_console_widget_tab(ui_we_want_to_set: EditorMain):
253
+ # 紀錄日誌:新增 Console 分頁
254
+ # Log: add a Console tab
255
+ jeditor_logger.info(f"build_tab_menu.py add console widget tab ui_we_want_to_set: {ui_we_want_to_set}")
256
+ # 在主編輯器中新增動態控制台分頁
257
+ # Add a dynamic console tab
258
+ ui_we_want_to_set.tab_widget.addTab(
259
+ ConsoleWidget(), # 建立控制台元件 / Create Console widget
260
+ f"{language_wrapper.language_word_dict.get('tab_menu_console_widget_tab_name')} "
261
+ f"{ui_we_want_to_set.tab_widget.count()}"
262
+ )
263
+
264
+
265
+ def add_code_diff_compare_tab(ui_we_want_to_set: EditorMain):
266
+ # 紀錄日誌:新增 Code Diff Compare 分頁
267
+ # Log: add a Code Diff Compare tab
268
+ jeditor_logger.info(f"build_tab_menu.py add code diff compare tab ui_we_want_to_set: {ui_we_want_to_set}")
269
+ # 在主編輯器中新增程式碼差異比較分頁
270
+ # Add a code diff comparison tab
271
+ ui_we_want_to_set.tab_widget.addTab(
272
+ DiffViewerWidget(), # 建立程式碼比對元件 / Create Code Diff Viewer widget
273
+ f"{language_wrapper.language_word_dict.get('tab_code_diff_viewer_tab_name')} "
274
+ f"{ui_we_want_to_set.tab_widget.count()}"
275
+ )
@@ -8,24 +8,64 @@ from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
8
8
  from je_editor.pyside_ui.main_ui.save_settings.user_setting_file import user_setting_dict
9
9
  from je_editor.utils.logging.loggin_instance import jeditor_logger
10
10
 
11
+ # 啟用未來註解功能,允許型別提示使用字串前向參照
12
+ # Enable future annotations, allowing forward references in type hints
13
+ # TYPE_CHECKING 用於避免在執行時載入不必要的模組
14
+ # TYPE_CHECKING prevents unnecessary imports at runtime
15
+ # 匯入 QAction,用於建立選單動作
16
+ # Import QAction for creating menu actions
17
+ # 匯入編輯器元件
18
+ # Import the Editor widget
19
+ # 匯入使用者設定字典,用於儲存字型與字體大小
20
+ # Import user setting dictionary to save font and size
21
+
22
+ # 匯入日誌工具
23
+ # Import logger
24
+
11
25
  if TYPE_CHECKING:
12
26
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
27
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
28
+ # Import EditorMain only for type checking
29
+
13
30
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
14
31
 
15
32
 
33
+ # 匯入多語言包裝器,用於多語系 UI
34
+ # Import language wrapper for multilingual UI
35
+
36
+
16
37
  def set_text_menu(ui_we_want_to_set: EditorMain):
38
+ """
39
+ 建立文字選單,包含字型與字體大小的子選單
40
+ Create the text menu, including font and font size submenus
41
+ """
17
42
  jeditor_logger.info(f"build_text_menu.py set_text_menu ui_we_want_to_set: {ui_we_want_to_set}")
43
+
44
+ # 建立 Text Menu
45
+ # Create Text Menu
18
46
  ui_we_want_to_set.text_menu = ui_we_want_to_set.menu.addMenu(
19
47
  language_wrapper.language_word_dict.get("text_menu_label"))
48
+
49
+ # === 字型選單 (Font Menu) ===
50
+ # === Font Menu ===
20
51
  ui_we_want_to_set.text_menu.font_menu = ui_we_want_to_set.text_menu.addMenu(
21
52
  language_wrapper.language_word_dict.get("text_menu_label_font"))
53
+
54
+ # 將系統支援的字型加入選單
55
+ # Add available system fonts into the menu
22
56
  for family in ui_we_want_to_set.font_database.families():
23
57
  font_action = QAction(family, parent=ui_we_want_to_set.text_menu.font_menu)
24
58
  font_action.triggered.connect(
25
59
  lambda checked=False, action=font_action: set_font(ui_we_want_to_set, action))
26
60
  ui_we_want_to_set.text_menu.font_menu.addAction(font_action)
61
+
62
+ # === 字體大小選單 (Font Size Menu) ===
63
+ # === Font Size Menu ===
27
64
  ui_we_want_to_set.text_menu.font_size_menu = ui_we_want_to_set.text_menu.addMenu(
28
65
  language_wrapper.language_word_dict.get("text_menu_label_font_size"))
66
+
67
+ # 提供 12 ~ 36 pt 的字體大小選項 (每次增加 2)
68
+ # Provide font sizes from 12 to 36 pt (step = 2)
29
69
  for size in range(12, 38, 2):
30
70
  font_action = QAction(str(size), parent=ui_we_want_to_set.text_menu.font_size_menu)
31
71
  font_action.triggered.connect(
@@ -34,36 +74,62 @@ def set_text_menu(ui_we_want_to_set: EditorMain):
34
74
 
35
75
 
36
76
  def set_font(ui_we_want_to_set: EditorMain, action: QAction) -> None:
77
+ """
78
+ 設定編輯器的字型
79
+ Set the font family for the editor
80
+ """
37
81
  jeditor_logger.info("build_text_menu.py set_font "
38
82
  f"ui_we_want_to_set: {ui_we_want_to_set} "
39
83
  f"action: {action}")
84
+
85
+ # 遍歷所有分頁,找到 EditorWidget 並套用字型
86
+ # Iterate through all tabs, apply font to EditorWidget
40
87
  for code_editor in range(ui_we_want_to_set.tab_widget.count()):
41
88
  widget = ui_we_want_to_set.tab_widget.widget(code_editor)
42
89
  if isinstance(widget, EditorWidget):
90
+ # 設定程式碼編輯區字型
91
+ # Set font for code editor
43
92
  widget.code_edit.setStyleSheet(
44
93
  f"font-size: {widget.code_edit.font().pointSize()}pt;"
45
94
  f"font-family: {action.text()};"
46
95
  )
96
+ # 設定輸出結果區字型
97
+ # Set font for result display
47
98
  widget.code_result.setStyleSheet(
48
99
  f"font-size: {widget.code_result.font().pointSize()}pt;"
49
100
  f"font-family: {action.text()};"
50
101
  )
102
+ # 更新使用者設定
103
+ # Update user settings
51
104
  user_setting_dict.update({"font": action.text()})
52
105
 
53
106
 
54
107
  def set_font_size(ui_we_want_to_set: EditorMain, action: QAction) -> None:
108
+ """
109
+ 設定編輯器的字體大小
110
+ Set the font size for the editor
111
+ """
55
112
  jeditor_logger.info("build_text_menu.py set_font_size "
56
113
  f"ui_we_want_to_set: {ui_we_want_to_set} "
57
114
  f"action: {action}")
115
+
116
+ # 遍歷所有分頁,找到 EditorWidget 並套用字體大小
117
+ # Iterate through all tabs, apply font size to EditorWidget
58
118
  for code_editor in range(ui_we_want_to_set.tab_widget.count()):
59
119
  widget = ui_we_want_to_set.tab_widget.widget(code_editor)
60
120
  if type(widget) is EditorWidget:
121
+ # 設定程式碼編輯區字體大小
122
+ # Set font size for code editor
61
123
  widget.code_edit.setStyleSheet(
62
124
  f"font-size: {int(action.text())}pt;"
63
125
  f"font-family: {widget.code_edit.font().family()};"
64
126
  )
127
+ # 設定輸出結果區字體大小
128
+ # Set font size for result display
65
129
  widget.code_result.setStyleSheet(
66
130
  f"font-size: {int(action.text())}pt;"
67
131
  f"font-family: {widget.code_result.font().family()};"
68
132
  )
133
+ # 更新使用者設定
134
+ # Update user settings
69
135
  user_setting_dict.update({"font_size": int(action.text())})
@@ -6,11 +6,28 @@ from je_editor.utils.logging.loggin_instance import jeditor_logger
6
6
 
7
7
 
8
8
  def write_setting(save_dict: dict, file_name: str) -> None:
9
+ """
10
+ 將設定資料寫入 JSON 檔案
11
+ Write settings dictionary into a JSON file
12
+ """
13
+ # 紀錄日誌,方便除錯與追蹤
14
+ # Log the action for debugging and tracking
9
15
  jeditor_logger.info("setting_utils.py write_setting "
10
16
  f"save_dict: {save_dict} "
11
17
  f"file_name: {file_name}")
18
+
19
+ # 建立儲存設定的資料夾路徑:當前工作目錄下的 `.jeditor`
20
+ # Create the save directory path: `.jeditor` under current working directory
12
21
  save_dir = Path(getcwd() + "/.jeditor")
22
+
23
+ # 如果資料夾不存在就自動建立 (parents=True 表示可遞迴建立多層資料夾)
24
+ # Create the directory if it does not exist (parents=True allows nested dirs)
13
25
  save_dir.mkdir(parents=True, exist_ok=True)
26
+
27
+ # 建立完整的檔案路徑,例如 `.jeditor/settings.json`
28
+ # Create the full file path, e.g., `.jeditor/settings.json`
14
29
  save_file = Path(getcwd() + f"/.jeditor/{file_name}")
15
- write_json(str(save_file), save_dict)
16
30
 
31
+ # 將設定字典寫入 JSON 檔案
32
+ # Write the dictionary into the JSON file
33
+ write_json(str(save_file), save_dict)
@@ -10,34 +10,47 @@ from je_editor.utils.logging.loggin_instance import jeditor_logger
10
10
 
11
11
 
12
12
  def update_actually_color_dict():
13
+ """
14
+ 更新實際使用的顏色字典 (actually_color_dict),
15
+ 將 user_setting_color_dict 中的 RGB 值轉換成 QColor 物件。
16
+ Update the actual color dictionary (actually_color_dict),
17
+ converting RGB values from user_setting_color_dict into QColor objects.
18
+ """
13
19
  jeditor_logger.info(f"user_color_setting_file.py update_actually_color_dict")
20
+
14
21
  actually_color_dict.update(
15
22
  {
23
+ # 行號顏色 / Line number color
16
24
  "line_number_color": QColor(
17
25
  user_setting_color_dict.get("line_number_color")[0],
18
26
  user_setting_color_dict.get("line_number_color")[1],
19
27
  user_setting_color_dict.get("line_number_color")[2],
20
28
  ),
29
+ # 行號背景顏色 / Line number background color
21
30
  "line_number_background_color": QColor(
22
31
  user_setting_color_dict.get("line_number_background_color")[0],
23
32
  user_setting_color_dict.get("line_number_background_color")[1],
24
33
  user_setting_color_dict.get("line_number_background_color")[2],
25
34
  ),
35
+ # 當前行顏色 / Current line highlight color
26
36
  "current_line_color": QColor(
27
37
  user_setting_color_dict.get("current_line_color")[0],
28
38
  user_setting_color_dict.get("current_line_color")[1],
29
39
  user_setting_color_dict.get("current_line_color")[2],
30
40
  ),
41
+ # 一般輸出顏色 / Normal output color
31
42
  "normal_output_color": QColor(
32
43
  user_setting_color_dict.get("normal_output_color")[0],
33
44
  user_setting_color_dict.get("normal_output_color")[1],
34
45
  user_setting_color_dict.get("normal_output_color")[2],
35
46
  ),
47
+ # 錯誤輸出顏色 / Error output color
36
48
  "error_output_color": QColor(
37
49
  user_setting_color_dict.get("error_output_color")[0],
38
50
  user_setting_color_dict.get("error_output_color")[1],
39
51
  user_setting_color_dict.get("error_output_color")[2],
40
52
  ),
53
+ # 警告輸出顏色 / Warning output color
41
54
  "warning_output_color": QColor(
42
55
  user_setting_color_dict.get("warning_output_color")[0],
43
56
  user_setting_color_dict.get("warning_output_color")[1],
@@ -47,6 +60,8 @@ def update_actually_color_dict():
47
60
  )
48
61
 
49
62
 
63
+ # 使用者設定的顏色字典 (以 RGB list 表示)
64
+ # User-defined color dictionary (stored as RGB lists)
50
65
  user_setting_color_dict: Dict[str, list] = {
51
66
  "line_number_color": [255, 255, 255],
52
67
  "line_number_background_color": [179, 179, 179],
@@ -56,18 +71,33 @@ user_setting_color_dict: Dict[str, list] = {
56
71
  "warning_output_color": [204, 204, 0]
57
72
  }
58
73
 
59
- actually_color_dict: Dict[str, QColor] = {
60
- }
74
+ # 實際使用的顏色字典 (以 QColor 表示)
75
+ # Actual color dictionary (stored as QColor objects)
76
+ actually_color_dict: Dict[str, QColor] = {}
77
+
78
+ # 初始化時先更新一次
79
+ # Update once at initialization
61
80
  update_actually_color_dict()
62
81
 
63
82
 
64
83
  def write_user_color_setting() -> None:
84
+ """
85
+ 將使用者顏色設定寫入 JSON 檔案
86
+ Write user color settings into a JSON file
87
+ """
65
88
  jeditor_logger.info("user_color_setting_file.py write_user_color_setting")
66
89
  write_setting(user_setting_color_dict, "user_color_setting.json")
67
90
 
68
91
 
69
92
  def read_user_color_setting() -> None:
93
+ """
94
+ 從 JSON 檔案讀取使用者顏色設定,並更新 user_setting_color_dict
95
+ Read user color settings from JSON file and update user_setting_color_dict
96
+ """
70
97
  jeditor_logger.info("user_color_setting_file.py read_user_color_setting")
71
98
  user_color_setting_file = Path(getcwd() + "/.jeditor/user_color_setting.json")
99
+
100
+ # 如果檔案存在,就讀取並更新設定
101
+ # If the file exists, read and update the settings
72
102
  if user_color_setting_file.exists() and user_color_setting_file.is_file():
73
103
  user_setting_color_dict.update(read_json(str(user_color_setting_file)))
@@ -5,27 +5,54 @@ from je_editor.pyside_ui.main_ui.save_settings.setting_utils import write_settin
5
5
  from je_editor.utils.json.json_file import read_json
6
6
  from je_editor.utils.logging.loggin_instance import jeditor_logger
7
7
 
8
+ # 匯入通用的設定寫入工具
9
+ # Import utility function to write settings
10
+ # 匯入 JSON 讀取工具
11
+ # Import JSON reader utility
12
+
13
+ # 匯入日誌工具
14
+ # Import logger
15
+
16
+
17
+ # 使用者設定字典,包含 UI 與編輯器的偏好
18
+ # User settings dictionary, storing UI and editor preferences
8
19
  user_setting_dict = {
9
- "ui_font": "Lato",
10
- "ui_font_size": 12,
11
- "language": "English",
12
- "ui_style": "dark_amber.xml",
13
- "font": "Lato",
14
- "font_size": 12,
15
- "encoding": "utf-8",
16
- "last_file": None,
17
- "python_compiler": None,
18
- "max_line_of_output": 200000,
20
+ "ui_font": "Lato", # UI 字型 / UI font
21
+ "ui_font_size": 12, # UI 字體大小 / UI font size
22
+ "language": "English", # 語言設定 / Language setting
23
+ "ui_style": "dark_amber.xml", # UI 樣式檔 / UI style file
24
+ "font": "Lato", # 編輯器字型 / Editor font
25
+ "font_size": 12, # 編輯器字體大小 / Editor font size
26
+ "encoding": "utf-8", # 檔案編碼 / File encoding
27
+ "last_file": None, # 上次開啟的檔案 / Last opened file
28
+ "python_compiler": None, # Python 編譯器路徑 / Python compiler path
29
+ "max_line_of_output": 200000, # 最大輸出行數限制 / Max lines of output
19
30
  }
20
31
 
21
32
 
22
33
  def write_user_setting() -> None:
34
+ """
35
+ 將使用者設定寫入 JSON 檔案
36
+ Write user settings into a JSON file
37
+ """
23
38
  jeditor_logger.info("user_setting_file.py write_user_setting")
39
+ # 呼叫通用工具,將 user_setting_dict 寫入 `.jeditor/user_setting.json`
40
+ # Use utility to write user_setting_dict into `.jeditor/user_setting.json`
24
41
  write_setting(user_setting_dict, "user_setting.json")
25
42
 
26
43
 
27
44
  def read_user_setting() -> None:
45
+ """
46
+ 從 JSON 檔案讀取使用者設定,並更新 user_setting_dict
47
+ Read user settings from JSON file and update user_setting_dict
48
+ """
28
49
  jeditor_logger.info("user_setting_file.py read_user_setting")
50
+
51
+ # 設定檔路徑:當前工作目錄下的 `.jeditor/user_setting.json`
52
+ # File path: `.jeditor/user_setting.json` under current working directory
29
53
  user_setting_file = Path(getcwd() + "/.jeditor/user_setting.json")
54
+
55
+ # 如果檔案存在,就讀取並更新設定字典
56
+ # If the file exists, read and update the settings dictionary
30
57
  if user_setting_file.exists() and user_setting_file.is_file():
31
58
  user_setting_dict.update(read_json(str(user_setting_file)))