Difference between revisions of "SynEdit"

From Free Pascal wiki
Jump to navigationJump to search
(see also)
Line 13: Line 13:
 
The SynEdit in lazarus is a built-in package, because the IDE uses it itself. That's why there is no .lpk file.
 
The SynEdit in lazarus is a built-in package, because the IDE uses it itself. That's why there is no .lpk file.
 
The components can be found on the component palette on the 'SynEdit' page.
 
The components can be found on the component palette on the 'SynEdit' page.
 +
 +
= Using SynEdit=
 +
 +
== Highlighting ==
 +
 +
* Use an existing Highlighter or Download more from [http://bugs.freepascal.org/view.php?id=18248 Highlighter for SynEdit]
 +
* Use a customizable Highlighter (SynAnySyn or SynPositionSyn) (See Examples for how to use)
 +
* Write your own [[SynEdit_Highlighter]]
 +
 +
== (Auto-)Completion ==
 +
 +
There are 2 completion plugins for SynEdit:
 +
* TSynCompletion (the one used by the IDE)
 +
* TSynAutoComplete
 +
 +
Note: TSynAutoComplete (from the component palette) is <b>not</b> the auto-completion with drop-down (as used by the IDE. The drop-down is provided by TSynCompletion (not available via component palette)
 +
 +
See examples for how to use both
  
 
= Examples =
 
= Examples =
  
An example can be found at lazarus/examples/synedit1.lpi.
+
Examples can be found in the folder lazarus/examples/synedit
  
 
== How to add support to Copy, Paste, Cut, Undo, Redo, etc ==
 
== How to add support to Copy, Paste, Cut, Undo, Redo, etc ==

Revision as of 01:09, 2 July 2011

Deutsch (de) English (en) español (es) français (fr) 日本語 (ja) polski (pl) русский (ru) 中文(中国大陆)‎ (zh_CN)

General

The SynEdit contained in Lazarus is based on on SynEdit 1.3 [[1]], and was adapted and extended quite a lot. For example UTF-8 support and code folding were added.

The package contains a source editor component named TSynEdit, several syntax highlighters and other components used for surce editing.

It is licensed under the same terms as the original SynEdit (MPL or GPL)

SynEdit in the IDE

The SynEdit in lazarus is a built-in package, because the IDE uses it itself. That's why there is no .lpk file. The components can be found on the component palette on the 'SynEdit' page.

Using SynEdit

Highlighting

(Auto-)Completion

There are 2 completion plugins for SynEdit:

  • TSynCompletion (the one used by the IDE)
  • TSynAutoComplete

Note: TSynAutoComplete (from the component palette) is not the auto-completion with drop-down (as used by the IDE. The drop-down is provided by TSynCompletion (not available via component palette)

See examples for how to use both

Examples

Examples can be found in the folder lazarus/examples/synedit

How to add support to Copy, Paste, Cut, Undo, Redo, etc

These features can be implemented by using SynEdit commands.

<delphi>uses

 ...
 SynEdit, SynEditKeyCmds;

procedure TfrmPrincipal.HandleCodigoKeyDown(Sender: TObject; var Key: Word;

 Shift: TShiftState);

begin

 if (Shift = [ssCtrl]) then
 begin
   case Key of
   VK_C: synCodigo.CommandProcessor(TSynEditorCommand(ecCopy), ' ', nil);
   VK_V: synCodigo.CommandProcessor(TSynEditorCommand(ecPaste), ' ', nil);
   VK_X: synCodigo.CommandProcessor(TSynEditorCommand(ecCut), ' ', nil);
   end;
 end;

end;</delphi>


Further development, discussions

  • RTL (right-to-left): started by Mazen
  • automatic monospace font selection: At the moment SynEdit starts with a font 'courier'. But it would be better, if SynEdit would start with a monospace font (meaning: every character has the same width). At the moment the LCL TFont does not provide such a property. At the moment the user has to choose the right font.
  • automatic UTF-8 font selection: Same as above monospace, but also with an UTF-8 font, so that for example umlaute are shown correctly. At the moment the user has to choose the right font.
  • Dead keys. Most keyboards support typing two or more keys to create one special character (like accented or umlaut characters).
  • Redesign of the SynEdit component. The primary goal is more reliable display and navigation in the text. A more modular approach also allows for better integration of extensions, and for specialized controls, for use outside of Lazarus.

See also