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)
| 2202 | |
| 2203 | |
| 2204 | def 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 | |
| 2223 | def just_simple_events(event_list: Iterable[str | events.Event]) -> list[str]: |
no outgoing calls
no test coverage detected