From c0440b4555d512b24746bc4377488f8574e1d612 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 10 May 2015 04:11:16 +0200 Subject: [PATCH] clean up --- src/ce_common.pas | 63 +++++++++++----------------------------------- src/ce_main.pas | 30 +++++++++++----------- src/ce_options.pas | 2 ++ 3 files changed, 31 insertions(+), 64 deletions(-) diff --git a/src/ce_common.pas b/src/ce_common.pas index 538f2407..5194de26 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -50,24 +50,6 @@ type procedure Assign(aValue: TPersistent); end; - (** - * Makes TReader.ReadProperties visible - *) - TReaderEx = class helper for TReader - public - procedure ReadPersistent(aValue: TPersistent); - end; - - (** - * Makes TWriter.WriteProperties visible - * W - *) - TWriterEx = class helper for TWriter - public - // works as bin but raises because of 'ObjectBinaryToText' - procedure WritePersistent(aValue: TPersistent); - end; - (** * Save a component with a readable aspect. *) @@ -122,7 +104,7 @@ type (** * Returns an unique object identifier, based on its heap address. *) - function uniqueObjStr(const aObject: Tobject): string; + function uniqueObjStr(const aObject: TObject): string; (** * Reduces a filename if its length is over the threshold defined by charThresh. @@ -136,7 +118,7 @@ type function getUserDocPath: string; (** - * Returns the folder Coedit documents and settings. + * Returns the documents and settings folder for Coedit. *) function getCoeditDocPath: string; @@ -187,7 +169,7 @@ type procedure processOutputToStream(aProcess: TProcess; output: TMemoryStream); (** - * Terminates and frees aProcess; + * Terminates and frees aProcess. *) procedure killProcess(var aProcess: TAsyncProcess); @@ -224,13 +206,14 @@ begin inherited; fTimer := TIdleTimer.Create(self); fTimer.Enabled := false; - fTimer.Interval :=50; + fTimer.Interval := 50; fTimer.AutoEnabled := false; end; procedure TCheckedAsyncProcess.Execute; begin - if OnTerminate <> nil then fTimer.Enabled :=true; + if OnTerminate <> nil then + fTimer.Enabled :=true; fTimer.OnTimer := @checkTerminated; inherited; end; @@ -244,9 +227,6 @@ begin end; {$ENDIF} - -// https://stackoverflow.com/questions/25438091/objectbinarytotext-error-with-a-treader-twriter-helper-class -// http://forum.lazarus.freepascal.org/index.php/topic,25557.0.html procedure TProcessEx.Assign(aValue: TPersistent); var src: TProcess; @@ -278,21 +258,6 @@ begin else inherited; end; -procedure TReaderEx.ReadPersistent(aValue: TPersistent); -begin - ReadListBegin; - while not EndOfList do - ReadProperty(aValue); - ReadListEnd; -end; - -procedure TWriterEx.WritePersistent(aValue: TPersistent); -begin - WriteListBegin; - WriteProperties(aValue); - WriteListEnd; -end; - procedure saveCompToTxtFile(const aComp: TComponent; const aFilename: string); var str1, str2: TMemoryStream; @@ -400,14 +365,6 @@ begin end; end; -function stripFileExt(const aFilename: string): string; -begin - if Pos('.', aFilename) > 1 then - exit(ChangeFileExt(aFilename, '')) - else - exit(aFilename); -end; - function patchPlateformExt(const aFilename: string): string; var ext, newext: string; @@ -446,6 +403,14 @@ begin result := ChangeFileExt(aFilename, newext); end; +function stripFileExt(const aFilename: string): string; +begin + if Pos('.', aFilename) > 1 then + exit(ChangeFileExt(aFilename, '')) + else + exit(aFilename); +end; + function dlgOkCancel(const aMsg: string): TModalResult; const Btns = [mbOK,mbCancel]; diff --git a/src/ce_main.pas b/src/ce_main.pas index 1c431700..ea73068c 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -592,7 +592,7 @@ begin try DockMaster.SaveLayoutToConfig(xcfg); xcfg.WriteToDisk; - // TODO: this when AnchorDocking wiont save anymore invalid layout + // TODO: remove this when AnchorDocking wiont save anymore invalid layout with TMemoryStream.Create do try LoadFromFile(getCoeditDocPath + 'docking.xml.tmp'); if Size < 10000 then @@ -905,13 +905,16 @@ begin for i:= 0 to fActionHandler.observersCount-1 do begin prov := fActionHandler[i] as ICEActionProvider; - if not prov.actHandlerWantRecollect then continue; + if not prov.actHandlerWantRecollect then + continue; // for j := Actions.ActionCount-1 downto 0 do begin act := Actions.Actions[j]; - if act.Owner = Self then continue; - if act.Tag <> PtrInt(prov) then continue; + if act.Owner = Self then + continue; + if act.Tag <> PtrInt(prov) then + continue; // act.ActionList := nil; end; @@ -938,7 +941,8 @@ begin for i:= 0 to fActionHandler.observersCount-1 do begin prov := fActionHandler[i] as ICEActionProvider; - if not prov.actHandlerWantFirst then continue; + if not prov.actHandlerWantFirst then + continue; // act := nil; cat := ''; @@ -1006,9 +1010,7 @@ begin try filter := DdiagFilter; if execute then - begin openFile(filename); - end; finally free; end; @@ -1069,7 +1071,8 @@ begin str := fDoc.fileName; if (str <> fDoc.tempFilename) and (fileExists(str)) then saveFile(fDoc) - else actFileSaveAs.Execute; + else + actFileSaveAs.Execute; end; procedure TCEMainForm.actFileAddToProjExecute(Sender: TObject); @@ -1182,7 +1185,8 @@ begin // if fDoc.SelAvail then str := fDoc.SelText - else str := fDoc.Identifier; + else + str := fDoc.Identifier; ffindwidg.cbToFind.Text := str; ffindwidg.cbToFindChange(nil); end; @@ -1234,11 +1238,9 @@ begin finally lst.Free; end; - //if proc = fPrInpWidg.process then - //fPrInpWidg.process := nil; - inph := EntitiesConnector.getSingleService('ICEProcInputHandler'); - if (inph <> nil) then (inph as ICEProcInputHandler).removeProcess(proc); + if (inph <> nil) then + (inph as ICEProcInputHandler).removeProcess(proc); end; procedure TCEMainForm.compileAndRunFile(unittest: boolean = false; redirect: boolean = true; @@ -1791,6 +1793,4 @@ begin end; {$ENDREGION} -initialization - RegisterClasses([TCEOptions]); end. diff --git a/src/ce_options.pas b/src/ce_options.pas index ab393da7..1122973d 100644 --- a/src/ce_options.pas +++ b/src/ce_options.pas @@ -68,4 +68,6 @@ begin subjSesOptsAfterLoad(TCESessionOptionsSubject(fSubjPersObservers)); end; +initialization + RegisterClasses([TCEOptions]); end.