Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /newedit/src/, /newedit/src/mixins/, /newedit/src/modules/

newedit
Discussion topic

Back to topic list

CVS update: /newedit/src/, /newedit/src/mixins/, /newedit/src/modules/

Reply

Author limodou
Full name limodou
Date 2005-02-06 03:46:23 PST
Message User: limodou
Date: 05/02/06 03:46:23

Modified:
 /newedit/src/
  ChangeLog.txt
 /newedit/src/mixins/
  DocumentBase.py, Editor.py, EditorFactory.py, HtmlPage.py, Import.py,
  mAutoCheck.py, mDDESupport.py, mEditorCtrl.py, mSession.py
 /newedit/src/modules/
  DDE.py

Log:
 delay open file

File Changes:

Directory: /newedit/src/
========================

File [changed]: ChangeLog.txt
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/ChangeLo​g.txt?r1=1.125&r​2=1.126
Delta lines: +7 -0
-------------------
--- ChangeLog.txt 30 Jan 2005 13:30:04 -0000 1.125
+++ ChangeLog.txt 6 Feb 2005 11:46:22 -0000 1.126
@@ -1,3 +1,10 @@
+[2005/02/06]
+EditorFactory.py mSession.py Editor.py mEditorCtrl.py
+ Æô¶¯Ê±±à¼­´°¿ÚµÄÎļþÑÓ³Ù´ò¿ª
+
+DDE.py mDDESupport.py
+ DDEÖ§³ÖʹÓÃCallAfter´¦Àí
+
 [2005/01/28]
 mPythonContextIndent.py
                 ÐÞÕýµ±Ñ¡ÖÐÎı¾Ê±£¬°´​»Ø³µ²»Çå³ýÎı¾µÄbug

Directory: /newedit/src/mixins/
===============================

File [changed]: DocumentBase.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/D​ocumentBase.py?r1=1.​9&r2=1.10
Delta lines: +4 -2
-------------------
--- DocumentBase.py 30 Jan 2005 13:30:21 -0000 1.9
+++ DocumentBase.py 6 Feb 2005 11:46:23 -0000 1.10
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: DocumentBase.py,v 1.9 2005/01/30 13:30:21 limodou Exp $
+# $Id: DocumentBase.py,v 1.10 2005/02/06 11:46:23 limodou Exp $
 
 __doc__ = 'Document base class'
 
@@ -74,10 +74,12 @@
         self.title = ''
         self.canopenfileflag = False
         self.canedit = False
+ self.opened = False
 
- def openfile(self, filename='', encoding=''):
+ def openfile(self, filename='', encoding='', delay=False):
         self.filename = filename
         self.locale = encoding
+ self.opened = False
 
     def savefile(self, filename, encoding):
         self.filename = filename

File [changed]: Editor.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/E​ditor.py?r1=1.49​&r2=1.50
Delta lines: +11 -2
--------------------
--- Editor.py 14 Oct 2004 03:27:12 -0000 1.49
+++ Editor.py 6 Feb 2005 11:46:23 -0000 1.50
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: Editor.py,v 1.49 2004/10/14 03:27:12 limodou Exp $
+# $Id: Editor.py,v 1.50 2005/02/06 11:46:23 limodou Exp $
 
 from modules import Mixin
 import wx
@@ -137,7 +137,14 @@
         else:
             return False
 
- def openfile(self, filename, encoding=None):
+ def openfile(self, filename, encoding=None, delay=False):
+ if delay:
+ self.filename = filename
+ self.encoding = encoding
+ self.opened = False
+
+ return
+
         self.callplugin('openfile', self, filename)
 
         oldfilename = self.filename
@@ -177,6 +184,8 @@
             self.settext = False
 
         self.callplugin('aft​eropenfile', self, filename)
+
+ self.opened = True
 
     def savefile(self, filename, encoding):
         self.callplugin('savefile', self, filename)

File [changed]: EditorFactory.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/E​ditorFactory.py?r1=1​.7&r2=1.8
Delta lines: +66 -28
---------------------
--- EditorFactory.py 21 Oct 2004 03:23:55 -0000 1.7
+++ EditorFactory.py 6 Feb 2005 11:46:23 -0000 1.8
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: EditorFactory.py,v 1.7 2004/10/21 03:23:55 limodou Exp $
+# $Id: EditorFactory.py,v 1.8 2005/02/06 11:46:23 limodou Exp $
 
 from modules import Mixin
 import wx
@@ -86,7 +86,24 @@
         for file in self.mainframe.filenames:
             self.new(os.path.joi​n(self.app.workpath,​ file))
 
- def changeDocument(self, document):
+ def changeDocument(self, document, delay=False):
+ if not delay:
+ #open delayed document
+ if not document.opened:
+ index = self.getIndex(document)
+ try:
+ document.openfile(do​cument.filename, document.encoding, False)
+ except MyUnicodeException, e:
+ error.traceback()
+ e.ShowMessage()
+ self.closefile(document)
+ return
+ except:
+ error.traceback()
+ filename = document.filename
+ self.closefile(document)
+ wx.MessageDialog(self, tr("Can't open the file [%s]!") % filename, tr("Open file..."), wx.OK).ShowModal()
+ return
         self.mainframe.document = document
         self.document = document
         self.showTitle(self.document)
@@ -98,23 +115,23 @@
         self.lastlanguagename = document.languagename
         self.lastdocument = document
         self.document.SetFocus()
-# self.document.Ensure​CaretVisible()
+ # self.document.Ensure​CaretVisible()
 
     def getIndex(self, document):
         return self.list.index(document)
 
- def new(self, filename='', encoding=''):
+ def new(self, filename='', encoding='', delay=False):
         if filename:
             for document in self.list: #if the file has been opened
                 if document.isMe(filename, documenttype = 'edit'):
- self.switch(document)
+ self.switch(document, delay)
                     return document
             else: #the file hasn't been opened
                 #if current page is empty and has not been modified
                 if (self.document != None) and self.document.canope​nfile(filename):
                     #use current page , donot open a new page
                     try:
- self.document.openfi​le(filename, encoding)
+ self.document.openfi​le(filename, encoding, delay)
                     except MyUnicodeException, e:
                         error.traceback()
                         e.ShowMessage()
@@ -124,14 +141,14 @@
                         wx.MessageDialog(self, tr("Can't open the file [%s]!") % filename, tr("Open file..."), wx.OK).ShowModal()
                         return self.document
 
- self.switch(self.document)
+ self.switch(self.document, delay)
                     return self.document
                 else:
- return self.newPage(filename, encoding)
+ return self.newPage(filename, encoding, delay=delay)
         else:
- return self.newPage(filename, encoding)
+ return self.newPage(filename, encoding, delay=delay)
 
- def newPage(self, filename, encoding=None, documenttype='edit', **kwargs):
+ def newPage(self, filename, encoding=None, documenttype='edit', delay=False, **kwargs):
         try:
             panelclass = self.panellist[documenttype]
         except:
@@ -141,7 +158,7 @@
         panel = panelclass(self, filename, **kwargs)
         document = panel.document
         try:
- document.openfile(filename, encoding)
+ document.openfile(filename, encoding, delay)
         except MyUnicodeException, e:
             error.traceback()
             e.ShowMessage()
@@ -158,7 +175,7 @@
         imageindex = self.imageindex.get(​document.pageimagena​me, -1)
         if imageindex > -1:
             self.SetPageImage(se​lf.GetPageCount() - 1, imageindex)
- self.switch(document)
+ self.switch(document, delay)
 
         return document
 
@@ -183,11 +200,12 @@
         elif eid == self.IDPM_FILE_SAVE_AS:
             self.mainframe.OnFil​eSaveAs(event)
 
- def switch(self, document):
+ def switch(self, document, delay=False):
+ if not delay:
         index = self.getIndex(document)
         self.SetSelection(index)
         self.showPageTitle(document)
- self.changeDocument(document)
+ self.changeDocument(document, delay)
 
     def getDispTitle(self, ctrl):
         if ctrl.title:
@@ -217,4 +235,24 @@
         if title != self.mainframe.GetTitle():
             self.mainframe.SetTitle(title)
 
+ def closefile(self, document):
+ index = self.getIndex(document)
+ self.DeletePage(index)
+ self.list.pop(index)
+ if index >= len(self.list):
+ index = len(self.list)-1
+ if index >= 0:
+ self.switch(self.list[index])
 
+ def savefile(self, document, filename, encoding):
+ try:
+ document.savefile(filename, encoding)
+ self.switch(document)
+ except MyUnicodeException, e:
+ error.traceback()
+ e.ShowMessage()
+ return False
+ except:
+ error.traceback()
+ return False
+ return True

File [changed]: HtmlPage.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/H​tmlPage.py?r1=1.4​&r2=1.5
Delta lines: +2 -2
-------------------
--- HtmlPage.py 14 Oct 2004 03:27:12 -0000 1.4
+++ HtmlPage.py 6 Feb 2005 11:46:23 -0000 1.5
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: HtmlPage.py,v 1.4 2004/10/14 03:27:12 limodou Exp $
+# $Id: HtmlPage.py,v 1.5 2005/02/06 11:46:23 limodou Exp $
 
 from modules import Mixin
 import DocumentBase
@@ -127,7 +127,7 @@
         wx.EVT_UPDATE_UI(self.btnBack, self.ID_BACK, self.OnUpdateUI)
         wx.EVT_UPDATE_UI(sel​f.btnForward, self.ID_FORWARD, self.OnUpdateUI)
 
- def openfile(self, filename='', encoding=''):
+ def openfile(self, filename='', encoding='', delay=False):
         self.filename = filename
         self.html.Load(self.filename)
         self.locale = encoding

File [changed]: Import.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/I​mport.py?r1=1.67​&r2=1.68
Delta lines: +10 -29
---------------------
--- Import.py 30 Jan 2005 13:30:21 -0000 1.67
+++ Import.py 6 Feb 2005 11:46:23 -0000 1.68
@@ -20,7 +20,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: Import.py,v 1.67 2005/01/30 13:30:21 limodou Exp $
+# $Id: Import.py,v 1.68 2005/02/06 11:46:23 limodou Exp $
 
 
 #----------------------- mPreference.py ------------------
@@ -258,13 +258,7 @@
     if checkonly == False:
         win.editctrl.lastdocument = None
         win.callplugin('closefile', win, document.filename)
- index = win.editctrl.getIndex(document)
- win.editctrl.DeletePage(index)
- win.editctrl.list.pop(index)
- if index >= len(win.editctrl.list):
- index = len(win.editctrl.list)-1
- if index >= 0:
- win.editctrl.switch(​win.editctrl.list[in​dex])
+ win.editctrl.closefi​le(document)
     return answer
 Mixin.setMixin('mainframe', 'CloseFile', CloseFile)
 
@@ -305,17 +299,7 @@
     else:
         filename = ctrl.filename
 
- try:
- ctrl.savefile(filename, encoding)
- ctrl.editctrl.switch(ctrl)
- except MyUnicodeException, e:
- error.traceback()
- e.ShowMessage()
- return False
- except:
- error.traceback()
- return False
- return True
+ return win.editctrl.savefile(ctrl, filename, encoding)
 Mixin.setMixin('mainframe', 'SaveFile', SaveFile)
 
 def init(pref):
@@ -2425,13 +2409,14 @@
     n = 0
     if win.mainframe.pref.load_session and not win.mainframe.app.sk​ipsessionfile:
         for filename, row, col, bookmarks in win.mainframe.pref.sessions:
- document = win.new(filename)
+ document = win.new(filename, delay=True)
             if document:
                 setStatus(document, row, col, bookmarks)
                 n += 1
         index = win.mainframe.pref.l​ast_tab_index
         if index > -1 and index < len(win.list):
- win.switch(win.list[index])
+ wx.CallAfter(win.switch, win.list[index], delay=False)
+
     return n > 0
 Mixin.setPlugin('editctrl', 'openpage', openPage)
 
@@ -3447,7 +3432,7 @@
 def on_idle(win, event):
     if win.pref.auto_check:
         for document in win.editctrl.list:
- if document.filename and document.documenttype == 'edit':
+ if document.filename and document.documenttype == 'edit' and document.opened:
                 if not checkFilename(win, document):
                     if getModifyTime(docume​nt.filename) > win.editctrl.filetim​es[document.filename​]:
                         dlg = wx.MessageDialog(win, tr("This file [%s] has been modified by others,\ndo you like reload it?") % document.filename, tr("Check"), wx.YES_NO | wx.ICON_QUESTION)
@@ -3927,17 +3912,13 @@
     win.readfiles = []
 Mixin.setPlugin('mainframe', 'init', init)
 
-def on_idle(win, event):
- if win.readfiles:
- from modules.Debug import error
-
- error.info('files=' + ','.join(win.readfiles))
- for filename in win.readfiles:
+def openfiles(win, files):
+ if files:
+ for filename in files:
             win.editctrl.new(filename)
- win.readfiles = []
         win.Show()
         win.Raise()
-Mixin.setPlugin('mainframe', 'on_idle', on_idle)
+Mixin.setMixin('mainframe', 'openfiles', openfiles)
 
 
 

File [changed]: mAutoCheck.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/m​AutoCheck.py?r1=1.5​&r2=1.6
Delta lines: +2 -2
-------------------
--- mAutoCheck.py 14 Oct 2004 13:17:13 -0000 1.5
+++ mAutoCheck.py 6 Feb 2005 11:46:23 -0000 1.6
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: mAutoCheck.py,v 1.5 2004/10/14 13:17:13 limodou Exp $
+# $Id: mAutoCheck.py,v 1.6 2005/02/06 11:46:23 limodou Exp $
 
 __doc__ = 'Auto check if the file is modified'
 
@@ -39,7 +39,7 @@
 def on_idle(win, event):
     if win.pref.auto_check:
         for document in win.editctrl.list:
- if document.filename and document.documenttype == 'edit':
+ if document.filename and document.documenttype == 'edit' and document.opened:
                 if not checkFilename(win, document):
                     if getModifyTime(docume​nt.filename) > win.editctrl.filetim​es[document.filename​]:
                         dlg = wx.MessageDialog(win, tr("This file [%s] has been modified by others,\ndo you like reload it?") % document.filename, tr("Check"), wx.YES_NO | wx.ICON_QUESTION)

File [changed]: mDDESupport.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/m​DDESupport.py?r1=1.4​&r2=1.5
Delta lines: +5 -9
-------------------
--- mDDESupport.py 14 Oct 2004 03:27:12 -0000 1.4
+++ mDDESupport.py 6 Feb 2005 11:46:23 -0000 1.5
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: mDDESupport.py,v 1.4 2004/10/14 03:27:12 limodou Exp $
+# $Id: mDDESupport.py,v 1.5 2005/02/06 11:46:23 limodou Exp $
 
 __doc__ = 'simulate DDE support'
 
@@ -47,15 +47,11 @@
     win.readfiles = []
 Mixin.setPlugin('mainframe', 'init', init)
 
-def on_idle(win, event):
- if win.readfiles:
- from modules.Debug import error
-
- error.info('files=' + ','.join(win.readfiles))
- for filename in win.readfiles:
+def openfiles(win, files):
+ if files:
+ for filename in files:
             win.editctrl.new(filename)
- win.readfiles = []
         win.Show()
         win.Raise()
-Mixin.setPlugin('mainframe', 'on_idle', on_idle)
+Mixin.setMixin('mainframe', 'openfiles', openfiles)
 

File [changed]: mEditorCtrl.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/m​EditorCtrl.py?r1=1.1​0&r2=1.11
Delta lines: +3 -19
--------------------
--- mEditorCtrl.py 23 Dec 2004 15:41:58 -0000 1.10
+++ mEditorCtrl.py 6 Feb 2005 11:46:23 -0000 1.11
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: mEditorCtrl.py,v 1.10 2004/12/23 15:41:58 limodou Exp $
+# $Id: mEditorCtrl.py,v 1.11 2005/02/06 11:46:23 limodou Exp $
 
 from modules import Mixin
 import wx
@@ -168,13 +168,7 @@
     if checkonly == False:
         win.editctrl.lastdocument = None
         win.callplugin('closefile', win, document.filename)
- index = win.editctrl.getIndex(document)
- win.editctrl.DeletePage(index)
- win.editctrl.list.pop(index)
- if index >= len(win.editctrl.list):
- index = len(win.editctrl.list)-1
- if index >= 0:
- win.editctrl.switch(​win.editctrl.list[in​dex])
+ win.editctrl.closefi​le(document)
     return answer
 Mixin.setMixin('mainframe', 'CloseFile', CloseFile)
 
@@ -215,17 +209,7 @@
     else:
         filename = ctrl.filename
 
- try:
- ctrl.savefile(filename, encoding)
- ctrl.editctrl.switch(ctrl)
- except MyUnicodeException, e:
- error.traceback()
- e.ShowMessage()
- return False
- except:
- error.traceback()
- return False
- return True
+ return win.editctrl.savefile(ctrl, filename, encoding)
 Mixin.setMixin('mainframe', 'SaveFile', SaveFile)
 
 def init(pref):

File [changed]: mSession.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/m​Session.py?r1=1.5​&r2=1.6
Delta lines: +10 -3
--------------------
--- mSession.py 14 Oct 2004 03:27:12 -0000 1.5
+++ mSession.py 6 Feb 2005 11:46:23 -0000 1.6
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: mSession.py,v 1.5 2004/10/14 03:27:12 limodou Exp $
+# $Id: mSession.py,v 1.6 2005/02/06 11:46:23 limodou Exp $
 
 from modules import Mixin
 import wx
@@ -73,13 +73,20 @@
     n = 0
     if win.mainframe.pref.load_session and not win.mainframe.app.sk​ipsessionfile:
         for filename, row, col, bookmarks in win.mainframe.pref.sessions:
- document = win.new(filename)
+ document = win.new(filename, delay=True)
             if document:
                 setStatus(document, row, col, bookmarks)
                 n += 1
         index = win.mainframe.pref.l​ast_tab_index
         if index > -1 and index < len(win.list):
- win.switch(win.list[index])
+ wx.CallAfter(win.switch, win.list[index], delay=False)
+# while 1:
+# try:
+# win.switch(win.list[index], delay=False)
+# break
+# except:
+# index=len(win.list)-1
+
     return n > 0
 Mixin.setPlugin('editctrl', 'openpage', openPage)
 

Directory: /newedit/src/modules/
====================​============

File [changed]: DDE.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​DDE.py?r1=1.9&r2​=1.10
Delta lines: +3 -2
-------------------
--- DDE.py 30 Jan 2005 13:30:21 -0000 1.9
+++ DDE.py 6 Feb 2005 11:46:23 -0000 1.10
@@ -19,12 +19,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: DDE.py,v 1.9 2005/01/30 13:30:21 limodou Exp $
+# $Id: DDE.py,v 1.10 2005/02/06 11:46:23 limodou Exp $
 
 from socket import *
 import threading
 import traceback
 from Debug import error
+import wx
 
 ADDR = '127.0.0.1'
 PORT = 50000
@@ -61,7 +62,7 @@
                 if cmd == 'data':
 # print 'data'
                     if app:
- app.frame.readfiles = lines[1:]
+ wx.CallAfter(app.fra​me.openfiles, lines[1:])
                 elif cmd == 'stop':
 # print 'stop'
                     break




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@newe​dit.tigris.org
For additional commands, e-mail: cvs-help at newedit dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /newedit/src/, /newedit/src/mixins/, /newedit/src/modules/ limodou limodou 2005-02-06 03:46:23 PST
Messages per page: