MCPcopy Index your code
hub / github.com/bpython/bpython / compress_paste_event

Function compress_paste_event

bpython/curtsiesfrontend/repl.py:2204–2220  ·  view source on GitHub ↗

If all events in a paste event are identical and not simple characters, returns one of them Useful for when the UI is running so slowly that repeated keypresses end up in a paste event. If we value not getting delayed and assume the user is holding down a key to produce such freque

(paste_event)

Source from the content-addressed store, hash-verified

2202
2203
2204def compress_paste_event(paste_event):
2205 """If all events in a paste event are identical and not simple characters,
2206 returns one of them
2207
2208 Useful for when the UI is running so slowly that repeated keypresses end up
2209 in a paste event. If we value not getting delayed and assume the user is
2210 holding down a key to produce such frequent key events, it makes sense to
2211 drop some of the events.
2212 """
2213 if not all(paste_event.events[0] == e for e in paste_event.events):
2214 return None
2215 event = paste_event.events[0]
2216 # basically "is there a special curtsies names for this key?"
2217 if len(event) > 1:
2218 return event
2219 else:
2220 return None
2221
2222
2223def just_simple_events(event_list: Iterable[str | events.Event]) -> list[str]:

Callers 1

process_control_eventMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected