* search fixed

+ backward search
  * help fixes
  * browser updates
This commit is contained in:
peter 1999-02-18 13:44:30 +00:00
parent 6352fd282f
commit f511ac5267
10 changed files with 595 additions and 581 deletions

View File

@ -22,7 +22,7 @@ uses
Dos,
BrowCol,
FPIni,FPViews,FPConst,FPVars,FPUtils,FPIde,FPHelp,FPSwitch,FPUsrScr,
FPTools,FPDebug
FPTools,FPDebug,FPTemplt
{$ifdef TEMPHEAP}
,dpmiexcp
{$endif TEMPHEAP}
@ -83,6 +83,7 @@ BEGIN
InitINIFile;
InitUserScreen;
InitTools;
InitTemplates;
{ load old options }
ReadINIFile;
@ -97,7 +98,8 @@ BEGIN
WriteSwitches(SwitchesPath);
WriteINIFile;
DoneTemplates;
DoneTools;
DoneUserScreen;
DoneSwitches;
@ -109,7 +111,13 @@ BEGIN
END.
{
$Log$
Revision 1.10 1999-02-15 09:07:10 pierre
Revision 1.11 1999-02-18 13:44:30 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.10 1999/02/15 09:07:10 pierre
* HEAPTRC conditionnal renamed IDEHEAPTRC
Revision 1.9 1999/02/10 09:55:43 pierre

View File

@ -143,7 +143,6 @@ begin
ProgramInfoWindow^.Hide;
Desktop^.Insert(ProgramInfoWindow);
Message(@Self,evBroadcast,cmUpdate,nil);
InitTemplates;
CurDirChanged;
end;
@ -658,13 +657,18 @@ destructor TIDEApp.Done;
begin
inherited Done;
DoneHelpSystem;
DoneTemplates;
end;
END.
{
$Log$
Revision 1.15 1999-02-16 10:43:55 peter
Revision 1.16 1999-02-18 13:44:31 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.15 1999/02/16 10:43:55 peter
* use -dGDB for the compiler
* only use gdb_file when -dDEBUG is used
* profiler switch is now a toggle instead of radiobutton

View File

@ -375,10 +375,8 @@ begin
Items:=NewSItem(ProfileInfoSwitches^.ItemName(I), Items);
New(CB, Init(R2, Items));
L:=ProfileInfoSwitches^.GetCurrSel;
If L = 1 then
CB^.SetData(3)
else
CB^.SetData(1);
If L = 1 then L:=3;
CB^.SetData(L);
Insert(CB);
R2.Copy(R); Inc(R2.A.Y,6); R2.B.Y:=R2.A.Y+1;
Insert(New(PLabel, Init(R2, 'Profiling Switches', CB)));
@ -724,7 +722,13 @@ end;
{
$Log$
Revision 1.15 1999-02-16 17:15:28 pierre
Revision 1.16 1999-02-18 13:44:32 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.15 1999/02/16 17:15:28 pierre
* Peter's debug code commented
Revision 1.14 1999/02/16 10:43:56 peter

View File

@ -130,13 +130,13 @@ var
FileName : string;
LineNr : longint;
begin
if not assigned(DeskTop^.First) or
if (DeskTop^.First=nil) or
(TypeOf(DeskTop^.First^)<>TypeOf(TSourceWindow)) then
Begin
ErrorBox('Impossible to reach current cursor',nil);
Exit;
End;
W:=PSourceWindow(DeskTop^.First);
If assigned(W) then
begin
@ -163,13 +163,13 @@ var
b : boolean;
LineNr : longint;
begin
if not assigned(DeskTop^.First) or
if (DeskTop^.First=nil) or
(TypeOf(DeskTop^.First^)<>TypeOf(TSourceWindow)) then
Begin
ErrorBox('Impossible to set breakpoints here',nil);
Exit;
End;
W:=PSourceWindow(DeskTop^.First);
If assigned(W) then
begin
@ -182,7 +182,13 @@ end;
{
$Log$
Revision 1.12 1999-02-11 19:07:24 pierre
Revision 1.13 1999-02-18 13:44:33 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.12 1999/02/11 19:07:24 pierre
* GDBWindow redesigned :
normal editor apart from
that any kbEnter will send the line (for begin to cursor)

View File

@ -23,11 +23,11 @@ uses Objects,Drivers,Views,Dialogs,
const
{ Browser tab constants }
btScope = 1;
btReferences = 2;
btInheritance = 4;
btBreakWatch = 8;
btScope = 0;
btReferences = 1;
btInheritance = 2;
btBreakWatch = 3;
type
PSymbolView = ^TSymbolView;
TSymbolView = object(TListBox)
@ -62,13 +62,25 @@ type
References: PReferenceCollection;
end;
PBrowserTabItem = ^TBrowserTabItem;
TBrowserTabItem = record
Sign : char;
Link : PView;
Next : PBrowserTabItem;
end;
PBrowserTab = ^TBrowserTab;
TBrowserTab = object(TView)
constructor Init(var Bounds: TRect);
Items: PBrowserTabItem;
constructor Init(var Bounds: TRect; AItems: PBrowserTabItem);
function GetItemCount: sw_integer; virtual;
function GetItem(Index: sw_integer): PBrowserTabItem; virtual;
procedure SetParams(AFlags: word; ACurrent: Sw_integer); virtual;
procedure SelectItem(Index: Sw_integer); virtual;
procedure Draw; virtual;
procedure HandleEvent(var Event: TEvent);virtual;
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
destructor Done; virtual;
private
Flags : word;
Current : Sw_integer;
@ -103,6 +115,28 @@ uses Commands,App,
WEditor,FPDebug,
FPConst,FPUtils,FPVars;
function NewBrowserTabItem(ASign: char; ALink: PView; ANext: PBrowserTabItem): PBrowserTabItem;
var P: PBrowserTabItem;
begin
New(P); FillChar(P^,SizeOf(P^),0);
with P^ do begin Sign:=ASign; Link:=ALink; Next:=ANext; end;
NewBrowserTabItem:=P;
end;
procedure DisposeBrowserTabItem(P: PBrowserTabItem);
begin
if P<>nil then Dispose(P);
end;
procedure DisposeBrowserTabList(P: PBrowserTabItem);
begin
if P<>nil then
begin
if P^.Next<>nil then DisposeBrowserTabList(P^.Next);
DisposeBrowserTabItem(P);
end;
end;
function IsSymbolInfoAvailable: boolean;
begin
IsSymbolInfoAvailable:=BrowCol.Modules<>nil;
@ -118,7 +152,7 @@ var Index : sw_integer;
begin
Search:=UpcaseStr(P^.Items^.LookUp(Name,Index))=Name;
end;
begin
Name:=UpcaseStr(Name);
If BrowCol.Modules<>nil then
@ -413,7 +447,6 @@ begin
Desktop^.UnLock;
end;
(* this does not work correctly
function LastBrowserWindow: PBrowserWindow;
var BW: PBrowserWindow;
procedure IsBW(P: PView); {$ifndef FPC}far;{$endif}
@ -425,26 +458,6 @@ begin
BW:=nil;
Desktop^.ForEach(@IsBW);
LastBrowserWindow:=BW;
end; *)
function LastBrowserWindowBeforeAnyOtherWindow: PBrowserWindow;
var BW: PBrowserWindow;
AnyOther : boolean;
procedure IsBW(P: PView); {$ifndef FPC}far;{$endif}
begin
if (P^.HelpCtx=hcBrowserWindow) then
begin
if not AnyOther then
BW:=pointer(P);
end
else
AnyOther:=true;
end;
begin
AnyOther:=false;
BW:=nil;
Desktop^.ForEach(@IsBW);
LastBrowserWindowBeforeAnyOtherWindow:=BW;
end;
procedure TSymbolReferenceView.TrackSource;
@ -461,16 +474,12 @@ begin
W:=TryToOpenFile(nil,R^.GetFileName,P.X,P.Y);
if W<>nil then
begin
{ do not count W }
Desktop^.Delete(W);
BW:=LastBrowserWindowBeforeAnyOtherWindow;
BW:=LastBrowserWindow;
if BW=nil then
begin
Desktop^.Insert(W);
W^.Select;
end
W^.Select
else
begin
Desktop^.Delete(W);
Desktop^.InsertBefore(W,BW^.NextView);
end;
W^.Editor^.SetHighlightRow(P.Y);
@ -493,37 +502,77 @@ end;
TBrowserTab
****************************************************************************}
constructor TBrowserTab.Init(var Bounds: TRect);
constructor TBrowserTab.Init(var Bounds: TRect; AItems: PBrowserTabItem);
begin
inherited Init(Bounds);
Options:=Options or ofPreProcess;
Items:=AItems;
SetParams(0,0);
end;
procedure TBrowserTab.SetParams(AFlags: word; ACurrent: Sw_integer);
begin
Flags:=AFlags; Current:=ACurrent;
Flags:=AFlags;
SelectItem(ACurrent);
end;
procedure TBrowserTab.SelectItem(Index: Sw_integer);
var P: PBrowserTabItem;
begin
Current:=Index;
P:=GetItem(Current);
if (P<>nil) and (P^.Link<>nil) then
P^.Link^.Focus;
DrawView;
end;
function TBrowserTab.GetItemCount: sw_integer;
var Count: integer;
P: PBrowserTabItem;
begin
Count:=0; P:=Items;
while (P<>nil) do
begin
Inc(Count);
P:=P^.Next;
end;
GetItemCount:=Count;
end;
function TBrowserTab.GetItem(Index: sw_integer): PBrowserTabItem;
var Counter: integer;
P: PBrowserTabItem;
begin
P:=Items; Counter:=0;
while (P<>nil) and (Counter<Index) do
begin
P:=P^.Next;
Inc(Counter);
end;
GetItem:=P;
end;
procedure TBrowserTab.Draw;
var B: TDrawBuffer;
SelColor, NormColor, C: word;
I,CurX,Count: Sw_integer;
const
Names: string[4] = 'SRIB';
function Names(Idx: integer): char;
begin
Names:=GetItem(Idx)^.Sign;
end;
begin
NormColor:=GetColor(1); SelColor:=GetColor(2);
MoveChar(B,'Ä',SelColor,Size.X);
CurX:=0; Count:=0;
for I:=0 to 3 do
for I:=0 to GetItemCount-1 do
if (Flags and (1 shl I))<>0 then
begin
Inc(Count);
if Current=(1 shl I) then C:=SelColor
else C:=NormColor;
if Current=I then C:=SelColor
else C:=NormColor;
if Count=1 then MoveChar(B[CurX],'´',SelColor,1)
else MoveChar(B[CurX],'³',SelColor,1);
MoveCStr(B[CurX+1],' '+Names[I+1]+' ',C);
MoveCStr(B[CurX+1],' '+Names(I)+' ',C);
Inc(CurX,4);
end;
if Count>0 then
@ -531,46 +580,65 @@ begin
WriteLine(0,0,Size.X,Size.Y,B);
end;
procedure TBrowserTab.HandleEvent(var Event: TEvent);
var I,Idx: integer;
DontClear: boolean;
P: TPoint;
function GetItemForCoord(X: integer): integer;
var I,CurX,Idx: integer;
begin
CurX:=0; Idx:=-1;
for I:=0 to GetItemCount-1 do
if (Flags and (1 shl I))<>0 then
begin
if (CurX+1<=X) and (X<=CurX+3) then
begin Idx:=I; Break; end;
Inc(CurX,4);
end;
GetItemForCoord:=Idx;
end;
begin
case Event.What of
evMouseDown :
if MouseInView(Event.Where) then
begin
repeat
MakeLocal(Event.Where,P);
Idx:=GetItemForCoord(P.X);
if Idx<>-1 then
SelectItem(Idx);
until not MouseEvent(Event, evMouseMove);
ClearEvent(Event);
end;
evKeyDown :
begin
DontClear:=false; Idx:=-1;
for I:=0 to GetItemCount-1 do
if Upcase(GetCtrlChar(Event.KeyCode))=Upcase(GetItem(I)^.Sign) then
begin
Idx:=I;
Break;
end;
if Idx=-1 then
DontClear:=true
else
SelectItem(Idx);
if DontClear=false then ClearEvent(Event);
end;
end;
inherited HandleEvent(Event);
end;
function TBrowserTab.GetPalette: PPalette;
const P: string[length(CBrowserTab)] = CBrowserTab;
begin
GetPalette:=@P;
end;
procedure TBrowserTab.HandleEvent(var Event: TEvent);
var
i,bt : byte;
index,X : Sw_integer;
P : Tpoint;
destructor TBrowserTab.Done;
begin
if (Event.What and evMouseDown)<>0 then
begin
MakeLocal(Event.Where,P);
if P.Y<3 then
begin
bt:=1;
X:=1;
Index:=-1;
for i:=0 to 3 do
begin
if bt=0 then
bt:=1
else
bt:=bt*2;
if (Flags and (1 shl I))<>0 then
begin
if (P.X>X) and (P.X<=X+3) then Index:=bt;
X:=X+4;
end;
end;
if Index<>-1 then
Begin
PBrowserWindow(Owner)^.SelectTab(Index);
ClearEvent(Event);
End;
end;
end;
Inherited HandleEvent(Event);
inherited Done;
if Items<>nil then DisposeBrowserTabList(Items);
end;
constructor TBrowserWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer;ASym : PSymbol;
@ -603,11 +671,6 @@ begin
New(ST, Init(R, ' '+AName)); ST^.GrowMode:=gfGrowHiX;
Insert(ST);
GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.B.Y:=R.A.Y+1;
New(PageTab, Init(R));
PageTab^.GrowMode:=gfGrowHiX;
Insert(PageTab);
GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,2);
if assigned(ASymbols) and (ASymbols^.Count>0) then
begin
@ -625,6 +688,16 @@ begin
ReferenceView^.GrowMode:=gfGrowHiX+gfGrowHiY;
Insert(ReferenceView);
end;
GetExtent(R); R.Grow(-1,-1); R.Move(0,1); R.B.Y:=R.A.Y+1;
New(PageTab, Init(R,
NewBrowserTabItem('S',ScopeView,
NewBrowserTabItem('R',ReferenceView,
nil))
));
PageTab^.GrowMode:=gfGrowHiX;
Insert(PageTab);
if assigned(ScopeView) then
SelectTab(btScope)
else
@ -662,12 +735,6 @@ begin
case Event.KeyCode of
kbEsc :
Close;
kbCtrlB :
SelectTab(btBreakWatch);
kbCtrlS :
SelectTab(btScope);
kbCtrlR :
SelectTab(btReferences);
else DontClear:=true;
end;
if DontClear=false then ClearEvent(Event);
@ -698,25 +765,13 @@ var Tabs: Sw_integer;
PS :PString;
l : longint;
begin
case BrowserTab of
(* case BrowserTab of
btScope :
if assigned(ScopeView) then
begin
RemoveView(ScopeView^.HScrollBar);
InsertView(ScopeView^.HScrollBar,First);
RemoveView(ScopeView^.VScrollBar);
InsertView(ScopeView^.VScrollBar,First);
ScopeView^.Select;
end;
ScopeView^.Select;
btReferences :
if assigned(ReferenceView) then
begin
RemoveView(ReferenceView^.HScrollBar);
InsertView(ReferenceView^.HScrollBar,First);
RemoveView(ReferenceView^.VScrollBar);
InsertView(ReferenceView^.VScrollBar,First);
ReferenceView^.Select;
end;
ReferenceView^.Select;
btBreakWatch :
begin
if Assigned(Sym) then
@ -774,20 +829,15 @@ begin
end;
end;
end;
end;*)
Tabs:=0;
if assigned(ScopeView) then
Tabs:=Tabs or btScope;
Tabs:=Tabs or (1 shl btScope);
if assigned(ReferenceView) then
Tabs:=Tabs or btReferences;
Tabs:=Tabs or (1 shl btReferences);
if Assigned(Sym) then
if (Pos('proc',Sym^.GetText)>0) or (Pos('var',Sym^.GetText)>0) then
Tabs:=Tabs or btBreakWatch;
if (Tabs and BrowserTab)=0 then
if (Tabs and btScope)<>0 then BrowserTab:=btScope else
if (Tabs and btReferences)<>0 then BrowserTab:=btReferences else
if (Tabs and btInheritance)<>0 then BrowserTab:=btInheritance else
BrowserTab:=btBreakWatch;
Tabs:=Tabs or (1 shl btBreakWatch);
if PageTab<>nil then PageTab^.SetParams(Tabs,BrowserTab);
end;
@ -813,12 +863,11 @@ end;
END.
{
$Log$
Revision 1.8 1999-02-17 15:50:27 pierre
* ScrollBars in SymbolView where allways for ReferenceView
* TrackSource puts now the source in front of the first non
browser window !
+* Tried to get mouse clicks in TBrowserTab to issue correct
command, but still does not work !
Revision 1.9 1999-02-18 13:44:34 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.7 1999/02/16 12:44:20 pierre
* DoubleClick works now

View File

@ -19,10 +19,11 @@ interface
uses FPViews;
procedure InitTemplates;
function GetTemplateCount: integer;
function GetTemplateName(Index: integer): string;
function StartTemplate(Index: integer; Editor: PSourceEditor): boolean;
procedure InitTemplates;
procedure DoneTemplates;
implementation
@ -52,22 +53,26 @@ type
const Templates : PTemplateCollection = nil;
function NewTemplate(Name, Path: string): PTemplate;
function NewTemplate(const Name, Path: string): PTemplate;
var P: PTemplate;
begin
New(P); FillChar(P^,SizeOf(P^),0);
P^.Name:=NewStr(Name); P^.Path:=NewStr(Path);
New(P);
FillChar(P^,SizeOf(P^),0);
P^.Name:=NewStr(Name);
P^.Path:=NewStr(Path);
NewTemplate:=P;
end;
procedure DisposeTemplate(P: PTemplate);
begin
if P<>nil then
begin
if P^.Name<>nil then DisposeStr(P^.Name);
if P^.Path<>nil then DisposeStr(P^.Path);
Dispose(P);
end;
if assigned(P) then
begin
if assigned(P^.Name) then
DisposeStr(P^.Name);
if assigned(P^.Path) then
DisposeStr(P^.Path);
Dispose(P);
end;
end;
function TTemplateCollection.At(Index: Integer): PTemplate;
@ -77,7 +82,8 @@ end;
procedure TTemplateCollection.FreeItem(Item: Pointer);
begin
if Item<>nil then DisposeTemplate(Item);
if assigned(Item) then
DisposeTemplate(Item);
end;
function TTemplateCollection.Compare(Key1, Key2: Pointer): Sw_Integer;
@ -91,31 +97,6 @@ begin
Compare:=R;
end;
procedure InitTemplates;
procedure ScanDir(Dir: PathStr);
var SR: SearchRec;
S: string;
begin
if copy(Dir,length(Dir),1)<>DirSep then Dir:=Dir+DirSep;
FindFirst(Dir+'*.pt',AnyFile,SR);
while (DosError=0) do
begin
S:=NameOf(SR.Name);
S:=LowerCaseStr(S);
S[1]:=Upcase(S[1]);
Templates^.Insert(NewTemplate(S,FExpand(Dir+SR.Name)));
FindNext(SR);
end;
{$ifdef FPC}
FindClose(SR);
{$endif def FPC}
end;
begin
New(Templates, Init(10,10));
ScanDir('.');
ScanDir(DirOf(ParamStr(0)));
end;
function GetTemplateCount: integer;
var Count: integer;
begin
@ -151,16 +132,58 @@ begin
StartTemplate:=OK;
end;
{*****************************************************************************
InitTemplates
*****************************************************************************}
procedure InitTemplates;
procedure ScanDir(Dir: PathStr);
var SR: SearchRec;
S: string;
begin
if copy(Dir,length(Dir),1)<>DirSep then Dir:=Dir+DirSep;
FindFirst(Dir+'*.pt',AnyFile,SR);
while (DosError=0) do
begin
S:=NameOf(SR.Name);
S:=LowerCaseStr(S);
S[1]:=Upcase(S[1]);
Templates^.Insert(NewTemplate(S,FExpand(Dir+SR.Name)));
FindNext(SR);
end;
{$ifdef FPC}
FindClose(SR);
{$endif def FPC}
end;
begin
New(Templates, Init(10,10));
ScanDir('.');
ScanDir(DirOf(ParamStr(0)));
end;
procedure DoneTemplates;
begin
if Templates<>nil then
Dispose(Templates, Done);
if assigned(Templates) then
begin
Dispose(Templates, Done);
Templates:=nil;
end;
end;
END.
{
$Log$
Revision 1.4 1999-02-16 17:13:56 pierre
Revision 1.5 1999-02-18 13:44:35 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.4 1999/02/16 17:13:56 pierre
+ findclose added for FPC
Revision 1.3 1999/01/21 11:54:24 peter

View File

@ -19,7 +19,6 @@ interface
{$ifndef FPC}
{$define TPUNIXLF}
{.$define ASMSCAN}
{$endif}
uses
@ -541,277 +540,10 @@ begin
CompressUsingTabs:=S;
end;
{$ifdef ASMSCAN}
function Scan_F(var Block; Size: Word; Str: String): Word; near; assembler;
asm
PUSH DS
LES DI,Block
LDS SI,Str
MOV CX,Size
JCXZ @@3
CLD
LODSB
CMP AL,1
JB @@5
JA @@1
LODSB
REPNE SCASB
JNE @@3
JMP @@5
@@1: XOR AH,AH
MOV BX,AX
DEC BX
MOV DX,CX
SUB DX,AX
JB @@3
LODSB
INC DX
INC DX
@@2: DEC DX
MOV CX,DX
REPNE SCASB
JNE @@3
MOV DX,CX
MOV CX,BX
REP CMPSB
JE @@4
SUB CX,BX
ADD SI,CX
ADD DI,CX
INC DI
OR DX,DX
JNE @@2
@@3: XOR AX,AX
JMP @@6
@@4: SUB DI,BX
@@5: MOV AX,DI
SUB AX,WORD PTR Block
@@6: DEC AX
POP DS
end;
function IScan_F(var Block; Size: Word; Str: String): Word; near; assembler;
var
S: String;
asm
PUSH DS
MOV AX,SS
MOV ES,AX
LEA DI,S
LDS SI,Str
XOR AH,AH
LODSB
STOSB
MOV CX,AX
MOV BX,AX
JCXZ @@9
@@1: LODSB
CMP AL,'a'
JB @@2
CMP AL,'z'
JA @@2
SUB AL,20H
@@2: STOSB
LOOP @@1
SUB DI,BX
LDS SI,Block
MOV CX,Size
JCXZ @@8
CLD
SUB CX,BX
JB @@8
INC CX
@@4: MOV AH,ES:[DI]
AND AH,$DF
@@5: LODSB
AND AL,$DF
CMP AL,AH
LOOPNE @@5
JNE @@8
DEC SI
MOV DX,CX
MOV CX,BX
@@6: REPE CMPSB
JE @@10
MOV AL,DS:[SI-1]
CMP AL,'a'
JB @@7
CMP AL,'z'
JA @@7
SUB AL,20H
@@7: CMP AL,ES:[DI-1]
JE @@6
SUB CX,BX
ADD SI,CX
ADD DI,CX
INC SI
MOV CX,DX
OR CX,CX
JNE @@4
@@8: XOR AX,AX
JMP @@11
@@9: MOV AX, 1
JMP @@11
@@10: SUB SI,BX
MOV AX,SI
SUB AX,WORD PTR Block
INC AX
@@11: DEC AX
POP DS
end;
function Scan_B(var Block; Size: Word; Str: String): Word; near; assembler;
asm
PUSH DS
LES DI,Block
LDS SI,Str
MOV CX,Size
JCXZ @@3
CLD
LODSB
CMP AL,1
JB @@5
JA @@1
LODSB
STD
REPNE SCASB
JNE @@3
JMP @@5
@@1: XOR AH,AH
ADD SI, AX { !! }
DEC SI
ADD DI, CX { !! }
DEC DI
SUB DI, AX
STD
MOV BX,AX
DEC BX
MOV DX,CX
{ SUB DX,AX}
JB @@3
LODSB
INC DX
INC DX
@@2: DEC DX
MOV CX,DX
REPNE SCASB
JNE @@3
MOV DX,CX
MOV CX,BX
REP CMPSB
JE @@4
SUB CX,BX
SUB SI,CX { ADD }
SUB DI,CX { ADD }
DEC DI { INC DI }
OR DX,DX
JNE @@2
@@3: XOR AX,AX
JMP @@6
@@4: ADD DI,BX
@@5: MOV AX,DI
SUB AX,WORD PTR Block
@@6: DEC AX
POP DS
end;
function IScan_B(var Block; Size: Word; Str: String): Word; near; assembler;
var
S: String;
asm
PUSH DS
MOV AX,SS
MOV ES,AX
LEA DI,S
LDS SI,Str
XOR AH,AH
LODSB
STOSB
MOV CX,AX
MOV BX,AX
JCXZ @@9
@@1: LODSB
CMP AL,'a'
JB @@2
CMP AL,'z'
JA @@2
SUB AL,20H
@@2: STOSB
LOOP @@1
SUB DI,BX
LDS SI,Block
ADD SI,Size
SUB SI, BX
MOV CX,Size
JCXZ @@8
CLD
SUB CX,BX
JB @@8
INC CX
ADD SI, 2
@@4: SUB SI, 2
MOV AH,ES:[DI]
AND AH,$DF
ADD SI,2
@@5: SUB SI,2
LODSB
AND AL,$DF
CMP AL,AH
LOOPNE @@5
JNE @@8
DEC SI
MOV DX,CX
MOV CX,BX
@@6: REPE CMPSB
JE @@10
MOV AL,DS:[SI-1]
CMP AL,'a'
JB @@7
CMP AL,'z'
JA @@7
SUB AL,20H
@@7: CMP AL,ES:[DI-1]
JE @@6
SUB CX,BX
ADD SI,CX
ADD DI,CX
INC SI
MOV CX,DX
OR CX,CX
JNE @@4
@@8: XOR AX,AX
JMP @@11
@@9: MOV AX, 1
JMP @@11
@@10: SUB SI,BX
MOV AX,SI
SUB AX,WORD PTR Block
INC AX
@@11: DEC AX
POP DS
end;
function PosB(SubS, InS: string; CaseSensitive: boolean): byte;
var W: word;
begin
if CaseSensitive then W:=Scan_B(InS[1],length(Ins),SubS)
else W:=IScan_B(InS[1],length(Ins),SubS);
if W=$ffff then W:=0 else W:=W+1;
PosB:=W;
end;
function PosF(SubS, InS: string; CaseSensitive: boolean): byte;
var W: word;
begin
if CaseSensitive then W:=Scan_F(InS[1],length(Ins),SubS)
else W:=IScan_F(InS[1],length(Ins),SubS);
if W=$ffff then W:=0 else W:=W+1;
PosF:=W;
end;
{$else}
{*****************************************************************************
Forward/Backward Scanning
*****************************************************************************}
Const
{$ifndef FPC}
@ -852,22 +584,22 @@ begin
s2[0]:=chr(len); { sets the length to that of the search String }
found:=False;
numb:=pred(len);
While (not found) and (numb<(size-len)) do
While (not found) and (numb<size) do
begin
{ partial match }
if buffer[numb] = ord(str[len]) then
begin
{ less partial! }
if buffer[numb-pred(len)] = ord(str[1]) then
begin
move(buffer[numb-pred(len)],s2[1],len);
if (str=s2) then
begin
found:=true;
break;
end;
end;
inc(numb);
{ less partial! }
if buffer[numb-pred(len)] = ord(str[1]) then
begin
move(buffer[numb-pred(len)],s2[1],len);
if (str=s2) then
begin
found:=true;
break;
end;
end;
inc(numb);
end
else
inc(numb,Bt[buffer[numb]]);
@ -890,14 +622,14 @@ Var
c : char;
begin
len:=length(str);
if len>size then
if (len=0) or (len>size) then
begin
BMFIScan := NotFoundValue;
exit;
end;
found:=False;
numb:=pred(len);
While (not found) and (numb<(size-len)) do
While (not found) and (numb<size) do
begin
{ partial match }
c:=buffer[numb];
@ -905,35 +637,146 @@ begin
c:=chr(ord(c)-32);
if (c=str[len]) then
begin
{ less partial! }
p:=@buffer[numb-pred(len)];
x:=1;
while (x<=len) do
begin
if not(((p^ in ['a'..'z']) and (chr(ord(p^)-32)=str[x])) or
(p^=str[x])) then
break;
inc(p);
inc(x);
end;
if (x>len) then
begin
found:=true;
break;
end;
inc(numb);
end
else
inc(numb,Bt[ord(c)]);
end;
{ less partial! }
p:=@buffer[numb-pred(len)];
x:=1;
while (x<=len) do
begin
if not(((p^ in ['a'..'z']) and (chr(ord(p^)-32)=str[x])) or
(p^=str[x])) then
break;
inc(p);
inc(x);
end;
if (x>len) then
begin
found:=true;
break;
end;
inc(numb);
end
else
inc(numb,Bt[ord(c)]);
end;
if not found then
BMFIScan := NotFoundValue
else
BMFIScan := numb - pred(len);
end;
{$endif}
Procedure BMBMakeTable(const s:string; Var t : Btable);
Var
x : sw_integer;
begin
FillChar(t,sizeof(t),length(s));
For x := 1 to length(s)do
if (t[ord(s[x])] = length(s)) then
t[ord(s[x])] := x-1;
end;
function BMBScan(var Block; Size: Sw_Word;const Str: String;const bt:BTable): Sw_Integer;
Var
buffer : Array[0..MaxBufLength-1] of Byte Absolute block;
s2 : String;
len,
numb : Sw_integer;
found : Boolean;
begin
len:=length(str);
if len>size then
begin
BMBScan := NotFoundValue;
exit;
end;
s2[0]:=chr(len); { sets the length to that of the search String }
found:=False;
numb:=size-pred(len);
While (not found) and (numb>0) do
begin
{ partial match }
if buffer[numb] = ord(str[1]) then
begin
{ less partial! }
if buffer[numb+pred(len)] = ord(str[len]) then
begin
move(buffer[numb],s2[1],len);
if (str=s2) then
begin
found:=true;
break;
end;
end;
dec(numb);
end
else
dec(numb,Bt[buffer[numb]]);
end;
if not found then
BMBScan := NotFoundValue
else
BMBScan := numb;
end;
function BMBIScan(var Block; Size: Sw_Word;const Str: String;const bt:BTable): Sw_Integer;
Var
buffer : Array[0..MaxBufLength-1] of Char Absolute block;
len,
numb,
x : Sw_integer;
found : Boolean;
p : pchar;
c : char;
begin
len:=length(str);
if (len=0) or (len>size) then
begin
BMBIScan := NotFoundValue;
exit;
end;
found:=False;
numb:=size-len;
While (not found) and (numb>0) do
begin
{ partial match }
c:=buffer[numb];
if c in ['a'..'z'] then
c:=chr(ord(c)-32);
if (c=str[1]) then
begin
{ less partial! }
p:=@buffer[numb];
x:=1;
while (x<=len) do
begin
if not(((p^ in ['a'..'z']) and (chr(ord(p^)-32)=str[x])) or
(p^=str[x])) then
break;
inc(p);
inc(x);
end;
if (x>len) then
begin
found:=true;
break;
end;
dec(numb);
end
else
dec(numb,Bt[ord(c)]);
end;
if not found then
BMBIScan := NotFoundValue
else
BMBIScan := numb;
end;
{*****************************************************************************
PLine,TLineCollection
*****************************************************************************}
function NewLine(S: string): PLine;
var P: PLine;
@ -943,6 +786,7 @@ begin
NewLine:=P;
end;
procedure DisposeLine(P: PLine);
begin
if P<>nil then
@ -2276,10 +2120,8 @@ var S: string;
AreaStart,AreaEnd: TPoint;
CanReplace,Confirm: boolean;
Re: word;
{$ifndef ASMSCAN}
IFindStr : string;
BT : BTable;
{$endif}
function ContainsText(const SubS:string;var S: string; Start: Sw_word): Sw_integer;
var
@ -2289,29 +2131,24 @@ var S: string;
P:=0
else
begin
{$ifdef ASMSCAN}
if SForward then
begin
P:=PosF(SubS,copy(S,Start,255),(FindFlags and ffCaseSensitive)<>0);
end
begin
if FindFlags and ffCaseSensitive<>0 then
P:=BMFScan(S[Start],length(s)+1-Start,FindStr,Bt)+1
else
P:=BMFIScan(S[Start],length(s)+1-Start,IFindStr,Bt)+1;
if P>0 then
Inc(P,Start-1);
end
else
begin
P:=PosB(SubS,copy(S,1,Start),(FindFlags and ffCaseSensitive)<>0);
end;
{$else}
if SForward then
begin
if FindFlags and ffCaseSensitive<>0 then
P:=BMFScan(S[Start],length(s)+1-Start,FindStr,Bt)+1
else
P:=BMFIScan(S[Start],length(s)+1-Start,IFindStr,Bt)+1;
end
else
begin
end;
{$endif}
if P>0 then
Inc(P,Start-1);
begin
if start>length(s) then
start:=length(s);
if FindFlags and ffCaseSensitive<>0 then
P:=BMBScan(S[1],Start,FindStr,Bt)+1
else
P:=BMBIScan(S[1],Start,IFindStr,Bt)+1;
end;
end;
ContainsText:=P;
end;
@ -2320,7 +2157,7 @@ var S: string;
begin
InArea:=((AreaStart.Y=Y) and (AreaStart.X<=X)) or
((AreaStart.Y<Y) and (Y<AreaEnd.Y)) or
((AreaEnd.Y=Y) and (X<AreaEnd.X));
((AreaEnd.Y=Y) and (X<=AreaEnd.X));
end;
begin
@ -2332,38 +2169,72 @@ begin
DoReplaceAll:=(FindFlags and ffReplaceAll)<>0;
Count:=GetLineCount; FoundCount:=0;
if SForward then DY:=1 else DY:=-1; DX:=DY;
if SForward then
DY:=1
else
DY:=-1;
DX:=DY;
if (FindFlags and ffmScope)=ffGlobal
then begin AreaStart.X:=0; AreaStart.Y:=0; AreaEnd.X:=length(GetDisplayText(Count-1)); AreaEnd.Y:=Count-1; end
else begin AreaStart:=SelStart; AreaEnd:=SelEnd; end;
if (FindFlags and ffmScope)=ffGlobal then
begin
AreaStart.X:=0;
AreaStart.Y:=0;
AreaEnd.X:=length(GetDisplayText(Count-1));
AreaEnd.Y:=Count-1;
end
else
begin
AreaStart:=SelStart;
AreaEnd:=SelEnd;
end;
X:=CurPos.X-DX; Y:=CurPos.Y;;
X:=CurPos.X-DX;
Y:=CurPos.Y;;
if SearchRunCount=1 then
if (FindFlags and ffmOrigin)=ffEntireScope then
if SForward then begin X:=AreaStart.X-1; Y:=AreaStart.Y; end
else begin X:=AreaEnd.X+1; Y:=AreaEnd.Y; end;
if SForward then
begin
X:=AreaStart.X-1;
Y:=AreaStart.Y;
end
else
begin
X:=AreaEnd.X+1;
Y:=AreaEnd.Y;
end;
{$ifndef ASMSCAN}
if FindFlags and ffCaseSensitive<>0 then
BMFMakeTable(FindStr,bt)
begin
if SForward then
BMFMakeTable(FindStr,bt)
else
BMBMakeTable(FindStr,bt);
end
else
begin
IFindStr:=Upper(FindStr);
BMFMakeTable(IFindStr,bt);
if SForward then
BMFMakeTable(IFindStr,bt)
else
BMBMakeTable(IFindStr,bt);
end;
{$endif}
X:=X+DX;
inc(X,DX);
CanExit:=false;
if DoReplace and (Confirm=false) and (Owner<>nil) then Owner^.Lock;
if DoReplace and (Confirm=false) and (Owner<>nil) then
Owner^.Lock;
if InArea(X,Y) then
repeat
S:=GetDisplayText(Y);
P:=ContainsText(FindStr,S,X+1);
Found:=P<>0;
if Found then
begin A.X:=P-1; A.Y:=Y; B.Y:=Y; B.X:=A.X+length(FindStr); end;
begin
A.X:=P-1;
A.Y:=Y;
B.Y:=Y;
B.X:=A.X+length(FindStr);
end;
Found:=Found and InArea(A.X,A.Y);
if Found and ((FindFlags and ffWholeWordsOnly)<>0) then
@ -2373,48 +2244,65 @@ begin
Found:=LeftOK and RightOK;
end;
if Found then Inc(FoundCount);
if Found then
Inc(FoundCount);
if Found then
begin
SetCurPtr(B.X,B.Y);
TrackCursor(true);
SetHighlight(A,B);
if (DoReplace=false) then CanExit:=true else
begin
if Confirm=false then CanReplace:=true else
begin
Re:=EditorDialog(edReplacePrompt,@CurPos);
case Re of
cmYes : CanReplace:=true;
cmNo : CanReplace:=false;
else {cmCancel} begin CanReplace:=false; CanExit:=true; end;
end;
end;
if CanReplace then
begin
if Owner<>nil then Owner^.Lock;
SetSelection(A,B);
DelSelect;
InsertText(ReplaceStr);
if Owner<>nil then Owner^.UnLock;
end;
if (DoReplaceAll=false) then CanExit:=true;
end;
if SForward then
SetCurPtr(B.X,B.Y)
else
SetCurPtr(A.X,A.Y);
TrackCursor(true);
SetHighlight(A,B);
if (DoReplace=false) then CanExit:=true else
begin
if Confirm=false then CanReplace:=true else
begin
Re:=EditorDialog(edReplacePrompt,@CurPos);
case Re of
cmYes :
CanReplace:=true;
cmNo :
CanReplace:=false;
else {cmCancel}
begin
CanReplace:=false;
CanExit:=true;
end;
end;
end;
if CanReplace then
begin
if Owner<>nil then
Owner^.Lock;
SetSelection(A,B);
DelSelect;
InsertText(ReplaceStr);
if Owner<>nil then
Owner^.UnLock;
end;
if (DoReplaceAll=false) then
CanExit:=true;
end;
end;
if CanExit=false then
begin
Y:=Y+DY;
if SForward then X:=0 else X:=255;
CanExit:=(Y>=Count) or (Y<0);
inc(Y,DY);
if SForward then
X:=0
else
X:=254;
CanExit:=(Y>=Count) or (Y<0);
end;
if CanExit=false then
CanExit:=InArea(X,Y)=false;
if not CanExit then
CanExit:=not InArea(X,Y);
until CanExit;
if (FoundCount=0) or (DoReplace) then
SetHighlight(CurPos,CurPos);
if DoReplace and (Confirm=false) and (Owner<>nil) then Owner^.UnLock;
if DoReplace and (Confirm=false) and (Owner<>nil) then
Owner^.UnLock;
if (FoundCount=0) then
EditorDialog(edSearchFailed,nil);
end;
@ -3329,7 +3217,13 @@ end;
END.
{
$Log$
Revision 1.18 1999-02-15 15:12:25 pierre
Revision 1.19 1999-02-18 13:44:36 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.18 1999/02/15 15:12:25 pierre
+ TLine remembers Comment type
Revision 1.17 1999/02/15 09:32:58 pierre

View File

@ -140,6 +140,7 @@ type
Links : PKeywordDescriptors;
LastAccess : longint;
FileID : word;
Param : PString;
end;
PUnsortedStringCollection = ^TUnsortedStringCollection;
@ -230,7 +231,7 @@ const TopicCacheSize : integer = 10;
HelpFacility : PHelpFacility = nil;
MaxHelpTopicSize : word = 65520;
function NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint): PTopic;
function NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint; Param: string): PTopic;
procedure DisposeTopic(P: PTopic);
function NewIndexEntry(Tag: string; FileID: word; HelpCtx: THelpCtx): PIndexEntry;
@ -277,11 +278,12 @@ begin
FillChar(R, SizeOf(R), 0);
end;
function NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint): PTopic;
function NewTopic(FileID: byte; HelpCtx: THelpCtx; Pos: longint; Param: string): PTopic;
var P: PTopic;
begin
New(P); FillChar(P^,SizeOf(P^), 0);
P^.HelpCtx:=HelpCtx; P^.FileOfs:=Pos; P^.FileID:=FileID;
P^.Param:=NewStr(Param);
NewTopic:=P;
end;
@ -295,6 +297,7 @@ begin
if (P^.LinkCount>0) and (P^.Links<>nil) then
FreeMem(P^.Links,P^.LinkSize);
P^.Links:=nil;
if P^.Param<>nil then DisposeStr(P^.Param); P^.Param:=nil;
Dispose(P);
end;
end;
@ -307,6 +310,8 @@ begin
begin GetMem(NT^.Text,NT^.TextSize); Move(T^.Text^,NT^.Text^,NT^.TextSize); end;
if NT^.Links<>nil then
begin GetMem(NT^.Links,NT^.LinkSize); Move(T^.Links^,NT^.Links^,NT^.LinkSize); end;
if NT^.Param<>nil then
NT^.Param:=NewStr(T^.Param^);
CloneTopic:=NT;
end;
@ -527,7 +532,7 @@ begin
if (L=-1) and (Header.MainIndexScreen>0) then
L:=GetCtxPos(Contexts[Header.MainIndexScreen]);
if (L>0) then
Topics^.Insert(NewTopic(ID,I,L));
Topics^.Insert(NewTopic(ID,I,L,''));
end;
DisposeRecord(R);
TopicsRead:=OK;
@ -876,7 +881,7 @@ begin
New(Keywords, Init(5000,1000));
HelpFiles^.ForEach(@InsertKeywordsOfFile);
New(Lines, Init((Keywords^.Count div 2)+100,100));
T:=NewTopic(0,0,0);
T:=NewTopic(0,0,0,'');
if HelpFiles^.Count=0 then
begin
AddLine('');
@ -930,7 +935,13 @@ end;
END.
{
$Log$
Revision 1.3 1999-02-08 10:37:46 peter
Revision 1.4 1999-02-18 13:44:37 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.3 1999/02/08 10:37:46 peter
+ html helpviewer
Revision 1.2 1998/12/28 15:47:56 peter

View File

@ -415,7 +415,6 @@ begin
ZeroLevel:=0;
end;
end;
var Diff: integer;
begin
Lines^.FreeAll; Links^.FreeAll;
if Topic=nil then Lines^.Insert(NewStr('No help available for this topic.')) else
@ -1117,7 +1116,13 @@ end;
END.
{
$Log$
Revision 1.4 1999-02-08 10:37:47 peter
Revision 1.5 1999-02-18 13:44:38 peter
* search fixed
+ backward search
* help fixes
* browser updates
Revision 1.4 1999/02/08 10:37:47 peter
+ html helpviewer
Revision 1.3 1999/01/21 11:54:32 peter

View File

@ -22,7 +22,7 @@ type
PHTMLTopicRenderer = ^THTMLTopicRenderer;
THTMLTopicRenderer = object(THTMLParser)
function BuildTopic(P: PTopic; HTMLFile: PTextFile; ATopicLinks: PTopicLinkCollection): boolean;
function BuildTopic(P: PTopic; AURL: string; HTMLFile: PTextFile; ATopicLinks: PTopicLinkCollection): boolean;
public
procedure DocAddTextChar(C: char); virtual;
procedure DocSoftBreak; virtual;
@ -56,6 +56,7 @@ type
procedure DocDefExp; virtual;
procedure DocHorizontalRuler; virtual;
private
URL: string;
Topic: PTopic;
TopicLinks: PTopicLinkCollection;
TextPtr: word;
@ -114,6 +115,24 @@ begin
FormatPath:=Path;
end;
function CompletePath(const Base, InComplete: string): string;
var Drv,BDrv: string[40]; D,BD: DirStr; N,BN: NameStr; E,BE: ExtStr;
P: sw_integer;
Complete: string;
begin
Complete:=FormatPath(InComplete);
FSplit(FormatPath(InComplete),D,N,E);
P:=Pos(':',D); if P=0 then Drv:='' else begin Drv:=copy(D,1,P); Delete(D,1,P); end;
FSplit(FormatPath(Base),BD,BN,BE);
P:=Pos(':',BD); if P=0 then BDrv:='' else begin BDrv:=copy(BD,1,P); Delete(BD,1,P); end;
if copy(D,1,1)<>'\' then
Complete:=BD+D+N+E;
if Drv='' then
Complete:=BDrv+Complete;
Complete:=FExpand(Complete);
CompletePath:=Complete;
end;
function UpcaseStr(S: string): string;
var I: integer;
begin
@ -236,6 +255,7 @@ begin
begin
InAnchor:=true;
AddChar(hscLink);
HRef:=CompletePath(URL,HRef);
LinkIndexes[LinkPtr]:=TopicLinks^.AddItem(HRef);
Inc(LinkPtr);
end;
@ -268,7 +288,6 @@ begin
end
else
begin
{ if LastChar<>hscLineBreak then AddText(hscLineBreak);}
CurHeadLevel:=0;
DocBreak;
end;
@ -277,7 +296,6 @@ end;
procedure THTMLTopicRenderer.DocParagraph(Entered: boolean);
var Align: string;
begin
{ if Entered and InParagraph then}
if Entered and InParagraph then DocParagraph(false);
if Entered then
begin
@ -439,11 +457,13 @@ begin
AddChar(S[I]);
end;
function THTMLTopicRenderer.BuildTopic(P: PTopic; HTMLFile: PTextFile; ATopicLinks: PTopicLinkCollection): boolean;
function THTMLTopicRenderer.BuildTopic(P: PTopic; AURL: string; HTMLFile: PTextFile;
ATopicLinks: PTopicLinkCollection): boolean;
var OK: boolean;
TP: pointer;
I: sw_integer;
begin
URL:=AURL;
Topic:=P; TopicLinks:=ATopicLinks;
OK:=Assigned(Topic) and Assigned(HTMLFile) and Assigned(TopicLinks);
if OK then
@ -518,6 +538,7 @@ begin
end;
var FileID,LinkNo: word;
P: PTopic;
FName: string;
begin
DecodeHTMLCtx(HelpCtx,FileID,LinkNo);
if (HelpCtx<>0) and (FileID<>ID) then P:=nil else
@ -526,29 +547,17 @@ begin
P:=Topics^.FirstThat(@MatchCtx);
if P=nil then
begin
P:=NewTopic(ID,HelpCtx,0);
if LinkNo=0 then
FName:=FileName
else
FName:=TopicLinks^.At(LinkNo-1)^;
P:=NewTopic(ID,HelpCtx,0,FName);
Topics^.Insert(P);
end;
end;
SearchTopic:=P;
end;
function CompletePath(const Base: string; InComplete: string): string;
var Drv,BDrv: string[40]; D,BD: DirStr; N,BN: NameStr; E,BE: ExtStr;
P: sw_integer;
begin
FSplit(InComplete,D,N,E);
P:=Pos(':',D); if P=0 then Drv:='' else begin Drv:=copy(D,1,P); Delete(D,1,P); end;
FSplit(Base,BD,BN,BE);
P:=Pos(':',BD); if P=0 then BDrv:='' else begin BDrv:=copy(BD,1,P); Delete(BD,1,P); end;
if copy(D,1,1)<>'\' then
InComplete:=BD+D+N+E;
if Drv='' then
InComplete:=BDrv+InComplete;
InComplete:=FExpand(InComplete);
CompletePath:=InComplete;
end;
function THTMLHelpFile.ReadTopic(T: PTopic): boolean;
var OK: boolean;
HTMLFile: PDOSTextFile;
@ -564,11 +573,12 @@ begin
Link:=TopicLinks^.At(T^.HelpCtx-1)^;
Link:=FormatPath(Link);
P:=Pos('#',Link); if P>0 then Delete(Link,P,255);
if CurFileName='' then Name:=Link else
Name:=CompletePath(CurFileName,Link);
{ if CurFileName='' then Name:=Link else
Name:=CompletePath(CurFileName,Link);}
Name:=Link;
end;
New(HTMLFile, Init(Name));
OK:=Renderer^.BuildTopic(T,HTMLFile,TopicLinks);
OK:=Renderer^.BuildTopic(T,Name,HTMLFile,TopicLinks);
if OK then CurFileName:=Name;
if HTMLFile<>nil then Dispose(HTMLFile, Done);
end;