Login | Register
My pages Projects Community openCollabNet

newedit
Reply to message

* = Required fields
* Subject
* Body
Attachments
Send reply to
Topic
Author (directly in email)
Please type the letters in the image above.

Original message

Author limodou
Full name limodou
Date 2004-05-13 00:04:53 PDT
Message User: limodou
Date: 04/05/13 00:04:53

Added:
 /newedit/src/mixins/
  Lineending.py, OnPosition.py
 /newedit/src/modules/
  Resource.py
 /newedit/src/resources/
  finddialog.xrc

Modified:
 /newedit/src/
  ChangeLog.txt
 /newedit/src/mixins/
  Editor.py, EditorCtrl.py, MainFrame.py, MainSubFrame.py, OnModified.py,
  Pref.py, RecentFile.py, Search.py, StatusBar.py, __init__.py
 /newedit/src/modules/
  FindReplaceDialog.py, Preference.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.3&r2=​1.4
Delta lines: +11 -0
--------------------
--- ChangeLog.txt 12 May 2004 07:04:19 -0000 1.3
+++ ChangeLog.txt 13 May 2004 07:04:49 -0000 1.4
@@ -1,3 +1,14 @@
+[2004/05/13]
+OnPosition.py Ôö¼ÓÐС¢ÁÐ×ø±êÏÔʾ
+Lineending.py ÐнáÊøģʽ´¦Àí
+
+[2004/05/12]
+Ŀ¼±ä¸ü
+images ´æ·ÅͼƬ
+modules ´æ·ÅÄ£¿é
+mixins ´æ·ÅmixinºÍplugin
+resource´æ·Å×ÊÔ´Îļþ
+
 [2004/05/11]
 RecentFile.py Ôö¼Ó×î½üÎļþµÄ²Ëµ¥Ïî´¦Àí
 CommEdit.py Ôö¼ÓSelect All¹¦ÄÜ

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

File [changed]: Editor.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/E​ditor.py?r1=1.1&​r2=1.2
Delta lines: +15 -4
--------------------
--- Editor.py 12 May 2004 07:04:19 -0000 1.1
+++ Editor.py 13 May 2004 07:04:49 -0000 1.2
@@ -13,13 +13,16 @@
         self.initmixin()
 
         wx.stc.StyledTextCtr​l.__init__(self, parent, -1)
- self.id = self.GetId()
         self.parent = parent
         self.editctrl = self.parent
         self.mainframe = self.editctrl.mainframe
         self.app = self.mainframe.app
+ self.pref = self.mainframe.pref
         self.fileid = self.fid
         Editor.fid += 1
+
+ self.callplugin('beforeinit', self)
+
         self.reset(filename)
 
         #make popup menu
@@ -58,10 +61,18 @@
     def reset(self, filename):
         self.filename = filename
         if self.filename:
- text = open(self.filename).read()
- self.SetText(text)
+ text = open(self.filename, 'rb').read()
+
+ stext = [text]
+ #stext is a list of the file text. To get the file text you can use
+ #stext[0]. Then you can reset the value in order to change the text
+ self.callplugin('openfiletext', self, stext)
+
+ self.SetText(stext[0])
             self.EmptyUndoBuffer()
             self.SetSavePoint()
+
+ self.callplugin('resetfile', self)
 
     def getFilename(self):
         if self.filename:

File [changed]: EditorCtrl.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/E​ditorCtrl.py?r1=1.1​&r2=1.2
Delta lines: +5 -4
-------------------
--- EditorCtrl.py 12 May 2004 07:04:19 -0000 1.1
+++ EditorCtrl.py 13 May 2004 07:04:49 -0000 1.2
@@ -41,7 +41,7 @@
         self.id = self.GetId()
 
         self.parent = parent
- self.mainframe = self.parent.parent
+ self.mainframe = self.parent.mainframe
         self.pref = self.mainframe.pref
         self.app = self.mainframe.app
         self.mainframe.editctrl = self
@@ -77,8 +77,6 @@
     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)
@@ -96,6 +94,9 @@
         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)
         event.Skip()
 
     def OnPopUp(self, event):
@@ -177,7 +178,7 @@
 
 def SaveFile(win, ctrl, issaveas=False):
     if issaveas or len(ctrl.filename)<=0:
- dlg = wx.FileDialog(win, "Save File As", "", "", "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()

File [added]: Lineending.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/L​ineending.py?rev=1.1​&content-type=te​xt/vnd.viewcvs-marku​p
Added lines: 65
---------------
import Mixin
import wx
import wx.stc

def beforeinit(win):
    win.lineendingsaremixed = 0
    win.eolmode = win.GetEOLMode()
Mixin.setPlugin('editor', 'beforeinit', beforeinit)

def fileopentext(win, stext):
    text = stext[0]

    win.lineendingsaremixed = 0

    eollist = "".join(map(getEndOf​LineCharacter, text))

    if eollist.count('\r\n'):
        emodenum = 1
        win.eolmode = wx.stc.STC_EOL_CRLF
    elif eollist.count('\n'):
        emodenum = 0
        win.eolmode = wx.stc.STC_EOL_LF
    elif eollist.count('\r'):
        emodenum = 2
        win.eolmode = wx.stc.STC_EOL_CR
    if len(eollist) >= 2:
        win = eollist.count('\r\n\r\n')
        unix = eollist.count('\n\n')
        mac = eollist.count('\r\r')
    if (win and unix) or (win and mac) or (mac and unix):
        win.lineendingsaremixed = 1
Mixin.setPlugin('editor', 'openfiletext', fileopentext)

def resetfile(win):
    if win.lineendingsaremixed:
        eolmodestr = "MIX"
    else:
        if win.eolmode == wx.stc.STC_EOL_CR:
            eolmodestr = "MAC"
        elif win.eolmode == wx.stc.STC_EOL_CRLF:
            eolmodestr = "WIN"
        else:
            eolmodestr = "UNIX"
    win.mainframe.SetSta​tusText(eolmodestr, 3)
    win.SetEOLMode(win.eolmode)
Mixin.setPlugin('editor', 'resetfile', resetfile)

def documentchange(win):
    if win.document.lineend​ingsaremixed:
        eolmodestr = "MIX"
    else:
        eolmode = win.document.GetEOLMode()
        if eolmode == wx.stc.STC_EOL_CR:
            eolmodestr = "MAC"
        elif eolmode == wx.stc.STC_EOL_CRLF:
            eolmodestr = "WIN"
        else:
            eolmodestr = "UNIX"
    win.mainframe.SetSta​tusText(eolmodestr, 3)
Mixin.setPlugin('editctrl', 'documentchange', documentchange)

def getEndOfLineCharacte​r(character):
    if character == '\r' or character == '\n':
        return character
    return ""

File [changed]: MainFrame.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/M​ainFrame.py?r1=1.1​&r2=1.2
Delta lines: +2 -0
-------------------
--- MainFrame.py 12 May 2004 07:04:19 -0000 1.1
+++ MainFrame.py 13 May 2004 07:04:49 -0000 1.2
@@ -16,6 +16,8 @@
 
         wx.Frame.__init__(self, None, -1, self.app.appname, size=wx.Size(600, 400))
 
+ self.callplugin('beforeinit', self)
+
         self.id = self.GetId()
         self.menubar=makemen​u.makemenu(self, self.menulist, NewEditFrame.accellist)
         self.SetMenuBar(self.menubar)

File [changed]: MainSubFrame.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/M​ainSubFrame.py?r1=1.​1&r2=1.2
Delta lines: +1 -0
-------------------
--- MainSubFrame.py 12 May 2004 07:04:19 -0000 1.1
+++ MainSubFrame.py 13 May 2004 07:04:49 -0000 1.2
@@ -11,6 +11,7 @@
         wx.SashLayoutWindow.​__init__(self, parent, -1, wx.DefaultPosition, wx.Size(10, 10), style = wx.NO_BORDER|wx.SW_3D)
         self.parent = parent
         self.parent.mainsubframe = self
+ self.mainframe = self.parent
         self.id = self.GetId()
 
         wx.EVT_SASH_DRAGGED(​self.parent, self.id, self.parent.OnSashDrag)

File [changed]: OnModified.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/O​nModified.py?r1=1.1​&r2=1.2
Delta lines: +10 -9
--------------------
--- OnModified.py 12 May 2004 07:04:19 -0000 1.1
+++ OnModified.py 13 May 2004 07:04:49 -0000 1.2
@@ -1,16 +1,17 @@
 import Mixin
-import os.path
-from wx import *
-from wx.stc import *
+import wx.stc
 
 def init(win):
- EVT_STC_MODIFIED(win, win.id, win.OnModified)
+ wx.stc.EVT_STC_MODIFIED(win, win.GetId(), win.OnModified)
 Mixin.setPlugin('editor', 'init', init)
 
 def OnModified(win, event):
- if (win.GetModify()):
- win.editctrl.showTitle(win)
- else:
- win.SetSavePoint()
- win.editctrl.showTitle(win)
+# if (win.GetModify()):
+# win.editctrl.showTitle(win)
+# else:
+# win.SetSavePoint()
+# win.editctrl.showTitle(win)
+# import os.path
+# win.editctrl.SetPage​Text(win.editctrl.ge​tIndex(win), os.path.basename(win​.getFilename()))
+ pass
 Mixin.setMixin('editor', 'OnModified', OnModified)

File [added]: OnPosition.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/O​nPosition.py?rev=1.1​&content-type=te​xt/vnd.viewcvs-marku​p
Added lines: 19
---------------
import Mixin
import wx
import wx.stc

def init(win):
    wx.EVT_KEY_UP(win, win.OnPositionChanged)
    wx.EVT_LEFT_UP(win, win.OnPositionChanged)
Mixin.setPlugin('editor', 'init', init)

def OnPositionChanged(win, event):
    win.mainframe.SetSta​tusText("Line: %d" % (win.GetCurrentLine()+1), 1)
    win.mainframe.SetSta​tusText("Col: %s" % win.GetColumn(win.Ge​tCurrentPos()), 2)
    event.Skip()
Mixin.setMixin('editor', 'OnPositionChanged', OnPositionChanged)

def documentchange(win):
    win.mainframe.SetSta​tusText("Line: %d" % (win.document.GetCur​rentLine()+1), 1)
    win.mainframe.SetSta​tusText("Col: %s" % win.document.GetColu​mn(win.document.GetC​urrentPos()), 2)
Mixin.setPlugin('editctrl', 'documentchange', documentchange)

File [changed]: Pref.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/P​ref.py?r1=1.1&r2​=1.2
Delta lines: +1 -0
-------------------
--- Pref.py 12 May 2004 07:04:19 -0000 1.1
+++ Pref.py 13 May 2004 07:04:49 -0000 1.2
@@ -18,6 +18,7 @@
     win.pref = Preference.Preference()
     win.pref.load()
     win.pref.printValues()
+ win.pref.last_dir = ''
 Mixin.setPlugin('mainframe', 'init', initpreference)
 
 def OnOptionPreference(win, event):

File [changed]: RecentFile.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/R​ecentFile.py?r1=1.1​&r2=1.2
Delta lines: +5 -1
-------------------
--- RecentFile.py 12 May 2004 07:04:19 -0000 1.1
+++ RecentFile.py 13 May 2004 07:04:49 -0000 1.2
@@ -19,11 +19,15 @@
     create_recent_menu(win)
 Mixin.setPlugin('mainframe', 'init', main_init)
 
+preflist = [
+ ('generic', 100, 'num', 'recent_files_num', 'Max number of recent files:', None)
+]
+Mixin.setMixin('preference', 'preflist', preflist)
+
 def pref_init(pref):
     pref.last_dir = ''
     pref.recent_files = []
     pref.recent_files_num = 10
- pref.preflist.append​(('generic', 100, 'num', 'recent_files_num', 'Max number of recent files:', None))
 Mixin.setPlugin('preference', 'init', pref_init)
 
 def afteropen(win, filename):

File [changed]: Search.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/S​earch.py?r1=1.1&​r2=1.2
Delta lines: +43 -3
--------------------
--- Search.py 12 May 2004 07:04:19 -0000 1.1
+++ Search.py 13 May 2004 07:04:49 -0000 1.2
@@ -1,6 +1,9 @@
+"""Search process"""
+
 import wx
 import Mixin
 import FindReplaceDialog
+import Resource
 
 menulist = [ (0, #parent menu id
     [
@@ -10,12 +13,49 @@
     [
         (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, None, 'Find next occurance of text'),
- (304, 'IDM_SEARCH_FIND_PREVIOUS', 'Find Previous\tCtrl+Shift+F3', wx.ITEM_NORMAL, None, 'Find previous occurance of 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'),
     ]),
 ]
 Mixin.setMixin('mainframe', 'menulist', menulist)
 
+findresfile = 'resources/finddialog.xrc'
+Mixin.setMixin('mainframe', 'findresfile', findresfile)
+
+def init(win):
+ win.finder = FindReplaceDialog.Finder()
+Mixin.setPlugin('mainframe', 'beforeinit', init)
+
+def documentchange(win):
+ win.mainframe.finder​.setWindow(win.docum​ent)
+Mixin.setPlugin('editctrl', 'documentchange', documentchange)
+
 def OnSearchFind(win, event):
- FindReplaceDialog.Fi​ndDialog(win, None)
+ dlg = Resource.loadfromres​file(win.findresfile​, win, FindReplaceDialog.FindDialog, 'FindDialog', win.finder)
+ 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)
+
+preflist = [
+ ('generic', 120, 'num', 'max_findtext_num', 'Max number of saved find text:', None)
+]
+Mixin.setMixin('preference', 'preflist', preflist)
+
+def pref_init(pref):
+ pref.max_findtext_num = 20
+ pref.findtexts = []
+Mixin.setPlugin('preference', 'init', pref_init)
+

File [changed]: StatusBar.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/S​tatusBar.py?r1=1.1​&r2=1.2
Delta lines: +2 -2
-------------------
--- StatusBar.py 12 May 2004 07:04:19 -0000 1.1
+++ StatusBar.py 13 May 2004 07:04:49 -0000 1.2
@@ -2,6 +2,6 @@
 import wx
 
 def init(win):
- win.statusbar = win.CreateStatusBar(3)
- win.SetStatusWidths([-1, 60, 60])
+ win.statusbar = win.CreateStatusBar(4, 0)
+ win.SetStatusWidths([-1, 60, 60, 40])
 Mixin.setPlugin('mainframe', 'init', init)

File [changed]: __init__.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/_​_init__.py?r1=1.1​&r2=1.2
Delta lines: +2 -0
-------------------
--- __init__.py 12 May 2004 07:04:19 -0000 1.1
+++ __init__.py 13 May 2004 07:04:49 -0000 1.2
@@ -12,4 +12,6 @@
     'icon',
     'RecentFile',
     'Search',
+ 'OnPosition',
+ 'Lineending',
 ]

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

File [changed]: FindReplaceDialog.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​FindReplaceDialog.py​?r1=1.1&r2=1.2
Delta lines: +152 -112
-----------------------
--- FindReplaceDialog.py 12 May 2004 07:04:19 -0000 1.1
+++ FindReplaceDialog.py 13 May 2004 07:04:49 -0000 1.2
@@ -1,114 +1,98 @@
-# Programmer: Daniel Pozmanter
-# E-mail: drpython at bluebottle dot com
-# Note: You must reply to the verification e-mail to get through.
-#
-# Copyright 2003-2004 Daniel Pozmanter
-#
-# Distributed under the terms of the GPL (GNU Public License)
-#
-# DrPython is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-#FindReplace Dialog
-
 import wx
 import wx.stc
-import wx.lib.dialogs
+#import wx.lib.dialogs
 import re
 import wx.xrc
+import Resource
 
-class drFinder:
- #copy old finder limodou 2004/04/19
- #def __init__(self, parent):
- def __init__(self, parent, oldfinder=None):
- #end limodou
- self.parent = parent
- self.reset()
- #copy old finder limodou 2004/04/19
- self.Copy(oldfinder)
- #end limodou
-
- #copy old finder limodou 2004/04/19
- def Copy(self, finder):
- if finder:
- self.findtext = finder.findtext
- self.findflags = finder.findflags
- self.backwards = finder.backwards
- #end limodou
-
- def DoFind(self, findtext, findflags, backwards):
- doclength = self.parent.txtDocum​ent.GetLength()
-
- self.findtext = findtext
- self.findflags = findflags
- self.backwards = backwards
-
- prev = self.lastpos
-
- if (backwards):
- endpos = self.targetStart
- if (self.lastpos >= doclength) or (self.lastpos < 0):
- self.lastpos = doclength
- else:
- endpos = self.targetEnd
- if (self.lastpos >= doclength) or (self.lastpos < 0):
- self.lastpos = 0
-
- self.lastpos = self.parent.txtDocum​ent.FindText(self.la​stpos, endpos, findtext, findflags)
-
- if (self.lastpos == -1):
- if (prev > self.targetStart):
- self.lastpos = self.targetStart
- d = wx.lib.dialogs.Scrol​ledMessageDialog(sel​f.parent, ("End of document reached."), "DrPython Find")
- d.ShowModal()
- d.Destroy()
+class Finder:
+ def __init__(self):
+ self.findtext = ""
+ self.regular = False
+ self.rewind = True
+ self.matchcase = False
+ self.wholeword = False
+ self.inselection = False
+ self.fromcursor = True
+
+ def getFlags(self):
+ flags = 0
+ if self.wholeword:
+ flags |= wx.stc.STC_FIND_WHOLEWORD
+ if self.matchcase:
+ flags |= wx.stc.STC_FIND_MATCHCASE
+ if self.regular:
+ flags |= wx.stc.STC_FIND_REGEXP
+
+ return flags
+
+ def setWindow(self, win):
+ self.win = win
+
+ def beginFind(self, direction=0):
+ """win is a STC window"""
+
+ 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
+ if self.regular:
+ self.findReNext()
+ else:
+ self.findNext()
+ else:
+ self.findPrev()
+
+ def findNext(self):
+ end = self.win.GetLength()
+ pos = self.win.FindText(self.lastpos, end, self.findtext, self.getFlags())
+ if pos == -1: #not found
+ if self.rewind:
+ pos = self.win.FindText(0, self.lastpos, self.findtext, self.getFlags())
+ if pos == -1:
+ wx.MessageDialog(self.win, "Cann't find the text [%s]" % self.findtext, "Find result", wx.OK).ShowModal()
                 return
- d = wx.lib.dialogs.Scrol​ledMessageDialog(sel​f.parent, ("Search string \"" + findtext + "\" not found"), "DrPython Find")
- d.ShowModal()
- d.Destroy()
+ self.lastpos = pos
+ self.win.GotoPos(pos + len(self.findtext))
+ self.win.EnsureCaretVisible()
+ self.win.SetSelectionStart(pos)
+ self.win.SetSelectionEnd(pos + len(self.findtext))
+
+ def findPrev(self):
+ pos = self.win.FindText(self.lastpos, 0, self.findtext, self.getFlags())
+ if pos == -1: #not found
+ if self.rewind:
+ pos = self.win.FindText(se​lf.win.GetLength(), self.lastpos, self.findtext, self.getFlags())
+ 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.win.GotoPos(pos)
+ self.win.EnsureCaretVisible()
+ self.win.SetSelectionStart(pos)
+ self.win.SetSelectionEnd(pos + len(self.findtext))
 
- self.parent.txtDocum​ent.GotoPos(self.las​tpos)
- self.parent.txtDocum​ent.EnsureCaretVisib​le()
- self.parent.txtDocum​ent.SetSelectionStar​t(self.lastpos)
- self.parent.txtDocum​ent.SetSelectionEnd(​self.lastpos + len(findtext))
-
- if (backwards):
- self.lastpos = self.lastpos - 1
- else:
- self.lastpos = self.lastpos + 1
-
- def DoREFind(self, findtext, matchcase):
- self.RE = 1
- doclength = self.parent.txtDocum​ent.GetLength()
-
- self.findtext = findtext
- self.findflags = matchcase
+ def findReNext(self):
+ doclength = self.win.GetLength()
         
         prev = self.lastpos
         
         case = 0
- if (not matchcase):
+ if (not self.matchcase):
             case = re.IGNORECASE
         
- regularexpression = re.compile(findtext, case | re.MULTILINE)
+ regularexpression = re.compile(self.findtext, case | re.MULTILINE)
                 
         endpos = self.targetEnd
         if (self.lastpos >= doclength) or (self.lastpos < 0):
             self.lastpos = 0
                         
- matchedtext = regularexpression.se​arch(self.parent.txt​Document.GetText()[s​elf.lastpos:endpos])​
+ matchedtext = regularexpression.se​arch(self.win.GetTex​t()[self.lastpos:end​pos])
                 
         if matchedtext is None:
             if (prev > self.targetStart):
@@ -256,18 +240,6 @@
                     
         return x
     
- def reset(self):
- self.findflags = 0
- self.lastpos = 0
- self.backwards = 0
- self.findtext = ""
- self.targetStart = 0
- self.targetEnd = 0
- self.RE = 0
- #copy old finder limodou 2004/04/19
- self.SetTargetRange(​self.parent.txtDocum​ent.GetCurrentPos(),​ self.parent.txtDocum​ent.GetTextLength())​
- #end limodou
-
     def SetFindPos(self, findpos):
         self.lastpos = findpos
         
@@ -491,14 +463,82 @@
         self.txtSearchFor.Se​tValue(findstring)
         self.txtSearchFor.Se​tSelection(0, len(findstring))
 
-class FindDialog:
- resfile = 'finddialog.xrc'
+class FindDialog(wx.Dialog):
+ resfile = 'resources/finddialog.xrc'
+
+ def __init__(self, *args, **kwargs):
+ wx.Dialog.__init__(self, *args, **kwargs)
 
- def __init__(self, parent, finder):
- self.parent = parent
+ def init(self, finder):
+ self.finder = finder
+ self.pref = finder.win.pref
+ wx.EVT_BUTTON(self, self.ID_FIND, self.OnFind)
+ wx.EVT_BUTTON(self, self.ID_CLOSE, self.OnClose)
+ wx.EVT_CHECKBOX(self, self.ID_REGEX, self.OnCheckRegular)
+
+ text = self.finder.win.GetS​electedText()
+ eolmode = self.finder.win.GetEOLMode()
+ if eolmode == wx.stc.STC_EOL_CR:
+ eolchar = '\r'
+ elif eolmode == wx.stc.STC_EOL_CRLF:
+ eolchar = '\r\n'
+ else:
+ eolchar = '\n'
+# if (len(text) > 0) and (len(text.splitlines()) == 0):
+ if (len(text) > 0) and (text.count(eolchar) == 0):
+ self.obj_ID_FINDTEXT​.SetValue(text)
+ self.finder.findtext = text
+ for c in text:
+ print ord(c)
+ print 4
+ else:
+ self.obj_ID_FINDTEXT​.SetValue(self.finde​r.findtext)
+ print self.finder.findtext
+ print 5
+
+ for s in self.pref.findtexts:
+ self.obj_ID_FINDTEXT.Append(s)
+
+ 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())
+
+ def addString(self, text):
+ if self.pref.findtexts.count(text) > 0:
+ self.pref.findtexts.​remove(text)
+ self.pref.findtexts.insert(0, text)
+ else:
+ self.pref.findtexts.insert(0, text)
+ while len(self.pref.findtexts) > self.pref.max_findtext_num:
+ del self.pref.findtexts[-1]
+
+ self.pref.save()
+
+ self.obj_ID_FINDTEXT.Clear()
+ for s in self.pref.findtexts:
+ self.obj_ID_FINDTEXT.Append(s)
+
+ self.obj_ID_FINDTEXT​.SetValue(text)
+ self.obj_ID_FINDTEXT.SetMark(0, len(text))
+
+ def OnClose(self, event):
+ self.Destroy()
+
+ def OnCheckRegular(self, event):
+ self.obj_ID_WHOLEWOR​D.SetValue(0)
+ self.obj_ID_WHOLEWOR​D.Enable(not self.obj_ID_REGEX.GetValue())
+ if self.obj_ID_REGEX.GetValue():
+ self.obj_ID_DIRECTIO​N.SetSelection(not self.obj_ID_REGEX.GetValue())
+ self.obj_ID_DIRECTIO​N.Enable(not self.obj_ID_REGEX.GetValue())
+
+ def OnCheckInSelection(self, event):
+ self.obj_ID_FROMCURS​OR.SetValue(0)
+ self.obj_ID_FROMCURS​OR.Enable(not self.obj_ID_INSELECT​ION.GetValue())
 
- res = wx.xrc.XmlResource(s​elf.resfile)
 
- # Now create a panel from the resource data
- dlg = res.LoadDialog(self.parent, "FindDialog")
- dlg.Show()

File [changed]: Preference.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​Preference.py?r1=1.1​&r2=1.2
Delta lines: +1 -1
-------------------
--- Preference.py 12 May 2004 07:04:19 -0000 1.1
+++ Preference.py 13 May 2004 07:04:49 -0000 1.2
@@ -15,11 +15,11 @@
 # ('generic', 100, 'num', 'recent_files_num', 10, 'Max number of recent files:', None),
 # ('HTML', 100, 'check', 'html', False, 'Html format', None),
 # ]
+ preflist = []
     defaultfile = 'newedit.opt'
 
     def __init__(self):
         self.initmixin()
- self.preflist = []
         self.callplugin('init', self)
         self.preflist.sort()
 

File [added]: Resource.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​Resource.py?rev=1.1​&content-type=tex​t/vnd.viewcvs-markup​
Added lines: 121
----------------
"""Resource processing module"""

import wx
import wx.xrc
from wx.xrc import XRCID
from Debug import *

def loadfromresfile(resfile, parent, winclass, resname, *args, **kwargs):
    """Load resource from file"""

    return loadfromres(file(res​file).read(), parent, winclass, resname, *args, **kwargs)

def loadfromres(resourceText, parent, winclass, resname, *args, **kwargs):
    """Load resource from string
    only support three kinds: Frame, Dialog, Panel
    parent parent window
    winclass the created object class
    resname the name of resource"""

    res = wx.xrc.EmptyXmlResource()
    res.LoadFromString(r​esourceText)
    if issubclass(winclass, wx.Dialog):
        res.InsertHandler(xm​lDefaultHandler(pare​nt, winclass, 'wxDialog', *args, **kwargs))
        obj = res.LoadDialog(parent, resname)
    elif issubclass(winclass, wx.Frame):
        res.InsertHandler(xm​lDefaultHandler(pare​nt, winclass, 'wxFrame', *args, **kwargs))
        obj = res.LoadFrame(winclass, resname)
    elif issubclass(winclass, wx.Panel):
        res.InsertHandler(xm​lDefaultHandler(pare​nt, winclass, 'wxPanel', *args, **kwargs))
        obj = res.LoadPanel(winclass, resname)

    return obj

class xmlDefaultHandler(wx​.xrc.XmlResourceHand​ler):
    def __init__(self, parentwin, winclass, classname, *args, **kwargs):
        wx.xrc.XmlResourceHa​ndler.__init__(self)​
        self.parentwin = parentwin
        self.winclass = winclass
        self.classname = classname
        self.args = args
        self.kwargs = kwargs
        self.ids = []

        # Specify the styles recognized by objects of this type
        self.AddStyle("wxDEF​AULT_DIALOG_STYLE", wx.DEFAULT_DIALOG_STYLE)
        self.AddStyle("wxSTAY_ON_TOP", wx.STAY_ON_TOP)
        self.AddStyle("wxDIALOG_MODAL", wx.DIALOG_MODAL)
        self.AddStyle("wxDIA​LOG_MODELESS", wx.DIALOG_MODELESS)
        self.AddStyle("wxCAPTION", wx.CAPTION)
        self.AddStyle("wxSYSTEM_MENU", wx.SYSTEM_MENU)
        self.AddStyle("wxRES​IZE_BORDER", wx.RESIZE_BORDER)
        self.AddStyle("wxRESIZE_BOX", wx.RESIZE_BOX)
        self.AddStyle("wxTHICK_FRAME", wx.THICK_FRAME)
        self.AddStyle("wxNO_3D", wx.NO_3D)
        self.AddStyle("wxTAB​_TRAVERSAL", wx.TAB_TRAVERSAL)
        self.AddStyle("wxCLI​P_CHILDREN", wx.CLIP_CHILDREN)
        self.AddStyle("wxSIM​PLE_BORDER", wx.SIMPLE_BORDER)
        self.AddStyle("wxDOU​BLE_BORDER", wx.DOUBLE_BORDER)
        self.AddStyle("wxSUN​KEN_BORDER", wx.SUNKEN_BORDER)
        self.AddStyle("wxRAI​SED_BORDER", wx.RAISED_BORDER)
        self.AddStyle("wxSTA​TIC_BORDER", wx.STATIC_BORDER)
        self.AddStyle("wxNO_BORDER", wx.NO_BORDER)
        self.AddStyle("wxTRA​NSPARENT_WINDOW", wx.TRANSPARENT_WINDOW)
        self.AddStyle("wxWANTS_CHARS", wx.WANTS_CHARS)
        self.AddStyle("wxNO_​FULL_REPAINT_ON_RESI​ZE",wx.NO_FULL_REPAI​NT_ON_RESIZE)

# self.AddWindowStyles();

    # This method and the next one are required for XmlResourceHandlers
    def CanHandle(self, node):
        id = node.GetPropVal('name', '')
        if id:
            self.ids.append(id)
            debugput("\t%s\t%s" % (node.GetPropVal('class', ''), id))
        return self.IsOfClass(node, self.classname)

    def DoCreateResource(self):

        debugput("[Resource] class %s 's object..." % self.GetName())

        # Now create the object
        if issubclass(self.winclass, wx.Dialog):
            obj = self.winclass(self.parentwin,
                self.GetID(),
                self.GetText('title'),
                self.GetPosition(),
                self.GetSize(),
                self.GetStyle()
                )
        elif issubclass(self.winclass, wx.Frame):
            obj = self.winclass(self.parentwin,
                self.GetID(),
                self.GetText('title'),
                self.GetPosition(),
                self.GetSize(),
                self.GetStyle()
                )
        elif issubclass(self,winclass, wx.Panel):
            obj = self.winclass(self.parentwin,
                self.GetID(),
                self.GetPosition(),
                self.GetSize(),
                self.GetStyle(),
                self.GetName(),
                )

        # These two things should be done in either case:
        # Set standard window attributes
        self.SetupWindow(obj)
        # Create any child windows of this node
        self.CreateChildren(obj)

        # Create IDs
        for id in self.ids:
            setattr(obj, id, XRCID(id))
            setattr(obj, 'obj_'+id, self.parentwin.FindW​indowById(XRCID(id))​)

        # Call object init
        obj.init(*self.args, **self.kwargs)

        return obj

Directory: /newedit/src/resources/
====================​==============

File [added]: finddialog.xrc
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/resource​s/finddialog.xrc?rev​=1.1&content-typ​e=text/vnd.viewcvs-m​arkup
Added lines: 59
---------------
<?xml version="1.0" encoding="utf-8"?>
<resource>
  <object class="wxDialog" name="FindDialog">
    <title>Find...​</title>
    <centered>1​</centered>
    <size>400,142​</size>
    <style>wxDEFAU​LT_DIALOG_STYLE</​style>
    <object class="wxComboBox" name="ID_FINDTEXT">
      <content/>
      <pos>80,8</pos>
      <size>200,-1</size>
    </object>
    <object class="wxButton" name="ID_FIND">
      <label>Find</label>
      <default>1<​/default>
      <pos>320, 7</pos>
      <size>60, 22</size>
    </object>
    <object class="wxButton" name="ID_CLOSE">
      <label>Close​</label>
      <pos>320, 37</pos>
      <size>60, 22</size>
    </object>
    <object class="wxCheckBox" name="ID_MATCHCASE">
      <label>Match Case</label>
      <pos>10, 40</pos>
    </object>
    <object class="wxCheckBox" name="ID_WHOLEWORD">
      <label>Whole Word</label>
      <pos>10, 60</pos>
    </object>
    <object class="wxRadioBox" name="ID_DIRECTION">
      <label>Directi​on</label>
      <content>
        <item>Forwards​</item>
        <item>Backward​s</item>
      </content>
      <pos>100, 30</pos>
      <style>wxRA_SP​ECIFY_ROWS</style​>
    </object>
    <object class="wxCheckBox" name="ID_REGEX">
      <label>Regular Expression</label>
      <pos>10, 80</pos>
    </object>
    <object class="wxCheckBox" name="ID_FROMCURSOR">
      <label>Search from cursor</label>
      <pos>10, 100</pos>
    </object>
    <object class="wxCheckBox" name="ID_REWIND">
      <label>Rewind as reached the end of the file</label>
      <checked>1<​/checked>
      <pos>150, 80</pos>
    </object>
    <object class="wxStaticText">
      <label>Find for:</label>
      <pos>10,10</pos>
    </object>
  </object>
</resource>




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