phreplace Goes Open Source
Warning: Please consider that this post is over 8 years old and the content may no longer be relevant.
I’ve decided to release phreplace as open source software in order to continue it’s development, I no longer have the time to give it the attention it requires.
The VB6 source code will be released under the GNU Lesser General Public License (LGPL), in my understanding this means that anyone can use phreplace and even include the library in a greater works (e.g. PSPad), however if they modify the code it must be released under a similar open source library, in order that everyone will benefit from the changes.
The source code is available at Assembla, feel free to send any code changes to me to be included in the project.
I rewrote phreplace in early 2009 when I was studying design patterns and as such the VB6 source code is heavily object-oriented and pattern focused. VB6 is not strictly an oo language but it does support inheritance through the ‘Implements’ keyword.
phreplace uses the iterator, observer and factory methods. I found some of the sample chapters of Visual Basic design patterns: VB 6.0 and VB.NET By James William Cooper on Google Books a very useful resource.
This early class architecture diagram (PDF) may help decipher some of the code design.
phreplace was designed to be application agnostic, it currently works only with PSPad but I hoped that by implementing only a few interfaces (IHostAdapter, IDocument and IDocumentCollection) it could work with any other editor that supported the basic operations required. My next intended editor to support was SciTE.
The first major change that I would like to see is support for Vista / Windows 7. At present the phreplace.vbs script intialises the application by checking to see if the phreplace.dll library is registered, if it isn’t it tries to register it with regsvr32. This works for Windows XP but standard users aren’t able to register libraries in Vista / Windows 7. So far I have come up with 3 solutions.
- Override DllRegisterServer using vbAdvance. I can’t get this library to work. See Registering phreplace DLL in Windows Vista.
- Create a separate utility similar to regsvr32 and include this with phreplace. I think this is messy. Again see Registering phreplace DLL in Windows Vista.
- Use the Registration-Free COM solution of adding a manifest file for PSPad which references the phreplace.dll library so that we don’t have to register it in the registry at all. This solution works for XP, see the reg-free-com branch of the source code, but doesn’t seem to work for Vista. My theory is that perhaps Vista handles vbscript differently, so it doesn’t inherit the PSPad manifest. If someone could get this working I think this is the most elegant solution.
I look forward to seeing user contributions to this project.