Click here to Skip to main content
6,595,854 members and growing! (18,207 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:132,001
Bookmarked:164 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
40 votes for this article.
Popularity: 6.24 Rating: 3.90 out of 5
6 votes, 15.0%
1

2
2 votes, 5.0%
3
10 votes, 25.0%
4
22 votes, 55.0%
5
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


Member

Occupation: Web Developer
Location: Italy Italy

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 122 (Total in Forum: 122) (Refresh)FirstPrevNext
GeneralSelectionError [modified] Pinmembertigor13:15 3 Jul '09  
GeneralMy vote of 1 Pinmembercraigd14:53 14 Feb '09  
QuestionSome words are lower case... Pinmembertigor3:48 7 Jan '09  
GeneralChinese or Japanese IME Problem Solved Pinmemberhelanmouse2:08 6 Jan '09  
GeneralMy vote of 1 PinmvpPete O'Hanlon12:23 25 Nov '08  
GeneralCredit where credit is due PinmemberRoger Alsing1:52 12 Jun '08  
GeneralRe: Credit where credit is due PinmvpPete O'Hanlon12:21 25 Nov '08  
General'correct' link for the _real_ code [modified] Pinmembercraigd14:52 14 Feb '09  
GeneralRe: Credit where credit is due PinmemberNorm .net22:42 27 Apr '09  
GeneralCompiling FireFx-RC2_0_0_46 Pinmemberrobotuner16:02 20 Dec '07  
GeneralNewbie questions Pinmemberpactis13:51 27 Nov '07  
GeneralWhitespaces instead of tabs PinmemberLaubi23:49 18 Nov '07  
GeneralGreat Job! PinmemberSantiago Corredoira8:34 11 Nov '07  
GeneralCongrats & bug PinmemberItaniumX10:21 10 Nov '07  
GeneralHi PinmemberGinanity8:41 2 Nov '07  
GeneralRe: Hi Pinmemberdotnetfireball11:26 7 Nov '07  
GeneralLine Wrap PinmemberJack_Cai5:34 17 Oct '07  
GeneralHow to add a language Pinmemberchenjin_seu23:36 19 Sep '07  
GeneralRe: How to add a language PinmemberJack_Cai1:56 17 Oct '07  
QuestionRe: How to add a language PinmemberMarijn Stevens4:40 15 Mar '08  
GeneralGet Current Token / Block Pinmemberdanielku1513:41 24 Aug '07  
QuestionASP syntax file gone? Pinmembersamtaz4:32 19 Jul '07  
AnswerRe: ASP syntax file gone? Pinmemberdanielku1513:23 24 Aug '07  
GeneralMore note on Undo/redo Pinmembergokkor2:02 8 May '07  
GeneralFocused doesn't work PinmemberMarco Bellocchi3:39 4 May '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-2009
Web15 | Advertise on the Code Project