pyte icon indicating copy to clipboard operation
pyte copied to clipboard

Support progressive enhencements

Open deathaxe opened this issue 8 months ago • 5 comments

Resolves #194

This PR adds Screen.set_keyboard_flags() event handler, to handle progressive enhancement events.

The Screen class therefore maintains a stack of Screen.keybord_flags, which is managed by set_keybord_flags() handler, if Stream detects related CSI = flags ; mode u, CSI > flags u or CSI < count u escape sequences.

Sending proper key sequences to shell is up to a real terminal implementation, which can use Screen.keyboard_flags to query requested features.

This PR ensures not to pass through related escape sequences to buffer.

deathaxe avatar Apr 18 '25 17:04 deathaxe

Thanks @deathaxe. The CI configuration was not up to date. Would you mind rebasing on master?

superbobry avatar Apr 22 '25 09:04 superbobry

FWIW, KeyboardFlags could be out-sourced to a keyboards.py or something alike, if it feels too misplaced in screens.py.

deathaxe avatar Apr 22 '25 16:04 deathaxe

Note that mypy is unhappy on the CI.

FWIW, KeyboardFlags could be out-sourced to a keyboards.py or something alike, if it feels too misplaced in screens.py.

Yeah, this sgtm.

superbobry avatar Apr 22 '25 18:04 superbobry

Well, I've rarely seen general *args and *kwargs being typed anywhere as they can contain arbritary number of arguments of any type. In this special case list[int] might work as this is what arguments of CSI sequences are defined as.

deathaxe avatar Apr 23 '25 06:04 deathaxe

An unfortunate issue with mypy is that it does not type check functions if any type hint is missing (at least not by default). I guess you could use object or Any?

superbobry avatar Apr 23 '25 11:04 superbobry