A lightweight and syntax hilighted UNICODE editor.
A compact, syntax-highlighted code editor using UNICODE encoding.
TCodeEdit is a component of my lysee project for editing pascal and lysee codes, and it is easy to be extended to fit other developing languages. On the whole, TCodeEdit is small, simple, easy to use and might be useful to other coders, so I put it in here open source.
TCodeEdit was originally developed as a Pascal/Lysee code editor for my Lysee project, and later I found that it can be easily extended for editing other programming languages. Overall, TCodeEdit is small, simple, and easy to use, and may be useful to other programmers, so I put it here as an open source code for everyone to use.
TCodeEdit is in development and lacks some helpful functions.
TCodeEdit is still under development and improvement. In addition to the basic syntax highlighting editing function, some other auxiliary functions have yet to be added:
TCodeEdit was released under the MIT license. Just use it as you will.
TCodeEdit uses the MIT license and can be used with confidence.
Maybe has just completed 60%, so current version is 0.6.0.
Maybe it's just 60% complete, so the version is tentatively 0.6.0.
Get TCodeEdit and add it to your Lazarus/Delphi project.
Download TCodeEdit and add it to your development project.
Use codeedit.pas in your form unit and declare class field to hold TCodeEdit
Add codeedit.pas to the window unit that needs to use TCodeEdit and declare class member variables.
uses codeedit;
type
TMainForm = class (TForm)
private
FEdit: TCodeEdit ;
procedure EditStatus (Sender: TObject);
end ;
Palce a TCodeEdit at where you want by calling PlaceACodeEdit().
Call the PlaceACodeEdit function to place TCodeEdit at the required location.
procedure TMainForm.FormCreate (Sender: TObject);
begin
FEdit := PlaceACodeEdit(Self);
FEdit.OnStatus := @EditStatus;
end ;
Reponds OnStatus event to display editor status and enable/disable menu or buttons.
Respond to the OnStatus event to display the editor status and modify the properties of related menus, buttons and other components.
procedure TMainForm.EditStatus (Sender: TObject);
begin
EditUndoMenu.Enabled := (FEdit.Undos.Last <> nil );
EditRedoMenu.Enabled := (FEdit.Redos.Last <> nil );
EditCutMenu.Enabled := FEdit.Selection.Selected;
EditCopyMenu.Enabled := FEdit.Selection.Selected;
EditPasteMenu.Enabled := HasTextFormat;
StatusBar.Panels[ 0 ].Text := Format( ' %d, %d ' , [FEdit.Caret.LineIndex + 1 , FEdit.Caret.TextIndex]);
if FEdit.Modified then
StatusBar.Panels[ 1 ].Text := ' Changed ' else
StatusBar.Panels[ 1 ].Text := ' ' ;
StatusBar.Panels[ 2 ].Text := FEdit.Syntax.Language;
end ;
How to open a file.
How to open a file.
procedure TMainForm.FileOpenMenuClick (Sender: TObject);
begin
CloseDialogs;
if OpenDialog.Execute then
FEdit.Lines.LoadFromFile(OpenDialog.FileName);
end ;
Base on file extension, TCodeEdit will choose preferred language syntax automatically.
After opening the file, TCodeEdit automatically selects the matching syntax highlighting class based on the file suffix.
How to use syntax class manually.
How to manually set syntax highlighting classes.
FEdit.Syntax.SyntaxClass := TPascalSyntax;
FEdit.Syntax.SyntaxClass := FindSyntax( ' Pascal ' );
FEdit.Syntax.SyntaxClass := FindSyntaxByFileExt( ' .pas ' );
FEdit.Syntax.SyntaxClass := FindFileSyntax( ' ~/editor/frmmain.pas ' );