advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the sample projects for this article.
An Aside: The Hippocratic Oath for Software Designers
Partners & Affiliates
advertisement
advertisement
Average Rating: 3/5 | Rate this item | 1 user has rated this item.
 Print Print
 
.NET Building Blocks: Build a RichTextBox-Based Syntax-Highlighting Editor and IDE
By using the RichTextbox as a base control, you can build an editor that highlights keywords and quoted strings—or even an editor that employs IDE-like smart indentation and runs script code interactively. 

advertisement
ow difficult do you think it would be to create a SQL tool like Query Analyzer or SqlServer Management Studio? How about a programming and execution framework for VBScript? Or how about a dual code-and-WYSIWYG editor for HTML—or a development IDE for creating and testing XSLT transformations? And why would you bother programming your own tool when there are many fine commercial products in each of these categories?


It turns out there are several reasons. For example, you may want to incorporate such a tool as an integral component of your product. Or perhaps you just have a favorite tool that you find mostly adequate, but that you'd prefer to be able to customize to your own specifications. In this article, I'll show you tools and techniques that will facilitate building such applications.

It's important to realize that all the tools I've mentioned so far use a common model—the classic input-process-output model illustrated in Figure 1.

However, this high-level system description is applicable to a much broader range of applications than the ones already listed, and—indeed—in many systems besides software. Figure 2 shows a more refined model that fits the types of tools under consideration more closely. That is, all these tools fundamentally provide an interactive editor control for input and a textual, tabular, or graphical control for output. I submit that any of the four tools I mentioned could essentially make use of the same type of interactive editor control. Consider Visual Studio's own built-in editor, which performs keyword highlighting, automatic block indentation, word completion (Intellisense), and much more, for a variety of languages. I will give you ideas on how to start creating your own such editor here. I am not going to cover everything that the Visual Studio editor can do, but I shall provide a complete component solution for keyword highlighting for an arbitrary language of your choice, block commenting and indenting, external compilation and execution, and other useful features. Then, I'll walk you through the process of incorporating that component into an elementary integrated development environment (IDE) using two different application types: a SQL query tool and a VBScript execution framework.

 
Figure 1. Classical Process Model: The classic high-level model accepts input, performs some processing on that input, and delivers some output.
 
Figure 2: IDE-Tailored Model. Building an IDE requires an interactive editor for input, a processing engine (which may be internal or external), and a way to render the resulting output.
Application One: An IDE for SqlServer
The code download that accompanies this article includes source code for a demo SyntaxHilightAndEditDemo project that you'll build during this article. The project uses an external library. The necessary library components are already included with the demo project but the source for those components is not; however, you can download the source code for the library components from my open source web site.

One of the library components is a control called a SyntaxHilightTextBox, based on a RichTextBox. The SyntaxHilightTextbox is my core user editor control. You'll see how to use it in the first walkthrough.

To begin, create a new Visual Studio project using the Windows Application template. You'll need to add some controls to your toolbox. Right click on the toolbox in the visual designer and select "Choose Items…" That brings up the dialog shown in Figure 3. The checked items are already added to your toolbox.

The component you're looking for won't appear in the list, though, so click the Browse button, and then navigate to the CleanCodeControls.dll file ( see Figure 4) that you'll find in the downloadable code accompanying this article. Select the file, and then click the Open button.

 
Figure 3. Choosing Toolbox Items: The context menu for the toolbox allows you to customize what is displayed in your toolbox.
 
Figure 4. Adding Toolbox Items: Selecting Browse from the toolbox items dialog lets you access libraries of your choice—in this case, the CleanCodeControls library.
When you click the Open button, Visual Studio adds the controls from the CleanCodeControls library to the list of available items and automatically checks them (see Figure 5).

 
Figure 5. New Controls: After selecting the library file, Visual Studio adds controls in the library to the list and checks them.
 
Figure 6. CleanCodeControls Added to the Toolbox: The new controls appear at the bottom of the toolbar on the left. The enlargement in the middle of the screen shows the items clearly.
Click OK to close the dialog and update your toolbox. You'll find the CleanCode controls at the bottom of the toolbox, including two subclasses of the SyntaxHilightTextBox, one for SqlServer and one for Oracle (see Figure 6).

Page 1 of 6


advertisement
  Next Page: Adding the Controls
Page 1: IntroductionPage 4: Control Operations
Page 2: Adding the ControlsPage 5: Application Two: A VBScript IDE
Page 3: Get Under the SyntaxHilightTextBox's CoversPage 6: Creating Your Own Language-Aware IDE
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES