首 页 网络编程
网页制作 图形图象 操作系统 冲浪宝典
软件教学 认证考试

网络安全 网络办公 行业资讯 评测对比
您当前位置:站长天空 -> 网络编程-> 移动开发教程
讲述如何开发一个控件,很有价值_delphi教程
作者:网友供稿 点击:0
推荐
西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!可在线rar解压,自动数据恢复设置虚拟目录等.免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金
站内搜索
文章页数:[1] 

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:

  1. code-highlighting
  2. on the spot syntax highlighting
  3. code completion and suggesting
  4. remote compile capabilities to my Linux box
  5. jump to line with error
  6. 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:

  1. Internet controls (telnet, remote shell, remote execute, ftp)
  2. Editor with multi-file capabilities
  3. Syntax highlighter or Parser
  4. 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:
 

There are three main features in YourPasEdit. First is the PAS to RTF conversion unit, contained in mwPasToRtf.pas, by Martin Waldenburg. The second shows how to create TabSheets at run time, with a RichEdit. The third are the procedures written by Andrius Adamonis, which allow YourPasEdit to be associated with files and to open those files in the running instance of YourPasEdit, creating a new TabSheet and RichEdit for the newly opened file.

Unfortunately it also told me:
 

It is not intended to be a full Delphi file editor, because it does not highlight keywords on the fly, like a syntax aware editor.

But I wasnt complaining - I needed some challenge - otherwise it wouldnt be any fun! So I delved into how things were being done in YourPasEdit. To get the best from the following sections you should get your hands on at least YourPasEdit so you can follow and (more importantly) program along.
 

Syntax highlight (YourPasEdit)

In YourPasEdit, syntax highlighting was done by parsing the plain text file, dividing each line of text into separate "Tokens", working out what TokenType each token was, and formatting them based on preset Font and Color settings. The following tokens were supported, corresponding to the Token types in the Delphi 3.0 Editor: TTokenState = (tsAssembler, tsComment, tsCRLF, tsDirective, tsIdentifier, tsKeyWord, tsNumber, tsSpace, tsString, tsSymbol, tsUnknown);

How these tokens were formatted (that is with what Color and Attributes) was determined by using the Delphi 3.0 Editors own settings as they are stored in the Windows Registry. Basically a line of Pascal source such as:
 


procedure TForm1.FormCreate(Sender: TObject); { Create the Form }


文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

文章页数:[1] 


放大字体显示 缩小字体显示 打印文章 推荐给朋友
热门文章
·ems图片格式转换(java)程序
·使用hashtable实现的购物车-ASP教程,ASP应用
·Java中数据库事务处理的实现-JSP教程,Java技巧及代码
·Oracle数据库操作类(c#)-.NET教程,C#语言
·移动短消息技术演进与业务发展浅析
·ASP生成静态网页,学习CASE的用法,以及“权限”的一种控制方法-ASP教程,组件开发
·中国电信发展移动通信的制式与频段选择
·ASP中access数据库的路径问题-ASP教程,数据库相关
·td-scdma系统移动台接入过程浅析
·JAVA与数据库连接方法(三)-JSP教程,数据库相关
最新文章
·fireworks表现vista毛玻璃朦胧效果_fireworks教程
·google adsense哪些情况会被k号_网赚技巧
·减少google adsense展示单元并不能提高收入_网赚技巧
·google adsense“允许域名”新功能很有用_网赚技巧
·于源:办南京人“淘宝”的大三学生_站长访谈
·谈谈网站策划和网站运营方面的点滴经验_站长心得
·美国网站兵败中国的10大思路性执行错误_站长心得
·付款流程中的电话确认_google推广
·google adsense的部分规则的背面_google推广
·googleadsense富翁排行榜最猛每月赚30万美元_google推广
相关主题
  • 讲述如何开发一个控件,很有价值(七)_delphi教程
  • 讲述如何开发一个控件,很有价值(六)_delphi教程
  • 讲述如何开发一个控件,很有价值(五)_delphi教程
  • 讲述如何开发一个控件,很有价值(二)_delphi教程
  • 西部数码虚拟主机

    友情链接
    CNNIC 西部数码
    万网 自助建站
    虚拟主机 asp空间
    域名注册 域名
    域名申请 主页空间
    论坛空间 网站空间
    国际域名 虚拟空间
    空间租用 DDOS防火墙
    成都主机托管 四川主机托管
    主机租用 服务器租用
    网站目录 自助建站
    虚拟主机 网址大全
    软件下载
    自助链接
    虚拟主机资讯 特价虚拟主机
    版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
    关于我们:站长天空:专业提供最新的站长资讯、在线教程、虚拟主机权威评测、虚拟主机性能对比、网站制作教程,开发教程,站长工具。包括网页制作教程、冲浪宝典、编程参考、操作系统、软件教学、行业动态等。
    特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
    发表评论 打印  刷新     关闭