Стартовый пул

This commit is contained in:
Александр Бабаев 2024-04-02 08:46:59 +03:00
parent fd57fffd3a
commit 3bb34d000b
5591 changed files with 3291734 additions and 0 deletions

View File

@ -0,0 +1,111 @@
object MainFrm: TMainFrm
Left = 603
Height = 297
Top = 302
Width = 559
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'JSON Font Demo'
ClientHeight = 297
ClientWidth = 559
Font.CharSet = RUSSIAN_CHARSET
Font.Color = clBlack
Font.Height = -15
Font.Name = 'Times New Roman'
Font.Pitch = fpVariable
Font.Quality = fqDraft
Position = poScreenCenter
LCLVersion = '1.6.4.0'
object JSONFileNameEd: TFileNameEdit
Left = 16
Height = 25
Top = 32
Width = 528
Filter = 'JSON File (*.json)|*.json'
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 1
Flat = True
FocusOnButtonClick = True
MaxLength = 0
TabOrder = 0
end
object JSONFileNameEdLbl: TLabel
Left = 16
Height = 17
Top = 8
Width = 72
Caption = '&Имя файла:'
ParentColor = False
end
object KeyEdt: TLabeledEdit
Left = 16
Height = 25
Top = 88
Width = 528
EditLabel.AnchorSideLeft.Control = KeyEdt
EditLabel.AnchorSideRight.Control = KeyEdt
EditLabel.AnchorSideRight.Side = asrBottom
EditLabel.AnchorSideBottom.Control = KeyEdt
EditLabel.Left = 16
EditLabel.Height = 17
EditLabel.Top = 68
EditLabel.Width = 528
EditLabel.Caption = '&Ключ:'
EditLabel.ParentColor = False
TabOrder = 1
end
object ExitBtn: TButton
Left = 432
Height = 25
Top = 256
Width = 112
Caption = 'В&ыход'
Default = True
OnClick = ExitBtnClick
TabOrder = 2
end
object WriteBtn: TButton
Left = 296
Height = 25
Top = 256
Width = 131
Caption = '&Записать'
OnClick = WriteBtnClick
TabOrder = 3
end
object FontDemoLbl: TLabel
Left = 16
Height = 56
Top = 136
Width = 528
AutoSize = False
Caption = 'Это пример шрифта'
ParentColor = False
end
object ReadBtn: TButton
Left = 160
Height = 25
Top = 256
Width = 131
Caption = '&Прочитать'
OnClick = ReadBtnClick
TabOrder = 4
end
object SelectFontBtn: TButton
Left = 16
Height = 25
Top = 203
Width = 528
Caption = 'В&ыбрать шрифт'
OnClick = SelectFontBtnClick
TabOrder = 5
end
object FontDialog: TFontDialog
MinFontSize = 0
MaxFontSize = 0
left = 440
top = 8
end
end

View File

@ -0,0 +1,69 @@
unit MainForm;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, EditBtn, windows, SimplyJSON;
type
{ TMainFrm }
TMainFrm = class(TForm)
FontDialog: TFontDialog;
SelectFontBtn: TButton;
FontDemoLbl: TLabel;
WriteBtn: TButton;
ExitBtn: TButton;
JSONFileNameEd: TFileNameEdit;
JSONFileNameEdLbl: TLabel;
KeyEdt: TLabeledEdit;
ReadBtn: TButton;
procedure ExitBtnClick(Sender: TObject);
procedure ReadBtnClick(Sender: TObject);
procedure SelectFontBtnClick(Sender: TObject);
procedure WriteBtnClick(Sender: TObject);
private
public
function CheckReqs: Boolean;
end;
var
MainFrm: TMainFrm;
implementation
{$R *.lfm}
{ TMainFrm }
function TMainFrm.CheckReqs: Boolean;
begin
Result:= True;
if Trim(JSONFileNameEd.Text) = '' then
begin
Application.MessageBox(PChar('Поле "Имя файла" не заполнено!'), PChar('Ошибка!'), MB_ICONERROR);
Result:= False;
end;
if Trim(KeyEdt.Text) = '' then
begin
Application.MessageBox(PChar('Поле "Ключ" не заполнено!'), PChar('Ошибка!'), MB_ICONERROR);
Result:= False;
end;
end;
procedure TMainFrm.ExitBtnClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TMainFrm.ReadBtnClick(Sender: TObject);
begin
if not CheckReqs then
Exit;
FontDemoLbl.Font:= JSReadFont(KeyEdt.Text, FontDemoLbl.Font, JSONFileNameEd.Text);
Application.MessageBox(PChar('Шрифт загружен из файла!'), PChar('Информация'), MB_ICONASTERISK);
end;
procedure TMainFrm.SelectFontBtnClick(Sender: TObject);
begin
FontDialog.Font:= FontDemoLbl.Font;
if FontDialog.Execute then
FontDemoLbl.Font:= FontDialog.Font;
end;
procedure TMainFrm.WriteBtnClick(Sender: TObject);
begin
if not CheckReqs then
Exit;
JSWriteFont(KeyEdt.Text, FontDemoLbl.Font, JSONFileNameEd.Text);
Application.MessageBox(PChar('Шрифт записан в файл!'), PChar('Информация'), MB_ICONASTERISK);
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="10"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="JSON Font Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<MinorVersionNr Value="5"/>
<RevisionNr Value="1"/>
<BuildNr Value="5"/>
<Language Value="0419"/>
<StringTable CompanyName="Alexander Babaev" FileDescription="BGPlus Backups Creator" InternalName="BC" LegalCopyright="Alexander Babaev" LegalTrademarks="Alexander Babaev" OriginalFilename="BGPlus BC" ProductName="BGPlus Manager" ProductVersion="0.5"/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Win32" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="ANBSTCP"/>
</Item1>
<Item2>
<PackageName Value="LazControls"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="jsonfontdemo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="data\MainForm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainFrm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="jsonfontdemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="data"/>
<UnitOutputDirectory Value="data\lib\Win32"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<TargetCPU Value="i386"/>
<TargetOS Value="win32"/>
<Optimizations>
<OptimizationLevel Value="4"/>
</Optimizations>
<SmallerCode Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<StripSymbols Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,11 @@
program jsonfontdemo;
{$mode delphi}
{$codepage UTF8}
uses Interfaces, Forms, lazcontrols, MainForm;
{$R *.res}
begin
Application.Title:= 'JSON Font Demo';
Application.Initialize;
Application.CreateForm(TMainFrm, MainFrm);
Application.Run;
end.

View File

@ -0,0 +1,104 @@
object MainFrm: TMainFrm
Left = 603
Height = 221
Top = 302
Width = 559
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'JSON Reader'
ClientHeight = 221
ClientWidth = 559
Font.CharSet = RUSSIAN_CHARSET
Font.Color = clBlack
Font.Height = -15
Font.Name = 'Times New Roman'
Font.Pitch = fpVariable
Font.Quality = fqDraft
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.6.0.1'
object JSONFileNameEd: TFileNameEdit
Left = 16
Height = 25
Top = 32
Width = 528
Filter = 'JSON File (*.json)|*.json'
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 1
Flat = True
FocusOnButtonClick = True
MaxLength = 0
TabOrder = 0
end
object JSONFileNameEdLbl: TLabel
Left = 16
Height = 17
Top = 8
Width = 72
Caption = '&Имя файла:'
ParentColor = False
end
object KeyEdt: TLabeledEdit
Left = 16
Height = 25
Top = 88
Width = 528
EditLabel.AnchorSideLeft.Control = KeyEdt
EditLabel.AnchorSideRight.Control = KeyEdt
EditLabel.AnchorSideRight.Side = asrBottom
EditLabel.AnchorSideBottom.Control = KeyEdt
EditLabel.Left = 16
EditLabel.Height = 17
EditLabel.Top = 68
EditLabel.Width = 528
EditLabel.Caption = '&Ключ:'
EditLabel.ParentColor = False
TabOrder = 1
end
object RecTypeEd: TRadioGroup
Left = 16
Height = 48
Top = 128
Width = 528
AutoFill = True
Caption = '&Тип:'
ChildSizing.LeftRightSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 26
ClientWidth = 524
Columns = 3
ItemIndex = 0
Items.Strings = (
'Строка'
'Число'
'Правда/Ложь'
)
TabOrder = 2
end
object ExitBtn: TButton
Left = 432
Height = 25
Top = 184
Width = 112
Caption = 'В&ыход'
Default = True
OnClick = ExitBtnClick
TabOrder = 3
end
object ReadBtn: TButton
Left = 296
Height = 25
Top = 184
Width = 131
Caption = '&Прочитать'
OnClick = ReadBtnClick
TabOrder = 4
end
end

View File

@ -0,0 +1,64 @@
unit MainForm;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, EditBtn, ComCtrls, Spin,
windows, SimplyJSON;
type
{ TMainFrm }
TMainFrm = class(TForm)
ReadBtn: TButton;
ExitBtn: TButton;
JSONFileNameEd: TFileNameEdit;
JSONFileNameEdLbl: TLabel;
KeyEdt: TLabeledEdit;
RecTypeEd: TRadioGroup;
procedure ExitBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ReadBtnClick(Sender: TObject);
private
public
end;
var
MainFrm: TMainFrm;
implementation
{$R *.lfm}
{ TMainFrm }
procedure TMainFrm.ExitBtnClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TMainFrm.FormCreate(Sender: TObject);
begin
RecTypeEd.ItemIndex:= 0;
end;
procedure TMainFrm.ReadBtnClick(Sender: TObject);
var STitle, SMsg: String;
begin
if Trim(JSONFileNameEd.Text) = '' then
begin
Application.MessageBox(PChar('Поле "Имя файла" не заполнено!'), PChar('Ошибка!'), MB_ICONERROR);
Abort;
end;
if Trim(KeyEdt.Text) = '' then
begin
Application.MessageBox(PChar('Поле "Ключ" не заполнено!'), PChar('Ошибка!'), MB_ICONERROR);
Abort;
end;
case RecTypeEd.ItemIndex of
0: begin
STitle:= 'Строка';
SMsg:= JSReadString(KeyEdt.Text, '???', JSONFileNameEd.Text);
end;
1: begin
STitle:= 'Число';
SMsg:= IntToStr(JSReadInteger(KeyEdt.Text, 0, JSONFileNameEd.Text));
end;
2: begin
STitle:= 'Правда/Ложь';
SMsg:= BoolToStr(JSReadBoolean(KeyEdt.Text, False, JSONFileNameEd.Text), 'Правда', 'Ложь');
end;
end;
Application.MessageBox(PChar(SMsg), PChar(STitle), MB_ICONASTERISK);
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="JSONReader Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<MinorVersionNr Value="5"/>
<RevisionNr Value="1"/>
<BuildNr Value="5"/>
<Language Value="0419"/>
<StringTable CompanyName="Alexander Babaev" FileDescription="BGPlus Backups Creator" InternalName="BC" LegalCopyright="Alexander Babaev" LegalTrademarks="Alexander Babaev" OriginalFilename="BGPlus BC" ProductName="BGPlus Manager" ProductVersion="0.5"/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Win32" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="ANBSTCP"/>
</Item1>
<Item2>
<PackageName Value="LazControls"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="jsonreader.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="data\MainForm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainFrm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="jsonreader"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="data"/>
<UnitOutputDirectory Value="data\lib\Win32"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<TargetCPU Value="i386"/>
<TargetOS Value="win32"/>
<Optimizations>
<OptimizationLevel Value="4"/>
</Optimizations>
<SmallerCode Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<StripSymbols Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,11 @@
program jsonreader;
{$mode delphi}
{$codepage UTF8}
uses Interfaces, Forms, lazcontrols, MainForm;
{$R *.res}
begin
Application.Title:='JSONReader Demo';
Application.Initialize;
Application.CreateForm(TMainFrm, MainFrm);
Application.Run;
end.

View File

@ -0,0 +1,170 @@
object MainFrm: TMainFrm
Left = 603
Height = 297
Top = 302
Width = 559
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'JSON Writer'
ClientHeight = 297
ClientWidth = 559
Font.CharSet = RUSSIAN_CHARSET
Font.Color = clBlack
Font.Height = -15
Font.Name = 'Times New Roman'
Font.Pitch = fpVariable
Font.Quality = fqDraft
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.6.0.1'
object JSONFileNameEd: TFileNameEdit
Left = 16
Height = 25
Top = 32
Width = 528
Filter = 'JSON File (*.json)|*.json'
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 1
Flat = True
FocusOnButtonClick = True
MaxLength = 0
TabOrder = 0
end
object JSONFileNameEdLbl: TLabel
Left = 16
Height = 17
Top = 8
Width = 72
Caption = '&Имя файла:'
ParentColor = False
end
object KeyEdt: TLabeledEdit
Left = 16
Height = 25
Top = 88
Width = 528
EditLabel.AnchorSideLeft.Control = KeyEdt
EditLabel.AnchorSideRight.Control = KeyEdt
EditLabel.AnchorSideRight.Side = asrBottom
EditLabel.AnchorSideBottom.Control = KeyEdt
EditLabel.Left = 16
EditLabel.Height = 17
EditLabel.Top = 68
EditLabel.Width = 528
EditLabel.Caption = '&Ключ:'
EditLabel.ParentColor = False
TabOrder = 1
end
object RecTypeEd: TRadioGroup
Left = 16
Height = 48
Top = 128
Width = 528
AutoFill = True
Caption = '&Тип:'
ChildSizing.LeftRightSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 26
ClientWidth = 524
Columns = 3
ItemIndex = 0
Items.Strings = (
'Строка'
'Число'
'Правда/Ложь'
)
OnSelectionChanged = RecTypeEdSelectionChanged
TabOrder = 2
end
object ValuePages: TPageControl
Left = 16
Height = 48
Top = 200
Width = 528
ActivePage = StringSht
ShowTabs = False
TabIndex = 0
TabOrder = 3
object StringSht: TTabSheet
Caption = 'StringSht'
ClientHeight = 40
ClientWidth = 520
object sValueEd: TEdit
Left = 8
Height = 25
Top = 8
Width = 504
TabOrder = 0
end
end
object IntegerSht: TTabSheet
Caption = 'IntegerSht'
ClientHeight = 40
ClientWidth = 520
object iValueEd: TSpinEdit
Left = 8
Height = 25
Top = 8
Width = 498
Alignment = taRightJustify
MaxValue = 2147483647
MinValue = -2147483648
TabOrder = 0
end
end
object BooleanSht: TTabSheet
Caption = 'BooleanSht'
ClientHeight = 40
ClientWidth = 520
object bValueEd: TComboBox
Left = 8
Height = 25
Top = 8
Width = 496
ItemHeight = 17
ItemIndex = 0
Items.Strings = (
'Правда'
'Ложь'
)
Style = csDropDownList
TabOrder = 0
Text = 'Правда'
end
end
end
object ValueEdLbl: TLabel
Left = 16
Height = 17
Top = 183
Width = 115
Caption = '&Введите значение:'
ParentColor = False
end
object ExitBtn: TButton
Left = 432
Height = 25
Top = 256
Width = 112
Caption = 'В&ыход'
Default = True
OnClick = ExitBtnClick
TabOrder = 4
end
object WriteBtn: TButton
Left = 296
Height = 25
Top = 256
Width = 131
Caption = '&Записать'
OnClick = WriteBtnClick
TabOrder = 5
end
end

View File

@ -0,0 +1,72 @@
unit MainForm;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, EditBtn, ComCtrls, Spin,
windows, SimplyJSON;
type
{ TMainFrm }
TMainFrm = class(TForm)
WriteBtn: TButton;
ExitBtn: TButton;
bValueEd: TComboBox;
iValueEd: TSpinEdit;
sValueEd: TEdit;
JSONFileNameEd: TFileNameEdit;
JSONFileNameEdLbl: TLabel;
KeyEdt: TLabeledEdit;
BooleanSht: TTabSheet;
ValueEdLbl: TLabel;
StringSht: TTabSheet;
IntegerSht: TTabSheet;
ValuePages: TPageControl;
RecTypeEd: TRadioGroup;
procedure ExitBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RecTypeEdSelectionChanged(Sender: TObject);
procedure WriteBtnClick(Sender: TObject);
private
public
end;
var
MainFrm: TMainFrm;
implementation
{$R *.lfm}
{ TMainFrm }
procedure TMainFrm.ExitBtnClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TMainFrm.FormCreate(Sender: TObject);
begin
RecTypeEd.ItemIndex:= 0;
ValuePages.ActivePage:= StringSht;
end;
procedure TMainFrm.RecTypeEdSelectionChanged(Sender: TObject);
begin
case RecTypeEd.ItemIndex of
0: ValuePages.ActivePage:= StringSht;
1: ValuePages.ActivePage:= IntegerSht;
2: ValuePages.ActivePage:= BooleanSht;
end;
end;
procedure TMainFrm.WriteBtnClick(Sender: TObject);
begin
if Trim(JSONFileNameEd.Text) = '' then
begin
Application.MessageBox(PChar('Поле "Имя файла" не заполнено!'), PChar('Ошибка!'), MB_ICONERROR);
Abort;
end;
if Trim(KeyEdt.Text) = '' then
begin
Application.MessageBox(PChar('Поле "Ключ" не заполнено!'), PChar('Ошибка!'), MB_ICONERROR);
Abort;
end;
case RecTypeEd.ItemIndex of
0: JSWriteString(KeyEdt.Text, sValueEd.Text, JSONFileNameEd.Text);
1: JSWriteInteger(KeyEdt.Text, iValueEd.Value, JSONFileNameEd.Text);
2: JSWriteBoolean(KeyEdt.Text, (bValueEd.ItemIndex = 0), JSONFileNameEd.Text);
end;
Application.MessageBox(PChar('Выполнено!'), PChar('Информация'), MB_ICONASTERISK);
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="JSONWriter Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<MinorVersionNr Value="5"/>
<RevisionNr Value="1"/>
<BuildNr Value="5"/>
<Language Value="0419"/>
<StringTable CompanyName="Alexander Babaev" FileDescription="BGPlus Backups Creator" InternalName="BC" LegalCopyright="Alexander Babaev" LegalTrademarks="Alexander Babaev" OriginalFilename="BGPlus BC" ProductName="BGPlus Manager" ProductVersion="0.5"/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Win32" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="ANBSTCP"/>
</Item1>
<Item2>
<PackageName Value="LazControls"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="jsonwriter.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="data\MainForm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainFrm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="jsonwriter"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="data"/>
<UnitOutputDirectory Value="data\lib\Win32"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<TargetCPU Value="i386"/>
<TargetOS Value="win32"/>
<Optimizations>
<OptimizationLevel Value="4"/>
</Optimizations>
<SmallerCode Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<StripSymbols Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,11 @@
program jsonwriter;
{$mode delphi}
{$codepage UTF8}
uses Interfaces, Forms, lazcontrols, MainForm;
{$R *.res}
begin
Application.Title:= 'JSONWriter Demo';
Application.Initialize;
Application.CreateForm(TMainFrm, MainFrm);
Application.Run;
end.

View File

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="Demo"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="2">
<Item1 Name="Win32" Default="True"/>
<Item2 Name="Win64">
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="Win64\Demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="data;$(ProjOutDir)"/>
<OtherUnitFiles Value="data"/>
<UnitOutputDirectory Value="data\lib\Win64\"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<TargetCPU Value="x86_64"/>
<TargetOS Value="win64"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</Item2>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="ANBSTCP"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="Demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="data\DemoMainForm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="DemoMainFrm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="DemoMainForm"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="Win32\Demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="data;$(ProjOutDir)"/>
<OtherUnitFiles Value="data"/>
<UnitOutputDirectory Value="data\lib\Win32\"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<TargetCPU Value="i386"/>
<TargetOS Value="win32"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,12 @@
program Demo;
{$MODE Delphi}
{$codepage UTF8}
uses Forms, Interfaces,
DemoMainForm in 'data\DemoMainForm.pas' {DemoMainFrm};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TDemoMainFrm, DemoMainFrm);
Application.Run;
end.

View File

@ -0,0 +1,63 @@
object DemoMainFrm: TDemoMainFrm
Left = 642
Height = 172
Top = 381
Width = 326
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'DEMO -- ParamsMngr'
ClientHeight = 172
ClientWidth = 326
Color = clBtnFace
Font.CharSet = RUSSIAN_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Times New Roman'
Position = poScreenCenter
LCLVersion = '1.2.2.0'
object TestSParam: TButton
Left = 8
Height = 25
Top = 16
Width = 310
Caption = '/s param test'
OnClick = TestSParamClick
TabOrder = 0
end
object TestTestParam: TButton
Left = 8
Height = 25
Top = 47
Width = 310
Caption = '/test param test'
OnClick = TestTestParamClick
TabOrder = 1
end
object TestVParamValue: TButton
Left = 8
Height = 25
Top = 78
Width = 310
Caption = '/v param value test'
OnClick = TestVParamValueClick
TabOrder = 2
end
object TestMSGParamValue: TButton
Left = 8
Height = 25
Top = 109
Width = 310
Caption = '/msg param value test'
OnClick = TestMSGParamValueClick
TabOrder = 3
end
object ExitBtn: TButton
Left = 8
Height = 25
Top = 140
Width = 310
Caption = '&Exit'
OnClick = ExitBtnClick
TabOrder = 4
end
end

View File

@ -0,0 +1,56 @@
unit DemoMainForm;
{$MODE Delphi}
{$codepage UTF8}
interface
uses LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls, ParamsMngr;
type
TDemoMainFrm = class(TForm)
TestSParam: TButton;
TestTestParam: TButton;
TestVParamValue: TButton;
TestMSGParamValue: TButton;
ExitBtn: TButton;
procedure ExitBtnClick(Sender: TObject);
procedure TestSParamClick(Sender: TObject);
procedure TestTestParamClick(Sender: TObject);
procedure TestVParamValueClick(Sender: TObject);
procedure TestMSGParamValueClick(Sender: TObject);
private
public
end;
var
DemoMainFrm: TDemoMainFrm;
implementation
{$R *.lfm}
procedure ShowDLG (const ATitle, AMessage: string);
begin
Application.MessageBox(pchar(AMessage), pchar(ATitle), MB_ICONASTERISK);
end;
procedure TDemoMainFrm.ExitBtnClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TDemoMainFrm.TestMSGParamValueClick(Sender: TObject);
begin
if HasParam(StartParams, 'msg') then
ShowDLG(TestMSGParamValue.Caption, GetParamValue(StartParams, 'msg'))
else
ShowDLG(TestMSGParamValue.Caption, 'Param "/msg" not founded!');
end;
procedure TDemoMainFrm.TestSParamClick(Sender: TObject);
begin
ShowDLG(TestSParam.Caption, BoolToStr(HasParam(StartParams, 's'), true));
end;
procedure TDemoMainFrm.TestTestParamClick(Sender: TObject);
begin
ShowDLG(TestTestParam.Caption, BoolToStr(HasParam(StartParams, 'test'), true));
end;
procedure TDemoMainFrm.TestVParamValueClick(Sender: TObject);
begin
if HasParam(StartParams, 'v') then
ShowDLG(TestVParamValue.Caption, GetParamValue(StartParams, 'v'))
else
ShowDLG(TestVParamValue.Caption, 'Param "/v" not founded!');
end;
end.

View File

@ -0,0 +1,59 @@
object MainFrm: TMainFrm
Left = 301
Height = 154
Top = 148
Width = 397
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = 'Wait DEMO'
ClientHeight = 154
ClientWidth = 397
Font.CharSet = RUSSIAN_CHARSET
Font.Color = clBlack
Font.Height = -15
Font.Name = 'Times New Roman'
Font.Pitch = fpVariable
Font.Quality = fqDraft
LCLVersion = '1.6.0.4'
object WaitingIntro: TLabel
Left = 10
Height = 17
Top = 10
Width = 377
Align = alTop
BorderSpacing.Around = 10
Caption = '&We waiting (sec):'
ParentColor = False
end
object WaitingSec: TLabel
Left = 10
Height = 72
Top = 37
Width = 377
Align = alClient
Alignment = taCenter
BorderSpacing.Around = 10
Caption = '&Press "wait 5 sec"...'
Font.CharSet = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -15
Font.Name = 'Old English Text MT'
Font.Pitch = fpVariable
Font.Quality = fqDraft
Font.Style = [fsBold]
Layout = tlCenter
ParentColor = False
ParentFont = False
end
object WaitBtn: TButton
Left = 10
Height = 25
Top = 119
Width = 377
Align = alBottom
BorderSpacing.Around = 10
Caption = '&Wait 5 sec'
OnClick = WaitBtnClick
TabOrder = 0
end
end

View File

@ -0,0 +1,41 @@
unit MainForm;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, VCLEx;
type
{ TMainFrm }
TMainFrm = class(TForm)
WaitBtn: TButton;
WaitingSec: TLabel;
WaitingIntro: TLabel;
procedure WaitBtnClick(Sender: TObject);
private
public
CurWait, OldS, NewS: Int64;
end;
var
MainFrm: TMainFrm;
implementation
{$R *.lfm}
{ TMainFrm }
procedure TMainFrm.WaitBtnClick(Sender: TObject);
procedure OnWait;
begin
MainFrm.CurWait:= MainFrm.CurWait + 1;
MainFrm.NewS:= MainFrm.CurWait div 1000;
if MainFrm.NewS > MainFrm.OldS then
begin
MainFrm.WaitingSec.Caption:= IntToStr(MainFrm.NewS);
MainFrm.OldS:= MainFrm.NewS;
end;
Application.ProcessMessages;
end;
begin
OldS:= 0;
CurWait:= 0;
WaitingSec.Caption:= '0';
WaitEx(5000, @OnWait);
WaitingSec.Caption:= '&Stoped...';
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="Wait Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="ANBSTCP"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="wdemo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="data\MainForm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainFrm"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="..\output\wdemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="data"/>
<UnitOutputDirectory Value="data\lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Optimizations>
<OptimizationLevel Value="4"/>
</Optimizations>
<SmallerCode Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<StripSymbols Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,12 @@
program wdemo;
{$mode delphi}
{$codepage UTF8}
uses Interfaces, Forms, MainForm;
{$R *.res}
begin
Application.Title:='Wait Demo';
RequireDerivedFormResource:= True;
Application.Initialize;
Application.CreateForm(TMainFrm, MainFrm);
Application.Run;
end.

124
ANB ST CP/anbstcp.lpk Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="ANBSTCP"/>
<Type Value="RunAndDesignTime"/>
<Author Value="Александр Бабаев"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="data"/>
<UnitOutputDirectory Value="data\lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
</CompilerOptions>
<Description Value="ANB ST Components Pack"/>
<License Value="ЛИЦЕНЗИОНОЕ СОГЛАШЕНИЕ С КОНЕЧНЫМ ПОЛЬЗОВАТЕЛЕМ (EULA) НА ANB ST COMPONENTS PACK.
(Версия 1.0)
ОПРЕДЕЛЕНИЯ
ANB ST COMPONENTS PACK (или просто ASTCP) (далее &quot;ПРОДУКТ&quot;) - программа и/или компонент программы и/или другое (игра, изображение, фильм и т.п.), на которое распространяется данное соглашение.
КОНЕЧНЫЙ ПОЛЬЗОВАТЕЛЬ (далее &quot;ВЫ&quot; или &quot;ПОЛЬЗОВАТЕЛЬ&quot;) - лицо и/или организация, которое(-ая) использует продукт, предоставляемый под этой лицензией.
АЛЕКСАНДР БАБАЕВ (далее &quot;ПРОИЗВОДИТЕЛЬ&quot;) - лицо и/или организация, которое(-ая) произвело продукт.
ОГРАНИЧЕНИЯ
В некоторых государствах (районах, областях, штатах) не позволяется ограничение или исключение ответственности за непредвиденный ущерб. Если ваша страна (район, область, штат) не подразумевает ограничение или исключение ответственности за непредвиденный ущерб, то данное соглашение не может применяться к вам. В этом случае откажитесь от использования продукта.
В некоторых государствах (районах, областях, штатах) не позволяется исключение подразумеваемых гарантий. Если ваша страна (район, область, штат) не подразумевает исключение подразумеваемых гарантий, то данное соглашение не может применяться к вам. В этом случае откажитесь от использования продукта.
ПРЕДМЕТ СОГЛАШЕНИЯ
Данное соглашение заключается между Производителем продукта и Пользователем продукта. Данное соглашение определяет отношения между Производителем и Пользователем, возникающие при использовании продукта.
ЛИЦЕНЗИЯ
Продукт распространяется по принципу &quot;AS-IS&quot; (&quot;КАК ЕСТЬ&quot;). Автор не несёт НИКАКОЙ ОТВЕТСТВЕННОСТИ в случае нанесения данной программой физического, материального или любого другого вреда вам и вашему компьютеру. Вы на свой страх и риск устанавливаете продукт. Производитель и/или Распространитель не несёт(-ут) никакой ответственности за ошибки, неисправности (и т.п.), нанесённые продуктом вашему компьютеру. Вы можете использовать данную программу на своё усмотрение, а также копировать и распространять со ссылкой на автора, сайт &quot;http://anbsoftteam.com/&quot;.
Вам запрещается копировать, распространять продукт без ссылки на автора и указанные ранее сайты. Вам запрещается копирование и использование продукта, если устанавливаемая вами копия продукта не имеет ссылки на автора и указанные ранее сайты. Вам запрещается ипользовать компоненты продукта в других программах без письменного соглашения Производителя, удалять или исправлять в продукте любые знаки о праве собственности и/или авторском праве на продукт.
ЕСЛИ ВЫ ЗАГРУЖАЕТЕ, КОПИРУЕТЕ ПРОДУКТ ИЛИ ИСПОЛЬЗУЕТЕ ЕГО КАКИМ-ЛИБО ДРУГИМ СПОСОБОМ, ЭТИМ ВЫ ПОДТВЕРЖДАЕТЕ СВОЕ СОГЛАСИЕ СОБЛЮДАТЬ УСЛОВИЯ ДАННОГО
ЛИЦЕНЗИОННОГО СОГЛАШЕНИЯ С КОНЕЧНЫМ ПОЛЬЗОВАТЕЛЕМ. ЕСЛИ ВЫ НЕ СОГЛАСНЫ, НЕ УСТАНАВЛИВАЙТЕ, НЕ КОПИРУЙТЕ И НЕ ИСПОЛЬЗУЙТЕ ПРОДУКТ.
АВТОРСКОЕ ПРАВО
Авторское право на все копии продукта принадлежат Производителю и частично Распространителю и защищено законодательством РФ и ряда других стран.
ОГРАНИЧЕННАЯ ГАРАНТИЯ И ПРАВОВАЯ ОГОВОРКА
Вам не даётся никаких гарантий. Все ваши возможные требования, притязания и претензии (в том числе и по качеству) будут НЕПРИЗНАННЫ.
ОГРАНИЧЕНИЕ ОТВЕТСТВЕННОСТИ
Вам не даётся никаких обязательств. Все ваши возможные требования будут НЕПРИЗНАНЫ.
СПАСИБО, ЧТО ИСПОЛЬЗУЕТЕ &quot;ANB ST COMPONENTS PACK&quot;!"/>
<Version Major="1" Minor="8" Release="25" Build="70"/>
<Files Count="10">
<Item1>
<Filename Value="data\ANBFormatString.pas"/>
<UnitName Value="ANBFormatString"/>
</Item1>
<Item2>
<Filename Value="data\ParamsMngr.pas"/>
<UnitName Value="ParamsMngr"/>
</Item2>
<Item3>
<Filename Value="data\SimplyINI.pas"/>
<UnitName Value="SimplyINI"/>
</Item3>
<Item4>
<Filename Value="data\VCLEx.pas"/>
<UnitName Value="VCLEx"/>
</Item4>
<Item5>
<Filename Value="data\ANBInputBox.pas"/>
<UnitName Value="ANBInputBox"/>
</Item5>
<Item6>
<Filename Value="data\VersionControl.pas"/>
<UnitName Value="VersionControl"/>
</Item6>
<Item7>
<Filename Value="data\SimplyJSON.pas"/>
<UnitName Value="SimplyJSON"/>
</Item7>
<Item8>
<Filename Value="data\FileUtilsEx.pas"/>
<UnitName Value="FileUtilsEx"/>
</Item8>
<Item9>
<Filename Value="data\GraphicsEx.pas"/>
<UnitName Value="GraphicsEx"/>
</Item9>
<Item10>
<Filename Value="data\MsgBoxes.pas"/>
<UnitName Value="sfp_msgboxes"/>
</Item10>
</Files>
<RequiredPkgs Count="3">
<Item1>
<PackageName Value="dd_versioninfo"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
<Item3>
<PackageName Value="FCL"/>
</Item3>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<CustomOptions Items="ExternHelp" Version="2">
<_ExternHelp Items="Count"/>
</CustomOptions>
</Package>
</CONFIG>

22
ANB ST CP/anbstcp.pas Normal file
View File

@ -0,0 +1,22 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit ANBSTCP;
{$warn 5023 off : no warning about unused units}
interface
uses
ANBFormatString, ParamsMngr, SimplyINI, VCLEx, ANBInputBox, VersionControl,
SimplyJSON, FileUtilsEx, GraphicsEx, MsgBoxes, LazarusPackageIntf;
implementation
procedure Register;
begin
end;
initialization
RegisterPackage('ANBSTCP', @Register);
end.

View File

@ -0,0 +1,72 @@
unit ANBFormatString;
{$MODE Delphi}
{$codepage UTF8}
interface
uses StrUtils, SysUtils, VCLEx;
{stdcalls}
function FormatStr(const AFrmtdStr: String; const AArgs, AArgsValues: array of String): String; STDCALL;
function FormatStrW(const AFrmtdStr: WideString; const AArgs, AArgsValues: array of WideString): WideString; STDCALL;
implementation
function SearchAndReplaceStr(const AStr, ASearchStr, AReplaceStr: String): String;
var CurrDelim, NextDelim: IntEx;
ElemName, s: String;
begin
s:= '';
CurrDelim:= 1;
repeat
NextDelim:= PosEx(ASearchStr, AStr, CurrDelim);
if NextDelim = 0 then
NextDelim:= Length(AStr) + 1;
ElemName:= Copy(AStr, CurrDelim, NextDelim - CurrDelim);
if not (NextDelim > Length(AStr)) then
s:= s + ElemName + AReplaceStr
else
s:= s + ElemName;
CurrDelim:= NextDelim + Length(ASearchStr);
until CurrDelim > Length(AStr);
Result:= s;
end;
{Only for Windows}
function SearchAndReplaceStrW(const AStr, ASearchStr, AReplaceStr: WideString): WideString;
var CurrDelim, NextDelim: IntEx;
ElemName, s: WideString;
begin
s:= '';
CurrDelim:= 1;
repeat
NextDelim:= PosEx(ASearchStr, AStr, CurrDelim);
if NextDelim = 0 then
NextDelim:= Length(AStr) + 1;
ElemName:= Copy(AStr, CurrDelim, NextDelim - CurrDelim);
if not (NextDelim > Length(AStr)) then
s:= s + ElemName + AReplaceStr
else
s:= s + ElemName;
CurrDelim:= NextDelim + Length(ASearchStr);
until CurrDelim > Length(AStr);
Result:= s;
end;
function FormatStr(const AFrmtdStr: string; const AArgs, AArgsValues: array of String): String;
var i: IntEx;
s: String;
begin
s:= AFrmtdStr;
if High(AArgs) <> High(AArgsValues) then
raise Exception.Create('Array of arguments not equal array of its values!');
for i:= 0 to High(AArgs) do
s:= SearchAndReplaceStr(s, AArgs[i], AArgsValues[i]);
Result:= s;
end;
{Only for Windows}
function FormatStrW(const AFrmtdStr: WideString; const AArgs, AArgsValues: array of WideString): WideString;
var i: IntEx;
s: WideString;
begin
s:= AFrmtdStr;
if High(AArgs) <> High(AArgsValues) then
raise Exception.Create('Array of arguments not equal array of its values!');
for i:= 0 to High(AArgs) do
s:= SearchAndReplaceStrW(s, AArgs[i], AArgsValues[i]);
Result:= s;
end;
end.

View File

@ -0,0 +1,401 @@
unit ANBInputBox;
{$MODE Delphi}
{$codepage UTF8}
interface
uses LCLIntf, LCLType, SysUtils, Graphics, Controls, Forms, StdCtrls, Classes, Types, MaskEdit, Spin, VCLEx;
function ShowInputBox (const ACaption, APrompt, ADefault: String; var isAccept: Boolean): String; OVERLOAD; STDCALL;
function ShowInputBox (const ACaption, APrompt, ADefault: String; const ABtnCaptions: array of String; var isAccept: Boolean): String; OVERLOAD; STDCALL;
function ShowInputBox (const ACaption, APrompt, ADefault: String; const ABtnCaptions: array of String; const AMaxLength: IntEx; var isAccept: Boolean): String; OVERLOAD; STDCALL;
function ShowPasswordInputBox (const ACaption, APrompt, ADefault, APassword: String; var isAccept, isPasswordConfirmed: Boolean; const APasswordChar: Char = '*'): String; OVERLOAD; STDCALL;
function ShowPasswordInputBox (const ACaption, APrompt, ADefault, APassword: String; var isAccept, isPasswordConfirmed: Boolean; const ABtnCaptions: array of String; const APasswordChar: Char = '*'): String; OVERLOAD; STDCALL;
function ShowComboBox (const ACaption, APrompt: String; var Items: TStringList; const ADefaultIndex: IntEx; var isAccept: Boolean): IntEx; OVERLOAD; STDCALL;
function ShowComboBox (const ACaption, APrompt: String; var Items: TStringList; const ADefaultIndex: IntEx; const ABtnsCaption: array of String; var isAccept: Boolean): IntEx; OVERLOAD; STDCALL;
function ShowMaskedBox (const ACaption, APrompt, AMask, ADefault: String; const isIgnoreMask: Boolean; var isAccept: Boolean): String; OVERLOAD; STDCALL;
function ShowMaskedBox (const ACaption, APrompt, AMask, ADefault: String; const isIgnoreMask: Boolean; const ABtnCaptions: array of String; const AMaxLength: IntEx; var isAccept: Boolean): String; OVERLOAD; STDCALL;
function ShowSpinedBox (const ACaption, APrompt: String; const ADefault: IntEx; var isAccept: Boolean): IntEx; STDCALL; OVERLOAD;
function ShowSpinedBox (const ACaption, APrompt: String; const ADefault, AMinValue, AMaxValue: IntEx; const ABtnCaptions: array of String; var isAccept: Boolean): IntEx; STDCALL; OVERLOAD;
const OkBtnDefCaption: String = '&Ok';
CancelBtnDefCaption: String = 'C&ancel';
implementation
function MyGetAveCharSize(Canvas: TCanvas): TPoint;
var I: IntEx;
Buffer: array[0..51] of Char;
begin
with Result do
begin
x:= 0;
y:= 0;
end;
for I:= 0 to 25 do
Buffer[I]:= Chr(I + Ord('A'));
for I:= 0 to 25 do
Buffer[I + 26]:= Chr(I + Ord('a'));
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
Result.X:= Result.X div 52;
end;
function MyInputQuery(const ACaption, APrompt: String; var Value: String; var APasswordConfirmed: Boolean; const APassword: Boolean; const ANeedPassword: String; const APasswordChar: Char; const AMaxLength: IntEx; const ABtnsCaption: array of String): Boolean;
var Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: IntEx;
begin
Result:= false;
Form:= TForm.Create(Application);
with Form do
try
Canvas.Font:= Font;
DialogUnits:= MyGetAveCharSize(Canvas);
BorderStyle:= bsDialog;
Caption:= ACaption;
ClientWidth:= MulDiv(180, DialogUnits.X, 4);
Position:= poScreenCenter;
Color:= clBtnFace;
Prompt:= TLabel.Create(Form);
with Prompt do
begin
Parent:= Form;
Caption:= APrompt;
Left:= MulDiv(8, DialogUnits.X, 4);
Top:= MulDiv(8, DialogUnits.Y, 8);
Constraints.MaxWidth:= MulDiv(164, DialogUnits.X, 4);
WordWrap:= True;
end;
Edit:= TEdit.Create(Form);
with Edit do
begin
Parent:= Form;
Left:= Prompt.Left;
Top:= Prompt.Top + Prompt.Height + 5;
Width:= MulDiv(164, DialogUnits.X, 4);
MaxLength:= AMaxLength;
if APassword then
PasswordChar:= APasswordChar;
Text:= Value;
SelectAll;
end;
ButtonTop:= Edit.Top + Edit.Height + 15;
ButtonWidth:= MulDiv(50, DialogUnits.X, 4);
ButtonHeight:= MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent:= Form;
Caption:= ABtnsCaption[0];
ModalResult:= mrOk;
Cursor:= crHandPoint;
Default:= True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent:= Form;
Caption:= ABtnsCaption[1];
ModalResult:= mrCancel;
Cursor:= crHandPoint;
Cancel:= True;
SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15, ButtonWidth, ButtonHeight);
Form.ClientHeight:= Top + Height + 13;
end;
if ShowModal = mrOk then
begin
Value:= Edit.Text;
if APassword then
if Value = ANeedPassword then
APasswordConfirmed:= true
else
APasswordConfirmed:= false;
Result:= True;
end;
finally
Form.Free;
end;
end;
function MyInputComboQuery(const ACaption, APrompt: String; const Values: TStringList; const DefIndex: IntEx; var SelectedIndex: IntEx; const ABtnsCaption: array of String): Boolean;
var Form: TForm;
Prompt: TLabel;
Combo: TComboBox;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: IntEx;
begin
Result:= false;
Form:= TForm.Create(Application);
with Form do
try
Canvas.Font:= Font;
DialogUnits:= MyGetAveCharSize(Canvas);
BorderStyle:= bsDialog;
Caption:= ACaption;
ClientWidth:= MulDiv(180, DialogUnits.X, 4);
Position:= poScreenCenter;
Color:= clBtnFace;
Prompt:= TLabel.Create(Form);
with Prompt do
begin
Parent:= Form;
Caption:= APrompt;
Left:= MulDiv(8, DialogUnits.X, 4);
Top:= MulDiv(8, DialogUnits.Y, 8);
Constraints.MaxWidth:= MulDiv(164, DialogUnits.X, 4);
WordWrap:= True;
end;
Combo:= TComboBox.Create(Form);
with Combo do
begin
Parent:= Form;
Left:= Prompt.Left;
Top:= Prompt.Top + Prompt.Height + 5;
Width:= MulDiv(164, DialogUnits.X, 4);
Style:= csDropDownList;
Items.Assign(Values);
if DefIndex <= Items.Count - 1 then
ItemIndex:= DefIndex
else
ItemIndex:= -1;
end;
ButtonTop:= Combo.Top + Combo.Height + 15;
ButtonWidth:= MulDiv(50, DialogUnits.X, 4);
ButtonHeight:= MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent:= Form;
Caption:= ABtnsCaption[0];
ModalResult:= mrOk;
Cursor:= crHandPoint;
Default:= True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent:= Form;
Caption:= ABtnsCaption[1];
ModalResult:= mrCancel;
Cursor:= crHandPoint;
Cancel:= True;
SetBounds(MulDiv(92, DialogUnits.X, 4), Combo.Top + Combo.Height + 15, ButtonWidth, ButtonHeight);
Form.ClientHeight:= Top + Height + 13;
end;
if ShowModal = mrOk then
begin
SelectedIndex:= Combo.ItemIndex;
Result:= True;
end;
finally
Form.Free;
end;
end;
function MyInputMaskQuery(const ACaption, APrompt, AMask: String; var Value: String; const isIgnoreMask: Boolean; const AMaxLength: IntEx; const ABtnsCaption: array of String): Boolean;
var Form: TForm;
Prompt: TLabel;
Edit: TMaskEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: IntEx;
begin
Result:= false;
Form:= TForm.Create(Application);
with Form do
try
Canvas.Font:= Font;
DialogUnits:= MyGetAveCharSize(Canvas);
BorderStyle:= bsDialog;
Caption:= ACaption;
ClientWidth:= MulDiv(180, DialogUnits.X, 4);
Position:= poScreenCenter;
Color:= clBtnFace;
Prompt:= TLabel.Create(Form);
with Prompt do
begin
Parent:= Form;
Caption:= APrompt;
Left:= MulDiv(8, DialogUnits.X, 4);
Top:= MulDiv(8, DialogUnits.Y, 8);
Constraints.MaxWidth:= MulDiv(164, DialogUnits.X, 4);
WordWrap:= True;
end;
Edit:= TMaskEdit.Create(Form);
with Edit do
begin
Parent:= Form;
Left:= Prompt.Left;
Top:= Prompt.Top + Prompt.Height + 5;
Width:= MulDiv(164, DialogUnits.X, 4);
MaxLength:= AMaxLength;
EditMask:= AMask;
if isIgnoreMask then
Text:= Value
else
EditText:= Value;
ValidateEdit;
end;
ButtonTop:= Edit.Top + Edit.Height + 15;
ButtonWidth:= MulDiv(50, DialogUnits.X, 4);
ButtonHeight:= MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent:= Form;
Caption:= ABtnsCaption[0];
ModalResult:= mrOk;
Cursor:= crHandPoint;
Default:= True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent:= Form;
Caption:= ABtnsCaption[1];
ModalResult:= mrCancel;
Cursor:= crHandPoint;
Cancel:= True;
SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15, ButtonWidth, ButtonHeight);
Form.ClientHeight:= Top + Height + 13;
end;
if ShowModal = mrOk then
begin
if isIgnoreMask then
Value:= Edit.Text
else
Value:= Edit.EditText;
Result:= True;
end;
finally
Form.Free;
end;
end;
function MyInputSpinQuery(const ACaption, APrompt: String; var _Value: IntEx; const AMinValue, AMaxValue: IntEx; const ABtnsCaption: array of String): Boolean;
var Form: TForm;
Prompt: TLabel;
Edit: TSpinEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: IntEx;
begin
Result:= False;
Form:= TForm.Create(Application);
with Form do
try
Canvas.Font:= Font;
DialogUnits:= MyGetAveCharSize(Canvas);
BorderStyle:= bsDialog;
Caption:= ACaption;
ClientWidth:= MulDiv(180, DialogUnits.X, 4);
Position:= poScreenCenter;
Color:= clBtnFace;
Prompt:= TLabel.Create(Form);
with Prompt do
begin
Parent:= Form;
Caption:= APrompt;
Left:= MulDiv(8, DialogUnits.X, 4);
Top:= MulDiv(8, DialogUnits.Y, 8);
Constraints.MaxWidth:= MulDiv(164, DialogUnits.X, 4);
WordWrap:= True;
end;
Edit:= TSpinEdit.Create(Form);
with Edit do
begin
Parent:= Form;
Left:= Prompt.Left;
Top:= Prompt.Top + Prompt.Height + 5;
Width:= MulDiv(164, DialogUnits.X, 4);
MinValue:= Integer(AMinValue);
MaxValue:= Integer(AMaxValue);
if _Value < AMinValue then
Value:= AMinValue
else
if _Value > AMaxValue then
Value:= AMaxValue
else
Value:= _Value;
SelectAll;
end;
ButtonTop:= Edit.Top + Edit.Height + 15;
ButtonWidth:= MulDiv(50, DialogUnits.X, 4);
ButtonHeight:= MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent:= Form;
Caption:= ABtnsCaption[0];
ModalResult:= mrOk;
Cursor:= crHandPoint;
Default:= True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent:= Form;
Caption:= ABtnsCaption[1];
ModalResult:= mrCancel;
Cursor:= crHandPoint;
Cancel:= True;
SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15, ButtonWidth, ButtonHeight);
Form.ClientHeight:= Top + Height + 13;
end;
if ShowModal = mrOk then
begin
_Value:= Edit.Value;
Result:= True;
end;
finally
Form.Free;
end;
end;
function ShowInputBox (const ACaption, APrompt, ADefault: String; var isAccept: Boolean): String;
var Pasw: boolean;
begin
Result:= ADefault;
Pasw:= False;
isAccept:= MyInputQuery(ACaption, APrompt, Result, Pasw, False, '', '*', 0, [OkBtnDefCaption, CancelBtnDefCaption]);
end;
function ShowInputBox (const ACaption, APrompt, ADefault: String; const ABtnCaptions: array of String; var isAccept: Boolean): String;
var Pasw: boolean;
begin
Result:= ADefault;
Pasw:= False;
isAccept:= MyInputQuery(ACaption, APrompt, Result, Pasw, False, '', '*', 0, ABtnCaptions);
end;
function ShowInputBox (const ACaption, APrompt, ADefault: String; const ABtnCaptions: array of String; const AMaxLength: IntEx; var isAccept: Boolean): String;
var Pasw: boolean;
begin
Result:= ADefault;
Pasw:= False;
isAccept:= MyInputQuery(ACaption, APrompt, Result, Pasw, false, '', '*', AMaxLength, ABtnCaptions);
end;
function ShowPasswordInputBox (const ACaption, APrompt, ADefault, APassword: String; var isAccept, isPasswordConfirmed: Boolean; const APasswordChar: Char = '*'): String;
begin
Result:= ADefault;
isAccept:= MyInputQuery(ACaption, APrompt, Result, isPasswordConfirmed, True, APassword, APasswordChar, 0, [OkBtnDefCaption, CancelBtnDefCaption]);
end;
function ShowPasswordInputBox (const ACaption, APrompt, ADefault, APassword: String; var isAccept, isPasswordConfirmed: Boolean; const ABtnCaptions: array of String; const APasswordChar: Char = '*'): String;
begin
Result:= ADefault;
isAccept:= MyInputQuery(ACaption, APrompt, Result, isPasswordConfirmed, True, APassword, APasswordChar, 0, ABtnCaptions);
end;
function ShowComboBox (const ACaption, APrompt: string; var Items: TStringList; const ADefaultIndex: IntEx; var isAccept: boolean): IntEx;
begin
Result:= ADefaultIndex;
isAccept:= MyInputComboQuery(ACaption, APrompt, Items, Result, Result, [OkBtnDefCaption, CancelBtnDefCaption]);
end;
function ShowComboBox (const ACaption, APrompt: String; var Items: TStringList; const ADefaultIndex: IntEx; const ABtnsCaption: array of String; var isAccept: Boolean): IntEx;
begin
Result:= ADefaultIndex;
isAccept:= MyInputComboQuery(ACaption, APrompt, Items, Result, Result, ABtnsCaption);
end;
function ShowMaskedBox (const ACaption, APrompt, AMask, ADefault: String; const isIgnoreMask: Boolean; var isAccept: Boolean): String;
begin
Result:= ADefault;
isAccept:= MyInputMaskQuery(ACaption, APrompt, AMask, Result, isIgnoreMask, 0, [OkBtnDefCaption, CancelBtnDefCaption]);
end;
function ShowMaskedBox (const ACaption, APrompt, AMask, ADefault: String; const isIgnoreMask: Boolean; const ABtnCaptions: array of String; const AMaxLength: IntEx; var isAccept: Boolean): String;
begin
Result:= ADefault;
isAccept:= MyInputMaskQuery(ACaption, APrompt, AMask, Result, isIgnoreMask, AMaxLength, ABtnCaptions);
end;
function ShowSpinedBox (const ACaption, APrompt: String; const ADefault: IntEx; var isAccept: Boolean): IntEx;
begin
Result:= ADefault;
isAccept:= MyInputSpinQuery(ACaption, APrompt, Result, 0, 100, [OkBtnDefCaption, CancelBtnDefCaption]);
end;
function ShowSpinedBox (const ACaption, APrompt: String; const ADefault, AMinValue, AMaxValue: IntEx; const ABtnCaptions: array of String; var isAccept: Boolean): IntEx;
begin
Result:= ADefault;
isAccept:= MyInputSpinQuery(ACaption, APrompt, Result, AMinValue, AMaxValue, ABtnCaptions);
end;
end.

View File

@ -0,0 +1,12 @@
unit ANBRegComp;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, SkinButton;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('ANB Components', [TSkinBtn]);
end;
end.

View File

@ -0,0 +1,169 @@
//version 0.31 beta
unit FileUtilsEx;
{$MODE Delphi}
{$codepage UTF8}
interface
uses windows, sysutils, ShellApi, Classes;
type TExePlatform = (expUnknown, exp32Bit, exp64Bit, expOther);
//stdcalls
function FileVersion (AFileName: String): String;
function FileSize2Str (const AFileSize: Int64; AStringNames: Array of String; const ADecimalPlaces: Byte): String; Stdcall; Overload;
function FileSize2Str (const AFileSize: Int64; AStringNames: Array of String): String; Stdcall; Overload;
function FileSize2Str (const AFileSize: Int64; const ADecimalPlaces: Byte): String; Overload;
function FileSize2Str (const AFileSize: Int64): String; Overload;
function FileAccessDateToDateTime (FileTime: TFILETIME): TDateTime; Stdcall;
function RenameDir (const DirName, NewName: String): Boolean; STDCALL;
function GetEXEPlatform (const AFileName: String): TExePlatform; STDCALL;
implementation
const AFileSizeNames: Array[0..4] of String = ('Byte', 'KB', 'MB', 'GB', 'TB');
//Getting version of the file
function FileVersion (AFileName: String): String;
var szName: array[0..255] of Char;
P: Pointer;
Value: Pointer;
Len: UINT;
GetTranslationString: String;
FFileName: PChar;
FValid:boolean;
FSize: DWORD;
FHandle: DWORD;
FBuffer: PChar;
begin
try
FFileName:= StrPCopy(StrAlloc(Length(AFileName) + 1), AFileName);
FValid:= False;
FSize:= GetFileVersionInfoSize(FFileName, FHandle);
if FSize > 0 then
try
GetMem(FBuffer, FSize);
FValid:= GetFileVersionInfo(FFileName, FHandle, FSize, FBuffer);
except
FValid:= False;
raise;
end;
Result:= '';
if FValid then
VerQueryValue(FBuffer, '\VarFileInfo\Translation', P, Len)
else
P:= nil;
if P <> nil then
GetTranslationString:= IntToHex(MakeLong(HiWord(Longint(P^)), LoWord(Longint(P^))), 8);
if FValid then
begin
StrPCopy(szName, '\StringFileInfo\' + GetTranslationString + '\FileVersion');
if VerQueryValue(FBuffer, szName, Value, Len) then
Result:= StrPas(PChar(Value));
end;
finally
try
if FBuffer <> nil then
FreeMem(FBuffer, FSize);
except
end;
try
StrDispose(FFileName);
except
end;
end;
end;
//FileSize2Str
function FileSize2Str (const AFileSize: Int64; AStringNames: Array of String; const ADecimalPlaces: Byte): String; Overload;
function FrmtSize (const ASize, ADelim: Int64; const ADP: Byte): String;
var VDelim: Int64;
Indx: Byte;
begin
VDelim:= 1;
for Indx:= 0 to ADP do
VDelim:= VDelim*10;
Result:= FloatToStr(round((ASize*VDelim)/ADelim)/VDelim);
end;
const AFrmtsStr: String = '%s %s';
begin
//Bytes
if AFileSize < 1024 then
Result:= Format(AFrmtsStr, [IntToStr(AFileSize), AStringNames[0]]);
//KiloBytes
if (AFileSize >= 1024) and (AFileSize < 1048576) then
Result:= Format(AFrmtsStr, [FrmtSize(AFileSize, 1024, ADecimalPlaces), AStringNames[1]]);
//MegaBytes
if (AFileSize >= 1048576) and (AFileSize < 1073741824) then
Result:= Format(AFrmtsStr, [FrmtSize(AFileSize, 1048576, ADecimalPlaces), AStringNames[2]]);
//GigaBytes
if (AFileSize >= 1073741824) and (AFileSize < 1099511627776) then
Result:= Format(AFrmtsStr, [FrmtSize(AFileSize, 1073741824, ADecimalPlaces), AStringNames[3]]);
//TeraBytes
if (AFileSize >= 1099511627776) then
Result:= Format(AFrmtsStr, [FrmtSize(AFileSize, 1073741824, ADecimalPlaces), AStringNames[4]]);
end;
function FileSize2Str (const AFileSize: Int64; AStringNames: Array of String): String; Overload;
begin
Result:= FileSize2Str(AFileSize, AStringNames, 2);
end;
function FileSize2Str (const AFileSize: Int64; const ADecimalPlaces: Byte): String; Overload;
begin
Result:= FileSize2Str(AFileSize, AFileSizeNames, ADecimalPlaces);
end;
function FileSize2Str (const AFileSize: Int64): String; Overload;
begin
Result:= FileSize2Str(AFileSize, AFileSizeNames, 2);
end;
//FileAccessDateToDateTime
//Author: Дураг (http://www.sql.ru/forum/memberinfo.aspx?mid=32731) from http://www.sql.ru/forum/259218/kak-poluchit-datu-i-vremya-sozdaniya-fayla
function FileAccessDateToDateTime (FileTime: TFILETIME): TDateTime;
var LocalTime: TFILETIME;
DOSFileTime: DWORD;
begin
FileTimeToLocalFileTime(FileTime, LocalTime);
FileTimeToDosDateTime(LocalTime, LongRec(DOSFileTime).Hi, LongRec(DOSFileTime).Lo);
Result:= FileDateToDateTime(DOSFileTime);
end;
//RenameDir
function RenameDir (const DirName, NewName: String): Boolean;
var shellinfo: TSHFILEOPSTRUCT;
DirFrom, DirTo: String;
begin
DirFrom:= DirName;
DirTo:= NewName;
with shellinfo do
begin
Wnd:= 0;
wFunc:= FO_RENAME;
pFrom:= PChar(DirFrom);
pTo:= PChar(DirTo);
fFlags:= FOF_FILESONLY or FOF_ALLOWUNDO or FOF_SILENT or FOF_NOCONFIRMATION;
end;
SHFileOperation(shellinfo);
Result:= DirectoryExists(NewName);
end;
//GetEXEPlatform
//Author Dmitry Arefiev (http://www.sql.ru/forum/808857/kak-opredelit-razryadnost-prilozheniya)
function GetEXEPlatform (const AFileName: String): TExePlatform;
var oFS: TFileStream;
iPeOffset: Integer;
iPeHead: LongWord;
iMachineType: Word;
begin
Result:= expUnknown;
try
oFS:= TFileStream.Create(AFileName, fmOpenRead or fmShareDenyNone);
try
oFS.Seek($3C, soFromBeginning);
oFS.Read(iPeOffset, SizeOf(iPeOffset));
oFS.Seek(iPeOffset, soFromBeginning);
oFS.Read(iPeHead, SizeOf(iPeHead));
if iPeHead <> $00004550 then
Exit;
oFS.Read(iMachineType, SizeOf(iMachineType));
case iMachineType of
$8664, $0200: Result:= exp64Bit;
$014C: Result:= exp32Bit;
else
Result:= expOther;
end;
finally
oFS.Free;
end;
except
end;
end;
end.

View File

@ -0,0 +1,28 @@
unit GraphicsEx;
//version 0.1
{$MODE Delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, Graphics;
type TRGBByte = 0..255;
TRGBColor = record
R, G, B: TRGBByte;
end;
//stdcalls
function RGB2Color (const ARGB: TRGBColor): TColor;
function Color2RGB (const AColor: TColor): TRGBColor;
implementation
function RGB2Color (const ARGB: TRGBColor): TColor;
begin
Result:= RGBToColor(ARGB.R, ARGB.G, ARGB.B);
end;
function Color2RGB (const AColor: TColor): TRGBColor;
//from http://www.delphisources.ru/pages/faq/base/rgb_tcolor.html
var Color: LongInt;
begin
Color:= ColorToRGB(AColor);
Result.R:= Color;
Result.G:= Color shr 8;
Result.B:= Color shr 16;
end;
end.

View File

@ -0,0 +1,25 @@
unit MsgBoxes;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, Forms;
{dialog types for Linux capatability}
const DLG_ASTERISK = $40;
DLG_EXCLAMATION = $30;
DLG_WARNING = $30;
DLG_ERROR = $10;
DLG_QUESTION = $20;
{stdcalls}
function ShowMessageBox (const AText, ATitle: String; const AMessageType: LongInt = 0): Integer; STDCALL;
function ShowMessageBoxA (const AText: String; const AMessageType: LongInt = 0): Integer; STDCALL;
implementation
//Sample Windows MessageDialogs
function ShowMessageBox (const AText, ATitle: String; const AMessageType: LongInt = 0): Integer;
begin
Result:= Application.MessageBox(PChar(AText), PChar(ATitle), AMessageType);
end;
function ShowMessageBoxA (const AText: String; const AMessageType: LongInt = 0): Integer;
begin
Result:= Application.MessageBox(PChar(AText), PChar(Application.Title), AMessageType);
end;
end.

View File

@ -0,0 +1,96 @@
unit ParamsMngr;
{$MODE Delphi}
{$codepage UTF8}
interface
uses StrUtils, VCLEx;
{stdcalls}
function HasParam (const AParams: String; const AParam: Char): Boolean; OVERLOAD; STDCALL;
function HasParam (const AParams: String; const AParam: String): Boolean; OVERLOAD; STDCALL;
function HasParam (const AParam: String): Boolean; OVERLOAD; STDCALL;
function GetParamValue (const AParams: String; const AParam: Char): String; OVERLOAD; STDCALL;
function GetParamValue (const AParams: String; const AParam: String): String; OVERLOAD; STDCALL;
function GetParamValue (const AParam: string): string; overload; stdcall;
function StartParams: String; STDCALL;
implementation
function HasParam (const AParams: String; const AParam: Char): Boolean;
begin
Result:= False;
if AParams <> '' then
if Pos('/' + AParam, AParams) > 0 then
Result:= True;
end;
function HasParam (const AParams: String; const AParam: String): Boolean;
var PS: IntEx;
NextChr: Char;
begin
Result:= False;
if AParams <> '' then
begin
PS:= Pos('/' + AParam, AParams);
if PS > 0 then
begin
NextChr:= AParams[PS + Length(AParam) + 1];
if (NextChr = '=') or (NextChr = '#') then
Result:= True;
end;
end;
end;
function HasParam (const AParam: String): Boolean;
begin
Result:= HasParam(StartParams, AParam);
end;
function GetParamValue (const AParams: String; const AParam: Char): String;
var i, j, k: IntEx;
begin
Result:= '';
i:= 0;
j:= 0;
k:= 0;
if AParams <> '' then
begin
i:= Pos('/' + AParam, AParams);
if (i > 0) and (AParams[i+2] = '=') then
j:= i+3;
if j > 0 then
begin
k:= PosEx('#', AParams, j);
if k = 0 then
k:= Length(AParams) + 1;
Result:= Copy(AParams, j, k-j);
end;
end;
end;
function GetParamValue (const AParams: String; const AParam: String): String;
var i, j, k: IntEx;
begin
Result:= '';
i:= 0;
j:= 0;
k:= 0;
if AParams <> '' then
begin
i:= Pos('/' + AParam, AParams);
if (i > 0) and (AParams[i + Length(AParam) + 1] = '=') then
j:= i + Length(AParam) + 2;
if j > 0 then
begin
k:= PosEx('#', AParams, j);
if k = 0 then
k:= Length(AParams) + 1;
Result:= Copy(AParams, j, k-j);
end;
end;
end;
function GetParamValue (const AParam: String): String;
begin
Result:= GetParamValue(StartParams, AParam);
end;
function StartParams: String;
var i: IntEx;
begin
Result:= '';
if Paramcount > 0 then
for i:= 1 to Paramcount do
Result:= Result + ParamStr(i) + '#';
end;
end.

View File

@ -0,0 +1,132 @@
unit SimplyINI;
{$MODE Delphi}
{$codepage UTF8}
interface
uses SysUtils, Classes, IniFiles;
//stdcalls
function INIReadString (const ASection, AKey, ADefault, AFileName: string): string; stdcall;
function INIReadInteger (const ASection, AKey: string; const ADefault: Int64; const AFileName: string): Int64; stdcall;
function INIReadBoolean (const ASection, AKey: string; const ADefault: boolean; const AFileName: string): boolean; stdcall;
procedure INIWriteString (const ASection, AKey, AValue, AFileName: string); stdcall;
procedure INIWriteInteger (const ASection, AKey: string; const AValue: Int64; const AFileName: string); stdcall;
procedure INIWriteBoolean (const ASection, AKey: string; const AValue: boolean; const AFileName: string); stdcall;
procedure INIDeleteKey (const ASection, AKey, AFileName: string); stdcall;
procedure INIDeleteSection (const ASection, AFileName: string); stdcall;
function INISectionExists (const ASection, AFileName: string): boolean; stdcall;
procedure INIReadSections (const AFileName: string; VStrings: TStrings); stdcall;
procedure INIReadSection (const ASection, AFileName: string; VStrings: TStrings); stdcall;
implementation
//Read functions
function INIReadString (const ASection, AKey, ADefault, AFileName: string): string;
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
Result:= INI.ReadString(ASection, AKey, ADefault);
finally
INI.Free;
end;
end;
function INIReadInteger (const ASection, AKey: string; const ADefault: Int64; const AFileName: string): Int64;
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
Result:= INI.ReadInteger(ASection, AKey, ADefault);
finally
INI.Free;
end;
end;
function INIReadBoolean (const ASection, AKey: string; const ADefault: boolean; const AFileName: string): boolean;
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
Result:= INI.ReadBool(ASection, AKey, ADefault);
finally
INI.Free;
end;
end;
//Write procedures
procedure INIWriteString (const ASection, AKey, AValue, AFileName: string);
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
INI.WriteString(ASection, AKey, AValue);
finally
INI.Free;
end;
end;
procedure INIWriteInteger (const ASection, AKey: string; const AValue: Int64; const AFileName: string);
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
INI.WriteInt64(ASection, AKey, AValue);
finally
INI.Free;
end;
end;
procedure INIWriteBoolean (const ASection, AKey: string; const AValue: boolean; const AFileName: string);
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
INI.WriteBool(ASection, AKey, AValue);
finally
INI.Free;
end;
end;
//Delete function
procedure INIDeleteKey (const ASection, AKey, AFileName: string);
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
INI.DeleteKey(ASection, AKey);
finally
INI.Free;
end;
end;
procedure INIDeleteSection (const ASection, AFileName: string);
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
INI.EraseSection(ASection);
finally
INI.Free;
end;
end;
function INISectionExists (const ASection, AFileName: string): boolean;
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
Result:= INI.SectionExists(ASection);
finally
INI.Free;
end;
end;
procedure INIReadSections (const AFileName: string; VStrings: TStrings);
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
INI.ReadSections(VStrings);
finally
INI.Free;
end;
end;
procedure INIReadSection (const ASection, AFileName: string; VStrings: TStrings);
var INI: TIniFile;
begin
INI:= TIniFile.Create(AFileName);
try
INI.ReadSection(ASection, VStrings);
finally
INI.Free;
end;
end;
end.

View File

@ -0,0 +1,324 @@
unit SimplyJSON;
{$MODE Delphi}
{$codepage UTF8}
{*************************************************************************************************************************************
SimplyJSON
Модуль для парсинга JSON файлов (используется TJSONConfig).
Авторские права (c) 2016 - 2019, Александр Бабаев.
История изменений:
1.3 (01.05.2019) Переработан алгоритм открытия / парсинга JSON файлов при чтении, изменена функция JSReadFont
1.2 (09.05.2017) Добавлены функции чтения/записи шрифтов.
*************************************************************************************************************************************}
interface
uses Classes, SysUtils, Graphics, GraphicsEx, LazFileUtils, fpjson, jsonparser, jsonConf, ANBFormatString;
//stdcalls
function JSReadString (const AKey, ADefault: UnicodeString; const AFileName: String): UnicodeString; STDCALL; OVERLOAD;
function JSReadString (const AKey, ADefault, AFileName: String): String; STDCALL; OVERLOAD;
function JSReadInteger (const AKey: UnicodeString; const ADefault: Int64; const AFileName: String): Int64; STDCALL; OVERLOAD;
function JSReadInteger (const AKey: String; const ADefault: Int64; const AFileName: String): Int64; STDCALL; OVERLOAD;
function JSReadBoolean (const AKey: UnicodeString; const ADefault: Boolean; const AFileName: String): Boolean; STDCALL; OVERLOAD;
function JSReadBoolean (const AKey: String; const ADefault: Boolean; const AFileName: String): Boolean; STDCALL; OVERLOAD;
function JSReadRGBColor (const AKey: UnicodeString; const ADefault: TRGBColor; const AFileName: String): TRGBColor; STDCALL; OVERLOAD;
function JSReadRGBColor (const AKey: String; const ADefault: TRGBColor; const AFileName: String): TRGBColor; STDCALL; OVERLOAD;
procedure JSReadFont (const AKey: UnicodeString; var Font: TFont; const AFileName: String); STDCALL; OVERLOAD;
procedure JSReadFont (const AKey: String; var Font: TFont; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteString (const AKey, AValue: UnicodeString; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteString (const AKey, AValue, AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteInteger (const AKey: UnicodeString; const AValue: Int64; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteInteger (const AKey: String; const AValue: Int64; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteBoolean (const AKey: UnicodeString; const AValue: Boolean; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteBoolean (const AKey: String; const AValue: Boolean; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteRGBColor (const AKey: UnicodeString; const AValue: TRGBColor; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteRGBColor (const AKey: String; const AValue: TRGBColor; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteFont (const AKey: UnicodeString; const AValue: TFont; const AFileName: String); STDCALL; OVERLOAD;
procedure JSWriteFont (const AKey: String; const AValue: TFont; const AFileName: String); STDCALL; OVERLOAD;
procedure JSDeleteKey (const AKey: UnicodeString; const AFileName: String); STDCALL; OVERLOAD;
procedure JSDeleteKey (const AKey, AFileName: String); STDCALL; OVERLOAD;
procedure JSReadSubKeys (const AKey: UnicodeString; SubkeyList: TStrings; const AFileName: String); STDCALL; OVERLOAD;
procedure JSReadSubKeys (const AKey: String; SubkeyList: TStrings; const AFileName: String); STDCALL; OVERLOAD;
implementation
//Support functions
procedure GetJSData (const AFileName: String; var JSData: TJSONData);
var FS: TFileStream;
SL: TStringList;
begin
if not FileExistsUTF8(AFileName) then
begin
FS:= TFileStream.Create(AFileName, fmOpenWrite);
SL:= TStringList.Create;
SL.Text:= '{}';
SL.SaveToStream(FS);
SL.Free;
FS.Free;
end;
FS:= TFileStream.Create(AFileName, fmOpenRead or fmShareDenyNone);
JSData:= GetJSON(FS, True);
FS.Free;
end;
function FrmtKey (const AKey: UnicodeString): UnicodeString;
var KeyM: UnicodeString;
begin
Result:= AKey;
//Для совместимости с SimplyJSON 1.0 - 1.2 и операциями записи
KeyM:= AKey;
if KeyM[1] = '/' then
Delete(KeyM, 1, 1);
Result:= UnicodeString(FormatStr(KeyM, ['/'], ['.']));
end;
//Read functions
function JSReadString (const AKey, ADefault: UnicodeString; const AFileName: String): UnicodeString; OVERLOAD;
var JD: TJSONData;
begin
GetJSData(AFileName, JD);
try
Result:= JD.FindPath(FrmtKey(AKey)).AsUnicodeString;
except
Result:= ADefault;
end;
JD.Free;
end;
function JSReadString (const AKey, ADefault, AFileName: String): String; OVERLOAD;
var Key, Def, Res: UnicodeString;
begin
Key:= UnicodeString(AKey);
Def:= UnicodeString(ADefault);
Res:= JSReadString(Key, Def, AFileName);
Result:= String(Res);
end;
function JSReadInteger (const AKey: UnicodeString; const ADefault: Int64; const AFileName: String): Int64; OVERLOAD;
var JD: TJSONData;
begin
GetJSData(AFileName, JD);
try
Result:= JD.FindPath(FrmtKey(AKey)).AsInt64;
except
Result:= ADefault;
end;
JD.Free;
end;
function JSReadInteger (const AKey: String; const ADefault: Int64; const AFileName: String): Int64; OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
Result:= JSReadInteger(Key, ADefault, AFileName);
end;
function JSReadBoolean (const AKey: UnicodeString; const ADefault: Boolean; const AFileName: String): Boolean; OVERLOAD;
var JD: TJSONData;
begin
GetJSData(AFileName, JD);
try
Result:= JD.FindPath(FrmtKey(AKey)).AsBoolean;
except
Result:= ADefault;
end;
JD.Free;
end;
function JSReadBoolean (const AKey: String; const ADefault: Boolean; const AFileName: String): Boolean; OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
Result:= JSReadBoolean(Key, ADefault, AFileName);
end;
function JSReadRGBColor (const AKey: UnicodeString; const ADefault: TRGBColor; const AFileName: String): TRGBColor; OVERLOAD;
var JD: TJSONData;
KeyM: UnicodeString;
begin
GetJSData(AFileName, JD);
KeyM:= FrmtKey(AKey);
try
Result.R:= JD.FindPath(KeyM + '.r').AsInteger;
Result.G:= JD.FindPath(KeyM + '.g').AsInteger;
Result.B:= JD.FindPath(KeyM + '.b').AsInteger;
except
Result:= ADefault;
end;
JD.Free;
end;
function JSReadRGBColor (const AKey: String; const ADefault: TRGBColor; const AFileName: String): TRGBColor; OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
Result:= JSReadRGBColor(Key, ADefault, AFileName);
end;
procedure JSReadFont (const AKey: UnicodeString; var Font: TFont; const AFileName: String);
var JD: TJSONData;
FStyle: TFontStyles;
KeyM: UnicodeString;
begin
GetJSData(AFileName, JD);
KeyM:= FrmtKey(AKey);
try
Font.CharSet:= TFontCharSet(JD.FindPath(KeyM + '.charset').AsInteger);
Font.Color:= StringToColor(JD.FindPath(KeyM + '.color').AsString);
Font.Height:= JD.FindPath(KeyM + '.height').AsInteger;
Font.Name:= JD.FindPath(KeyM + '.name').AsString;
Font.Orientation:= JD.FindPath(KeyM + '.orientation').AsInteger;
Font.Pitch:= TFontPitch(JD.FindPath(KeyM + '.pitch').AsInteger);
Font.Quality:= TFontQuality(JD.FindPath(KeyM + '.quality').AsInteger);
Font.Size:= JD.FindPath(KeyM + '.size').AsInteger;
FStyle:= [];
if (JD.FindPath(KeyM + '.style.bold').AsBoolean) then
FStyle:= FStyle + [fsBold];
if (JD.FindPath(KeyM + '.style.italic').AsBoolean) then
FStyle:= FStyle + [fsItalic];
if (JD.FindPath(KeyM + '.style.underline').AsBoolean) then
FStyle:= FStyle + [fsUnderline];
if (JD.FindPath(KeyM + '.style.strikeout').AsBoolean) then
FStyle:= FStyle + [fsStrikeOut];
Font.Style:= FStyle;
except
end;
JD.Free;
end;
procedure JSReadFont (const AKey: String; var Font: TFont; const AFileName: String);
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
JSReadFont(Key, Font, AFileName);
end;
//Write procedures
procedure JSWriteString (const AKey, AValue: UnicodeString; const AFileName: String); OVERLOAD;
var JSConf: TJSONConfig;
begin
JSConf:= TJSONConfig.Create(Nil);
with JSConf do
begin
Filename:= AFileName;
Formatted:= True;
SetValue(AKey, AValue);
Flush;
Free;
end;
end;
procedure JSWriteString (const AKey, AValue, AFileName: String); OVERLOAD;
var Key, Val: UnicodeString;
begin
Key:= UnicodeString(AKey);
Val:= UnicodeString(AValue);
JSWriteString(Key, Val, AFileName);
end;
procedure JSWriteInteger (const AKey: UnicodeString; const AValue: Int64; const AFileName: String); OVERLOAD;
var JSConf: TJSONConfig;
begin
JSConf:= TJSONConfig.Create(Nil);
with JSConf do
begin
Filename:= AFileName;
Formatted:= True;
SetValue(AKey, AValue);
Free;
end;
end;
procedure JSWriteInteger (const AKey: String; const AValue: Int64; const AFileName: String); OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
JSWriteInteger(Key, AValue, AFileName);
end;
procedure JSWriteBoolean (const AKey: UnicodeString; const AValue: Boolean; const AFileName: String); OVERLOAD;
var JSConf: TJSONConfig;
begin
JSConf:= TJSONConfig.Create(Nil);
with JSConf do
begin
Filename:= AFileName;
Formatted:= True;
SetValue(AKey, AValue);
Free;
end;
end;
procedure JSWriteBoolean (const AKey: String; const AValue: Boolean; const AFileName: String); OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
JSWriteBoolean(Key, AValue, AFileName);
end;
procedure JSWriteRGBColor (const AKey: UnicodeString; const AValue: TRGBColor; const AFileName: String); OVERLOAD;
var JSConf: TJSONConfig;
begin
JSConf:= TJSONConfig.Create(Nil);
with JSConf do
begin
Filename:= AFileName;
Formatted:= True;
SetValue(AKey + '/r', AValue.R);
SetValue(AKey + '/g', AValue.G);
SetValue(AKey + '/b', AValue.B);
Free;
end;
end;
procedure JSWriteRGBColor (const AKey: String; const AValue: TRGBColor; const AFileName: String); OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
JSWriteRGBColor(Key, AValue, AFileName);
end;
procedure JSWriteFont (const AKey: UnicodeString; const AValue: TFont; const AFileName: String); OVERLOAD;
var JSConf: TJSONConfig;
begin
JSConf:= TJSONConfig.Create(Nil);
with JSConf do
begin
Filename:= AFileName;
Formatted:= True;
SetValue(AKey + '/charset', Integer(AValue.CharSet));
SetValue(AKey + '/color', ColorToString(AValue.Color));
SetValue(AKey + '/height', AValue.Height);
SetValue(AKey + '/name', AValue.Name);
SetValue(AKey + '/orientation', AValue.Orientation);
SetValue(AKey + '/pitch', Integer(AValue.Pitch));
SetValue(AKey + '/quality', Integer(AValue.Quality));
SetValue(AKey + '/size', AValue.Size);
SetValue(AKey + '/style/bold', (fsBold in AValue.Style));
SetValue(AKey + '/style/italic', (fsItalic in AValue.Style));
SetValue(AKey + '/style/underline', (fsUnderline in AValue.Style));
SetValue(AKey + '/style/strikeout', (fsStrikeOut in AValue.Style));
Free;
end;
end;
procedure JSWriteFont (const AKey: String; const AValue: TFont; const AFileName: String); OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
JSWriteFont(Key, AValue, AFileName);
end;
//Delete function
procedure JSDeleteKey (const AKey: UnicodeString; const AFileName: String); OVERLOAD;
var JSConf: TJSONConfig;
begin
JSConf:= TJSONConfig.Create(Nil);
with JSConf do
begin
Filename:= AFileName;
Formatted:= True;
DeletePath(AKey);
Free;
end;
end;
procedure JSDeleteKey (const AKey, AFileName: String); OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
JSDeleteKey(Key, AFileName);
end;
//Read subkeys
procedure JSReadSubKeys (const AKey: UnicodeString; SubkeyList: TStrings; const AFileName: String); OVERLOAD;
var JSConf: TJSONConfig;
begin
JSConf:= TJSONConfig.Create(Nil);
with JSConf do
begin
Filename:= AFileName;
Formatted:= True;
SubkeyList.Clear;
EnumSubKeys(AKey, SubkeyList);
Free;
end;
end;
procedure JSReadSubKeys (const AKey: String; SubkeyList: TStrings; const AFileName: String); OVERLOAD;
var Key: UnicodeString;
begin
Key:= UnicodeString(AKey);
JSReadSubKeys(Key, SubkeyList, AFileName);
end;
end.

View File

@ -0,0 +1,61 @@
unit SkinButton;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, Buttons, Graphics, Controls;
type TSkinBtn = class(TSpeedButton)
private
FNormalColor, FHighlightColor, FClickColor: TColor;
FTransparent: Boolean;
FOnMouseDown: TMouseEvent;
FOnMouseEnter, FOnMouseLeave: TNotifyEvent;
protected
procedure POnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure POnMouseEnter(Sender: TObject);
procedure POnMouseLeave(Sender: TObject);
public
constructor Create(AOwner: TComponent);
destructor Destroy;
published
property Transparent: Boolean read FTransparent;
property NormalColor: TColor read FNormalColor write FNormalColor;
property OnHighlightColor: TColor read FHighlightColor write FHighlightColor;
property OnClickColor: TColor read FClickColor write FClickColor;
property OnMouseDown: TMouseEvent read FOnMouseDown;
property OnMouseEnter: TNotifyEvent read FOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FOnMouseLeave;
end;
implementation
constructor TSkinBtn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FNormalColor:= clWhite;
FHighlightColor:= FNormalColor;
FClickColor:= FNormalColor;
FTransparent:= False;
inherited Transparent:= FTransparent;
inherited OnMouseEnter:= POnMouseEnter;
inherited OnMouseDown:= POnMouseDown;
inherited OnMouseLeave:= POnMouseLeave;
end;
destructor TSkinBtn.Destroy;
begin
inherited Destroy;
end;
procedure TSkinBtn.POnMouseEnter(Sender: TObject);
begin
(Sender as TSkinBtn).Color:= FHighlightColor;
inherited OnMouseEnter(Sender);
end;
procedure TSkinBtn.POnMouseLeave(Sender: TObject);
begin
(Sender as TSkinBtn).Color:= FNormalColor;
inherited OnMouseLeave(Sender);
end;
procedure TSkinBtn.POnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
(Sender as TSkinBtn).Color:= FClickColor;
inherited OnMouseDown(Sender, Button, Shift, X, Y);
end;
end.

249
ANB ST CP/data/VCLEx.pas Normal file
View File

@ -0,0 +1,249 @@
unit VCLEx;
{$MODE Delphi}
{$codepage UTF8}
interface
uses ShellApi, windows, sysutils, strutils, LazFileUtils, LazUTF8;
type IntEx = {$IFDEF Win64}Int64{$ELSE}Integer{$ENDIF};
TWaitEvent = procedure;
TOSPlatform = (ospUnknown, ospWin32, ospWin64);
TPrivilegeState = (psError, psLimitedUser, psAdmin);
Percent = 0..100;
TRandomRange = (rrUpperCasesLetters, rrLowerCasesLetters, rrNumbers, rrStandartSymbols);
TRandomRanges = set of TRandomRange;
//stdcalls
function IntToBool (const AInt: IntEx): Boolean; STDCALL;
function BoolToInt (const ABool: Boolean): IntEx; STDCALL;
function CopyDirectory (const AFromDir, AToDir: String; const AFlags: Word = FOF_FILESONLY): Boolean; STDCALL;
function MoveDirectory (const AFromDir, AToDir: String; const AFlags: Word = FOF_FILESONLY): Boolean; STDCALL;
function DelDirectory (const ADir: String; const AFlags: Word = FOF_SILENT or FOF_NOCONFIRMATION): Boolean; STDCALL;
procedure WaitEx (const AMs: Int64; OnWait: TWaitEvent); STDCALL;
procedure Wait (const AMs: Int64); STDCALL;
function GetBuildPlatform: TOSPlatform; STDCALL;
function GetWindowsUserPrivilege: TPrivilegeState; STDCALL;
function ExtractUpDir(const ADir: String; var VSuccess: Boolean): String; STDCALL;
function GetAnyFileType (const AFileName: UTF8String): UTF8String; STDCALL;
function FileSizeToStr (const AFS: Int64; const AScaleCaptions: array of String): String; OVERLOAD; STDCALL;
function FileSizeToStr (const AFS: Int64): String; OVERLOAD; STDCALL;
function GetRandomString (const sLength: Integer; const ARange: TRandomRanges = [rrUpperCasesLetters, rrLowerCasesLetters]; const AIncludedSymbols: String = ''; const AExcludedSymbols: String = ''): String; STDCALL;
implementation
function IntToBool (const AInt: IntEx): Boolean;
begin
if AInt >= 0 then
Result:= True
else
Result:= False;
end;
function BoolToInt (const ABool: Boolean): IntEx;
begin
if ABool then
Result:= 1
else
Result:= -1;
end;
//from http://www.delphiworld.narod.ru/base/copy_del_move_dir.html
function CopyDirectory (const AFromDir, AToDir: String; const AFlags: Word = FOF_FILESONLY): Boolean;
var fos: TSHFileOpStruct;
begin
with fos do
begin
wFunc:= FO_COPY;
fFlags:= AFlags;
pFrom:= PChar(AFromDir + #0);
pTo:= PChar(AToDir);
end;
Result:= (0 = SHFileOperation(fos));
end;
function MoveDirectory (const AFromDir, AToDir: String; const AFlags: Word = FOF_FILESONLY): Boolean;
var fos: TSHFileOpStruct;
begin
with fos do
begin
wFunc:= FO_MOVE;
fFlags:= AFlags;
pFrom:= PChar(AFromDir + #0);
pTo:= PChar(AToDir);
end;
Result:= (0 = SHFileOperation(fos));
end;
function DelDirectory (const ADir: String; const AFlags: Word = FOF_SILENT or FOF_NOCONFIRMATION): Boolean;
var
fos: TSHFileOpStruct;
begin
with fos do
begin
wFunc:= FO_DELETE;
fFlags:= AFlags;
pFrom:= PChar(ADir + #0);
end;
Result:= (0 = SHFileOperation(fos));
end;
//---
procedure WaitEx (const AMs: Int64; OnWait: TWaitEvent);
var STime: Int64;
begin
STime:= GetTickCount64;
repeat
OnWait;
until (GetTickCount64 - STime) = AMs;
end;
procedure Wait (const AMs: Int64);
procedure MyWait;
begin
end;
begin
WaitEx(AMs, @MyWait);
end;
//GetBuildPlatform
function GetBuildPlatform: TOSPlatform;
begin
Result:= ospUnknown;
if LowerCase({$I %FPCTARGETOS%}) = 'win32' then
Result:= ospWin32;
if LowerCase({$I %FPCTARGETOS%}) = 'win64' then
Result:= ospWin64;
end;
//GetWindowsUserPrivilege
function GetWindowsUserPrivilege: TPrivilegeState;
const SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5));
SECURITY_BUILTIN_DOMAIN_RID = $00000020;
DOMAIN_ALIAS_RID_ADMINS = $00000220;
SECURITY_MANDATORY_HIGH_RID = $00003000;
TokenIntegrityLevel = 25;
var hAccessToken: THandle;
ptgGroups: PTokenGroups;
dwInfoBufferSize: DWORD;
psidAdministrators: PSID;
I: Integer;
SubAuthority: DWORD;
begin
Result:= psError;
if Win32Platform <> VER_PLATFORM_WIN32_NT then
Exit;
if not OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken) then
if not OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, hAccessToken) then
Exit;
try
GetMem(ptgGroups, 1024);
try
if Win32MajorVersion < 6 then
begin
if not GetTokenInformation(hAccessToken, TokenGroups, ptgGroups, 1024, dwInfoBufferSize) then
Exit;
AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, psidAdministrators);
try
Result:= psLimitedUser;
for I:= 0 to ptgGroups.GroupCount - 1 do
if EqualSid(psidAdministrators, ptgGroups.Groups[I].Sid) then
begin
Result:= psAdmin;
Break;
end;
finally
FreeSid(psidAdministrators);
end;
end
else
begin
if GetTokenInformation(hAccessToken, TTokenInformationClass(TokenIntegrityLevel), ptgGroups, 1024, dwInfoBufferSize) and IsValidSid(PSIDAndAttributes(ptgGroups)^.Sid) then
begin
Result:= psLimitedUser;
SubAuthority:= GetSidSubAuthorityCount(PSIDAndAttributes(ptgGroups)^.Sid)^ - 1;
if GetSidSubAuthority(PSIDAndAttributes(ptgGroups)^.Sid, SubAuthority)^ >= SECURITY_MANDATORY_HIGH_RID then
Result:= psAdmin;
end;
end;
finally
FreeMem(ptgGroups);
end;
finally
CloseHandle(hAccessToken);
end;
end;
function ExtractUpDir (const ADir: String; var VSuccess: Boolean): String;
var CurrDelim, NextDelim: Integer;
s, Str: String;
begin
Str:= ExcludeTrailingBackslash(ADir);
if Length(ADir) < 4 then
begin
VSuccess:= false;
Result:= ADir;
Exit;
end;
s:= '';
CurrDelim:= 1;
repeat
NextDelim:= PosEx('\', Str, CurrDelim);
if NextDelim = 0 then
NextDelim:= Length(Str) + 1;
if NextDelim < Length(Str) then
s:= s + Copy(Str, CurrDelim, NextDelim - CurrDelim) + '\';
CurrDelim:= NextDelim + 1;
until (CurrDelim > Length(Str));
VSuccess:= DirectoryExistsUTF8(s);
Result:= s;
end;
function GetAnyFileType (const AFileName: UTF8String): UTF8String;
var FileInfo: TSHFILEINFO;
begin
Result:= '';
FillChar(FileInfo, SizeOf(FileInfo), 0);
if (SHGetFileInfo(PChar(ExtractFileExt(AFileName)), FILE_ATTRIBUTE_NORMAL, FileInfo, SizeOf(FileInfo), SHGFI_TYPENAME or SHGFI_USEFILEATTRIBUTES) <> 0) then
Result:= AnsiToUtf8(FileInfo.szTypeName);
end;
function FileSizeToStr (const AFS: Int64; const AScaleCaptions: array of String): String;
var ARSize: Real;
begin
if AFS < 1024 then
begin
Result:= Format('%d ' + AScaleCaptions[0], [AFS]);
Exit;
end;
if AFS < 1048576 then
begin
ARSize:= Round((AFS / 1024)*100)/100;
Result:= FloatToStr(ARSize) + ' ' + AScaleCaptions[1];
Exit;
end;
if AFS < 1073741824 then
begin
ARSize:= Round((AFS / 1048576)*100)/100;
Result:= FloatToStr(ARSize) + ' ' + AScaleCaptions[2];
Exit;
end;
ARSize:= Round((AFS / 1073741824)*100)/100;
Result:= FloatToStr(ARSize) + ' ' + AScaleCaptions[3];
end;
function FileSizeToStr (const AFS: Int64): String;
begin
Result:= FileSizeToStr(AFS, ['Byte', 'KB', 'MB', 'GB']);
end;
function GetRandomString (const sLength: Integer; const ARange: TRandomRanges = [rrUpperCasesLetters, rrLowerCasesLetters]; const AIncludedSymbols: String = ''; const AExcludedSymbols: String = ''): String;
const UpperCaseChars = 'ABCDEFGHIKLMNOPQRSTUVWXYZ';
LowerCaseChars = 'abcdefghiklmnopqrstuvwxyz';
NumbersChars = '0123456789';
SymbolsChars = '!"#$%&''()*+,-.:;<=>?@\]^_`{|}~';
var i, j: Integer;
Chars: String;
begin
SetLength (Result, sLength);
Chars:= AIncludedSymbols;
if rrUpperCasesLetters in ARange then
Chars:= Chars + UpperCaseChars;
if rrLowerCasesLetters in ARange then
Chars:= Chars + LowerCaseChars;
if rrNumbers in ARange then
Chars:= Chars + NumbersChars;
if rrStandartSymbols in ARange then
Chars:= Chars + SymbolsChars;
if Length(AExcludedSymbols) > 0 then
for i:= 1 to Length(AExcludedSymbols) do
begin
j:= Pos(AExcludedSymbols[i], Chars);
if j > 0 then
Delete(Chars, j, 1);
end;
for i:= 1 to sLength do
Result[i]:= Chars[Random(Length(Chars))+1];
end;
end.

View File

@ -0,0 +1,145 @@
unit VersionControl;
{$MODE Delphi}
{$codepage UTF8}
interface
uses LCLIntf, LCLType, LMessages, SysUtils, StrUtils, Forms, Classes,
{$IFDEF WINDOWS}PJVersionInfo{$ENDIF};
type TSmallVersionInfo = record
sviMajor, sviMinor: int64;
end;
type TVersionInfo = record
viMajor, viMinor, viRelease, viBuild: integer;
end;
function SmallVersionInfoToStr (const Value: TSmallVersionInfo): string; stdcall;
function VersionInfoToStr (const Value: TVersionInfo): string; stdcall;
function VersionInfoToSmallVersionInfo (const Value: TVersionInfo): TSmallVersionInfo; stdcall;
function SmallVersionInfoToVersionInfo (const Value: TSmallVersionInfo; const ANilValue: integer = 0): TVersionInfo; stdcall;
function StrToVersionInfo (const AString: string): TVersionInfo; stdcall;
function StrToSmallVersionInfo (const AString: string): TSmallVersionInfo; stdcall;
function CompareVersionInfo (const AVersionInfo1, AVersionInfo2: TVersionInfo): integer; stdcall;
function CompareSmallVersionInfo (const ASmallVersionInfo1, ASmallVersionInfo2: TSmallVersionInfo): integer; stdcall;
{$IFDEF WINDOWS}function GetApplicationVersionInfoStr (const AFileName, AVersionSTR: string): string; STDCALL;{$ENDIF}
const NilVersionInfo: TVersionInfo = (viMajor: 0; viMinor: 0; viRelease: 0; viBuild: 0);
NilSmallVersionInfo: TSmallVersionInfo = (sviMajor: 0; sviMinor: 0);
implementation
function SmallVersionInfoToStr (const Value: TSmallVersionInfo): string;
const Mask: string = '%d.%d';
begin
Result:= Format(Mask, [Value.sviMajor, Value.sviMinor]);
end;
function VersionInfoToStr (const Value: TVersionInfo): string;
const Mask: string = '%d.%d.%d.%d';
begin
Result:= Format(Mask, [Value.viMajor, Value.viMinor, Value.viRelease, Value.viBuild]);
end;
function VersionInfoToSmallVersionInfo (const Value: TVersionInfo): TSmallVersionInfo;
begin
Result.sviMajor:= Value.viMajor;
Result.sviMinor:= Value.viMinor;
end;
function SmallVersionInfoToVersionInfo (const Value: TSmallVersionInfo; const ANilValue: integer = 0): TVersionInfo;
begin
Result.viMajor:= Value.sviMajor;
Result.viMinor:= Value.sviMinor;
Result.viRelease:= ANilValue;
Result.viBuild:= ANilValue;
end;
function StrToVersionInfo (const AString: string): TVersionInfo;
var stringver: string;
CurrDelim, NextDelim, CurrIndex: Integer;
StrArray: array [1..4] of string;
begin
stringver:= AString;
CurrDelim:= 1;
CurrIndex:= 1;
repeat
NextDelim:= PosEx('.', stringver, CurrDelim);
if NextDelim = 0 then
NextDelim:= Length(stringver) + 1;
StrArray[CurrIndex]:= Copy(stringver, CurrDelim, NextDelim - CurrDelim);
CurrDelim:= NextDelim + 1;
CurrIndex:= CurrIndex + 1;
until CurrDelim > Length(stringver);
Result.viMajor:= StrToInt(StrArray[1]);
Result.viMinor:= StrToInt(StrArray[2]);
Result.viRelease:= StrToInt(StrArray[3]);
Result.viBuild:= StrToInt(StrArray[4]);
end;
function StrToSmallVersionInfo (const AString: string): TSmallVersionInfo;
var stringver: string;
CurrDelim, NextDelim: Integer;
StrArray: array [1..2] of string;
begin
stringver:= AString;
NextDelim:= PosEx('.', stringver, 1);
if NextDelim = 0 then
begin
StrArray[1]:= stringver;
Exit;
end;
StrArray[1]:= Copy(stringver, 1, NextDelim - 1);
CurrDelim:= NextDelim + 1;
NextDelim:= PosEx('.', stringver, CurrDelim);
if NextDelim = 0 then
NextDelim:= Length(stringver) + 1;
StrArray[2]:= Copy(stringver, CurrDelim, NextDelim - CurrDelim);
Result.sviMajor:= StrToInt(StrArray[1]);
Result.sviMinor:= StrToInt(StrArray[2]);
end;
function CompareVersionInfo (const AVersionInfo1, AVersionInfo2: TVersionInfo): integer;
//Result:
// 0 - AVersionInfo1 = AVersionInfo2
// -1 - AVersionInfo1 > AVersionInfo2
// 1 - AVersionInfo1 < AVersionInfo2
begin
//by default this versions are equal
Result:= 0;
//equal
if ((AVersionInfo1.viMajor = AVersionInfo2.viMajor) and
(AVersionInfo1.viMinor = AVersionInfo2.viMinor) and
(AVersionInfo1.viRelease = AVersionInfo2.viRelease) and
(AVersionInfo1.viBuild = AVersionInfo2.viBuild)) then
Result:= 0;
//more
if ((AVersionInfo1.viMajor > AVersionInfo2.viMajor) or
((AVersionInfo1.viMajor = AVersionInfo2.viMajor) and
(AVersionInfo1.viMinor > AVersionInfo2.viMinor)) or
((AVersionInfo1.viMajor = AVersionInfo2.viMajor) and
(AVersionInfo1.viMinor = AVersionInfo2.viMinor) and
(AVersionInfo1.viRelease > AVersionInfo2.viRelease)) or
((AVersionInfo1.viMajor = AVersionInfo2.viMajor) and
(AVersionInfo1.viMinor = AVersionInfo2.viMinor) and
(AVersionInfo1.viRelease = AVersionInfo2.viRelease) and
(AVersionInfo1.viBuild > AVersionInfo2.viBuild))) then
Result:= -1;
//less
if ((AVersionInfo1.viMajor < AVersionInfo2.viMajor) or
((AVersionInfo1.viMajor = AVersionInfo2.viMajor) and
(AVersionInfo1.viMinor < AVersionInfo2.viMinor)) or
((AVersionInfo1.viMajor = AVersionInfo2.viMajor) and
(AVersionInfo1.viMinor = AVersionInfo2.viMinor) and
(AVersionInfo1.viRelease < AVersionInfo2.viRelease)) or
((AVersionInfo1.viMajor = AVersionInfo2.viMajor) and
(AVersionInfo1.viMinor = AVersionInfo2.viMinor) and
(AVersionInfo1.viRelease = AVersionInfo2.viRelease) and
(AVersionInfo1.viBuild < AVersionInfo2.viBuild))) then
Result:= 1;
end;
function CompareSmallVersionInfo (const ASmallVersionInfo1, ASmallVersionInfo2: TSmallVersionInfo): integer;
var AVI1, AVI2: TVersionInfo;
begin
AVI1:= SmallVersionInfoToVersionInfo(ASmallVersionInfo1);
AVI2:= SmallVersionInfoToVersionInfo(ASmallVersionInfo2);
Result:= CompareVersionInfo(AVI1, AVI2);
end;
{$IFDEF WINDOWS}
function GetApplicationVersionInfoStr (const AFileName, AVersionSTR: string): string;
var VIC: TPJVersionInfo;
begin
VIC:= TPJVersionInfo.Create(nil);
VIC.FileName:= AFileName;
Result:= VIC.StringFileInfo[AVersionSTR];
VIC.Free;
end;
{$ENDIF WINDOWS}
end.

31
ATSynEdit/.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
*.exe
*.rar
*.zip
*.dbg
*.ico
*.dll
*.bpl
*.bpi
*.dcp
*.so
*.apk
*.drc
*.map
*.dres
*.rsm
*.tds
*.dcu
*.dof
*.deb
*.zip
*.ppu
*.bak
*.ini
*.lps
*.copy
lib/
backup/
project?
demo
lex_lib_demo

View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="econtrol_package"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="11">
<Unit0>
<Filename Value="demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
<Unit2>
<Filename Value="..\..\atsynedit\atsynedit_adapter_econtrol.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Adapter_EControl"/>
</Unit2>
<Unit3>
<Filename Value="..\..\atsynedit\atsynedit.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit"/>
</Unit3>
<Unit4>
<Filename Value="..\..\atsynedit\atsynedit_canvasproc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_CanvasProc"/>
</Unit4>
<Unit5>
<Filename Value="..\..\atsynedit\atsynedit_adapters.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Adapters"/>
</Unit5>
<Unit6>
<Filename Value="..\..\atsynedit\atstringproc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATStringProc"/>
</Unit6>
<Unit7>
<Filename Value="..\..\atsynedit\atstringproc_textbuffer.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATStringProc_TextBuffer"/>
</Unit7>
<Unit8>
<Filename Value="..\..\atsynedit\atsynedit_fold.inc"/>
<IsPartOfProject Value="True"/>
</Unit8>
<Unit9>
<Filename Value="..\..\atsynedit\atsynedit_ranges.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Ranges"/>
</Unit9>
<Unit10>
<Filename Value="..\..\atsynedit\atsynedit_hilite.inc"/>
<IsPartOfProject Value="True"/>
</Unit10>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);..\..\atsynedit"/>
<OtherUnitFiles Value="..\..\atsynedit;..\..\proc_lexer"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,22 @@
program demo;
{$mode objfpc}{$H+}
uses
//heaptrc,
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1, ATSynEdit, atsynedit_adapters, ATSynEdit_CanvasProc,
ATStringProc_TextBuffer, ATSynEdit_Ranges, ecLists, ecStrUtils;
{$R *.res}
begin
RequireDerivedFormResource:= True;
Application.Initialize;
Application.CreateForm(TfmMain, fmMain);
Application.Run;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,452 @@
object fmMain: TfmMain
Left = 391
Height = 578
Top = 237
Width = 889
Caption = 'Demo'
ClientHeight = 578
ClientWidth = 889
OnCreate = FormCreate
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.5'
object Panel1: TPanel
Left = 0
Height = 218
Top = 360
Width = 889
Align = alBottom
BevelOuter = bvNone
ClientHeight = 218
ClientWidth = 889
TabOrder = 0
object chkWrap: TCheckBox
Left = 9
Height = 24
Top = 8
Width = 98
Caption = 'word wrap'
OnChange = chkWrapChange
TabOrder = 0
end
object edLexer: TComboBox
Left = 9
Height = 31
Top = 120
Width = 176
DropDownCount = 24
ItemHeight = 0
OnChange = edLexerChange
Style = csDropDownList
TabOrder = 5
end
object files: TShellListView
Left = 352
Height = 208
Top = 3
Width = 528
Anchors = [akTop, akLeft, akBottom]
Color = clDefault
HideSelection = False
ReadOnly = True
ShowColumnHeaders = False
SortType = stText
TabOrder = 12
ToolTips = False
ViewStyle = vsSmallIcon
OnClick = filesClick
ObjectTypes = [otNonFolders]
end
object chkFullSel: TCheckBox
Left = 9
Height = 24
Top = 48
Width = 129
Caption = 'show full sel-bg'
OnChange = chkFullSelChange
TabOrder = 2
end
object chkFullHilite: TCheckBox
Left = 9
Height = 24
Top = 68
Width = 154
Caption = 'show full syntax-bg'
OnChange = chkFullHiliteChange
TabOrder = 3
end
object bOpen: TButton
Left = 192
Height = 25
Top = 8
Width = 152
Caption = 'open...'
OnClick = bOpenClick
TabOrder = 8
end
object chkUnpri: TCheckBox
Left = 9
Height = 24
Top = 28
Width = 130
Caption = 'show unprinted'
OnChange = chkUnpriChange
TabOrder = 1
end
object chkShowCur: TCheckBox
Left = 9
Height = 24
Top = 88
Width = 132
Caption = 'show cur line bg'
OnChange = chkShowCurChange
TabOrder = 4
end
object chkLexer: TCheckBox
Left = 9
Height = 24
Top = 152
Width = 108
Caption = 'enable lexer'
Checked = True
OnChange = chkLexerChange
State = cbChecked
TabOrder = 6
end
object chkDyn: TCheckBox
Left = 9
Height = 24
Top = 176
Width = 119
Caption = 'dynamic hilite'
OnChange = chkDynChange
TabOrder = 7
end
object bComment: TButton
Left = 192
Height = 25
Top = 40
Width = 152
Caption = 'comment sel'
OnClick = bCommentClick
TabOrder = 9
end
object bUncomment: TButton
Left = 192
Height = 25
Top = 72
Width = 152
Caption = 'uncomment sel'
OnClick = bUncommentClick
TabOrder = 10
end
object bExport: TButton
Left = 192
Height = 25
Top = 104
Width = 152
Caption = 'export html'
OnClick = bExportClick
TabOrder = 11
end
end
object Tree: TTreeView
Left = 0
Height = 360
Top = 0
Width = 240
Align = alLeft
HideSelection = False
Images = ImageListTree
ReadOnly = True
RightClickSelect = True
RowSelect = True
TabOrder = 1
OnClick = TreeClick
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end
object PanelText: TPanel
Left = 245
Height = 360
Top = 0
Width = 644
Align = alClient
BevelOuter = bvNone
Caption = 'PanelText'
TabOrder = 2
end
object Splitter1: TSplitter
Left = 240
Height = 360
Top = 0
Width = 5
end
object OpenDialog1: TOpenDialog
left = 264
top = 176
end
object ImageListTree: TImageList
AllocBy = 10
left = 368
top = 176
Bitmap = {
4C69080000001000000010000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000848484FF848484FF8484
84FF848484FF848484FF00000000000000000000000000000000000000000000
000000000000000000000000000000000000848484FFC6C6C6FF00FFFFFFC6C6
C6FF00FFFFFFC6C6C6FF848484FF000000000000000000000000000000000000
0000000000000000000000000000848484FFC6C6C6FF00FFFFFFC6C6C6FF00FF
FFFFC6C6C6FF00FFFFFFC6C6C6FF848484FF848484FF848484FF848484FF8484
84FF848484FF0000000000000000848484FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFF848484FF000000FF00000000848484FFFFFFFFFF00FFFFFFC6C6C6FF00FF
FFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FF
FFFF848484FF000000FF00000000848484FFFFFFFFFFC6C6C6FF00FFFFFFC6C6
C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6
C6FF848484FF000000FF00000000848484FFFFFFFFFF00FFFFFFC6C6C6FF00FF
FFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FF
FFFF848484FF000000FF00000000848484FFFFFFFFFFC6C6C6FF00FFFFFFC6C6
C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6
C6FF848484FF000000FF00000000848484FFFFFFFFFF00FFFFFFC6C6C6FF00FF
FFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FF
FFFF848484FF000000FF00000000848484FFFFFFFFFFC6C6C6FF00FFFFFFC6C6
C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6
C6FF848484FF000000FF00000000848484FFFFFFFFFF00FFFFFFC6C6C6FF00FF
FFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FFFFFFC6C6C6FF00FF
FFFF848484FF000000FF00000000848484FF848484FF848484FF848484FF8484
84FF848484FF848484FF848484FF848484FF848484FF848484FF848484FF8484
84FF848484FF000000FF0000000000000000000000FF000000FF000000FF0000
00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000
00FF000000FF000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF0000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000848400FF848400FFFF0000FFFF0000FF840000FF0000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FFFF00FFFFFFFFFFFF0000FFFF0000FFFF0000FF000000FF8484
84FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000848400FF848400FFFF0000FFFF0000FF000000FF8484
84FF000000000000000000000000000000000000000000000000000000000000
000000000000FFFF00FFFFFFFFFFFF0000FFFF0000FFFF0000FF000000FF8484
84FF0000000000000000000000000000FFFF000084FF00000000000000000000
0000848484FFFFFFFFFFFF0000FF848400FFFF0000FFFF0000FF000000FF8484
84FF0000000000000000000000000000FFFF0000FFFF000084FF000084FF0000
000000000000848484FF848484FF848484FF848484FF848484FF848484FF8484
84FF0000000000000000000000000000FFFF0000FFFF000084FF000084FF0000
84FF000084FFFFFFFFFFFFFFFFFFFFFFFFFF008484FF008484FF008484FF0000
00000000000000000000000000000000FFFF0000FFFF0000FFFF000084FF0000
84FF000084FF000000FFFFFFFFFF848484FF00FFFFFF00FFFFFF008484FF0084
84FF0000000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000
00FF000000FF848484FF008484FF00FFFFFF00FFFFFF008484FF008484FF0084
84FF008484FF00000000000000000000FFFF0000FFFF0000FFFF000000FF8484
84FF848484FF848484FF008484FF00FFFFFF008484FF008484FF008484FF0084
84FF008484FF00000000000000000000FFFF000000FF000000FF848484FF8484
84FF848484FF848484FF008484FF008484FF008484FF008484FF008484FF0084
84FF000000FF848484FF000000000000000000000000848484FF848484FF8484
84FF000000000000000000000000008484FF008484FF008484FF008484FF0084
84FF000000FF848484FF00000000000000000000000000000000848484FF0000
0000000000000000000000000000848484FF008484FF008484FF008484FF0000
00FF848484FF848484FF00000000000000000000000000000000000000000000
000000000000000000000000000000000000000000FF000000FF000000FF8484
84FF848484FF0000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000848484FF848484FF8484
84FF000000000000000000000000000000000000000000000000000000000000
000000000000FFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FF0000
0000000000000000000000000000000000000000000000000000000000000000
000000000000848484FF848484FF848484FF848484FF848484FF840000FF0000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFF00FF848484FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000FF8484
84FF000000000000000000000000000000000000000000000000000000000000
000000000000848484FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000FF8484
84FF000000000000000000000000000000000000000000000000000000000000
0000FFFF00FF848484FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000FF8484
84FF0000000000000000000000000000FFFF000084FF00000000000000000000
0000848484FF848484FFFF0000FF848400FFFF0000FFFF0000FF000000FF8484
84FF0000000000000000000000000000FFFF848484FF000084FF000084FF0000
000000000000848484FF848484FF848484FF848484FF848484FF848484FF8484
84FF0000000000000000000000000000FFFF848484FF848484FF848484FF0000
84FF000084FFFFFFFFFFFFFFFFFFFFFFFFFF008484FF008484FF008484FF0000
00000000000000000000000000000000FFFF848484FFFFFFFFFFFFFFFFFF8484
84FF848484FF000000FFFFFFFFFFFFFFFFFF00FFFFFF848484FF848484FF0084
84FF0000000000000000000000000000FFFF848484FFFFFFFFFF0000FFFF0000
00FF000000FF848484FF008484FF00FFFFFF848484FF848484FFFFFFFFFFFFFF
FFFF008484FF00000000000000000000FFFF848484FF0000FFFF000000FF8484
84FF848484FF848484FF008484FF848484FF848484FFFFFFFFFFFFFFFFFFFFFF
FFFF008484FF848484FF000000000000FFFF000000FF000000FF848484FF8484
84FF848484FF848484FF008484FF848484FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFF000000FF848484FF000000000000000000000000848484FF848484FF8484
84FF000000000000000000000000008484FF848484FFFFFFFFFFFFFFFFFF0084
84FF000000FF848484FF00000000000000000000000000000000848484FF0000
0000000000000000000000000000848484FF008484FF848484FF008484FF0000
00FF848484FF0000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000FF000000FF000000FF8484
84FF848484FF0000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000848484FF848484FF8484
84FF000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000848484FF0000
000000000000848484FF0000000000000000848484FF00000000000000008484
84FF000000000000000000000000000000000000000000000000848484FF0000
000000000000848484FF848400FF848400FFFF0000FF840000FF000000008484
84FF00000000000000000000000000000000848484FF848484FF000000FF8484
84FF848484FF000000FF848484FFFF0000FFFF0000FF000000FF848484FF0000
00FF848484FF848484FF00000000000000000000000000000000848484FFFFFF
FFFFFFFFFFFF848484FF848400FF848400FFFF0000FF000000FF848484FF8484
84FF00000000000000000000000000000000000000000000FFFF000084FFFFFF
FFFFFFFFFFFF848484FFFF0000FF848400FFFF0000FF000000FF848484FF8484
84FF00000000000000000000000000000000848484FF0000FFFF0000FFFF0000
84FF848484FF000000FF848484FF848484FF848484FF848484FF848484FF0000
00FF848484FF848484FF0000000000000000000000000000FFFF0000FFFF0000
84FF000084FF000084FFFFFFFFFFFFFFFFFF008484FF008484FFFFFFFFFF8484
84FF00000000000000000000000000000000000000000000FFFF0000FFFF0000
FFFF000000FF000000FF008484FF00FFFFFF00FFFFFF008484FF008484FF0084
84FF00000000000000000000000000000000848484FF0000FFFF0000FFFF0000
00FF848484FF848484FF008484FF00FFFFFF008484FF008484FF008484FF0084
84FF848484FF848484FF0000000000000000000000000000FFFF000000FF8484
84FF848484FF848484FF008484FF008484FF008484FF008484FF008484FF0000
00FF000000000000000000000000000000000000000000000000848484FF8484
84FFFFFFFFFF848484FFFFFFFFFF848484FF008484FF008484FF000000FF8484
84FF00000000000000000000000000000000848484FF848484FF000000FF8484
84FF848484FF000000FF848484FF848484FF000000FF000000FF848484FF8484
84FF848484FF848484FF00000000000000000000000000000000848484FF0000
000000000000848484FF0000000000000000848484FF848484FF848484FF8484
84FF000000000000000000000000000000000000000000000000848484FF0000
000000000000848484FF0000000000000000848484FF00000000000000008484
84FF000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000848484FF848484FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000848484FFC6C6C6FFC6C6C6FF848484FF848484FF00000000000000000000
0000000000000000000000000000000000000000000000000000000000008484
84FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FF848484FF848484FF0000
0000000000000000000000000000000000000000000000000000848484FFC6C6
C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FF8484
84FF848484FF00000000000000000000000000000000848484FFC6C6C6FFC6C6
C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FF848484FF8484
84FF000000FF00000000000000000000000000000000848484FFC6C6C6FFC6C6
C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FF848484FF8484
84FF000000FF00000000000000000000000000000000848484FFFFFFFFFFC6C6
C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FFC6C6C6FF848484FF848484FF8484
84FF000000FF00000000000000000000000000000000848484FFC6C6C6FFFFFF
FFFFFFFFFFFFC6C6C6FFC6C6C6FFC6C6C6FF848484FF848484FF848484FF8484
84FF000000FF00000000000000000000000000000000848484FFFFFFFFFFC6C6
C6FFFFFFFFFFC6C6C6FFFFFFFFFFC6C6C6FF848484FF848484FF848484FF8484
84FF000000FF00000000000000000000000000000000848484FFC6C6C6FFFFFF
FFFFC6C6C6FFFFFFFFFFC6C6C6FFC6C6C6FF848484FF848484FF848484FF0000
00FF000000000000000000000000000000000000000000000000848484FF8484
84FFFFFFFFFFC6C6C6FFFFFFFFFFC6C6C6FF848484FF848484FF000000FF0000
0000000000000000000000000000000000000000000000000000000000000000
0000848484FF848484FF848484FFC6C6C6FF848484FF000000FF000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000848484FF000000FF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000005A5A5AFF292929FF4A4A4AFF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000292929FF313131FF00000000212121FF424242FF000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000004A4A4AFF4A4A4AFF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000001810
18FF101010FF181818FF080808FF000000FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000292921FF000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000292121FF212121FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00FF181818FF212121FF0000000000000000313131FF313131FF000000000000
00FF181818FF0000000000000000000000000000000000000000000000000808
08FF101010FF00000000000000000000000000000000393939FF080808FF3131
31FF000000000000000000000000000000000000000000000000000000000808
08FF313131FF000000000000000000000000000000FF101010FF212121FF0000
0000000000000000000000000000000000000000000000000000000000000808
08FF000000000000000000000000000000FF101010FF00000000212121FF2121
21FF000000000000000000000000000000000000000000000000313131FF2121
21FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000FF000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000848484FF00FF00FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000848484FF00FF00FF00FF00FF00FF00FF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000848484FF008400FF00FF00FF00FF00FF00FF00FF000000000000
0000000000000000000000000000000000000000000000000000000000008484
84FF00000000848484FF008400FF008400FF00FF00FF00FF00FF00FF00FF0000
000000FF00FF0000000000000000000000000000000000000000848484FF00FF
00FF848484FF848484FF008400FF008400FF008400FF00FF00FF00FF00FF00FF
00FF00FF00FF848484FF000000000000000000000000848484FF00FF00FF00FF
00FF00FF00FF848484FF008400FF000000FF000000FF000000FF00FF00FF00FF
00FF00FF00FF848484FF00000000000000000000000000000000000000FF00FF
00FF00FF00FF00FF00FF008400FF000000FF848484FF008400FF00FF00FF00FF
00FF00FF00FF848484FF00000000000000000000000000000000000000000000
00FF00FF00FF00FF00FF008400FF000000FF848484FF00FF00FF00FF00FF00FF
00FF00FF00FF848484FF00000000000000000000000000000000000000000000
0000000000FF000000FF000000FF848484FF848484FF00000000848484FF8484
84FF848484FF848484FF00000000000000000000000000000000000000000000
000000000000848484FF848484FF848484FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000848484FF00FFFFFF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000848484FF00FFFFFF00FFFFFF00FFFFFF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000848484FF008484FF00FFFFFF00FFFFFF00FFFFFF000000000000
0000000000000000000000000000000000000000000000000000000000008484
84FF00000000848484FF008484FF008484FF00FFFFFF00FFFFFF00FFFFFF0000
000000FFFFFF0000000000000000000000000000000000000000848484FF00FF
FFFF848484FF848484FF008484FF008484FF008484FF00FFFFFF00FFFFFF00FF
FFFF00FFFFFF848484FF000000000000000000000000848484FF00FFFFFF00FF
FFFF00FFFFFF848484FF008484FF000000FF000000FF000000FF00FFFFFF00FF
FFFF00FFFFFF848484FF00000000000000000000000000000000000000FF00FF
FFFF00FFFFFF00FFFFFF008484FF000000FF848484FF008484FF00FFFFFF00FF
FFFF00FFFFFF848484FF00000000000000000000000000000000000000000000
00FF00FFFFFF00FFFFFF008484FF000000FF848484FF00FFFFFF00FFFFFF00FF
FFFF00FFFFFF848484FF00000000000000000000000000000000000000000000
0000000000FF000000FF000000FF848484FF848484FF00000000848484FF8484
84FF848484FF848484FF00000000000000000000000000000000000000000000
000000000000848484FF848484FF848484FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000
}
end
end

View File

@ -0,0 +1,360 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, ShellCtrls, ComCtrls,
LclIntf, LclType,
ATSynEdit,
ATStringProc,
ATSynEdit_Adapter_EControl,
ATSynEdit_Carets,
ATSynEdit_Export_HTML,
ecSyntAnal,
proc_lexer;
type
{ TfmMain }
TfmMain = class(TForm)
bOpen: TButton;
bComment: TButton;
bUncomment: TButton;
bExport: TButton;
chkDyn: TCheckBox;
chkFullHilite: TCheckBox;
chkFullSel: TCheckBox;
chkLexer: TCheckBox;
chkShowCur: TCheckBox;
chkUnpri: TCheckBox;
chkWrap: TCheckBox;
edLexer: TComboBox;
files: TShellListView;
ImageListTree: TImageList;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
PanelText: TPanel;
Splitter1: TSplitter;
Tree: TTreeView;
procedure AdapterParseBegin(Sender: TObject);
procedure AdapterParseDone(Sender: TObject);
procedure bCommentClick(Sender: TObject);
procedure bExportClick(Sender: TObject);
procedure bOpenClick(Sender: TObject);
procedure bUncommentClick(Sender: TObject);
procedure chkDynChange(Sender: TObject);
procedure chkFullHiliteChange(Sender: TObject);
procedure chkFullSelChange(Sender: TObject);
procedure chkLexerChange(Sender: TObject);
procedure chkShowCurChange(Sender: TObject);
procedure chkUnpriChange(Sender: TObject);
procedure chkWrapChange(Sender: TObject);
procedure EditorChangeCaretPos(Sender: TObject);
procedure edLexerChange(Sender: TObject);
procedure filesClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TreeClick(Sender: TObject);
private
{ private declarations }
ed: TATSynEdit;
FDir: string;
FFilename: string;
procedure DoCommentAct(Act: TATCommentAction);
procedure DoLexer(const aname: string);
procedure DoOpenFile(const fn: string);
procedure EditCalcStaple(Sender: TObject; ALine, AIndent: integer; var AColor: TColor);
procedure EditClickGutter(Sender: TObject; ABand: integer; ALine: integer);
function GetComment: string;
procedure UpdateLexList;
public
{ public declarations }
end;
var
fmMain: TfmMain;
implementation
{$R *.lfm}
var
manager: TecSyntaxManager;
adapter: TATAdapterEControl;
{ TfmMain }
procedure TfmMain.UpdateLexList;
var
i: integer;
sl: tstringlist;
begin
sl:= tstringlist.create;
try
for i:= 0 to manager.AnalyzerCount-1 do
sl.Add(manager.Analyzers[i].LexerName);
sl.sort;
edLexer.Items.AddStrings(sl);
finally
sl.free;
end;
end;
procedure TfmMain.DoOpenFile(const fn: string);
var
an: TecSyntAnalyzer;
begin
FFilename:= fn;
adapter.Lexer:= nil;
Tree.Items.Clear;
ed.LoadFromFile(fn);
ed.SetFocus;
an:= DoFindLexerForFilename(manager, fn);
adapter.Lexer:= an;
if Assigned(an) then
edLexer.ItemIndex:= edLexer.Items.IndexOf(an.LexerName);
end;
procedure TfmMain.FormCreate(Sender: TObject);
var
fname_lxl: string;
begin
FDir:= ExtractFileDir(ExtractFileDir(ExtractFileDir(Application.ExeName)))+'/test_syntax_files/';
fname_lxl:= ExtractFilePath(Application.ExeName)+'lib.lxl';
manager:= TecSyntaxManager.Create(Self);
manager.LoadFromFile(fname_lxl);
UpdateLexList;
ed:= TATSynEdit.Create(Self);
ed.Font.Name:= 'Courier New';
ed.Parent:= PanelText;
ed.Align:= alClient;
ed.OptUnprintedVisible:= false;
ed.OptRulerVisible:= false;
ed.Colors.TextBG:= $e0f0f0;
ed.Colors.CurrentLineBG:= clTeal;
ed.Gutter[ed.GutterBandNum].Visible:= false;
ed.Gutter.Update;
ed.OnClickGutter:= @EditClickGutter;
ed.OnCalcStaple:= @EditCalcStaple;
ed.OnChangeCaretPos:=@EditorChangeCaretPos;
adapter:= TATAdapterEControl.Create(Self);
adapter.OnParseBegin:=@AdapterParseBegin;
adapter.OnParseDone:=@AdapterParseDone;
ed.AdapterHilite:= adapter;
chkWrap.Checked:= ed.OptWrapMode=cWrapOn;
chkFullSel.Checked:= ed.OptShowFullSel;
chkFullHilite.Checked:= ed.OptShowFullHilite;
chkUnpri.Checked:= ed.OptUnprintedVisible;
chkShowCur.Checked:= ed.OptShowCurLine;
chkDyn.Checked:= adapter.DynamicHiliteEnabled;
end;
procedure TfmMain.FormShow(Sender: TObject);
begin
if DirectoryExists(FDir) then
files.Root:= FDir;
end;
procedure TfmMain.TreeClick(Sender: TObject);
var
R: TecTextRange;
P: TPoint;
begin
if adapter.TreeBusy then exit;
if Tree.Selected=nil then exit;
if Tree.Selected.Data=nil then exit;
R:= TecTextRange(Tree.Selected.Data);
P:= adapter.TreeGetPositionOfRange(R);
ed.DoGotoPos_AndUnfold(P, 5, 5);
ed.SetFocus;
end;
procedure TfmMain.chkWrapChange(Sender: TObject);
begin
if chkWrap.checked then
ed.OptWrapMode:= cWrapOn
else
ed.OptWrapMode:= cWrapOff;
end;
procedure TfmMain.EditorChangeCaretPos(Sender: TObject);
begin
adapter.TreeShowItemForCaret(Tree, Point(ed.Carets[0].PosX, ed.Carets[0].PosY));
end;
procedure TfmMain.chkFullSelChange(Sender: TObject);
begin
ed.OptShowFullSel:= chkFullSel.Checked;
ed.Update;
end;
procedure TfmMain.chkLexerChange(Sender: TObject);
begin
adapter.Lexer:= nil;
ed.Fold.Clear;
if chkLexer.Checked then
adapter.Lexer:= DoFindLexerForFilename(manager, FFilename);
ed.Update;
end;
procedure TfmMain.chkShowCurChange(Sender: TObject);
begin
ed.OptShowCurLine:= chkShowCur.Checked;
ed.Update;
end;
procedure TfmMain.chkUnpriChange(Sender: TObject);
begin
ed.OptUnprintedVisible:= chkUnpri.Checked;
ed.Update;
end;
procedure TfmMain.chkFullHiliteChange(Sender: TObject);
begin
ed.OptShowFullHilite:= chkFullHilite.Checked;
ed.Update;
end;
procedure TfmMain.bOpenClick(Sender: TObject);
begin
with OpenDialog1 do
begin
Filename:= '';
InitialDir:= FDir;
if not Execute then exit;
DoOpenFile(Filename);
end;
end;
function TfmMain.GetComment: string;
var
an: TecSyntAnalyzer;
begin
Result:= '';
an:= adapter.Lexer;
if Assigned(an) then
Result:= an.LineComment;
end;
procedure TfmMain.DoCommentAct(Act: TATCommentAction);
var
Str: string;
begin
Str:= GetComment;
if Str='' then
Showmessage('No line comment defined for lexer')
else
Ed.DoCommentSelectionLines(Act, Str);
end;
procedure TfmMain.bCommentClick(Sender: TObject);
begin
DoCommentAct(cCommentAdd_AtNonespace_IfNone);
end;
procedure TfmMain.bExportClick(Sender: TObject);
var
fn: string;
begin
fn:= GetTempDir+DirectorySeparator+'_export.html';
DoEditorExportToHTML(Ed, fn, 'Export test',
'Courier New', 12, false,
clWhite, clMedGray);
if FileExists(fn) then
OpenDocument(fn);
end;
procedure TfmMain.AdapterParseDone(Sender: TObject);
begin
adapter.TreeFill(Tree);
EditorChangeCaretPos(Self);
end;
procedure TfmMain.AdapterParseBegin(Sender: TObject);
begin
Tree.Items.Clear;
end;
procedure TfmMain.bUncommentClick(Sender: TObject);
begin
DoCommentAct(cCommentRemove);
end;
procedure TfmMain.chkDynChange(Sender: TObject);
begin
adapter.DynamicHiliteEnabled:= chkDyn.Checked;
Ed.Update;
end;
procedure TfmMain.DoLexer(const aname: string);
begin
adapter.Lexer:= manager.FindAnalyzer(aname);
ed.Update;
end;
procedure TfmMain.edLexerChange(Sender: TObject);
begin
DoLexer(edLexer.Text);
end;
procedure TfmMain.filesClick(Sender: TObject);
var
fn: string;
begin
if files.Selected=nil then exit;
//while adapter.TreeBusy do Application.ProcessMessages;
fn:= files.GetPathFromItem(files.Selected);
if FileExistsUTF8(fn) then
DoOpenFile(fn);
end;
procedure TfmMain.EditClickGutter(Sender: TObject; ABand: integer; ALine: integer);
begin
if ABand=ed.GutterBandBm then
begin
if ed.Strings.LinesBm[ALine]<>0 then
ed.Strings.LinesBm[ALine]:= 0
else
ed.Strings.LinesBm[ALine]:= 1;
ed.Update;
end;
end;
procedure TfmMain.EditCalcStaple(Sender: TObject; ALine, AIndent: integer; var AColor: TColor);
const
nColors = 10;
cl: array[0..nColors-1] of TColor = (
clGray,
clBlue,
clRed,
clGreen,
clOlive,
clMaroon,
clLime,
clMoneyGreen,
clNavy,
clTeal
);
begin
AColor:= cl[AIndent div 2 mod nColors];
end;
end.

View File

@ -0,0 +1,80 @@
object fmLexerLib: TfmLexerLib
Left = 434
Height = 468
Top = 338
Width = 459
BorderIcons = [biSystemMenu]
Caption = 'Lexer library'
ClientHeight = 468
ClientWidth = 459
OnShow = FormShow
Position = poScreenCenter
ShowInTaskBar = stNever
LCLVersion = '1.5'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 29
Top = 433
Width = 447
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 2
ShowButtons = [pbClose]
ShowBevel = False
end
object ToolBar1: TToolBar
Left = 0
Height = 28
Top = 0
Width = 459
AutoSize = True
ButtonHeight = 28
Caption = 'ToolBar1'
EdgeInner = esNone
EdgeOuter = esNone
ShowCaptions = True
TabOrder = 0
object bProp: TToolButton
Left = 1
Top = 0
Caption = 'Config'
OnClick = bPropClick
end
object bDel: TToolButton
Left = 88
Top = 0
Caption = 'Delete'
OnClick = bDelClick
end
object bAdd: TToolButton
Left = 52
Top = 0
Caption = 'Add'
OnClick = bAddClick
end
end
object List: TCheckListBox
Left = 6
Height = 393
Top = 34
Width = 447
Align = alClient
BorderSpacing.Around = 6
ItemHeight = 0
OnClickCheck = ListClickCheck
TabOrder = 1
TopIndex = -1
end
object OpenDlg: TOpenDialog
Filter = 'Zip files|*.zip'
Options = [ofHideReadOnly, ofFileMustExist, ofEnableSizing, ofViewDetail]
left = 280
top = 360
end
end

View File

@ -0,0 +1,216 @@
(*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (c) Alexey Torgashin
*)
unit formlexerlib;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
StdCtrls, ComCtrls, CheckLst,
LCLIntf, LCLType, LCLProc,
ecSyntAnal,
formlexerprop, proc_lexer_install_zip,
math;
type
{ TfmLexerLib }
TfmLexerLib = class(TForm)
ButtonPanel1: TButtonPanel;
List: TCheckListBox;
OpenDlg: TOpenDialog;
ToolBar1: TToolBar;
bProp: TToolButton;
bDel: TToolButton;
bAdd: TToolButton;
procedure bAddClick(Sender: TObject);
procedure bDelClick(Sender: TObject);
procedure bPropClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ListClickCheck(Sender: TObject);
private
{ private declarations }
procedure UpdateList;
public
FManager: TecSyntaxManager;
FFontName: string;
FFontSize: integer;
FDirAcp: string;
{ public declarations }
end;
var
fmLexerLib: TfmLexerLib;
function DoShowDialogLexerLib(ALexerManager: TecSyntaxManager;
const ADirAcp: string;
const AFontName: string;
AFontSize: integer): boolean;
implementation
{$R *.lfm}
function DoShowDialogLexerLib(ALexerManager: TecSyntaxManager;
const ADirAcp: string; const AFontName: string; AFontSize: integer): boolean;
var
F: TfmLexerLib;
begin
F:= TfmLexerLib.Create(nil);
try
F.FManager:= ALexerManager;
F.FFontName:= AFontName;
F.FFontSize:= AFontSize;
F.FDirAcp:= ADirAcp;
F.ShowModal;
Result:= F.FManager.Modified;
finally
F.Free;
end;
end;
function IsLexerLinkDup(an: TecSyntAnalyzer; LinkN: integer): boolean;
var
i: integer;
begin
Result:= false;
for i:= 0 to LinkN-1 do
if an.SubAnalyzers[i].SyntAnalyzer=an.SubAnalyzers[LinkN].SyntAnalyzer then
begin
Result:= true;
exit
end;
end;
{ TfmLexerLib }
procedure TfmLexerLib.FormShow(Sender: TObject);
begin
UpdateList;
if List.Items.Count>0 then
List.ItemIndex:= 0;
end;
procedure TfmLexerLib.ListClickCheck(Sender: TObject);
var
an: TecSyntAnalyzer;
n: integer;
begin
n:= List.ItemIndex;
if n<0 then exit;
an:= List.Items.Objects[n] as TecSyntAnalyzer;
an.Internal:= not List.Checked[n];
FManager.Modified:= true;
end;
procedure TfmLexerLib.bPropClick(Sender: TObject);
var
an: TecSyntAnalyzer;
n: integer;
begin
n:= List.ItemIndex;
if n<0 then exit;
an:= List.Items.Objects[n] as TecSyntAnalyzer;
if DoShowDialogLexerProp(an, FFontName, FFontSize) then
begin
FManager.Modified:= true;
UpdateList;
List.ItemIndex:= n;
end;
end;
procedure TfmLexerLib.bDelClick(Sender: TObject);
var
an: TecSyntAnalyzer;
n: integer;
begin
n:= List.ItemIndex;
if n<0 then exit;
an:= List.Items.Objects[n] as TecSyntAnalyzer;
if Application.MessageBox(
PChar(Format('Delete lexer "%s"?', [an.LexerName])),
PChar(Caption),
MB_OKCANCEL or MB_ICONWARNING)=id_ok then
begin
an.Free;
FManager.Modified:= true;
UpdateList;
List.ItemIndex:= Min(n, List.Count-1);
end;
end;
procedure TfmLexerLib.bAddClick(Sender: TObject);
var
msg: string;
begin
OpenDlg.Filename:= '';
if not OpenDlg.Execute then exit;
if DoInstallLexerFromZip(OpenDlg.FileName, FManager, FDirAcp, msg) then
begin
UpdateList;
Application.MessageBox(
PChar('Installed:'#13+msg),
PChar(Caption), MB_OK or MB_ICONINFORMATION);
end;
end;
procedure TfmLexerLib.UpdateList;
var
sl: tstringlist;
an: TecSyntAnalyzer;
an_sub: TecSubAnalyzerRule;
links: string;
i, j: integer;
begin
List.Items.BeginUpdate;
List.Items.Clear;
sl:= tstringlist.create;
try
for i:= 0 to FManager.AnalyzerCount-1 do
begin
an:= FManager.Analyzers[i];
sl.AddObject(an.LexerName, an);
end;
sl.sort;
for i:= 0 to sl.count-1 do
begin
an:= sl.Objects[i] as TecSyntAnalyzer;
links:= '';
for j:= 0 to an.SubAnalyzers.Count-1 do
if not IsLexerLinkDup(an, j) then
begin
if links='' then
links:= 'links: '
else
links:= links+', ';
an_sub:= an.SubAnalyzers[j];
if an_sub<>nil then
if an_sub.SyntAnalyzer<>nil then
links:= links+an_sub.SyntAnalyzer.LexerName;
end;
if links<>'' then links:= ' ('+links+')';
List.Items.AddObject(sl[i]+links, an);
List.Checked[List.Count-1]:= not an.Internal;
end;
finally
sl.free;
end;
List.Items.EndUpdate;
end;
end.

View File

@ -0,0 +1,548 @@
object fmLexerProp: TfmLexerProp
Left = 218
Height = 566
Top = 300
Width = 623
BorderIcons = [biSystemMenu]
BorderStyle = bsDialog
Caption = 'Lexer properties'
ClientHeight = 566
ClientWidth = 623
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poScreenCenter
ShowInTaskBar = stNever
LCLVersion = '1.5'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 29
Top = 531
Width = 611
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 1
ShowButtons = [pbOK, pbCancel]
ShowBevel = False
end
object chkBorderT: TPageControl
Left = 0
Height = 525
Top = 0
Width = 623
ActivePage = TabSheetGen
Align = alClient
TabIndex = 0
TabOrder = 0
object TabSheetGen: TTabSheet
Caption = 'General'
ClientHeight = 494
ClientWidth = 619
object Label2: TLabel
Left = 6
Height = 17
Top = 0
Width = 607
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Lexer name:'
ParentColor = False
end
object edName: TEdit
Left = 6
Height = 27
Top = 20
Width = 607
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Top = 3
BorderSpacing.Right = 6
BorderSpacing.Bottom = 3
TabOrder = 0
end
object Label3: TLabel
Left = 6
Height = 17
Top = 50
Width = 607
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'File types:'
ParentColor = False
end
object edExt: TEdit
Left = 6
Height = 27
Top = 70
Width = 607
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Top = 3
BorderSpacing.Right = 6
BorderSpacing.Bottom = 3
TabOrder = 1
end
object Label4: TLabel
Left = 6
Height = 17
Top = 100
Width = 607
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Line-comment string:'
ParentColor = False
end
object edLineCmt: TEdit
Left = 6
Height = 27
Top = 120
Width = 607
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Top = 3
BorderSpacing.Right = 6
BorderSpacing.Bottom = 3
TabOrder = 2
end
object Label1: TLabel
Left = 6
Height = 17
Top = 150
Width = 607
Align = alTop
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Sample text:'
ParentColor = False
end
object edSample: TATSynEdit
Left = 6
Height = 315
Top = 173
Width = 607
Align = alClient
BorderSpacing.Around = 6
BorderStyle = bsSingle
Font.Height = -12
Font.Name = 'Courier New'
ParentFont = False
TabOrder = 3
TabStop = True
CursorText = crIBeam
CursorBm = crHandPoint
Colors.TextFont = clBlack
Colors.TextBG = clWhite
Colors.TextDisabledFont = clMedGray
Colors.TextDisabledBG = clSilver
Colors.TextSelFont = clHighlightText
Colors.TextSelBG = clHighlight
Colors.Caret = clBlack
Colors.GutterFont = clGray
Colors.GutterBG = 14737632
Colors.GutterCaretBG = 13158600
Colors.GutterPlusBorder = clGray
Colors.GutterPlusBG = 16053492
Colors.GutterFoldLine = clGray
Colors.GutterFoldBG = 13158600
Colors.GutterSeparatorBG = clBlack
Colors.CurrentLineBG = 14741744
Colors.MarginRight = clSilver
Colors.MarginCaret = clLime
Colors.MarginUser = clYellow
Colors.IndentVertLines = clMedGray
Colors.BookmarkBG = clMoneyGreen
Colors.RulerFont = clGray
Colors.RulerBG = 14737632
Colors.CollapseLine = 10510432
Colors.CollapseMarkFont = 14712960
Colors.CollapseMarkBG = clCream
Colors.UnprintedFont = 5263600
Colors.UnprintedBG = 14737632
Colors.UnprintedHexFont = clMedGray
Colors.MinimapBorder = clSilver
Colors.MinimapSelBG = 15658734
Colors.StateChanged = 61680
Colors.StateAdded = 2146336
Colors.StateSaved = clMedGray
Colors.BlockStaple = clMedGray
Colors.BlockSepLine = clMedGray
Colors.LockedBG = 14737632
Colors.TextHintFont = clGray
Colors.ComboboxArrow = clGray
Colors.ComboboxArrowBG = 15790320
WantTabs = True
OptTabSpaces = False
OptTabSize = 8
OptFoldStyle = cFoldHereWithTruncatedText
OptTextLocked = 'wait...'
OptTextHintFontStyle = [fsItalic]
OptTextHintCenter = False
OptTextOffsetTop = 0
OptTextOffsetFromLine = 1
OptAutoIndent = True
OptAutoIndentKind = cIndentAsIs
OptCopyLinesIfNoSel = True
OptCutLinesIfNoSel = False
OptLastLineOnTop = False
OptOverwriteSel = True
OptOverwriteAllowedOnPaste = False
OptShowStapleStyle = cLineStyleSolid
OptShowStapleIndent = -1
OptShowStapleWidthPercent = 100
OptShowFullSel = False
OptShowFullHilite = True
OptShowCurLine = False
OptShowCurLineMinimal = True
OptShowScrollHint = False
OptShowCurColumn = False
OptCaretManyAllowed = True
OptCaretVirtual = True
OptCaretShape = cCaretShapeVertPixels1
OptCaretShapeOvr = cCaretShapeFull
OptCaretShapeRO = cCaretShapeHorzPixels1
OptCaretBlinkTime = 600
OptCaretBlinkEnabled = True
OptCaretStopUnfocused = True
OptCaretPreferLeftSide = True
OptGutterVisible = True
OptGutterPlusSize = 4
OptGutterShowFoldAlways = True
OptGutterShowFoldLines = True
OptGutterShowFoldLinesAll = False
OptRulerVisible = False
OptRulerSize = 20
OptRulerFontSize = 8
OptRulerMarkSizeSmall = 3
OptRulerMarkSizeBig = 7
OptRulerTextIndent = 0
OptMinimapVisible = False
OptMinimapCharWidth = 0
OptMinimapShowSelBorder = False
OptMinimapShowSelAlways = True
OptMicromapVisible = False
OptMicromapWidth = 30
OptCharSpacingX = 0
OptCharSpacingY = 1
OptWrapMode = cWrapOff
OptWrapIndented = True
OptMarginRight = 80
OptNumbersAutosize = True
OptNumbersAlignment = taRightJustify
OptNumbersFontSize = 0
OptNumbersStyle = cNumbersNone
OptNumbersShowFirst = True
OptNumbersShowCarets = False
OptNumbersSkippedChar = '.'
OptNumbersIndentLeft = 5
OptNumbersIndentRight = 5
OptUnprintedVisible = False
OptUnprintedSpaces = True
OptUnprintedEnds = True
OptUnprintedEndsDetails = True
OptUnprintedReplaceSpec = True
OptMouseEnableNormalSelection = True
OptMouseEnableColumnSelection = True
OptMouseDownForPopup = False
OptMouseHideCursorOnType = False
OptMouse2ClickSelectsLine = False
OptMouse3ClickSelectsLine = True
OptMouse2ClickDragSelectsWords = True
OptMouseDragDrop = True
OptMouseNiceScroll = True
OptMouseRightClickMovesCaret = False
OptMouseGutterClickSelectsLine = True
OptKeyBackspaceUnindent = True
OptKeyPageKeepsRelativePos = True
OptKeyUpDownNavigateWrapped = True
OptKeyUpDownKeepColumn = True
OptKeyHomeEndNavigateWrapped = True
OptKeyPageUpDownSize = cPageSizeFullMinus1
OptKeyLeftRightSwapSel = True
OptKeyLeftRightSwapSelAndSelect = False
OptKeyHomeToNonSpace = True
OptKeyEndToNonSpace = True
OptKeyTabIndents = True
OptIndentSize = 2
OptIndentKeepsAlign = True
OptShowIndentLines = True
OptShowGutterCaretBG = True
OptAllowScrollbarVert = True
OptAllowScrollbarHorz = True
OptAllowZooming = True
OptAllowReadOnly = True
OptUndoLimit = 5000
OptUndoGrouped = True
OptUndoAfterSave = True
OptSavingForceFinalEol = False
OptSavingTrimSpaces = False
end
end
object TabSheetStyles: TTabSheet
Caption = 'Styles'
ClientHeight = 494
ClientWidth = 619
object ListStyles: TListBox
Left = 6
Height = 482
Top = 6
Width = 176
Align = alLeft
BorderSpacing.Around = 6
ItemHeight = 0
OnClick = ListStylesClick
ScrollWidth = 174
TabOrder = 0
TopIndex = -1
end
object Panel1: TPanel
Left = 188
Height = 482
Top = 6
Width = 425
Align = alClient
BorderSpacing.Around = 6
BevelOuter = bvNone
ClientHeight = 482
ClientWidth = 425
TabOrder = 1
object edColorFont: TColorBox
Left = 208
Height = 31
Top = 65
Width = 190
ColorRectWidth = 22
NoneColorColor = clNone
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
DropDownCount = 20
ItemHeight = 0
TabOrder = 2
end
object edColorBG: TColorBox
Left = 8
Height = 31
Top = 65
Width = 190
ColorRectWidth = 22
NoneColorColor = clNone
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
DropDownCount = 20
ItemHeight = 0
TabOrder = 1
end
object Label5: TLabel
Left = 208
Height = 17
Top = 49
Width = 91
Caption = 'Color of font:'
ParentColor = False
end
object edStyleType: TComboBox
Left = 8
Height = 31
Top = 18
Width = 190
ItemHeight = 0
Items.Strings = (
'Misc font (not supp.)'
'Colors, styles'
'Colors'
'Color BG only'
)
OnChange = edStyleTypeChange
Style = csDropDownList
TabOrder = 0
end
object Label6: TLabel
Left = 8
Height = 17
Top = 0
Width = 70
Caption = 'Style type:'
ParentColor = False
end
object Label7: TLabel
Left = 8
Height = 17
Top = 48
Width = 81
Caption = 'Color of BG:'
ParentColor = False
end
object Label8: TLabel
Left = 8
Height = 17
Top = 104
Width = 77
Caption = 'Font styles:'
ParentColor = False
end
object chkBold: TCheckBox
Left = 8
Height = 24
Top = 120
Width = 57
Caption = 'Bold'
TabOrder = 3
end
object chkItalic: TCheckBox
Left = 88
Height = 24
Top = 120
Width = 59
Caption = 'Italic'
TabOrder = 4
end
object chkStrik: TCheckBox
Left = 280
Height = 24
Top = 120
Width = 83
Caption = 'Stikeout'
TabOrder = 6
end
object chkUnder: TCheckBox
Left = 168
Height = 24
Top = 120
Width = 91
Caption = 'Underline'
TabOrder = 5
end
object bApplyStl: TButton
Left = 8
Height = 29
Top = 304
Width = 143
AutoSize = True
Caption = 'Apply style changes'
OnClick = bApplyStlClick
TabOrder = 12
end
object Label9: TLabel
Left = 8
Height = 17
Top = 152
Width = 58
Caption = 'Borders:'
ParentColor = False
end
object cbBorderL: TComboBox
Left = 8
Height = 31
Top = 184
Width = 100
DropDownCount = 20
ItemHeight = 0
Style = csDropDownList
TabOrder = 7
end
object cbBorderT: TComboBox
Left = 112
Height = 31
Top = 184
Width = 100
DropDownCount = 20
ItemHeight = 0
Style = csDropDownList
TabOrder = 8
end
object cbBorderR: TComboBox
Left = 216
Height = 31
Top = 184
Width = 100
DropDownCount = 20
ItemHeight = 0
Style = csDropDownList
TabOrder = 9
end
object cbBorderB: TComboBox
Left = 320
Height = 31
Top = 184
Width = 100
DropDownCount = 20
ItemHeight = 0
Style = csDropDownList
TabOrder = 10
end
object Label10: TLabel
Left = 8
Height = 17
Top = 168
Width = 28
Caption = 'Left'
ParentColor = False
end
object Label11: TLabel
Left = 112
Height = 17
Top = 168
Width = 25
Caption = 'Top'
ParentColor = False
end
object Label12: TLabel
Left = 216
Height = 17
Top = 168
Width = 35
Caption = 'Right'
ParentColor = False
end
object Label13: TLabel
Left = 320
Height = 17
Top = 168
Width = 52
Caption = 'Bottom'
ParentColor = False
end
object Label14: TLabel
Left = 8
Height = 17
Top = 216
Width = 109
Caption = 'Color of border:'
ParentColor = False
end
object edColorBorder: TColorBox
Left = 8
Height = 31
Top = 232
Width = 190
ColorRectWidth = 22
NoneColorColor = clNone
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
DropDownCount = 20
ItemHeight = 0
TabOrder = 11
end
end
end
object TabSheetNotes: TTabSheet
Caption = 'Notes'
ClientHeight = 494
ClientWidth = 619
object edNotes: TMemo
Left = 6
Height = 482
Top = 6
Width = 607
Align = alClient
BorderSpacing.Around = 6
ScrollBars = ssBoth
TabOrder = 0
end
end
end
end

View File

@ -0,0 +1,272 @@
(*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (c) Alexey Torgashin
*)
unit formlexerprop;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Graphics, FileUtil, Forms, Controls, StdCtrls,
Dialogs, ButtonPanel, ComCtrls, ExtCtrls, ColorBox,
ecSyntAnal,
ATSynEdit,
ATSynEdit_Adapter_EControl;
type
{ TfmLexerProp }
TfmLexerProp = class(TForm)
bApplyStl: TButton;
ButtonPanel1: TButtonPanel;
chkBold: TCheckBox;
chkItalic: TCheckBox;
chkStrik: TCheckBox;
chkUnder: TCheckBox;
cbBorderL: TComboBox;
cbBorderT: TComboBox;
cbBorderR: TComboBox;
cbBorderB: TComboBox;
edColorFont: TColorBox;
edColorBG: TColorBox;
edColorBorder: TColorBox;
edStyleType: TComboBox;
edExt: TEdit;
edLineCmt: TEdit;
edName: TEdit;
edSample: TATSynEdit;
Label1: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
edNotes: TMemo;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
ListStyles: TListBox;
chkBorderT: TPageControl;
Panel1: TPanel;
TabSheetGen: TTabSheet;
TabSheetNotes: TTabSheet;
TabSheetStyles: TTabSheet;
procedure bApplyStlClick(Sender: TObject);
procedure edStyleTypeChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ListStylesClick(Sender: TObject);
private
{ private declarations }
FAn: TecSyntAnalyzer;
procedure InitBorder(cb: TCombobox);
procedure UpdateStl;
procedure UpdateStlEn(fmt: TecFormatType);
procedure UpdateStlFromList;
procedure UpdateStlToList;
public
{ public declarations }
Adapter: TATAdapterEControl;
end;
var
fmLexerProp: TfmLexerProp;
function DoShowDialogLexerProp(an: TecSyntAnalyzer;
AFontName: string; AFontSize: integer): boolean;
implementation
{$R *.lfm}
{ TfmLexerProp }
procedure TfmLexerProp.FormCreate(Sender: TObject);
begin
Adapter:= TATAdapterEControl.Create(Self);
edSample.AdapterHilite:= Adapter;
InitBorder(cbBorderL);
InitBorder(cbBorderT);
InitBorder(cbBorderR);
InitBorder(cbBorderB);
end;
procedure TfmLexerProp.bApplyStlClick(Sender: TObject);
begin
UpdateStlToList;
end;
procedure TfmLexerProp.edStyleTypeChange(Sender: TObject);
begin
UpdateStlEn(TecFormatType(edStyleType.ItemIndex));
end;
procedure TfmLexerProp.FormDestroy(Sender: TObject);
begin
edSample.AdapterHilite:= nil;
FreeAndNil(Adapter);
end;
procedure TfmLexerProp.ListStylesClick(Sender: TObject);
begin
UpdateStlFromList;
end;
procedure TfmLexerProp.UpdateStl;
var
i: integer;
fmt: TecSyntaxFormat;
begin
ListStyles.Items.Clear;
for i:= 0 to FAn.Formats.Count-1 do
begin
fmt:= FAn.Formats[i];
ListStyles.Items.Add(fmt.DisplayName);
end;
if ListStyles.Count>0 then
ListStyles.ItemIndex:= 0;
UpdateStlFromList;
end;
procedure TfmLexerProp.UpdateStlFromList;
var
n: integer;
fmt: TecSyntaxFormat;
begin
n:= ListStyles.ItemIndex;
if n<0 then exit;
fmt:= FAn.Formats[n];
UpdateStlEn(fmt.FormatType);
edStyleType.ItemIndex:= Ord(fmt.FormatType);
edColorFont.Selected:= fmt.Font.Color;
edColorBG.Selected:= fmt.BgColor;
edColorBorder.Selected:= fmt.BorderColorBottom;
chkBold.Checked:= fsBold in fmt.Font.Style;
chkItalic.Checked:= fsItalic in fmt.Font.Style;
chkUnder.Checked:= fsUnderline in fmt.Font.Style;
chkStrik.Checked:= fsStrikeOut in fmt.Font.Style;
cbBorderL.ItemIndex:= Ord(fmt.BorderTypeLeft);
cbBorderT.ItemIndex:= Ord(fmt.BorderTypeTop);
cbBorderR.ItemIndex:= Ord(fmt.BorderTypeRight);
cbBorderB.ItemIndex:= Ord(fmt.BorderTypeBottom);
end;
procedure TfmLexerProp.UpdateStlEn(fmt: TecFormatType);
begin
edColorFont.Enabled:= fmt in [ftCustomFont, ftFontAttr, ftColor];
edColorBG.Enabled:= true;
chkBold.Enabled:= fmt in [ftCustomFont, ftFontAttr];
chkItalic.Enabled:= chkBold.Enabled;
chkUnder.Enabled:= chkBold.Enabled;
chkStrik.Enabled:= chkBold.Enabled;
end;
procedure TfmLexerProp.UpdateStlToList;
var
n: integer;
fmt: TecSyntaxFormat;
fs: TFontStyles;
begin
n:= ListStyles.ItemIndex;
if n<0 then exit;
fmt:= FAn.Formats[n];
fmt.FormatType:= TecFormatType(edStyleType.ItemIndex);
fmt.Font.Color:= edColorFont.Selected;
fmt.BgColor:= edColorBG.Selected;
fmt.BorderColorBottom:= edColorBorder.Selected;
fs:= [];
if chkBold.Checked then Include(fs, fsBold);
if chkItalic.Checked then Include(fs, fsItalic);
if chkUnder.Checked then Include(fs, fsUnderline);
if chkStrik.Checked then Include(fs, fsStrikeOut);
fmt.Font.Style:= fs;
fmt.BorderTypeLeft:= TecBorderLineType(cbBorderL.ItemIndex);
fmt.BorderTypeTop:= TecBorderLineType(cbBorderT.ItemIndex);
fmt.BorderTypeRight:= TecBorderLineType(cbBorderR.ItemIndex);
fmt.BorderTypeBottom:= TecBorderLineType(cbBorderB.ItemIndex);
end;
function DoShowDialogLexerProp(an: TecSyntAnalyzer; AFontName: string;
AFontSize: integer): boolean;
var
F: TfmLexerProp;
begin
Result:= false;
if an=nil then exit;
F:= TfmLexerProp.Create(nil);
try
F.FAn:= an;
F.edName.Text:= an.LexerName;
F.edExt.Text:= an.Extentions;
F.edLineCmt.Text:= an.LineComment;
F.edNotes.Lines.AddStrings(an.Notes);
F.UpdateStl;
F.edSample.Font.Name:= AFontName;
F.edSample.Font.Size:= AFontSize;
F.edSample.Gutter[F.edSample.GutterBandBm].Visible:= false;
F.edSample.Gutter[F.edSample.GutterBandNum].Visible:= false;
F.Adapter.Lexer:= an;
if Assigned(an.SampleText) then
begin
F.edSample.Strings.LoadFromString(an.SampleText.Text);
F.edSample.Update(true);
F.edSample.DoEventChange;
end;
if F.ShowModal<>mrOk then exit;
if Trim(F.edName.Text)='' then exit;
Result:= true;
an.LexerName:= F.edName.Text;
an.Extentions:= F.edExt.Text;
an.LineComment:= F.edLineCmt.Text;
an.Notes.Clear;
an.Notes.AddStrings(F.edNotes.Lines);
finally
F.Free;
end;
end;
procedure TfmLexerProp.InitBorder(cb: TCombobox);
begin
with cb.Items do
begin
Clear;
Add('none');
Add('solid');
Add('dash');
Add('dot');
Add('dash dot');
Add('dash dot dot');
Add('solid2');
Add('solid3');
Add('wave');
Add('double');
end;
end;
end.

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="atsynedit_package"/>
</Item1>
<Item2>
<PackageName Value="econtrol_package"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="4">
<Unit0>
<Filename Value="lex_lib_demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unmain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
<Unit2>
<Filename Value="formlexerlib.pas"/>
<IsPartOfProject Value="True"/>
<HasResources Value="True"/>
</Unit2>
<Unit3>
<Filename Value="formlexerprop.pas"/>
<IsPartOfProject Value="True"/>
<HasResources Value="True"/>
</Unit3>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="lex_lib_demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../../atsynedit"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,22 @@
program lex_lib_demo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, unmain
{ you can add units after this };
{$R *.res}
begin
Application.Title:='Demo';
RequireDerivedFormResource:=True;
Application.Initialize;
Application.CreateForm(TfmMain, fmMain);
Application.Run;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,167 @@
unit proc_lexer_install_zip;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, FileUtil,
ecSyntAnal;
function DoInstallLexerFromZip(const fn_zip: string;
Manager: TecSyntaxManager;
const dir_acp: string;
out s_installed: string): boolean;
var
cInstallLexerZipTitle: string = 'Install zip';
implementation
uses
LCLIntf, LCLProc, LCLType,
IniFiles,
Zipper;
function MsgBox(const msg: string; flags: integer): integer;
begin
Result:= Application.MessageBox(PChar(msg), PChar(cInstallLexerZipTitle), flags);
end;
function DoInstallLexerFromZip(const fn_zip: string;
Manager: TecSyntaxManager;
const dir_acp: string;
out s_installed: string): boolean;
var
unzip: TUnZipper;
list: TStringlist;
dir, fn_inf, fn_lexer, fn_acp: string;
s_title, s_type, s_lexer: string;
an, an_sub: TecSyntAnalyzer;
i_lexer, i_sub: integer;
begin
Result:= false;
dir:= GetTempDir(false)+DirectorySeparator+'zip_lexer';
if not DirectoryExists(dir) then
CreateDir(dir);
if not DirectoryExists(dir) then
begin
MsgBox('Cannot create dir:'#13+dir, mb_ok or mb_iconerror);
exit
end;
fn_inf:= dir+DirectorySeparator+'install.inf';
if FileExists(fn_inf) then
DeleteFile(fn_inf);
unzip:= TUnZipper.Create;
try
unzip.FileName:= fn_zip;
unzip.OutputPath:= dir;
unzip.Examine;
list:= TStringlist.create;
try
list.Add('install.inf');
unzip.UnZipFiles(list);
finally
FreeAndNil(list);
end;
if not FileExists(fn_inf) then
begin
MsgBox('Cannot find install.inf in zip', mb_ok or mb_iconerror);
exit
end;
unzip.Files.Clear;
unzip.UnZipAllFiles;
finally
unzip.Free;
end;
with TIniFile.Create(fn_inf) do
try
s_title:= ReadString('info', 'title', '');
s_type:= ReadString('info', 'type', '');
//s_subdir:= ReadString('info', 'subdir', '');
finally
Free
end;
if (s_title='') or (s_type='') then
begin
MsgBox('Incorrect install.inf in zip', mb_ok or mb_iconerror);
exit
end;
if (s_type<>'lexer') then
begin
MsgBox('Unsupported addon type: '+s_type, mb_ok or mb_iconerror);
exit
end;
if MsgBox('This package contains:'#13#13+
'title: '+s_title+#13+
'type: '+s_type+#13#13+
'Do you want to install it?',
MB_OKCANCEL or MB_ICONQUESTION)<>id_ok then exit;
s_installed:= '';
with TIniFile.Create(fn_inf) do
try
for i_lexer:= 1 to 20 do
begin
s_lexer:= ReadString('lexer'+Inttostr(i_lexer), 'file', '');
if s_lexer='' then Break;
//lexer file
fn_lexer:= ExtractFileDir(fn_inf)+DirectorySeparator+s_lexer+'.lcf';
if not FileExists(fn_lexer) then
begin
MsgBox('Cannot find lexer file: '+fn_lexer, mb_ok or mb_iconerror);
exit
end;
fn_acp:= ExtractFileDir(fn_inf)+DirectorySeparator+s_lexer+'.acp';
if FileExists(fn_acp) then
if dir_acp<>'' then
CopyFile(fn_acp, dir_acp+DirectorySeparator+s_lexer+'.acp');
an:= Manager.FindAnalyzer(s_lexer);
if an=nil then
an:= Manager.AddAnalyzer;
an.LoadFromFile(fn_lexer);
s_installed:= s_installed+s_lexer+#13;
//links
for i_sub:= 0 to an.SubAnalyzers.Count-1 do
begin
s_lexer:= ReadString('lexer'+Inttostr(i_lexer), 'link'+Inttostr(i_sub+1), '');
if s_lexer='' then Continue;
if s_lexer='Style sheets' then s_lexer:= 'CSS';
if s_lexer='Assembler' then s_lexer:= 'Assembly';
an_sub:= Manager.FindAnalyzer(s_lexer);
if an_sub<>nil then
begin
an.SubAnalyzers.Items[i_sub].SyntAnalyzer:= an_sub;
//MsgBox('Linked lexer "'+an.LexerName+'" to "'+s_lexer+'"', mb_ok or MB_ICONINFORMATION);
end
else
begin
MsgBox('Cannot find linked sublexer in library: '+s_lexer, MB_OK or MB_ICONWARNING);
Continue;
end;
end;
end;
finally
Free
end;
Result:= true;
end;
end.

View File

@ -0,0 +1,30 @@
object fmMain: TfmMain
Left = 428
Height = 231
Top = 408
Width = 454
BorderStyle = bsDialog
Caption = 'Demo'
ClientHeight = 231
ClientWidth = 454
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.5'
object bShow: TButton
Left = 144
Height = 40
Top = 80
Width = 152
Caption = 'Lexer lib dialog'
OnClick = bShowClick
TabOrder = 0
end
object Label1: TLabel
Left = 8
Height = 17
Top = 184
Width = 45
Caption = 'Label1'
ParentColor = False
end
end

View File

@ -0,0 +1,76 @@
unit unmain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
LclIntf, LclProc, LclType,
ecSyntAnal,
formlexerlib;
type
{ TfmMain }
TfmMain = class(TForm)
bShow: TButton;
Label1: TLabel;
procedure bShowClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure UpdStatus;
{ private declarations }
public
{ public declarations }
end;
var
fmMain: TfmMain;
implementation
{$R *.lfm}
var
Manager: TecSyntaxManager;
{ TfmMain }
procedure TfmMain.bShowClick(Sender: TObject);
var
dirAcp: string;
begin
dirAcp:= ExtractFileDir(Application.ExeName)+DirectorySeparator+'acp';
CreateDir(dirAcp);
DoShowDialogLexerLib(Manager, dirAcp, 'Courier new', 9);
if Manager.Modified then
begin
UpdStatus;
Manager.Modified:= false;
if Application.MessageBox('Lib was modified. Save file?', 'Demo',
MB_OKCANCEL or MB_ICONQUESTION)=id_ok then
Manager.SaveToFile(Manager.FileName);
end;
end;
procedure TfmMain.FormCreate(Sender: TObject);
var
fn: string;
begin
fn:= ExtractFileDir(Application.ExeName)+DirectorySeparator+
'lexlib'+DirectorySeparator+'small.lxl';
Manager:= TecSyntaxManager.Create(Self);
Manager.LoadFromFile(fn);
UpdStatus;
end;
procedure TfmMain.UpdStatus;
begin
Label1.Caption:= Format('library "%s" has %d lexers',
[Extractfilename(Manager.FileName), Manager.AnalyzerCount]);
end;
end.

View File

@ -0,0 +1,266 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<AutoCreateForms Value="False"/>
<Title Value="Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="37">
<Unit0>
<Filename Value="demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="formmain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
<Unit2>
<Filename Value="formkey.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmCmd"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit2>
<Unit3>
<Filename Value="..\..\atsynedit\atstrings_editing.inc"/>
<IsPartOfProject Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\..\atsynedit\atsynedit_carets.inc"/>
<IsPartOfProject Value="True"/>
</Unit4>
<Unit5>
<Filename Value="..\..\atsynedit\atsynedit_cmd_clipboard.inc"/>
<IsPartOfProject Value="True"/>
</Unit5>
<Unit6>
<Filename Value="..\..\atsynedit\atsynedit_cmd_editing.inc"/>
<IsPartOfProject Value="True"/>
</Unit6>
<Unit7>
<Filename Value="..\..\atsynedit\atsynedit_cmd_handler.inc"/>
<IsPartOfProject Value="True"/>
</Unit7>
<Unit8>
<Filename Value="..\..\atsynedit\atsynedit_cmd_keys.inc"/>
<IsPartOfProject Value="True"/>
</Unit8>
<Unit9>
<Filename Value="..\..\atsynedit\atsynedit_cmd_misc.inc"/>
<IsPartOfProject Value="True"/>
</Unit9>
<Unit10>
<Filename Value="..\..\atsynedit\atsynedit_proc.inc"/>
<IsPartOfProject Value="True"/>
</Unit10>
<Unit11>
<Filename Value="..\..\atsynedit\atsynedit_canvasproc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_CanvasProc"/>
</Unit11>
<Unit12>
<Filename Value="..\..\atsynedit\atsynedit_keymap.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Keymap"/>
</Unit12>
<Unit13>
<Filename Value="..\..\atsynedit\atstringproc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATStringProc"/>
</Unit13>
<Unit14>
<Filename Value="..\..\atsynedit\atstringproc_wordjump.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATStringProc_WordJump"/>
</Unit14>
<Unit15>
<Filename Value="..\..\atsynedit\atstrings.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATStrings"/>
</Unit15>
<Unit16>
<Filename Value="..\..\atsynedit\atsynedit_carets.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Carets"/>
</Unit16>
<Unit17>
<Filename Value="..\..\atsynedit\atsynedit.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit"/>
</Unit17>
<Unit18>
<Filename Value="..\..\atsynedit\atsynedit_commands.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Commands"/>
</Unit18>
<Unit19>
<Filename Value="..\..\atsynedit\atsynedit_keymap_init.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Keymap_Init"/>
</Unit19>
<Unit20>
<Filename Value="..\..\atsynedit\atsynedit_hilite.inc"/>
<IsPartOfProject Value="True"/>
</Unit20>
<Unit21>
<Filename Value="..\..\atsynedit\atsynedit_sel.inc"/>
<IsPartOfProject Value="True"/>
</Unit21>
<Unit22>
<Filename Value="..\..\atsynedit\atsynedit_gutter.pas"/>
<IsPartOfProject Value="True"/>
</Unit22>
<Unit23>
<Filename Value="formopt.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmOpt"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit23>
<Unit24>
<Filename Value="..\..\atsynedit\atstrings_load.inc"/>
<IsPartOfProject Value="True"/>
</Unit24>
<Unit25>
<Filename Value="..\..\atsynedit\atstrings_undo.pas"/>
<IsPartOfProject Value="True"/>
</Unit25>
<Unit26>
<Filename Value="..\..\atsynedit\atstrings_save.inc"/>
<IsPartOfProject Value="True"/>
</Unit26>
<Unit27>
<Filename Value="..\..\atsynedit\atsynedit_wrapinfo.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_WrapInfo"/>
</Unit27>
<Unit28>
<Filename Value="..\..\atsynedit\atsynedit_cmd_sel.inc"/>
<IsPartOfProject Value="True"/>
</Unit28>
<Unit29>
<Filename Value="..\..\atsynedit\atsynedit_debug.inc"/>
<IsPartOfProject Value="True"/>
</Unit29>
<Unit30>
<Filename Value="..\..\atsynedit\atsynedit_edits.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Edits"/>
</Unit30>
<Unit31>
<Filename Value="formcombo.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmCombo"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit31>
<Unit32>
<Filename Value="..\..\atsynedit\atsynedit_ranges.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Ranges"/>
</Unit32>
<Unit33>
<Filename Value="..\..\atsynedit\atsynedit_fold.inc"/>
<IsPartOfProject Value="True"/>
</Unit33>
<Unit34>
<Filename Value="..\..\atsynedit\atsynedit_adapters.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Adapters"/>
</Unit34>
<Unit35>
<Filename Value="formfind.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmFind"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit35>
<Unit36>
<Filename Value="..\..\atsynedit\atsynedit_export_html.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit_Export_HTML"/>
</Unit36>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);..\..\comp\atsynedit;..\..\atsynedit"/>
<OtherUnitFiles Value="..\..\atsynedit;..\..\proc_lexer"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="4">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
<Item4>
<Name Value="ERegExpr"/>
</Item4>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,41 @@
program demo;
{$mode objfpc}{$H+}
uses
//heaptrc,
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms,
atsynedit_canvasproc,
atsynedit_keymap,
atstringproc,
atstringproc_wordjump,
atstrings,
atstrings_undo,
atsynedit_carets,
atsynedit,
atsynedit_gutter,
atsynedit_commands,
atsynedit_keymap_init,
atsynedit_wrapinfo,
atsynedit_edits,
atsynedit_ranges, ATSynEdit_Adapters,
formmain,
formkey,
formopt,
formcombo, formfind, atsynedit_export_html;
{$R *.res}
begin
Application.Title:= 'Demo';
RequireDerivedFormResource:= True;
Application.Initialize;
Application.CreateForm(TfmMain, fmMain);
Application.CreateForm(TfmOpt, fmOpt);
Application.Run;
end.

View File

@ -0,0 +1,21 @@
program demo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, formmain,
ATSynEdit, ATStrings, ATStringProc, ATCanvasProc;
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,58 @@
object fmCombo: TfmCombo
Left = 426
Height = 240
Top = 370
Width = 397
Caption = 'Combo'
ClientHeight = 240
ClientWidth = 397
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.5'
object Panel1: TPanel
Left = 16
Height = 49
Top = 32
Width = 335
BevelOuter = bvNone
ClientHeight = 49
ClientWidth = 335
TabOrder = 0
object Label1: TLabel
Left = 0
Height = 17
Top = 4
Width = 97
Caption = 'ATComboEdit:'
ParentColor = False
end
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 29
Top = 205
Width = 385
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 1
ShowButtons = [pbClose]
ShowBevel = False
end
object chkEnabled: TCheckBox
Left = 17
Height = 24
Top = 174
Width = 80
Caption = 'Enabled'
Checked = True
OnChange = chkEnabledChange
State = cbChecked
TabOrder = 2
end
end

View File

@ -0,0 +1,81 @@
unit formcombo;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, ButtonPanel, ATSynEdit_Edits;
type
{ TfmCombo }
TfmCombo = class(TForm)
ButtonPanel1: TButtonPanel;
chkEnabled: TCheckBox;
Label1: TLabel;
Panel1: TPanel;
procedure chkEnabledChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure ComboCommand(Sender: TObject; ACmd: integer; const AText: string; var AHandled: boolean);
{ private declarations }
public
{ public declarations }
ed: TATComboEdit;
end;
var
fmCombo: TfmCombo;
implementation
uses ATSynEdit_Commands;
{$R *.lfm}
{ TfmCombo }
procedure TfmCombo.FormCreate(Sender: TObject);
begin
ed:= TATComboEdit.Create(Self);
ed.Parent:= Panel1;
ed.Align:= alBottom;
ed.OnCommand:= @ComboCommand;
ed.Text:= 'Test';
ed.OptTextHint:= '(empty)';
end;
procedure TfmCombo.chkEnabledChange(Sender: TObject);
begin
ed.Enabled:= chkEnabled.Checked;
end;
procedure TfmCombo.ComboCommand(Sender: TObject; ACmd: integer;
const AText: string; var AHandled: boolean);
var
s: string;
n: integer;
begin
if ACmd=cCommand_KeyEnter then
begin
with ed do
begin
s:= UTF8Encode(Trim(Text));
ShowMessage('Enter: '+s);
Text:= '';
DoCaretSingle(0, 0);
n:= Items.IndexOf(s);
if n>=0 then Items.Delete(n);
Items.Insert(0, s);
end;
AHandled:= true;
end;
end;
end.

View File

@ -0,0 +1,149 @@
object fmFind: TfmFind
Left = 521
Height = 233
Top = 265
Width = 489
BorderStyle = bsDialog
Caption = 'Find/Replace'
ClientHeight = 233
ClientWidth = 489
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.5'
object bFind: TButton
Left = 376
Height = 25
Top = 48
Width = 99
Caption = 'find'
ModalResult = 1
TabOrder = 9
end
object bCancel: TButton
Left = 376
Height = 25
Top = 144
Width = 99
Cancel = True
Caption = 'cancel'
ModalResult = 2
TabOrder = 14
end
object Label1: TLabel
Left = 9
Height = 17
Top = 8
Width = 66
Caption = 'find what:'
ParentColor = False
end
object edFind: TEdit
Left = 9
Height = 27
Top = 32
Width = 359
TabOrder = 0
end
object chkRegex: TCheckBox
Left = 9
Height = 24
Top = 128
Width = 64
Caption = 'regex'
OnChange = chkRegexChange
TabOrder = 3
end
object chkBack: TCheckBox
Left = 9
Height = 24
Top = 200
Width = 92
Caption = 'backward'
TabOrder = 6
end
object chkCase: TCheckBox
Left = 9
Height = 24
Top = 152
Width = 118
Caption = 'case sensitive'
TabOrder = 4
end
object chkWords: TCheckBox
Left = 9
Height = 24
Top = 176
Width = 142
Caption = 'whole words only'
TabOrder = 5
end
object edRep: TEdit
Left = 9
Height = 27
Top = 88
Width = 359
TabOrder = 2
end
object chkRep: TCheckBox
Left = 9
Height = 24
Top = 64
Width = 112
Caption = 'replace with:'
OnChange = chkRepChange
TabOrder = 1
end
object bRep: TButton
Left = 376
Height = 25
Top = 16
Width = 99
Caption = 'replace'
Default = True
ModalResult = 6
TabOrder = 10
end
object bRepAll: TButton
Left = 376
Height = 25
Top = 48
Width = 99
Caption = 'replace all'
ModalResult = 10
TabOrder = 11
end
object chkFromCaret: TCheckBox
Left = 216
Height = 24
Top = 128
Width = 98
Caption = 'from caret'
TabOrder = 7
end
object bCount: TButton
Left = 376
Height = 25
Top = 80
Width = 99
Caption = 'count all'
ModalResult = 5
TabOrder = 12
end
object chkConfirm: TCheckBox
Left = 216
Height = 24
Top = 152
Width = 131
Caption = 'confirm replace'
TabOrder = 8
end
object bMarkAll: TButton
Left = 376
Height = 25
Top = 112
Width = 99
Caption = 'mark all'
ModalResult = 4
TabOrder = 13
end
end

View File

@ -0,0 +1,85 @@
unit formfind;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
StdCtrls;
type
{ TfmFind }
TfmFind = class(TForm)
bCount: TButton;
bMarkAll: TButton;
bFind: TButton;
bCancel: TButton;
bRep: TButton;
bRepAll: TButton;
chkFromCaret: TCheckBox;
chkConfirm: TCheckBox;
chkRep: TCheckBox;
chkRegex: TCheckBox;
chkBack: TCheckBox;
chkCase: TCheckBox;
chkWords: TCheckBox;
edFind: TEdit;
edRep: TEdit;
Label1: TLabel;
procedure chkRegexChange(Sender: TObject);
procedure chkRepChange(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure Update;
{ private declarations }
public
{ public declarations }
end;
var
fmFind: TfmFind;
implementation
{$R *.lfm}
{ TfmFind }
procedure TfmFind.chkRegexChange(Sender: TObject);
begin
Update;
end;
procedure TfmFind.chkRepChange(Sender: TObject);
begin
Update;
end;
procedure TfmFind.FormShow(Sender: TObject);
begin
Update;
end;
procedure TfmFInd.Update;
var
rep: boolean;
begin
rep:= chkRep.Checked;
chkWords.Enabled:= not chkRegex.Checked;
chkBack.Enabled:= not chkRegex.Checked;
chkConfirm.Enabled:= rep;
edRep.Enabled:= rep;
bFind.Visible:= not rep;
bRep.Visible:= rep;
bRepAll.Visible:= rep;
if rep then Caption:= 'Replace' else Caption:= 'Find';
if rep then bRep.Default:= true else bFind.Default:= true;
end;
end.

View File

@ -0,0 +1,59 @@
object fmCmd: TfmCmd
Left = 425
Height = 620
Top = 120
Width = 679
ActiveControl = List
Caption = 'Commands'
ClientHeight = 620
ClientWidth = 679
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.5'
object List: TListView
Left = 6
Height = 573
Top = 6
Width = 667
Align = alClient
AutoSort = False
BorderSpacing.Around = 6
Columns = <
item
Caption = 'name'
Width = 350
end
item
Caption = 'key1'
Width = 150
end
item
Caption = 'key2'
Width = 150
end>
ColumnClick = False
ReadOnly = True
RowSelect = True
TabOrder = 0
ViewStyle = vsReport
OnDblClick = ListDblClick
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 29
Top = 585
Width = 667
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 1
ShowButtons = [pbOK, pbCancel]
ShowGlyphs = []
ShowBevel = False
end
end

View File

@ -0,0 +1,78 @@
unit formkey;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, comctrls,
ButtonPanel, ATSynedit;
type
{ TfmCmd }
TfmCmd = class(TForm)
ButtonPanel1: TButtonPanel;
List: TListView;
procedure FormShow(Sender: TObject);
procedure ListDblClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
edit: TATSynEdit;
end;
var
fmCmd: TfmCmd;
function DoCommandDialog(AEdit: TATSynEdit): integer;
implementation
uses
Menus, LCLProc;
{$R *.lfm}
function DoCommandDialog(AEdit: TATSynEdit): integer;
begin
Result:= 0;
with TfmCmd.Create(nil) do
try
edit:= AEdit;
if ShowModal=mrOk then
if List.Selected<>nil then
Result:= StrToIntDef(List.Selected.SubItems[2], 0);
finally
Free
end;
end;
{ TfmCmd }
procedure TfmCmd.FormShow(Sender: TObject);
var
i: integer;
begin
for i:= 0 to edit.Keymap.Count-1 do
with edit.Keymap.Items[i] do
with List.Items.Add do
begin
Caption:= Name;
SubItems.Add(ShortCutToText(Keys1[0]));
SubItems.Add(ShortCutToText(Keys2[0]));
SubItems.Add(Inttostr(Command));
end;
if List.Items.Count>0 then
List.Selected:= List.Items[0];
end;
procedure TfmCmd.ListDblClick(Sender: TObject);
begin
//ModalResult:= mrOk;
end;
end.

View File

@ -0,0 +1,73 @@
object fmKeyOpt: TfmKeyOpt
Left = 464
Height = 160
Top = 241
Width = 291
BorderStyle = bsDialog
Caption = 'Hotkey'
ClientHeight = 160
ClientWidth = 291
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.4.0.2'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 33
Top = 121
Width = 279
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.Caption = 'Clear key'
CloseButton.DefaultCaption = False
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 5
ShowButtons = [pbOK, pbCancel, pbClose]
ShowGlyphs = []
end
object chkCtrl: TCheckBox
Left = 24
Height = 19
Top = 16
Width = 39
Caption = 'Ctrl'
TabOrder = 0
end
object chkAlt: TCheckBox
Left = 24
Height = 19
Top = 40
Width = 35
Caption = 'Alt'
TabOrder = 1
end
object chkShift: TCheckBox
Left = 24
Height = 19
Top = 64
Width = 44
Caption = 'Shift'
TabOrder = 2
end
object chkMeta: TCheckBox
Left = 24
Height = 19
Top = 88
Width = 47
Caption = 'Meta'
TabOrder = 3
end
object ed: TComboBox
Left = 112
Height = 23
Top = 48
Width = 112
DropDownCount = 30
ItemHeight = 15
Style = csDropDownList
TabOrder = 4
end
end

View File

@ -0,0 +1,129 @@
unit formkeyoption;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
StdCtrls;
type
{ TfmKeyOpt }
TfmKeyOpt = class(TForm)
ButtonPanel1: TButtonPanel;
chkCtrl: TCheckBox;
chkAlt: TCheckBox;
chkShift: TCheckBox;
chkMeta: TCheckBox;
ed: TComboBox;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
function DoDialogHotkey(S: string): string;
implementation
{$R *.lfm}
function DoDialogHotkey(S: string): string;
var
n: integer;
begin
Result:= S;
with TfmKeyOpt.Create(nil) do
try
chkCtrl.Checked:= Pos('Ctrl+', S)>0;
chkAlt.Checked:= Pos('Alt+', S)>0;
chkShift.Checked:= Pos('Shift+', S)>0;
chkMeta.Checked:= Pos('Meta+', S)>0;
repeat
n:= Pos('+', S);
if n=0 then Break;
Delete(S, 1, n);
until false;
ed.ItemIndex:= ed.Items.IndexOf(S);
if ed.ItemIndex<0 then
ed.ItemIndex:= 0;
case ShowModal of
mrOk:
begin
Result:= ed.Text;
if chkMeta.Checked then Result:= 'Meta+'+Result;
if chkShift.Checked then Result:= 'Shift+'+Result;
if chkAlt.Checked then Result:= 'Alt+'+Result;
if chkCtrl.Checked then Result:= 'Ctrl+'+Result;
end;
mrClose:
Result:= '';
end;
finally
Free;
end;
end;
{ TfmKeyOpt }
procedure TfmKeyOpt.FormCreate(Sender: TObject);
var
i: integer;
begin
for i:= Ord('A') to Ord('Z') do
ed.Items.Add(Chr(i));
for i:= 0 to 9 do
ed.Items.Add(Inttostr(i));
for i:= 1 to 12 do
ed.Items.Add('F'+Inttostr(i));
ed.Items.Add('Left');
ed.Items.Add('Right');
ed.Items.Add('Up');
ed.Items.Add('Down');
ed.Items.Add('Ins');
ed.Items.Add('Del');
ed.Items.Add('Home');
ed.Items.Add('End');
ed.Items.Add('PgUp');
ed.Items.Add('PgDn');
ed.Items.Add('Enter');
ed.Items.Add('BkSp');
ed.Items.Add('Tab');
ed.Items.Add('Esc');
ed.Items.Add('-');
ed.Items.Add('=');
ed.Items.Add('`');
ed.Items.Add(',');
ed.Items.Add('.');
ed.Items.Add(';');
ed.Items.Add('''');
ed.Items.Add('\');
ed.Items.Add('/');
ed.Items.Add('[');
ed.Items.Add(']');
for i:= 0 to 9 do
ed.Items.Add('Num'+Inttostr(i));
ed.Items.Add('NumPlus');
ed.Items.Add('NumMinus');
ed.Items.Add('NumMul');
ed.Items.Add('NumDiv');
ed.Items.Add('NumDot');
ed.Items.Add('NumClear');
ed.Items.Add('NumLock');
ed.Items.Add('ScrollLock');
ed.Items.Add('CapsLock');
ed.Items.Add('Break');
ed.Items.Add('PopUp');
end;
end.

View File

@ -0,0 +1,556 @@
object fmMain: TfmMain
Left = 266
Height = 498
Top = 242
Width = 953
Caption = 'Demo'
ClientHeight = 498
ClientWidth = 953
Menu = MainMenu1
OnCreate = FormCreate
OnDestroy = FormDestroy
OnResize = FormResize
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.5'
object PanelMain: TPanel
Left = 0
Height = 498
Top = 0
Width = 672
Align = alClient
BevelOuter = bvNone
ClientHeight = 498
ClientWidth = 672
TabOrder = 0
object Status: TStatusBar
Left = 0
Height = 21
Top = 477
Width = 672
Panels = <>
end
object StatusMsg: TStatusBar
Left = 0
Height = 21
Top = 456
Width = 672
Font.Color = clBlue
Panels = <>
ParentFont = False
end
object progress: TProgressBar
AnchorSideLeft.Control = PanelMain
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = StatusMsg
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = StatusMsg
AnchorSideBottom.Side = asrCenter
Left = 507
Height = 14
Top = 459
Width = 160
Anchors = [akRight, akBottom]
BorderSpacing.Right = 5
Smooth = True
Step = 1
TabOrder = 2
Visible = False
end
object btnStop: TButton
AnchorSideRight.Control = progress
AnchorSideBottom.Control = StatusMsg
AnchorSideBottom.Side = asrCenter
Left = 412
Height = 22
Top = 455
Width = 90
Anchors = [akRight, akBottom]
BorderSpacing.Right = 5
Caption = 'stop'
OnClick = btnStopClick
TabOrder = 3
Visible = False
end
end
object PanelRt: TPanel
Left = 672
Height = 498
Top = 0
Width = 281
Align = alRight
BevelOuter = bvNone
ClientHeight = 498
ClientWidth = 281
TabOrder = 1
object chkGutter: TCheckBox
Left = 8
Height = 24
Top = 8
Width = 68
Caption = 'gutter'
OnChange = chkGutterChange
TabOrder = 0
end
object chkRuler: TCheckBox
Left = 8
Height = 24
Top = 28
Width = 58
Caption = 'ruler'
OnChange = chkRulerChange
TabOrder = 1
end
object chkMinimap: TCheckBox
Left = 8
Height = 24
Top = 48
Width = 85
Caption = 'minimap'
OnChange = chkMinimapChange
TabOrder = 2
end
object edSpaceX: TSpinEdit
Left = 8
Height = 27
Top = 240
Width = 52
MaxValue = 10
MinValue = -5
OnChange = edSpaceXChange
TabOrder = 8
end
object Label1: TLabel
Left = 67
Height = 17
Top = 244
Width = 63
Caption = 'spacing-x'
ParentColor = False
end
object Label2: TLabel
Left = 67
Height = 17
Top = 308
Width = 47
Caption = 'margin'
ParentColor = False
end
object edMarRt: TSpinEdit
Left = 8
Height = 27
Top = 304
Width = 52
MaxValue = 200
MinValue = 20
OnChange = edMarRtChange
TabOrder = 10
Value = 20
end
object gWrap: TGroupBox
Left = 144
Height = 104
Top = 4
Width = 128
Caption = 'wrap'
ClientHeight = 85
ClientWidth = 124
TabOrder = 11
object chkWrapOff: TRadioButton
Left = 8
Height = 24
Top = 0
Width = 46
Caption = 'off'
Checked = True
OnChange = chkWrapOffChange
TabOrder = 0
TabStop = True
end
object chkWrapOn: TRadioButton
Left = 8
Height = 24
Top = 20
Width = 76
Caption = 'at edge'
OnChange = chkWrapOnChange
TabOrder = 1
end
object chkWrapMargin: TRadioButton
Left = 8
Height = 24
Top = 40
Width = 90
Caption = 'at margin'
OnChange = chkWrapMarginChange
TabOrder = 2
end
object chkWrapIndent: TCheckBox
Left = 8
Height = 24
Top = 60
Width = 101
Caption = 'with indent'
OnChange = chkWrapIndentChange
TabOrder = 3
end
end
object edFontsize: TSpinEdit
Left = 8
Height = 27
Top = 176
Width = 52
MaxValue = 40
MinValue = 4
OnChange = edFontsizeChange
TabOrder = 6
Value = 10
end
object Label4: TLabel
Left = 67
Height = 17
Top = 180
Width = 58
Caption = 'font size'
ParentColor = False
end
object gUnpri: TGroupBox
Left = 144
Height = 104
Top = 108
Width = 128
Caption = 'unprintable'
ClientHeight = 85
ClientWidth = 124
TabOrder = 12
object chkUnprintVis: TCheckBox
Left = 8
Height = 24
Top = 1
Width = 61
Caption = 'show'
OnChange = chkUnprintVisChange
TabOrder = 0
end
object chkUnprintSp: TCheckBox
Left = 8
Height = 24
Top = 20
Width = 72
Caption = 'spaces'
OnChange = chkUnprintSpChange
TabOrder = 1
end
object chkUnprintEnd: TCheckBox
Left = 8
Height = 24
Top = 40
Width = 58
Caption = 'ends'
OnChange = chkUnprintEndChange
TabOrder = 2
end
object chkUnprintEndDet: TCheckBox
Left = 8
Height = 24
Top = 60
Width = 101
Caption = 'end-details'
OnChange = chkUnprintEndDetChange
TabOrder = 3
end
end
object edTabsize: TSpinEdit
Left = 8
Height = 27
Top = 208
Width = 52
MaxValue = 12
MinValue = 1
OnChange = edTabsizeChange
TabOrder = 7
Value = 8
end
object Label5: TLabel
Left = 67
Height = 17
Top = 212
Width = 52
Caption = 'tab size'
ParentColor = False
end
object bFont: TButton
Left = 8
Height = 25
Top = 92
Width = 81
Caption = 'font...'
OnClick = bFontClick
TabOrder = 4
end
object chkMicromap: TCheckBox
Left = 8
Height = 24
Top = 68
Width = 95
Caption = 'micromap'
OnChange = chkMicromapChange
TabOrder = 3
end
object edSpaceY: TSpinEdit
Left = 8
Height = 27
Top = 272
Width = 52
MaxValue = 10
MinValue = -5
OnChange = edSpaceYChange
TabOrder = 9
end
object Label6: TLabel
Left = 67
Height = 17
Top = 276
Width = 62
Caption = 'spacing-y'
ParentColor = False
end
object bOpt: TButton
Left = 8
Height = 25
Top = 120
Width = 81
Caption = 'opts...'
OnClick = bOptClick
TabOrder = 5
end
object Memo1: TMemo
Left = 14
Height = 151
Top = 336
Width = 162
ScrollBars = ssBoth
TabOrder = 13
Visible = False
end
object btnMarker: TButton
Left = 144
Height = 25
Top = 224
Width = 96
Caption = 'marker'
OnClick = btnMarkerClick
TabOrder = 14
end
end
object OpenDialog1: TOpenDialog
Options = [ofFileMustExist, ofEnableSizing]
left = 472
top = 20
end
object FontDialog1: TFontDialog
Title = 'Font'
MinFontSize = 0
MaxFontSize = 0
left = 536
top = 20
end
object SaveDialog1: TSaveDialog
Options = [ofOverwritePrompt, ofEnableSizing, ofViewDetail]
left = 504
top = 20
end
object MainMenu1: TMainMenu
left = 432
top = 80
object mnuFile: TMenuItem
Caption = 'File'
object mnuFileOpen: TMenuItem
Caption = 'Open..'
ShortCut = 16463
OnClick = mnuFileOpenClick
end
object mnuFileSav: TMenuItem
Caption = 'Save..'
OnClick = mnuFileSaveClick
end
object mnuFileEnd: TMenuItem
Caption = 'Set ends'
object mnuEndWin: TMenuItem
Caption = 'win'
OnClick = mnuEndWinClick
end
object mnuEndUnix: TMenuItem
Caption = 'unix'
OnClick = mnuEndUnixClick
end
object mnuEndMac: TMenuItem
Caption = 'mac'
OnClick = mnuEndMacClick
end
end
object mnuFileHtml: TMenuItem
Caption = 'Export HTML'
OnClick = mnuFileHtmlClick
end
end
object MenuItem9: TMenuItem
Caption = 'Search'
object mnuFind: TMenuItem
Caption = 'find...'
ShortCut = 16454
OnClick = mnuFindClick
end
object mnuFindNext: TMenuItem
Caption = 'find next'
ShortCut = 114
OnClick = mnuFindNextClick
end
object mnuGoto: TMenuItem
Caption = 'go to..'
ShortCut = 16455
OnClick = bGotoClick
end
end
object mnuEnc: TMenuItem
Caption = 'Encoding'
end
object mnuTst: TMenuItem
Caption = 'Test'
object mnuTCaret1: TMenuItem
Caption = 'set 100 cr''s'
OnClick = mnuTCaret1Click
end
object mnuTCaretK: TMenuItem
Caption = 'set 2000 cr''s'
OnClick = bAddCrtClick
end
object mnuTMargin: TMenuItem
Caption = 'set margins..'
OnClick = mnuTMarginClick
end
object mnuTBms: TMenuItem
Caption = 'toggle bookm'
OnClick = mnuTBmsClick
end
object MenuItem5: TMenuItem
Caption = '-'
end
object mnuSyntax: TMenuItem
Caption = 'hilite syntax'
ShortCut = 16467
OnClick = mnuSyntaxClick
end
object mnuUnderline: TMenuItem
Caption = 'underline ''www'''
OnClick = mnuUnderlineClick
end
object MenuItem1: TMenuItem
Caption = '-'
end
object mnuPane: TMenuItem
Caption = 'show pane'
Checked = True
OnClick = mnuPaneClick
end
object mnuOneLine: TMenuItem
Caption = 'combo..'
OnClick = mnuOneLineClick
end
end
object mnuOpts: TMenuItem
Caption = 'Options'
object mnuOptDlg: TMenuItem
Caption = 'options..'
ShortCut = 120
OnClick = bOptClick
end
object mnuOptSave: TMenuItem
Caption = 'save'
Visible = False
OnClick = btnSaveClick
end
object mnuOptLoad: TMenuItem
Caption = 'load'
Visible = False
OnClick = btnLoadClick
end
end
object mnuHlp: TMenuItem
Caption = 'Help'
object mnuHelpKey: TMenuItem
Caption = 'commands..'
ShortCut = 112
OnClick = bKeymapClick
end
object MenuItem2: TMenuItem
Caption = '-'
end
object mnuHelpMous: TMenuItem
Caption = 'mouse help..'
OnClick = mnuHelpMousClick
end
end
end
object PopupBookmk: TPopupMenu
left = 480
top = 104
object mnuBms: TMenuItem
Caption = 'toggle all bm''s'
OnClick = mnuBmsClick
end
end
object PopupNums: TPopupMenu
left = 523
top = 128
object MenuItem3: TMenuItem
Caption = 'test nums'
Enabled = False
end
end
object PopupFold: TPopupMenu
left = 568
top = 152
object MenuItem4: TMenuItem
Caption = 'test fold'
Enabled = False
end
end
object PopupMinimap: TPopupMenu
left = 448
top = 192
object MenuItem6: TMenuItem
Caption = 'minimap'
Enabled = False
end
end
object PopupMicromap: TPopupMenu
left = 496
top = 216
object MenuItem7: TMenuItem
Caption = 'micromap'
Enabled = False
end
end
object PopupRuler: TPopupMenu
left = 552
top = 240
object MenuItem8: TMenuItem
Caption = 'ruler'
Enabled = False
end
end
object TimerHint: TTimer
Enabled = False
Interval = 5500
OnTimer = TimerHintTimer
left = 560
top = 303
end
object ApplicationProperties1: TApplicationProperties
ShowButtonGlyphs = sbgNever
ShowMenuGlyphs = sbgNever
left = 548
top = 366
end
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,474 @@
unit formopt;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ButtonPanel, Spin, ComCtrls, ATSynEdit, ATSynEdit_CanvasProc;
type
{ TfmOpt }
TfmOpt = class(TForm)
bColDown: TButton;
bColUp: TButton;
ButtonPanel1: TButtonPanel;
chkCrBlinkEn: TCheckBox;
chkMsNormalSel: TCheckBox;
chkMsColumnSel: TCheckBox;
chkUnprintArrowDown: TCheckBox;
chkShowFullHilite: TCheckBox;
chkMsHideCursor: TCheckBox;
chkLeftRtSwapAndSel: TCheckBox;
chkGutterSep: TCheckBox;
chkGutterNumAuto: TCheckBox;
chkGutterBm: TCheckBox;
chkGutterEmpty: TCheckBox;
chkGutterFold: TCheckBox;
chkGutterNum: TCheckBox;
chkGutterStat: TCheckBox;
chkShowFoldLinesAll: TCheckBox;
chkBackspUnindent: TCheckBox;
chkEnterIndent: TCheckBox;
chkMsMenuDown: TCheckBox;
chkTabIndent: TCheckBox;
chkUnindentKeepAlign: TCheckBox;
chkUnprintAsciiRep: TCheckBox;
chkShowFoldLines: TCheckBox;
chkShowFoldAlways: TCheckBox;
chkCrPreferLeft: TCheckBox;
chkKeepCol: TCheckBox;
chkCurLineMin: TCheckBox;
chkScrollHint: TCheckBox;
chkPageKeepRel: TCheckBox;
chkNavHomeEnd: TCheckBox;
chkMsNiceScroll: TCheckBox;
chkSaveEol: TCheckBox;
chkSaveTrim: TCheckBox;
chkShowNum1st: TCheckBox;
chkShowNumCr: TCheckBox;
chkMapSelBorder: TCheckBox;
chkMapSelAlways: TCheckBox;
chkShowNumBg: TCheckBox;
chkTabSpaces: TCheckBox;
chkUndoSv: TCheckBox;
chkUndoGr: TCheckBox;
chkCutNoSel: TCheckBox;
chkDotLn: TCheckBox;
chkMsClickNumSel: TCheckBox;
chkCrStopUnfocus: TCheckBox;
chkEndNonspace: TCheckBox;
chkHomeNonspace: TCheckBox;
chkLeftRtSwap: TCheckBox;
chkNavUpDown: TCheckBox;
chkOvrSel: TCheckBox;
chkMsRtClickMove: TCheckBox;
chkMsDragDrop: TCheckBox;
chkCrMul: TCheckBox;
chkCrVirt: TCheckBox;
chkMsClick2: TCheckBox;
chkMsClick2Drag: TCheckBox;
chkMsClick3: TCheckBox;
chkShowFullSel: TCheckBox;
chkCopyNoSel: TCheckBox;
chkCurCol: TCheckBox;
chkCurLine: TCheckBox;
chkLastOnTop: TCheckBox;
chkOvrPaste: TCheckBox;
chkUnprintEnd: TCheckBox;
chkUnprintEndDet: TCheckBox;
chkUnprintSpace: TCheckBox;
chkUnprintEn: TCheckBox;
edMapCharWidth: TSpinEdit;
edNumAlign: TComboBox;
edIndentKind: TComboBox;
edCrShape: TComboBox;
edCrShape2: TComboBox;
edCrTime: TSpinEdit;
edSizeSep: TSpinEdit;
edWordChars: TEdit;
edIndentSize: TSpinEdit;
edPlusSize: TSpinEdit;
edNumChar: TEdit;
edNumStyle: TComboBox;
edPageSize: TComboBox;
edRulerFSize: TSpinEdit;
edRulerIndent: TSpinEdit;
edRulerSize: TSpinEdit;
edSizeBm: TSpinEdit;
edSizeEmpty: TSpinEdit;
edSizeFold: TSpinEdit;
edSizeNum1: TSpinEdit;
edSizeNum2: TSpinEdit;
edSizeNum: TSpinEdit;
edSizeState: TSpinEdit;
edTabArrowSize: TSpinEdit;
edTabArrowPnt: TSpinEdit;
edTextHint: TEdit;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
groupIndent: TGroupBox;
LabChars: TLabel;
Label1: TLabel;
Label10: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label2: TLabel;
Label20: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
LabelArr: TLabel;
LabelArr1: TLabel;
LabelHint: TLabel;
ListCol: TListBox;
ListShapes: TListBox;
PageControl1: TPageControl;
edUndo: TSpinEdit;
edNumSize: TSpinEdit;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
TabSheet6: TTabSheet;
TabSheet7: TTabSheet;
TabSheet8: TTabSheet;
TabSheet9: TTabSheet;
procedure bColDownClick(Sender: TObject);
procedure bColUpClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
procedure InitShape(ed: TCombobox);
end;
var
fmOpt: TfmOpt;
procedure DoConfigEditor(ed: TATSynEdit);
implementation
{$R *.lfm}
const
nameBm = 'bookmk';
nameNums = 'nums';
nameState = 'states';
nameFold = 'fold';
nameSep = 'separator';
procedure DoConfigEditor(ed: TATSynEdit);
var
i: integer;
begin
with fmOpt do
begin
with ListCol do
begin
Items.Clear;
for i:= 0 to 4 do
begin
if i=ed.GutterBandBm then Items.Add(nameBm);
if i=ed.GutterBandNum then Items.Add(nameNums);
if i=ed.GutterBandState then Items.Add(nameState);
if i=ed.GutterBandFold then Items.Add(nameFold);
if i=ed.GutterBandSep then Items.Add(nameSep);
end;
ItemIndex:= 0;
end;
//general
chkCurLine.Checked:= ed.OptShowCurLine;
chkCurLineMin.Checked:= ed.OptShowCurLineMinimal;
chkCurCol.Checked:= ed.OptShowCurColumn;
chkLastOnTop.Checked:= ed.OptLastLineOnTop;
chkShowFullSel.Checked:= ed.OptShowFullSel;
chkShowFullHilite.Checked:= ed.OptShowFullHilite;
chkCopyNoSel.Checked:= ed.OptCopyLinesIfNoSel;
chkCutNoSel.Checked:= ed.OptCutLinesIfNoSel;
chkOvrPaste.Checked:= ed.OptOverwriteAllowedOnPaste;
chkDotLn.Checked:= ed.OptShowIndentLines;
edTextHint.Text:= ed.OptTextHint;
edWordChars.Text:= ed.OptWordChars;
chkSaveEol.Checked:= ed.OptSavingForceFinalEol;
chkSaveTrim.Checked:= ed.OptSavingTrimSpaces;
chkScrollHint.Checked:= ed.OptShowScrollHint;
//unprint
chkUnprintEn.Checked:= ed.OptUnprintedVisible;
chkUnprintSpace.Checked:= ed.OptUnprintedSpaces;
chkUnprintEnd.Checked:= ed.OptUnprintedEnds;
chkUnprintEndDet.Checked:= ed.OptUnprintedEndsDetails;
chkUnprintArrowDown.Checked:= OptUnprintedEndArrowOrDot;
chkUnprintAsciiRep.Checked:= ed.OptUnprintedReplaceSpec;
edTabArrowSize.Value:= OptUnprintedTabCharLength;
edTabArrowPnt.Value:= OptUnprintedTabPointerScale;
//caret
chkCrBlinkEn.Checked:= ed.OptCaretBlinkEnabled;
edCrTime.Value:= ed.OptCaretBlinkTime;
chkCrVirt.Checked:= ed.OptCaretVirtual;
chkCrMul.Checked:= ed.OptCaretManyAllowed;
chkCrStopUnfocus.Checked:= ed.OptCaretStopUnfocused;
chkCrPreferLeft.Checked:= ed.OptCaretPreferLeftSide;
edCrShape.ItemIndex:= Ord(ed.OptCaretShape);
edCrShape2.ItemIndex:= Ord(ed.OptCaretShapeOvr);
//gutter
edNumStyle.ItemIndex:= Ord(ed.OptNumbersStyle);
edNumAlign.ItemIndex:= Ord(ed.OptNumbersAlignment);
edNumSize.Value:= ed.OptNumbersFontSize;
edNumChar.Text:= ed.OptNumbersSkippedChar;
edPlusSize.Value:= ed.OptGutterPlusSize;
chkShowNum1st.Checked:= ed.OptNumbersShowFirst;
chkShowNumCr.Checked:= ed.OptNumbersShowCarets;
chkShowNumBg.Checked:= ed.OptShowGutterCaretBG;
chkShowFoldAlways.Checked:= ed.OptGutterShowFoldAlways;
chkShowFoldLines.Checked:= ed.OptGutterShowFoldLines;
chkShowFoldLinesAll.Checked:= ed.OptGutterShowFoldLinesAll;
edRulerSize.Value:= ed.OptRulerSize;
edRulerFSize.Value:= ed.OptRulerFontSize;
edRulerIndent.Value:= ed.OptRulerTextIndent;
chkGutterBm.Checked:= ed.Gutter[ed.GutterBandBm].Visible;
chkGutterNum.Checked:= ed.Gutter[ed.GutterBandNum].Visible;
chkGutterFold.Checked:= ed.Gutter[ed.GutterBandFold].Visible;
chkGutterStat.Checked:= ed.Gutter[ed.GutterBandState].Visible;
chkGutterSep.Checked:= ed.Gutter[ed.GutterBandSep].Visible;
chkGutterEmpty.Checked:= ed.Gutter[ed.GutterBandEmpty].Visible;
edSizeBm.Value:= ed.Gutter[ed.GutterBandBm].Size;
edSizeFold.Value:= ed.Gutter[ed.GutterBandFold].Size;
edSizeState.Value:= ed.Gutter[ed.GutterBandState].Size;
edSizeSep.Value:= ed.Gutter[ed.GutterBandSep].Size;
edSizeEmpty.Value:= ed.Gutter[ed.GutterBandEmpty].Size;
edSizeNum.Value:= ed.Gutter[ed.GutterBandNum].Size;
edSizeNum1.Value:= ed.OptNumbersIndentLeft;
edSizeNum2.Value:= ed.OptNumbersIndentRight;
chkGutterNumAuto.Checked:= ed.OptNumbersAutosize;
//minimap
edMapCharWidth.Value:= ed.OptMinimapCharWidth;
chkMapSelBorder.Checked:= ed.OptMinimapShowSelBorder;
chkMapSelAlways.Checked:= ed.OptMinimapShowSelAlways;
//key
chkTabSpaces.Checked:= ed.OptTabSpaces;
chkOvrSel.Checked:= ed.OptOverwriteSel;
chkNavUpDown.Checked:= ed.OptKeyUpDownNavigateWrapped;
chkNavHomeEnd.Checked:= ed.OptKeyHomeEndNavigateWrapped;
chkKeepCol.Checked:= ed.OptKeyUpDownKeepColumn;
chkLeftRtSwap.Checked:= ed.OptKeyLeftRightSwapSel;
chkLeftRtSwapAndSel.Checked:= ed.OptKeyLeftRightSwapSelAndSelect;
chkHomeNonspace.Checked:= ed.OptKeyHomeToNonSpace;
chkEndNonspace.Checked:= ed.OptKeyEndToNonSpace;
chkTabIndent.Checked:= ed.OptKeyTabIndents;
chkEnterIndent.Checked:= ed.OptAutoIndent;
chkBackspUnindent.Checked:= ed.OptKeyBackspaceUnindent;
edIndentKind.ItemIndex:= Ord(ed.OptAutoIndentKind);
edIndentSize.Value:= ed.OptIndentSize;
chkUnindentKeepAlign.Checked:= ed.OptIndentKeepsAlign;
edPageSize.ItemIndex:= Ord(ed.OptKeyPageUpDownSize);
chkPageKeepRel.Checked:= ed.OptKeyPageKeepsRelativePos;
//mouse
chkMsNormalSel.Checked:= ed.OptMouseEnableNormalSelection;
chkMsColumnSel.Checked:= ed.OptMouseEnableColumnSelection;
chkMsClick2.Checked:= ed.OptMouse2ClickSelectsLine;
chkMsClick3.Checked:= ed.OptMouse3ClickSelectsLine;
chkMsClick2Drag.Checked:= ed.OptMouse2ClickDragSelectsWords;
chkMsClickNumSel.Checked:= ed.OptMouseGutterClickSelectsLine;
chkMsDragDrop.Checked:= ed.OptMouseDragDrop;
chkMsRtClickMove.Checked:= ed.OptMouseRightClickMovesCaret;
chkMsNiceScroll.Checked:= ed.OptMouseNiceScroll;
chkMsHideCursor.Checked:= ed.OptMouseHideCursorOnType;
chkMsMenuDown.Checked:= ed.OptMouseDownForPopup;
//undo
edUndo.Value:= ed.OptUndoLimit;
chkUndoGr.Checked:= ed.OptUndoGrouped;
chkUndoSv.Checked:= ed.OptUndoAfterSave;
if ShowModal=mrOk then
begin
ed.GutterBandBm:= ListCol.Items.IndexOf(nameBm);
ed.GutterBandNum:= ListCol.Items.IndexOf(nameNums);
ed.GutterBandState:= ListCol.Items.IndexOf(nameState);
ed.GutterBandFold:= ListCol.Items.IndexOf(nameFold);
ed.GutterBandSep:= ListCol.Items.IndexOf(nameSep);
//general
ed.OptShowCurLine:= chkCurLine.Checked;
ed.OptShowCurLineMinimal:= chkCurLineMin.Checked;
ed.OptShowCurColumn:= chkCurCol.Checked;
ed.OptTextHint:= edTextHint.Text;
ed.OptWordChars:= edWordChars.Text;
ed.OptOverwriteAllowedOnPaste:= chkOvrPaste.Checked;
ed.OptCopyLinesIfNoSel:= chkCopyNoSel.Checked;
ed.OptCutLinesIfNoSel:= chkCutNoSel.Checked;
ed.OptShowFullSel:= chkShowFullSel.Checked;
ed.OptShowFullHilite:= chkShowFullHilite.Checked;
ed.OptLastLineOnTop:= chkLastOnTop.Checked;
ed.OptShowIndentLines:= chkDotLn.Checked;
ed.OptSavingForceFinalEol:= chkSaveEol.Checked;
ed.OptSavingTrimSpaces:= chkSaveTrim.Checked;
ed.OptShowScrollHint:= chkScrollHint.Checked;
//unprint
ed.OptUnprintedVisible:= chkUnprintEn.Checked;
ed.OptUnprintedSpaces:= chkUnprintSpace.Checked;
ed.OptUnprintedEnds:= chkUnprintEnd.Checked;
ed.OptUnprintedEndsDetails:= chkUnprintEndDet.Checked;
ed.OptUnprintedReplaceSpec:= chkUnprintAsciiRep.Checked;
OptUnprintedTabCharLength:= edTabArrowSize.Value;
OptUnprintedTabPointerScale:= edTabArrowPnt.Value;
OptUnprintedEndArrowOrDot:= chkUnprintArrowDown.Checked;
//caret
ed.OptCaretBlinkEnabled:= chkCrBlinkEn.Checked;
ed.OptCaretBlinkTime:= edCrTime.Value;
ed.OptCaretShape:= TATSynCaretShape(edCrShape.ItemIndex);
ed.OptCaretShapeOvr:= TATSynCaretShape(edCrShape2.ItemIndex);
ed.OptCaretVirtual:= chkCrVirt.Checked;
ed.OptCaretManyAllowed:= chkCrMul.Checked;
ed.OptCaretStopUnfocused:= chkCrStopUnfocus.Checked;
ed.OptCaretPreferLeftSide:= chkCrPreferLeft.Checked;
//gutter
ed.OptNumbersFontSize:= edNumSize.Value;
ed.OptNumbersStyle:= TATSynNumbersStyle(edNumStyle.ItemIndex);
ed.OptNumbersAlignment:= TAlignment(edNumAlign.ItemIndex);
ed.OptNumbersShowFirst:= chkShowNum1st.Checked;
ed.OptNumbersShowCarets:= chkShowNumCr.Checked;
ed.OptNumbersSkippedChar:= edNumChar.Text;
ed.OptGutterShowFoldAlways:= chkShowFoldAlways.Checked;
ed.OptGutterShowFoldLines:= chkShowFoldLines.Checked;
ed.OptGutterShowFoldLinesAll:= chkShowFoldLinesAll.Checked;
ed.OptGutterPlusSize:= edPlusSize.Value;
ed.OptShowGutterCaretBG:= chkShowNumBg.Checked;
ed.OptRulerSize:= edRulerSize.Value;
ed.OptRulerFontSize:= edRulerFSize.Value;
ed.OptRulerTextIndent:= edRulerIndent.Value;
ed.Gutter[ed.GutterBandBm].Visible:= chkGutterBm.Checked;
ed.Gutter[ed.GutterBandNum].Visible:= chkGutterNum.Checked;
ed.Gutter[ed.GutterBandFold].Visible:= chkGutterFold.Checked;
ed.Gutter[ed.GutterBandState].Visible:= chkGutterStat.Checked;
ed.Gutter[ed.GutterBandSep].Visible:= chkGutterSep.Checked;
ed.Gutter[ed.GutterBandEmpty].Visible:= chkGutterEmpty.Checked;
ed.Gutter[ed.GutterBandBm].Size:= edSizeBm.Value;
ed.Gutter[ed.GutterBandNum].Size:= edSizeNum.Value;
ed.Gutter[ed.GutterBandFold].Size:= edSizeFold.Value;
ed.Gutter[ed.GutterBandState].Size:= edSizeState.Value;
ed.Gutter[ed.GutterBandSep].Size:= edSizeSep.Value;
ed.Gutter[ed.GutterBandEmpty].Size:= edSizeEmpty.Value;
ed.OptNumbersAutosize:= chkGutterNumAuto.Checked;
ed.OptNumbersIndentLeft:= edSizeNum1.Value;
ed.OptNumbersIndentRight:= edSizeNum2.Value;
//minimap
ed.OptMinimapCharWidth:= edMapCharWidth.Value;
ed.OptMinimapShowSelBorder:= chkMapSelBorder.Checked;
ed.OptMinimapShowSelAlways:= chkMapSelAlways.Checked;
//key
ed.OptTabSpaces:= chkTabSpaces.Checked;
ed.OptOverwriteSel:= chkOvrSel.Checked;
ed.OptKeyUpDownKeepColumn:= chkKeepCol.Checked;
ed.OptKeyUpDownNavigateWrapped:= chkNavUpDown.Checked;
ed.OptKeyHomeEndNavigateWrapped:= chkNavHomeEnd.Checked;
ed.OptKeyPageUpDownSize:= TATPageUpDownSize(edPageSize.ItemIndex);
ed.OptKeyLeftRightSwapSel:= chkLeftRtSwap.Checked;
ed.OptKeyLeftRightSwapSelAndSelect:= chkLeftRtSwapAndSel.Checked;
ed.OptKeyHomeToNonSpace:= chkHomeNonspace.Checked;
ed.OptKeyEndToNonSpace:= chkEndNonspace.Checked;
ed.OptKeyPageKeepsRelativePos:= chkPageKeepRel.Checked;
ed.OptKeyTabIndents:= chkTabIndent.Checked;
ed.OptAutoIndent:= chkEnterIndent.Checked;
ed.OptKeyBackspaceUnindent := chkBackspUnindent.Checked;
ed.OptAutoIndentKind:= TATAutoIndentKind(edIndentKind.ItemIndex);
ed.OptIndentSize:= edIndentSize.Value;
ed.OptIndentKeepsAlign:= chkUnindentKeepAlign.Checked;
//mouse
ed.OptMouseEnableNormalSelection:= chkMsNormalSel.Checked;
ed.OptMouseEnableColumnSelection:= chkMsColumnSel.Checked;
ed.OptMouse2ClickSelectsLine:= chkMsClick2.Checked;
ed.OptMouse3ClickSelectsLine:= chkMsClick3.Checked;
ed.OptMouse2ClickDragSelectsWords:= chkMsClick2Drag.Checked;
ed.OptMouseGutterClickSelectsLine:= chkMsClickNumSel.Checked;
ed.OptMouseDragDrop:= chkMsDragDrop.Checked;
ed.OptMouseRightClickMovesCaret:= chkMsRtClickMove.Checked;
ed.OptMouseNiceScroll:= chkMsNiceScroll.Checked;
ed.OptMouseHideCursorOnType:= chkMsHideCursor.Checked;
ed.OptMouseDownForPopup:= chkMsMenuDown.Checked;
//undo
ed.OptUndoLimit:= edUndo.Value;
ed.OptUndoGrouped:= chkUndoGr.Checked;
ed.OptUndoAfterSave:= chkUndoSv.Checked;
//apply
ed.Gutter.Update;
ed.Update;
end;
end;
end;
{ TfmOpt }
procedure TfmOpt.FormCreate(Sender: TObject);
begin
InitShape(edCrShape);
InitShape(edCrShape2);
end;
procedure SwapItems(L: TListbox; n1, n2: integer);
var
s: string;
begin
s:= L.Items[n1];
L.Items[n1]:= L.Items[n2];
L.Items[n2]:= s;
L.ItemIndex:= n2;
end;
procedure TfmOpt.bColUpClick(Sender: TObject);
begin
with ListCol do
if ItemIndex>0 then
SwapItems(ListCol, ItemIndex, ItemIndex-1);
end;
procedure TfmOpt.bColDownClick(Sender: TObject);
begin
with ListCol do
if ItemIndex<Count-1 then
SwapItems(ListCol, ItemIndex, ItemIndex+1);
end;
procedure TfmOpt.InitShape(ed: TCombobox);
begin
ed.Items.Clear;
ed.Items.AddStrings(ListShapes.Items);
end;
end.

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="project1"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="4">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
<Unit2>
<Filename Value="..\..\atsynedit\atsynedit.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit"/>
</Unit2>
<Unit3>
<Filename Value="..\..\atsynedit\atstrings.pas"/>
<IsPartOfProject Value="True"/>
</Unit3>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\..\atsynedit"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,20 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1, atstrings, atsynedit;
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Initialize;
Application.CreateForm(TfmMain, fmMain);
Application.Run;
end.

View File

@ -0,0 +1,68 @@
object fmMain: TfmMain
Left = 222
Height = 442
Top = 254
Width = 932
Caption = 'App'
ClientHeight = 442
ClientWidth = 932
OnCreate = FormCreate
OnShow = FormShow
LCLVersion = '1.5'
object Panel1: TPanel
Left = 0
Height = 442
Top = 0
Width = 626
Align = alClient
BevelOuter = bvNone
Caption = 'Panel1'
TabOrder = 0
end
object Panel2: TPanel
Left = 632
Height = 442
Top = 0
Width = 300
Align = alRight
BevelOuter = bvNone
ClientHeight = 442
ClientWidth = 300
TabOrder = 1
object bGettext: TButton
Left = 0
Height = 25
Top = 400
Width = 80
Caption = 'Get text'
OnClick = bGettextClick
TabOrder = 0
end
object List: TShellListView
Left = 0
Height = 442
Top = 0
Width = 300
Align = alClient
Color = clWhite
HideSelection = False
ReadOnly = True
RowSelect = True
SortColumn = 0
SortType = stText
TabOrder = 1
ViewStyle = vsSmallIcon
OnClick = ListClick
ObjectTypes = [otNonFolders]
end
end
object Splitter1: TSplitter
Left = 626
Height = 442
Top = 0
Width = 6
Align = alRight
Beveled = True
ResizeAnchor = akRight
end
end

View File

@ -0,0 +1,76 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, ShellCtrls, atstrings, atsynedit, atstringproc;
type
{ TfmMain }
TfmMain = class(TForm)
bGettext: TButton;
Panel1: TPanel;
Panel2: TPanel;
List: TShellListView;
Splitter1: TSplitter;
procedure bGettextClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ListClick(Sender: TObject);
private
{ private declarations }
fDir: string;
ed: TATSynEdit;
public
{ public declarations }
end;
var
fmMain: TfmMain;
implementation
{$R *.lfm}
{ TfmMain }
procedure TfmMain.FormCreate(Sender: TObject);
begin
ed:= TATSynEdit.Create(Self);
ed.Parent:= Panel1;
ed.Align:= alClient;
ed.Font.Name:= 'Courier New';
ed.OptUnprintedVisible:= false;
ed.OptRulerVisible:= false;
ed.OptWrapMode:= cWrapOff;
fDir:= ExtractFilePath(Application.Exename)+'../../test_files';
end;
procedure TfmMain.FormShow(Sender: TObject);
begin
List.Root:= fDir;
end;
procedure TfmMain.ListClick(Sender: TObject);
var
s: string;
begin
s:= List.GetPathFromItem(List.Selected);
if not FileExistsUTF8(s) then Exit;
ed.LoadFromFile(s);
ed.SetFocus;
Caption:= 'App - '+ExtractFileName(s);
end;
procedure TfmMain.bGettextClick(Sender: TObject);
begin
ShowMessage(UTF8Encode(ed.Strings.TextString));
end;
end.

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\..\atsynedit"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,22 @@
program demo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1
{ you can add units after this };
{$R *.res}
begin
Application.Title:= 'Demo';
RequireDerivedFormResource:= True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,10 @@
object Form1: TForm1
Left = 260
Height = 391
Top = 262
Width = 690
Caption = 'Demo'
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.4.0.4'
end

View File

@ -0,0 +1,52 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ATSynEdit, ATSynEdit_Keymap_Init;
type
{ TForm1 }
TForm1 = class(TForm)
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
ed: TATSynEdit;
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
ed:= TATSynEdit.Create(Self);
ed.Parent:= Self;
ed.Font.Name:= 'Courier New';
ed.Align:= alClient;
ed.OptUnprintedVisible:= false;
ed.OptRulerVisible:= false;
ed.Colors.TextBG:= $e0f0f0;
ed.LoadFromFile(ExtractFilePath(Application.ExeName)+'unit1.pas');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ed.OptCaretBlinkEnabled:= not ed.OptCaretBlinkEnabled;
ed.SetFocus;
end;
end.

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="demo"/>
<ResourceType Value="res"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,19 @@
program demo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1
{ you can add units after this };
begin
RequireDerivedFormResource:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,20 @@
object Form1: TForm1
Left = 456
Height = 278
Top = 453
Width = 500
Caption = 'Form1'
ClientHeight = 278
ClientWidth = 500
OnPaint = FormPaint
LCLVersion = '1.5'
object Button1: TButton
Left = 154
Height = 25
Top = 68
Width = 75
Caption = 'close'
OnClick = Button1Click
TabOrder = 0
end
end

View File

@ -0,0 +1,58 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormPaint(Sender: TObject);
var
c: tcanvas;
begin
c:= self.canvas;
c.brush.color:= clyellow;
c.fillrect(0, 0, 200, 200);
c.pen.color:= clred;
c.line(10,10,30,10);
c.line(30,10,50,10);
c.line(50,10,80,10);
c.line(10,10,10,30);
c.line(10,30,10,50);
c.line(10,50,10,80);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;
end.

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="atsynedit_package"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="3">
<Unit0>
<Filename Value="demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
<Unit2>
<Filename Value="..\..\atsynedit\atsynedit.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATSynEdit"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\..\atsynedit"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,21 @@
program demo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1, ATSynEdit
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource:= True;
Application.Initialize;
Application.CreateForm(TfmMain, fmMain);
Application.Run;
end.

View File

@ -0,0 +1,343 @@
object fmMain: TfmMain
Left = 359
Height = 419
Top = 457
Width = 685
Caption = 'Test'
ClientHeight = 419
ClientWidth = 685
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.5'
object ed: TATSynEdit
Left = 6
Height = 308
Top = 6
Width = 673
Align = alClient
BorderSpacing.Around = 6
BorderStyle = bsSingle
Font.Height = -12
Font.Name = 'Courier New'
ParentFont = False
TabOrder = 0
TabStop = True
CursorText = crIBeam
CursorBm = crHandPoint
Colors.TextFont = clBlack
Colors.TextBG = clWhite
Colors.TextDisabledFont = clGray
Colors.TextDisabledBG = 15790320
Colors.TextSelFont = clHighlightText
Colors.TextSelBG = clHighlight
Colors.Caret = clBlack
Colors.GutterFont = clGray
Colors.GutterBG = 14737632
Colors.GutterCaretBG = 13158600
Colors.GutterPlusBorder = clGray
Colors.GutterPlusBG = 16053492
Colors.GutterFoldLine = clGray
Colors.GutterFoldBG = 13158600
Colors.GutterSeparatorBG = clBlack
Colors.CurrentLineBG = 14741744
Colors.MarginRight = clSilver
Colors.MarginCaret = clLime
Colors.MarginUser = clYellow
Colors.IndentVertLines = clMedGray
Colors.BookmarkBG = clMoneyGreen
Colors.RulerFont = clGray
Colors.RulerBG = 14737632
Colors.CollapseLine = 10510432
Colors.CollapseMarkFont = 14712960
Colors.CollapseMarkBG = clWhite
Colors.UnprintedFont = 5263600
Colors.UnprintedBG = 14737632
Colors.UnprintedHexFont = clMedGray
Colors.MinimapBorder = clSilver
Colors.MinimapSelBG = 15658734
Colors.StateChanged = 61680
Colors.StateAdded = 2146336
Colors.StateSaved = clMedGray
Colors.BlockStaple = clMedGray
Colors.BlockSepLine = clMedGray
Colors.LockedBG = 14737632
Colors.TextHintFont = clGray
Colors.ComboboxArrow = clGray
Colors.ComboboxArrowBG = 15790320
WantTabs = True
OptTabSpaces = False
OptTabSize = 10
OptFoldStyle = cFoldHereWithTruncatedText
OptTextLocked = 'wait...'
OptTextHintFontStyle = [fsItalic]
OptTextHintCenter = False
OptTextOffsetTop = 0
OptTextOffsetFromLine = 1
OptAutoIndent = True
OptAutoIndentKind = cIndentAsIs
OptCopyLinesIfNoSel = True
OptCutLinesIfNoSel = False
OptLastLineOnTop = False
OptOverwriteSel = True
OptOverwriteAllowedOnPaste = False
OptShowStapleStyle = cLineStyleSolid
OptShowStapleIndent = -1
OptShowStapleWidthPercent = 100
OptShowFullSel = False
OptShowFullHilite = True
OptShowCurLine = False
OptShowCurLineMinimal = True
OptShowScrollHint = False
OptShowCurColumn = False
OptCaretManyAllowed = True
OptCaretVirtual = True
OptCaretShape = cCaretShapeVertPixels1
OptCaretShapeOvr = cCaretShapeFull
OptCaretShapeRO = cCaretShapeHorzPixels1
OptCaretBlinkTime = 600
OptCaretBlinkEnabled = True
OptCaretStopUnfocused = True
OptCaretPreferLeftSide = True
OptGutterVisible = True
OptGutterPlusSize = 4
OptGutterShowFoldAlways = True
OptGutterShowFoldLines = True
OptGutterShowFoldLinesAll = False
OptRulerVisible = True
OptRulerSize = 19
OptRulerFontSize = 8
OptRulerMarkSizeSmall = 3
OptRulerMarkSizeBig = 7
OptRulerTextIndent = 0
OptMinimapVisible = False
OptMinimapCharWidth = 0
OptMinimapShowSelBorder = False
OptMinimapShowSelAlways = True
OptMicromapVisible = False
OptMicromapWidth = 30
OptCharSpacingX = 0
OptCharSpacingY = 1
OptWrapMode = cWrapOn
OptWrapIndented = True
OptMarginRight = 80
OptNumbersAutosize = True
OptNumbersAlignment = taRightJustify
OptNumbersFontSize = 0
OptNumbersStyle = cNumbersEach5th
OptNumbersShowFirst = True
OptNumbersShowCarets = False
OptNumbersSkippedChar = '.'
OptNumbersIndentLeft = 5
OptNumbersIndentRight = 5
OptUnprintedVisible = False
OptUnprintedSpaces = True
OptUnprintedEnds = True
OptUnprintedEndsDetails = True
OptUnprintedReplaceSpec = True
OptMouseEnableNormalSelection = True
OptMouseEnableColumnSelection = True
OptMouseDownForPopup = False
OptMouseHideCursorOnType = False
OptMouse2ClickSelectsLine = False
OptMouse3ClickSelectsLine = True
OptMouse2ClickDragSelectsWords = True
OptMouseDragDrop = True
OptMouseNiceScroll = True
OptMouseRightClickMovesCaret = False
OptMouseGutterClickSelectsLine = True
OptKeyBackspaceUnindent = True
OptKeyPageKeepsRelativePos = True
OptKeyUpDownNavigateWrapped = True
OptKeyUpDownKeepColumn = True
OptKeyHomeEndNavigateWrapped = True
OptKeyPageUpDownSize = cPageSizeFullMinus1
OptKeyLeftRightSwapSel = True
OptKeyLeftRightSwapSelAndSelect = False
OptKeyHomeToNonSpace = True
OptKeyEndToNonSpace = True
OptKeyTabIndents = True
OptIndentSize = 2
OptIndentKeepsAlign = True
OptShowIndentLines = True
OptShowGutterCaretBG = True
OptAllowScrollbarVert = True
OptAllowScrollbarHorz = True
OptAllowZooming = True
OptAllowReadOnly = True
OptUndoLimit = 5000
OptUndoGrouped = True
OptUndoAfterSave = True
OptSavingForceFinalEol = False
OptSavingTrimSpaces = False
end
object Panel1: TPanel
Left = 0
Height = 99
Top = 320
Width = 685
Align = alBottom
ClientHeight = 99
ClientWidth = 685
TabOrder = 1
object ATComboEdit1: TATComboEdit
Left = 8
Height = 26
Top = 0
Width = 300
BorderStyle = bsSingle
Font.Height = -12
Font.Name = 'Courier New'
ParentFont = False
TabOrder = 0
TabStop = True
CursorText = crIBeam
CursorBm = crHandPoint
Colors.TextFont = clBlack
Colors.TextBG = clWhite
Colors.TextDisabledFont = clGray
Colors.TextDisabledBG = 15790320
Colors.TextSelFont = clHighlightText
Colors.TextSelBG = clHighlight
Colors.Caret = clBlack
Colors.GutterFont = clGray
Colors.GutterBG = 14737632
Colors.GutterCaretBG = 13158600
Colors.GutterPlusBorder = clGray
Colors.GutterPlusBG = 16053492
Colors.GutterFoldLine = clGray
Colors.GutterFoldBG = 13158600
Colors.GutterSeparatorBG = clBlack
Colors.CurrentLineBG = 14741744
Colors.MarginRight = clSilver
Colors.MarginCaret = clLime
Colors.MarginUser = clYellow
Colors.IndentVertLines = clMedGray
Colors.BookmarkBG = clMoneyGreen
Colors.RulerFont = clGray
Colors.RulerBG = 14737632
Colors.CollapseLine = 10510432
Colors.CollapseMarkFont = 14712960
Colors.CollapseMarkBG = clCream
Colors.UnprintedFont = 5263600
Colors.UnprintedBG = 14737632
Colors.UnprintedHexFont = clMedGray
Colors.MinimapBorder = clSilver
Colors.MinimapSelBG = 15658734
Colors.StateChanged = 61680
Colors.StateAdded = 2146336
Colors.StateSaved = clMedGray
Colors.BlockStaple = clMedGray
Colors.BlockSepLine = clMedGray
Colors.LockedBG = 14737632
Colors.TextHintFont = clGray
Colors.ComboboxArrow = clGray
Colors.ComboboxArrowBG = 15790320
WantTabs = False
OptTabSpaces = False
OptTabSize = 8
OptFoldStyle = cFoldHereWithTruncatedText
OptTextLocked = 'wait...'
OptTextHintFontStyle = [fsItalic]
OptTextHintCenter = False
OptTextOffsetTop = 2
OptTextOffsetFromLine = 1
OptAutoIndent = True
OptAutoIndentKind = cIndentAsIs
OptCopyLinesIfNoSel = True
OptCutLinesIfNoSel = False
OptLastLineOnTop = False
OptOverwriteSel = True
OptOverwriteAllowedOnPaste = False
OptShowStapleStyle = cLineStyleSolid
OptShowStapleIndent = -1
OptShowStapleWidthPercent = 100
OptShowFullSel = False
OptShowFullHilite = True
OptShowCurLine = False
OptShowCurLineMinimal = True
OptShowScrollHint = False
OptShowCurColumn = False
OptCaretManyAllowed = False
OptCaretVirtual = False
OptCaretShape = cCaretShapeVertPixels1
OptCaretShapeOvr = cCaretShapeFull
OptCaretShapeRO = cCaretShapeHorzPixels1
OptCaretBlinkTime = 600
OptCaretBlinkEnabled = True
OptCaretStopUnfocused = True
OptCaretPreferLeftSide = True
OptGutterVisible = False
OptGutterPlusSize = 4
OptGutterShowFoldAlways = True
OptGutterShowFoldLines = True
OptGutterShowFoldLinesAll = False
OptRulerVisible = False
OptRulerSize = 20
OptRulerFontSize = 8
OptRulerMarkSizeSmall = 3
OptRulerMarkSizeBig = 7
OptRulerTextIndent = 0
OptMinimapVisible = False
OptMinimapCharWidth = 0
OptMinimapShowSelBorder = False
OptMinimapShowSelAlways = True
OptMicromapVisible = True
OptMicromapWidth = 22
OptCharSpacingX = 0
OptCharSpacingY = 1
OptWrapMode = cWrapOff
OptWrapIndented = True
OptMarginRight = 1000
OptNumbersAutosize = True
OptNumbersAlignment = taRightJustify
OptNumbersFontSize = 0
OptNumbersStyle = cNumbersEach5th
OptNumbersShowFirst = True
OptNumbersShowCarets = False
OptNumbersSkippedChar = '.'
OptNumbersIndentLeft = 5
OptNumbersIndentRight = 5
OptUnprintedVisible = False
OptUnprintedSpaces = True
OptUnprintedEnds = True
OptUnprintedEndsDetails = True
OptUnprintedReplaceSpec = True
OptMouseEnableNormalSelection = True
OptMouseEnableColumnSelection = True
OptMouseDownForPopup = False
OptMouseHideCursorOnType = False
OptMouse2ClickSelectsLine = False
OptMouse3ClickSelectsLine = True
OptMouse2ClickDragSelectsWords = True
OptMouseDragDrop = False
OptMouseNiceScroll = False
OptMouseRightClickMovesCaret = False
OptMouseGutterClickSelectsLine = True
OptKeyBackspaceUnindent = True
OptKeyPageKeepsRelativePos = True
OptKeyUpDownNavigateWrapped = True
OptKeyUpDownKeepColumn = True
OptKeyHomeEndNavigateWrapped = True
OptKeyPageUpDownSize = cPageSizeFullMinus1
OptKeyLeftRightSwapSel = True
OptKeyLeftRightSwapSelAndSelect = False
OptKeyHomeToNonSpace = True
OptKeyEndToNonSpace = True
OptKeyTabIndents = True
OptIndentSize = 2
OptIndentKeepsAlign = True
OptShowIndentLines = True
OptShowGutterCaretBG = True
OptAllowScrollbarVert = False
OptAllowScrollbarHorz = False
OptAllowZooming = False
OptAllowReadOnly = False
OptUndoLimit = 200
OptUndoGrouped = True
OptUndoAfterSave = True
OptSavingForceFinalEol = False
OptSavingTrimSpaces = False
OptComboboxArrowSize = 4
end
end
end

View File

@ -0,0 +1,52 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, ATSynEdit, ATSynEdit_Edits, LCLType;
type
{ TfmMain }
TfmMain = class(TForm)
ATComboEdit1: TATComboEdit;
ed: TATSynEdit;
Panel1: TPanel;
procedure FormShow(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
fmMain: TfmMain;
implementation
{$R *.lfm}
{ TfmMain }
procedure TfmMain.FormShow(Sender: TObject);
begin
ed.Strings.Clear;
ed.Strings.LineAdd('This is demo text');
ed.Strings.LineAdd('test');
ed.Strings.LineAdd('test...');
ed.Update(true);
{
combo2:= tatcomboedit.create(Self);
combo2.parent:= panel1;
combo2.left:= 350;
combo2.width:= 300;
combo2.top:= 20;
}
end;
end.

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="Finder test"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../../atsynedit"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-dUnicode"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,22 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1
{ you can add units after this };
{$R *.res}
begin
Application.Title:='Finder test';
RequireDerivedFormResource:=True;
Application.Initialize;
Application.CreateForm(TfmMain, fmMain);
Application.Run;
end.

View File

@ -0,0 +1,137 @@
object fmMain: TfmMain
Left = 516
Height = 320
Top = 250
Width = 667
BorderStyle = bsDialog
Caption = 'Test Finder.FindMatch'
ClientHeight = 320
ClientWidth = 667
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.5'
object Memo1: TMemo
Left = 8
Height = 48
Top = 24
Width = 407
Lines.Strings = (
'register'
)
TabOrder = 0
end
object Memo2: TMemo
Left = 8
Height = 216
Top = 96
Width = 407
Lines.Strings = (
'unit shapeline_reg;'
''
'interface'
''
'uses'
' SysUtils, Classes, Controls, LResources, shapeline;'
''
'procedure Register;'
''
'implementation'
''
'procedure Register;'
'begin'
' RegisterComponents(''Misc'', [TShapeLine]);'
'end;'
''
'initialization'
' {$I res/icons.lrs}'
''
'end.'
)
TabOrder = 1
end
object bFindNext: TButton
Left = 431
Height = 25
Top = 62
Width = 120
Caption = 'find next'
OnClick = bFindNextClick
TabOrder = 3
end
object bFind: TButton
Left = 431
Height = 25
Top = 30
Width = 120
Caption = 'find first'
OnClick = bFindClick
TabOrder = 2
end
object Label1: TLabel
Left = 8
Height = 17
Top = 7
Width = 62
Caption = 'find what'
ParentColor = False
end
object Label2: TLabel
Left = 8
Height = 17
Top = 80
Width = 70
Caption = 'find where'
ParentColor = False
end
object Memo3: TMemo
Left = 424
Height = 58
Top = 254
Width = 230
Lines.Strings = (
''
)
ReadOnly = True
TabOrder = 8
end
object chkBack: TCheckBox
Left = 431
Height = 24
Top = 174
Width = 92
Caption = 'backward'
TabOrder = 7
end
object chkCase: TCheckBox
Left = 431
Height = 24
Top = 126
Width = 89
Caption = 'case sens'
TabOrder = 5
end
object chkWords: TCheckBox
Left = 431
Height = 24
Top = 150
Width = 111
Caption = 'whole words'
TabOrder = 6
end
object Label3: TLabel
Left = 424
Height = 17
Top = 230
Width = 39
Caption = 'result'
ParentColor = False
end
object chkRegex: TCheckBox
Left = 431
Height = 24
Top = 102
Width = 64
Caption = 'regex'
TabOrder = 4
end
end

View File

@ -0,0 +1,93 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
atsynedit_finder, regexpr;
type
{ TfmMain }
TfmMain = class(TForm)
bFindNext: TButton;
bFind: TButton;
chkRegex: TCheckBox;
chkBack: TCheckBox;
chkCase: TCheckBox;
chkWords: TCheckBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Memo1: TMemo;
Memo2: TMemo;
Memo3: TMemo;
procedure bFindNextClick(Sender: TObject);
procedure bFindClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
Finder: TATTextFinder;
procedure DoFind(ANext: boolean);
{ private declarations }
public
{ public declarations }
end;
var
fmMain: TfmMain;
implementation
{$R *.lfm}
{ TfmMain }
procedure TfmMain.bFindClick(Sender: TObject);
begin
DoFind(false);
end;
procedure TfmMain.bFindNextClick(Sender: TObject);
begin
DoFind(true);
end;
procedure TfmMain.DoFind(ANext: boolean);
var
NFromPos, NSkipLen: integer;
begin
Finder.StrFind:= trim(Memo1.Text);
Finder.StrText:= trim(Memo2.Text);
Finder.OptCase:= chkCase.Checked;
Finder.OptWords:= chkWords.Checked;
Finder.OptBack:= chkBack.Checked;
Finder.OptRegex:= chkRegex.Checked;
NSkipLen:= Finder.MatchLen;
if ANext then
NFromPos:= Finder.MatchPos
else
if Finder.OptRegex then
NFromPos:= 1
else
if Finder.OptBack then
NFromPos:= Length(Finder.StrText)
else
NFromPos:= 1;
if not FInder.FindMatch(ANext, NSkipLen, NFromPos) then
memo3.text:= '(not found)'
else
memo3.text:= 'context:'#13+Copy(Finder.StrText, Finder.MatchPos-2, FInder.MatchLen+4);
end;
procedure TfmMain.FormCreate(Sender: TObject);
begin
FInder:= TATTextFinder.Create;
end;
end.

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="project1"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="3">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
<Unit2>
<Filename Value="..\..\atsynedit\atstringproc_textbuffer.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ATStringProc_TextBuffer"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\..\atsynedit"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,21 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1, atstringproc_textbuffer
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource:= True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,27 @@
object Form1: TForm1
Left = 350
Height = 259
Top = 362
Width = 508
Caption = 'Form1'
ClientHeight = 259
ClientWidth = 508
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.5'
object Memo1: TMemo
Left = 0
Height = 259
Top = 0
Width = 508
Align = alClient
Font.CharSet = RUSSIAN_CHARSET
Font.Height = -12
Font.Name = 'Courier New'
Font.Pitch = fpFixed
Font.Quality = fqDraft
ParentFont = False
ScrollBars = ssBoth
TabOrder = 0
end
end

View File

@ -0,0 +1,69 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
atstringproc_textbuffer, Types;
type
{ TForm1 }
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
buf: TATStringBuffer;
s: tstringlist;
list: tlist;
i: integer;
pos: integer;
pnt0, pnt: tpoint;
begin
s:= tstringlist.create;
for i:= 0 to 20 do
s.add(stringofchar('t', random(40)));
list:= tlist.create;
for i:= 0 to s.count-1 do
list.add(pointer(length(s[i])));
buf:= TATStringBuffer.create;
buf.Setup(s.text, list, 1);
for i:= 0 to 1000 do
begin
pnt0.y:= random(s.count);
pnt0.x:= random(length(s[pnt0.y]));
pos:= buf.CaretToStr(pnt0);
pnt:= buf.StrToCaret(pos);
if not PointsEqual(pnt, pnt0) then
begin
memo1.lines.add('bad test: line:col '+inttostr(pnt0.y)+':'+inttostr(pnt0.x));
exit;
end;
end;
memo1.lines.add('ok test');
end;
end.

View File

@ -0,0 +1,895 @@
unit ATStringProc;
{$mode objfpc}{$H+}
//{$define test_wide_char}
interface
uses
Classes, SysUtils, StrUtils;
type
atString = UnicodeString;
atChar = WideChar;
PatChar = PWideChar;
type
TATIntArray = array of Longint;
TATRealArray = array of real;
TATPointArray = array of TPoint;
function SCharUpper(ch: atChar): atChar;
function SCharLower(ch: atChar): atChar;
function SCaseTitle(const S, SWordChars: atString): atString;
function SCaseInvert(const S: atString): atString;
function SCaseSentence(const S, SWordChars: atString): atString;
{$Z1}
type
TATLineEnds = (cEndNone, cEndWin, cEndUnix, cEndMac);
const
cLineEndStrings: array[TATLineEnds] of atString = ('', #13#10, #10, #13);
cLineEndNiceNames: array[TATLineEnds] of string = ('', 'win', 'un', 'mac');
const
cMaxTabPositionToExpand = 500; //no sense to expand too far tabs
cCharScaleFullwidth_Default = 1.7; //width of CJK chars
cCharScaleHex = 6.0; //width of hex show: "<NNNN>"
cMinWordWrapOffset = 3;
var
OptHexCharsDefault: UnicodeString = ''; //show these chars as "<NNNN>"
OptHexCharsUser: UnicodeString = ''; //these too
OptCommaCharsWrapWithWords: UnicodeString = '.,;:''"`~?!&%$';
cCharScaleFullwidth: Single = cCharScaleFullwidth_Default;
function IsCharEol(ch: atChar): boolean;
function IsCharWord(ch: atChar; const AWordChars: atString): boolean;
function IsCharSpace(ch: atChar): boolean;
function IsCharAsciiControl(ch: atChar): boolean;
function IsCharAccent(ch: atChar): boolean;
function IsCharHex(ch: atChar): boolean;
function IsStringWithUnicodeChars(const S: atString): boolean;
function SBeginsWith(const S, SubStr: atString): boolean;
function SBeginsWith(const S, SubStr: string): boolean;
function SEndsWith(const S, SubStr: atString): boolean;
function SEndsWith(const S, SubStr: string): boolean;
function STrimRight(const S: atString): atString;
function SGetIndentChars(const S: atString): integer;
function SGetIndentExpanded(const S: atString; ATabSize: integer): integer;
function SGetNonSpaceLength(const S: atString): integer;
function STabsToSpaces(const S: atString; ATabSize: integer): atString;
function SSpacesToTabs(const S: atString; ATabSize: integer): atString;
function SCharPosToColumnPos(const S: atString; APos, ATabSize: integer): integer;
function SColumnPosToCharPos(const S: atString; AColumn, ATabSize: integer): integer;
type
TATCommentAction = (
cCommentAdd_AtNonspace,
cCommentAdd_AtNonespace_IfNone,
cCommentAdd_AtStart,
cCommentAdd_AtStart_IfNone,
cCommentRemove,
cCommentToggle_AtNonspace,
cCommentToggle_AtStart
);
function SCommentLineAction(L: TStringList; const AComment: atString; Act: TATCommentAction): boolean;
function SRemoveNewlineChars(const S: atString): atString;
function SRemoveHexChars(const S: atString): atString;
function SRemoveAsciiControlChars(const S: atString): atString;
procedure SCalcCharOffsets(const S: atString; var AList: TATRealArray;
ATabSize: integer; ACharsSkipped: integer = 0);
function SFindWordWrapOffset(const S: atString; AColumns, ATabSize: integer;
const AWordChars: atString; AWrapIndented: boolean): integer;
function SFindClickedPosition(const Str: atString;
APixelsFromLeft, ACharSize, ATabSize: integer;
AAllowVirtualPos: boolean;
out AEndOfLinePos: boolean): integer;
procedure SFindOutputSkipOffset(const S: atString; ATabSize, AScrollPos: integer;
out ACharsSkipped: integer; out ASpacesSkipped: real);
function SIndentUnindent(const Str: atString; ARight: boolean;
AIndentSize, ATabSize: integer): atString;
function SGetItem(var S: string; const sep: Char = ','): string;
function SGetItemAtEnd(var S: string; const sep: Char = ','): string;
function SSwapEndian(const S: UnicodeString): UnicodeString;
function SWithBreaks(const S: atString): boolean;
procedure SAddStringToHistory(const S: string; List: TStrings; MaxItems: integer);
function BoolToPlusMinusOne(b: boolean): integer;
procedure TrimStringList(L: TStringList);
type
TATDecodeRec = record SFrom, STo: UnicodeString; end;
function SDecodeRecords(const S: UnicodeString; const Decode: array of TATDecodeRec): UnicodeString;
procedure SReplaceAll(var s: string; const SFrom, STo: string);
procedure SReplaceAllPercentChars(var S: string);
procedure SDeleteFrom(var s: string; const SFrom: string);
implementation
uses
Dialogs, Math;
function IsCharEol(ch: atChar): boolean;
begin
Result:= (ch=#10) or (ch=#13);
end;
function IsCharWord(ch: atChar; const AWordChars: atString): boolean;
begin
Result:= false;
case Ord(ch) of
//Eng
Ord('0')..Ord('9'),
Ord('a')..Ord('z'),
Ord('A')..Ord('Z'),
Ord('_'),
//German
$E4, $C4, $E9, $F6, $D6, $FC, $DC, $DF,
//Rus
$0430..$044F, //a..z
$0410..$042F, //A..Z
$0451, $0401, //yo, Yo
//Greek
$0391..$03A9,
$03B1..$03C9:
begin Result:= true; Exit end;
end;
if AWordChars<>'' then
if Pos(ch, AWordChars)>0 then
Result:= true;
end;
function IsCharSpace(ch: atChar): boolean;
begin
Result:= (ch=' ') or (ch=#9);
end;
function IsCharAsciiControl(ch: atChar): boolean;
begin
Result:= (ch<>#9) and (AnsiChar(ch)<' ');
end;
function IsCharHex(ch: atChar): boolean;
begin
Result:= Pos(ch, OptHexCharsDefault+OptHexCharsUser)>0;
end;
function IsStringWithUnicodeChars(const S: atString): boolean;
var
i, N: integer;
begin
Result:= false;
for i:= 1 to Length(S) do
begin
N:= Ord(S[i]);
if (N<32) or (N>126) then exit(true);
end;
end;
procedure DoDebugOffsets(const List: TATRealArray);
var
i: integer;
s: string;
begin
s:= '';
for i:= Low(List) to High(List) do
s:= s+FloatToStr(List[i])+' ';
showmessage('Offsets'#13+s);
end;
function SFindWordWrapOffset(const S: atString; AColumns, ATabSize: integer;
const AWordChars: atString; AWrapIndented: boolean): integer;
//
//override IsCharWord to check also commas,dots,quotes
//to wrap them with wordchars
function _IsWord(ch: atChar): boolean;
begin
Result:= IsCharWord(ch, AWordChars+OptCommaCharsWrapWithWords);
end;
//
var
N, NMin, NAvg: integer;
List: TATRealArray;
begin
if S='' then
begin Result:= 0; Exit end;
if AColumns<cMinWordWrapOffset then
begin Result:= AColumns; Exit end;
SetLength(List, Length(S));
SCalcCharOffsets(S, List, ATabSize);
if List[High(List)]<=AColumns then
begin
Result:= Length(S);
Exit
end;
//NAvg is average wrap offset, we use it if no correct offset found
N:= Length(S)-1;
while (N>0) and (List[N]>AColumns+1) do Dec(N);
NAvg:= N;
if NAvg<cMinWordWrapOffset then
begin Result:= cMinWordWrapOffset; Exit end;
//find correct offset: not allowed at edge
//a) 2 wordchars,
//b) space as 2nd char (not nice look for Python src)
NMin:= SGetIndentChars(S)+1;
while (N>NMin) and
((_IsWord(S[N]) and _IsWord(S[N+1])) or
(AWrapIndented and IsCharSpace(S[N+1])))
do Dec(N);
//use correct of avg offset
if N>NMin then
Result:= N
else
Result:= NAvg;
end;
function SGetIndentChars(const S: atString): integer;
begin
Result:= 0;
while (Result<Length(S)) and IsCharSpace(S[Result+1]) do
Inc(Result);
end;
function SGetNonSpaceLength(const S: atString): integer;
begin
Result:= Length(S);
while (Result>0) and IsCharSpace(S[Result]) do Dec(Result);
if Result=0 then
Result:= Length(S);
end;
function SGetIndentExpanded(const S: atString; ATabSize: integer): integer;
var
SIndent: atString;
begin
SIndent:= Copy(S, 1, SGetIndentChars(S));
SIndent:= STabsToSpaces(SIndent, ATabSize);
Result:= Length(SIndent);
end;
function SSwapEndian(const S: UnicodeString): UnicodeString;
var
i: integer;
begin
Result:= S;
for i:= 1 to Length(Result) do
Result[i]:= WideChar(SwapEndian(Ord(Result[i])));
end;
function SCalcTabulationSize(const ATabSize, APos: integer): integer;
begin
Result:= 1;
if APos>cMaxTabPositionToExpand then Exit;
while (APos+Result-1) mod ATabSize <> 0 do
Inc(Result);
end;
function STabsToSpaces(const S: atString; ATabSize: integer): atString;
var
N, NSize: integer;
begin
Result:= S;
repeat
N:= Pos(#9, Result);
if N=0 then Break;
NSize:= SCalcTabulationSize(ATabSize, N);
if NSize<=1 then
Result[N]:= ' '
else
begin
Delete(Result, N, 1);
Insert(StringOfChar(' ', NSize), Result, N);
end;
until false;
end;
{
http://en.wikipedia.org/wiki/Combining_character
Combining Diacritical Marks (0300036F), since version 1.0, with modifications in subsequent versions down to 4.1
Combining Diacritical Marks Extended (1AB01AFF), version 7.0
Combining Diacritical Marks Supplement (1DC01DFF), versions 4.1 to 5.2
Combining Diacritical Marks for Symbols (20D020FF), since version 1.0, with modifications in subsequent versions down to 5.1
Combining Half Marks (FE20FE2F), versions 1.0, updates in 5.2
}
{
http://www.unicode.org/charts/PDF/U0E80.pdf
cannot render them ok anyway as accents:
0EB1, 0EB4..0EBC, 0EC8..0ECD
}
function IsCharAccent(ch: atChar): boolean;
begin
case Ord(ch) of
$0300..$036F,
$1AB0..$1AFF,
$1DC0..$1DFF,
$20D0..$20FF,
{$ifdef unix}
$0EB1, $0EB4..$0EBC, $0EC8..$0ECD, //Lao accent chars
{$endif}
$FE20..$FE2F:
Result:= true;
else
Result:= false;
end;
end;
function IsCharFullWidth(ch: atChar): boolean;
begin
case Ord(ch) of
$1100..$115F,
$2329..$232A,
$2E80..$303E,
$3041..$33FF,
$3400..$4DB5,
$4E00..$9FC3,
$A000..$A4C6,
$AC00..$D7A3,
$F900..$FAD9,
$FE10..$FE19,
$FE30..$FE6B,
$FF01..$FF60,
$FFE0..$FFE6:
Result:= true;
else
Result:= false;
end;
end;
{$ifdef test_wide_char}
const
cScaleTest = 1.9; //debug, for test code, commented
{$endif}
procedure SCalcCharOffsets(const S: atString; var AList: TATRealArray;
ATabSize: integer; ACharsSkipped: integer);
var
NSize, NTabSize, NCharsSkipped: integer;
Scale: real;
i: integer;
begin
if S='' then Exit;
if Length(AList)<>Length(S) then
raise Exception.Create('Bad list len: CalcCharOffsets');
NCharsSkipped:= ACharsSkipped;
for i:= 1 to Length(S) do
begin
Inc(NCharsSkipped);
Scale:= 1.0;
if IsCharHex(S[i]) then
Scale:= cCharScaleHex
else
if IsCharFullWidth(S[i]) then
Scale:= cCharScaleFullwidth;
{$ifdef test_wide_char}
if IsSpaceChar(S[i]) then
Scale:= 1
else
Scale:= cScaleTest;
{$endif}
if S[i]<>#9 then
NSize:= 1
else
begin
NTabSize:= SCalcTabulationSize(ATabSize, NCharsSkipped);
NSize:= NTabSize;
Inc(NCharsSkipped, NTabSize-1);
end;
if (i<Length(S)) and IsCharAccent(S[i+1]) then
NSize:= 0;
if i=1 then
AList[i-1]:= NSize*Scale
else
AList[i-1]:= AList[i-2]+NSize*Scale;
end;
end;
function SFindClickedPosition(const Str: atString;
APixelsFromLeft, ACharSize, ATabSize: integer;
AAllowVirtualPos: boolean;
out AEndOfLinePos: boolean): integer;
var
ListReal: TATRealArray;
ListEnds, ListMid: TATIntArray;
i: integer;
begin
AEndOfLinePos:= false;
if Str='' then
begin
if AAllowVirtualPos then
Result:= 1+APixelsFromLeft div ACharSize
else
Result:= 1;
Exit;
end;
SetLength(ListReal, Length(Str));
SetLength(ListEnds, Length(Str));
SetLength(ListMid, Length(Str));
SCalcCharOffsets(Str, ListReal, ATabSize);
//positions of each char end
for i:= 0 to High(ListEnds) do
ListEnds[i]:= Trunc(ListReal[i]*ACharSize);
//positions of each char middle
for i:= 0 to High(ListEnds) do
if i=0 then
ListMid[i]:= ListEnds[i] div 2
else
ListMid[i]:= (ListEnds[i-1]+ListEnds[i]) div 2;
for i:= 0 to High(ListEnds) do
if APixelsFromLeft<ListMid[i] then
begin
Result:= i+1;
Exit
end;
AEndOfLinePos:= true;
if AAllowVirtualPos then
Result:= Length(Str)+1 + (APixelsFromLeft - ListEnds[High(ListEnds)]) div ACharSize
else
Result:= Length(Str)+1;
end;
procedure SFindOutputSkipOffset(const S: atString; ATabSize, AScrollPos: integer;
out ACharsSkipped: integer; out ASpacesSkipped: real);
var
List: TATRealArray;
begin
ACharsSkipped:= 0;
ASpacesSkipped:= 0;
if (S='') or (AScrollPos=0) then Exit;
SetLength(List, Length(S));
SCalcCharOffsets(S, List, ATabSize);
while (ACharsSkipped<Length(S)) and (List[ACharsSkipped]<AScrollPos) do
Inc(ACharsSkipped);
if (ACharsSkipped>0) then
ASpacesSkipped:= List[ACharsSkipped-1];
end;
function BoolToPlusMinusOne(b: boolean): integer;
begin
if b then Result:= 1 else Result:= -1;
end;
function SGetItem(var S: string; const sep: Char = ','): string;
var
i: integer;
begin
i:= Pos(sep, s);
if i=0 then i:= MaxInt;
Result:= Copy(s, 1, i-1);
Delete(s, 1, i);
end;
function SGetItemAtEnd(var S: string; const sep: Char = ','): string;
var
i: integer;
begin
Result:= '';
i:= Pos(sep, S);
if i>0 then
begin
Result:= Copy(S, i+1, MaxInt);
Delete(S, i, MaxInt);
end;
end;
procedure TrimStringList(L: TStringList);
begin
//dont do "while", we need correct last empty lines
if (L.Count>0) and (L[L.Count-1]='') then
L.Delete(L.Count-1);
end;
function SWithBreaks(const S: atString): boolean;
begin
Result:=
(Pos(#13, S)>0) or
(Pos(#10, S)>0);
end;
function SSpacesToTabs(const S: atString; ATabSize: integer): atString;
begin
Result:= StringReplace(S, StringOfChar(' ', ATabSize), #9, [rfReplaceAll]);
end;
function SCharPosToColumnPos(const S: atString; APos, ATabSize: integer): integer;
begin
Result:= Length(STabsToSpaces(Copy(S, 1, APos), ATabSize));
if APos>Length(S) then
Inc(Result, APos-Length(S));
end;
function SColumnPosToCharPos(const S: atString; AColumn, ATabSize: integer): integer;
var
size, i: integer;
begin
if AColumn=0 then exit(AColumn);
if Pos(#9, S)=0 then exit(AColumn);
size:= 0;
for i:= 1 to Length(S) do
begin
if S[i]<>#9 then
Inc(size)
else
Inc(size, SCalcTabulationSize(ATabSize, size+1));
if size>=AColumn then
exit(i);
end;
Result:= AColumn-Length(STabsToSpaces(S, ATabSize))+Length(S);
end;
function SIndentUnindent(const Str: atString; ARight: boolean;
AIndentSize, ATabSize: integer): atString;
var
StrIndent, StrText: atString;
DecSpaces, N: integer;
DoTabs: boolean;
begin
Result:= Str;
//indent<0 - use tabs
if AIndentSize>=0 then
begin
StrIndent:= StringOfChar(' ', AIndentSize);
DecSpaces:= AIndentSize;
end
else
begin
StrIndent:= StringOfChar(#9, Abs(AIndentSize));
DecSpaces:= Abs(AIndentSize)*ATabSize;
end;
if ARight then
Result:= StrIndent+Str
else
begin
N:= SGetIndentChars(Str);
StrIndent:= Copy(Str, 1, N);
StrText:= Copy(Str, N+1, MaxInt);
DoTabs:= Pos(#9, StrIndent)>0;
StrIndent:= STabsToSpaces(StrIndent, ATabSize);
if DecSpaces>Length(StrIndent) then
DecSpaces:= Length(StrIndent);
Delete(StrIndent, 1, DecSpaces);
if DoTabs then
StrIndent:= SSpacesToTabs(StrIndent, ATabSize);
Result:= StrIndent+StrText;
end;
end;
function SRemoveAsciiControlChars(const S: atString): atString;
var
i: integer;
begin
Result:= S;
for i:= 1 to Length(Result) do
if IsCharAsciiControl(Result[i]) then
Result[i]:= '.';
end;
function SRemoveHexChars(const S: atString): atString;
var
i: integer;
begin
Result:= S;
for i:= 1 to Length(Result) do
if IsCharHex(Result[i]) then
Result[i]:= '?';
end;
function SRemoveNewlineChars(const S: atString): atString;
var
i: integer;
begin
Result:= S;
for i:= 1 to Length(Result) do
if IsCharEol(Result[i]) then
Result[i]:= ' ';
end;
{
http://unicode.org/reports/tr9/#Directional_Formatting_Characters
Implicit Directional Formatting Characters LRM, RLM, ALM
Explicit Directional Embedding and Override Formatting Characters LRE, RLE, LRO, RLO, PDF
Explicit Directional Isolate Formatting Characters LRI, RLI, FSI, PDI
}
const
cDirCodes: UnicodeString =
#$202A {LRE} + #$202B {RLE} + #$202D {LRO} + #$202E {RLO} + #$202C {PDF} +
#$2066 {LRI} + #$2067 {RLI} + #$2068 {FSI} + #$2069 {PDI} +
#$200E {LRM} + #$200F {RLM} + #$061C {ALM};
procedure _InitCharsHex;
var
i: integer;
begin
OptHexCharsDefault:= '';
for i:= 0 to 31 do
if (i<>13) and (i<>10) and (i<>9) then
OptHexCharsDefault:= OptHexCharsDefault+Chr(i);
OptHexCharsDefault:= OptHexCharsDefault + cDirCodes;
end;
function STrimRight(const S: atString): atString;
var
N: integer;
begin
N:= Length(S);
while (N>0) and (S[N]=' ') do Dec(N);
Result:= Copy(S, 1, N);
end;
function SBeginsWith(const S, SubStr: atString): boolean;
begin
Result:= (SubStr<>'') and (Copy(S, 1, Length(SubStr))=SubStr);
end;
function SBeginsWith(const S, SubStr: string): boolean;
begin
Result:= (SubStr<>'') and (Copy(S, 1, Length(SubStr))=SubStr);
end;
function SEndsWith(const S, SubStr: atString): boolean;
begin
Result:= (SubStr<>'') and (Length(SubStr)<=Length(S)) and
(Copy(S, Length(S)-Length(SubStr)+1, MaxInt)=SubStr);
end;
function SEndsWith(const S, SubStr: string): boolean;
begin
Result:= (SubStr<>'') and (Length(SubStr)<=Length(S)) and
(Copy(S, Length(S)-Length(SubStr)+1, MaxInt)=SubStr);
end;
function SCharUpper(ch: atChar): atChar;
begin
Result:= UnicodeUpperCase(ch)[1];
end;
function SCharLower(ch: atChar): atChar;
begin
Result:= UnicodeLowerCase(ch)[1];
end;
function SCaseTitle(const S, SWordChars: atString): atString;
var
i: integer;
begin
Result:= S;
for i:= 1 to Length(Result) do
if (i=1) or not IsCharWord(S[i-1], SWordChars) then
Result[i]:= SCharUpper(Result[i])
else
Result[i]:= SCharLower(Result[i]);
end;
function SCaseInvert(const S: atString): atString;
var
i: integer;
begin
Result:= S;
for i:= 1 to Length(Result) do
if S[i]<>SCharUpper(S[i]) then
Result[i]:= SCharUpper(Result[i])
else
Result[i]:= SCharLower(Result[i]);
end;
function SCaseSentence(const S, SWordChars: atString): atString;
var
dot: boolean;
i: Integer;
begin
Result:= S;
dot:= True;
for i:= 1 to Length(Result) do
begin
if IsCharWord(Result[i], SWordChars) then
begin
if dot then
Result[i]:= SCharUpper(Result[i])
else
Result[i]:= SCharLower(Result[i]);
dot:= False;
end
else
if (Result[i] = '.') or (Result[i] = '!') or (Result[i] = '?') then
dot:= True;
end;
end;
function SDecodeRecords(const S: UnicodeString; const Decode: array of TATDecodeRec): UnicodeString;
var
i, j: Integer;
DoDecode: Boolean;
begin
Result := '';
i := 1;
repeat
if i > Length(S) then Break;
DoDecode := False;
for j := Low(Decode) to High(Decode) do
with Decode[j] do
if SFrom = Copy(S, i, Length(SFrom)) then
begin
DoDecode := True;
Result := Result + STo;
Inc(i, Length(SFrom));
Break
end;
if DoDecode then Continue;
Result := Result + S[i];
Inc(i);
until False;
end;
function SCommentLineAction(L: TStringList;
const AComment: atString; Act: TATCommentAction): boolean;
var
Str, Str0: atString;
IndentThis, IndentAll, i: integer;
IsCmtThis, IsCmtAll: boolean;
begin
Result:= false;
if L.Count=0 then exit;
IndentAll:= MaxInt;
for i:= 0 to L.Count-1 do
IndentAll:= Min(IndentAll, SGetIndentChars(L[i])+1);
//no need Utf8decode
for i:= 0 to L.Count-1 do
begin
Str:= Utf8Decode(L[i]);
Str0:= Str;
//IndentThis, IsCmtThis: regarding indent if this line
//IndentAll, IsCmtAll: regarding minimal indent of block
IndentThis:= SGetIndentChars(Str)+1;
IsCmtThis:= Copy(Str, IndentThis, Length(AComment))=AComment;
IsCmtAll:= Copy(Str, IndentAll, Length(AComment))=AComment;
case Act of
cCommentAdd_AtNonspace:
begin
Insert(AComment, Str, IndentAll);
end;
cCommentAdd_AtNonespace_IfNone:
begin
if not IsCmtAll then
Insert(AComment, Str, IndentAll);
end;
cCommentAdd_AtStart:
begin
Insert(AComment, Str, 1);
end;
cCommentAdd_AtStart_IfNone:
begin
if not IsCmtAll then
Insert(AComment, Str, 1);
end;
cCommentRemove:
begin
if IsCmtAll then
Delete(Str, IndentAll, Length(AComment))
else
if IsCmtThis then
Delete(Str, IndentThis, Length(AComment))
end;
cCommentToggle_AtNonspace:
begin
if IsCmtAll then
Delete(Str, IndentAll, Length(AComment))
else
Insert(AComment, Str, IndentAll);
end;
cCommentToggle_AtStart:
begin
if IsCmtAll then
Delete(Str, IndentAll, Length(AComment))
else
Insert(AComment, Str, 1);
end;
end;
if Str<>Str0 then
begin
Result:= true; //modified
L[i]:= Utf8Encode(Str);
end;
end;
end;
procedure SReplaceAll(var s: string; const SFrom, STo: string);
begin
S:= StringReplace(S, SFrom, STo, [rfReplaceAll]);
end;
procedure SReplaceAllPercentChars(var S: string);
var
i: Integer;
begin
for i:= $20 to $2F do
SReplaceAll(S, '%'+IntToHex(i, 2), Chr(i));
i:= $7C;
SReplaceAll(S, '%'+IntToHex(i, 2), Chr(i));
end;
procedure SDeleteFrom(var s: string; const SFrom: string);
var
n: integer;
begin
n:= Pos(SFrom, S);
if n>0 then
Delete(S, n, MaxInt);
end;
procedure SAddStringToHistory(const S: string; List: TStrings; MaxItems: integer);
var
n: integer;
begin
if s<>'' then
begin
n:= List.IndexOf(s);
if n>=0 then
List.Delete(n);
List.Insert(0, s);
end;
while List.Count>MaxItems do
List.Delete(List.Count-1);
end;
initialization
_InitCharsHex;
end.

View File

@ -0,0 +1,81 @@
unit ATStringProc_HtmlColor;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Graphics;
//convert TColor -> HTML color string #rrggbb
function SColorToHtmlColor(Color: TColor): string;
//convert string which starts with HTML color token #rgb, #rrggbb -> TColor, get len of color-string
function SHtmlColorToColor(s: string; out Len: integer; Default: TColor): TColor;
implementation
function IsCharWord(ch: char): boolean;
begin
Result:= ch in ['a'..'z', 'A'..'Z', '_', '0'..'9'];
end;
function IsCharHex(ch: char): boolean;
begin
Result:= ch in ['0'..'9', 'a'..'f', 'A'..'F'];
end;
function SColorToHtmlColor(Color: TColor): string;
var
N: Longint;
begin
if Color=clNone then
begin Result:= ''; exit end;
N:= ColorToRGB(Color);
Result:= '#'+
IntToHex(Red(N), 2)+
IntToHex(Green(N), 2)+
IntToHex(Blue(N), 2);
end;
function SHtmlColorToColor(s: string; out Len: integer; Default: TColor): TColor;
var
N1, N2, N3: integer;
i: integer;
begin
Result:= Default;
Len:= 0;
if (s<>'') and (s[1]='#') then Delete(s, 1, 1);
if (s='') then exit;
//delete after first nonword char
i:= 1;
while (i<=Length(s)) and IsCharWord(s[i]) do Inc(i);
Delete(s, i, Maxint);
//allow only #rgb, #rrggbb
Len:= Length(s);
if (Len<>3) and (Len<>6) then exit;
for i:= 1 to Len do
if not IsCharHex(s[i]) then exit;
if Len=6 then
begin
N1:= StrToInt('$'+Copy(s, 1, 2));
N2:= StrToInt('$'+Copy(s, 3, 2));
N3:= StrToInt('$'+Copy(s, 5, 2));
end
else
begin
N1:= StrToInt('$'+s[1]+s[1]);
N2:= StrToInt('$'+s[2]+s[2]);
N3:= StrToInt('$'+s[3]+s[3]);
end;
Result:= RGBToColor(N1, N2, N3);
end;
end.

View File

@ -0,0 +1,204 @@
unit ATStringProc_TextBuffer;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
Dialogs,
ATStringProc;
type
TTextChangedEvent = procedure(Sender: TObject; Pos, Count, LineChange: integer) of object;
type
{ TATStringBuffer }
TATStringBuffer = class
private
FStarts: TList; //contains offsets of lines
FLenEol: integer;
FOnChange: TTextChangedEvent;
public
FText: atString;
constructor Create; virtual;
destructor Destroy; override;
procedure Setup(const AText: atString; ALineLens: TList; ALenEol: integer);
procedure SetupSlow(const AText: atString);
procedure Clear;
function CaretToStr(APnt: TPoint): integer;
function StrToCaret(APos: integer): TPoint;
function SubString(AFrom, ALen: integer): atString;
function TextLength: integer;
function LineIndex(N: integer): integer;
function LineLength(N: integer): integer;
function LineSpace(N: integer): integer;
function Count: integer;
property OnChange: TTextChangedEvent read FOnChange write FOnChange;
end;
implementation
const
cInitListCapacity = 10000;
{ TATStringBuffer }
constructor TATStringBuffer.Create;
begin
FText:= '';
FStarts:= TList.Create;
FStarts.Capacity:= cInitListCapacity;
FLenEol:= 1;
end;
destructor TATStringBuffer.Destroy;
begin
FStarts.Clear;
FreeAndNil(FStarts);
inherited;
end;
procedure TATStringBuffer.Setup(const AText: atString; ALineLens: TList;
ALenEol: integer);
var
Pos, NLen, i: integer;
begin
FText:= AText;
FLenEol:= ALenEol;
FStarts.Clear;
Pos:= 0;
FStarts.Add(nil);
for i:= 0 to ALineLens.Count-1 do
begin
NLen:= integer(ALineLens[i]);
Inc(Pos, NLen+FLenEol);
FStarts.Add(pointer(Pos));
end;
end;
procedure TATStringBuffer.SetupSlow(const AText: atString);
var
STextFinal: atString;
L: TStringList;
Lens: TList;
i: integer;
begin
if Trim(AText)='' then
begin
FText:= '';
FStarts.Clear;
Exit
end;
L:= TStringList.Create;
Lens:= TList.Create;
try
L.TextLineBreakStyle:= tlbsLF;
L.Text:= UTF8Encode(AText);
STextFinal:= UTF8Decode(L.Text); //this converts eol to LF
for i:= 0 to L.Count-1 do
Lens.Add(pointer(Length(UTF8Decode(L[i]))));
Setup(STextFinal, Lens, 1);
finally
FreeAndNil(Lens);
FreeAndNil(L);
end;
end;
procedure TATStringBuffer.Clear;
begin
FText:= '';
FStarts.Clear;
end;
function TATStringBuffer.CaretToStr(APnt: TPoint): integer;
var
Len: integer;
begin
Result:= -1;
if (APnt.Y<0) then Exit;
if (APnt.X<0) then Exit;
if (APnt.Y>=FStarts.Count) then Exit;
//handle caret pos after eol
Len:= LineLength(APnt.Y);
if APnt.X>Len then
APnt.X:= Len;
Result:= integer(FStarts[APnt.Y])+APnt.X;
end;
function TATStringBuffer.StrToCaret(APos: integer): TPoint;
var
a, b, m, dif: integer;
begin
Result.Y:= -1;
Result.X:= 0;
if APos<=0 then
begin Result.Y:= 0; Exit end;
a:= 0;
b:= FStarts.Count-1;
if b<0 then Exit;
repeat
dif:= integer(FStarts[a])-APos;
if dif=0 then begin m:= a; Break end;
//middle, which is near b if not exact middle
m:= (a+b+1) div 2;
dif:= integer(FStarts[m])-APos;
if dif=0 then Break;
if Abs(a-b)<=1 then begin m:= a; Break end;
if dif>0 then b:= m else a:= m;
until false;
Result.Y:= m;
Result.X:= APos-integer(FStarts[Result.Y]);
end;
function TATStringBuffer.SubString(AFrom, ALen: integer): atString;
begin
Result:= Copy(FText, AFrom, ALen);
end;
function TATStringBuffer.TextLength: integer;
begin
Result:= Length(FText);
end;
function TATStringBuffer.LineIndex(N: integer): integer;
begin
if N<0 then Result:= 0
else
if N>=FStarts.Count then Result:= TextLength-1
else
Result:= integer(FStarts[N]);
end;
function TATStringBuffer.LineLength(N: integer): integer;
begin
if N<0 then Result:= 0
else
if N>=FStarts.Count-1 then Result:= 0
else
Result:= integer(FStarts[N+1])-integer(FStarts[N])-FLenEol;
end;
function TATStringBuffer.LineSpace(N: integer): integer;
begin
Result:= LineLength(N)+FLenEol;
end;
function TATStringBuffer.Count: integer;
begin
Result:= FStarts.Count;
end;
end.

View File

@ -0,0 +1,68 @@
//Code by Christian Ghisler (ghisler.com)
//Christian gave code to open-source at TCmd forum
unit atstringproc_utf8detect;
{$mode objfpc}{$H+}
interface
//PartialAllowed must be set to true if the buffer is smaller than the file.
function IsBufferUtf8(buf:PAnsiChar;PartialAllowed:boolean):boolean;
implementation
const bytesFromUTF8:array[AnsiChar] of byte = (
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 32
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 64
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 96
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //128
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //160
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //192
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, //224
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5); //256
function GetUtf8CharWidth(firstchar:AnsiChar):integer;
begin
result:=bytesFromUTF8[firstchar]+1;
end;
function IsFirstUTF8Char(thechar:AnsiChar):boolean;
{The remaining bytes in a multi-byte sequence have 10 as their two most significant bits.}
begin
result:=(byte(thechar) and (128+64))<>128;
end;
function IsSecondaryUTF8Char(thechar:AnsiChar):boolean;
{The remaining bytes in a multi-byte sequence have 10 as their two most significant bits.}
begin
result:=(byte(thechar) and (128+64))=128;
end;
function IsBufferUtf8(buf:PAnsiChar;PartialAllowed:boolean):boolean;
{Buffer contains only valid UTF-8 characters, no secondary alone,
no primary without the correct nr of secondary}
var p:PAnsiChar;
utf8bytes:integer;
hadutf8bytes:boolean;
begin
p:=buf;
hadutf8bytes:=false;
result:=false;
utf8bytes:=0;
while p[0]<>#0 do begin
if utf8bytes>0 then begin {Expecting secondary AnsiChar}
hadutf8bytes:=true;
if not IsSecondaryUTF8Char(p[0]) then exit; {Fail!}
dec(utf8bytes);
end else if IsFirstUTF8Char(p[0]) then
utf8bytes:=GetUtf8CharWidth(p[0])-1
else if IsSecondaryUTF8Char(p[0]) then
exit; {Fail!}
inc(p);
end;
result:=hadutf8bytes and (PartialAllowed or (utf8bytes=0));
end;
end.

View File

@ -0,0 +1,105 @@
unit ATStringProc_WordJump;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
ATStringProc;
function SFindWordOffset(const S: atString; AOffset: integer; ANext, ABigJump: boolean;
const AWordChars: atString): integer;
procedure SFindWordBounds(const S: atString; AOffset: integer; out AOffset1, AOffset2: integer;
const AWordChars: atString);
implementation
const
//no EOL here, we jump only inside line
cCharsSp: atString = ' '#9;
//no chars '@' (email) and '$' (used in php)
cCharsSymb: atString = '!"#%&''()[]{}<>*+-/=,.:;?\^`|~‚„…‹›‘’“”–—¦«»­±';
type
TCharGr = (cgSp, cgSymb, cgWord);
function SCharGr(ch: atChar; const AWordChars: atString): TCharGr;
begin
if (AWordChars<>'') and (Pos(ch, AWordChars)>0) then Result:= cgWord else
if Pos(ch, cCharsSp)>0 then Result:= cgSp else
if Pos(ch, cCharsSymb)>0 then Result:= cgSymb else
Result:= cgWord;
end;
function SFindWordOffset(const S: atString; AOffset: integer; ANext,
ABigJump: boolean; const AWordChars: atString): integer;
var
n: integer;
//------------
procedure Next;
var gr: TCharGr;
begin
if not ((n>=0) and (n<Length(s))) then Exit;
gr:= SCharGr(s[n+1], AWordChars);
repeat Inc(n)
until
(n>=Length(s)) or (SCharGr(s[n+1], AWordChars)<>gr);
end;
//------------
procedure Home;
var gr: TCharGr;
begin
if not ((n>0) and (n<Length(s))) then Exit;
gr:= SCharGr(s[n+1], AWordChars);
while (n>0) and (SCharGr(s[n], AWordChars)=gr) do
Dec(n);
end;
//------------
begin
n:= AOffset;
if ANext then
begin
Next;
if ABigJump then
if (n<Length(s)) and (SCharGr(s[n+1], AWordChars)= cgSp) then
Next;
end
else
begin
//if we at word middle, jump to word start
if (n>0) and (n<Length(s)) and (SCharGr(s[n], AWordChars)=SCharGr(s[n+1], AWordChars)) then
Home
else
begin
//jump lefter, then jump to prev word start
if (n>0) then
begin Dec(n); Home end;
if ABigJump then
if (n>0) and (SCharGr(s[n+1], AWordChars)= cgSp) then
begin Dec(n); Home end;
end
end;
Result:= n;
end;
procedure SFindWordBounds(const S: atString; AOffset: integer; out AOffset1,
AOffset2: integer; const AWordChars: atString);
begin
AOffset1:= AOffset;
AOffset2:= AOffset;
if (AOffset>=0) and (AOffset<Length(S)) and
IsCharWord(S[AOffset+1], AWordChars) then
begin
//jump left only if at middle of word
if (AOffset>0) and IsCharWord(S[AOffset], AWordChars) then
AOffset1:= SFindWordOffset(S, AOffset, false, false, AWordChars);
//jump right always
AOffset2:= SFindWordOffset(S, AOffset, true, false, AWordChars);
end;
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,355 @@
{$ifdef none}begin end;{$endif}
procedure TATStrings.TextInsert(AX, AY: integer; const AText: atString; AOverwrite: boolean; out AShift, APosAfter: TPoint);
var
Str, StrLead, StrTail: atString;
List: TATStrings;
bWithEol, bInsertAtEnd: boolean;
begin
AShift.X:= 0;
AShift.Y:= 0;
APosAfter.X:= AX;
APosAfter.Y:= AY;
if not IsIndexValid(AY) then Exit;
if AX<0 then Exit;
if AText='' then Exit;
Str:= Lines[AY];
bInsertAtEnd:= AX>=Length(Str);
if not bInsertAtEnd then
begin
StrLead:= Copy(Str, 1, AX);
StrTail:= Copy(Str, AX+1, MaxInt);
end
else
begin
StrLead:= Str+StringOfChar(' ', AX-Length(Str));
StrTail:= '';
end;
if AOverwrite then
Delete(StrTail, 1, Length(AText));
//------------------
//Insert single line
if not SWithBreaks(AText) then
begin
Lines[AY]:= StrLead+AText+StrTail;
if not AOverwrite then
AShift.X:= Length(AText);
APosAfter.X:= AX+Length(AText);
Exit
end;
//----------------------
//Insert multi-line text
List:= TATStrings.Create;
BeginUndoGroup;
try
List.LoadFromString(StrLead+AText);
List.ActionDeleteFakeLine;
if List.Count=0 then Exit;
if StrTail<>'' then
Lines[AY]:= StrTail
else
if Lines[AY]<>'' then
LineDelete(AY);
bWithEol:= SEndsWith(AText, #10) or
SEndsWith(AText, #13) or
bInsertAtEnd //need for (paste N lines, no final eol, at end of line)
;
LineInsertStrings(AY, List, bWithEol);
if bWithEol then
begin
APosAfter.X:= 0;
APosAfter.Y:= AY+List.Count;
end
else
begin
APosAfter.X:= Length(List.Lines[List.Count-1]);
APosAfter.Y:= AY+List.Count-1;
end;
AShift.Y:= APosAfter.Y-AY;
finally
FreeAndNil(List);
EndUndoGroup;
end;
end;
procedure TATStrings.TextDeleteLeft(AX, AY: integer; ALen: integer; out AShift,
APosAfter: TPoint);
var
Str, StrPrev: atString;
begin
AShift.X:= 0;
AShift.Y:= 0;
APosAfter.X:= AX;
APosAfter.Y:= AY;
if not IsIndexValid(AY) then Exit;
Str:= Lines[AY];
//handle spec case: caret on last fake line, BkSp pressed:
//delete fake line,
//delete EOL at prev line
if (AX=0) and (AY=Count-1) and (AY>0) and IsLastLineFake then
begin
LineDelete(AY, false);
LinesEnds[AY-1]:= cEndNone;
AShift.Y:= -1;
APosAfter.X:= Length(Lines[AY-1]);
APosAfter.Y:= AY-1;
exit
end;
if AX>0 then
begin
if AX<=Length(Str) then
begin
System.Delete(Str, Max(1, AX+1-ALen), ALen);
Lines[AY]:= Str;
end;
AShift.X:= -Min(AX, ALen);
APosAfter.X:= Max(0, AX-ALen);
end
else
if AY>0 then
begin
StrPrev:= Lines[AY-1];
Lines[AY-1]:= StrPrev+Str;
LineDelete(AY);
AShift.Y:= -1;
APosAfter.X:= Length(StrPrev);
APosAfter.Y:= AY-1;
end;
end;
procedure TATStrings.TextDeleteRight(AX, AY: integer; ALen: integer; out AShift,
APosAfter: TPoint; ACanDelEol: boolean = true);
var
Str: atString;
DelEol: boolean;
begin
AShift.X:= 0;
AShift.Y:= 0;
APosAfter.X:= AX;
APosAfter.Y:= AY;
if not IsIndexValid(AY) then Exit;
Str:= Lines[AY];
//special case: last fake line
if (AY=Count-1) and (Str='') and (LinesEnds[AY]=cEndNone) then
Exit;
DelEol:= false;
if AX<Length(Str) then
begin
System.Delete(Str, AX+1, ALen);
Lines[AY]:= Str;
AShift.X:= -ALen;
end
else
DelEol:= ACanDelEol;
if DelEol then
if Str='' then //handle for simpler line-states
begin
AShift.Y:= -1;
if (AY>0) and (AY=Count-1) then
begin
APosAfter.X:= 0;
APosAfter.Y:= AY-1;
end;
LineDelete(AY);
end
else
begin
//add spaces if we are after eol
if AX>=Length(Str) then
Str:= Str+StringOfChar(' ', AX-Length(Str));
//not last: del next line
if AY+1<Count then
begin
Lines[AY]:= Str+Lines[AY+1];
LineDelete(AY+1, false{not force});
//maybe also eol
if AY=Count-1 then
LinesEnds[AY]:= cEndNone;
end
else
//last line: del eol
LinesEnds[AY]:= cEndNone;
AShift.Y:= -1;
end;
end;
procedure TATStrings.TextDeleteRange(AFromX, AFromY, AToX, AToY: integer;
out AShift, APosAfter: TPoint);
var
Str: atString;
bDelEmpty: boolean;
bNoEol: boolean;
i: integer;
begin
AShift.X:= 0;
AShift.Y:= 0;
APosAfter.X:= AFromX;
APosAfter.Y:= AFromY;
if not IsIndexValid(AFromY) then Exit;
if not IsIndexValid(AToY) then Exit;
if (AFromX=AToX) and (AFromY=AToY) then Exit;
if (AFromY>AToY) then Exit;
if AFromY=AToY then
begin
//delete range in one line
Str:= Lines[AFromY];
Delete(Str, AFromX+1, AToX-AFromX);
Lines[AFromY]:= Str;
AShift.X:= -(AToX-AFromX);
end
else
begin
bDelEmpty:= false;
//correct AToX/AToY to not del extra empty line
if (AToX=0) and (Lines[AToY]='') then //for empty last line
begin
AToY:= Max(0, AToY-1);
AToX:= Length(Lines[AToY]);
bDelEmpty:= true;
end;
//remember no final Eol
bNoEol:= (AToY=Count-1) and (LinesEnds[AToY]=cEndNone);
//place ramaining parts of 1st+last lines
Str:= Copy(Lines[AFromY], 1, AFromX) + Copy(Lines[AToY], AToX+1, MaxInt);
Lines[AFromY]:= Str;
//del middle lines
for i:= AToY downto AFromY+1 do
LineDelete(i);
//del empty line?
if bDelEmpty then
if Str='' then
LineDelete(AFromY);
if bNoEol then
begin
ActionDeleteFakeLine;
if Count>0 then
LinesEnds[Count-1]:= cEndNone;
end;
AShift.Y:= -(AToY-AFromY);
end;
end;
procedure TATStrings.TextInsertColumnBlock(AX, AY: integer; ABlock: TATStrings; AOverwrite: boolean);
var
Shift, PosAfter: TPoint;
i: integer;
begin
for i:= 0 to ABlock.Count-1 do
begin
TextInsert(AX, AY+i, ABlock.Lines[i], AOverwrite, Shift, PosAfter);
LinesEnds[AY+i]:= Endings; //force eol
if not IsIndexValid(AY+i+1) then
LineAddRaw('', cEndNone);
end;
end;
procedure TATStrings.TextInsertEol(AX, AY: integer; AKeepCaret: boolean; const AStrIndent: atString; out AShift, APosAfter: TPoint);
var
Str, StrMove: atString;
NewEnd: TATLineEnds;
begin
AShift.X:= 0;
AShift.Y:= 0;
APosAfter.X:= AX;
APosAfter.Y:= AY;
if not IsIndexValid(AY) then Exit;
Str:= Lines[AY];
StrMove:= '';
//special case AX=0: just insert empty line
//(less changes in undo)
if AX=0 then
begin
LineInsertRaw(AY, '', Endings);
end
else
begin
BeginUndoGroup;
if (AX<Length(Str)) then
begin
StrMove:= Copy(Str, AX+1, MaxInt);
Delete(Str, AX+1, MaxInt);
Lines[AY]:= Str;
end;
//handle situation when we at non-eol line, this must give
//inserted line also w/o eol
NewEnd:= LinesEnds[AY];
LinesEnds[AY]:= Endings; //force eol to cur line
LineInsertRaw(AY+1, AStrIndent+StrMove, NewEnd);
EndUndoGroup;
end;
if not AKeepCaret then
begin
APosAfter.X:= Length(AStrIndent);
APosAfter.Y:= AY+1;
AShift.Y:= 1;
end;
end;
procedure TATStrings.TextDeleteLine(AX, AY: integer; out AShift, APosAfter: TPoint);
begin
AShift.X:= 0;
AShift.Y:= 0;
APosAfter.X:= AX;
APosAfter.Y:= AY;
if not IsIndexValid(AY) then Exit;
AShift.Y:= -1;
APosAfter.X:= 0;
LineDelete(AY);
if AY>=Count then
LineAddEx('', cEndNone);
end;
procedure TATStrings.TextDuplicateLine(AX, AY: integer; out AShift, APosAfter: TPoint);
begin
AShift.X:= 0;
AShift.Y:= 0;
APosAfter.X:= AX;
APosAfter.Y:= AY;
if not IsIndexValid(AY) then Exit;
LineInsert(AY+1, Lines[AY]);
if LinesEnds[AY]<>Endings then
LinesEnds[AY]:= Endings;
LinesEnds[AY+1]:= Endings;
AShift.Y:= 1;
end;

Some files were not shown because too many files have changed in this diff Show More