
    dq                     P    d Z dZddlmZ ddlZddlZddlZddlmZ  G d d      Z	y)	Buffer class.z(Patrick K. O'Brien <pobrien@orbtech.com>   )Interpreter    N)documentc                   L    e Zd ZdZdZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zy)Bufferr   r   Nc                    t         xj                  dz  c_        t         j                  | _        t        i       | _        d| _        i | _        d| _        t        t        j                        | _	        t        j                  dd | _        	 	 | j                  j                  d       # t        $ r Y nw xY w	 	 | j                  j                  d       n# t        $ r Y nw xY w-| j                  |       y)zCreate a Buffer instance.r   )locals N.)r   idr   interpnameeditorseditorlistsysmodulespathsyspathremove
ValueErroropenselffilenames     ./usr/lib/python3/dist-packages/wx/py/buffer.py__init__zBuffer.__init__   s    		Q	))!,	CKK(xx{##B'   ##C(  
 			(s$   B) )	B54B5:C 	C"!C"c                 D    || _         || j                  |j                  <   y)zAdd an editor.N)r   r   r   )r   r   s     r   	addEditorzBuffer.addEditor(   s    "(VYY    c                 P    | j                   r| j                   j                         S y)z:Return True if text in editor has changed since last save.F)r   
hasChanged)r   s    r   r#   zBuffer.hasChanged-   s    ;;;;))++r!   c                     |syt         j                  j                  |      r| j                  |      | _        yd| _        y)zNew empty buffer.NT)osr   existsoverwriteConfirm	confirmedr   filepaths     r   newz
Buffer.new4   s1    77>>(#!228<DN!DNr!   c                    t        j                  |      | _        | j                  j                  xs dt	        | j
                        z   | _        | j                  j                  | _        | j                  j                  rR| j                  j                  | j                  vr0| j                  j                  d| j                  j                         | j                  j                  r:t        j                  j                  | j                  j                        rd| _        | j"                  r8| j                  j%                         }| j"                  j'                  | |       yy)zOpen file into buffer.z	Untitled:r   T)buffertextN)r   Documentdocr   strr   r   filebase
modulenamefiledirr   insertr*   r%   r   r&   r(   r   read
_setBuffer)r   r   r.   s      r   r   zBuffer.open=   s    $$X.HH%%E+DGG*D	((++ 88 0 0 DLL488#3#34880A0A!B!DN;;88==?DKK""$T": r!   c                      y)z%Confirm overwriting an existing file.F r)   s     r   r'   zBuffer.overwriteConfirmM   s    r!   c                    | j                   j                  }|syt        j                  j	                  |      sd| _        | j
                  s| j                  |      | _        | j
                  r[| j                   j                  | j                  j                                | j                  r| j                  j                          yyy)Save buffer.NT)r0   r*   r%   r   r&   r(   r'   writer   getTextsetSavePointr)   s     r   savezBuffer.saveQ   s    88$$ww~~h'!DN~~!228<DN>>HHNN4;;..01{{((*  r!   c                     t        j                  |      | _        | j                  j                  | _        | j                  j
                  | _        | j                          y)r;   N)r   r/   r0   r   r   r2   r3   r?   r   s     r   saveAszBuffer.saveAs_   s?    $$X.HH%%	((++		r!   c                    | j                   rt        | j                  d      syt        j                  }| j
                  t        _        | j                  j                         }|j                  dd      }|j                  dd      }| j                  xs | j                  }t        j                  |      }|j                  j                         }	 	 t        ||d      }	 t        ||       | j                   j                   j#                          | j                   j                   j%                  |       	 |t        _        t        j&                  D ]"  }|| j&                  vst        j&                  |= $ y#   xY w#   xY w# |t        _        t        j&                  D ]"  }|| j&                  vst        j&                  |= $ w xY w)zsUpdate the namespace for autocompletion and calltips.

        Return True if updated, False if there was an error.r=   Fz

execT)r   hasattrr   r   r   r   r=   replacer3   r   types
ModuleType__dict__copycompilerE   r
   clearupdater   )r   r   r.   r   modulenewspacecodems           r   updateNamespacezBuffer.updateNamespacef   sg    {{'$++y"A((<<{{""$||FD)||D$'+$))!!$'??'')	'tT62	T8$ ""((*""))(3CH[[ 'DLL(A' CH[[ 'DLL(A's7   E7  E= ,A	F 7E::F =F  F -G1G)N)__name__
__module____qualname____doc__r   r   r    r#   r+   r   r'   r?   rA   rS   r9   r!   r   r   r      s7    	
B,)
"; +"'r!   r   )
rW   
__author__interpreterr   rH   r%   r   r   r   r   r9   r!   r   <module>rZ      s(    7
 $  	 
 {' {'r!   