This simply can be implemented. The example how can it be done is here https://gist.githubusercontent.com/o-murphy/c18342302a2ab09a9d8bfbf086248797/raw/21e54ab26eb3961086ef2d93b4ba1c9e8aa1bfb5/pythonista_ansi_patch.py