Стартовый пул
This commit is contained in:
80
ATSynEdit/app/demo_econtrol_lexer_lib/formlexerlib.lfm
Normal file
80
ATSynEdit/app/demo_econtrol_lexer_lib/formlexerlib.lfm
Normal 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
|
216
ATSynEdit/app/demo_econtrol_lexer_lib/formlexerlib.pas
Normal file
216
ATSynEdit/app/demo_econtrol_lexer_lib/formlexerlib.pas
Normal 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.
|
||||
|
548
ATSynEdit/app/demo_econtrol_lexer_lib/formlexerprop.lfm
Normal file
548
ATSynEdit/app/demo_econtrol_lexer_lib/formlexerprop.lfm
Normal 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
|
272
ATSynEdit/app/demo_econtrol_lexer_lib/formlexerprop.pas
Normal file
272
ATSynEdit/app/demo_econtrol_lexer_lib/formlexerprop.pas
Normal 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.
|
||||
|
109
ATSynEdit/app/demo_econtrol_lexer_lib/lex_lib_demo.lpi
Normal file
109
ATSynEdit/app/demo_econtrol_lexer_lib/lex_lib_demo.lpi
Normal 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>
|
22
ATSynEdit/app/demo_econtrol_lexer_lib/lex_lib_demo.lpr
Normal file
22
ATSynEdit/app/demo_econtrol_lexer_lib/lex_lib_demo.lpr
Normal 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.
|
||||
|
23789
ATSynEdit/app/demo_econtrol_lexer_lib/lexlib/small.lxl
Normal file
23789
ATSynEdit/app/demo_econtrol_lexer_lib/lexlib/small.lxl
Normal file
File diff suppressed because it is too large
Load Diff
167
ATSynEdit/app/demo_econtrol_lexer_lib/proc_lexer_install_zip.pas
Normal file
167
ATSynEdit/app/demo_econtrol_lexer_lib/proc_lexer_install_zip.pas
Normal 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.
|
||||
|
30
ATSynEdit/app/demo_econtrol_lexer_lib/unmain.lfm
Normal file
30
ATSynEdit/app/demo_econtrol_lexer_lib/unmain.lfm
Normal 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
|
76
ATSynEdit/app/demo_econtrol_lexer_lib/unmain.pas
Normal file
76
ATSynEdit/app/demo_econtrol_lexer_lib/unmain.pas
Normal 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.
|
||||
|
Reference in New Issue
Block a user