5,693,062 members and growing! (15,622 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » General     Intermediate

Fireball.CodeEditor

By dotnetfireball

Fireball.CodeEditor is simple and complete control for create source code editing controls
C#, Windows, .NET, Visual Studio, Dev

Posted: 4 Jan 2006
Updated: 30 Apr 2006
Views: 107,163
Bookmarked: 145 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
37 votes for this Article.
Popularity: 6.27 Rating: 4.00 out of 5
5 votes, 13.5%
1
0 votes, 0.0%
2
2 votes, 5.4%
3
8 votes, 21.6%
4
22 votes, 59.5%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article
For a binary release go at DotNetFireball SourceForge.net page

FireEdit screenShot

N.B. For FireEdit source code go at DotNetFireball SourceForge Page

Introduction

Fireball.CodeEditor is an source code editor control derived from the best compona SyntaxBox Control, because compona as recently released it as LGPL, i have imported it on my framework,because imported? because i need to add some changes and solve some issue, example;

BUG: The original source code of the compona don't work on C#, Visual Studio 2005.

FIXED: Fireball.CodeEditor work correctly on C# 2.0 and on Visual Studio 2005 Designer!

Removed some bad try catch statment and replaced with if statment because are more speedly.

BUG: The original compona code, caret don't position correctly on presence of { and (

FIXED: This is a p/invoke issue because C# 2.0 don't work on the same mode as C# 1.0 for p/invoke, i have find this bug simply removing all try catch!

On the Fireball Framework the needed dll's are this Fireball.CodeEditor ( this contains the CodeEditorControl ), Fireball.Windows.Forms ( this contains some widgets use by the CodeEditorControl ),Fireball.SyntaxDocument ( this contain the SyntaxDocument used by the CodeEditorControl) and Fireball.Core! that contains some low level api like GDIObject, it is also present another library the Fireball.CodeEditor.SyntaxFiles this is only a utils library that contains some standard syntax files for common programming languages and a class for fast loading this.

Background

On this article i explain the basic usage of this control, this article article can't cover advanced use of this control, it is only an introduction, i can write more about the CodeEditorControl on the future, for use the example on this article you need to download and compile all libraries, the compile order is this,

  1. Fireball.Core
  2. Fireball.Windows.Forms
  3. Fireball.SyntaxDocument
  4. Fireball.CodeEditor
  5. Fireball.CodeEditor.SyntaxFiles

Next you can compile the example of this article.

Note: You need to change the build output directory because it set for working with fireball repository structure.

Using the code

N.B The demo illustrated on this article is a really working Fireball application called FireEdit! 

For find a dettailed use of this libraries you can see the code, next i put some line of that illustrate the use of CodeEditorControl.

Adding an istance of CodeEditorControl to your form is very simple, you need only to add to your toolbox the Fireball.CodeEditor.dll, or you can also istance it manualy with this lines of code.

...
using Fireball.Windows.Forms; // Where is located CodeEditorControl class
using Fireball.Syntax; // Where is located SyntaxDocument class
using Fireball.CodeEditor.SyntaxFiles; // Where is located commons SyntaxFiles


 public class yourclass : Form
 {
     public yourclass()
     {
        CodeEditorControl codeEdit = new CodeEditorControl();
        
        this.Controls.Add(codeEdit );
        
        codeEdit.Dock = DockStyle.Fill;

        codeEdit.Document = CodeEditorSyntaxLoader.SetSyntax(codeEdit, SyntaxLanguage.CSharp);        
    }
}
 

You have istanced your own CodeEditor! very simple!!

What is SyntaxLanguage? is an enumeration that contains a list of the common languages, see the enum,

    public enum SyntaxLanguage
    {
        Lang6502 = 0,
        ASP = 1,
        CPP = 2,
        Cobol = 3,
        CSharp = 4,
        CSS = 5,
        DataFlex = 6,
        Delphi = 7,
        DOSBatch = 8,
        Fortran90 = 9,
        FoxPro = 10,
        Java = 11,
        JavaScript = 12,
        JSP = 13,
        LotusScript = 14,
        MSIL = 15,
        MySql_SQL = 16,
        NPath = 17,
        Oracle_SQL = 18,
        Perl = 19,
        PHP = 20,
        Povray = 21,
        Python = 22,
        Rtf = 23,
        SmallTalk = 24,
        SqlServer2K = 25,
        SqlServer7 = 26,
        SystemPolicies = 27,
        Template = 28,
        Text = 29,
        TurboPascal = 30,
        VBNET = 31,
        VB = 32,
        VBScript = 33,
        VRML97 = 34,
        XML = 35,
    }
 

The CodeEditorControl give to you a simple way for implementing a little editor and professional editor, on the control you have some nice commands like clipboard function, Cut, Copy and Paste, the control also can split in multiple views, see the class diagram here
The control also contains some function for text search and replace.

Now you need to see the FireEdit code is more explicative to see code than read an article ;)

If you need more help don't esitate to enter my forum at http://www.dotnetfireball.net, and ask your question.

if you are interested to contribute to the project with producing path, new functionalities or Documentation please contact me on my forum.

Thanks

Thanks to compona.com for have released SyntaxBox as LGPL, and gived to me the possibility to correct it's bug.

History

30/04/2006 - Fixed some bugs, released as beta 2 31/03/2006 - Fixed some bugs, thanks to my users for helping me, coming soon a beta 2 19/02/2006 - Updated with the last version of Fireball Source Code, Fixed an issue with IntelliMouse, now the source code of FireEdit is only available at http://www.codeproject.com/useritems/fireedit.asp 14/02/2006 - Fixed an overload error on Fireball.Core GDIBitmap and Fixed a bug TabStrip control. 4/02/2006 - Updated article with zip files and with last version of source code
29/01/2006 - Merged some fixes maked by Roger (Compona) that solve an issue with font assignement and added IME Window for international support
15/01/2006 - Added a new method CenterInView on EditViewControl (Thx to Marcel Isler for contribution), and you now get the Active View with the method ActiveViewControl on CodeEditorControl.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

dotnetfireball



Occupation: Web Developer
Location: Italy Italy

Other popular Miscellaneous articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 116 (Total in Forum: 116) (Refresh)FirstPrevNext
GeneralMy vote of 1mvpPete O'Hanlon12:23 25 Nov '08  
GeneralCredit where credit is duememberRoger Alsing1:52 12 Jun '08  
GeneralRe: Credit where credit is duemvpPete O'Hanlon12:21 25 Nov '08  
GeneralCompiling FireFx-RC2_0_0_46memberrobotuner16:02 20 Dec '07  
GeneralNewbie questionsmemberpactis13:51 27 Nov '07  
GeneralWhitespaces instead of tabsmemberLaubi23:49 18 Nov '07  
GeneralGreat Job!memberSantiago Corredoira8:34 11 Nov '07  
GeneralCongrats & bugmemberItaniumX10:21 10 Nov '07  
GeneralHimemberGinanity8:41 2 Nov '07  
GeneralRe: Himemberdotnetfireball11:26 7 Nov '07  
GeneralLine WrapmemberJack_Cai5:34 17 Oct '07  
GeneralHow to add a languagememberchenjin_seu23:36 19 Sep '07  
GeneralRe: How to add a languagememberJack_Cai1:56 17 Oct '07  
QuestionRe: How to add a languagememberMarijn Stevens4:40 15 Mar '08  
GeneralGet Current Token / Blockmemberdanielku1513:41 24 Aug '07  
QuestionASP syntax file gone?membersamtaz4:32 19 Jul '07  
AnswerRe: ASP syntax file gone?memberdanielku1513:23 24 Aug '07  
GeneralMore note on Undo/redomembergokkor2:02 8 May '07  
GeneralFocused doesn't workmemberMarco Bellocchi3:39 4 May '07  
GeneralDocking BugmemberTerzy14:03 11 Apr '07  
Generalhow to export the doc (with formating)memberuniquekaiser18:38 9 Apr '07  
GeneralRegion and function collapsingmemberEnriad23:00 2 Apr '07  
GeneralRe: Region and function collapsingmemberuniquekaiser18:36 9 Apr '07  
GeneralRe: Region and function collapsingmemberEnriad5:24 10 Apr '07  
Generaltwo fixesmembergokkor0:03 26 Mar '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 30 Apr 2006
Editor:
Copyright 2006 by dotnetfireball
Everything else Copyright © CodeProject, 1999-2008
Web18 | Advertise on the Code Project