Skip to content

Commit 4d58258

Browse files
committed
update dev version
update dev version
1 parent c9d5ed5 commit 4d58258

File tree

8 files changed

+101
-51
lines changed

8 files changed

+101
-51
lines changed

exe/a.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
print("Hello World")
1+
print("Hello World")
2+
print(var)

je_editor/pyside_ui/code/code_process/code_exec.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import Union
99

1010
from PySide6.QtCore import QTimer
11+
from PySide6.QtGui import QTextCharFormat
1112
from PySide6.QtWidgets import QTextEdit
1213

1314
from je_editor.pyside_ui.code.running_process_manager import run_instance_manager
@@ -43,6 +44,7 @@ def __init__(
4344
self.main_window: EditorWidget = main_window
4445
self.compiler_path = None
4546
self.code_result: Union[QTextEdit, None] = None
47+
self.code_result_cursor: Union[QTextEdit.textCursor, None] = None
4648
self.timer: Union[QTimer, None] = None
4749
self.still_run_program = True
4850
self.process: Union[subprocess.Popen, None] = None
@@ -86,7 +88,6 @@ def exec_code(self, exec_file_name, exec_prefix: Union[str, list] = None) -> Non
8688
f"exec_prefix: {exec_prefix}")
8789
try:
8890
self.exit_program()
89-
self.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
9091
self.code_result.setPlainText("")
9192
file_path = Path(exec_file_name)
9293
reformat_os_file_path = str(file_path.absolute())
@@ -127,17 +128,23 @@ def exec_code(self, exec_file_name, exec_prefix: Union[str, list] = None) -> Non
127128
)
128129
self.read_program_error_output_from_thread.start()
129130
# show which file execute
130-
self.code_result.append(self.compiler_path + " " + reformat_os_file_path)
131+
text_cursor = self.code_result.textCursor()
132+
text_format = QTextCharFormat()
133+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
134+
text_cursor.insertText(self.compiler_path + " " + reformat_os_file_path, text_format)
135+
text_cursor.insertBlock()
131136
# start tkinter_ui update
132137
# start timer
133138
self.timer = QTimer(self.main_window)
134139
self.timer.setInterval(10)
135140
self.timer.timeout.connect(self.pull_text)
136141
self.timer.start()
137142
except Exception as error:
138-
self.code_result.setTextColor(actually_color_dict.get("error_output_color"))
139-
self.code_result.append(str(error))
140-
self.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
143+
text_cursor = self.code_result.textCursor()
144+
text_format = QTextCharFormat()
145+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
146+
text_cursor.insertText(str(error), text_format)
147+
text_cursor.insertBlock()
141148
if self.process is not None:
142149
self.process.terminate()
143150

@@ -151,19 +158,24 @@ def pull_text(self) -> None:
151158
jeditor_logger.info("ExecManager pull_text")
152159
# Pull text from queue and put in code result area
153160
try:
154-
self.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
155161
if not self.run_output_queue.empty():
156162
output_message = self.run_output_queue.get_nowait()
157163
output_message = str(output_message).strip()
158164
if output_message:
159-
self.code_result.append(output_message)
160-
self.code_result.setTextColor(actually_color_dict.get("error_output_color"))
165+
text_cursor = self.code_result.textCursor()
166+
text_format = QTextCharFormat()
167+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
168+
text_cursor.insertText(output_message, text_format)
169+
text_cursor.insertBlock()
161170
if not self.run_error_queue.empty():
162171
error_message = self.run_error_queue.get_nowait()
163172
error_message = str(error_message).strip()
164173
if error_message:
165-
self.code_result.append(error_message)
166-
self.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
174+
text_cursor = self.code_result.textCursor()
175+
text_format = QTextCharFormat()
176+
text_format.setForeground(actually_color_dict.get("error_output_color"))
177+
text_cursor.insertText(error_message, text_format)
178+
text_cursor.insertBlock()
167179
except queue.Empty:
168180
pass
169181
if self.process.returncode == 0:
@@ -185,7 +197,11 @@ def exit_program(self) -> None:
185197
self.print_and_clear_queue()
186198
if self.process is not None:
187199
self.process.terminate()
188-
self.code_result.append(f"Program exit with code {self.process.returncode}")
200+
text_cursor = self.code_result.textCursor()
201+
text_format = QTextCharFormat()
202+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
203+
text_cursor.insertText(f"Program exit with code {self.process.returncode}", text_format)
204+
text_cursor.insertBlock()
189205
self.process = None
190206

191207
# Pull all remain string on queue and add to code result area

je_editor/pyside_ui/code/shell_process/shell_exec.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Union, Callable
1111

1212
from PySide6.QtCore import QTimer
13+
from PySide6.QtGui import QTextCharFormat
1314
from PySide6.QtWidgets import QTextEdit
1415

1516
from je_editor.pyside_ui.code.running_process_manager import run_instance_manager
@@ -48,8 +49,8 @@ def __init__(
4849
self.timer: Union[QTimer, None] = None
4950
self.still_run_shell: bool = True
5051
self.process = None
51-
self.run_output_queue: queue = queue.Queue()
52-
self.run_error_queue: queue = queue.Queue()
52+
self.run_output_queue: queue.Queue = queue.Queue()
53+
self.run_error_queue: queue.Queue = queue.Queue()
5354
self.program_encoding: str = shell_encoding
5455
self.program_buffer: int = program_buffer
5556
self.after_done_function = after_done_function
@@ -75,21 +76,24 @@ def later_init(self) -> None:
7576
else:
7677
raise JEditorException(je_editor_init_error)
7778

78-
def exec_shell(self, shell_command: [str, list]) -> None:
79+
def exec_shell(self, shell_command: Union[str, list]) -> None:
7980
"""
8081
:param shell_command: shell command will run
8182
:return: if error return result and True else return result and False
8283
"""
8384
jeditor_logger.info(f"ShellManager exec_shell, shell_command: {shell_command}")
8485
try:
8586
self.exit_program()
86-
self.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
8787
self.code_result.setPlainText("")
8888
if sys.platform in ["win32", "cygwin", "msys"]:
8989
args = shell_command
9090
else:
9191
args = shlex.split(shell_command)
92-
self.code_result.append(str(args))
92+
text_cursor = self.code_result.textCursor()
93+
text_format = QTextCharFormat()
94+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
95+
text_cursor.insertText(str(args), text_format)
96+
text_cursor.insertBlock()
9397
self.process = subprocess.Popen(
9498
args=args,
9599
stdout=subprocess.PIPE,
@@ -116,29 +120,36 @@ def exec_shell(self, shell_command: [str, list]) -> None:
116120
self.timer.timeout.connect(self.pull_text)
117121
self.timer.start()
118122
except Exception as error:
119-
self.code_result.setTextColor(actually_color_dict.get("error_output_color"))
120-
self.code_result.append(str(error))
121-
self.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
123+
text_cursor = self.code_result.textCursor()
124+
text_format = QTextCharFormat()
125+
text_format.setForeground(actually_color_dict.get("error_output_color"))
126+
text_cursor.insertText(str(error), text_format)
127+
text_cursor.insertBlock()
122128
if self.process is not None:
123129
self.process.terminate()
124130

125131
# tkinter_ui update method
126132
def pull_text(self) -> None:
127133
jeditor_logger.info("ShellManager pull_text")
128134
try:
129-
self.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
130135
if not self.run_output_queue.empty():
131136
output_message = self.run_output_queue.get_nowait()
132137
output_message = str(output_message).strip()
133138
if output_message:
134-
self.code_result.append(output_message)
135-
self.code_result.setTextColor(actually_color_dict.get("error_output_color"))
139+
text_cursor = self.code_result.textCursor()
140+
text_format = QTextCharFormat()
141+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
142+
text_cursor.insertText(output_message, text_format)
143+
text_cursor.insertBlock()
136144
if not self.run_error_queue.empty():
137145
error_message = self.run_error_queue.get_nowait()
138146
error_message = str(error_message).strip()
139147
if error_message:
140-
self.code_result.append(error_message)
141-
self.code_result.setTextColor(actually_color_dict.get("normal_output_color"))
148+
text_cursor = self.code_result.textCursor()
149+
text_format = QTextCharFormat()
150+
text_format.setForeground(actually_color_dict.get("error_output_color"))
151+
text_cursor.insertText(error_message, text_format)
152+
text_cursor.insertBlock()
142153
except queue.Empty:
143154
pass
144155
if self.process.returncode == 0:
@@ -168,7 +179,11 @@ def exit_program(self) -> None:
168179
self.print_and_clear_queue()
169180
if self.process is not None:
170181
self.process.terminate()
171-
self.code_result.append(f"Shell command exit with code {self.process.returncode}")
182+
text_cursor = self.code_result.textCursor()
183+
text_format = QTextCharFormat()
184+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
185+
text_cursor.insertText(f"Shell command exit with code {self.process.returncode}", text_format)
186+
text_cursor.insertBlock()
172187
self.process = None
173188

174189
def print_and_clear_queue(self) -> None:

je_editor/pyside_ui/main_ui/editor/editor_widget.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from typing import TYPE_CHECKING
44

5+
from PySide6.QtGui import QTextCharFormat
6+
57
from je_editor.utils.logging.loggin_instance import jeditor_logger
68
from je_editor.utils.multi_language.multi_language_wrapper import language_wrapper
79

@@ -38,7 +40,7 @@ def __init__(self, main_window: EditorMain):
3840
self.checker: Union[PEP8FormatChecker, None] = None
3941
self.current_file = None
4042
self.tree_view_scroll_area = None
41-
self.project_treeview = None
43+
self.project_treeview: Union[QTreeView, None] = None
4244
self.project_treeview_model = None
4345
self.python_compiler = None
4446
self.main_window = main_window
@@ -64,6 +66,7 @@ def __init__(self, main_window: EditorMain):
6466
# code edit and code result plaintext
6567
self.code_edit = CodeEditor(self)
6668
self.code_result = CodeRecord()
69+
self.code_result_cursor = self.code_result.textCursor()
6770
self.code_edit_scroll_area = QScrollArea()
6871
self.code_edit_scroll_area.setWidgetResizable(True)
6972
self.code_edit_scroll_area.setViewportMargins(0, 0, 0, 0)
@@ -74,7 +77,6 @@ def __init__(self, main_window: EditorMain):
7477
self.code_result_scroll_area.setWidget(self.code_result)
7578
# Code format checker
7679
self.format_check_result = CodeRecord()
77-
self.format_check_result.setTextColor(actually_color_dict.get("warning_output_color"))
7880
# Debugger
7981
self.debugger_result = CodeRecord()
8082
# Code result tab
@@ -192,7 +194,11 @@ def check_file_format(self):
192194
self.checker.check_all_format()
193195
self.format_check_result.setPlainText("")
194196
for error in self.checker.error_list:
195-
self.format_check_result.append(error)
197+
text_cursor = self.format_check_result.textCursor()
198+
text_format = QTextCharFormat()
199+
text_format.setForeground(actually_color_dict.get("error_output_color"))
200+
text_cursor.insertText(error, text_format)
201+
text_cursor.insertBlock()
196202
self.checker.error_list.clear()
197203
else:
198204
message_box = QMessageBox()

je_editor/pyside_ui/main_ui/main_editor.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import jedi.settings
88
from PySide6.QtCore import QTimer, QEvent
9-
from PySide6.QtGui import QFontDatabase, QIcon, Qt
9+
from PySide6.QtGui import QFontDatabase, QIcon, Qt, QTextCharFormat
1010
from PySide6.QtWidgets import QMainWindow, QWidget, QTabWidget, QMessageBox
1111
from frontengine import FrontEngineMainUI
1212
from qt_material import QtStyleTools
@@ -16,7 +16,7 @@
1616
from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
1717
from je_editor.pyside_ui.main_ui.menu.set_menu_bar import set_menu_bar
1818
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import write_user_color_setting, \
19-
read_user_color_setting, update_actually_color_dict
19+
read_user_color_setting, update_actually_color_dict, actually_color_dict
2020
from je_editor.pyside_ui.main_ui.save_settings.user_setting_file import user_setting_dict, read_user_setting, \
2121
write_user_setting
2222
from je_editor.pyside_ui.main_ui.system_tray.extend_system_tray import ExtendSystemTray
@@ -141,14 +141,20 @@ def redirect(self) -> None:
141141
output_message = redirect_manager_instance.std_out_queue.get_nowait()
142142
output_message = str(output_message).strip()
143143
if output_message:
144-
widget.code_result.append(output_message)
145-
widget.code_result.setTextColor(Qt.GlobalColor.red)
144+
text_cursor = self.code_result.textCursor()
145+
text_format = QTextCharFormat()
146+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
147+
text_cursor.insertText(output_message, text_format)
148+
text_cursor.insertBlock()
146149
if not redirect_manager_instance.std_err_queue.empty():
147150
error_message = redirect_manager_instance.std_err_queue.get_nowait()
148151
error_message = str(error_message).strip()
149152
if error_message:
150-
widget.code_result.append(error_message)
151-
widget.code_result.setTextColor(Qt.GlobalColor.black)
153+
text_cursor = self.code_result.textCursor()
154+
text_format = QTextCharFormat()
155+
text_format.setForeground(actually_color_dict.get("error_output_color"))
156+
text_cursor.insertText(error_message, text_format)
157+
text_cursor.insertBlock()
152158
break
153159

154160
def startup_setting(self) -> None:

je_editor/pyside_ui/main_ui/menu/python_env_menu/build_venv_menu.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from typing import TYPE_CHECKING
44

5+
from je_editor.pyside_ui.main_ui.save_settings.user_color_setting_file import actually_color_dict
6+
57
from je_editor.pyside_ui.main_ui.editor.editor_widget import EditorWidget
68
from je_editor.pyside_ui.main_ui.save_settings.user_setting_file import user_setting_dict
79
from je_editor.utils.logging.loggin_instance import jeditor_logger
@@ -11,7 +13,7 @@
1113
import os
1214
from pathlib import Path
1315

14-
from PySide6.QtGui import QAction, QKeySequence
16+
from PySide6.QtGui import QAction, QKeySequence, QTextCharFormat
1517
from PySide6.QtWidgets import QMessageBox, QInputDialog, QFileDialog
1618

1719
from je_editor.pyside_ui.code.shell_process.shell_exec import ShellManager
@@ -76,8 +78,12 @@ def create_venv(ui_we_want_to_set: EditorMain) -> None:
7678
create_venv_shell.exec_shell(
7779
[f"{create_venv_shell.compiler_path}", "-m", "venv", "venv"]
7880
)
79-
widget.code_result.append(
80-
language_wrapper.language_word_dict.get("python_env_menu_creating_venv_message"))
81+
text_cursor = widget.code_result.textCursor()
82+
text_format = QTextCharFormat()
83+
text_format.setForeground(actually_color_dict.get("normal_output_color"))
84+
text_cursor.insertText(
85+
language_wrapper.language_word_dict.get("python_env_menu_creating_venv_message"), text_format)
86+
text_cursor.insertBlock()
8187
else:
8288
message_box = QMessageBox()
8389
message_box.setText(

pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Rename to build stable version
2-
# This is stable version
1+
# Rename to build dev version
2+
# This is dev version
33
[build-system]
4-
requires = ["setuptools>=61.0"]
4+
requires = ["setuptools"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "je_editor"
9-
version = "0.0.213"
8+
name = "je_editor_dev"
9+
version = "0.0.236"
1010
authors = [
1111
{ name = "JE-Chen", email = "[email protected]" },
1212
]
@@ -23,11 +23,9 @@ classifiers = [
2323
"Environment :: Win32 (MS Windows)",
2424
"Environment :: MacOS X",
2525
"Environment :: X11 Applications",
26-
"License :: OSI Approved :: MIT License",
2726
"Operating System :: OS Independent"
2827
]
2928

30-
3129
[project.urls]
3230
Homepage = "https://github.com/JE-Chen/je_editor"
3331
Documentation = "https://je-editor.readthedocs.io/en/latest/"
@@ -37,5 +35,6 @@ Code = "https://github.com/JE-Chen/je_editor"
3735
file = "README.md"
3836
content-type = "text/markdown"
3937

38+
4039
[tool.setuptools.packages]
4140
find = { namespaces = false }

0 commit comments

Comments
 (0)