Login | Register
My pages Projects Community openCollabNet

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

newedit
Discussion topic

Back to topic list

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

Reply

Author limodou
Full name limodou
Date 2004-05-10 07:17:07 PDT
Message User: limodou
Date: 04/05/10 07:17:07

Modified:
 /newedit/src/
  ChangeLog.txt, Debug.py, PrefDialog.py, Preference.py, makemenu.py
 /newedit/src/modules/
  DefaultMenu.py, Editor.py, EditorCtrl.py, MainFrame.py, Pref.py, __init__.py

Log:
 Issue number:
 Obtained from:
 Submitted by:
 Reviewed by:

File Changes:

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

File [changed]: ChangeLog.txt
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/ChangeLo​g.txt?r1=1.1&r2=​1.2
Delta lines: +7 -0
-------------------
--- ChangeLog.txt 8 May 2004 14:23:05 -0000 1.1
+++ ChangeLog.txt 10 May 2004 14:17:03 -0000 1.2
@@ -1,3 +1,10 @@
+[2004/05/11]
+RecentFile.py Ôö¼Ó×î½üÎļþµÄ²Ëµ¥Ïî´¦Àí
+
+[2004/05/10]
+Preference.py Ôö¼ÓϵͳÅäÖÃÑ¡Ïî¹ÜÀí​£¬Ê¹ÓÃpickle
+PrefDialog.py ´¦Àíprefercent¶Ô»°¿ò
+
 [2004/05/03]
 OnModified.py Ôö¼ÓÎĵµÐ޸ĺónotebo​okºÍ´°ÌåµÄ±êÌâ±ä»¯
 EditCtrl.py Ôö¼ÓtabÇл»ºó±êÌâµÄ±ä»¯

File [changed]: Debug.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/Debug.py​?r1=1.1&r2=1.2
Delta lines: +19 -19
---------------------

File [changed]: PrefDialog.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/PrefDial​og.py?r1=1.2&r2=​1.3
Delta lines: +5 -5
-------------------
--- PrefDialog.py 9 May 2004 15:01:53 -0000 1.2
+++ PrefDialog.py 10 May 2004 14:17:03 -0000 1.3
@@ -15,6 +15,7 @@
         self.items = []
 
         self.parent = parent
+ self.pref = self.parent.pref
         self.box1 = wx.BoxSizer(wx.VERTICAL)
         self.notebook = wx.Notebook(self, -1)
         self.addPages(self.notebook)
@@ -39,11 +40,11 @@
 
     def addPages(self, notebook):
         pages = []
- for v in self.parent.pref.preflist:
- pagename, order, kind, prefname, prefvalue, message, extern = v
- prefvalue = getattr(self.parent.pref, prefname)
- if pagename == '':
+ for v in self.pref.preflist:
+ pagename, order, kind, prefname, message, extern = v
+ if not hasattr(self.pref, prefname):
                 continue
+ prefvalue = getattr(self.parent.pref, prefname)
             if pages.count(pagename)==0:
                 page = wx.Panel(notebook, -1)
                 notebook.AddPage(page, pagename)
@@ -74,7 +75,6 @@
             cb = wx.ComboBox(page, -1, '', choices = extern, style = wx.CB_DROPDOWN)
             obj.Add(cb, 0)
             if types.IntType == type(prefvalue):
- #cb.SetValue(cb.GetS​tring(prefvalue))
                 cb.SetSelection(prefvalue)
                 self.items.append((prefname, cb.GetSelection))
             else:

File [changed]: Preference.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/Preferen​ce.py?r1=1.2&r2=​1.3
Delta lines: +21 -31
---------------------
--- Preference.py 9 May 2004 15:01:53 -0000 1.2
+++ Preference.py 10 May 2004 14:17:03 -0000 1.3
@@ -1,25 +1,27 @@
 import Mixin
-import Debug
+from Debug import *
 import copy
 import pickle
 import os.path
 
 class Preference(Mixin.Mixin):
     __mixinname__ = 'preference'
- preflist = [
- ('generic', 100, 'check', 'utf8_encoding_auto_detect', True, 'UTF-8 encoding auto detect', None),
- ('generic', 200, 'num', 'int', 100, 'int value', None),
- ('generic', 150, 'choice', 'select1', 'one', 'combox1', ['two', 'one', 'three']),
- ('generic', 150, 'choice', 'select2', 3, 'combox2', ['two', 'one', 'three']),
- ('generic', 300, 'text', 'name', 'limodou','enter your name', None),
- ('HTML', 100, 'check', 'html', False, 'Html format', None),
- ]
+# preflist = [
+# ('generic', 100, 'check', 'utf8_encoding_auto_detect', True, 'UTF-8 encoding auto detect', None),
+# ('generic', 200, 'num', 'int', 100, 'int value', None),
+# ('generic', 150, 'choice', 'select1', 'one', 'combox1', ['two', 'one', 'three']),
+# ('generic', 150, 'choice', 'select2', 3, 'combox2', ['two', 'one', 'three']),
+# ('generic', 300, 'text', 'name', 'limodou','enter your name', None),
+# ('generic', 100, 'num', 'recent_files_num', 10, 'Max number of recent files:', None),
+# ('HTML', 100, 'check', 'html', False, 'Html format', None),
+# ]
     defaultfile = 'newedit.opt'
 
     def __init__(self):
         self.initmixin()
-
- self.initpref()
+ self.preflist = []
+ self.callplugin('init', self)
+ self.preflist.sort()
 
     def clone(self):
         return copy.copy(self)
@@ -33,25 +35,13 @@
         if not filename:
             filename = self.defaultfile
         if os.path.exists(filename):
- return pickle.load(open(filename))
- else:
- return self
-
- def initpref(self):
- for catalog, order, kind, name, value, message, extern in self.preflist:
- setattr(self, name, value)
- Preference.preflist.sort()
+ obj = pickle.load(open(filename))
+ for k, v in obj.__dict__.items():
+ if hasattr(self, k):
+ setattr(self, k, v)
     
     def printValues(self):
- for catalog, order, kind, name, value, message, extern in self.preflist:
- print name, getattr(self, name)
+ debugput("[preference] member variable...")
+ for k, v in self.__dict__.items():
+ debugput('\t', k,'=', v)
 
-if __name__ == '__main__':
- Debug.debuginit('out.txt')
- p = Preference()
- print p.__dict__
- p.wildcard = 'aaa'
- p.save()
- p = p.load()
- print p.__dict__
- print p.wildcard, p.__mixinname__

File [changed]: makemenu.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/makemenu​.py?r1=1.1&r2=1.​2
Delta lines: +14 -2
--------------------
--- makemenu.py 8 May 2004 14:23:05 -0000 1.1
+++ makemenu.py 10 May 2004 14:17:03 -0000 1.2
@@ -8,14 +8,18 @@
     for m in mlist:
         order, idname, caption, kind, func, obj = m
         if type(obj) == types.ListType:
- submenu = makesubmenu(obj)
+ id = Id.makeid(win, idname)
+ submenu = makesubmenu(win, obj)
             menu.AppendMenu(id, caption, submenu)
+ win.menuitems[idname] = submenu
         else:
             if kind == wx.ITEM_SEPARATOR:
                 menu.AppendSeparator()
             else:
                 id = Id.makeid(win, idname)
+ mitem = wx.MenuItem(menu, id, caption, obj, kind)
                 menu.Append(id, caption, obj, kind)
+ win.menuitems[idname] = mitem
 
             if kind in (wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO):
                 if func:
@@ -27,6 +31,8 @@
     return menu
 
 def makepopmenu(win, popmenu, accel=None):
+ win.menuitems = {}
+
     mlist = mergemenu(popmenu)
     makeaccelerator(mlist, accel)
     menu = makesubmenu(win, mlist)
@@ -34,6 +40,7 @@
 
 def makemenu(win, menulist, accel=None):
     menuBar = wx.MenuBar()
+ win.menuitems = {}
 
     mlist = mergemenu(menulist)
     printmenu(mlist)
@@ -41,8 +48,10 @@
 
     for m in mlist:
         order, idname, caption, kind, func, obj = m
+ id = Id.makeid(win, idname)
         menu = makesubmenu(win, obj, accel)
         menuBar.Append(menu, caption)
+ win.menuitems[idname] = menu
 
     return menuBar
 
@@ -78,7 +87,7 @@
 # print level, id,idname,caption, message
     debugput('[makemenu] Menu listing...')
     for order, idname, caption, kind, func, obj in m:
- debugput('\t%s %s %s' % (order, idname, caption))
+ debugput('\t%s\t%s\t"%s"' % (order, idname, caption))
         if type(obj) == types.ListType:
             printmenu(obj)
 
@@ -90,3 +99,6 @@
                 accellist.append((ca​ption[pos+1:], idname))
         if type(obj) == types.ListType:
             makeaccelerator(obj, accellist)
+
+def findmenu(menuitems, id):
+ return menuitems[id]
\ No newline at end of file

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

File [changed]: DefaultMenu.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​DefaultMenu.py?r1=1.​1&r2=1.2
Delta lines: +6 -6
-------------------
--- DefaultMenu.py 8 May 2004 14:25:28 -0000 1.1
+++ DefaultMenu.py 10 May 2004 14:17:03 -0000 1.2
@@ -1,18 +1,18 @@
 #menu
 
 import Mixin
-from makemenu import *
-from wx import *
+import makemenu
+import wx
 
 menulist = [ (0, #parent menu id
     [
- (100, 'IDM_FILE', 'File', ITEM_NORMAL, None, ''),
- (900, 'IDM_FILE', 'Help', ITEM_NORMAL, None, ''),
+ (100, 'IDM_FILE', 'File', wx.ITEM_NORMAL, None, ''),
+ (900, 'IDM_FILE', 'Help', wx.ITEM_NORMAL, None, ''),
     ]),
     (100,
     [
- (119, '', '-', ITEM_SEPARATOR, None, ''),
- (120, 'IDM_FILE_EXIT', 'Exit\tAlt+X', ITEM_NORMAL, 'OnExit', 'Exit Program'),
+ (190, '', '-', wx.ITEM_SEPARATOR, None, ''),
+ (195, 'IDM_FILE_EXIT', 'Exit\tAlt+X',wx. ITEM_NORMAL, 'OnExit', 'Exit Program'),
     ]),
 ]
 Mixin.setMixin('mainframe', 'menulist', menulist)

File [changed]: Editor.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​Editor.py?r1=1.1​&r2=1.2
Delta lines: +9 -6
-------------------
--- Editor.py 8 May 2004 14:25:28 -0000 1.1
+++ Editor.py 10 May 2004 14:17:03 -0000 1.2
@@ -18,20 +18,23 @@
         self.editctrl = self.parent
         self.mainframe = self.editctrl.mainframe
         self.app = self.mainframe.app
- self.filename = filename
         self.fileid = self.fid
         Editor.fid += 1
- if self.filename:
- text = open(self.filename).read()
- self.SetText(text)
- self.EmptyUndoBuffer()
- self.SetSavePoint()
+ self.reset(filename)
 
         #make popup menu
         self.popmenu = makemenu.makepopmenu(self, self.popmenulist)
 
         #INTERFACE: editor,setevent,win
         self.callplugin('init', self)
+
+ def reset(self, filename):
+ self.filename = filename
+ if self.filename:
+ text = open(self.filename).read()
+ self.SetText(text)
+ self.EmptyUndoBuffer()
+ self.SetSavePoint()
 
     def getFilename(self):
         if self.filename:

File [changed]: EditorCtrl.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​EditorCtrl.py?r1=1.1​&r2=1.2
Delta lines: +26 -11
---------------------
--- EditorCtrl.py 8 May 2004 14:25:28 -0000 1.1
+++ EditorCtrl.py 10 May 2004 14:17:03 -0000 1.2
@@ -5,14 +5,14 @@
 
 menulist = [ (100,
     [
- (101, 'IDM_FILE_NEW', 'New\tCtrl+N', wx.ITEM_NORMAL, 'OnFileNew', 'New document'),
- (102, 'IDM_FILE_OPEN', 'Open\tCtrl+O', wx.ITEM_NORMAL, 'OnFileOpen', 'Open an exist document'),
- (103, 'IDM_FILE_CLOSE', 'Close', wx.ITEM_NORMAL, 'OnFileClose', 'Close current document'),
- (104, 'IDM_FILE_CLOSE_ALL', 'Close All', wx.ITEM_NORMAL, 'OnFileCloseAll', 'Close all documents'),
- (110, '', '-', wx.ITEM_SEPARATOR, None, ''),
- (111, 'IDM_FILE_SAVE', 'Save\tCtrl+S', wx.ITEM_NORMAL, 'OnFileSave', 'Save current document'),
- (112, 'IDM_FILE_SAVE_ALL', 'Save All', wx.ITEM_NORMAL, 'OnFileSaveAll', 'Save all documents'),
- (113, 'IDM_FILE_SAVE_AS', 'Save As', wx.ITEM_NORMAL, 'OnFileSaveAs', 'Save current document as ...'),
+ (105, 'IDM_FILE_NEW', 'New\tCtrl+N', wx.ITEM_NORMAL, 'OnFileNew', 'New document'),
+ (110, 'IDM_FILE_OPEN', 'Open\tCtrl+O', wx.ITEM_NORMAL, 'OnFileOpen', 'Open an exist document'),
+ (115, 'IDM_FILE_CLOSE', 'Close', wx.ITEM_NORMAL, 'OnFileClose', 'Close current document'),
+ (120, 'IDM_FILE_CLOSE_ALL', 'Close All', wx.ITEM_NORMAL, 'OnFileCloseAll', 'Close all documents'),
+ (125, '', '-', wx.ITEM_SEPARATOR, None, ''),
+ (130, 'IDM_FILE_SAVE', 'Save\tCtrl+S', wx.ITEM_NORMAL, 'OnFileSave', 'Save current document'),
+ (135, 'IDM_FILE_SAVE_ALL', 'Save All', wx.ITEM_NORMAL, 'OnFileSaveAll', 'Save all documents'),
+ (140, 'IDM_FILE_SAVE_AS', 'Save As', wx.ITEM_NORMAL, 'OnFileSaveAs', 'Save current document as ...'),
     ]),
 ]
 Mixin.setMixin('mainframe', 'menulist', menulist)
@@ -42,6 +42,7 @@
 
         self.parent = parent
         self.mainframe = self.parent.parent
+ self.pref = self.mainframe.pref
         self.app = self.mainframe.app
         self.mainframe.editctrl = self
 
@@ -55,6 +56,18 @@
         self.new()
 
     def new(self, filename=''):
+ if filename:
+ for obj in self.list: #if the file has been opened
+ if filename == obj.filename:
+ self.switch(obj)
+ return
+ else: #the file hasn't been opened
+ #if current page is empty and has not been modified
+ if (self.document.filename == '') and (not self.document.GetModify()):
+ #use current page , donot open a new page
+ self.document.reset(filename)
+ self.switch(self.document)
+ return
         ctrl = self.execplugin('neweditor', self, filename)
         if ctrl:
             self.list.append(ctrl)
@@ -64,6 +77,8 @@
     def switch(self, ctrl):
         index = self.getIndex(ctrl)
         self.SetSelection(index)
+ self.showTitle(self.document)
+ self.document.SetSTCFocus(True)
 
     def getIndex(self, ctrl):
         return self.list.index(ctrl)
@@ -79,8 +94,6 @@
 
     def OnPageChanged(self, event):
         document = self.list[event.GetSelection()]
- self.showTitle(document)
- document.SetFocus()
         self.mainframe.document = document
         self.document = document
         event.Skip()
@@ -110,10 +123,11 @@
 Mixin.setMixin('mainframe', 'OnFileNew', OnFileNew)
 
 def OnFileOpen(win, event):
- dlg = wx.FileDialog(win, "Open", "", "", "All files (*.*)|*", wx.OPEN|wx.HIDE_READ​ONLY|wx.MULTIPLE)
+ dlg = wx.FileDialog(win, "Open", win.pref.last_dir, "", "All files (*.*)|*", wx.OPEN|wx.HIDE_READ​ONLY|wx.MULTIPLE)
     if dlg.ShowModal() == wx.ID_OK:
         for file in dlg.GetPaths():
             win.editctrl.new(file)
+ win.callplugin('afteropen', win, file)
 Mixin.setMixin('mainframe', 'OnFileOpen', OnFileOpen)
 
 def OnFileClose(win, event):
@@ -173,6 +187,7 @@
     cfile.close()
     ctrl.SetSavePoint()
     win.editctrl.showTitle(ctrl)
+ win.callplugin('aftersave', win, ctrl.filename)
     return True
 Mixin.setMixin('mainframe', 'SaveFile', SaveFile)
 

File [changed]: MainFrame.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​MainFrame.py?r1=1.1​&r2=1.2
Delta lines: +2 -2
-------------------
--- MainFrame.py 8 May 2004 14:25:28 -0000 1.1
+++ MainFrame.py 10 May 2004 14:17:03 -0000 1.2
@@ -17,8 +17,8 @@
         wx.Frame.__init__(self, None, -1, self.app.appname, size=wx.Size(600, 400))
 
         self.id = self.GetId()
- self.menuBar=makemen​u.makemenu(self, self.menulist, NewEditFrame.accellist)
- self.SetMenuBar(self.menuBar)
+ self.menubar=makemen​u.makemenu(self, self.menulist, NewEditFrame.accellist)
+ self.SetMenuBar(self.menubar)
         Accelerator.initacce​lerator(self, NewEditFrame.accellist)
 
         self.callplugin('init', self)

File [changed]: Pref.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​Pref.py?r1=1.2&r​2=1.3
Delta lines: +3 -2
-------------------
--- Pref.py 9 May 2004 15:01:53 -0000 1.2
+++ Pref.py 10 May 2004 14:17:03 -0000 1.3
@@ -15,8 +15,9 @@
 Mixin.setMixin('mainframe', 'menulist', menulist)
 
 def initpreference(win):
- pref = Preference.Preference()
- win.pref = pref.load()
+ win.pref = Preference.Preference()
+ win.pref.load()
+ win.pref.printValues()
 Mixin.setPlugin('mainframe', 'init', initpreference)
 
 def OnOptionPreference(win, event):

File [changed]: __init__.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​__init__.py?r1=1.2​&r2=1.3
Delta lines: +1 -0
-------------------
--- __init__.py 9 May 2004 15:01:53 -0000 1.2
+++ __init__.py 10 May 2004 14:17:03 -0000 1.3
@@ -10,4 +10,5 @@
     'ComEdit',
     'Toolbar',
     'icon',
+ 'RecentFile',
 ]




--------------------​--------------------​--------------------​---------
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/modules/ limodou limodou 2004-05-10 07:17:07 PDT
Messages per page: