fix: update ctrl c for qtermwidget

This commit is contained in:
2026-07-07 15:05:44 +02:00
committed by wakonig_k
parent 6cf075c3ae
commit c9d05e42f7
4 changed files with 31 additions and 5 deletions
@@ -329,7 +329,8 @@ class DeveloperWidget(DockAreaWidget):
"""Stop the execution of the currently running script"""
if not self.current_script_id:
return
self.console.send_ctrl_c()
if self.console.term is not None:
self.console.term.send_ctrl_c()
@property
def current_script_id(self):
@@ -397,7 +397,7 @@ class BecConsole(BECWidget, QWidget):
def _set_up_instance(self):
"""
Set up the web instance and UI elements.
Set up the console instance.
"""
self._stacked_layout = QStackedLayout()
# self._stacked_layout.setStackingMode(QStackedLayout.StackingMode.StackAll)
@@ -434,7 +434,7 @@ class BecConsole(BECWidget, QWidget):
def _set_mode(self, mode: ConsoleMode):
"""
Set the mode of the web console.
Set the mode of the console.
Args:
mode (ConsoleMode): The mode to set.
@@ -508,7 +508,7 @@ class BecConsole(BECWidget, QWidget):
def take_terminal_ownership(self):
"""
Take ownership of a web instance from the registry. This will transfer the instance
Take ownership of a console instance from the registry. This will transfer the instance
from its current owner (if any) to this widget.
"""
# Get the instance from registry
@@ -520,7 +520,7 @@ class BecConsole(BECWidget, QWidget):
def yield_ownership(self):
"""
Yield ownership of the instance. The instance remains in the registry with no owner,
Yield ownership of the console instance. The instance remains in the registry with no owner,
available for another widget to claim. This is automatically called when the
widget becomes hidden.
"""
@@ -6,3 +6,9 @@ class BecTerminal(Protocol):
"""Implementors of this protocol must also be subclasses of QWidget"""
def write(self, text: str, add_newline: bool = True): ...
def zoom_in(self): ...
def zoom_out(self): ...
def send_ctrl_c(self): ...
@@ -74,10 +74,29 @@ class BecQTerm(QWidget):
self._layout.addWidget(self._main_widget)
def write(self, text: str, add_newline: bool = True):
"""
Write text to the terminal.
Args:
text (str): The text to write.
add_newline (bool): Whether to add a newline at the end.
"""
if add_newline:
text += "\n"
self._sendText(text)
def zoom_in(self):
"""Zoom in the terminal font size."""
self._zoomIn()
def zoom_out(self):
"""Zoom out the terminal font size."""
self._zoomOut()
def send_ctrl_c(self):
"""Send Ctrl+C to the terminal."""
self.write("\x03", add_newline=False) # Send Ctrl+C character to the terminal
# automatically forwarded to the widget only if it exists
@_forward
def _addCustomColorSchemeDir(self, custom_dir: str, /) -> None: ...