\dRdZddlZddlmZddlmZgdZdadZdZ Gdd eZ Gd d Z e d krdd l mZeddddSdS)z0Editor window that can serve as an output file. N) messagebox) EditorWindow)zfile "([^"]*)", line (\d+)z([^\s]+)\((\d+)\)z^(\s*\S.*?):\s*(\d+):z([^\s]+):\s*(\d+):z^\s*(\S.*?):\s*(\d+):c(dtDadS)z?Compile the patterns for matching to file name and line number.cLg|]!}tj|tj"S)recompile IGNORECASE).0pats ..\python\lib\idlelib\outwin.py z!compile_progs..s6222z#r}55222N)file_line_patsfile_line_progsrrr compile_progsrs$22"0222OOOrcVtsttD]h}||}|rO|dd\}} t |}|n#t $rYdwxYwidS |t|fS#t$rYdSwxYw)a-Extract file name and line number from line of text. Check if line of text contains one of the file/line patterns. If it does and if the file and line are valid, return a tuple of the file name and line number. If it doesn't match or if the file or line is invalid, return None. N) rrsearchgroupopencloseOSErrorint TypeError)lineprogmatchfilenamelinenofs r file_line_helperr#s    D!!  ${{1a00 Hf NN       tV$$ tts$#A55 BB B B('B(cXeZdZdZgdZdZdZdZdZdZ dd Z d Z d Z d Z ddZdS) OutputWindowzAn editor window that can serve as an output file. Also the future base class for the Python shell window. This class has no input facilities. Adds binding to open a file at a line to the text widget. ))Cutz<>rmenu_check_cut)Copyz<>rmenu_check_copy)Pastez <>rmenu_check_paste)NNN)zGo to file/line<>NFcjtj|g|R|jd|jdS)Nr,)r__init__textbindgoto_file_line)selfargss r r.zOutputWindow.__init__Ns;d*T**** +T-@AAAAArcdS)z6Python source is only part of output: do not colorize.Fr)r2r s r ispythonsourcezOutputWindow.ispythonsourceSsurcdS)zCustomize EditorWindow title.Outputrr2s r short_titlezOutputWindow.short_titleWsxrc2|rdndS)z;Customize EditorWindow to not display save file messagebox.yesno) get_savedr8s r maybesavezOutputWindow.maybesave[s((2uud2rrinsertct|tsJ|j||||j||jt |S)aWrite text to text widget. The text is inserted at the given index with the provided tags. The text widget is then scrolled to make it visible and updated to display it, giving the effect of seeing each line as it is added. Args: s: Text to insert into text widget. tags: Tuple of tag strings to apply on the insert. mark: Index for the insert. Return: Length of text inserted. ) isinstancestrr/r?seeupdate_idletaskslenr2stagsmarks r writezOutputWindow.write`sg !S!!!!! q$''' d ""$$$1vv rc:|D]}||dS)z"Write each item in lines iterable.N)rJ)r2linesrs r writelineszOutputWindow.writelinesvs0  D JJt      rcdS)z8No flushing needed as write() directly writes to widget.Nrr8s r flushzOutputWindow.flush{s rc(tj|i|dSN)r showerror)r2r3kwargss r rRzOutputWindow.showerrorsd-f-----rNc4|jdd}t|}|sK|jdd}t|}|s|dd|jdS|\}}|j||dS) aHandle request to open file/line. If the selected or previous line in the output window contains a file name and line number, then open that file name in a new window and position on the line number. Otherwise, display an error messagebox. zinsert 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.)parentN)r/getr#rRflist gotofileline)r2eventrresultr r!s r r1zOutputWindow.goto_file_linesy}}/1ABB!$'' 9==!:!8::D%d++F %C9 &&& !& &11111r)rr?rQ)__name__ __module__ __qualname____doc__ rmenu_specsallow_code_contextr.r5r9r>rJrMrOrRr1rrr r%r%:sKBBB 333 ,    ...222222rr%c2eZdZddiddidZdZdZdZdS) OnDemandOutputWindow foregroundbluez#007700)stdoutstderrc"||_d|_dSrQ)rWowin)r2rWs r r.zOnDemandOutputWindow.__init__s  rct|js||j|||dSrQ)rhsetuprJrFs r rJzOnDemandOutputWindow.writes7y  JJLLL 4&&&&&rct|jx|_}|j}|jD]\}}|r|j|fi||d|jj|_dS)Nsel) r%rWrhr/tagdefsitems tag_configure tag_raiserJ)r2rhr/tagcnfs r rjzOnDemandOutputWindow.setups' 333 Dy **,, / /HC /""3..#... uY_ rN)r[r\r]rmr.rJrjrrr rbrbs_!&) ),G ''' %%%%%rrb__main__)mainzidlelib.idle_test.test_outwinrF) verbosityexit)r^rtkinterridlelib.editorrrrrr#r%rbr[unittestrtrrr rzs ''''''2228a2a2a2a2a2<a2a2a2J%%%%%%%%4 zD (AEBBBBBBr