-
Notifications
You must be signed in to change notification settings - Fork 9
Filter ANSI escape sequences for terminal colors as a new term type #180
Description
Describe the feature you'd like
byexample uses pyte to interpret all the ANSI escape sequences coming from the interpreter. But pyte is not cheap and introduces some artifacts in the output like truncated lines.
Some interpreters however doesn't use the full set of possible escape sequences. In the happier case, they would use only the escape sequences to add some coloring to their output.
These sequences don't change the final layout so filter them will yield the same result except colorless. This is what pyte does and it could be implemented directly in byexample with a simple regex.
To be backward compatible the new filter-the-colors mode could be added as a new terminal type
Lines 546 to 551 in a084bd6
| if options['term'] == 'dumb': | |
| out = self._emulate_dumb_terminal(self._output_between_prompts) | |
| elif options['term'] == 'ansi': | |
| out = self._emulate_ansi_terminal(self._output_between_prompts) | |
| elif options['term'] == 'as-is': | |
| out = self._emulate_as_is_terminal(self._output_between_prompts) |
dump and ansi.
We could make the change non-backward compatible and add the filtering in dump as it is unclear how many people could be really testing ANSI escape sequences in their examples.