Skip to content

Commit 1a2fa42

Browse files
committed
Merge remote-tracking branch 'upstream/main' into jq/using-blessed-for-kitty
2 parents ac7fc7e + 7ae6fb0 commit 1a2fa42

6 files changed

Lines changed: 20 additions & 35 deletions

File tree

gambaterm/ansi_escape_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from string import ascii_lowercase, ascii_uppercase
77
from typing import Callable, Generator, TypeAlias, TypeVar, cast
88

9-
from asyncssh import SSHServerProcess, TerminalSizeChanged
9+
from asyncssh import SSHServerProcess, TerminalSizeChanged
1010

1111
T = TypeVar("T")
1212

gambaterm/blessed_keyboard_input.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,9 @@ def get_pressed() -> set[DomCode]:
6666
key = term.inkey(timeout=0)
6767
if not key:
6868
break
69-
# Ctrl+C
70-
ctrl = key.modifiers_bits & 4
71-
if (str(key) == "\x03"
72-
or key.key_name == "KEY_CTRL_C"
73-
or (ctrl and key.key_value == "c")):
69+
if key.key_name == "KEY_CTRL_C":
7470
raise KeyboardInterrupt
75-
# Ctrl+D
76-
if (str(key) == "\x04"
77-
or key.key_name == "KEY_CTRL_D"
78-
or (ctrl and key.key_value == "d")):
71+
if key.key_name == "KEY_CTRL_D":
7972
raise OSError
8073
# Cursor position response
8174
if _CPR_RE.match(str(key)):

gambaterm/keyboard_input.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ def get_input_mapping(console: Console) -> dict[DomCode, Console.Input]:
4343
DomCode.ARROW_DOWN: console.Input.DOWN,
4444
DomCode.ARROW_LEFT: console.Input.LEFT,
4545
DomCode.ARROW_RIGHT: console.Input.RIGHT,
46+
DomCode.NUMPAD8: console.Input.UP,
47+
DomCode.NUMPAD2: console.Input.DOWN,
48+
DomCode.NUMPAD4: console.Input.LEFT,
49+
DomCode.NUMPAD6: console.Input.RIGHT,
4650
DomCode.US_Z: console.Input.A,
4751
DomCode.US_X: console.Input.B,
4852
# WASD controls
@@ -154,7 +158,7 @@ def console_input_from_keyboard_context(
154158
if xdg_session_type is None:
155159
xdg_session_type = os.environ.get("XDG_SESSION_TYPE", "")
156160
if xdg_session_type != "x11":
157-
raise RuntimeError(MESSAGE_FOR_WAYLAND_USERS)
161+
raise RuntimeError(MESSAGE_SUGGESTING_KITTY_SUPPORT)
158162
with console_input_from_x11_keyboard_context(console, display) as get_input:
159163
yield get_input
160164
else:

gambaterm/pynput_keyboard_input.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def get_value_from_pynput_key_code(key: pynput.keyboard.KeyCode) -> DomCode | No
3434
assert False
3535

3636

37-
38-
3937
@contextmanager
4038
def pynput_key_pressed_context() -> Iterator[Callable[[], set[DomCode]]]:
4139
import pynput.keyboard

gambaterm/run.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,22 @@ def run(
133133
# Check terminal size
134134
new_height = term.height or 24
135135
new_width = term.width or 80
136-
maybe_clear_prefix, maybe_clear_suffix = b"", b""
136+
maybe_clear_seq = b""
137137
if (new_height, new_width) != (height, width):
138-
# Write video frame with clear sequence inside synchronized output mode (DEC
139-
# 2026) to prevent flicker, and, set last_frame as inverse of the current frame
140-
# to ensure a full redraw by the blitter
141-
maybe_clear_prefix = b"\033[?2026h\033[H\033[2J"
142-
maybe_clear_suffix = b"\033[?2026l"
138+
maybe_clear_seq = b"\033[H\033[2J"
143139
height, width = new_height, new_width
144140
refx, refy = get_ref(width, height, console)
145141
last_frame = ~video
146-
# Render frame
147-
video_data = maybe_clear_prefix + blit(
148-
video, last_frame, refx, refy, width - 1, height, color_mode
149-
) + maybe_clear_suffix
142+
# Render frame with synchronized output mode (DEC 2026) to prevent flickering
143+
# when the screen is cleared, or an artificial CRT-like "rolling band" side-effects
144+
# from fast "sprite blinking" meant to cause "transparency" effect on original HW,
145+
# https://zladx.github.io/posts/links-awakening-partial-translucency
146+
video_data = (
147+
b"\033[?2026h"
148+
+ maybe_clear_seq
149+
+ blit(video, last_frame, refx, refy, width - 1, height, color_mode)
150+
+ b"\033[?2026l"
151+
)
150152
last_frame = video.copy()
151153
# Update reporting
152154
data_length.append(len(video_data))

gambaterm/ssh.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ async def ssh_process_handler(process: SSHServerProcess[str]) -> int:
111111
executor: ThreadPoolExecutor = process.get_extra_info("executor")
112112
display = process.channel.get_x11_display()
113113
command = process.channel.get_command()
114-
environment = dict(process.channel.get_environment())
115114
terminal_type = process.get_terminal_type()
116115
connection = process.get_extra_info("connection")
117116
username = process.get_extra_info("username")
@@ -182,17 +181,6 @@ async def ssh_process_handler(process: SSHServerProcess[str]) -> int:
182181
else:
183182
color_mode = ColorMode.HAS_24_BIT_COLOR
184183

185-
if color_mode == ColorMode.NO_COLOR:
186-
print(
187-
f"Your terminal `{terminal_type}` doesn't seem to support colors.",
188-
f"Try to force a color mode by appending `-t -- --color-mode 3`"
189-
f" to the ssh command",
190-
sep="\r\n",
191-
file=process.stdout,
192-
)
193-
print(f"< User `{username}` terminal `{terminal_type}` does not support colors")
194-
return 1
195-
196184
# Now is a good time to instanciate the console
197185
# (it might fail if the ROM does not exist for instance)
198186
console = console_callback()

0 commit comments

Comments
 (0)