讲述如何开发一个控件,很有价值
The Unofficial Newsletter of Delphi Users
by Robert Vivrette
Automatic Syntax Highlighting Using a RichEdit Control (Updated with fixes)
Part 1 of "A Tale of Two RichEdits"
by Jon Hogan-Doran - jonhd@hotmail.com
Introduction
As a new programmer to Delphi, with a history in C, C++, Unix shells and a little Awk and Perl, I came to it with a particular goal in mind. I wanted to implement an Editor for a Australian-4GL Databse language called cl4. Having little to no experience in Windows programming, except some dalliance in Powerbuilder and SQLExpress, it seemed a pretty imposing goal.
One is often taught when learning a new language to read a few books, tryout the samples and then start some simple coding. Unfortunately Im a bit of a sado-masochist, and love to jump in with all 10 fingers (and 10 toes) and try to implement the most difficult parts first, and all at once. Being able to print "Hello World" never caught my interest.
I guess I had a bad upbringing. I started programming by jumping into a language called "C" on SCO Xenix in 1986 with no programming experience at all. Just a book by two guys called Kerningham and Ritchie and some C code that wouldnt compile (it was BSD Unix based from memory). When I managed to get it to compile after 2 weeks, I decided to port the BinkleyTerm FidoNet mailer to Unix, while concurrently getting all the associated programs ported from Dos as well (the Fido mailer, Newsgroup controller, a entire BBS Program). I think I had 5 different DOS->UNIX programs compiling on 5 different virtual consoles all at once.
12 Months later and my [DosLib] and [FossilDriver] were done, BinkleyTerm was getting me my first newsgroups (comp.os.xenix.???) from a local friendly Sysop, and I was chewing up $1,000 in overseas phone bills organising a world-wide group of programmers to try out my handiwork.
So with Delphi I started on my next big challenge. I didnt want just any old editor for my old 4GL Unix database language. I wanted it all:
- code-highlighting
- on the spot syntax highlighting
- code completion and suggesting
- remote compile capabilities to my Linux box
- jump to line with error
- even a remote visual debugger
plus lots more goodies.
This is my adventure. Its a story not a traditional tutorial - the codes there if your not interested in reading my little tale. But if you are: sit back with a packet of chips and plenty of caffeine. And enjoy....
The Plan
No-one wants to re-invent the wheel. The whole point of OOP (Object oriented programming) is the reusability of objects. The whole point of the Internet was the reusability of someone elses object. Luckily I had read enough about these component "things" to want to find some more. So I connected up to the Internet and went "shopping".
My shopping list:
- Internet controls (telnet, remote shell, remote execute, ftp)
- Editor with multi-file capabilities
- Syntax highlighter or Parser
- Automatic Syntax highlighting
I shopped at:
- Delphi Super Page
- Torris page
- Borland
- RxLibs
- RzLibs
- QuickReport Homepage
Within 4 hour I was off the net with a number of goodies, 23 or so assorted controls, programs and Internet suites, (and plenty of stuff that had nothing to do with the current project, but I thought might be of use on my next one). Eventually I whittled the choices down to:
YourPasEdit | by D C AL CODA, Ken Hale and Coda Hale | PasToRTF | by Martin Waldenburg (included in above) | TntClient | by Francois Piette (and associated ICS suite) | RxTools | by those great Russian dudes. YourPasEdit was a great find, and its description said it all:
|