Check-in [2ccce4c882]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:First attempt at using our own wide diff highlighter (which fails with a Range Check Error).
Timelines: family | ancestors | descendants | both | lazarus
Files: files | file ages | folders
SHA1: 2ccce4c882e9c155c0415021f937482a520a21d7
User & Date: tinus 2014-08-06 20:53:08
Context
2014-08-06
21:11
Bugfix: reset the ColIndex when starting a new line. check-in: e74a31c95f user: tinus tags: lazarus
20:53
First attempt at using our own wide diff highlighter (which fails with a Range Check Error). check-in: 2ccce4c882 user: tinus tags: lazarus
06:10
Added new unit with start of syntax highlighter for wide diff. check-in: f26843ce0b user: tinus tags: lazarus
Changes

Changes to src/a_fileversioninfo.lfm.

714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
    WantTabs = False
    inline SynLeftGutterPartList1: TSynGutterPartList
      object SynGutterMarks1: TSynGutterMarks
        Width = 24
        MouseActions = <>
      end
      object SynGutterLineNumber1: TSynGutterLineNumber
        Width = 16
        Visible = False
        MouseActions = <>
        MarkupInfo.Background = clBtnFace
        MarkupInfo.Foreground = clNone
        MarkupInfo.FrameEdges = sfeAround
        DigitCount = 2
        ShowOnlyLineNumbersMultiplesOf = 1







|







714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
    WantTabs = False
    inline SynLeftGutterPartList1: TSynGutterPartList
      object SynGutterMarks1: TSynGutterMarks
        Width = 24
        MouseActions = <>
      end
      object SynGutterLineNumber1: TSynGutterLineNumber
        Width = 22
        Visible = False
        MouseActions = <>
        MarkupInfo.Background = clBtnFace
        MarkupInfo.Foreground = clNone
        MarkupInfo.FrameEdges = sfeAround
        DigitCount = 2
        ShowOnlyLineNumbersMultiplesOf = 1

Changes to src/a_fileversioninfo.pas.

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
...
197
198
199
200
201
202
203



204
205
206
207
208
209
210
211
212
213
214
215
216
217

procedure TfraFileVersionInfo.btnDiffTKClick(Sender: TObject);
var
  DiffOpts: TDiffOptions;
begin
  if not Assigned(FFile) then
    Exit;
  //modMain.Fossil.Run('diff --tk ' + AnsiQuotedStr(FFile.FullName, '"'));
  DiffOpts := cDefaultDiffOptions;
  DiffOpts.External := True;
  DiffOpts.SideBySide := True;
  FFile.GetDiff(@DiffOpts);
end;

procedure TfraFileVersionInfo.SelectFile(const AFile: TFileVersion;
................................................................................
  Ext: TFileName;
  Contents: TStream;
begin
  synEdit.Visible := Assigned(FFile);
  if not Assigned(FFile) then
    Exit;




  synEdit.BeginUpdate(False);
  try
    synEdit.Lines.Clear;
    try
      if btnViewDiff.Down or btnViewDiffWide.Down then begin
        if btnViewDiffWide.Down then begin
          synEdit.Highlighter := nil; // TODO: roll our own
        end else begin
          synEdit.Highlighter := modHighlighters.shlDiff;
        end;

        DiffOpts := cDefaultDiffOptions;
        DiffOpts.SideBySide := btnViewDiffWide.Down;
        DiffOpts.Width := (synEdit.CharsInWindow div 2) - 10;







|







 







>
>
>






|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220

procedure TfraFileVersionInfo.btnDiffTKClick(Sender: TObject);
var
  DiffOpts: TDiffOptions;
begin
  if not Assigned(FFile) then
    Exit;

  DiffOpts := cDefaultDiffOptions;
  DiffOpts.External := True;
  DiffOpts.SideBySide := True;
  FFile.GetDiff(@DiffOpts);
end;

procedure TfraFileVersionInfo.SelectFile(const AFile: TFileVersion;
................................................................................
  Ext: TFileName;
  Contents: TStream;
begin
  synEdit.Visible := Assigned(FFile);
  if not Assigned(FFile) then
    Exit;

  // TODO: figure out the first button down AND enabled; if it's not enabled,
  //  we should try the other ones that ARE enabled.

  synEdit.BeginUpdate(False);
  try
    synEdit.Lines.Clear;
    try
      if btnViewDiff.Down or btnViewDiffWide.Down then begin
        if btnViewDiffWide.Down then begin
          synEdit.Highlighter := modHighlighters.shlDiffWide;
        end else begin
          synEdit.Highlighter := modHighlighters.shlDiff;
        end;

        DiffOpts := cDefaultDiffOptions;
        DiffOpts.SideBySide := btnViewDiffWide.Down;
        DiffOpts.Width := (synEdit.CharsInWindow div 2) - 10;

Changes to src/m_highlighters.pas.

6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
..
34
35
36
37
38
39
40

41
42



43
44
45
46
47
48
49
50








51
52
53

uses
  Classes, SysUtils, FileUtil, SynHighlighterMulti, SynHighlighterDiff,
  SynHighlighterAny, SynHighlighterPas, SynHighlighterJScript,
  SynHighlighterHTML, SynHighlighterXML, SynHighlighterCss, SynHighlighterSQL,
  SynHighlighterIni, SynHighlighterCpp, SynHighlighterJava, SynHighlighterPerl,
  synhighlighterunixshellscript, SynHighlighterPHP, SynHighlighterPython,
  SynHighlighterVB, SynHighlighterBat, SynHighlighterPo;


type

  { TmodHighlighters }

  TmodHighlighters = class(TDataModule)
    shlAny: TSynAnySyn;
................................................................................
    shlPHP: TSynPHPSyn;
    shlPython: TSynPythonSyn;
    shlBasic: TSynVBSyn;
    shlBatch: TSynBatSyn;
    shlPO: TSynPoSyn;
  private
    { private declarations }

  public
    { public declarations }



  end;

var
  modHighlighters: TmodHighlighters;

implementation

{$R *.lfm}









end.








|
>







 







>


>
>
>








>
>
>
>
>
>
>
>



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

uses
  Classes, SysUtils, FileUtil, SynHighlighterMulti, SynHighlighterDiff,
  SynHighlighterAny, SynHighlighterPas, SynHighlighterJScript,
  SynHighlighterHTML, SynHighlighterXML, SynHighlighterCss, SynHighlighterSQL,
  SynHighlighterIni, SynHighlighterCpp, SynHighlighterJava, SynHighlighterPerl,
  synhighlighterunixshellscript, SynHighlighterPHP, SynHighlighterPython,
  SynHighlighterVB, SynHighlighterBat, SynHighlighterPo,
  SynHighlighterDiffWide;

type

  { TmodHighlighters }

  TmodHighlighters = class(TDataModule)
    shlAny: TSynAnySyn;
................................................................................
    shlPHP: TSynPHPSyn;
    shlPython: TSynPythonSyn;
    shlBasic: TSynVBSyn;
    shlBatch: TSynBatSyn;
    shlPO: TSynPoSyn;
  private
    { private declarations }
    FshlDiffWide: TSynHighlighterDiffWide;
  public
    { public declarations }
    constructor Create(AOwner: TComponent); override;
  published
    property shlDiffWide: TSynHighlighterDiffWide read FshlDiffWide;
  end;

var
  modHighlighters: TmodHighlighters;

implementation

{$R *.lfm}

{ TmodHighlighters }

constructor TmodHighlighters.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FshlDiffWide := TSynHighlighterDiffWide.Create(Self);
end;

end.

Changes to src/synhighlighterdiffwide.pas.

1
2
3
4
5
6
7
8
9
10
11











12
13
14
15
16





17








18


19
20
21
22
23
24
25
26
27
28
29
30



31
32
33













34
35
36


37
38
39
40




41
42
43
44
45




















46


































47
48
49
50
51
52





















53
54




55
















56
57


58
59
60

61
62
63
64
65
66
67
68











69
70

71
72
73
74

75
76

77

78
79

80
81

82
83
84
85
86
87
88
89









90
91
92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

121
122
123
124
125










126
127
128
129
unit SynHighlighterDiffWide;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,
  SynEditHighlighter;

type












  { TSynHighlighterDiffWide }

  TSynHighlighterDiffWide = class(TSynCustomHighlighter)
  private





    FContentWidth: Integer;








  protected


  public
    procedure SetLine(const NewValue: String;
                  LineNumber:Integer // 0 based
                  ); override;
    procedure Next; override;
    function GetEol: Boolean; override;
    procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override;
    function GetEndOfLineAttribute: TSynHighlighterAttributes; override;
    function GetTokenAttribute: TSynHighlighterAttributes; override;
    function GetToken: String; override;
    function GetTokenPos: Integer; override; // 0-based
    function GetTokenKind: integer; override;



  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;













  end;

implementation



{ TSynHighlighterDiffWide }

constructor TSynHighlighterDiffWide.Create(AOwner: TComponent);




begin
  inherited Create(AOwner);
  // TODO: add attributes (header, divider, unknown, linenum, space,
  //        markerdeleted, markermodified, markeradded,
  //        unchangedcontent, addedcontent, modifiedcontent, deletedcontent)




















end;



































destructor TSynHighlighterDiffWide.Destroy;
begin
  inherited Destroy;
end;






















procedure TSynHighlighterDiffWide.SetLine(const NewValue: String;
  LineNumber: Integer);




begin
















  inherited SetLine(NewValue, LineNumber);



  if Length(NewValue) = 0 then begin
    // TODO: FLineType := #0;
    FIsInNextToEOL := True;

    Exit;
  end;
  // TODO: keep track of the type of line we're on
  // FLineType := NewValue[1];
  case NewValue[1] of
    '=': begin // header
      // Determine the content width
      FContentWidth := (Length(NewValue) - 1) div 2 - 8;











      // TODO: set the token to the entire line, and set the styler to HeaderAttri
      FIsInNextToEOL := True;

    end;
    '.': begin // divider
      // TODO: set the token to the entire line, and set the styler to DividerAttri
      FIsInNextToEOL := True;

    end;
    ' ', '0'..'9': begin // a diff line

      // TODO: set the token to the first 5 chars, and set the styler to LineNumberAttri

    end;
    else begin // unknown

      // TODO: set the token to the entire line, and set the styler to UnknownAttri
      FIsInNextToEOL := True;

    end;
  end;
end;

procedure TSynHighlighterDiffWide.Next;
begin
  // TODO: move to the next token
  // TODO: linenum[5], space[2], content[FContentWidth], space[1], marker[1], space[1], linenum[5], space[2], content[FContentWidth]









end;

function TSynHighlighterDiffWide.GetEol: Boolean;
begin
  Result := FIsInNextToEOL;
end;

procedure TSynHighlighterDiffWide.GetTokenEx(out TokenStart: PChar; out
  TokenLength: integer);
begin
  // TODO: get the TokenStart and length

end;

function TSynHighlighterDiffWide.GetEndOfLineAttribute: TSynHighlighterAttributes;
begin
  Result:=inherited GetEndOfLineAttribute; // TODO?
end;

function TSynHighlighterDiffWide.GetTokenAttribute: TSynHighlighterAttributes;
begin
  // TODO: return the proper token attribute
end;

function TSynHighlighterDiffWide.GetToken: String;
begin
  // TODO: return the token text
end;

function TSynHighlighterDiffWide.GetTokenPos: Integer;
begin
  // TODO: return the token position (0-based)

end;

function TSynHighlighterDiffWide.GetTokenKind: integer;
begin
  // TODO: return the token kind (index in list of styles/attributes?)










end;

end.








|



>
>
>
>
>
>
>
>
>
>
>





>
>
>
>
>

>
>
>
>
>
>
>
>

>
>







<




>
>
>



>
>
>
>
>
>
>
>
>
>
>
>
>



>
>




>
>
>
>


<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

<
>
>

|
<
>


|
|



|
>
>
>
>
>
>
>
>
>
>
>
|
<
>


|
<
>


>
|
>


>
|
<
>






|
|
>
>
>
>
>
>
>
>
>




|





|
>




|




|




|




|
>




|
>
>
>
>
>
>
>
>
>
>




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195

196
197
198
199

200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220

221
222
223
224

225
226
227
228
229
230
231
232
233
234

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
unit SynHighlighterDiffWide;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Graphics,
  SynEditHighlighter;

type

  THighlightStyle = (hsUnknown, hsHeader, hsDivider, hsLineNumber, hsSpace,
                      hsMarkerDeleted, hsMarkerEdited, hsMarkerAdded,
                      hsContent, hsContentDeleted, hsContentEdited, hsContentAdded);

  THSColDef = record
    Start: Integer;
    Length: Integer;
    Style: THighlightStyle;
  end;
  PHSColDef = ^THSColDef;

  { TSynHighlighterDiffWide }

  TSynHighlighterDiffWide = class(TSynCustomHighlighter)
  private
    FStyles: array[THighlightStyle] of TSynHighlighterAttributes;

    FLineText: string;
    FLineIndex: Integer;
    FLineType: Char;
    FContentWidth: Integer;
    FColDefs: array of THSColDef;

    FColIndex: Integer;
    FTokenPos: Integer;
    FTokenLength: Integer;
    FTokenStyle: THighlightStyle;

    function GetStyleAttrib(AIndex: THighlightStyle): TSynHighlighterAttributes;
  protected
    procedure SetToken(const StartPos, ALength: Integer; const Style: THighlightStyle); overload;
    procedure SetToken(const ColDef: PHSColDef); overload; inline;
  public
    procedure SetLine(const NewValue: String;
                  LineNumber:Integer // 0 based
                  ); override;
    procedure Next; override;
    function GetEol: Boolean; override;
    procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override;

    function GetTokenAttribute: TSynHighlighterAttributes; override;
    function GetToken: String; override;
    function GetTokenPos: Integer; override; // 0-based
    function GetTokenKind: integer; override;

    function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override;
    function GetEndOfLineAttribute: TSynHighlighterAttributes; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property UnknownAttrib: TSynHighlighterAttributes         index hsUnknown         read GetStyleAttrib;
    property HeaderAttrib: TSynHighlighterAttributes          index hsHeader          read GetStyleAttrib;
    property DividerAttrib: TSynHighlighterAttributes         index hsDivider         read GetStyleAttrib;
    property LineNumberAttrib: TSynHighlighterAttributes      index hsLineNumber      read GetStyleAttrib;
    property SpaceAttrib: TSynHighlighterAttributes           index hsSpace           read GetStyleAttrib;
    property MarkerDeletedAttrib: TSynHighlighterAttributes   index hsMarkerDeleted   read GetStyleAttrib;
    property MarkerEditedAttrib: TSynHighlighterAttributes    index hsMarkerEdited    read GetStyleAttrib;
    property MarkerAddedAttrib: TSynHighlighterAttributes     index hsMarkerAdded     read GetStyleAttrib;
	  property ContentAttrib: TSynHighlighterAttributes         index hsContent         read GetStyleAttrib;
    property ContentDeletedAttrib: TSynHighlighterAttributes  index hsContentDeleted  read GetStyleAttrib;
    property ContentEditedAttrib: TSynHighlighterAttributes   index hsContentEdited   read GetStyleAttrib;
    property ContentAddedAttrib: TSynHighlighterAttributes    index hsContentAdded    read GetStyleAttrib;
  end;

implementation
uses
  TypInfo;

{ TSynHighlighterDiffWide }

constructor TSynHighlighterDiffWide.Create(AOwner: TComponent);
var
  hs: THighlightStyle;
  Attr: TSynHighlighterAttributes;
  StyleName: string;
begin
  inherited Create(AOwner);




  FLineText := '';
  FLineIndex := -1;
  FLineType := #0;

  FTokenPos := 1;
  FTokenLength := 0;
  FTokenStyle := hsUnknown;

  SetLength(FColDefs, 0);
  FColIndex := 0;
  for hs := Low(THighlightStyle) to High(THighlightStyle) do begin
    //StyleName := GetEnumName(TypeInfo(THighlightStyle), Ord(hs));
    //StyleName := Copy(StyleName, 3, Length(StyleName));
    StyleName := 'Style' + IntToStr(Ord(hs));
    Attr := AddSpecialAttribute(StyleName, StyleName);
    FStyles[hs] := Attr;
    case hs of
      hsUnknown: begin
        Attr.Style := [fsItalic];
      end;
      hsHeader: begin
        Attr.Style := [fsBold];
      end;
      hsDivider: begin
        Attr.Style := [fsBold];
        Attr.Foreground := clBlue;
      end;
      hsSpace, hsContent: begin
      end;
      hsLineNumber: begin
        Attr.Background := clGray;
        Attr.Foreground := clWhite;
      end;
      hsMarkerAdded: begin
        Attr.Foreground := clGreen;
      end;
      hsMarkerEdited: begin
        Attr.Foreground := clNavy;
      end;
      hsMarkerDeleted: begin
        Attr.Foreground := clRed;
      end;
      hsContentAdded: begin
        //Attr.Background := TColor($99FF99); // TODO
      end;
      hsContentEdited: begin
        //Attr.Background := TColor($FF9999); // TODO
      end;
      hsContentDeleted: begin
        //Attr.Background := TColor($9999FF); // TODO
      end;
    end;
  end;
end;

destructor TSynHighlighterDiffWide.Destroy;
begin
  inherited Destroy;
end;

function TSynHighlighterDiffWide.GetStyleAttrib(AIndex: THighlightStyle
  ): TSynHighlighterAttributes;
begin
  Result := FStyles[AIndex];
end;

procedure TSynHighlighterDiffWide.SetToken(const StartPos, ALength: Integer;
                                            const Style: THighlightStyle);
begin
  FTokenPos := StartPos; // FTokenPos is 1-based
  if ALength < 0 then
    FTokenLength := Length(FLineText) - FTokenPos + 1
  else
    FTokenLength := ALength;
  FTokenStyle := Style;
end;
procedure TSynHighlighterDiffWide.SetToken(const ColDef: PHSColDef);
begin
  SetToken(ColDef^.Start, ColDef^.Length, ColDef^.Style);
end;

procedure TSynHighlighterDiffWide.SetLine(const NewValue: String;
  LineNumber: Integer);
var
  ColIndex: Integer;
  { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
  procedure ResetColDefs(const Length: Integer);
  begin
    SetLength(FColDefs, Length);
    ColIndex := 0;
  end;
  { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
  function AddColDef(const Length: Integer; const Style: THighlightStyle): Integer;
  begin
    Result := ColIndex;
    if ColIndex = 0 then
      FColDefs[Result].Start := 1
    else
      FColDefs[Result].Start := FColDefs[Result - 1].Start + FColDefs[Result - 1].Length;
    FColDefs[Result].Style := Style;
    Inc(ColIndex);
  end;
  { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
begin
  inherited SetLine(NewValue, LineNumber);

  FLineText := NewValue;
  FLineIndex := LineNumber;
  if Length(NewValue) = 0 then begin
    FLineType := #0;

    SetToken(1, -1, hsUnknown);
    Exit;
  end;
  // keep track of the type of line we're on
  FLineType := NewValue[1];
  case NewValue[1] of
    '=': begin // header
      // Determine the content width
      FContentWidth := (Length(FLineText) - 1) div 2 - 8;
      ResetColDefs(8);
      AddColDef(5, hsLineNumber);
      AddColDef(2, hsSpace);
      AddColDef(FContentWidth, hsContent);
      AddColDef(1, hsSpace);
      AddColDef(1, hsMarkerEdited);
      AddColDef(1, hsSpace);
      AddColDef(5, hsLineNumber);
      AddColDef(2, hsSpace);
      AddColDef(FContentWidth, hsContent);
      FColIndex := 0;
      // set the token to the entire line, and set the styler to HeaderAttri

      SetToken(1, -1, hsHeader);
    end;
    '.': begin // divider
      // set the token to the entire line, and set the styler to DividerAttri

      SetToken(1, -1, hsDivider);
    end;
    ' ', '0'..'9': begin // a diff line
      FLineType := ' ';
      // set the token to the first 5 chars, and set the styler to LineNumberAttri
      SetToken(1, 5, hsLineNumber);
    end;
    else begin // unknown
      FLineType := '?';
      // set the token to the entire line, and set the styler to UnknownAttri

      SetToken(1, -1, hsUnknown);
    end;
  end;
end;

procedure TSynHighlighterDiffWide.Next;
begin
  if FLineType = ' ' then begin
    // TODO: linenum[5], space[2], content[FContentWidth], space[1], marker[1], space[1], linenum[5], space[2], content[FContentWidth]
    Inc(FColIndex);
    if FColIndex < Length(FColDefs) then begin
      SetToken(@FColDefs[FColIndex]);
    end else begin
      SetToken(Length(FLineText) + 1, 0, hsSpace);
    end;
  end else begin
    SetToken(Length(FLineText) + 1, 0, hsSpace);
  end;
end;

function TSynHighlighterDiffWide.GetEol: Boolean;
begin
  Result := FTokenPos > Length(FLineText);
end;

procedure TSynHighlighterDiffWide.GetTokenEx(out TokenStart: PChar; out
  TokenLength: integer);
begin
  TokenStart := @FLineText[FTokenPos];
  TokenLength := FTokenLength;
end;

function TSynHighlighterDiffWide.GetEndOfLineAttribute: TSynHighlighterAttributes;
begin
  Result := inherited GetEndOfLineAttribute; // TODO?
end;

function TSynHighlighterDiffWide.GetTokenAttribute: TSynHighlighterAttributes;
begin
  Result := FStyles[FTokenStyle];
end;

function TSynHighlighterDiffWide.GetToken: String;
begin
  Result := Copy(FLineText, FTokenPos, FTokenLength);
end;

function TSynHighlighterDiffWide.GetTokenPos: Integer;
begin
  //  return the token position (0-based)
  Result := FTokenPos - 1;
end;

function TSynHighlighterDiffWide.GetTokenKind: integer;
begin
  Result := Ord(FTokenStyle);
end;

function TSynHighlighterDiffWide.GetDefaultAttribute(Index: integer
  ): TSynHighlighterAttributes;
begin
  case Index of
    SYN_ATTR_WHITESPACE: Result := Self.SpaceAttrib;
    else
      Result := nil;
  end;
end;

end.