fix: osc block termination if terminator is sent char by char
This commit fixes an issue with lazygit not being rendered. It sends OSC block terminator sequence 0x1b\\ char by char (0x1b, \\) which was therefore not detected as such, before.
It applies relevant code lines from original pyte library's stream module.
see: https://github.com/selectel/pyte/blob/0718fa80887dc646c2121b6706b362cc8c594032/pyte/streams.py#L358-L375
This seems to be an alternative implementation to #463
Though I'm not sure why 0x1b\\ isn't included in OSC_TERMINATORS; per ECMA-48, it's a valid terminator. However, I just tested this and it also works just fine.
Well, 0x1b\\ == st.ST_C0 (see: https://github.com/randy3k/Terminus/pull/463/files#r2592172307).
The actual bug is how block is evaluated. In case byte stream from terminal app is interrupted between 0x1b and \\, the current implementation is not able to detect the combination of both.
I've dropped the OSC_PARAM stuff as it is basically just wrong. An OSC sequence starts with 0x1b], but the _osc_termination_pattern may result in block containing all other sorts unrelated of text and escape sequences up to an OSC sequence. That's what some debug prints with lazygit revealed.
Another reason is to align _fsm_parser with implementation of current releases of pyte.
Performance of pyte is terrible, regardless.
Thanks for the clarification! I spent a while studying standards while working on the OSC fix and still missed a few things it seems. While both our PR's solve the same problem, given the explanation, your solution is definitely a cleaner one.
Thanks for fixing it.