Skip to content

Commit

Permalink
FarAPI update
Browse files Browse the repository at this point in the history
  • Loading branch information
Max.Rusov authored and Max.Rusov committed Feb 5, 2012
1 parent f55f3aa commit c0ba896
Show file tree
Hide file tree
Showing 122 changed files with 1,391 additions and 1,899 deletions.
6 changes: 1 addition & 5 deletions DlgSelect/DlgSelectMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ interface
uses
Windows,
MixTypes,
{$ifdef Far3}
Plugin3,
{$else}
PluginW,
{$endif Far3}
Far_API,
FarCtrl;

const
Expand Down
7 changes: 1 addition & 6 deletions EdtFind/EdtFindCtrl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ interface
MixStrings,
MixWinUtils,

{$ifdef Far3}
Plugin3,
{$else}
PluginW,
{$endif Far3}
FarColor,
Far_API,
FarCtrl,
FarMatch,
FarMenu,
Expand Down
9 changes: 1 addition & 8 deletions EdtFind/EdtFindDlg.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ interface
MixStrings,
MixClasses,

{$ifdef Far3}
Plugin3,
{$else}
PluginW,
{$endif Far3}
FarColor,

FarKeysW,
Far_API,
FarCtrl,
FarDlg,
FarMenu,
Expand Down
181 changes: 3 additions & 178 deletions EdtFind/EdtFindGrep.pas
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,20 @@ interface
MixStrings,
MixClasses,

{$ifdef Far3}
Plugin3,
{$else}
PluginW,
{$endif Far3}
FarKeysW,
FarColor,
Far_API,
FarCtrl,
FarMatch,
FarDlg,
FarGrid,
FarMenu,
FarDraw,
FarListDlg,

EdtFindCtrl,
EdtFinder,
EdtFindHints;


type
TDrawBuf = class(TBasis)
public
constructor Create; override;
destructor Destroy; override;

procedure SetPalette(const APalette :array of TFarColor);

procedure Clear;
procedure Add(AChr :TChar; Attr :Byte; ACount :Integer = 1);
procedure AddStrExpandTabsEx(AStr :PTChar; ALen :Integer; AColor :Byte);
procedure FillAttr(APos, ACount :Integer; AColor :Byte);
procedure FillLoAttr(APos, ACount :Integer; ALoColor :Byte);

procedure Paint(X, Y, ADelta, ALimit :Integer);

private
FTabSize :Integer;
FChars :PTChar;
FAttrs :PByteArray;
FCount :Integer;
FSize :Integer;
FPalette :array of TFarColor;

procedure SetSize(ASize :Integer);

public
property Count :Integer read FCount;
end;


type
TGrepDlg = class(TFilteredListDlg)
public
Expand All @@ -94,7 +58,7 @@ TGrepDlg = class(TFilteredListDlg)
function DialogHandler(Msg :Integer; Param1 :Integer; Param2 :TIntPtr) :TIntPtr; override;

private
FDrawBuf :TDrawBuf;
FDrawBuf :TDrawBuf;
FMatches :TExList;
FNeedSync :Boolean;

Expand Down Expand Up @@ -134,145 +98,6 @@ TGrepDlg = class(TFilteredListDlg)
end;
end;


{-----------------------------------------------------------------------------}
{ TDrawBuf }
{-----------------------------------------------------------------------------}

constructor TDrawBuf.Create; {override;}
begin
inherited Create;
FTabSize := DefTabSize;
end;


destructor TDrawBuf.Destroy; {override;}
begin
MemFree(FChars);
MemFree(FAttrs);
inherited Destroy;
end;


procedure TDrawBuf.SetPalette(const APalette :array of TFarColor);
var
I :Integer;
begin
SetLength(FPalette, High(APalette) + 1);
for I := 0 to High(APalette) do
FPalette[I] := APalette[I];
end;


procedure TDrawBuf.Clear;
begin
FCount := 0;
end;


procedure TDrawBuf.Add(AChr :TChar; Attr :Byte; ACount :Integer = 1);
var
I :Integer;
begin
if FCount + ACount + 1 > FSize then
SetSize(FCount + ACount + 1);
for I := 0 to ACount - 1 do begin
FChars[FCount] := AChr;
FAttrs[FCount] := Attr;
Inc(FCount);
end;
end;


procedure TDrawBuf.AddStrExpandTabsEx(AStr :PTChar; ALen :Integer; AColor :Byte);
var
vEnd :PTChar;
vChr :TChar;
vAtr :Byte;
vDPos, vDstLen, vSize :Integer;
begin
vDstLen := ChrExpandTabsLen(AStr, ALen, FTabSize);
if FCount + vDstLen + 1 > FSize then
SetSize(FCount + vDstLen + 1);

vEnd := AStr + ALen;
vDPos := 0;
while AStr < vEnd do begin
vChr := AStr^;
vAtr := AColor;

if vChr <> charTab then begin
Assert(vDPos < vDstLen);
Add(vChr, vAtr);
Inc(vDPos);
end else
begin
vSize := FTabSize - (vDPos mod FTabSize);
Assert(vDPos + vSize <= vDstLen);
Add(' ', vAtr, vSize);
Inc(vDPos, vSize);
end;
Inc(AStr);
end;
FChars[FCount] := #0;
end;


procedure TDrawBuf.FillAttr(APos, ACount :Integer; AColor :Byte);
begin
Assert(APos + ACount <= FCount);
FillChar(FAttrs[APos], ACount, AColor);
end;


procedure TDrawBuf.FillLoAttr(APos, ACount :Integer; ALoColor :Byte);
var
I :Integer;
begin
Assert(APos + ACount <= FCount);
for I := APos to APos + ACount - 1 do
FAttrs[I] := (FAttrs[I] and $F0) or (ALoColor and $0F);
end;


procedure TDrawBuf.Paint(X, Y, ADelta, ALimit :Integer);
var
I, J, vEnd, vPartLen :Integer;
vAtr :Byte;
vTmp :TChar;
begin
vEnd := FCount;
if FCount - ADelta > ALimit then
vEnd := ADelta + ALimit;

I := ADelta;
while I < vEnd do begin
vAtr := FAttrs[I];
J := I + 1;
while (J < vEnd) and (FAttrs[J] = vAtr) do
Inc(J);
vPartLen := J - I;
if I + vPartLen = FCount then
FARAPI.Text(X, Y, FPalette[vAtr], FChars + I )
else begin
vTmp := (FChars + I + vPartLen)^;
(FChars + I + vPartLen)^ := #0;
FARAPI.Text(X, Y, FPalette[vAtr], FChars + I );
(FChars + I + vPartLen)^ := vTmp;
end;
Inc(X, vPartLen);
Inc(I, vPartLen);
end;
end;


procedure TDrawBuf.SetSize(ASize :Integer);
begin
ReallocMem(FChars, ASize * SizeOf(TChar));
ReallocMem(FAttrs, ASize * SizeOf(Byte));
FSize := ASize;
end;


{-----------------------------------------------------------------------------}
{ TGrepDlg }
Expand Down
7 changes: 1 addition & 6 deletions EdtFind/EdtFindHints.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ interface
MixUtils,
MixStrings,

{$ifdef Far3}
Plugin3,
{$else}
PluginW,
{$endif Far3}

Far_API,
FarCtrl,
FarDlg,
FarGrid,
Expand Down
6 changes: 1 addition & 5 deletions EdtFind/EdtFindMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ interface
MixClasses,
MixFormat,

{$ifdef Far3}
Plugin3,
{$else}
PluginW,
{$endif Far3}
Far_API,
FarCtrl,
FarPlug,
FarMenu,
Expand Down
6 changes: 1 addition & 5 deletions EdtFind/EdtFinder.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ interface
MixClasses,
MixFormat,

{$ifdef Far3}
Plugin3,
{$else}
PluginW,
{$endif Far3}
Far_API,
FarCtrl,

EdtFindCtrl;
Expand Down
7 changes: 1 addition & 6 deletions EdtFind/EdtReplaceDlg.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ interface
MixUtils,
MixStrings,

{$ifdef Far3}
Plugin3,
{$else}
PluginW,
{$endif Far3}
FarKeysW,
Far_API,
FarCtrl,
FarDlg,

Expand Down
9 changes: 1 addition & 8 deletions FarDebug/FarDebugAddrsList.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ interface
MixStrings,
MixClasses,

{$ifdef bUnicodeFar}
PluginW,
FarKeysW,
{$else}
Plugin,
FarKeys,
{$endif bUnicodeFar}
FarColor,
Far_API,
FarCtrl,
FarDlg,
FarGrid,
Expand Down
9 changes: 1 addition & 8 deletions FarDebug/FarDebugBreakpoints.pas
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ interface
MixFormat,
MixStrings,

{$ifdef bUnicodeFar}
PluginW,
FarKeysW,
{$else}
Plugin,
FarKeys,
{$endif bUnicodeFar}
FarColor,
Far_API,
FarCtrl,
FarDlg,
FarGrid,
Expand Down
9 changes: 1 addition & 8 deletions FarDebug/FarDebugCallstack.pas
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ interface
MixStrings,
MixClasses,

{$ifdef bUnicodeFar}
PluginW,
FarKeysW,
{$else}
Plugin,
FarKeys,
{$endif bUnicodeFar}
FarColor,
Far_API,
FarCtrl,
FarDlg,
FarGrid,
Expand Down
9 changes: 1 addition & 8 deletions FarDebug/FarDebugConsole.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ interface
MixStrings,
MixClasses,

{$ifdef bUnicodeFar}
PluginW,
FarKeysW,
{$else}
Plugin,
FarKeys,
{$endif bUnicodeFar}
FarColor,
Far_API,
FarCtrl,
FarDlg,
FarGrid,
Expand Down
2 changes: 1 addition & 1 deletion FarDebug/FarDebugCtrl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ interface
MixUtils,
MixStrings,
MixWinUtils,
PluginW,

Far_API,
FarCtrl,
FarMatch;

Expand Down
5 changes: 1 addition & 4 deletions FarDebug/FarDebugDisasm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ interface
MixStrings,
MixClasses,

PluginW,
FarKeysW,

FarColor,
Far_API,
FarCtrl,
FarDlg,
FarGrid,
Expand Down
Loading

0 comments on commit c0ba896

Please sign in to comment.