Skip to content

Commit ed703da

Browse files
committed
also set blessed's number_of_colors on cycle, even though it is unused
1 parent 63014ef commit ed703da

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

gambaterm/colors.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,24 @@ def report(self) -> str:
2424
"""Return a human-readable report of the color mode."""
2525
if self == ColorMode.COULD_NOT_DETECT:
2626
return "Could not detect color mode"
27+
if self == ColorMode.HAS_24_BIT_COLOR:
28+
return "True color"
29+
return f"{self.number_of_colors} colors"
30+
31+
def number_of_colors(self) -> int:
32+
"""Return a human-readable report of the color mode."""
33+
if self == ColorMode.COULD_NOT_DETECT:
34+
return 0
2735
if self == ColorMode.HAS_2_BIT_COLOR:
28-
return "4 colors"
36+
return 4
2937
if self == ColorMode.HAS_4_BIT_COLOR:
30-
return "16 colors"
38+
return 16
3139
if self == ColorMode.HAS_8_BIT_COLOR:
32-
return "256 colors"
40+
return 256
3341
if self == ColorMode.HAS_24_BIT_COLOR:
34-
return "True color"
42+
return 1 << 24
3543
assert False
3644

37-
3845
def detect_local_color_mode(term: Terminal) -> ColorMode:
3946
"""Detect the color mode of the local terminal using blessed."""
4047
n = term.number_of_colors

gambaterm/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def run(
162162
height, width = new_height, new_width
163163
refx, refy = get_ref(width, height, console)
164164
color_mode = new_color_mode
165+
term.number_of_colors = new_color_mode.number_of_colors()
165166
last_frame.fill(0)
166167

167168
# Render frame with synchronized output mode (DEC 2026) to prevent flickering

gambaterm/ssh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def ssh_terminal_handler(
217217
color_mode = app_config.color_mode or ColorMode.HAS_24_BIT_COLOR
218218

219219
print(
220-
f"[Terminal Info] {username}: {terminal_type}, {input_source}, {terminal.width}x{terminal.height}"
220+
f"[Terminal Info] {username}: term={terminal_type}, {input_source}, {terminal.width}x{terminal.height}"
221221
)
222222

223223
try:

gambaterm/telnet.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
is_kitty_keyboard_protocol_supported,
3434
)
3535
from .remote_terminal import RemoteTerminal
36-
from .telnet_app_session import (
37-
telnet_to_terminal,
38-
)
36+
from .telnet_app_session import telnet_to_terminal
3937

4038

4139
def _save_dir_name(username: str | None) -> str:
@@ -270,9 +268,7 @@ async def _telnet_shell(
270268

271269
cols = writer.get_extra_info("cols") or 80
272270
rows = writer.get_extra_info("rows") or 24
273-
print(
274-
f"[Terminal Info] {peer_host}: {terminal_type or 'unknown'}, " f"{cols}x{rows}"
275-
)
271+
print(f"[Terminal Info] {peer_host}: ttype={terminal_type}, {cols}x{rows}")
276272

277273
try:
278274
# Copy namespace and set telnet-specific save directory

0 commit comments

Comments
 (0)