je-editor 0.0.223__py3-none-any.whl → 0.0.224__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.

Potentially problematic release.


This version of je-editor might be problematic. Click here for more details.

Files changed (71) hide show
  1. je_editor/git_client/commit_graph.py +7 -7
  2. je_editor/git_client/git_action.py +0 -7
  3. je_editor/pyside_ui/browser/browser_widget.py +24 -11
  4. je_editor/pyside_ui/browser/main_browser_widget.py +40 -27
  5. je_editor/pyside_ui/code/auto_save/auto_save_manager.py +34 -2
  6. je_editor/pyside_ui/code/auto_save/auto_save_thread.py +19 -6
  7. je_editor/pyside_ui/code/code_format/pep8_format.py +53 -9
  8. je_editor/pyside_ui/code/code_process/code_exec.py +88 -52
  9. je_editor/pyside_ui/code/plaintext_code_edit/code_edit_plaintext.py +116 -55
  10. je_editor/pyside_ui/code/running_process_manager.py +19 -1
  11. je_editor/pyside_ui/code/shell_process/shell_exec.py +71 -48
  12. je_editor/pyside_ui/code/syntax/python_syntax.py +45 -10
  13. je_editor/pyside_ui/code/syntax/syntax_setting.py +40 -12
  14. je_editor/pyside_ui/code/textedit_code_result/code_record.py +34 -12
  15. je_editor/pyside_ui/code/variable_inspector/inspector_gui.py +53 -6
  16. je_editor/pyside_ui/dialog/ai_dialog/set_ai_dialog.py +30 -3
  17. je_editor/pyside_ui/dialog/file_dialog/create_file_dialog.py +35 -2
  18. je_editor/pyside_ui/dialog/file_dialog/open_file_dialog.py +33 -5
  19. je_editor/pyside_ui/dialog/file_dialog/save_file_dialog.py +25 -3
  20. je_editor/pyside_ui/dialog/search_ui/search_error_box.py +26 -1
  21. je_editor/pyside_ui/dialog/search_ui/search_text_box.py +26 -1
  22. je_editor/pyside_ui/git_ui/code_diff_compare/code_diff_viewer_widget.py +11 -11
  23. je_editor/pyside_ui/git_ui/git_client/commit_table.py +46 -8
  24. je_editor/pyside_ui/git_ui/git_client/git_branch_tree_widget.py +49 -15
  25. je_editor/pyside_ui/git_ui/git_client/graph_view.py +64 -20
  26. je_editor/pyside_ui/main_ui/ai_widget/ai_config.py +20 -5
  27. je_editor/pyside_ui/main_ui/ai_widget/ask_thread.py +20 -1
  28. je_editor/pyside_ui/main_ui/ai_widget/chat_ui.py +56 -41
  29. je_editor/pyside_ui/main_ui/ai_widget/langchain_interface.py +45 -6
  30. je_editor/pyside_ui/main_ui/console_widget/console_gui.py +44 -12
  31. je_editor/pyside_ui/main_ui/console_widget/qprocess_adapter.py +34 -13
  32. je_editor/pyside_ui/main_ui/dock/destroy_dock.py +33 -2
  33. je_editor/pyside_ui/main_ui/editor/editor_widget.py +104 -20
  34. je_editor/pyside_ui/main_ui/editor/editor_widget_dock.py +34 -7
  35. je_editor/pyside_ui/main_ui/editor/process_input.py +38 -11
  36. je_editor/pyside_ui/main_ui/ipython_widget/rich_jupyter.py +46 -11
  37. je_editor/pyside_ui/main_ui/main_editor.py +175 -37
  38. je_editor/pyside_ui/main_ui/menu/check_style_menu/build_check_style_menu.py +51 -28
  39. je_editor/pyside_ui/main_ui/menu/dock_menu/build_dock_menu.py +80 -22
  40. je_editor/pyside_ui/main_ui/menu/file_menu/build_file_menu.py +70 -17
  41. je_editor/pyside_ui/main_ui/menu/help_menu/build_help_menu.py +34 -3
  42. je_editor/pyside_ui/main_ui/menu/language_menu/build_language_server.py +41 -1
  43. je_editor/pyside_ui/main_ui/menu/python_env_menu/build_venv_menu.py +100 -42
  44. je_editor/pyside_ui/main_ui/menu/run_menu/build_run_menu.py +57 -7
  45. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_debug_menu.py +50 -4
  46. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_program_menu.py +52 -6
  47. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_shell_menu.py +44 -4
  48. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/utils.py +23 -1
  49. je_editor/pyside_ui/main_ui/menu/set_menu_bar.py +37 -12
  50. je_editor/pyside_ui/main_ui/menu/style_menu/build_style_menu.py +44 -7
  51. je_editor/pyside_ui/main_ui/menu/tab_menu/build_tab_menu.py +126 -28
  52. je_editor/pyside_ui/main_ui/menu/text_menu/build_text_menu.py +65 -1
  53. je_editor/pyside_ui/main_ui/save_settings/setting_utils.py +18 -1
  54. je_editor/pyside_ui/main_ui/save_settings/user_color_setting_file.py +33 -3
  55. je_editor/pyside_ui/main_ui/save_settings/user_setting_file.py +38 -11
  56. je_editor/pyside_ui/main_ui/system_tray/extend_system_tray.py +39 -2
  57. je_editor/start_editor.py +26 -1
  58. je_editor/utils/encodings/python_encodings.py +101 -98
  59. je_editor/utils/file/open/open_file.py +36 -19
  60. je_editor/utils/file/save/save_file.py +35 -14
  61. je_editor/utils/json/json_file.py +29 -14
  62. je_editor/utils/json_format/json_process.py +33 -2
  63. je_editor/utils/logging/loggin_instance.py +38 -8
  64. je_editor/utils/multi_language/multi_language_wrapper.py +29 -4
  65. je_editor/utils/redirect_manager/redirect_manager_class.py +49 -11
  66. je_editor/utils/venv_check/check_venv.py +45 -15
  67. {je_editor-0.0.223.dist-info → je_editor-0.0.224.dist-info}/METADATA +1 -1
  68. {je_editor-0.0.223.dist-info → je_editor-0.0.224.dist-info}/RECORD +71 -71
  69. {je_editor-0.0.223.dist-info → je_editor-0.0.224.dist-info}/WHEEL +0 -0
  70. {je_editor-0.0.223.dist-info → je_editor-0.0.224.dist-info}/licenses/LICENSE +0 -0
  71. {je_editor-0.0.223.dist-info → je_editor-0.0.224.dist-info}/top_level.txt +0 -0
@@ -4,9 +4,11 @@ from typing import TYPE_CHECKING
4
4
 
5
5
  from frontengine import FrontEngineMainUI
6
6
 
7
- from je_editor.pyside_ui.git_ui.code_diff_compare.code_diff_viewer_widget import DiffViewerWidget
8
7
  from je_editor.pyside_ui.browser.main_browser_widget import MainBrowserWidget
9
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
10
12
  from je_editor.pyside_ui.git_ui.git_client.git_branch_tree_widget import GitTreeViewGUI
11
13
  from je_editor.pyside_ui.git_ui.git_client.git_client_gui import GitGui
12
14
  from je_editor.pyside_ui.main_ui.ai_widget.chat_ui import ChatUI
@@ -15,81 +17,127 @@ from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
15
17
  from je_editor.pyside_ui.main_ui.ipython_widget.rich_jupyter import IpythonWidget
16
18
  from je_editor.utils.logging.loggin_instance import jeditor_logger
17
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
+
18
29
  if TYPE_CHECKING:
19
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
+
20
34
  from PySide6.QtGui import QAction
35
+ # 匯入 QAction,用於建立選單動作
36
+ # Import QAction for creating menu actions
37
+
21
38
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
22
39
 
23
40
 
41
+ # 匯入多語言包裝器,用於支援多語系 UI
42
+ # Import language wrapper for multilingual UI support
43
+
44
+
24
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
+ """
25
50
  jeditor_logger.info(f"build_tab_menu.py set_tab_menu ui_we_want_to_set:{ui_we_want_to_set}")
26
- # Editor
51
+
52
+ # 建立 Tab 選單 (主容器)
53
+ # Create the Tab menu (main container)
27
54
  ui_we_want_to_set.tab_menu = ui_we_want_to_set.menu.addMenu(
28
55
  language_wrapper.language_word_dict.get("tab_menu_label")
29
56
  )
57
+
58
+ # === Editor 分頁 ===
59
+ # === Editor Tab ===
30
60
  ui_we_want_to_set.tab_menu.add_editor_action = QAction(
31
61
  language_wrapper.language_word_dict.get("tab_menu_add_editor_label"))
32
62
  ui_we_want_to_set.tab_menu.add_editor_action.triggered.connect(
33
63
  lambda: add_editor_tab(ui_we_want_to_set)
34
64
  )
35
- # Front Engine
36
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 ===
37
69
  ui_we_want_to_set.tab_menu.add_frontengine_action = QAction(
38
70
  language_wrapper.language_word_dict.get("tab_menu_add_frontengine_label"))
39
71
  ui_we_want_to_set.tab_menu.add_frontengine_action.triggered.connect(
40
72
  lambda: add_frontengine_tab(ui_we_want_to_set)
41
73
  )
42
- # Web
43
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 ===
44
78
  ui_we_want_to_set.tab_menu.add_web_action = QAction(
45
79
  language_wrapper.language_word_dict.get("tab_menu_add_web_label"))
46
80
  ui_we_want_to_set.tab_menu.add_web_action.triggered.connect(
47
81
  lambda: add_web_tab(ui_we_want_to_set)
48
82
  )
49
83
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_web_action)
50
- # IPython
84
+
85
+ # === IPython 分頁 ===
86
+ # === IPython Tab ===
51
87
  ui_we_want_to_set.tab_menu.add_ipython_action = QAction(
52
88
  language_wrapper.language_word_dict.get("tab_menu_ipython_tab_name"))
53
89
  ui_we_want_to_set.tab_menu.add_ipython_action.triggered.connect(
54
90
  lambda: add_ipython_tab(ui_we_want_to_set)
55
91
  )
56
92
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_ipython_action)
57
- # ChatUI
93
+
94
+ # === Chat UI 分頁 ===
95
+ # === Chat UI Tab ===
58
96
  ui_we_want_to_set.tab_menu.add_chat_ui_action = QAction(
59
97
  language_wrapper.language_word_dict.get("tab_menu_chat_ui_tab_name"))
60
98
  ui_we_want_to_set.tab_menu.add_chat_ui_action.triggered.connect(
61
99
  lambda: add_chat_ui_tab(ui_we_want_to_set)
62
100
  )
63
101
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_chat_ui_action)
64
- # Git Client
102
+
103
+ # === Git Client 分頁 ===
104
+ # === Git Client Tab ===
65
105
  ui_we_want_to_set.tab_menu.add_git_client_ui_action = QAction(
66
106
  language_wrapper.language_word_dict.get("tab_menu_git_client_tab_name"))
67
107
  ui_we_want_to_set.tab_menu.add_git_client_ui_action.triggered.connect(
68
108
  lambda: add_git_client_tab(ui_we_want_to_set)
69
109
  )
70
110
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_git_client_ui_action)
71
- # Git Branch tree
111
+
112
+ # === Git Branch Tree 分頁 ===
113
+ # === Git Branch Tree Tab ===
72
114
  ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action = QAction(
73
115
  language_wrapper.language_word_dict.get("tab_menu_git_branch_tree_view_tab_name"))
74
116
  ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action.triggered.connect(
75
117
  lambda: add_git_tree_view_tab(ui_we_want_to_set)
76
118
  )
77
119
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action)
78
- # Variable Inspector
120
+
121
+ # === Variable Inspector 分頁 ===
122
+ # === Variable Inspector Tab ===
79
123
  ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action = QAction(
80
124
  language_wrapper.language_word_dict.get("tab_menu_variable_inspector_tab_name"))
81
125
  ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action.triggered.connect(
82
126
  lambda: add_variable_inspector_tab(ui_we_want_to_set)
83
127
  )
84
128
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action)
85
- # Dynamic Console
129
+
130
+ # === Console 分頁 ===
131
+ # === Console Tab ===
86
132
  ui_we_want_to_set.tab_menu.add_console_widget_ui_action = QAction(
87
133
  language_wrapper.language_word_dict.get("tab_menu_console_widget_tab_name"))
88
134
  ui_we_want_to_set.tab_menu.add_console_widget_ui_action.triggered.connect(
89
135
  lambda: add_console_widget_tab(ui_we_want_to_set)
90
136
  )
91
137
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_console_widget_ui_action)
92
- # Code diff viewer
138
+
139
+ # === Code Diff Viewer 分頁 ===
140
+ # === Code Diff Viewer Tab ===
93
141
  ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action = QAction(
94
142
  language_wrapper.language_word_dict.get("tab_code_diff_viewer_tab_name"))
95
143
  ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action.triggered.connect(
@@ -97,7 +145,13 @@ def set_tab_menu(ui_we_want_to_set: EditorMain) -> None:
97
145
  )
98
146
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action)
99
147
 
148
+
149
+ # === 以下為各分頁新增函式 ===
150
+ # === Functions to add each tab ===
151
+
100
152
  def add_editor_tab(ui_we_want_to_set: EditorMain):
153
+ # 新增 Editor 分頁
154
+ # Add Editor tab
101
155
  jeditor_logger.info(f"build_tab_menu.py add editor tab ui_we_want_to_set: {ui_we_want_to_set}")
102
156
  widget = EditorWidget(ui_we_want_to_set)
103
157
  ui_we_want_to_set.tab_widget.addTab(
@@ -108,69 +162,113 @@ def add_editor_tab(ui_we_want_to_set: EditorMain):
108
162
 
109
163
 
110
164
  def add_frontengine_tab(ui_we_want_to_set: EditorMain):
165
+ # 新增 FrontEngine 分頁
166
+ # Add FrontEngine tab
111
167
  jeditor_logger.info(f"build_tab_menu.py add frontengine tab ui_we_want_to_set: {ui_we_want_to_set}")
112
168
  ui_we_want_to_set.tab_widget.addTab(
113
169
  FrontEngineMainUI(show_system_tray_ray=False, redirect_output=False),
114
170
  f"{language_wrapper.language_word_dict.get('tab_menu_frontengine_tab_name')} "
115
171
  f"{ui_we_want_to_set.tab_widget.count()}")
116
172
 
117
-
118
173
  def add_web_tab(ui_we_want_to_set: EditorMain):
174
+ # 紀錄日誌:新增 Web 分頁
175
+ # Log: add a Web tab
119
176
  jeditor_logger.info(f"build_tab_menu.py add web tab ui_we_want_to_set: {ui_we_want_to_set}")
177
+ # 在主編輯器的 tab_widget 中新增一個瀏覽器分頁
178
+ # Add a browser tab into the main editor's tab_widget
120
179
  ui_we_want_to_set.tab_widget.addTab(
121
- MainBrowserWidget(),
180
+ MainBrowserWidget(), # 建立瀏覽器元件 / Create browser widget
122
181
  f"{language_wrapper.language_word_dict.get('tab_menu_web_tab_name')} "
123
- f"{ui_we_want_to_set.tab_widget.count()}")
182
+ f"{ui_we_want_to_set.tab_widget.count()}" # 分頁名稱包含序號 / Tab name with index
183
+ )
124
184
 
125
185
 
126
186
  def add_ipython_tab(ui_we_want_to_set: EditorMain):
187
+ # 紀錄日誌:新增 IPython 分頁
188
+ # Log: add an IPython tab
127
189
  jeditor_logger.info(f"build_tab_menu.py add ipython tab ui_we_want_to_set: {ui_we_want_to_set}")
190
+ # 在主編輯器中新增 IPython 互動式分頁
191
+ # Add an IPython interactive tab
128
192
  ui_we_want_to_set.tab_widget.addTab(
129
- IpythonWidget(ui_we_want_to_set),
193
+ IpythonWidget(ui_we_want_to_set), # 建立 IPython 元件 / Create IPython widget
130
194
  f"{language_wrapper.language_word_dict.get('tab_menu_ipython_tab_name')} "
131
- f"{ui_we_want_to_set.tab_widget.count()}")
195
+ f"{ui_we_want_to_set.tab_widget.count()}"
196
+ )
132
197
 
133
198
 
134
199
  def add_chat_ui_tab(ui_we_want_to_set: EditorMain):
200
+ # 紀錄日誌:新增 Chat UI 分頁
201
+ # Log: add a Chat UI tab
135
202
  jeditor_logger.info(f"build_tab_menu.py add chat_ui tab ui_we_want_to_set: {ui_we_want_to_set}")
203
+ # 在主編輯器中新增聊天分頁
204
+ # Add a chat tab into the main editor
136
205
  ui_we_want_to_set.tab_widget.addTab(
137
- ChatUI(ui_we_want_to_set),
206
+ ChatUI(ui_we_want_to_set), # 建立聊天元件 / Create Chat UI widget
138
207
  f"{language_wrapper.language_word_dict.get('tab_menu_chat_ui_tab_name')} "
139
- f"{ui_we_want_to_set.tab_widget.count()}")
208
+ f"{ui_we_want_to_set.tab_widget.count()}"
209
+ )
140
210
 
141
211
 
142
212
  def add_git_client_tab(ui_we_want_to_set: EditorMain):
213
+ # 紀錄日誌:新增 Git Client 分頁
214
+ # Log: add a Git Client tab
143
215
  jeditor_logger.info(f"build_tab_menu.py add git client tab ui_we_want_to_set: {ui_we_want_to_set}")
216
+ # 在主編輯器中新增 Git 客戶端分頁
217
+ # Add a Git client tab
144
218
  ui_we_want_to_set.tab_widget.addTab(
145
- GitGui(),
219
+ GitGui(), # 建立 Git GUI 元件 / Create Git GUI widget
146
220
  f"{language_wrapper.language_word_dict.get('tab_menu_git_client_tab_name')} "
147
- f"{ui_we_want_to_set.tab_widget.count()}")
221
+ f"{ui_we_want_to_set.tab_widget.count()}"
222
+ )
223
+
148
224
 
149
225
  def add_git_tree_view_tab(ui_we_want_to_set: EditorMain):
226
+ # 紀錄日誌:新增 Git Branch Tree 分頁
227
+ # Log: add a Git Branch Tree tab
150
228
  jeditor_logger.info(f"build_tab_menu.py add git tree view tab ui_we_want_to_set: {ui_we_want_to_set}")
229
+ # 在主編輯器中新增 Git 分支樹狀圖分頁
230
+ # Add a Git branch tree view tab
151
231
  ui_we_want_to_set.tab_widget.addTab(
152
- GitTreeViewGUI(),
232
+ GitTreeViewGUI(), # 建立 Git Tree View 元件 / Create Git Tree View widget
153
233
  f"{language_wrapper.language_word_dict.get('tab_menu_git_branch_tree_view_tab_name')} "
154
- f"{ui_we_want_to_set.tab_widget.count()}")
234
+ f"{ui_we_want_to_set.tab_widget.count()}"
235
+ )
236
+
155
237
 
156
238
  def add_variable_inspector_tab(ui_we_want_to_set: EditorMain):
239
+ # 紀錄日誌:新增 Variable Inspector 分頁
240
+ # Log: add a Variable Inspector tab
157
241
  jeditor_logger.info(f"build_tab_menu.py add variable inspector tab ui_we_want_to_set: {ui_we_want_to_set}")
242
+ # 在主編輯器中新增變數檢查器分頁
243
+ # Add a variable inspector tab
158
244
  ui_we_want_to_set.tab_widget.addTab(
159
- VariableInspector(),
245
+ VariableInspector(), # 建立變數檢查器元件 / Create Variable Inspector widget
160
246
  f"{language_wrapper.language_word_dict.get('tab_menu_variable_inspector_tab_name')} "
161
- f"{ui_we_want_to_set.tab_widget.count()}")
247
+ f"{ui_we_want_to_set.tab_widget.count()}"
248
+ )
162
249
 
163
250
 
164
251
  def add_console_widget_tab(ui_we_want_to_set: EditorMain):
252
+ # 紀錄日誌:新增 Console 分頁
253
+ # Log: add a Console tab
165
254
  jeditor_logger.info(f"build_tab_menu.py add console widget tab ui_we_want_to_set: {ui_we_want_to_set}")
255
+ # 在主編輯器中新增動態控制台分頁
256
+ # Add a dynamic console tab
166
257
  ui_we_want_to_set.tab_widget.addTab(
167
- ConsoleWidget(),
258
+ ConsoleWidget(), # 建立控制台元件 / Create Console widget
168
259
  f"{language_wrapper.language_word_dict.get('tab_menu_console_widget_tab_name')} "
169
- f"{ui_we_want_to_set.tab_widget.count()}")
260
+ f"{ui_we_want_to_set.tab_widget.count()}"
261
+ )
262
+
170
263
 
171
264
  def add_code_diff_compare_tab(ui_we_want_to_set: EditorMain):
265
+ # 紀錄日誌:新增 Code Diff Compare 分頁
266
+ # Log: add a Code Diff Compare tab
172
267
  jeditor_logger.info(f"build_tab_menu.py add code diff compare tab ui_we_want_to_set: {ui_we_want_to_set}")
268
+ # 在主編輯器中新增程式碼差異比較分頁
269
+ # Add a code diff comparison tab
173
270
  ui_we_want_to_set.tab_widget.addTab(
174
- DiffViewerWidget(),
271
+ DiffViewerWidget(), # 建立程式碼比對元件 / Create Code Diff Viewer widget
175
272
  f"{language_wrapper.language_word_dict.get('tab_code_diff_viewer_tab_name')} "
176
- f"{ui_we_want_to_set.tab_widget.count()}")
273
+ f"{ui_we_want_to_set.tab_widget.count()}"
274
+ )
@@ -1,31 +1,69 @@
1
1
  from __future__ import annotations
2
+ # 啟用未來註解功能,允許型別提示使用字串前向參照
3
+ # Enable future annotations, allowing forward references in type hints
2
4
 
3
5
  from typing import TYPE_CHECKING
6
+ # TYPE_CHECKING 用於避免在執行時載入不必要的模組
7
+ # TYPE_CHECKING prevents unnecessary imports at runtime
4
8
 
5
9
  from PySide6.QtGui import QAction
10
+ # 匯入 QAction,用於建立選單動作
11
+ # Import QAction for creating menu actions
6
12
 
7
13
  from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
14
+ # 匯入編輯器元件
15
+ # Import the Editor widget
16
+
8
17
  from je_editor.pyside_ui.main_ui.save_settings.user_setting_file import user_setting_dict
18
+ # 匯入使用者設定字典,用於儲存字型與字體大小
19
+ # Import user setting dictionary to save font and size
20
+
9
21
  from je_editor.utils.logging.loggin_instance import jeditor_logger
22
+ # 匯入日誌工具
23
+ # Import logger
10
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
31
+ # 匯入多語言包裝器,用於多語系 UI
32
+ # Import language wrapper for multilingual UI
14
33
 
15
34
 
16
35
  def set_text_menu(ui_we_want_to_set: EditorMain):
36
+ """
37
+ 建立文字選單,包含字型與字體大小的子選單
38
+ Create the text menu, including font and font size submenus
39
+ """
17
40
  jeditor_logger.info(f"build_text_menu.py set_text_menu ui_we_want_to_set: {ui_we_want_to_set}")
41
+
42
+ # 建立 Text Menu
43
+ # Create Text Menu
18
44
  ui_we_want_to_set.text_menu = ui_we_want_to_set.menu.addMenu(
19
45
  language_wrapper.language_word_dict.get("text_menu_label"))
46
+
47
+ # === 字型選單 (Font Menu) ===
48
+ # === Font Menu ===
20
49
  ui_we_want_to_set.text_menu.font_menu = ui_we_want_to_set.text_menu.addMenu(
21
50
  language_wrapper.language_word_dict.get("text_menu_label_font"))
51
+
52
+ # 將系統支援的字型加入選單
53
+ # Add available system fonts into the menu
22
54
  for family in ui_we_want_to_set.font_database.families():
23
55
  font_action = QAction(family, parent=ui_we_want_to_set.text_menu.font_menu)
24
56
  font_action.triggered.connect(
25
57
  lambda checked=False, action=font_action: set_font(ui_we_want_to_set, action))
26
58
  ui_we_want_to_set.text_menu.font_menu.addAction(font_action)
59
+
60
+ # === 字體大小選單 (Font Size Menu) ===
61
+ # === Font Size Menu ===
27
62
  ui_we_want_to_set.text_menu.font_size_menu = ui_we_want_to_set.text_menu.addMenu(
28
63
  language_wrapper.language_word_dict.get("text_menu_label_font_size"))
64
+
65
+ # 提供 12 ~ 36 pt 的字體大小選項 (每次增加 2)
66
+ # Provide font sizes from 12 to 36 pt (step = 2)
29
67
  for size in range(12, 38, 2):
30
68
  font_action = QAction(str(size), parent=ui_we_want_to_set.text_menu.font_size_menu)
31
69
  font_action.triggered.connect(
@@ -34,36 +72,62 @@ def set_text_menu(ui_we_want_to_set: EditorMain):
34
72
 
35
73
 
36
74
  def set_font(ui_we_want_to_set: EditorMain, action: QAction) -> None:
75
+ """
76
+ 設定編輯器的字型
77
+ Set the font family for the editor
78
+ """
37
79
  jeditor_logger.info("build_text_menu.py set_font "
38
80
  f"ui_we_want_to_set: {ui_we_want_to_set} "
39
81
  f"action: {action}")
82
+
83
+ # 遍歷所有分頁,找到 EditorWidget 並套用字型
84
+ # Iterate through all tabs, apply font to EditorWidget
40
85
  for code_editor in range(ui_we_want_to_set.tab_widget.count()):
41
86
  widget = ui_we_want_to_set.tab_widget.widget(code_editor)
42
87
  if isinstance(widget, EditorWidget):
88
+ # 設定程式碼編輯區字型
89
+ # Set font for code editor
43
90
  widget.code_edit.setStyleSheet(
44
91
  f"font-size: {widget.code_edit.font().pointSize()}pt;"
45
92
  f"font-family: {action.text()};"
46
93
  )
94
+ # 設定輸出結果區字型
95
+ # Set font for result display
47
96
  widget.code_result.setStyleSheet(
48
97
  f"font-size: {widget.code_result.font().pointSize()}pt;"
49
98
  f"font-family: {action.text()};"
50
99
  )
100
+ # 更新使用者設定
101
+ # Update user settings
51
102
  user_setting_dict.update({"font": action.text()})
52
103
 
53
104
 
54
105
  def set_font_size(ui_we_want_to_set: EditorMain, action: QAction) -> None:
106
+ """
107
+ 設定編輯器的字體大小
108
+ Set the font size for the editor
109
+ """
55
110
  jeditor_logger.info("build_text_menu.py set_font_size "
56
111
  f"ui_we_want_to_set: {ui_we_want_to_set} "
57
112
  f"action: {action}")
113
+
114
+ # 遍歷所有分頁,找到 EditorWidget 並套用字體大小
115
+ # Iterate through all tabs, apply font size to EditorWidget
58
116
  for code_editor in range(ui_we_want_to_set.tab_widget.count()):
59
117
  widget = ui_we_want_to_set.tab_widget.widget(code_editor)
60
118
  if type(widget) is EditorWidget:
119
+ # 設定程式碼編輯區字體大小
120
+ # Set font size for code editor
61
121
  widget.code_edit.setStyleSheet(
62
122
  f"font-size: {int(action.text())}pt;"
63
123
  f"font-family: {widget.code_edit.font().family()};"
64
124
  )
125
+ # 設定輸出結果區字體大小
126
+ # Set font size for result display
65
127
  widget.code_result.setStyleSheet(
66
128
  f"font-size: {int(action.text())}pt;"
67
129
  f"font-family: {widget.code_result.font().family()};"
68
130
  )
69
- user_setting_dict.update({"font_size": int(action.text())})
131
+ # 更新使用者設定
132
+ # Update user settings
133
+ 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
- user_setting_color_dict.update(read_json(str(user_color_setting_file)))
103
+ user_setting_color_dict.update(read_json(str(user_color_setting_file)))
@@ -2,30 +2,57 @@ from os import getcwd
2
2
  from pathlib import Path
3
3
 
4
4
  from je_editor.pyside_ui.main_ui.save_settings.setting_utils import write_setting
5
+ # 匯入通用的設定寫入工具
6
+ # Import utility function to write settings
7
+
5
8
  from je_editor.utils.json.json_file import read_json
9
+ # 匯入 JSON 讀取工具
10
+ # Import JSON reader utility
11
+
6
12
  from je_editor.utils.logging.loggin_instance import jeditor_logger
13
+ # 匯入日誌工具
14
+ # Import logger
15
+
7
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
- user_setting_dict.update(read_json(str(user_setting_file)))
58
+ user_setting_dict.update(read_json(str(user_setting_file)))