From 9a3e82cf0698f9c0e64f012f1832eec0f6ddf8dc Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 20 Oct 2024 18:34:10 +0200 Subject: [PATCH] IDE, SynEdit: Add custom ident/keywords to Pascal Highlighter --- components/synedit/synedithighlighter.pp | 7 + components/synedit/synhighlighterpas.pp | 224 +++- ide/editoroptions.pp | 30 +- ide/frames/editor_color_options.pas | 15 +- ide/lazarusidestrconsts.pas | 3 + ide/sourcesyneditor.pas | 116 +- ide/syncolorattribeditor.lfm | 1332 +++++++++++++--------- ide/syncolorattribeditor.pas | 164 ++- 8 files changed, 1277 insertions(+), 614 deletions(-) diff --git a/components/synedit/synedithighlighter.pp b/components/synedit/synedithighlighter.pp index 1b9fe96563..8786b28fae 100644 --- a/components/synedit/synedithighlighter.pp +++ b/components/synedit/synedithighlighter.pp @@ -169,6 +169,7 @@ type procedure AssignFrom(Src: TLazSynCustomTextAttributes); override; procedure DoChange; override; + procedure Init; virtual; property ConstName: string read FConstName write FConstName; // internal accessor public constructor Create; @@ -1290,9 +1291,15 @@ begin fOnChange(Self); end; +procedure TSynHighlighterAttributes.Init; +begin + // +end; + constructor TSynHighlighterAttributes.Create; begin inherited Create; + Init; InternalSaveDefaultValues; end; diff --git a/components/synedit/synhighlighterpas.pp b/components/synedit/synhighlighterpas.pp index c380b67430..20b70220b0 100644 --- a/components/synedit/synhighlighterpas.pp +++ b/components/synedit/synhighlighterpas.pp @@ -47,11 +47,12 @@ advanced features found in Object Pascal in Delphi 4. unit SynHighlighterPas; {$I synedit.inc} +{$ModeSwitch advancedrecords} interface uses - SysUtils, Classes, Registry, Graphics, SynEditHighlighterFoldBase, + SysUtils, Classes, fgl, Registry, Graphics, SynEditHighlighterFoldBase, SynEditMiscProcs, SynEditTypes, SynEditHighlighter, SynEditTextBase, SynEditStrConst, SynEditMiscClasses, LazLoggerBase; @@ -63,6 +64,7 @@ type TtkTokenKind = (tkAsm, tkComment, tkIdentifier, tkKey, tkModifier, tkNull, tkNumber, tkSpace, tkString, tkSymbol, tkDirective, tkIDEDirective, tkUnknown); + TtkTokenKinds= set of TtkTokenKind; TRangeState = ( rsAnsiMultiDQ, // Multi line double quoted string @@ -306,6 +308,30 @@ const type + { TSynPasSynCustomToken } + + TSynPasSynCustomToken = class + private + FOnChange: TNotifyEvent; + FOnMarkupChange: TNotifyEvent; + procedure DoMarkupChaged(Sender: TObject); + procedure DoTokensChanged(Sender: TObject); + private + FMarkup: TSynHighlighterAttributesModifier; + FMatchTokenKinds: TtkTokenKinds; + FTokens: TStrings; + + procedure SetMatchTokenKinds(AValue: TtkTokenKinds); + property OnChange: TNotifyEvent read FOnChange write FOnChange; + property OnMarkupChange: TNotifyEvent read FOnMarkupChange write FOnMarkupChange; + public + constructor Create; + destructor Destroy; override; + property MatchTokenKinds: TtkTokenKinds read FMatchTokenKinds write SetMatchTokenKinds; + property Tokens: TStrings read FTokens; + property Markup: TSynHighlighterAttributesModifier read FMarkup; + end; + TSynPasRangeInfo = record EndLevelIfDef: Smallint; MinLevelIfDef: Smallint; @@ -364,7 +390,29 @@ type { TSynPasSyn } TSynPasSyn = class(TSynCustomFoldHighlighter) + private type + + { TSynPasSynCustomTokenInfo } + + TSynPasSynCustomTokenInfo = record + MatchTokenKinds: TtkTokenKinds; + Word: String; + Token: TSynPasSynCustomToken; + class operator = (a, b: TSynPasSynCustomTokenInfo): boolean; + end; + PSynPasSynCustomTokenInfo = ^TSynPasSynCustomTokenInfo; + PPSynPasSynCustomTokenInfo = ^PSynPasSynCustomTokenInfo; + TSynPasSynCustomTokenInfoList = specialize TFPGList; private + FSynCustomTokens: array of TSynPasSynCustomToken; + FNeedCustomTokenBuild: boolean; + FCustomTokenInfo: array [byte] of record + MatchTokenKinds: TtkTokenKinds; + List: TSynPasSynCustomTokenInfoList; + end; + FCustomTokenMarkup: TSynHighlighterAttributesModifier; + FCustomTokenMergedMarkup: TSynSelectedColorMergeResult; + fAsmStart: Boolean; FExtendedKeywordsMode: Boolean; FNestedComments: boolean; @@ -396,6 +444,7 @@ type fIdentFuncTable: array[0..220] of TIdentFuncTableFunc; fTokenPos: Integer;// start of current token in fLine FTokenID: TtkTokenKind; + FTokenHashKey: Integer; FTokenFlags: set of (tfProcName); FTokenIsCaseLabel: Boolean; fStringAttri: TSynHighlighterAttributes; @@ -418,6 +467,11 @@ type // Divider FDividerDrawConfig: Array [TSynPasDividerDrawLocation] of TSynDividerDrawConfig; + procedure DoCustomTokenChanged(Sender: TObject); + procedure RebuildCustomTokenInfo; + function GetCustomTokenCount: integer; + procedure SetCustomTokenCount(AValue: integer); + function GetCustomTokens(AnIndex: integer): TSynPasSynCustomToken; function GetPasCodeFoldRange: TSynPasSynRange; procedure PasDocAttrChanged(Sender: TObject); procedure SetCompilerMode(const AValue: TPascalCompilerMode); @@ -669,6 +723,8 @@ type function FoldLineLength(ALineIndex, FoldIndex: Integer): integer; override; // accesses FoldNodeInfo function FoldEndLine(ALineIndex, FoldIndex: Integer): integer; override; // accesses FoldNodeInfo + property CustomTokenCount: integer read GetCustomTokenCount write SetCustomTokenCount; + property CustomTokens[AnIndex: integer]: TSynPasSynCustomToken read GetCustomTokens; published property AsmAttri: TSynHighlighterAttributes read fAsmAttri write fAsmAttri; property CommentAttri: TSynHighlighterAttributes read fCommentAttri @@ -1109,6 +1165,75 @@ begin Result := TSynPasSynRange(CodeFoldRange); end; +function TSynPasSyn.GetCustomTokenCount: integer; +begin + Result := Length(FSynCustomTokens); +end; + +procedure TSynPasSyn.DoCustomTokenChanged(Sender: TObject); +begin + FNeedCustomTokenBuild := True; +end; + +procedure TSynPasSyn.RebuildCustomTokenInfo; +var + i, j, h: Integer; + ti: TSynPasSynCustomTokenInfo; + t: String; +begin + FNeedCustomTokenBuild := False; + for i := 0 to 255 do begin + FreeAndNil(FCustomTokenInfo[i].List); + FCustomTokenInfo[i].MatchTokenKinds := []; + end; + for i := 0 to Length(FSynCustomTokens) - 1 do begin + for j := 0 to FSynCustomTokens[i].FTokens.Count - 1 do begin + if FSynCustomTokens[i].MatchTokenKinds = [] then + continue; + t := FSynCustomTokens[i].FTokens[j]; + if t = '' then + continue; + fLine := PChar(t); + fLineLen := Length(t); + fToIdent := 0; + h := KeyHash and 255; + + if FCustomTokenInfo[h].List = nil then + FCustomTokenInfo[h].List := TSynPasSynCustomTokenInfoList.Create; + + ti.MatchTokenKinds := FSynCustomTokens[i].MatchTokenKinds; + ti.Word := UpperCase(t); + ti.Token := FSynCustomTokens[i]; + FCustomTokenInfo[h].MatchTokenKinds := FCustomTokenInfo[h].MatchTokenKinds + FSynCustomTokens[i].MatchTokenKinds; + FCustomTokenInfo[h].List.Add(ti); + end; + end; +end; + +procedure TSynPasSyn.SetCustomTokenCount(AValue: integer); +var + l: SizeInt; + i: Integer; +begin + l := Length(FSynCustomTokens); + if AValue = l then + exit; + + for i := AValue to l - 1 do + FSynCustomTokens[i].Free; + SetLength(FSynCustomTokens, AValue); + for i := l to AValue - 1 do begin + FSynCustomTokens[i] := TSynPasSynCustomToken.Create; + FSynCustomTokens[i].OnMarkupChange := @DefHighlightChange; + FSynCustomTokens[i].OnChange := @DoCustomTokenChanged; + end; +end; + +function TSynPasSyn.GetCustomTokens(AnIndex: integer): TSynPasSynCustomToken; +begin + Result := FSynCustomTokens[AnIndex]; +end; + procedure TSynPasSyn.PasDocAttrChanged(Sender: TObject); begin FUsePasDoc := fPasDocKeyWordAttri.IsEnabled or @@ -3157,13 +3282,11 @@ begin end; function TSynPasSyn.IdentKind(p: integer): TtkTokenKind; -var - HashKey: Integer; begin fToIdent := p; - HashKey := KeyHash; - if HashKey <= High(fIdentFuncTable) then - Result := fIdentFuncTable[HashKey]() + FTokenHashKey := KeyHash; + if FTokenHashKey <= High(fIdentFuncTable) then + Result := fIdentFuncTable[FTokenHashKey]() else Result := tkIdentifier; end; @@ -3270,6 +3393,8 @@ begin FCurPasDocAttri := TSynSelectedColorMergeResult.Create(@SYNS_AttrCaseLabel, SYNS_XML_AttrCaseLabel); FPasDocWordList := TStringList.Create; + FCustomTokenMergedMarkup := TSynSelectedColorMergeResult.Create; + CompilerMode:=pcmDelphi; SetAttributesOnChange(@DefHighlightChange); fPasDocKeyWordAttri.OnChange := @PasDocAttrChanged; @@ -3285,13 +3410,19 @@ begin end; { Create } destructor TSynPasSyn.Destroy; +var + i: Integer; begin DestroyDividerDrawConfig; FreeAndNil(FCurCaseLabelAttri); FreeAndNil(FCurIDEDirectiveAttri); FreeAndNil(FCurProcedureHeaderNameAttr); FreeAndNil(FCurPasDocAttri); + FreeAndNil(FCustomTokenMergedMarkup); FreeAndNil(FPasDocWordList); + CustomTokenCount := 0; + for i := 0 to 255 do + FCustomTokenInfo[i].List.Free; inherited Destroy; end; @@ -3311,6 +3442,9 @@ end; procedure TSynPasSyn.SetLine(const NewValue: string; LineNumber:Integer); begin //DebugLn(['TSynPasSyn.SetLine START LineNumber=',LineNumber,' Line="',NewValue,'"']); + if FNeedCustomTokenBuild then + RebuildCustomTokenInfo; + fLineStr := NewValue; fLineLen:=length(fLineStr); fLine:=PChar(Pointer(fLineStr)); @@ -4243,7 +4377,10 @@ end; procedure TSynPasSyn.Next; var IsAtCaseLabel: Boolean; - OldNestLevel: Integer; + OldNestLevel, i: Integer; + CustTk: TSynPasSynCustomTokenInfoList; + CustTkList: PPSynPasSynCustomTokenInfo; + UpperTk: String; begin fAsmStart := False; FIsPasDocKey := False; @@ -4251,6 +4388,7 @@ begin FIsPasUnknown := False; FTokenIsCaseLabel := False; fTokenPos := Run; + FCustomTokenMarkup := nil; if Run>=fLineLen then begin NullProc; exit; @@ -4284,8 +4422,28 @@ begin IsAtCaseLabel := rsAtCaseLabel in fRange; + FTokenHashKey := 0; fProcTable[fLine[Run]]; + if FTokenID in FCustomTokenInfo[FTokenHashKey and 255].MatchTokenKinds then begin + CustTk := FCustomTokenInfo[FTokenHashKey and 255].List; + if CustTk <> nil then begin + UpperTk := ''; + CustTkList := CustTk.List; + for i := 0 to CustTk.Count - 1 do begin + if (FTokenID in CustTkList^^.MatchTokenKinds) then begin + if UpperTk = '' then + UpperTk := UpperCase(GetToken); + if (UpperTk = CustTkList^^.Word) then begin + FCustomTokenMarkup := CustTkList^^.Token.FMarkup; + break; + end + end; + inc(CustTkList); + end; + end; + end; + if (FTokenID = tkIdentifier) and (FTokenState = tsAtProcName) then begin if rsInProcHeader in fRange then FTokenFlags := FTokenFlags + [tfProcName]; @@ -4455,6 +4613,12 @@ begin FCurProcedureHeaderNameAttr.Merge(FProcedureHeaderNameAttr); Result := FCurProcedureHeaderNameAttr; end; + + if FCustomTokenMarkup <> nil then begin + FCustomTokenMergedMarkup.Assign(Result); + FCustomTokenMergedMarkup.Merge(FCustomTokenMarkup); + Result := FCustomTokenMergedMarkup; + end; end; function TSynPasSyn.GetTokenKind: integer; @@ -5774,6 +5938,15 @@ begin FD4syntax := Value; end; +{ TSynPasSyn.TSynPasSynCustomTokenInfo } + +class operator TSynPasSyn.TSynPasSynCustomTokenInfo. = (a, b: TSynPasSynCustomTokenInfo): boolean; +begin + Result := (a.MatchTokenKinds = b.MatchTokenKinds) and + (a.Token = b.Token) and + (a.Word = b.Word); +end; + { TSynFreePascalSyn } constructor TSynFreePascalSyn.Create(AOwner: TComponent); @@ -5859,6 +6032,43 @@ begin dec(FPasFoldFixLevel); end; +{ TSynPasSynCustomToken } + +procedure TSynPasSynCustomToken.DoTokensChanged(Sender: TObject); +begin + if FOnChange <> nil then + FOnChange(Self); +end; + +procedure TSynPasSynCustomToken.SetMatchTokenKinds(AValue: TtkTokenKinds); +begin + if FMatchTokenKinds = AValue then Exit; + FMatchTokenKinds := AValue; + DoTokensChanged(Self); +end; + +procedure TSynPasSynCustomToken.DoMarkupChaged(Sender: TObject); +begin + if FOnMarkupChange <> nil then + FOnMarkupChange(Self); +end; + +constructor TSynPasSynCustomToken.Create; +begin + FMarkup := TSynHighlighterAttributesModifier.Create; + FMarkup.OnChange := @DoMarkupChaged; + FTokens := TStringList.Create; + TStringList(FTokens).OnChange := @DoTokensChanged; + FMatchTokenKinds := []; +end; + +destructor TSynPasSynCustomToken.Destroy; +begin + inherited Destroy; + FMarkup.Free; + FTokens.Free; +end; + { TSynHighlighterPasRangeList } function TSynHighlighterPasRangeList.GetTSynPasRangeInfo(Index: Integer): TSynPasRangeInfo; diff --git a/ide/editoroptions.pp b/ide/editoroptions.pp index af8212e2ef..474c90f1d4 100644 --- a/ide/editoroptions.pp +++ b/ide/editoroptions.pp @@ -100,7 +100,8 @@ type ( hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafStyle, hafStyleMask, hafFrameStyle, hafFrameEdges, - hafMarkupFoldColor // for the MarkupFoldColor module + hafMarkupFoldColor, // for the MarkupFoldColor module + hafCustomWords ); TColorSchemeAttributeFeatures = set of TColorSchemeAttributeFeature; @@ -283,7 +284,7 @@ type { TColorSchemeAttribute } - TColorSchemeAttribute = class(TSynHighlighterAttributesModifier) + TColorSchemeAttribute = class(TSynHighlighterLazCustumPasAttribute) private FFeatures: TColorSchemeAttributeFeatures; FGroup: TAhaGroupName; @@ -6985,6 +6986,10 @@ begin TSynHighlighterAttributesModifier(aDest).ForeAlpha := Src.ForeAlpha; TSynHighlighterAttributesModifier(aDest).BackAlpha := Src.BackAlpha; TSynHighlighterAttributesModifier(aDest).FrameAlpha := Src.FrameAlpha; + if aDest is TSynHighlighterLazCustumPasAttribute then begin + TSynHighlighterLazCustumPasAttribute(aDest).CustomWords.Assign(CustomWords); + TSynHighlighterLazCustumPasAttribute(aDest).CustomWordTokenKind := CustomWordTokenKind; + end; end; if hafPrior in Src.Features then begin @@ -7026,6 +7031,8 @@ begin inherited Assign(Src); FFeatures := [hafBackColor, hafForeColor, hafFrameColor, hafStyle, hafFrameStyle, hafFrameEdges, hafPrior]; + if Src is TSynHighlighterLazCustumPasAttribute then + FFeatures := FFeatures + [hafCustomWords]; if Src is TSynHighlighterAttributesModifier then FFeatures := FFeatures + [hafAlpha, hafStyleMask]; @@ -7103,8 +7110,10 @@ begin Assert(Version > 4, 'TColorSchemeAttribute.LoadFromXml: Version ('+IntToStr(Version)+' < 5.'); if StoredName = '' then exit; Path := aPath + StrToValidXMLName(StoredName) + '/'; - if aXMLConfig.HasPath(Path, False) then - aXMLConfig.ReadObject(Path, Self, Defaults) + if aXMLConfig.HasPath(Path, False) then begin + aXMLConfig.ReadObject(Path, Self, Defaults); + CustomWords.Text := aXMLConfig.GetValue(Path+'CustomWords', ''); + end else begin if (Defaults <> Self) and (Defaults <> nil) then begin // do not copy (Stored)Name or Features ... @@ -7122,14 +7131,16 @@ begin BoldPriority := Defaults.BoldPriority; ItalicPriority := Defaults.ItalicPriority; UnderlinePriority := Defaults.UnderlinePriority; + CustomWords.Text := Defaults.CustomWords.Text; end; end; end; -procedure TColorSchemeAttribute.SaveToXml(aXMLConfig: TRttiXMLConfig; - const aPath: String; Defaults: TColorSchemeAttribute); +procedure TColorSchemeAttribute.SaveToXml(aXMLConfig: TRttiXMLConfig; const aPath: String; + Defaults: TColorSchemeAttribute); var AttriName: String; + Path: String; begin if StoredName = '' then exit; @@ -7138,7 +7149,9 @@ begin if AttriName <> '' then aXMLConfig.DeletePath(aPath + StrToValidXMLName(AttriName)); - aXMLConfig.WriteObject(aPath + StrToValidXMLName(StoredName) + '/', Self, Defaults); + Path := aPath + StrToValidXMLName(StoredName) + '/'; + aXMLConfig.WriteObject(Path, Self, Defaults); + aXMLConfig.SetDeleteValue(Path + 'CustomWords', CustomWords.Text, ''); end; { TColorSchemeLanguage } @@ -7258,6 +7271,9 @@ begin csa.Assign(hla); csa.Group := agnLanguage; if (FHighlighter <> nil) and (FHighlighter is TNonSrcIDEHighlighter) then + if hla is TSynHighlighterLazCustumPasAttribute then + csa.Features := [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafStyle, hafStyleMask, hafCustomWords] + else if hla is TSynHighlighterAttributesModifier then csa.Features := [hafBackColor, hafForeColor, hafFrameColor, hafAlpha, hafPrior, hafStyle, hafStyleMask] else diff --git a/ide/frames/editor_color_options.pas b/ide/frames/editor_color_options.pas index 01376b808e..8cc70727fe 100644 --- a/ide/frames/editor_color_options.pas +++ b/ide/frames/editor_color_options.pas @@ -1176,11 +1176,18 @@ begin agnDefault, // continue; // default is currently not shown agnLanguage: begin - if FIsEditingDefaults then - ParentName := AdditionalHighlightGroupNames[agnDefault] - else - ParentName := FCurrentHighlighter.LanguageName; ParentNode := ColorElementTree.Items.GetFirstNode; + if FIsEditingDefaults then begin + ParentName := AdditionalHighlightGroupNames[agnDefault]; + end + else + if hafCustomWords in Attr.Features then begin + ParentName := FCurrentHighlighter.LanguageName + ' (Custom)'; + ParentNode := ColorElementTree.Items.FindTopLvlNode(ParentName); + end + else begin + ParentName := FCurrentHighlighter.LanguageName; + end; end; else begin diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index a7ca74a79c..e9a258b39e 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -6291,6 +6291,9 @@ resourcestring optDispGutterNoCurrentLineColor = 'No current line color'; optDispGutterUseCurrentLineColor = 'Use current line color'; optDispGutterUseCurrentLineNumberColor = 'Use current line number color'; + dlgMatchWords = 'Match words'; + dlgKeyWord = 'KeyWord'; + dlgModifier = 'Modifier'; implementation diff --git a/ide/sourcesyneditor.pas b/ide/sourcesyneditor.pas index 1aa0d9906a..47a8091dc9 100644 --- a/ide/sourcesyneditor.pas +++ b/ide/sourcesyneditor.pas @@ -331,10 +331,32 @@ type FInitializationLine, FFinalizationLine: Integer; end; + { TSynHighlighterLazCustumPasAttribute } + + TSynHighlighterLazCustumPasAttribute = class(TSynHighlighterAttributesModifier) + private + FCustomWords: TStrings; + FCustomWordTokenKind: TtkTokenKind; + procedure DoWordsChanged(Sender: TObject); + procedure SetCustomWordTokenKind(AValue: TtkTokenKind); + protected + procedure AssignFrom(Src: TLazSynCustomTextAttributes); override; + procedure DoClear; override; + procedure Init; override; + public + destructor Destroy; override; + property CustomWords: TStrings read FCustomWords; + published + property CustomWordTokenKind: TtkTokenKind read FCustomWordTokenKind write SetCustomWordTokenKind; + end; + { TIDESynPasSyn } TIDESynPasSyn = class(TSynPasSyn) private + FCustomAttribs: array[0..9] of TSynHighlighterLazCustumPasAttribute; + + procedure DoBuildCustomPasAttr(Sender: TObject); function GetFinalizationLine: Integer; function GetImplementationLine: Integer; function GetInitializationLine: Integer; @@ -345,6 +367,10 @@ type IncreaseLevel: Boolean = true; ForceDisabled: Boolean = False ): TSynCustomCodeFoldBlock; override; public + constructor Create(AOwner: TComponent); override; + //procedure DefHighlightChange(Sender: TObject); + + procedure SetLine({$IFDEF FPC}const {$ENDIF}NewValue: string; LineNumber: Integer); override; property InterfaceLine: Integer read GetInterfaceLine; @@ -1925,11 +1951,86 @@ begin Ime.InvalidateLinesMethod := @InvalidateLines; ImeHandler := Ime; end; - {$ENDIF} +{ TSynHighlighterLazCustumPasAttribute } + +procedure TSynHighlighterLazCustumPasAttribute.SetCustomWordTokenKind(AValue: TtkTokenKind); +begin + if FCustomWordTokenKind = AValue then Exit; + FCustomWordTokenKind := AValue; + Changed; +end; + +procedure TSynHighlighterLazCustumPasAttribute.DoWordsChanged(Sender: TObject); +begin + Changed; +end; + +procedure TSynHighlighterLazCustumPasAttribute.AssignFrom(Src: TLazSynCustomTextAttributes); +begin + inherited AssignFrom(Src); + if Src is TSynHighlighterLazCustumPasAttribute then begin + FCustomWords.Assign(TSynHighlighterLazCustumPasAttribute(Src).FCustomWords); + FCustomWordTokenKind := TSynHighlighterLazCustumPasAttribute(Src).FCustomWordTokenKind; + end + else begin + FCustomWords.Clear; + FCustomWordTokenKind := tkIdentifier; + end; +end; + +procedure TSynHighlighterLazCustumPasAttribute.DoClear; +begin + inherited DoClear; + if FCustomWords <> nil then + FCustomWords.Clear; + FCustomWordTokenKind := tkIdentifier; +end; + +procedure TSynHighlighterLazCustumPasAttribute.Init; +begin + FCustomWords := TStringList.Create; + FCustomWordTokenKind := tkIdentifier; + TStringList(FCustomWords).OnChange := @DoWordsChanged; + inherited Init; +end; + +destructor TSynHighlighterLazCustumPasAttribute.Destroy; +begin + inherited Destroy; + FCustomWords.Destroy; +end; + { TIDESynPasSyn } +procedure TIDESynPasSyn.DoBuildCustomPasAttr(Sender: TObject); +var + c, i: Integer; +begin + c := 0; + for i := 0 to 9 do + if FCustomAttribs[i].IsEnabled and + (trim(FCustomAttribs[i].CustomWords.Text) <> '') + then + inc(c); + + CustomTokenCount := c; + c := 0; + for i := 0 to 9 do + if FCustomAttribs[i].IsEnabled and + (trim(FCustomAttribs[i].CustomWords.Text) <> '') + then begin + CustomTokens[c].Markup.Assign(FCustomAttribs[i]); + CustomTokens[c].MatchTokenKinds := [FCustomAttribs[i].CustomWordTokenKind]; + CustomTokens[c].Tokens.Assign(FCustomAttribs[i].CustomWords); + inc(c); + end; + + + DefHighlightChange(Sender); +end; + function TIDESynPasSyn.GetFinalizationLine: Integer; begin Result := TIDESynHighlighterPasRangeList(CurrentRanges).FFinalizationLine; @@ -1977,6 +2078,19 @@ begin Result := inherited; end; +constructor TIDESynPasSyn.Create(AOwner: TComponent); +var + i: Integer; +begin + inherited Create(AOwner); + + for i := 0 to 9 do begin + FCustomAttribs[i] := TSynHighlighterLazCustumPasAttribute.Create('Custom '+IntToStr(i), 'CustomToken_'+IntToStr(i)); + AddAttribute(FCustomAttribs[i]); + FCustomAttribs[i].OnChange := @DoBuildCustomPasAttr; + end; +end; + procedure TIDESynPasSyn.SetLine(const NewValue: string; LineNumber: Integer); begin if assigned(CurrentRanges) then begin diff --git a/ide/syncolorattribeditor.lfm b/ide/syncolorattribeditor.lfm index 3ec34ca64c..86041a1442 100644 --- a/ide/syncolorattribeditor.lfm +++ b/ide/syncolorattribeditor.lfm @@ -1,160 +1,715 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 0 - Height = 207 + Height = 197 Top = 0 - Width = 758 - ClientHeight = 207 - ClientWidth = 758 + Width = 1292 + AutoSize = True + ClientHeight = 197 + ClientWidth = 1292 Constraints.MinHeight = 140 - OnResize = pnlElementAttributesResize TabOrder = 0 - DesignLeft = 399 - DesignTop = 181 - object ForeGroundLabel: TLabel - AnchorSideTop.Control = ForegroundColorBox - AnchorSideTop.Side = asrCenter - Left = 6 - Height = 15 - Top = 7 - Width = 91 - BorderSpacing.Left = 6 - Caption = 'ForeGroundLabel' - ParentColor = False - Visible = False - OnResize = pnlElementAttributesResize - end - object BackGroundLabel: TLabel - AnchorSideTop.Control = BackGroundColorBox - AnchorSideTop.Side = asrCenter - Left = 6 - Height = 15 - Top = 32 - Width = 93 - BorderSpacing.Left = 6 - Caption = 'BackGroundLabel' - ParentColor = False - Visible = False - OnResize = pnlElementAttributesResize - end - object ForeGroundUseDefaultCheckBox: TCheckBox + OnResize = pnlElementAttributesResize + DesignLeft = 628 + DesignTop = 221 + object Panel1: TPanel AnchorSideLeft.Control = Owner - AnchorSideTop.Control = ForegroundColorBox - AnchorSideTop.Side = asrCenter - Left = 6 - Height = 19 - Top = 5 - Width = 192 - BorderSpacing.Left = 6 - Caption = 'ForeGroundUseDefaultCheckBox' - OnChange = GeneralCheckBoxOnChange - OnResize = pnlElementAttributesResize - TabOrder = 0 - end - object ForegroundColorBox: TColorBox - AnchorSideLeft.Control = ColumnPosBevel AnchorSideTop.Control = Owner - AnchorSideRight.Side = asrBottom - Left = 204 - Height = 22 - Top = 3 - Width = 200 - DefaultColorColor = clWhite - Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors] - OnGetColors = GeneralColorBoxOnGetColors - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 3 - Constraints.MaxWidth = 200 - Constraints.MinWidth = 80 - ItemHeight = 16 - OnChange = GeneralColorBoxOnChange - TabOrder = 1 - end - object BackGroundColorBox: TColorBox - AnchorSideLeft.Control = ColumnPosBevel - AnchorSideTop.Control = ForegroundColorBox - AnchorSideTop.Side = asrBottom - AnchorSideRight.Side = asrBottom - Left = 204 - Height = 22 - Top = 28 - Width = 200 - DefaultColorColor = clWhite - Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors] - OnGetColors = GeneralColorBoxOnGetColors - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 3 - Constraints.MaxWidth = 200 - Constraints.MinWidth = 80 - ItemHeight = 16 - OnChange = GeneralColorBoxOnChange - TabOrder = 4 - end - object BackGroundUseDefaultCheckBox: TCheckBox - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = BackGroundColorBox - AnchorSideTop.Side = asrCenter - AnchorSideRight.Side = asrBottom - Left = 6 - Height = 19 - Top = 30 - Width = 194 - BorderSpacing.Left = 6 - Caption = 'BackGroundUseDefaultCheckBox' - OnChange = GeneralCheckBoxOnChange - OnResize = pnlElementAttributesResize + Left = 0 + Height = 131 + Top = 0 + Width = 916 + AutoSize = True + BevelOuter = bvNone + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 3 + ChildSizing.HorizontalSpacing = 3 + ChildSizing.VerticalSpacing = 3 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 7 + ClientHeight = 131 + ClientWidth = 916 TabOrder = 3 - end - object FrameColorBox: TColorBox - AnchorSideLeft.Control = ColumnPosBevel - AnchorSideTop.Control = BackGroundColorBox - AnchorSideTop.Side = asrBottom - AnchorSideRight.Side = asrBottom - Left = 204 - Height = 22 - Top = 53 - Width = 200 - DefaultColorColor = clWhite - Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors] - OnGetColors = GeneralColorBoxOnGetColors - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 3 - Constraints.MaxWidth = 200 - Constraints.MinWidth = 80 - ItemHeight = 16 - OnChange = GeneralColorBoxOnChange - TabOrder = 7 - end - object FrameColorUseDefaultCheckBox: TCheckBox - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = FrameColorBox - AnchorSideTop.Side = asrCenter - AnchorSideRight.Side = asrBottom - Left = 6 - Height = 19 - Top = 55 - Width = 191 - BorderSpacing.Left = 6 - Caption = 'FrameColorUseDefaultCheckBox' - OnChange = GeneralCheckBoxOnChange - OnResize = pnlElementAttributesResize - TabOrder = 6 + object pnlForegroundName: TPanel + Left = 6 + Height = 23 + Top = 3 + Width = 221 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 221 + TabOrder = 0 + object ForeGroundUseDefaultCheckBox: TCheckBox + Left = 0 + Height = 19 + Top = 0 + Width = 191 + Caption = 'ForeGroundUseDefaultCheckBox' + TabOrder = 0 + OnChange = GeneralCheckBoxOnChange + end + object ForeGroundLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 91 + Caption = 'ForeGroundLabel' + ParentColor = False + Visible = False + end + end + object Panel2: TPanel + Left = 230 + Height = 23 + Top = 3 + Width = 203 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 203 + TabOrder = 4 + object ForegroundColorBox: TColorBox + Left = 0 + Height = 22 + Top = 0 + Width = 200 + DefaultColorColor = clWhite + Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors] + OnGetColors = GeneralColorBoxOnGetColors + Constraints.MaxWidth = 200 + Constraints.MinWidth = 80 + ItemHeight = 16 + TabOrder = 0 + OnChange = GeneralColorBoxOnChange + end + end + object Panel3: TPanel + Left = 436 + Height = 23 + Top = 3 + Width = 123 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 123 + TabOrder = 5 + object ForeAlphaLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 82 + Caption = 'ForeAlphaLabel' + ParentColor = False + end + end + object Panel4: TPanel + Left = 562 + Height = 23 + Top = 3 + Width = 65 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 65 + TabOrder = 6 + object ForeAlphaSpin: TSpinEdit + Left = 0 + Height = 23 + Top = 0 + Width = 65 + Constraints.MinWidth = 65 + MaxValue = 256 + MinValue = 1 + TabOrder = 0 + Value = 256 + OnChange = GeneralAlphaSpinOnChange + OnEditingDone = GeneralAlphaSpinOnChange + OnEnter = GeneralAlphaSpinOnEnter + OnExit = GeneralAlphaSpinOnChange + OnResize = GeneralAlphaSpinOnChange + end + end + object Panel5: TPanel + Left = 630 + Height = 23 + Top = 3 + Width = 86 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 86 + TabOrder = 7 + object ForePriorLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 76 + Caption = 'ForePriorLabel' + ParentColor = False + end + end + object Panel6: TPanel + Left = 719 + Height = 23 + Top = 3 + Width = 65 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 65 + TabOrder = 8 + object ForePriorSpin: TSpinEdit + Left = 0 + Height = 23 + Top = 0 + Width = 65 + Constraints.MinWidth = 65 + MaxValue = 9999 + TabOrder = 0 + Value = 1 + OnChange = GeneralPriorSpinOnChange + OnEditingDone = GeneralPriorSpinOnChange + OnExit = GeneralPriorSpinOnChange + end + end + object lbFiller1: TLabel + Left = 787 + Height = 23 + Top = 3 + Width = 123 + end + object pnlBackgroundName: TPanel + Left = 6 + Height = 23 + Top = 29 + Width = 221 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 221 + TabOrder = 1 + object BackGroundUseDefaultCheckBox: TCheckBox + Left = 0 + Height = 19 + Top = 0 + Width = 193 + Caption = 'BackGroundUseDefaultCheckBox' + TabOrder = 0 + OnChange = GeneralCheckBoxOnChange + end + object BackGroundLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 93 + Caption = 'BackGroundLabel' + ParentColor = False + Visible = False + end + end + object Panel7: TPanel + Left = 230 + Height = 23 + Top = 29 + Width = 203 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 203 + TabOrder = 9 + object BackGroundColorBox: TColorBox + Left = 0 + Height = 22 + Top = 0 + Width = 200 + DefaultColorColor = clWhite + Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors] + OnGetColors = GeneralColorBoxOnGetColors + Constraints.MaxWidth = 200 + Constraints.MinWidth = 80 + ItemHeight = 16 + TabOrder = 0 + OnChange = GeneralColorBoxOnChange + end + end + object Panel8: TPanel + Left = 436 + Height = 23 + Top = 29 + Width = 123 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 123 + TabOrder = 10 + object BackAlphaLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 84 + Caption = 'BackAlphaLabel' + ParentColor = False + end + end + object Panel9: TPanel + Left = 562 + Height = 23 + Top = 29 + Width = 65 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 65 + TabOrder = 11 + object BackAlphaSpin: TSpinEdit + Left = 0 + Height = 23 + Top = 0 + Width = 65 + Constraints.MinWidth = 65 + MaxValue = 256 + MinValue = 1 + TabOrder = 0 + Value = 256 + OnChange = GeneralAlphaSpinOnChange + OnEditingDone = GeneralAlphaSpinOnChange + OnEnter = GeneralAlphaSpinOnEnter + OnExit = GeneralAlphaSpinOnChange + OnResize = GeneralAlphaSpinOnChange + end + end + object Panel10: TPanel + Left = 630 + Height = 23 + Top = 29 + Width = 86 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 86 + TabOrder = 12 + object BackPriorLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 78 + Caption = 'BackPriorLabel' + ParentColor = False + end + end + object Panel11: TPanel + Left = 719 + Height = 23 + Top = 29 + Width = 65 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 65 + TabOrder = 13 + object BackPriorSpin: TSpinEdit + Left = 0 + Height = 23 + Top = 0 + Width = 65 + Constraints.MinWidth = 65 + MaxValue = 9999 + TabOrder = 0 + Value = 1 + OnChange = GeneralPriorSpinOnChange + OnEditingDone = GeneralPriorSpinOnChange + OnExit = GeneralPriorSpinOnChange + end + end + object lbFiller2: TLabel + Left = 787 + Height = 23 + Top = 29 + Width = 123 + end + object Panel12: TPanel + Left = 6 + Height = 23 + Top = 55 + Width = 221 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 221 + TabOrder = 14 + object FrameColorUseDefaultCheckBox: TCheckBox + Left = 0 + Height = 19 + Top = 0 + Width = 190 + Caption = 'FrameColorUseDefaultCheckBox' + TabOrder = 0 + OnChange = GeneralCheckBoxOnChange + end + end + object Panel13: TPanel + Left = 230 + Height = 23 + Top = 55 + Width = 203 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 203 + TabOrder = 15 + object FrameColorBox: TColorBox + Left = 0 + Height = 22 + Top = 0 + Width = 200 + DefaultColorColor = clWhite + Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors] + OnGetColors = GeneralColorBoxOnGetColors + Constraints.MaxWidth = 200 + Constraints.MinWidth = 80 + ItemHeight = 16 + TabOrder = 0 + OnChange = GeneralColorBoxOnChange + end + end + object Panel14: TPanel + Left = 436 + Height = 23 + Top = 55 + Width = 123 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 123 + TabOrder = 16 + object FrameAlphaLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 92 + Caption = 'FrameAlphaLabel' + ParentColor = False + end + end + object Panel15: TPanel + Left = 562 + Height = 23 + Top = 55 + Width = 65 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 65 + TabOrder = 17 + object FrameAlphaSpin: TSpinEdit + Left = 0 + Height = 23 + Top = 0 + Width = 65 + Constraints.MinWidth = 65 + MaxValue = 256 + MinValue = 1 + TabOrder = 0 + Value = 256 + OnChange = GeneralAlphaSpinOnChange + OnEditingDone = GeneralAlphaSpinOnChange + OnEnter = GeneralAlphaSpinOnEnter + OnExit = GeneralAlphaSpinOnChange + OnResize = GeneralAlphaSpinOnChange + end + end + object Panel16: TPanel + Left = 630 + Height = 23 + Top = 55 + Width = 86 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 86 + TabOrder = 18 + object FramePriorLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 86 + Caption = 'FramePriorLabel' + ParentColor = False + end + end + object Panel17: TPanel + Left = 719 + Height = 23 + Top = 55 + Width = 65 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 65 + TabOrder = 19 + object FramePriorSpin: TSpinEdit + Left = 0 + Height = 23 + Top = 0 + Width = 65 + Constraints.MinWidth = 65 + MaxValue = 9999 + TabOrder = 0 + Value = 1 + OnChange = GeneralPriorSpinOnChange + OnEditingDone = GeneralPriorSpinOnChange + OnExit = GeneralPriorSpinOnChange + end + end + object pnlFrameHost1: TPanel + Left = 787 + Height = 23 + Top = 55 + Width = 123 + AutoSize = True + BevelOuter = bvNone + ChildSizing.HorizontalSpacing = 3 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 2 + TabOrder = 2 + end + object lbFiller3: TLabel + Left = 6 + Height = 21 + Top = 81 + Width = 221 + end + object pnlFrameHost2: TPanel + Left = 230 + Height = 21 + Top = 81 + Width = 203 + BevelOuter = bvNone + ChildSizing.HorizontalSpacing = 3 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 2 + ClientHeight = 21 + ClientWidth = 203 + TabOrder = 3 + object FrameStyleBox: TComboBox + Left = 0 + Height = 21 + Top = 0 + Width = 100 + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'slsSolid' + 'slsDashed' + 'slsDotted' + 'slsWaved' + ) + Style = csOwnerDrawFixed + TabOrder = 0 + Text = 'slsSolid' + OnChange = GeneralColorBoxOnChange + OnDrawItem = GeneralStyleBoxOnDrawItem + end + object FrameEdgesBox: TComboBox + Left = 103 + Height = 21 + Top = 0 + Width = 100 + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'Around' + 'Bottom' + 'Left' + ) + Style = csOwnerDrawFixed + TabOrder = 1 + Text = 'Around' + OnChange = GeneralColorBoxOnChange + OnDrawItem = FrameEdgesBoxDrawItem + end + end + object lbFiller4: TLabel + Left = 436 + Height = 21 + Top = 81 + Width = 123 + end + object lbFiller5: TLabel + Left = 562 + Height = 21 + Top = 81 + Width = 65 + end + object lbFiller6: TLabel + Left = 630 + Height = 21 + Top = 81 + Width = 86 + end + object lbFiller7: TLabel + Left = 719 + Height = 21 + Top = 81 + Width = 65 + end + object lbFiller8: TLabel + Left = 787 + Height = 21 + Top = 81 + Width = 123 + end + object Panel18: TPanel + Left = 6 + Height = 23 + Top = 105 + Width = 221 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 221 + TabOrder = 20 + object MarkupFoldColorUseDefaultCheckBox: TCheckBox + Left = 0 + Height = 19 + Top = 0 + Width = 221 + Caption = 'MarkupFoldColorUseDefaultCheckBox' + TabOrder = 0 + OnChange = GeneralCheckBoxOnChange + end + end + object Panel19: TPanel + Left = 230 + Height = 23 + Top = 105 + Width = 203 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 203 + TabOrder = 21 + object MarkupFoldColorBox: TColorBox + Left = 0 + Height = 22 + Top = 0 + Width = 100 + DefaultColorColor = clWhite + Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors] + OnGetColors = GeneralColorBoxOnGetColors + Constraints.MaxWidth = 200 + Constraints.MinWidth = 80 + ItemHeight = 16 + TabOrder = 0 + OnChange = GeneralColorBoxOnChange + end + end + object Panel20: TPanel + Left = 436 + Height = 23 + Top = 105 + Width = 123 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 123 + TabOrder = 22 + object MarkupFoldAlphaLabel: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 123 + Caption = 'MarkupFoldAlphaLabel' + ParentColor = False + end + end + object Panel21: TPanel + Left = 562 + Height = 23 + Top = 105 + Width = 65 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 65 + TabOrder = 23 + object MarkupFoldAlphaSpin: TSpinEdit + Left = 0 + Height = 23 + Top = 0 + Width = 65 + Constraints.MinWidth = 65 + MaxValue = 256 + MinValue = 1 + TabOrder = 0 + Value = 256 + OnChange = GeneralAlphaSpinOnChange + OnEditingDone = GeneralAlphaSpinOnChange + OnEnter = GeneralAlphaSpinOnEnter + OnExit = GeneralAlphaSpinOnChange + OnResize = GeneralAlphaSpinOnChange + end + end + object lbFiller9: TLabel + Left = 630 + Height = 23 + Top = 105 + Width = 86 + end + object lbFiller10: TLabel + Left = 719 + Height = 23 + Top = 105 + Width = 65 + end + object Panel22: TPanel + Left = 787 + Height = 23 + Top = 105 + Width = 123 + AutoSize = True + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 123 + TabOrder = 24 + object MarkupFoldStyleBox: TComboBox + Left = 0 + Height = 21 + Top = 0 + Width = 123 + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'slsSolid' + 'slsDashed' + 'slsDotted' + 'slsWaved' + ) + Style = csOwnerDrawFixed + TabOrder = 0 + Text = 'slsSolid' + OnChange = GeneralColorBoxOnChange + OnDrawItem = GeneralStyleBoxOnDrawItem + end + end end object pnlUnderline: TPanel AnchorSideLeft.Control = Owner - AnchorSideTop.Control = MarkupFoldColorBox + AnchorSideTop.Control = Panel1 AnchorSideTop.Side = asrBottom Left = 6 Height = 40 - Top = 127 - Width = 145 + Top = 134 + Width = 144 AutoSize = True BorderSpacing.Left = 6 BorderSpacing.Top = 3 BorderSpacing.Bottom = 3 BevelOuter = bvNone ClientHeight = 40 - ClientWidth = 145 - TabOrder = 11 + ClientWidth = 144 + TabOrder = 0 + OnResize = pnlElementAttributesResize object TextUnderlineRadioPanel: TPanel AnchorSideLeft.Control = TextUnderlineCheckBox AnchorSideTop.Control = TextUnderlineCheckBox @@ -163,12 +718,12 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 0 Height = 21 Top = 19 - Width = 134 + Width = 128 AutoSize = True BevelInner = bvLowered BevelOuter = bvNone ClientHeight = 21 - ClientWidth = 134 + ClientWidth = 128 TabOrder = 0 object TextUnderlineRadioOn: TRadioButton Tag = 3 @@ -178,14 +733,14 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 4 Height = 19 Top = 1 - Width = 36 + Width = 34 BorderSpacing.Left = 3 BorderSpacing.Right = 3 Caption = 'On' Checked = True - OnChange = TextStyleRadioOnChange TabOrder = 0 TabStop = True + OnChange = TextStyleRadioOnChange end object TextUnderlineRadioOff: TRadioButton Tag = 3 @@ -193,15 +748,15 @@ object SynColorAttrEditor: TSynColorAttrEditor AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = TextUnderlineRadioOn AnchorSideRight.Control = TextUnderlineRadioInvert - Left = 43 + Left = 41 Height = 19 Top = 1 - Width = 37 + Width = 35 BorderSpacing.Left = 3 BorderSpacing.Right = 3 Caption = 'Off' - OnChange = TextStyleRadioOnChange TabOrder = 1 + OnChange = TextStyleRadioOnChange end object TextUnderlineRadioInvert: TRadioButton Tag = 3 @@ -210,14 +765,14 @@ object SynColorAttrEditor: TSynColorAttrEditor AnchorSideTop.Control = TextUnderlineRadioPanel AnchorSideRight.Control = TextUnderlineRadioPanel AnchorSideRight.Side = asrBottom - Left = 83 + Left = 79 Height = 19 Top = 1 - Width = 50 + Width = 48 BorderSpacing.Left = 3 Caption = 'Invert' - OnChange = TextStyleRadioOnChange TabOrder = 2 + OnChange = TextStyleRadioOnChange end end object TextUnderlineCheckBox: TCheckBox @@ -226,26 +781,26 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 0 Height = 19 Top = 0 - Width = 145 + Width = 144 Caption = 'TextUnderlineCheckBox' - OnChange = GeneralCheckBoxOnChange TabOrder = 1 + OnChange = GeneralCheckBoxOnChange end end object pnlBold: TPanel AnchorSideLeft.Control = pnlUnderline AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = pnlUnderline - Left = 157 + Left = 156 Height = 40 - Top = 127 - Width = 134 + Top = 134 + Width = 128 AutoSize = True BorderSpacing.Left = 6 BevelOuter = bvNone ClientHeight = 40 - ClientWidth = 134 - TabOrder = 12 + ClientWidth = 128 + TabOrder = 1 object TextBoldRadioPanel: TPanel AnchorSideLeft.Control = TextBoldCheckBox AnchorSideTop.Control = TextBoldCheckBox @@ -254,12 +809,12 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 0 Height = 21 Top = 19 - Width = 134 + Width = 128 AutoSize = True BevelInner = bvLowered BevelOuter = bvNone ClientHeight = 21 - ClientWidth = 134 + ClientWidth = 128 TabOrder = 0 object TextBoldRadioInvert: TRadioButton Tag = 2 @@ -268,14 +823,14 @@ object SynColorAttrEditor: TSynColorAttrEditor AnchorSideTop.Control = TextBoldRadioPanel AnchorSideRight.Control = TextBoldRadioPanel AnchorSideRight.Side = asrBottom - Left = 83 + Left = 79 Height = 19 Top = 1 - Width = 50 + Width = 48 BorderSpacing.Left = 3 Caption = 'Invert' - OnChange = TextStyleRadioOnChange TabOrder = 2 + OnChange = TextStyleRadioOnChange end object TextBoldRadioOn: TRadioButton Tag = 2 @@ -285,14 +840,14 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 4 Height = 19 Top = 1 - Width = 36 + Width = 34 BorderSpacing.Left = 3 BorderSpacing.Right = 3 Caption = 'On' Checked = True - OnChange = TextStyleRadioOnChange TabOrder = 0 TabStop = True + OnChange = TextStyleRadioOnChange end object TextBoldRadioOff: TRadioButton Tag = 2 @@ -300,15 +855,15 @@ object SynColorAttrEditor: TSynColorAttrEditor AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = TextBoldRadioPanel AnchorSideRight.Control = TextBoldRadioInvert - Left = 43 + Left = 41 Height = 19 Top = 1 - Width = 37 + Width = 35 BorderSpacing.Left = 3 BorderSpacing.Right = 3 Caption = 'Off' - OnChange = TextStyleRadioOnChange TabOrder = 1 + OnChange = TextStyleRadioOnChange end end object TextBoldCheckBox: TCheckBox @@ -317,26 +872,26 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 0 Height = 19 Top = 0 - Width = 118 + Width = 117 Caption = 'TextBoldCheckBox' - OnChange = GeneralCheckBoxOnChange TabOrder = 1 + OnChange = GeneralCheckBoxOnChange end end object pnlItalic: TPanel AnchorSideLeft.Control = pnlBold AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = pnlUnderline - Left = 297 + Left = 290 Height = 40 - Top = 127 - Width = 134 + Top = 134 + Width = 128 AutoSize = True BorderSpacing.Left = 6 BevelOuter = bvNone ClientHeight = 40 - ClientWidth = 134 - TabOrder = 13 + ClientWidth = 128 + TabOrder = 2 object TextItalicRadioPanel: TPanel AnchorSideLeft.Control = TextItalicCheckBox AnchorSideTop.Control = TextItalicCheckBox @@ -345,12 +900,12 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 0 Height = 21 Top = 19 - Width = 134 + Width = 128 AutoSize = True BevelInner = bvLowered BevelOuter = bvNone ClientHeight = 21 - ClientWidth = 134 + ClientWidth = 128 TabOrder = 0 object TextItalicRadioInvert: TRadioButton Tag = 2 @@ -359,14 +914,14 @@ object SynColorAttrEditor: TSynColorAttrEditor AnchorSideTop.Control = TextItalicRadioPanel AnchorSideRight.Control = TextItalicRadioPanel AnchorSideRight.Side = asrBottom - Left = 83 + Left = 79 Height = 19 Top = 1 - Width = 50 + Width = 48 BorderSpacing.Left = 3 Caption = 'Invert' - OnChange = TextStyleRadioOnChange TabOrder = 2 + OnChange = TextStyleRadioOnChange end object TextItalicRadioOn: TRadioButton Tag = 2 @@ -376,14 +931,14 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 4 Height = 19 Top = 1 - Width = 36 + Width = 34 BorderSpacing.Left = 3 BorderSpacing.Right = 3 Caption = 'On' Checked = True - OnChange = TextStyleRadioOnChange TabOrder = 0 TabStop = True + OnChange = TextStyleRadioOnChange end object TextItalicRadioOff: TRadioButton Tag = 2 @@ -391,15 +946,15 @@ object SynColorAttrEditor: TSynColorAttrEditor AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = TextItalicRadioPanel AnchorSideRight.Control = TextItalicRadioInvert - Left = 43 + Left = 41 Height = 19 Top = 1 - Width = 37 + Width = 35 BorderSpacing.Left = 3 BorderSpacing.Right = 3 Caption = 'Off' - OnChange = TextStyleRadioOnChange TabOrder = 1 + OnChange = TextStyleRadioOnChange end end object TextItalicCheckBox: TCheckBox @@ -408,361 +963,12 @@ object SynColorAttrEditor: TSynColorAttrEditor Left = 0 Height = 19 Top = 0 - Width = 119 + Width = 118 Caption = 'TextItalicCheckBox' - OnChange = GeneralCheckBoxOnChange TabOrder = 1 + OnChange = GeneralCheckBoxOnChange end end - object FrameStyleBox: TComboBox - AnchorSideLeft.Control = FrameEdgesBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = FrameEdgesBox - Left = 307 - Height = 21 - Top = 78 - Width = 97 - BorderSpacing.Left = 6 - ItemHeight = 15 - ItemIndex = 0 - Items.Strings = ( - 'slsSolid' - 'slsDashed' - 'slsDotted' - 'slsWaved' - ) - OnChange = GeneralColorBoxOnChange - OnDrawItem = GeneralStyleBoxOnDrawItem - Style = csOwnerDrawFixed - TabOrder = 10 - Text = 'slsSolid' - end - object FrameEdgesBox: TComboBox - AnchorSideLeft.Control = FrameColorBox - AnchorSideTop.Control = FrameColorBox - AnchorSideTop.Side = asrBottom - Left = 204 - Height = 21 - Top = 78 - Width = 97 - BorderSpacing.Top = 3 - ItemHeight = 15 - ItemIndex = 0 - Items.Strings = ( - 'Around' - 'Bottom' - 'Left' - ) - OnChange = GeneralColorBoxOnChange - OnDrawItem = FrameEdgesBoxDrawItem - Style = csOwnerDrawFixed - TabOrder = 9 - Text = 'Around' - end - object ColumnPosBevel: TPanel - AnchorSideLeft.Control = ForeGroundUseDefaultCheckBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = pnlUnderline - AnchorSideTop.Side = asrBottom - AnchorSideBottom.Side = asrBottom - Left = 204 - Height = 1 - Top = 170 - Width = 50 - AutoSize = True - BorderSpacing.Left = 6 - BevelOuter = bvNone - Constraints.MinHeight = 1 - Constraints.MinWidth = 50 - TabOrder = 14 - end - object ForeAlphaLabel: TLabel - AnchorSideLeft.Control = ForegroundColorBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = ForegroundColorBox - AnchorSideTop.Side = asrCenter - Left = 414 - Height = 15 - Top = 7 - Width = 82 - BorderSpacing.Left = 10 - Caption = 'ForeAlphaLabel' - ParentColor = False - end - object BackAlphaLabel: TLabel - AnchorSideLeft.Control = BackGroundColorBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = BackGroundColorBox - AnchorSideTop.Side = asrCenter - Left = 414 - Height = 15 - Top = 32 - Width = 84 - BorderSpacing.Left = 10 - Caption = 'BackAlphaLabel' - ParentColor = False - end - object FrameAlphaLabel: TLabel - AnchorSideLeft.Control = FrameColorBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = FrameColorBox - AnchorSideTop.Side = asrCenter - Left = 414 - Height = 15 - Top = 57 - Width = 92 - BorderSpacing.Left = 10 - Caption = 'FrameAlphaLabel' - ParentColor = False - end - object ForeAlphaSpin: TSpinEdit - AnchorSideLeft.Control = ForeAlphaLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = ForeAlphaLabel - AnchorSideTop.Side = asrCenter - Left = 502 - Height = 23 - Top = 3 - Width = 65 - BorderSpacing.Left = 6 - Constraints.MinWidth = 65 - MaxValue = 256 - MinValue = 1 - OnChange = GeneralAlphaSpinOnChange - OnEditingDone = GeneralAlphaSpinOnChange - OnEnter = GeneralAlphaSpinOnEnter - OnExit = GeneralAlphaSpinOnChange - OnResize = GeneralAlphaSpinOnChange - TabOrder = 2 - Value = 256 - end - object BackAlphaSpin: TSpinEdit - AnchorSideLeft.Control = BackAlphaLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = BackAlphaLabel - AnchorSideTop.Side = asrCenter - Left = 504 - Height = 23 - Top = 28 - Width = 65 - BorderSpacing.Left = 6 - Constraints.MinWidth = 65 - MaxValue = 256 - MinValue = 1 - OnChange = GeneralAlphaSpinOnChange - OnEditingDone = GeneralAlphaSpinOnChange - OnEnter = GeneralAlphaSpinOnEnter - OnExit = GeneralAlphaSpinOnChange - OnResize = GeneralAlphaSpinOnChange - TabOrder = 5 - Value = 256 - end - object FrameAlphaSpin: TSpinEdit - AnchorSideLeft.Control = FrameAlphaLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = FrameAlphaLabel - AnchorSideTop.Side = asrCenter - Left = 512 - Height = 23 - Top = 53 - Width = 65 - BorderSpacing.Left = 6 - Constraints.MinWidth = 65 - MaxValue = 256 - MinValue = 1 - OnChange = GeneralAlphaSpinOnChange - OnEditingDone = GeneralAlphaSpinOnChange - OnEnter = GeneralAlphaSpinOnEnter - OnExit = GeneralAlphaSpinOnChange - OnResize = GeneralAlphaSpinOnChange - TabOrder = 8 - Value = 256 - end - object ForePriorLabel: TLabel - AnchorSideLeft.Control = ForeAlphaSpin - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = ForegroundColorBox - AnchorSideTop.Side = asrCenter - Left = 577 - Height = 15 - Top = 7 - Width = 76 - BorderSpacing.Left = 10 - Caption = 'ForePriorLabel' - ParentColor = False - end - object BackPriorLabel: TLabel - AnchorSideLeft.Control = BackAlphaSpin - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = BackGroundColorBox - AnchorSideTop.Side = asrCenter - Left = 579 - Height = 15 - Top = 32 - Width = 78 - BorderSpacing.Left = 10 - Caption = 'BackPriorLabel' - ParentColor = False - end - object FramePriorLabel: TLabel - AnchorSideLeft.Control = FrameAlphaSpin - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = FrameColorBox - AnchorSideTop.Side = asrCenter - Left = 587 - Height = 15 - Top = 57 - Width = 86 - BorderSpacing.Left = 10 - Caption = 'FramePriorLabel' - ParentColor = False - end - object ForePriorSpin: TSpinEdit - AnchorSideLeft.Control = ForePriorLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = ForePriorLabel - AnchorSideTop.Side = asrCenter - Left = 659 - Height = 23 - Top = 3 - Width = 65 - BorderSpacing.Left = 6 - Constraints.MinWidth = 65 - MaxValue = 9999 - OnChange = GeneralPriorSpinOnChange - OnEditingDone = GeneralPriorSpinOnChange - OnExit = GeneralPriorSpinOnChange - TabOrder = 15 - Value = 1 - end - object BackPriorSpin: TSpinEdit - AnchorSideLeft.Control = BackPriorLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = BackPriorLabel - AnchorSideTop.Side = asrCenter - Left = 663 - Height = 23 - Top = 28 - Width = 65 - BorderSpacing.Left = 6 - Constraints.MinWidth = 65 - MaxValue = 9999 - OnChange = GeneralPriorSpinOnChange - OnEditingDone = GeneralPriorSpinOnChange - OnExit = GeneralPriorSpinOnChange - TabOrder = 16 - Value = 1 - end - object FramePriorSpin: TSpinEdit - AnchorSideLeft.Control = FramePriorLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = FrameAlphaLabel - AnchorSideTop.Side = asrCenter - Left = 679 - Height = 23 - Top = 53 - Width = 65 - BorderSpacing.Left = 6 - Constraints.MinWidth = 65 - MaxValue = 9999 - OnChange = GeneralPriorSpinOnChange - OnEditingDone = GeneralPriorSpinOnChange - OnExit = GeneralPriorSpinOnChange - TabOrder = 17 - Value = 1 - end - object MarkupFoldColorUseDefaultCheckBox: TCheckBox - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = MarkupFoldColorBox - AnchorSideTop.Side = asrCenter - AnchorSideRight.Side = asrBottom - Left = 6 - Height = 19 - Top = 104 - Width = 222 - BorderSpacing.Left = 6 - Caption = 'MarkupFoldColorUseDefaultCheckBox' - OnChange = GeneralCheckBoxOnChange - OnResize = pnlElementAttributesResize - TabOrder = 19 - end - object MarkupFoldColorBox: TColorBox - AnchorSideLeft.Control = ColumnPosBevel - AnchorSideTop.Control = FrameEdgesBox - AnchorSideTop.Side = asrBottom - AnchorSideRight.Side = asrBottom - Left = 204 - Height = 22 - Top = 102 - Width = 200 - DefaultColorColor = clWhite - Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors] - OnGetColors = GeneralColorBoxOnGetColors - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 3 - Constraints.MaxWidth = 200 - Constraints.MinWidth = 80 - ItemHeight = 16 - OnChange = GeneralColorBoxOnChange - TabOrder = 18 - end - object MarkupFoldAlphaLabel: TLabel - AnchorSideLeft.Control = MarkupFoldColorBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = MarkupFoldColorBox - AnchorSideTop.Side = asrCenter - Left = 414 - Height = 15 - Top = 106 - Width = 123 - BorderSpacing.Left = 10 - Caption = 'MarkupFoldAlphaLabel' - ParentColor = False - end - object MarkupFoldAlphaSpin: TSpinEdit - AnchorSideLeft.Control = MarkupFoldAlphaLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = MarkupFoldColorBox - AnchorSideTop.Side = asrCenter - Left = 543 - Height = 23 - Top = 102 - Width = 65 - BorderSpacing.Left = 6 - Constraints.MinWidth = 65 - MaxValue = 256 - MinValue = 1 - OnChange = GeneralAlphaSpinOnChange - OnEditingDone = GeneralAlphaSpinOnChange - OnEnter = GeneralAlphaSpinOnEnter - OnExit = GeneralAlphaSpinOnChange - OnResize = GeneralAlphaSpinOnChange - TabOrder = 20 - Value = 256 - end - object MarkupFoldStyleBox: TComboBox - AnchorSideLeft.Control = MarkupFoldAlphaSpin - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = MarkupFoldColorUseDefaultCheckBox - Left = 614 - Height = 21 - Top = 104 - Width = 97 - BorderSpacing.Left = 6 - ItemHeight = 15 - ItemIndex = 0 - Items.Strings = ( - 'slsSolid' - 'slsDashed' - 'slsDotted' - 'slsWaved' - ) - OnChange = GeneralColorBoxOnChange - OnDrawItem = GeneralStyleBoxOnDrawItem - Style = csOwnerDrawFixed - TabOrder = 21 - Text = 'slsSolid' - end object lblInfo: TLabel AnchorSideLeft.Control = Owner AnchorSideTop.Control = pnlUnderline @@ -770,15 +976,67 @@ object SynColorAttrEditor: TSynColorAttrEditor AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 6 - Height = 15 - Top = 170 - Width = 746 + Height = 1 + Top = 177 + Width = 1280 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Top = 3 BorderSpacing.Right = 6 - Caption = 'lblInfo' - Visible = False WordWrap = True + OnResize = pnlElementAttributesResize + end + object pnlWords: TPanel + AnchorSideLeft.Control = Panel1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Owner + AnchorSideBottom.Control = lblInfo + AnchorSideBottom.Side = asrBottom + Left = 916 + Height = 178 + Top = 0 + Width = 182 + Anchors = [akTop, akLeft, akBottom] + AutoSize = True + BevelOuter = bvNone + ClientHeight = 178 + ClientWidth = 182 + TabOrder = 4 + object lbCustomWords: TLabel + Left = 0 + Height = 15 + Top = 3 + Width = 182 + Align = alTop + BorderSpacing.Top = 3 + Caption = 'lbCustomWords' + WordWrap = True + end + object edCustomWord: TMemo + Left = 2 + Height = 128 + Top = 21 + Width = 180 + Align = alClient + BorderSpacing.Left = 2 + BorderSpacing.Top = 3 + BorderSpacing.Bottom = 3 + Constraints.MinWidth = 180 + TabOrder = 0 + OnChange = edCustomWordChange + OnEditingDone = edCustomWordChange + end + object dropCustomWordKind: TComboBox + Left = 0 + Height = 23 + Top = 152 + Width = 182 + Align = alBottom + BorderSpacing.Bottom = 3 + ItemHeight = 15 + Style = csDropDownList + TabOrder = 1 + OnChange = dropCustomWordKindChange + end end end diff --git a/ide/syncolorattribeditor.pas b/ide/syncolorattribeditor.pas index 55aeff0c5b..439cab60d9 100644 --- a/ide/syncolorattribeditor.pas +++ b/ide/syncolorattribeditor.pas @@ -10,7 +10,7 @@ uses LCLIntf, Forms, StdCtrls, ExtCtrls, Graphics, GraphUtil, ColorBox, Dialogs, Menus, Spin, // SynEdit - SynEditTypes, SynTextDrawer, + SynEditTypes, SynTextDrawer, SynHighlighterPas, // IdeConfig EnvironmentOpts, // IDE @@ -25,9 +25,20 @@ type BackPriorSpin: TSpinEdit; BackGroundColorBox: TColorBox; BackGroundLabel: TLabel; - ColumnPosBevel: TPanel; + dropCustomWordKind: TComboBox; ForePriorLabel: TLabel; ForePriorSpin: TSpinEdit; + lbFiller1: TLabel; + lbCustomWords: TLabel; + lbFiller10: TLabel; + lbFiller2: TLabel; + lbFiller3: TLabel; + lbFiller4: TLabel; + lbFiller5: TLabel; + lbFiller6: TLabel; + lbFiller7: TLabel; + lbFiller8: TLabel; + lbFiller9: TLabel; lblInfo: TLabel; MarkupFoldStyleBox: TComboBox; MarkupFoldAlphaSpin: TSpinEdit; @@ -45,6 +56,34 @@ type ForeAlphaLabel: TLabel; BackAlphaLabel: TLabel; FrameAlphaLabel: TLabel; + edCustomWord: TMemo; + Panel1: TPanel; + Panel10: TPanel; + Panel11: TPanel; + Panel12: TPanel; + Panel13: TPanel; + Panel14: TPanel; + Panel15: TPanel; + Panel16: TPanel; + Panel17: TPanel; + Panel18: TPanel; + Panel19: TPanel; + Panel2: TPanel; + Panel20: TPanel; + Panel21: TPanel; + Panel22: TPanel; + pnlWords: TPanel; + Panel3: TPanel; + Panel4: TPanel; + Panel5: TPanel; + Panel6: TPanel; + Panel7: TPanel; + Panel8: TPanel; + Panel9: TPanel; + pnlFrameHost2: TPanel; + pnlFrameHost1: TPanel; + pnlForegroundName: TPanel; + pnlBackgroundName: TPanel; pnlUnderline: TPanel; pnlBold: TPanel; pnlItalic: TPanel; @@ -68,6 +107,8 @@ type TextUnderlineRadioPanel: TPanel; ForeGroundLabel: TLabel; ForeGroundUseDefaultCheckBox: TCheckBox; + procedure dropCustomWordKindChange(Sender: TObject); + procedure edCustomWordChange(Sender: TObject); procedure GeneralAlphaSpinOnChange(Sender: TObject); procedure GeneralAlphaSpinOnEnter(Sender: TObject); procedure GeneralColorBoxOnChange(Sender: TObject); @@ -199,6 +240,25 @@ begin DoChanged; end; +procedure TSynColorAttrEditor.edCustomWordChange(Sender: TObject); +begin + if (FCurHighlightElement = nil) then + exit; + + FCurHighlightElement.CustomWords.Text := trim(edCustomWord.Text); +end; + +procedure TSynColorAttrEditor.dropCustomWordKindChange(Sender: TObject); +begin + case dropCustomWordKind.ItemIndex of + 0: FCurHighlightElement.CustomWordTokenKind := tkIdentifier; + 1: FCurHighlightElement.CustomWordTokenKind := tkKey; + 2: FCurHighlightElement.CustomWordTokenKind := tkModifier; + 3: FCurHighlightElement.CustomWordTokenKind := tkNumber; + 4: FCurHighlightElement.CustomWordTokenKind := tkSymbol; + end; +end; + procedure TSynColorAttrEditor.GeneralAlphaSpinOnEnter(Sender: TObject); begin UpdatingColor := True; @@ -278,29 +338,19 @@ end; procedure TSynColorAttrEditor.DoResized; var - S: TSpinEdit; + EdCustWidth: Integer; begin - S := FramePriorSpin; - if not S.Visible then - S := FrameAlphaSpin; - if Width > S.Left + S.Width + FrameStyleBox.Width + FrameEdgesBox.Width + 15 then - begin - //FrameEdgesBox.AnchorSide[akTop].Control := S; - FrameEdgesBox.AnchorSide[akTop].Side := asrTop; - FrameEdgesBox.AnchorSide[akLeft].Control := S; - FrameEdgesBox.AnchorSide[akLeft].Side := asrBottom; - FrameEdgesBox.BorderSpacing.Top := 0; - FrameEdgesBox.BorderSpacing.Left := 6; - MarkupFoldColorBox.AnchorSide[akTop].Control := FrameColorBox; + EdCustWidth := 0; + if edCustomWord.Visible then + EdCustWidth := edCustomWord.Width; + + if Width > Panel1.Width + EdCustWidth - pnlFrameHost1.Width + Max(pnlFrameHost1.Width, pnlFrameHost2.Width) + 15 then begin + FrameEdgesBox.Parent := pnlFrameHost1; + FrameStyleBox.Parent := pnlFrameHost1; end else begin - //FrameEdgesBox.AnchorSide[akTop].Control := FrameColorBox; - FrameEdgesBox.AnchorSide[akTop].Side := asrBottom; - FrameEdgesBox.AnchorSide[akLeft].Control := FrameColorBox; - FrameEdgesBox.AnchorSide[akLeft].Side := asrTop; - FrameEdgesBox.BorderSpacing.Top := 3; - FrameEdgesBox.BorderSpacing.Left := 0; - MarkupFoldColorBox.AnchorSide[akTop].Control := FrameEdgesBox; + FrameEdgesBox.Parent := pnlFrameHost2; + FrameStyleBox.Parent := pnlFrameHost2; end; end; @@ -432,37 +482,14 @@ end; procedure TSynColorAttrEditor.pnlElementAttributesResize(Sender: TObject); var - MinAnchor: TControl; - MinWidth: Integer; - S: TSpinEdit; - - procedure CheckControl(Other: TControl); - var w,h: Integer; - begin - if not Other.Visible then exit; - h:=0; - w:=0; - Other.GetPreferredSize(w,h); - if w <= MinWidth then exit; - MinAnchor := Other; - MinWidth := w; - end; + EdCustWidth: Integer; begin - MinWidth := -1; - MinAnchor := ForeGroundLabel; - CheckControl(ForeGroundLabel); - CheckControl(BackGroundLabel); - CheckControl(ForeGroundUseDefaultCheckBox); - CheckControl(BackGroundUseDefaultCheckBox); - CheckControl(FrameColorUseDefaultCheckBox); - CheckControl(MarkupFoldColorUseDefaultCheckBox); + EdCustWidth := 0; + if edCustomWord.Visible then + EdCustWidth := edCustomWord.Width; - ColumnPosBevel.AnchorSide[akLeft].Control := MinAnchor; - Constraints.MinHeight := lblInfo.Top + lblInfo.Height; - S := BackPriorSpin; - if not S.Visible then - S := BackAlphaSpin; - Constraints.MinWidth := S.Left + S.Width; + //Constraints.MinHeight := lblInfo.Top + lblInfo.Height; + Constraints.MinWidth := Panel1.Width + EdCustWidth - pnlFrameHost1.Width + 15; end; procedure TSynColorAttrEditor.TextStyleRadioOnChange(Sender: TObject); @@ -743,12 +770,26 @@ begin TextUnderlineCheckBox.Checked := fsUnderline in FCurHighlightElement.Style; end; - lblInfo.Visible := False; + lblInfo.Caption := ''; if IsAhaElement(FCurHighlightElement, ahaCaretColor) then begin lblInfo.Caption := dlgCaretColorInfo; lblInfo.Visible := True; end; + // custom words + lbCustomWords.Visible := hafCustomWords in FCurHighlightElement.Features; + edCustomWord.Visible := hafCustomWords in FCurHighlightElement.Features; + dropCustomWordKind.Visible := hafCustomWords in FCurHighlightElement.Features; + edCustomWord.Text := FCurHighlightElement.CustomWords.Text; + + case FCurHighlightElement.CustomWordTokenKind of + tkIdentifier: dropCustomWordKind.ItemIndex := 0; + tkKey: dropCustomWordKind.ItemIndex := 1; + tkModifier: dropCustomWordKind.ItemIndex := 2; + tkNumber: dropCustomWordKind.ItemIndex := 3; + tkSymbol: dropCustomWordKind.ItemIndex := 4; + end; + UpdatingColor := False; finally EnableAlign; @@ -792,7 +833,6 @@ end; procedure TSynColorAttrEditor.Setup; begin UpdatingColor := False; - ColumnPosBevel.Height := 1; ForeGroundLabel.Caption := dlgForecolor; BackGroundLabel.Caption := dlgBackColor; ForeGroundUseDefaultCheckBox.Caption := dlgForecolor; @@ -822,11 +862,19 @@ begin TextUnderlineRadioOff.Caption := dlgEdOff; TextUnderlineRadioInvert.Caption := dlgEdInvert; - Constraints.MinHeight := max(Constraints.MinHeight, - pnlUnderline.Top + pnlUnderline.Height + - Max(pnlUnderline.BorderSpacing.Around, - pnlUnderline.BorderSpacing.Bottom) - ); + lbCustomWords.Caption := dlgMatchWords; + dropCustomWordKind.Items.Add(lisCodeToolsOptsIdentifier); + dropCustomWordKind.Items.Add(dlgKeyWord); + dropCustomWordKind.Items.Add(dlgModifier); + dropCustomWordKind.Items.Add(lisCodeToolsOptsNumber); + dropCustomWordKind.Items.Add(lisCodeToolsOptsSymbol); + dropCustomWordKind.ItemIndex := 0; + + //Constraints.MinHeight := max(Constraints.MinHeight, + // pnlUnderline.Top + pnlUnderline.Height + + // Max(pnlUnderline.BorderSpacing.Around, + // pnlUnderline.BorderSpacing.Bottom) + // ); end; end.