diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index 0db901bec8..cb21ab7cbc 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -2504,6 +2504,14 @@ begin ,da_DefineRecurse)); MainDir.AddChild(DirTempl); + // components/htmllite + SubDirTempl:=TDefineTemplate.Create('HTMLLite', + 'HTMLLite', + '','htmllite',da_Directory); + SubDirTempl.AddChild(TDefineTemplate.Create('HL_LAZARUS', + 'Define HL_LAZARUS','HL_LAZARUS','',da_DefineRecurse)); + DirTempl.AddChild(SubDirTempl); + // components/custom SubDirTempl:=TDefineTemplate.Create('Custom Components', ctsCustomComponentsDirectory, diff --git a/components/htmllite/litecons.inc b/components/htmllite/litecons.inc index 1d4934e6d7..0a2620ef28 100644 --- a/components/htmllite/litecons.inc +++ b/components/htmllite/litecons.inc @@ -7,6 +7,7 @@ {$Define ver100_plus} {$Define ver120_plus} {$Define NoGIF} +{$Define NoThreads} {$ELSE} diff --git a/components/htmllite/litepars.pas b/components/htmllite/litepars.pas index 2b1672c488..d7c83e7cbc 100644 --- a/components/htmllite/litepars.pas +++ b/components/htmllite/litepars.pas @@ -167,7 +167,7 @@ type Base: string; BaseTarget: string; AllowSuspend: boolean; - ParseThread: TThread; + ParseThread: {$IFDEF NoThreads}TObject{$ELSE}TThread{$ENDIF}; CurrentStyle: TFontStyles; {as set by , , etc.} CurrentSScript: SubSuperType; CurrentForm: ThtmlForm; diff --git a/components/htmllite/litereadthd.pas b/components/htmllite/litereadthd.pas index 27706ab5b7..02ccb302d4 100644 --- a/components/htmllite/litereadthd.pas +++ b/components/htmllite/litereadthd.pas @@ -15,7 +15,46 @@ uses Classes, LitePars; type - TParseThread = class(TThread) + TFakeThread = class + private + FHandle: THandle; + FThreadID: THandle; + FTerminated: Boolean; + FSuspended: Boolean; + FFreeOnTerminate: Boolean; + FFinished: Boolean; + FReturnValue: Integer; + FOnTerminate: TNotifyEvent; + FPriority: TThreadPriority; + FMethod: TThreadMethod; + FSynchronizeException: TObject; + procedure CallOnTerminate; + function GetPriority: TThreadPriority; + procedure SetPriority(Value: TThreadPriority); + procedure SetSuspended(Value: Boolean); + procedure DoExecute; + protected + procedure DoTerminate; virtual; + procedure Execute; virtual; abstract; + procedure Synchronize(Method: TThreadMethod); + property ReturnValue: Integer read FReturnValue write FReturnValue; + property Terminated: Boolean read FTerminated; + public + constructor Create(CreateSuspended: Boolean); + destructor Destroy; override; + procedure Resume; + procedure Suspend; + procedure Terminate; + function WaitFor: Integer; + property FreeOnTerminate: Boolean read FFreeOnTerminate write FFreeOnTerminate; + property Handle: THandle read FHandle; + property Priority: TThreadPriority read GetPriority write SetPriority; + property Suspended: Boolean read FSuspended write SetSuspended; + property ThreadID: THandle read FThreadID; + property OnTerminate: TNotifyEvent read FOnTerminate write FOnTerminate; + end; + + TParseThread = class({$IFDEF NoThreads}TFakeThread{$ELSE}TThread{$ENDIF}) private { Private declarations } protected @@ -35,7 +74,7 @@ type constructor Create(CreateSuspended: Boolean); destructor Destroy; override; procedure Synchronize(Method: TThreadMethod); - procedure AddString(S: string); + procedure AddString({$IFDEF HL_LAZARUS}const {$ENDIF}S: string); end; @@ -51,7 +90,7 @@ Buffer := PChar(St); BuffEnd := Buffer; end; -procedure TParseThread.AddString(S: string); +procedure TParseThread.AddString({$IFDEF HL_LAZARUS}const {$ENDIF}S: string); {Call only when thread is suspended} var Space: integer; @@ -82,5 +121,84 @@ begin inherited; end; +{ TFakeThread } + +procedure TFakeThread.CallOnTerminate; +begin + +end; + +function TFakeThread.GetPriority: TThreadPriority; +begin + Result:=FPriority; +end; + +procedure TFakeThread.SetPriority(Value: TThreadPriority); +begin + FPriority:=Value; +end; + +procedure TFakeThread.SetSuspended(Value: Boolean); +begin + FSuspended:=Value; +end; + +procedure TFakeThread.DoExecute; +begin + FSuspended:=false; + Execute; + FSuspended:=true; + DoTerminate; +end; + +procedure TFakeThread.DoTerminate; +begin + if Assigned(FOnTerminate) then + FOnTerminate(Self); + FFinished:=true; + if FFreeOnTerminate then Free; +end; + +procedure TFakeThread.Synchronize(Method: TThreadMethod); +begin + +end; + +constructor TFakeThread.Create(CreateSuspended: Boolean); +begin + inherited Create; + if CreateSuspended then Suspend else DoExecute; +end; + +destructor TFakeThread.Destroy; +begin + if not FFinished and not Suspended then + begin + Terminate; + WaitFor; + end; + inherited Destroy; +end; + +procedure TFakeThread.Resume; +begin + if not FFinished then DoExecute; +end; + +procedure TFakeThread.Suspend; +begin + FSuspended := true; +end; + +procedure TFakeThread.Terminate; +begin + FTerminated := True; +end; + +function TFakeThread.WaitFor: Integer; +begin + Result:=0; +end; + end.