mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 13:59:34 +02:00
SynEdit: updates to markup fold-color, patch 15 from issue #0030421 // and started test case.
git-svn-id: trunk@53209 -
This commit is contained in:
parent
9c41906a96
commit
9b3d07a150
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -3964,6 +3964,7 @@ components/synedit/test/testhighlightfoldbase.pas svneol=native#text/pascal
|
||||
components/synedit/test/testhighlightmulti.pas svneol=native#text/pascal
|
||||
components/synedit/test/testhighlightpas.pas svneol=native#text/pascal
|
||||
components/synedit/test/testhighlightxml.pas svneol=native#text/pascal
|
||||
components/synedit/test/testmarkupfoldcoloring.pas svneol=native#text/pascal
|
||||
components/synedit/test/testmarkuphighall.pas svneol=native#text/pascal
|
||||
components/synedit/test/testmarkupifdef.pas svneol=native#text/pascal
|
||||
components/synedit/test/testmarkupwordgroup.pas svneol=native#text/pascal
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,12 +3,13 @@ program SynTest;
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Interfaces, Forms, GuiTestRunner, TestBase,
|
||||
TestBasicSynEdit, TestNavigation, TestSynSelection, TestBlockIndent, TestBookMarks,
|
||||
TestSearch, TestSynBeautifier, TestTrimSpace, TestSyncroEdit, TestSynTextArea,
|
||||
TestHighlightPas, TestHighlightXml, TestHighlightMulti,
|
||||
TestMarkupwordGroup, TestMarkupHighAll, TestFoldedView, TestSynSharedEdits,
|
||||
TestHighlighterLfm, TestHighlightFoldBase, TestMarkupIfDef, testPaintColorMerging;
|
||||
Interfaces, Forms, GuiTestRunner, TestBase, TestBasicSynEdit, TestNavigation,
|
||||
TestSynSelection, TestBlockIndent, TestBookMarks, TestSearch,
|
||||
TestSynBeautifier, TestTrimSpace, TestSyncroEdit, TestSynTextArea,
|
||||
TestHighlightPas, TestHighlightXml, TestHighlightMulti, TestMarkupwordGroup,
|
||||
TestMarkupHighAll, TestFoldedView, TestSynSharedEdits, TestHighlighterLfm,
|
||||
TestHighlightFoldBase, TestMarkupIfDef, testPaintColorMerging,
|
||||
TestMarkupFoldColoring;
|
||||
|
||||
{$IFDEF WINDOWS}{ $R SynTest.rc}{$ENDIF}
|
||||
|
||||
|
138
components/synedit/test/testmarkupfoldcoloring.pas
Normal file
138
components/synedit/test/testmarkupfoldcoloring.pas
Normal file
@ -0,0 +1,138 @@
|
||||
unit TestMarkupFoldColoring;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, math, testregistry, TestBase, TestHighlightPas, Forms,
|
||||
LCLProc, SynEdit, SynHighlighterPas, SynEditMarkupFoldColoring,
|
||||
SynEditMiscClasses, SynEditMarkup, SynEditHighlighterFoldBase;
|
||||
|
||||
type
|
||||
|
||||
{ TTestMarkupFoldColoring }
|
||||
|
||||
TTestMarkupFoldColoring = class(TTestBaseHighlighterPas)
|
||||
private
|
||||
Markup: TSynEditMarkupFoldColors;
|
||||
protected
|
||||
procedure SetUp; override;
|
||||
procedure TearDown; override;
|
||||
procedure ReCreateEdit; reintroduce;
|
||||
function TestText1: TStringArray;
|
||||
procedure EnableOutlines(AEnbledTypes: TPascalCodeFoldBlockTypes);
|
||||
published
|
||||
procedure TestColors;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestMarkupFoldColoring }
|
||||
|
||||
procedure TTestMarkupFoldColoring.SetUp;
|
||||
begin
|
||||
Markup := nil;
|
||||
inherited SetUp;
|
||||
end;
|
||||
|
||||
procedure TTestMarkupFoldColoring.TearDown;
|
||||
begin
|
||||
FreeAndNil(Markup);
|
||||
inherited TearDown;
|
||||
end;
|
||||
|
||||
procedure TTestMarkupFoldColoring.ReCreateEdit;
|
||||
begin
|
||||
inherited ReCreateEdit;
|
||||
Markup := TSynEditMarkupFoldColors.Create(SynEdit);
|
||||
Markup.Lines := SynEdit.TextBuffer;
|
||||
//Markup.Highlighter := SynEdit.Highlighter;
|
||||
end;
|
||||
|
||||
function TTestMarkupFoldColoring.TestText1: TStringArray;
|
||||
begin
|
||||
SetLength(Result, 20);
|
||||
Result[ 0] := 'program Foo;';
|
||||
Result[ 1] := '';
|
||||
Result[ 2] := 'procedure a;';
|
||||
Result[ 3] := 'var';
|
||||
Result[ 4] := ' a: boolean;';
|
||||
Result[ 5] := ' procedure inner;';
|
||||
Result[ 6] := ' writeln()';
|
||||
Result[ 7] := ' end;';
|
||||
Result[ 8] := '';
|
||||
Result[ 9] := 'begin';
|
||||
Result[10] := ' if a then begin';
|
||||
Result[11] := ' writeln()';
|
||||
Result[12] := ' end;';
|
||||
Result[13] := '';
|
||||
Result[14] := 'end;';
|
||||
Result[15] := '';
|
||||
Result[16] := 'begin';
|
||||
Result[17] := '';
|
||||
Result[18] := 'end.';
|
||||
Result[19] := '';
|
||||
end;
|
||||
|
||||
procedure TTestMarkupFoldColoring.EnableOutlines(AEnbledTypes: TPascalCodeFoldBlockTypes);
|
||||
var
|
||||
i: TPascalCodeFoldBlockType;
|
||||
begin
|
||||
for i := low(TPascalCodeFoldBlockType) to high(TPascalCodeFoldBlockType) do begin
|
||||
PasHighLighter.FoldConfig[ord(i)].Enabled := i in AEnbledTypes;
|
||||
if (i in AEnbledTypes) then
|
||||
PasHighLighter.FoldConfig[ord(i)].Modes := PasHighLighter.FoldConfig[ord(i)].Modes + [fmOutline]
|
||||
else
|
||||
PasHighLighter.FoldConfig[ord(i)].Modes := PasHighLighter.FoldConfig[ord(i)].Modes - [fmOutline]
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTestMarkupFoldColoring.TestColors;
|
||||
procedure TestNextAtPos(ALine, APos, AExp: Integer; Amsg: String);
|
||||
var
|
||||
col: TLazSynDisplayTokenBound;
|
||||
rtl: TLazSynDisplayRtlInfo;
|
||||
nextP, nextL: Integer;
|
||||
begin
|
||||
rtl.IsRtl := False;
|
||||
// text has no special char log=phys
|
||||
col.Logical := APos;
|
||||
col.Physical := APos;
|
||||
col.Offset := 0;
|
||||
Markup.GetNextMarkupColAfterRowCol(ALine, col, rtl, nextP, nextL);
|
||||
AssertEquals(BaseTestName + Amsg, AExp, Max(nextP, nextL));
|
||||
end;
|
||||
begin
|
||||
ReCreateEdit;
|
||||
|
||||
PushBaseName('All folds');
|
||||
|
||||
SetLines(TestText1);
|
||||
EnableFolds([cfbtBeginEnd.. cfbtNone], [cfbtSlashComment]);
|
||||
EnableOutlines([cfbtBeginEnd.. cfbtNone]);
|
||||
|
||||
PushBaseName('Line 7');
|
||||
Markup.PrepareMarkupForRow(7); // writeln // inner
|
||||
TestNextAtPos(7, 0, 1, '1 markup at 1');
|
||||
TestNextAtPos(7, 1, 3, '2 markup at 3');
|
||||
TestNextAtPos(7, 3,-1, '3 markup none');
|
||||
PopBaseName;
|
||||
|
||||
PushBaseName('Line 11 (if then)');
|
||||
Markup.PrepareMarkupForRow(11); // if them
|
||||
TestNextAtPos(11, 0, 1, '1 markup at 1');
|
||||
TestNextAtPos(11, 1, 3, '2 markup at 3');
|
||||
TestNextAtPos(11, 3, 8, '3 markup at 8 (then)');
|
||||
// ....
|
||||
PopBaseName;
|
||||
|
||||
PopBaseName;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
RegisterTest(TTestMarkupFoldColoring);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user