je-editor 0.0.222__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 (75) hide show
  1. je_editor/__init__.py +2 -2
  2. je_editor/git_client/commit_graph.py +7 -7
  3. je_editor/git_client/git_action.py +0 -7
  4. je_editor/pyside_ui/browser/browser_view.py +16 -4
  5. je_editor/pyside_ui/browser/browser_widget.py +43 -29
  6. je_editor/pyside_ui/browser/main_browser_widget.py +85 -0
  7. je_editor/pyside_ui/code/auto_save/auto_save_manager.py +34 -2
  8. je_editor/pyside_ui/code/auto_save/auto_save_thread.py +19 -6
  9. je_editor/pyside_ui/code/code_format/pep8_format.py +53 -9
  10. je_editor/pyside_ui/code/code_process/code_exec.py +88 -52
  11. je_editor/pyside_ui/code/plaintext_code_edit/code_edit_plaintext.py +116 -55
  12. je_editor/pyside_ui/code/running_process_manager.py +19 -1
  13. je_editor/pyside_ui/code/shell_process/shell_exec.py +71 -48
  14. je_editor/pyside_ui/code/syntax/python_syntax.py +45 -10
  15. je_editor/pyside_ui/code/syntax/syntax_setting.py +40 -12
  16. je_editor/pyside_ui/code/textedit_code_result/code_record.py +34 -12
  17. je_editor/pyside_ui/code/variable_inspector/inspector_gui.py +53 -6
  18. je_editor/pyside_ui/dialog/ai_dialog/set_ai_dialog.py +30 -3
  19. je_editor/pyside_ui/dialog/file_dialog/create_file_dialog.py +35 -2
  20. je_editor/pyside_ui/dialog/file_dialog/open_file_dialog.py +33 -5
  21. je_editor/pyside_ui/dialog/file_dialog/save_file_dialog.py +25 -3
  22. je_editor/pyside_ui/dialog/search_ui/search_error_box.py +26 -1
  23. je_editor/pyside_ui/dialog/search_ui/search_text_box.py +26 -1
  24. je_editor/pyside_ui/git_ui/code_diff_compare/code_diff_viewer_widget.py +11 -11
  25. je_editor/pyside_ui/git_ui/git_client/commit_table.py +46 -8
  26. je_editor/pyside_ui/git_ui/git_client/git_branch_tree_widget.py +49 -15
  27. je_editor/pyside_ui/git_ui/git_client/git_client_gui.py +81 -16
  28. je_editor/pyside_ui/git_ui/git_client/graph_view.py +64 -20
  29. je_editor/pyside_ui/main_ui/ai_widget/ai_config.py +20 -5
  30. je_editor/pyside_ui/main_ui/ai_widget/ask_thread.py +20 -1
  31. je_editor/pyside_ui/main_ui/ai_widget/chat_ui.py +56 -41
  32. je_editor/pyside_ui/main_ui/ai_widget/langchain_interface.py +45 -6
  33. je_editor/pyside_ui/main_ui/console_widget/console_gui.py +44 -12
  34. je_editor/pyside_ui/main_ui/console_widget/qprocess_adapter.py +34 -13
  35. je_editor/pyside_ui/main_ui/dock/destroy_dock.py +33 -2
  36. je_editor/pyside_ui/main_ui/editor/editor_widget.py +104 -20
  37. je_editor/pyside_ui/main_ui/editor/editor_widget_dock.py +34 -7
  38. je_editor/pyside_ui/main_ui/editor/process_input.py +38 -11
  39. je_editor/pyside_ui/main_ui/ipython_widget/rich_jupyter.py +46 -11
  40. je_editor/pyside_ui/main_ui/main_editor.py +180 -42
  41. je_editor/pyside_ui/main_ui/menu/check_style_menu/build_check_style_menu.py +51 -28
  42. je_editor/pyside_ui/main_ui/menu/dock_menu/build_dock_menu.py +83 -36
  43. je_editor/pyside_ui/main_ui/menu/file_menu/build_file_menu.py +70 -17
  44. je_editor/pyside_ui/main_ui/menu/help_menu/build_help_menu.py +35 -4
  45. je_editor/pyside_ui/main_ui/menu/language_menu/build_language_server.py +41 -1
  46. je_editor/pyside_ui/main_ui/menu/python_env_menu/build_venv_menu.py +100 -42
  47. je_editor/pyside_ui/main_ui/menu/run_menu/build_run_menu.py +57 -7
  48. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_debug_menu.py +50 -4
  49. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_program_menu.py +52 -6
  50. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/build_shell_menu.py +44 -4
  51. je_editor/pyside_ui/main_ui/menu/run_menu/under_run_menu/utils.py +23 -1
  52. je_editor/pyside_ui/main_ui/menu/set_menu_bar.py +37 -12
  53. je_editor/pyside_ui/main_ui/menu/style_menu/build_style_menu.py +44 -7
  54. je_editor/pyside_ui/main_ui/menu/tab_menu/build_tab_menu.py +127 -44
  55. je_editor/pyside_ui/main_ui/menu/text_menu/build_text_menu.py +65 -1
  56. je_editor/pyside_ui/main_ui/save_settings/setting_utils.py +18 -1
  57. je_editor/pyside_ui/main_ui/save_settings/user_color_setting_file.py +33 -3
  58. je_editor/pyside_ui/main_ui/save_settings/user_setting_file.py +38 -11
  59. je_editor/pyside_ui/main_ui/system_tray/extend_system_tray.py +39 -2
  60. je_editor/start_editor.py +26 -1
  61. je_editor/utils/encodings/python_encodings.py +101 -98
  62. je_editor/utils/file/open/open_file.py +36 -19
  63. je_editor/utils/file/save/save_file.py +35 -14
  64. je_editor/utils/json/json_file.py +29 -14
  65. je_editor/utils/json_format/json_process.py +33 -2
  66. je_editor/utils/logging/loggin_instance.py +38 -8
  67. je_editor/utils/multi_language/multi_language_wrapper.py +29 -4
  68. je_editor/utils/redirect_manager/redirect_manager_class.py +49 -11
  69. je_editor/utils/venv_check/check_venv.py +45 -15
  70. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/METADATA +1 -1
  71. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/RECORD +74 -74
  72. je_editor/git_client/github.py +0 -81
  73. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/WHEEL +0 -0
  74. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/licenses/LICENSE +0 -0
  75. {je_editor-0.0.222.dist-info → je_editor-0.0.224.dist-info}/top_level.txt +0 -0
@@ -1,32 +1,62 @@
1
+ # 匯入未來功能,允許延遲型別註解 (Python 3.7+ 常用)
2
+ # Import future feature: postponed evaluation of type annotations
1
3
  from __future__ import annotations
2
4
 
5
+ # 僅用於型別檢查,避免循環匯入
6
+ # For type checking only (avoids circular imports)
3
7
  from typing import TYPE_CHECKING
4
8
 
9
+ # 匯入編輯器元件與輸入處理
10
+ # Import EditorWidget and ProcessInput
5
11
  from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
6
12
  from je_editor.pyside_ui.main_ui.editor.process_input import ProcessInput
13
+
14
+ # 匯入工具函式:顯示「請先關閉目前執行中的程式」訊息框
15
+ # Import utility: show message box if a program is already running
7
16
  from je_editor.pyside_ui.main_ui.menu.run_menu.under_run_menu.utils import please_close_current_running_messagebox
17
+
18
+ # 匯入日誌紀錄器
19
+ # Import logger instance
8
20
  from je_editor.utils.logging.loggin_instance import jeditor_logger
9
21
 
22
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
23
+ # Import EditorMain only for type checking (avoids circular dependency)
10
24
  if TYPE_CHECKING:
11
25
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
26
+
27
+ # 匯入 Qt 動作
28
+ # Import QAction
12
29
  from PySide6.QtGui import QAction
13
30
 
31
+ # 匯入 ShellManager,用於執行系統命令
32
+ # Import ShellManager for executing shell commands
14
33
  from je_editor.pyside_ui.code.shell_process.shell_exec import ShellManager
34
+
35
+ # 匯入多語言包裝器
36
+ # Import multi-language wrapper for UI localization
15
37
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
16
38
 
17
39
 
40
+ # 設定 Shell 選單
41
+ # Set up the Shell menu
18
42
  def set_shell_menu(ui_we_want_to_set: EditorMain) -> None:
19
43
  jeditor_logger.info(f"build_shell_menu.py set_shell_menu ui_we_want_to_set: {ui_we_want_to_set}")
44
+ # 在 Run 選單下建立 Shell 子選單
45
+ # Create Shell submenu under Run menu
20
46
  ui_we_want_to_set.run_shell_menu = ui_we_want_to_set.run_menu.addMenu(
21
47
  language_wrapper.language_word_dict.get("run_menu_run_on_shell_label"))
22
- # Run on shell
48
+
49
+ # 建立「在 Shell 執行」動作
50
+ # Add "Run on Shell" action
23
51
  ui_we_want_to_set.run_shell_menu.run_on_shell_action = QAction(
24
52
  language_wrapper.language_word_dict.get("run_menu_run_on_shell_label"))
25
53
  ui_we_want_to_set.run_shell_menu.run_on_shell_action.triggered.connect(
26
54
  lambda: shell_exec(ui_we_want_to_set)
27
55
  )
28
56
  ui_we_want_to_set.run_shell_menu.addAction(ui_we_want_to_set.run_shell_menu.run_on_shell_action)
29
- # Show shell input
57
+
58
+ # 建立「顯示 Shell 輸入」動作
59
+ # Add "Show Shell Input" action
30
60
  ui_we_want_to_set.run_shell_menu.show_shell_input = QAction(
31
61
  language_wrapper.language_word_dict.get("show_shell_input"))
32
62
  ui_we_want_to_set.run_shell_menu.show_shell_input.triggered.connect(
@@ -35,26 +65,36 @@ def set_shell_menu(ui_we_want_to_set: EditorMain) -> None:
35
65
  ui_we_want_to_set.run_shell_menu.addAction(ui_we_want_to_set.run_shell_menu.show_shell_input)
36
66
 
37
67
 
68
+ # 在 Shell 中執行程式碼
69
+ # Execute code in Shell
38
70
  def shell_exec(ui_we_want_to_set: EditorMain) -> None:
39
71
  jeditor_logger.info(f"build_shell_menu.py shell_exec ui_we_want_to_set: {ui_we_want_to_set}")
40
72
  widget = ui_we_want_to_set.tab_widget.currentWidget()
41
73
  if isinstance(widget, EditorWidget):
74
+ # 確保沒有正在執行的 Shell 程式
75
+ # Ensure no shell process is already running
42
76
  if widget.exec_shell is None:
77
+ # 建立 ShellManager 並執行當前編輯器中的程式碼
78
+ # Create ShellManager and execute current editor code
43
79
  shell_command = ShellManager(
44
80
  main_window=widget,
45
81
  shell_encoding=ui_we_want_to_set.encoding)
46
82
  shell_command.later_init()
47
83
  shell_command.exec_shell(
48
- widget.code_edit.toPlainText()
84
+ widget.code_edit.toPlainText() # 直接執行編輯器中的文字
49
85
  )
50
86
  widget.exec_shell = shell_command
51
87
  else:
88
+ # 如果已有 Shell 在執行,顯示提示訊息
89
+ # If a shell process is already running, show message
52
90
  please_close_current_running_messagebox(ui_we_want_to_set)
53
91
 
54
92
 
93
+ # 顯示 Shell 輸入介面
94
+ # Show Shell input interface
55
95
  def show_shell_input(ui_we_want_to_set: EditorMain) -> None:
56
96
  jeditor_logger.info(f"build_shell_menu.py show_shell_input ui_we_want_to_set: {ui_we_want_to_set}")
57
97
  widget = ui_we_want_to_set.tab_widget.currentWidget()
58
98
  if isinstance(widget, EditorWidget):
59
99
  widget.shell_input = ProcessInput(widget, "shell")
60
- widget.shell_input.show()
100
+ widget.shell_input.show()
@@ -2,19 +2,41 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
+ # 匯入 Qt 訊息框
6
+ # Import QMessageBox for showing message dialogs
5
7
  from PySide6.QtWidgets import QMessageBox
6
8
 
9
+ # 匯入日誌紀錄器
10
+ # Import logger instance
7
11
  from je_editor.utils.logging.loggin_instance import jeditor_logger
12
+
13
+ # 匯入多語言包裝器,用於多語言顯示
14
+ # Import multi-language wrapper for UI localization
8
15
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
9
16
 
17
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
18
+ # Import EditorMain only for type checking (avoids circular dependency)
10
19
  if TYPE_CHECKING:
11
20
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
12
21
 
13
22
 
23
+ # 顯示「請先關閉目前執行中的程式」訊息框
24
+ # Show a message box: "Please stop the currently running program first"
14
25
  def please_close_current_running_messagebox(ui_we_want_to_set: EditorMain):
26
+ # 紀錄日誌,方便除錯
27
+ # Log info for debugging
15
28
  jeditor_logger.info(f"utils.py please_close_current_running_messagebox ui_we_want_to_set: {ui_we_want_to_set}")
29
+
30
+ # 建立訊息框,父視窗為主編輯器
31
+ # Create a message box with the main editor as parent
16
32
  please_stop_current_running_program_messagebox = QMessageBox(ui_we_want_to_set)
33
+
34
+ # 設定訊息框文字,從多語言字典取得對應語言的提示
35
+ # Set message text, retrieved from multi-language dictionary
17
36
  please_stop_current_running_program_messagebox.setText(
18
37
  language_wrapper.language_word_dict.get("please_stop_current_running_program")
19
38
  )
20
- please_stop_current_running_program_messagebox.show()
39
+
40
+ # 顯示訊息框
41
+ # Show the message box
42
+ please_stop_current_running_program_messagebox.show()
@@ -1,7 +1,13 @@
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
 
9
+ # 匯入各種子選單的建構函式
10
+ # Import functions to build different sub-menus
5
11
  from je_editor.pyside_ui.main_ui.menu.dock_menu.build_dock_menu import set_dock_menu
6
12
  from je_editor.pyside_ui.main_ui.menu.language_menu.build_language_server import set_language_menu
7
13
  from je_editor.pyside_ui.main_ui.menu.style_menu.build_style_menu import set_style_menu
@@ -11,8 +17,15 @@ from je_editor.utils.logging.loggin_instance import jeditor_logger
11
17
 
12
18
  if TYPE_CHECKING:
13
19
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
20
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
21
+ # Import EditorMain only for type checking
22
+
14
23
  from PySide6.QtWidgets import QMenuBar
24
+ # 匯入 QMenuBar,用於建立選單列
25
+ # Import QMenuBar to create the menu bar
15
26
 
27
+ # 其他子選單建構函式
28
+ # Other sub-menu builders
16
29
  from je_editor.pyside_ui.main_ui.menu.check_style_menu.build_check_style_menu import set_check_menu
17
30
  from je_editor.pyside_ui.main_ui.menu.file_menu.build_file_menu import set_file_menu
18
31
  from je_editor.pyside_ui.main_ui.menu.help_menu.build_help_menu import set_help_menu
@@ -21,17 +34,29 @@ from je_editor.pyside_ui.main_ui.menu.python_env_menu.build_venv_menu import set
21
34
 
22
35
 
23
36
  def set_menu_bar(ui_we_want_to_set: EditorMain) -> None:
37
+ """
38
+ 建立主選單列,並依序加入各種子選單
39
+ Build the main menu bar and add all sub-menus in order
40
+ """
24
41
  jeditor_logger.info(f"set_menu_bar.py set_menu_bar ui_we_want_to_set: {ui_we_want_to_set}")
25
- # set menu
42
+
43
+ # 建立一個新的選單列
44
+ # Create a new menu bar
26
45
  ui_we_want_to_set.menu = QMenuBar()
27
- set_file_menu(ui_we_want_to_set)
28
- set_run_menu(ui_we_want_to_set)
29
- set_text_menu(ui_we_want_to_set)
30
- set_check_menu(ui_we_want_to_set)
31
- set_help_menu(ui_we_want_to_set)
32
- set_venv_menu(ui_we_want_to_set)
33
- set_tab_menu(ui_we_want_to_set)
34
- set_dock_menu(ui_we_want_to_set)
35
- set_style_menu(ui_we_want_to_set)
36
- set_language_menu(ui_we_want_to_set)
37
- ui_we_want_to_set.setMenuBar(ui_we_want_to_set.menu)
46
+
47
+ # === 加入各種子選單 ===
48
+ # === Add different sub-menus ===
49
+ set_file_menu(ui_we_want_to_set) # 檔案選單 / File menu
50
+ set_run_menu(ui_we_want_to_set) # 執行選單 / Run menu
51
+ set_text_menu(ui_we_want_to_set) # 文字設定選單 / Text menu
52
+ set_check_menu(ui_we_want_to_set) # 程式碼檢查選單 / Code style check menu
53
+ set_help_menu(ui_we_want_to_set) # 幫助選單 / Help menu
54
+ set_venv_menu(ui_we_want_to_set) # Python 虛擬環境選單 / Python venv menu
55
+ set_tab_menu(ui_we_want_to_set) # 分頁選單 / Tab menu
56
+ set_dock_menu(ui_we_want_to_set) # Dock 視窗選單 / Dock menu
57
+ set_style_menu(ui_we_want_to_set) # 介面樣式選單 / Style menu
58
+ set_language_menu(ui_we_want_to_set) # 語言選單 / Language menu
59
+
60
+ # 將選單列設定到主視窗
61
+ # Attach the menu bar to the main editor window
62
+ ui_we_want_to_set.setMenuBar(ui_we_want_to_set.menu)
@@ -2,36 +2,73 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
+ # 匯入 Qt 動作
6
+ # Import QAction
5
7
  from PySide6.QtGui import QAction
6
8
 
9
+ # 匯入使用者設定字典,用來保存 UI 樣式設定
10
+ # Import user settings dictionary for saving UI style preferences
7
11
  from je_editor.pyside_ui.main_ui.save_settings.user_setting_file import user_setting_dict
12
+
13
+ # 匯入日誌紀錄器
14
+ # Import logger instance
8
15
  from je_editor.utils.logging.loggin_instance import jeditor_logger
9
16
 
10
17
  if TYPE_CHECKING:
18
+ # 僅在型別檢查時匯入 EditorMain,避免循環依賴
19
+ # Import EditorMain only for type checking (avoids circular dependency)
11
20
  from je_editor.pyside_ui.main_ui.main_editor import EditorMain
12
21
 
22
+ # 匯入多語言包裝器,用於 UI 多語言顯示
23
+ # Import multi-language wrapper for UI localization
13
24
  from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
14
25
 
15
26
 
27
+ # 設定 Style 選單
28
+ # Set up the Style menu
16
29
  def set_style_menu(ui_we_want_to_set: EditorMain) -> None:
17
30
  jeditor_logger.info(f"build_style_menu.py set_style_menu ui_we_want_to_set: {ui_we_want_to_set}")
31
+
32
+ # 在主選單中新增「Style」子選單
33
+ # Add "Style" submenu under the main menu
18
34
  ui_we_want_to_set.menu.style_menu = ui_we_want_to_set.menu.addMenu(
19
35
  language_wrapper.language_word_dict.get("style_menu_label")
20
36
  )
21
- for style in ['dark_amber.xml', 'dark_blue.xml', 'dark_cyan.xml', 'dark_lightgreen.xml',
22
- 'dark_pink.xml', 'dark_purple.xml', 'dark_red.xml', 'dark_teal.xml',
23
- 'dark_yellow.xml', 'light_amber.xml', 'light_blue.xml', 'light_cyan.xml',
24
- 'light_cyan_500.xml', 'light_lightgreen.xml', 'light_pink.xml', 'light_purple.xml'
25
- ]:
37
+
38
+ # 預設提供的樣式清單 (深色/淺色不同配色)
39
+ # Predefined style list (dark/light themes with different colors)
40
+ for style in [
41
+ 'dark_amber.xml', 'dark_blue.xml', 'dark_cyan.xml', 'dark_lightgreen.xml',
42
+ 'dark_pink.xml', 'dark_purple.xml', 'dark_red.xml', 'dark_teal.xml',
43
+ 'dark_yellow.xml', 'light_amber.xml', 'light_blue.xml', 'light_cyan.xml',
44
+ 'light_cyan_500.xml', 'light_lightgreen.xml', 'light_pink.xml', 'light_purple.xml'
45
+ ]:
46
+ # 建立一個 QAction,名稱為樣式檔名
47
+ # Create an QAction with the style filename as label
26
48
  change_style_action = QAction(style, parent=ui_we_want_to_set.menu.style_menu)
49
+
50
+ # 綁定觸發事件,呼叫 set_style 來套用樣式
51
+ # Connect action to set_style function
27
52
  change_style_action.triggered.connect(
28
- lambda checked=False, action=change_style_action: set_style(ui_we_want_to_set, action))
53
+ lambda checked=False, action=change_style_action: set_style(ui_we_want_to_set, action)
54
+ )
55
+
56
+ # 將動作加入 Style 選單
57
+ # Add action to the Style menu
29
58
  ui_we_want_to_set.menu.style_menu.addAction(change_style_action)
30
59
 
31
60
 
61
+ # 套用選擇的樣式
62
+ # Apply the selected style
32
63
  def set_style(ui_we_want_to_set: EditorMain, action: QAction) -> None:
33
64
  jeditor_logger.info("build_style_menu.py set_style "
34
65
  f"ui_we_want_to_set: {ui_we_want_to_set} "
35
66
  f"action: {action}")
67
+
68
+ # 呼叫主視窗的 apply_stylesheet 方法,套用選擇的樣式
69
+ # Call main window's apply_stylesheet method to apply the chosen style
36
70
  ui_we_want_to_set.apply_stylesheet(ui_we_want_to_set, action.text())
37
- user_setting_dict.update({"ui_style": action.text()})
71
+
72
+ # 更新使用者設定,保存目前選擇的樣式
73
+ # Update user settings dictionary to persist the chosen style
74
+ user_setting_dict.update({"ui_style": action.text()})
@@ -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
- from je_editor.pyside_ui.browser.browser_widget import BrowserWidget
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,88 +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
- # Stackoverflow
51
- ui_we_want_to_set.tab_menu.add_stackoverflow_action = QAction(
52
- language_wrapper.language_word_dict.get("tab_menu_add_stackoverflow_label"))
53
- ui_we_want_to_set.tab_menu.add_stackoverflow_action.triggered.connect(
54
- lambda: add_stackoverflow_tab(ui_we_want_to_set)
55
- )
56
- ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_stackoverflow_action)
57
- # IPython
84
+
85
+ # === IPython 分頁 ===
86
+ # === IPython Tab ===
58
87
  ui_we_want_to_set.tab_menu.add_ipython_action = QAction(
59
88
  language_wrapper.language_word_dict.get("tab_menu_ipython_tab_name"))
60
89
  ui_we_want_to_set.tab_menu.add_ipython_action.triggered.connect(
61
90
  lambda: add_ipython_tab(ui_we_want_to_set)
62
91
  )
63
92
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_ipython_action)
64
- # ChatUI
93
+
94
+ # === Chat UI 分頁 ===
95
+ # === Chat UI Tab ===
65
96
  ui_we_want_to_set.tab_menu.add_chat_ui_action = QAction(
66
97
  language_wrapper.language_word_dict.get("tab_menu_chat_ui_tab_name"))
67
98
  ui_we_want_to_set.tab_menu.add_chat_ui_action.triggered.connect(
68
99
  lambda: add_chat_ui_tab(ui_we_want_to_set)
69
100
  )
70
101
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_chat_ui_action)
71
- # Git Client
102
+
103
+ # === Git Client 分頁 ===
104
+ # === Git Client Tab ===
72
105
  ui_we_want_to_set.tab_menu.add_git_client_ui_action = QAction(
73
106
  language_wrapper.language_word_dict.get("tab_menu_git_client_tab_name"))
74
107
  ui_we_want_to_set.tab_menu.add_git_client_ui_action.triggered.connect(
75
108
  lambda: add_git_client_tab(ui_we_want_to_set)
76
109
  )
77
110
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_git_client_ui_action)
78
- # Git Branch tree
111
+
112
+ # === Git Branch Tree 分頁 ===
113
+ # === Git Branch Tree Tab ===
79
114
  ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action = QAction(
80
115
  language_wrapper.language_word_dict.get("tab_menu_git_branch_tree_view_tab_name"))
81
116
  ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action.triggered.connect(
82
117
  lambda: add_git_tree_view_tab(ui_we_want_to_set)
83
118
  )
84
119
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_git_branch_view_ui_action)
85
- # Variable Inspector
120
+
121
+ # === Variable Inspector 分頁 ===
122
+ # === Variable Inspector Tab ===
86
123
  ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action = QAction(
87
124
  language_wrapper.language_word_dict.get("tab_menu_variable_inspector_tab_name"))
88
125
  ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action.triggered.connect(
89
126
  lambda: add_variable_inspector_tab(ui_we_want_to_set)
90
127
  )
91
128
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_variable_inspector_ui_action)
92
- # Dynamic Console
129
+
130
+ # === Console 分頁 ===
131
+ # === Console Tab ===
93
132
  ui_we_want_to_set.tab_menu.add_console_widget_ui_action = QAction(
94
133
  language_wrapper.language_word_dict.get("tab_menu_console_widget_tab_name"))
95
134
  ui_we_want_to_set.tab_menu.add_console_widget_ui_action.triggered.connect(
96
135
  lambda: add_console_widget_tab(ui_we_want_to_set)
97
136
  )
98
137
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_console_widget_ui_action)
99
- # Code diff viewer
138
+
139
+ # === Code Diff Viewer 分頁 ===
140
+ # === Code Diff Viewer Tab ===
100
141
  ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action = QAction(
101
142
  language_wrapper.language_word_dict.get("tab_code_diff_viewer_tab_name"))
102
143
  ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action.triggered.connect(
@@ -104,7 +145,13 @@ def set_tab_menu(ui_we_want_to_set: EditorMain) -> None:
104
145
  )
105
146
  ui_we_want_to_set.tab_menu.addAction(ui_we_want_to_set.tab_menu.add_code_diff_viewer_ui_action)
106
147
 
148
+
149
+ # === 以下為各分頁新增函式 ===
150
+ # === Functions to add each tab ===
151
+
107
152
  def add_editor_tab(ui_we_want_to_set: EditorMain):
153
+ # 新增 Editor 分頁
154
+ # Add Editor tab
108
155
  jeditor_logger.info(f"build_tab_menu.py add editor tab ui_we_want_to_set: {ui_we_want_to_set}")
109
156
  widget = EditorWidget(ui_we_want_to_set)
110
157
  ui_we_want_to_set.tab_widget.addTab(
@@ -115,77 +162,113 @@ def add_editor_tab(ui_we_want_to_set: EditorMain):
115
162
 
116
163
 
117
164
  def add_frontengine_tab(ui_we_want_to_set: EditorMain):
165
+ # 新增 FrontEngine 分頁
166
+ # Add FrontEngine tab
118
167
  jeditor_logger.info(f"build_tab_menu.py add frontengine tab ui_we_want_to_set: {ui_we_want_to_set}")
119
168
  ui_we_want_to_set.tab_widget.addTab(
120
169
  FrontEngineMainUI(show_system_tray_ray=False, redirect_output=False),
121
170
  f"{language_wrapper.language_word_dict.get('tab_menu_frontengine_tab_name')} "
122
171
  f"{ui_we_want_to_set.tab_widget.count()}")
123
172
 
124
-
125
173
  def add_web_tab(ui_we_want_to_set: EditorMain):
174
+ # 紀錄日誌:新增 Web 分頁
175
+ # Log: add a Web tab
126
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
127
179
  ui_we_want_to_set.tab_widget.addTab(
128
- BrowserWidget(),
180
+ MainBrowserWidget(), # 建立瀏覽器元件 / Create browser widget
129
181
  f"{language_wrapper.language_word_dict.get('tab_menu_web_tab_name')} "
130
- f"{ui_we_want_to_set.tab_widget.count()}")
131
-
132
-
133
- def add_stackoverflow_tab(ui_we_want_to_set: EditorMain):
134
- jeditor_logger.info(f"build_tab_menu.py add stackoverflow tab ui_we_want_to_set: {ui_we_want_to_set}")
135
- ui_we_want_to_set.tab_widget.addTab(
136
- BrowserWidget(start_url="https://stackoverflow.com/", search_prefix="https://stackoverflow.com/search?q="),
137
- f"{language_wrapper.language_word_dict.get('tab_menu_stackoverflow_tab_name')} "
138
- f"{ui_we_want_to_set.tab_widget.count()}")
182
+ f"{ui_we_want_to_set.tab_widget.count()}" # 分頁名稱包含序號 / Tab name with index
183
+ )
139
184
 
140
185
 
141
186
  def add_ipython_tab(ui_we_want_to_set: EditorMain):
187
+ # 紀錄日誌:新增 IPython 分頁
188
+ # Log: add an IPython tab
142
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
143
192
  ui_we_want_to_set.tab_widget.addTab(
144
- IpythonWidget(ui_we_want_to_set),
193
+ IpythonWidget(ui_we_want_to_set), # 建立 IPython 元件 / Create IPython widget
145
194
  f"{language_wrapper.language_word_dict.get('tab_menu_ipython_tab_name')} "
146
- f"{ui_we_want_to_set.tab_widget.count()}")
195
+ f"{ui_we_want_to_set.tab_widget.count()}"
196
+ )
147
197
 
148
198
 
149
199
  def add_chat_ui_tab(ui_we_want_to_set: EditorMain):
200
+ # 紀錄日誌:新增 Chat UI 分頁
201
+ # Log: add a Chat UI tab
150
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
151
205
  ui_we_want_to_set.tab_widget.addTab(
152
- ChatUI(ui_we_want_to_set),
206
+ ChatUI(ui_we_want_to_set), # 建立聊天元件 / Create Chat UI widget
153
207
  f"{language_wrapper.language_word_dict.get('tab_menu_chat_ui_tab_name')} "
154
- f"{ui_we_want_to_set.tab_widget.count()}")
208
+ f"{ui_we_want_to_set.tab_widget.count()}"
209
+ )
155
210
 
156
211
 
157
212
  def add_git_client_tab(ui_we_want_to_set: EditorMain):
213
+ # 紀錄日誌:新增 Git Client 分頁
214
+ # Log: add a Git Client tab
158
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
159
218
  ui_we_want_to_set.tab_widget.addTab(
160
- GitGui(),
219
+ GitGui(), # 建立 Git GUI 元件 / Create Git GUI widget
161
220
  f"{language_wrapper.language_word_dict.get('tab_menu_git_client_tab_name')} "
162
- f"{ui_we_want_to_set.tab_widget.count()}")
221
+ f"{ui_we_want_to_set.tab_widget.count()}"
222
+ )
223
+
163
224
 
164
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
165
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
166
231
  ui_we_want_to_set.tab_widget.addTab(
167
- GitTreeViewGUI(),
232
+ GitTreeViewGUI(), # 建立 Git Tree View 元件 / Create Git Tree View widget
168
233
  f"{language_wrapper.language_word_dict.get('tab_menu_git_branch_tree_view_tab_name')} "
169
- f"{ui_we_want_to_set.tab_widget.count()}")
234
+ f"{ui_we_want_to_set.tab_widget.count()}"
235
+ )
236
+
170
237
 
171
238
  def add_variable_inspector_tab(ui_we_want_to_set: EditorMain):
239
+ # 紀錄日誌:新增 Variable Inspector 分頁
240
+ # Log: add a Variable Inspector tab
172
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
173
244
  ui_we_want_to_set.tab_widget.addTab(
174
- VariableInspector(),
245
+ VariableInspector(), # 建立變數檢查器元件 / Create Variable Inspector widget
175
246
  f"{language_wrapper.language_word_dict.get('tab_menu_variable_inspector_tab_name')} "
176
- f"{ui_we_want_to_set.tab_widget.count()}")
247
+ f"{ui_we_want_to_set.tab_widget.count()}"
248
+ )
177
249
 
178
250
 
179
251
  def add_console_widget_tab(ui_we_want_to_set: EditorMain):
252
+ # 紀錄日誌:新增 Console 分頁
253
+ # Log: add a Console tab
180
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
181
257
  ui_we_want_to_set.tab_widget.addTab(
182
- ConsoleWidget(),
258
+ ConsoleWidget(), # 建立控制台元件 / Create Console widget
183
259
  f"{language_wrapper.language_word_dict.get('tab_menu_console_widget_tab_name')} "
184
- f"{ui_we_want_to_set.tab_widget.count()}")
260
+ f"{ui_we_want_to_set.tab_widget.count()}"
261
+ )
262
+
185
263
 
186
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
187
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
188
270
  ui_we_want_to_set.tab_widget.addTab(
189
- DiffViewerWidget(),
271
+ DiffViewerWidget(), # 建立程式碼比對元件 / Create Code Diff Viewer widget
190
272
  f"{language_wrapper.language_word_dict.get('tab_code_diff_viewer_tab_name')} "
191
- f"{ui_we_want_to_set.tab_widget.count()}")
273
+ f"{ui_we_want_to_set.tab_widget.count()}"
274
+ )