a Z^c@sddlZddlmZddlmZddlmZgdZdaddZ dd Z Gd d d eZ Gd d d Z e dkrddlmZedddddS)iN) messagebox) EditorWindow)iomenu)zfile "([^"]*)", line (\d+)z([^\s]+)\((\d+)\)z^(\s*\S.*?):\s*(\d+):z([^\s]+):\s*(\d+):z^\s*(\S.*?):\s*(\d+):cCsddtDadS)NcSsg|]}t|tjqS)reZcompileZ IGNORECASE)Z.0Zpatrr&/usr/lib64/python3.9/idlelib/outwin.pyZ sz!compile_progs..)file_line_patsfile_line_progsrrrr compile_progssrc Csts ttD]V}||}|r|dd\}}zt|d}|WqjWqtybYqYq0qdSz|t|fWStyYdS0dS)NiZr) rrZsearchZgroupZopenZcloseZOSErrorZintZ TypeError)lineZprogZmatchfilenamelinenoZfrrrfile_line_helpers"      r c@sdeZdZgdZdZddZddZddZd d Zdd dZ ddZ ddZ ddZ dddZ dS) OutputWindow))ZCutz<>Zrmenu_check_cut)ZCopyz<>Zrmenu_check_copy)ZPastez <>Zrmenu_check_paste)NNN)zGo to file/line<>NFcGs&tj|g|R|jd|jdS)Nr)r__init__textZbindgoto_file_line)selfargsrrrrOszOutputWindow.__init__cCdS)NFr)rr rrrispythonsourceTzOutputWindow.ispythonsourcecCr)NZOutputrrrrr short_titleXrzOutputWindow.short_titlecCs|r dSdS)NZyesZno)Z get_savedrrrr maybesave\rzOutputWindow.maybesaverinsertcCsFt|tr|tjd}|j||||j||jt |S)NZreplace) Z isinstanceZbytesZdecoderZencodingrrZseeZupdateZlenrZsZtagsZmarkrrrwriteas    zOutputWindow.writecCs|D]}||qdSN)r)rZlinesr rrr writelinesxszOutputWindow.writelinescCsdSrrrrrrflush}rzOutputWindow.flushcOstj|i|dSr)r showerror)rrZkwargsrrrr!szOutputWindow.showerrorNcCsd|jdd}t|}|sJ|jdd}t|}|sJ|jdd|jddS|\}}|j||dS)Nzinsert linestartzinsert lineendzinsert -1line linestartzinsert -1line lineendzNo special linezTThe line you point at doesn't look like a valid file name followed by a line number.)Zparent)rZgetr r!flistZ gotofileline)rZeventr Zresultr r rrrrs zOutputWindow.goto_file_line)rrr)__name__ __module__ __qualname__Z rmenu_specsZallow_code_contextrrrrrrr r!rrrrrr;s  rc@s6eZdZddiddidZddZddZd d Zd S) OnDemandOutputWindowZ foregroundZbluez#007700)ZstdoutZstderrcCs||_d|_dSr)r"owin)rr"rrrrszOnDemandOutputWindow.__init__cCs"|js||j|||dSr)r'setuprrrrrrszOnDemandOutputWindow.writecCsXt|j|_}|j}|jD]\}}|r |j|fi|q |d|jj|_dS)NZsel) rr"r'rtagdefsZitemsZ tag_configureZ tag_raiser)rr'rZtagZcnfrrrr(s zOnDemandOutputWindow.setupN)r#r$r%r)rrr(rrrrr&s r&Z__main__)mainzidlelib.idle_test.test_outwinr F)Z verbosityZexit)rZtkinterrZidlelib.editorrZidlelibrrrrr rr&r#Zunittestr*rrrrZs    f