📄 uuniedit.pas
字号:
unit UUniEdit;
(******************************************************************************
Author: Vit (nevzorov@yahoo.com)
Official Site: www.delphist.com
With all questions, please visit www.delphist.com/forum
******************************************************************************)
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SynEditHighlighter, SynUniHighlighter, StdCtrls, ComCtrls, Spin,
ExtCtrls, FileCtrl, SynEdit, SynUniDesigner;
type
TForm1 = class(TForm)
Panel2: TPanel;
GroupBox1: TGroupBox;
Label9: TLabel;
Name: TEdit;
Label10: TLabel;
FileTypeName: TEdit;
GroupBox2: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Author: TEdit;
Email: TEdit;
Web: TEdit;
Copyright: TEdit;
Company: TEdit;
Remark: TEdit;
Label7: TLabel;
Label12: TLabel;
Label14: TLabel;
GroupBox3: TGroupBox;
Label8: TLabel;
Version: TSpinEdit;
Revision: TSpinEdit;
Label17: TLabel;
Panel1: TPanel;
Panel3: TPanel;
Button5: TButton;
Button1: TButton;
Button3: TButton;
Button4: TButton;
SampleMemo: TSynEdit;
Label13: TLabel;
Label15: TLabel;
History: TSynEdit;
Splitter1: TSplitter;
Button2: TButton;
DirectoryListBox1: TDirectoryListBox;
FileListBox1: TFileListBox;
DriveComboBox1: TDriveComboBox;
Panel4: TPanel;
SaveDialog1: TSaveDialog;
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FileListBox1DblClick(Sender: TObject);
private
procedure Load;
procedure Save;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
SynUniSyn:TSynUniSyn;
UniDesigner:TSynUniDesigner;
FileName:string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if SynUniSyn<>nil then
TSynUniDesigner.EditHighlighter(SynUniSyn)
else Showmessage('Please, choose highlighter');
end;
Procedure TForm1.Load;
begin
SampleMemo.Highlighter:=nil;
if FileName='' then
begin
Caption:='UniHighlighter Editor';
exit;
end;
if assigned(SynUniSyn) then
begin
SynUniSyn.free;
end;
SynUniSyn:=TSynUniSyn.create(nil);
SynUniSyn.LoadFromFile(FileName);
Name.Text:=SynUniSyn.Info.General.Name;
FileTypeName.Text:=SynUniSyn.Info.General.Extensions;
Author.text:=SynUniSyn.Info.Author.Name;
Email.text:=SynUniSyn.Info.Author.Email;
Web.Text:=SynUniSyn.Info.Author.Web;
Copyright.Text:=SynUniSyn.Info.Author.Copyright;
Company.Text:=SynUniSyn.Info.Author.Company;
Remark.Text:=SynUniSyn.Info.Author.Remark;
Version.Value:=SynUniSyn.Info.General.Version;
Revision.Value:=SynUniSyn.Info.General.Revision;
History.Text:=SynUniSyn.Info.General.History;
SampleMemo.text:=SynUniSyn.Info.General.Sample;
SampleMemo.Highlighter:=SynUniSyn;
Caption:='编辑语法文件 - '+FileName;
SampleMemo.InitCodeFolding;
end;
Procedure TForm1.Save;
begin
if FileName = '' then
if SaveDialog1.Execute then
FileName := SaveDialog1.FileName;
if SynUniSyn=nil then exit;
SynUniSyn.Info.Author.Name:=Author.text;
SynUniSyn.Info.Author.Email:=Email.text;
SynUniSyn.Info.Author.Web:=Web.Text;
SynUniSyn.Info.Author.Copyright:=Copyright.Text;
SynUniSyn.Info.Author.Company:=Company.Text;
SynUniSyn.Info.Author.Remark:=Remark.Text;
SynUniSyn.Info.General.Version:=Version.Value;
SynUniSyn.Info.General.Revision:=Revision.Value;
SynUniSyn.Info.General.Name:=Name.Text;
SynUniSyn.Info.General.Extensions:=FileTypeName.Text;
SynUniSyn.Info.General.History:=History.Text;
SynUniSyn.Info.General.Sample :=SampleMemo.text;
SynUniSyn.SaveToFile(FileName);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
SampleMemo.Highlighter:=nil;
if assigned(SynUniSyn) then
begin
SynUniSyn.free;
end;
SynUniSyn:=TSynUniSyn.create(nil);
SampleMemo.Text:='';
Name.Text:='';
FileTypeName.Text:='';
History.Text:='';
Caption:='新建语法文件 - NEW';
FileName := '';
// Load;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Save;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
SampleMemo.Highlighter:=nil;
end;
procedure TForm1.FileListBox1DblClick(Sender: TObject);
begin
if FileExists(FileListBox1.Items[FileListBox1.ItemIndex]) then
begin
filename := FileListBox1.Items[FileListBox1.ItemIndex];
Load;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if (paramstr(1)<>'') and FileExists(Paramstr(1)) then
begin
DirectoryListBox1.Directory := extractfilepath(ExpandFileName(Paramstr(1)));
Filename:=ExpandFileName(Paramstr(1));
Load;
end
else
DirectoryListBox1.Directory := extractfilepath(Paramstr(0));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -