Quantum Whale
Quick Info
FeedBack
Support Forum
Mail List
FAQ
Editor.NET FAQ
Ordering FAQ
Qwhale.net > Support

Editor.NET FAQ

What's the best way to starting using Editor.NET components?

The good place to start using Editor.NET components is reading user manual that can be downloaded here.
User manual describes purposes of each component and ways of using them to perform most common tasks.

Does Editor.NET support .NET Framework 2.0?

Yes, Editor.NET supports both .NET Framework 1.1 and 2.0. You can use Visual Studio 2003, Visual Studio 2005, Borland Delphi 8 for .NET and Borland Delphi 2005 as development environment for projects using Editor.NET.

How to incorporate the SyntaxEdit control into my form?

If the Editor.NET components already added to the Visual Studio/Delphi tool box, you can simply drag the SyntaxEdit component onto your form at design time. Read more about how to install components to the toolbox.
To add a SyntaxEdit control through code, you can use the following code:

QWhale.Editor.SyntaxEdit edit = new QWhale.Editor.SyntaxEdit();
edit.Parent = this;

How to set syntax highlighter for the SyntaxEdit control?

Text parsing is performed by one of the Parser non-visual components. This parser should be linked to SyntaxEdit's Lexer property.
You can use Parser component and edit Scheme property which specifies syntax highlighting rules.
Alternatively, you can use LanguageParser. LanguageParser contains all these languages in form of embedded resources allowing choosing syntax scheme via Language property.
Third way is to use dedicated SyntaxParsers, such as CsParser, JsParser, and VbParser that are designed to highlight syntax for specific languages (like C#, J# and VB.NET).

Where already designed syntax highlighting schemes are stored?

Editor.NET comes with ready-to-use schemes for more than 30 programming languages, located in the "schemes\" folder. To load one of these schemes to the Parser component you need to edit Parser's Scheme property and press Load button in the Syntax Scheme Editor dialog box.

What's the difference between using regular expressions based parsers and dedicated parsers?

Regular expressions based parser provide common way to perform syntax highlighting for the text based on parsing rules. Parsing is performed using a finite-state automaton driven by regular expressions matching the parsed text. This approach allows defining syntax highlighting rules for virtually unlimited set of programming languages.
Dedicated parsers such as CsParser, JsParser, and VbParser are designed to perform syntax highlighting for specific languages, they use hard-coded algorithm for parsing the text performing it much faster comparing to regular-expressions based parsers. These parsers actually do much more than just syntax highlighting, allowing having features that can be found in Visual Studio Editor - code outlining, intellisense, code formatting and underlying erroneous syntax tokens.

How to manage Selection in the SyntaxEdit control?

SyntaxEdit supports a concept of text selection and a wide range of operations on it. All the selection related aspects are controlled via the Selection property. For example, to execute standard actions like cut/copy/paste you need to use appropriate methods of the Selection object: Selection.Cut / Selection.Copy / Selection.Paste.

How to use Outlining feature of the SyntaxEdit control?

SyntaxEdit supports code outlining, which is a text navigation feature that can make navigation of large structured texts more effective by visually replacing them with shorter representation.
To switch outlining mode on, you need to set Outlining.AllowOutlining property to true.
There are two ways of creating outline sections. First one is direct definition of outline sections which can be implemented the following way:

syntaxEdit1.Outlining.Outline(new Point(0, 0), new Point(int.MaxValue, 0), 0, "...").Visible = false;

Another way to use SyntaxParser already supporting automatic outlining such as CsParser, JsParser, and VbParser.

How to use and customize Intellisense feature of the SyntaxEdit control?

Intellisense feature allow displaying popup windows containing related information to the Editor's context. These windows can be presented in form of popup listbox or tooltip window.
The easiest way to provide automatic invocation of Intellisense popup windows is to use dedicated parsers supporting this feature such as CsParser, JsParser, and VbParser.
Another way is to handle NeedCodeCompletion event handler to provide own data for intellisense windows.

How to save/restore additional information about bookmarks, gutter, line styles, etc. of the SyntaxEdit control?

Saving and loading state of the SyntaxEdit control is performed using XML serialization. The usage of the XML format causes the entire state of the editor and all related components (text source and syntax parser) to be serialized/deserialized. You can use the following code:

syntaxEdit.SaveFile(FileName, ExportFormat.Xml);
syntaxEdit.LoadFile(FileName, ExportFormat.Xml);

How to synchronize key properties for all SyntaxEdit controls in the application?

If the application contains more than one instance of the editor, it is quite often desired to share their UI settings, and to provide the user with a centralized facility to manage them. Editor.NET provides SyntaxSettings designed to implement this task. Settings can be saved/loaded to the specific file and assigned to the editor with the following code:

SyntaxSettings GlobalSettings = new SyntaxSettings();
GlobalSettings.LoadFile("GlobalSettings.xml");
GlobalSettings.ApplyToEdit(syntaxEdit1);

How to enable/disalbe keyboard shortcuts for the SyntaxEdit control?

While the SyntaxEdit closely mimics the keymapping common to the most of Microsoft's products, it is completely customizable: you can add or change behavior of certain keys or even define an entirely different keymapping.
To assign an action to some key combination or to remove some key handler you can use the following code:

private void syntaxEdit1_Action()
{
  // key hander here
}

syntaxEdit1.KeyList.Add(Keys.W | Keys.Control | Keys.Alt, new KeyEvent(syntaxEdit1_Action));
syntaxEdit1.KeyList.Remove(Keys.A | Keys.Control);

How to localize Search/Replace/Goto Line/Editor Settings dialogs?

All string constant used in dialogs are localized to a few foreign languages. So far Editor.NET supports German, French, Spanish, Russian and Ukrainian languages. The following code demonstrates how to switch to German language:

QWhale.Common.StringConsts.Localize(new System.Globalization.CultureInfo("de"));

How to use custom drawing for the SyntaxEdit control?

SyntaxEdit supports Custom Drawing feature allowing customizing drawing of text fragments and graphic primitives. The following code demonstrates how to highlight known identifiers with different color:

private void syntaxEdit1_CustomDraw(object sender, CustomDrawEventArgs e)
{
  LexToken tok = (LexToken)(e.DrawInfo.Style - 1);
  if ((tok == LexToken.Identifier) && (e.DrawStage == DrawStage.Before) && ((DrawState.Selection & e.DrawState) == 0))
  {
    if (knownIdentifiers.ContainsKey(e.DrawInfo.Text))
      e.Painter.TextColor = Color.Teal;
  }
}

Vertical line appearing in the SyntaxEdit control.

By default, vertical line appears at 80th character position to visually identify virtual limit of the text being typed. Appearance of this line is controlled via EditMargin property, so to hide it just set EditMargin.Visible to false.

.NET 2.0(Visual Studio) brings compiler warnings when building the solution.

This is known issue. Editor.NET was originally written using .NET Framework 1.1 and building the project under .NET 2.0 results in displaying warning about some obsolete properties. We're going to fix this issue by providing conditional defines for compiling under .NET 2.0.

Complier error about missing references.

Dropping SyntaxEdit component onto the form and building the project may result in displaying compiler errors about missing references to required dlls. This happens because SyntaxEdit control requires QWhale.Common and QWhale.Syntax dlls (located in "bin\" folder). To fix the problem you just need to add references to these dlls via Solution Explorer.

Search


Send us your feedback
Subscribe to our maillist
Join our forum