ó
vA¤\c           @  sŽ   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d a
 d „  Z d e d	 „ Z d S(
   iÿÿÿÿ(   t   print_functionNt   Editorc           B  s>   e  Z d  Z e d „ Z d „  Z d d „ Z e Z d „  Z	 RS(   sX  
    This class is intended to be subclassed by editor subclasses. It provides a
    number of editor related operations, which are called by Ren'Py (including
    the Ren'Py Launcher).

    Editor operations are grouped into transactions. An editor transaction
    starts with a call to the begin() method. Ren'Py will then call some number
    of command methods, each causing an operation to occur in the editor. Ren'Py
    will call end() at the end of the transaction.

    Although not required, it's reasonable than an implementation of this class
    will batch the files together and send them to the editor at once. It's also
    reasonable that an implementation will send the operations one at a time (and
    do little-to-nothing in begin() and end().

    Each operation takes a path to operate on. If the editor has a buffer
    corresponding to that path, that buffer is used. Otherwise, the editor
    is implicitly opened.

    We reserve the right to add new keyword arguments to methods of this class,
    so please ensure that subclasses accept and ignore unknown keyword
    arguments.
    c         K  s   d S(   sÙ   
        Begins an editor transaction.

        `new_window`
            If True, a new editor window will be created and presented to the
            user. Otherwise, and existing editor window will be used.
        N(    (   t   selft
   new_windowt   kwargs(    (    s   renpy/editor.pyt   begin7   s    c         K  s   d S(   s-   
        Ends an editor transaction.
        N(    (   R   R   (    (    s   renpy/editor.pyt   end@   s    c         K  s   d S(   sk  
        Ensures `filename` is open in the editor. This may be called multiple
        times per transaction.

        `line`
            If not None, this should be a line number to open in the
            editor.

        The first open call in a transaction is somewhat special - that file
        should be given focus in a tabbed editor environment.
        N(    (   R   t   filenamet   lineR   (    (    s   renpy/editor.pyt   openE   s    c         C  s   d S(   s?   
        Opens `directory` as a project in the editor.
        N(    (   R   t	   directory(    (    s   renpy/editor.pyt   open_projectU   s    N(
   t   __name__t
   __module__t   __doc__t   FalseR   R   t   NoneR	   t   has_projectsR   (    (    (    s   renpy/editor.pyR      s   		t   SystemEditorc           B  s   e  Z d d  „ Z RS(   c         K  s…   t  j j | ƒ } y[ t  j r. t j | ƒ n> t  j rM t j d | g ƒ n t  j	 rl t j d | g ƒ n  Wn t
 j ƒ  n Xd  S(   NR	   s   xdg-open(   t   renpyt   exportst   fsencodet   windowst   ost	   startfilet	   macintosht
   subprocesst   callt   linuxt	   tracebackt	   print_exc(   R   R   R   R   (    (    s   renpy/editor.pyR	   ]   s    			N(   R   R   R   R	   (    (    (    s   renpy/editor.pyR   [   s   c          B  s±   e  ƒ  a e j j d d ƒ }  |  d k r. d Se |  d ƒ  } | j ƒ  } Wd QXe | |  d ƒ } i |  d 6} | | | Ud | k r˜ | d ƒ  a d Se	 d j
 |  ƒ ƒ ‚ d S(   sY   
    Creates the editor object, based on the contents of the RENPY_EDIT_PY
    file.
    t   RENPY_EDIT_PYNt   rt   exect   __file__R   s#   {0} did not define an Editor class.(   R   t   editorR   t   environt   getR   R	   t   readt   compilet	   Exceptiont   format(   t   patht   ft   sourcet   codet   scope(    (    s   renpy/editor.pyt   initq   s    	
i   c         C  sº   t  j r t St d k r# t ƒ  n  t d k r3 t Sg  |  D] } t  j j | ƒ ^ q: }  yI t j	 d | ƒ x$ |  D] } t j
 | | ƒ d } qr Wt j ƒ  t SWn t j ƒ  t SXd S(   s+   
    Causes the editor to be launched.
    R   N(   R   t   mobilet   TrueR#   R   R/   R   t   parsert   unelide_filenameR   R	   R   R   R   (   t	   filenamesR   t	   transientt   i(    (    s   renpy/editor.pyt   launch_editorŽ   s"    	
%


(   t
   __future__R    R   R   R   R   t   objectR   R   R   R#   R/   R   R7   (    (    (    s   renpy/editor.pyt   <module>   s   =	