gh-139167: Allow users to hook gen_colors function to pyrepl Reader
I'm working on using pyrepl for pdb (at least most of it). I like the real-time color rendering for user's code, but we need some modification for pdb. The user could type a pdb command or a piece of valid python code. The problem now is we have some pdb commands that are either keywords or builtins (continue, break, list). We probably want to make all pdb commands the same color.
In order to do that, we can create a customized gen_colors function for pdb - use the original gen_colors mostly, but with some extra checks on the first word.
However, there's no way to hook that into pyrepl now. I think this change should be trivial enough without breaking the existing code or making the code base too messy. We already have plenty of code that changes the Reader object at run-time so that won't be an exception either.
- Issue: gh-139167
@ambv could you take a look when you have some time? I believe you implemented the original feature for real-time color in REPL.
Friendly ping @ambv if you have some time to check this PR