fix: refactor zoom level handling in BecConsoleRegistry for improved clarity

This commit is contained in:
2026-07-07 15:05:44 +02:00
committed by wakonig_k
parent de6b795591
commit 6067311789
@@ -76,14 +76,25 @@ class BecConsoleRegistry:
return
app.aboutToQuit.connect(self.clear, Qt.ConnectionType.UniqueConnection)
@staticmethod
def _apply_zoom_step(term: BecTerminal, direction: int) -> bool:
method_name = "zoom_in" if direction > 0 else "zoom_out"
method = getattr(term, method_name, None)
if not callable(method):
return False
method()
return True
@staticmethod
def _apply_zoom_level(term: BecTerminal, zoom_level: int) -> None:
if zoom_level > 0:
for _ in range(zoom_level):
term.zoom_in()
if not BecConsoleRegistry._apply_zoom_step(term, 1):
break
elif zoom_level < 0:
for _ in range(-zoom_level):
term.zoom_out()
if not BecConsoleRegistry._apply_zoom_step(term, -1):
break
@staticmethod
def _new_terminal_info(console: BecConsole) -> _TerminalOwnerInfo:
@@ -355,10 +366,12 @@ class BecConsoleRegistry:
if delta > 0:
for _ in range(delta):
info.instance.zoom_in()
if not self._apply_zoom_step(info.instance, 1):
return info.zoom_level
else:
for _ in range(-delta):
info.instance.zoom_out()
if not self._apply_zoom_step(info.instance, -1):
return info.zoom_level
info.zoom_level += delta
return info.zoom_level