Login | Register
My pages Projects Community openCollabNet

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

newedit
Discussion topic

Back to topic list

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

Reply

Author limodou
Full name limodou
Date 2004-05-13 22:10:13 PDT
Message User: limodou
Date: 04/05/13 22:10:13

Modified:
 /newedit/src/mixins/
  EditorCtrl.py, RecentFile.py, Search.py
 /newedit/src/modules/
  FindReplaceDialog.py

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

File Changes:

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

File [changed]: EditorCtrl.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/E​ditorCtrl.py?r1=1.3​&r2=1.4
Delta lines: +29 -30
---------------------
--- EditorCtrl.py 13 May 2004 10:24:44 -0000 1.3
+++ EditorCtrl.py 14 May 2004 05:10:09 -0000 1.4
@@ -55,6 +55,16 @@
         self.list = []
         self.new()
 
+ def changeDocument(self, document):
+ self.mainframe.document = document
+ self.document = document
+ self.showTitle(self.document)
+ self.document.SetSTCFocus(True)
+ self.callplugin('doc​umentchange', self)
+
+ def getIndex(self, ctrl):
+ return self.list.index(ctrl)
+
     def new(self, filename=''):
         if filename:
             for obj in self.list: #if the file has been opened
@@ -74,36 +84,9 @@
             self.AddPage(ctrl, os.path.basename(ctr​l.getFilename()))
             self.switch(ctrl)
 
- def switch(self, document):
- index = self.getIndex(document)
- if index != self.GetSelection():
- self.SetSelection(index)
- else:
- self.mainframe.document = document
- self.document = document
- self.showTitle(self.document)
- self.document.SetSTCFocus(True)
- self.callplugin('doc​umentchange', self)
-
- def getIndex(self, ctrl):
- return self.list.index(ctrl)
-
- def showTitle(self, ctrl):
- if ctrl.GetModify():
- pagetitle = ctrl.getFilename() + ' *'
- else:
- pagetitle = ctrl.getFilename()
- title = '%s - [%s]' % (self.app.appname, pagetitle)
- self.SetPageText(sel​f.getIndex(ctrl), os.path.basename(pagetitle))
- self.mainframe.SetTitle(title)
-
     def OnPageChanged(self, event):
         document = self.list[event.GetSelection()]
- self.mainframe.document = document
- self.document = document
- self.showTitle(self.document)
- self.document.SetSTCFocus(True)
- self.callplugin('doc​umentchange', self)
+ self.changeDocument(document)
         event.Skip()
 
     def OnPopUp(self, event):
@@ -122,6 +105,20 @@
         elif eid == self.IDPM_FILE_SAVE_AS:
             self.mainframe.OnFil​eSaveAs(event)
 
+ def switch(self, document):
+ self.changeDocument(document)
+ index = self.getIndex(document)
+ self.SetSelection(index)
+
+ def showTitle(self, ctrl):
+ if ctrl.GetModify():
+ pagetitle = ctrl.getFilename() + ' *'
+ else:
+ pagetitle = ctrl.getFilename()
+ title = '%s - [%s]' % (self.app.appname, pagetitle)
+ self.SetPageText(sel​f.getIndex(ctrl), os.path.basename(ctr​l.getFilename()))
+ self.mainframe.SetTitle(title)
+
 def neweditctrl(win):
     win.notebook = EditCtrl(win, 0)
 Mixin.setPlugin('mainsubframe', 'init', neweditctrl)
@@ -170,7 +167,6 @@
     else:
         if index >= len(win.editctrl.list):
             index = len(win.editctrl.list)-1
- print win.editctrl.list[in​dex].filename, len(win.editctrl.list)
         win.editctrl.switch(​win.editctrl.list[in​dex])
     return answer
 Mixin.setMixin('mainframe', 'CloseFile', CloseFile)
@@ -190,7 +186,7 @@
 
 def SaveFile(win, ctrl, issaveas=False):
     if issaveas or len(ctrl.filename)<=0:
- dlg = wx.FileDialog(win, "Save File As", win.pref.last_dir, "All files (*.*)|*", wx.SAVE|wx.OVERWRITE_PROMPT)
+ dlg = wx.FileDialog(win, "Save File As", win.pref.last_dir, '', "All files (*.*)|*", wx.SAVE|wx.OVERWRITE_PROMPT)
         if (dlg.ShowModal() == wx.ID_OK):
             old = win.document.filename
             win.document.filename = dlg.GetPath()
@@ -205,3 +201,6 @@
     return True
 Mixin.setMixin('mainframe', 'SaveFile', SaveFile)
 
+def pref_init(pref):
+ pref.last_dir = ''
+Mixin.setPlugin('preference', 'init', pref_init)
\ No newline at end of file

File [changed]: RecentFile.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/R​ecentFile.py?r1=1.2​&r2=1.3
Delta lines: +9 -5
-------------------
--- RecentFile.py 13 May 2004 07:04:49 -0000 1.2
+++ RecentFile.py 14 May 2004 05:10:09 -0000 1.3
@@ -25,17 +25,19 @@
 Mixin.setMixin('preference', 'preflist', preflist)
 
 def pref_init(pref):
- pref.last_dir = ''
     pref.recent_files = []
     pref.recent_files_num = 10
 Mixin.setPlugin('preference', 'init', pref_init)
 
-def afteropen(win, filename):
+def afteropen(win, filename, id):
     if win.pref.recent_file​s.count(filename) > 0:
         win.pref.recent_file​s.remove(filename)
+ win.recentfile_ids.remove(id)
     win.pref.recent_files.insert(0, filename)
+ win.recentfile_ids.insert(0, id)
     while len(win.pref.recent_​files)>win.pref.r​ecent_files_num:
         win.pref.recent_files.pop(-1)
+ win.recentfile_ids.pop(-1)
     win.pref.last_dir = os.path.dirname(filename)
     win.pref.save()
     create_recent_menu(win)
@@ -55,15 +57,17 @@
         menu.Append(id, 'Empty')
         menu.Enable(id, False)
     else:
+ win.recentmenu_ids = []
         for i, filename in enumerate(win.pref.r​ecent_files):
- id = win.IDM_FILE_RECENTF​ILES_ITEMS+i
+ id = wx.NewId()
+ win.recentmenu_ids.append(id)
             menu.Append(id, "&%d %s" % (i+1, filename))
             wx.EVT_MENU(win, id, getattr(win, 'OnOpenRecentFiles'))
 
 def OnOpenRecentFiles(win, event):
     eid = event.GetId()
- index = eid - win.IDM_FILE_RECENTFILES_ITEMS
+ index = win.recentmenu_ids.index(eid)
     filename = win.pref.recent_files[index]
     win.editctrl.new(filename)
- afteropen(win, filename)
+ afteropen(win, filename, eid)
 Mixin.setMixin('mainframe', 'OnOpenRecentFiles', OnOpenRecentFiles)

File [changed]: Search.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/S​earch.py?r1=1.2&​r2=1.3
Delta lines: +9 -15
--------------------
--- Search.py 13 May 2004 07:04:49 -0000 1.2
+++ Search.py 14 May 2004 05:10:09 -0000 1.3
@@ -13,8 +13,8 @@
     [
         (301, 'IDM_SEARCH_FIND', 'Find...\tCtrl+F', wx.ITEM_NORMAL, 'OnSearchFind', 'Find text'),
         (302, 'IDM_SEARCH_REPLACE', 'Replace...\tCtrl+H', wx.ITEM_NORMAL, 'OnSearchReplace', 'Find and replace text'),
- (303, 'IDM_SEARCH_FIND_NEXT', 'Find Next\tF3', wx.ITEM_NORMAL, 'OnTest', 'Find next occurance of text'),
- (304, 'IDM_SEARCH_FIND_PREVIOUS', 'Find Previous\tCtrl+Shift+F3', wx.ITEM_NORMAL, 'OnTest1', 'Find previous occurance of text'),
+ (303, 'IDM_SEARCH_FIND_NEXT', 'Find Next\tF3', wx.ITEM_NORMAL, 'OnSearchFindNext', 'Find next occurance of text'),
+ (304, 'IDM_SEARCH_FIND_PREVIOUS', 'Find Previous\tCtrl+Shift+F3', wx.ITEM_NORMAL, 'OnSearchFindPrev', 'Find previous occurance of text'),
     ]),
 ]
 Mixin.setMixin('mainframe', 'menulist', menulist)
@@ -35,19 +35,13 @@
     dlg.Show()
 Mixin.setMixin('mainframe', 'OnSearchFind', OnSearchFind)
 
-def OnTest(win, event):
- win.finder.setWindow​(win.document)
- win.finder.findtext = "app"
- win.finder.find()
-Mixin.setMixin('mainframe', 'OnTest', OnTest)
-
-def OnTest1(win, event):
- win.finder.setWindow​(win.document)
-# win.finder.direction = 1
-# win.finder.findtext = "app"
-# win.finder.find()
- win.finder.findnext()
-Mixin.setMixin('mainframe', 'OnTest1', OnTest1)
+def OnSearchFindNext(win, event):
+ win.finder.findNext()
+Mixin.setMixin('mainframe', 'OnSearchFindNext', OnSearchFindNext)
+
+def OnSerachFindPrev(win, event):
+ win.finder.findPrev()
+Mixin.setMixin('mainframe', 'OnSerachFindPrev', OnSerachFindPrev)
 
 preflist = [
     ('generic', 120, 'num', 'max_findtext_num', 'Max number of saved find text:', None)

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

File [changed]: FindReplaceDialog.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​FindReplaceDialog.py​?r1=1.3&r2=1.4
Delta lines: +32 -11
---------------------
--- FindReplaceDialog.py 13 May 2004 10:24:44 -0000 1.3
+++ FindReplaceDialog.py 14 May 2004 05:10:09 -0000 1.4
@@ -15,6 +15,8 @@
         self.inselection = False
         self.fromcursor = True
 
+ self.found = False
+
     def getFlags(self):
         flags = 0
         if self.wholeword:
@@ -32,12 +34,12 @@
     def beginFind(self, direction=0):
         """win is a STC window"""
 
+ self.found = False
         if not self.fromcursor:
             self.start = 0
         else:
             self.start = self.win.GetCurrentPos()
         self.lastpos = self.start
- self.find(direction)
 
     def find(self, direction=0):
         if direction == 0: #forwards
@@ -57,7 +59,7 @@
             if pos == -1:
                 wx.MessageDialog(self.win, "Cann't find the text [%s]" % self.findtext, "Find result", wx.OK).ShowModal()
                 return
- self.lastpos = pos
+ self.lastpos = pos + len(self.findtext)
         self.win.GotoPos(pos + len(self.findtext))
         self.win.EnsureCaretVisible()
         self.win.SetSelectionStart(pos)
@@ -495,17 +497,16 @@
         for s in self.pref.findtexts:
             self.obj_ID_FINDTEXT.Append(s)
 
+ self.setValue()
+ self.laststatus = self.getValue()
+
     def OnFind(self, event):
         self.addString(self.​obj_ID_FINDTEXT.GetV​alue())
- self.finder.findtext = self.obj_ID_FINDTEXT.GetValue()
- self.finder.regular = self.obj_ID_REGEX.GetValue()
- self.finder.rewind = self.obj_ID_REWIND.GetValue()
- self.finder.matchcase = self.obj_ID_MATCHCAS​E.GetValue()
- self.finder.wholeword = self.obj_ID_WHOLEWOR​D.GetValue()
- self.finder.fromcursor = self.obj_ID_FROMCURS​OR.GetValue()
- self.finder.beginFin​d(self.obj_ID_DIRECT​ION.GetSelection())
-
- self.obj_ID_FROMCURS​OR.SetValue(True)
+ newstatus = self.getValue()
+ if self.laststatus != newstatus:
+ self.laststatus = newstatus
+ self.finder.beginFin​d(self.finder.direct​ion)
+ self.finder.find(sel​f.finder.direction)
 
     def addString(self, text):
         if self.pref.findtexts.count(text) > 0:
@@ -526,6 +527,8 @@
         self.obj_ID_FINDTEXT.SetMark(0, len(text))
 
     def OnClose(self, event):
+ if self.laststatus != self.getValue():
+ self.finder.beginFind()
         self.Destroy()
 
     def OnCheckRegular(self, event):
@@ -539,4 +542,22 @@
         self.obj_ID_FROMCURS​OR.SetValue(0)
         self.obj_ID_FROMCURS​OR.Enable(not self.obj_ID_INSELECT​ION.GetValue())
 
+ def getValue(self):
+ self.finder.findtext = self.obj_ID_FINDTEXT.GetValue()
+ self.finder.regular = self.obj_ID_REGEX.GetValue()
+ self.finder.rewind = self.obj_ID_REWIND.GetValue()
+ self.finder.matchcase = self.obj_ID_MATCHCAS​E.GetValue()
+ self.finder.wholeword = self.obj_ID_WHOLEWOR​D.GetValue()
+ self.finder.fromcursor = self.obj_ID_FROMCURS​OR.GetValue()
+ return (self.finder.findtext, self.finder.regular, self.finder.fromcursor)
+
+ def setValue(self):
+ self.obj_ID_REGEX.Se​tValue(self.finder.r​egular)
+ self.obj_ID_REWIND.S​etValue(self.finder.​rewind)
+ self.obj_ID_MATCHCAS​E.SetValue(self.find​er.matchcase)
+ self.obj_ID_WHOLEWOR​D.SetValue(self.find​er.wholeword)
+ self.obj_ID_FROMCURS​OR.SetValue(self.fin​der.fromcursor)
+ self.obj_ID_DIRECTIO​N.Enable(not self.finder.regular)
+ self.obj_ID_WHOLEWOR​D.SetValue(0)
+ self.obj_ID_WHOLEWOR​D.Enable(not self.obj_ID_REGEX.GetValue())
 




--------------------​--------------------​--------------------​---------
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/mixins/, /newedit/src/modules/ limodou limodou 2004-05-13 22:10:13 PDT
Messages per page: