From c024e5bb5ad3a86716d8dcdd5e232aab7ad03212 Mon Sep 17 00:00:00 2001 From: Juha Date: Fri, 7 Oct 2022 11:51:58 +0300 Subject: [PATCH] Jedi Code Format: Revert changes for removing LCL dependency. It broke "make bigide" because of LAZARUS_PLUGIN define. --- components/jcf2/CommandLine/Lazarus/jcf.lpi | 259 ++++++++++-------- components/jcf2/CommandLine/Lazarus/jcf.lpr | 19 +- .../jcf2/CommandLine/Lazarus/jcfsettings.cfg | 185 ------------- .../jcf2/IdePlugin/lazarus/jcfidelazarus.lpk | 7 +- .../jcf2/IdePlugin/lazarus/jcfidelazarus.pas | 2 +- components/jcf2/Parse/BuildParseTree.pas | 9 +- components/jcf2/Parse/BuildTokenList.pas | 14 +- .../PreProcessor/PreProcessorParseTree.pas | 11 +- components/jcf2/Process/AllProcesses.pas | 8 +- components/jcf2/ReadWrite/Converter.pas | 31 ++- components/jcf2/ReadWrite/EditorConverter.pas | 1 + components/jcf2/ReadWrite/FileConverter.pas | 16 +- .../jcf2/Settings/JcfRegistrySettings.pas | 14 +- components/jcf2/Settings/JcfSettings.pas | 33 +-- components/jcf2/TestApplication/TestJCF.lpi | 12 +- components/jcf2/TestApplication/TestJCF.lpr | 2 +- components/jcf2/Ui/jcfuitools.pas | 111 -------- components/jcf2/Utils/JcfMiscFunctions.pas | 7 +- components/jcf2/Utils/JcfStringUtils.pas | 1 + components/jcf2/Utils/JcfSystemUtils.pas | 32 ++- 20 files changed, 275 insertions(+), 499 deletions(-) delete mode 100644 components/jcf2/CommandLine/Lazarus/jcfsettings.cfg delete mode 100644 components/jcf2/Ui/jcfuitools.pas diff --git a/components/jcf2/CommandLine/Lazarus/jcf.lpi b/components/jcf2/CommandLine/Lazarus/jcf.lpi index 7dbf983577..5e33349461 100644 --- a/components/jcf2/CommandLine/Lazarus/jcf.lpi +++ b/components/jcf2/CommandLine/Lazarus/jcf.lpi @@ -17,9 +17,15 @@ + + + + + + @@ -48,6 +54,9 @@ + + + @@ -67,19 +76,15 @@ - + - + - - - - + - @@ -142,439 +147,456 @@ - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + - + - + - + - - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + - + @@ -602,8 +624,5 @@ - - - diff --git a/components/jcf2/CommandLine/Lazarus/jcf.lpr b/components/jcf2/CommandLine/Lazarus/jcf.lpr index dd22c24b3a..47a1d81fa6 100644 --- a/components/jcf2/CommandLine/Lazarus/jcf.lpr +++ b/components/jcf2/CommandLine/Lazarus/jcf.lpr @@ -27,7 +27,13 @@ See http://www.gnu.org/licenses/gpl.html {$I JcfGlobal.inc} uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, SysUtils, + FileCtrl, JcfStringUtils in '..\..\Utils\JcfStringUtils.pas', JcfSystemUtils in '..\..\Utils\JcfSystemUtils.pas', Converter in '..\..\ReadWrite\Converter.pas', @@ -44,6 +50,7 @@ uses BaseVisitor in '..\..\Process\BaseVisitor.pas', JcfMiscFunctions in '..\..\Utils\JcfMiscFunctions.pas', JcfLog in '..\..\Utils\JcfLog.pas', + fShowParseTree in '..\..\Parse\UI\fShowParseTree.pas' {frmShowParseTree}, SetUses in '..\..\Settings\SetUses.pas', JcfSetBase in '..\..\Settings\JcfSetBase.pas', JcfSettings in '..\..\Settings\JcfSettings.pas', @@ -70,9 +77,8 @@ uses WarnCaseNoElse in '..\..\Process\Warnings\WarnCaseNoElse.pas', WarnDestroy in '..\..\Process\Warnings\WarnDestroy.pas', WarnEmptyBlock in '..\..\Process\Warnings\WarnEmptyBlock.pas', - WarnImbalancedComment in '..\..\Process\Warnings\WarnImbalancedComment.pas', Warning in '..\..\Process\Warnings\Warning.pas', - JcfVersionConsts in '..\..\JcfVersionConsts.pas', + JcfVersionConsts in '..\..\JcfVersionConsts.pas', jcfidelazarus, JcfRegistrySettings in '..\..\Settings\JcfRegistrySettings.pas', TokenUtils in '..\..\Parse\TokenUtils.pas', NoSpaceBefore in '..\..\Process\Spacing\NoSpaceBefore.pas', @@ -117,11 +123,13 @@ uses PreProcessorExpressionTokens in '..\..\Parse\PreProcessor\PreProcessorExpressionTokens.pas', PreProcessorExpressionParser in '..\..\Parse\PreProcessor\PreProcessorExpressionParser.pas', PreProcessorExpressionTokenise in '..\..\Parse\PreProcessor\PreProcessorExpressionTokenise.pas', + JcfHelp in '..\..\Utils\JcfHelp.pas', SettingsTypes in '..\..\Settings\SettingsTypes.pas', SetPreProcessor in '..\..\Settings\SetPreProcessor.pas', UnitNameCaps in '..\..\Process\Capitalisation\UnitNameCaps.pas', RemoveSpaceAtLineEnd in '..\..\Process\Spacing\RemoveSpaceAtLineEnd.pas', FindReplace in '..\..\Process\Transform\FindReplace.pas', + fJcfErrorDisplay in '..\..\Ui\fJcfErrorDisplay.pas' {ExceptionDialog}, ReturnsAfterFinalEnd in '..\..\Process\Returns\ReturnsAfterFinalEnd.pas', PreProcessorParseTree in '..\..\Parse\PreProcessor\PreProcessorParseTree.pas', RemoveEmptyComment in '..\..\Process\RemoveEmptyComment.pas', @@ -140,6 +148,7 @@ uses SortUsesData in '..\..\Process\Transform\SortUsesData.pas', IdentifierCaps in '..\..\Process\Capitalisation\IdentifierCaps.pas', WarnUnusedParam in '..\..\Process\Warnings\WarnUnusedParam.pas', + JcfFontSetFunctions in '..\..\Utils\JcfFontSetFunctions.pas', SetAsm in '..\..\Settings\SetAsm.pas', RemoveReturnsAfter in '..\..\Process\Returns\RemoveReturnsAfter.pas', IndentAsmParam in '..\..\Process\Indent\IndentAsmParam.pas', @@ -148,7 +157,6 @@ uses CommandLineReturnCode in '..\CommandLineReturnCode.pas', CommandLineConstants in '..\CommandLineConstants.pas', StatusMessageReceiver in '..\StatusMessageReceiver.pas', - JcfUiTools in '..\..\Ui\jcfuitools.pas', MoveSpaceToBeforeColon in '..\..\Process\Spacing\MoveSpaceToBeforeColon.pas'; const @@ -398,6 +406,7 @@ var { main program starts here } begin + Application.Initialize; GetDefaultSettingsFileName := CmdLineDefGetDefaultSettingsFileName; feReturnCode := rcSuccess; { read registry } @@ -428,10 +437,6 @@ begin ConvertFiles; end; - // keep for debuginng in the lazarus ide. - //Write('Press enter to end'); - //ReadLn; - FreeAndNil(lcStatus); HaltOnError(feReturnCode); diff --git a/components/jcf2/CommandLine/Lazarus/jcfsettings.cfg b/components/jcf2/CommandLine/Lazarus/jcfsettings.cfg deleted file mode 100644 index 814b846ad0..0000000000 --- a/components/jcf2/CommandLine/Lazarus/jcfsettings.cfg +++ /dev/null @@ -1,185 +0,0 @@ - - - 2.44 - 44779.7261157755 - format settings for use with Lazarus - True - - False - 1 - True - True - True - True - - - 0 - True - False - Sender - dpr,lpr,pas,pp - - - 2 - 0 - False - False - 2 - True - False - True - True - True - True - False - True - False - False - - - True - False - 2 - 2 - True - False - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 2 - True - 0 - False - False - False - False - False - False - - - 1 - 110 - 1 - True - True - False - False - True - True - True - True - True - True - True - 1 - 1 - - 1 - 1 - 1 - 0 - 0 - 0 - 1 - 0 - 1 - 0 - 1 - 1 - 0 - 1 - 0 - True - 4 - 1 - 1 - - - True - True - - - True - 1 - 1 - 1 - 1 - 1 - - - True - - - - True - ActivePage,AnsiCompareStr,AnsiCompareText,AnsiUpperCase,AsBoolean,AsDateTime,AsFloat,AsInteger,Assign,AsString,AsVariant,BeginDrag,Buttons,Caption,Checked,Classes,ClassName,Clear,Close,Components,Controls,Count,Create,Data,Dec,Delete,Destroy,Dialogs,Enabled,EndDrag,EOF,Exception,Execute,False,FieldByName,First,Forms,Free,FreeAndNil,GetFirstChild,Graphics,Height,idAbort,idCancel,idIgnore,IDispatch,idNo,idOk,idRetry,idYes,Inc,Initialize,IntToStr,ItemIndex,IUnknown,Lines,Math,MaxValue,mbAbort,mbAll,mbCancel,mbHelp,mbIgnore,mbNo,mbOK,mbRetry,mbYes,mbYesToAll,Messages,MinValue,mnNoToAll,mrAbort,mrAll,mrCancel,mrIgnore,mrNo,mrNone,mrNoToAll,mrOk,mrRetry,mrYes,mrYesToAll,mtConfirmation,mtCustom,mtError,mtInformation,mtWarning,Name,Next,Open,Ord,ParamStr,PChar,Perform,ProcessMessages,Read,ReadOnly,RecordCount,Register,Release,Result,Sender,SetFocus,Show,ShowMessage,Source,StdCtrls,StrToInt,SysUtils,TAutoObject,TButton,TComponent,TDataModule,Text,TForm,TFrame,TList,TNotifyEvent,TObject,TObjectList,TPageControl,TPersistent,True,TStringList,TStrings,TTabSheet,Unassigned,Value,Visible,WideString,Width,Windows,Write - - - True - False,Name,nil,PChar,read,ReadOnly,True,WideString,write - - - True - ActnColorMaps,ActnCtrls,ActnList,ActnMan,ActnMenus,ActnPopup,ActnRes,ADOConst,ADODB,ADOInt,AppEvnts,AxCtrls,BandActn,bdeconst,bdemts,Buttons,CheckLst,Classes,Clipbrd.pas,CmAdmCtl,ComCtrls,ComStrs,Consts,Controls,CtlConsts,CtlPanel,CustomizeDlg,DataBkr,DB,DBActns,dbcgrids,DBClient,DBClientActnRes,DBClientActns,DBCommon,DBConnAdmin,DBConsts,DBCtrls,DbExcept,DBGrids,DBLocal,DBLocalI,DBLogDlg,dblookup,DBOleCtl,DBPWDlg,DBTables,DBXpress,DdeMan,Dialogs,DrTable,DSIntf,ExtActns,ExtCtrls,ExtDlgs,FileCtrl,FMTBcd,Forms,Graphics,GraphUtil,Grids,HTTPIntr,IB,IBBlob,IBCustomDataSet,IBDatabase,IBDatabaseInfo,IBDCLConst,IBErrorCodes,IBEvents,IBExternals,IBExtract,IBGeneratorEditor,IBHeader,IBIntf,IBQuery,IBRestoreEditor,IBSecurityEditor,IBServiceEditor,IBSQL,IBSQLMonitor,IBStoredProc,IBTable,IBUpdateSQL,IBUtils,IBXConst,ImgList,Jcl8087,JclAbstractContainers,JclAlgorithms,JclAnsiStrings,JclAppInst,JclArrayLists,JclArraySets,JclBase,JclBinaryTrees,JclBorlandTools,JclCIL,JclCLR,JclCOM,JclComplex,JclCompression,JclConsole,JclContainerIntf,JclCounter,JclDateTime,JclDebug,JclDotNet,JclEDI,JclEDISEF,JclEDITranslators,JclEDIXML,JclEDI_ANSIX12,JclEDI_ANSIX12_Ext,JclEDI_UNEDIFACT,JclEDI_UNEDIFACT_Ext,JclExprEval,JclFileUtils,JclFont,JclGraphics,JclGraphUtils,JclHashMaps,JclHashSets,JclHookExcept,JclIniFiles,JclLANMan,JclLinkedLists,JclLocales,JclLogic,JclMapi,JclMath,JclMetadata,JclMIDI,JclMime,JclMiscel,JclMsdosSys,JclMultimedia,JclNTFS,JclPCRE,JclPeImage,JclPrint,JclQGraphics,JclQGraphUtils,JclQueues,JclRegistry,JclResources,JclRTTI,JclSchedule,JclSecurity,JclShell,JclSimpleXml,JclStacks,JclStatistics,JclStreams,JclStrHashMap,JclStringLists,JclStrings,JclStructStorage,JclSvcCtrl,JclSynch,JclSysInfo,JclSysUtils,JclTask,JclTD32,JclUnicode,JclUnitConv,JclUnitVersioning,JclUnitVersioningProviders,JclValidation,JclVectors,JclWideFormat,JclWideStrings,JclWin32,JclWin32Ex,JclWinMIDI,ListActns,Mask,MConnect,Menus,Midas,MidasCon,MidConst,MPlayer,MtsRdm,Mxconsts,ObjBrkr,OleAuto,OleConst,OleCtnrs,OleCtrls,OleDB,OleServer,Outline,Printers,Provider,recerror,ScktCnst,ScktComp,ScktMain,SConnect,ShadowWnd,SimpleDS,SMINTF,SqlConst,SqlExpr,SqlTimSt,StdActnMenus,StdActns,StdCtrls,StdStyleActnCtrls,SvcMgr,SysUtils,TabNotBk,Tabs,TConnect,Themes,ToolWin,ValEdit,VDBConsts,WinHelpViewer,XPActnCtrls,XPMan,XPStyleActnCtrls - - - 0 - 1 - True - True - 7 - True - 15 - - - True - FPC,MSWINDOWS - - - - False - False - False - False - False - False - False - 2 - 60 - 5 - 5 - 0 - - - False - - - - False - False - False - False - - - - - - - - 1 - True - False - False - False - False - False - 0 - False - - diff --git a/components/jcf2/IdePlugin/lazarus/jcfidelazarus.lpk b/components/jcf2/IdePlugin/lazarus/jcfidelazarus.lpk index 51a17a8514..7a2823fc60 100644 --- a/components/jcf2/IdePlugin/lazarus/jcfidelazarus.lpk +++ b/components/jcf2/IdePlugin/lazarus/jcfidelazarus.lpk @@ -20,8 +20,7 @@ - + @@ -735,10 +734,6 @@ - - - - diff --git a/components/jcf2/IdePlugin/lazarus/jcfidelazarus.pas b/components/jcf2/IdePlugin/lazarus/jcfidelazarus.pas index 0362463c45..cc7bc87f0b 100644 --- a/components/jcf2/IdePlugin/lazarus/jcfidelazarus.pas +++ b/components/jcf2/IdePlugin/lazarus/jcfidelazarus.pas @@ -42,7 +42,7 @@ uses frAnyCapsSettings, frIdentifierCapsSettings, frNotIdentifierCapsSettings, frUnitCaps, frReplace, frUses, frTransform, frAsm, frPreProcessor, JcfUIConsts, Diff, diffmerge, JcfStringUtils, JcfSystemUtils, - JcfUnicodeFiles, JcfUiTools, LazarusPackageIntf; + JcfUnicodeFiles, LazarusPackageIntf; implementation diff --git a/components/jcf2/Parse/BuildParseTree.pas b/components/jcf2/Parse/BuildParseTree.pas index 7f7ab26634..d1345bb6c1 100644 --- a/components/jcf2/Parse/BuildParseTree.pas +++ b/components/jcf2/Parse/BuildParseTree.pas @@ -41,6 +41,7 @@ interface uses Contnrs, SysUtils, + Forms, // local ParseTreeNode, ParseTreeNodeType, @@ -298,9 +299,6 @@ type implementation -uses - JcfUiTools; - const UPDATE_INTERVAL = 512; @@ -451,7 +449,10 @@ begin end; Inc(fiTokenCount); - UpdateGUI(fiTokenCount,UPDATE_INTERVAL); + {$IFnDEF LCLNOGUI} + if (fiTokenCount mod UPDATE_INTERVAL) = 0 then + Application.ProcessMessages; + {$ENDIF} { add trailing white space fixes some problems, causes others diff --git a/components/jcf2/Parse/BuildTokenList.pas b/components/jcf2/Parse/BuildTokenList.pas index 9eab8b6de8..475a0a8e69 100644 --- a/components/jcf2/Parse/BuildTokenList.pas +++ b/components/jcf2/Parse/BuildTokenList.pas @@ -39,8 +39,9 @@ interface uses SysUtils, StrUtils, + Forms, { local } - Tokens, SourceToken, SourceTokenList, JcfUiTools; + Tokens, SourceToken, SourceTokenList; type @@ -962,18 +963,27 @@ const var lcList: TSourceTokenList; lcNew: TSourceToken; + {$IFnDEF LCLNOGUI} liCounter: integer; + {$ENDIF} begin Assert(SourceCode <> ''); + + {$IFnDEF LCLNOGUI} liCounter := 0; + {$ENDIF} lcList := TSourceTokenList.Create; while not EndOfFile do begin lcNew := GetNextToken; lcList.Add(lcNew); + + {$IFnDEF LCLNOGUI} Inc(liCounter); - UpdateGUI(liCounter, UPDATE_INTERVAL); + if (liCounter mod UPDATE_INTERVAL) = 0 then + Application.ProcessMessages; + {$ENDIF} end; Result := lcList; diff --git a/components/jcf2/Parse/PreProcessor/PreProcessorParseTree.pas b/components/jcf2/Parse/PreProcessor/PreProcessorParseTree.pas index 2bb8a60c5b..930fb15d9a 100644 --- a/components/jcf2/Parse/PreProcessor/PreProcessorParseTree.pas +++ b/components/jcf2/Parse/PreProcessor/PreProcessorParseTree.pas @@ -34,6 +34,7 @@ interface uses Classes, SysUtils, + Forms, { local } Tokens, SourceTokenList, SourceToken; @@ -91,7 +92,7 @@ implementation uses { local } PreProcessorExpressionTokenise, PreProcessorExpressionParser, - ParseError, JcfSettings, JcfUiTools; + ParseError, JcfSettings; procedure RemoveConditionalCompilation(const pcTokens: TSourceTokenList); var @@ -177,11 +178,17 @@ end; procedure TPreProcessorParseTree.NextToken; +{$IFnDEF LCLNOGUI} const UPDATE_INTERVAL = 512; +{$ENDIF} begin Inc(fiCurrentTokenIndex); - UpdateGUI(fiCurrentTokenIndex,UPDATE_INTERVAL); + + {$IFnDEF LCLNOGUI} + if (fiCurrentTokenIndex mod UPDATE_INTERVAL) = 0 then + Application.ProcessMessages; + {$ENDIF} end; function TPreProcessorParseTree.CurrentToken: TSourceToken; diff --git a/components/jcf2/Process/AllProcesses.pas b/components/jcf2/Process/AllProcesses.pas index 999c71a812..da1f001f6b 100644 --- a/components/jcf2/Process/AllProcesses.pas +++ b/components/jcf2/Process/AllProcesses.pas @@ -71,7 +71,7 @@ type implementation uses - SysUtils, + Forms, SysUtils, { local } JcfSettings, SetClarify, VisitSetXY, { once-offs } @@ -107,7 +107,7 @@ uses BasicStats, { align } AlignConst, AlignVars, AlignAssign, AlignTypedef, AlignComment, AlignField, - IndentAsmParam, JcfUiTools; + IndentAsmParam; constructor TAllProcesses.Create; begin @@ -158,7 +158,9 @@ begin if lc.FinalSummary(lsMessage) then OnMessage('', lsMessage, mtFinalSummary, -1, -1); - UpdateGUI; + {$IFnDEF LCLNOGUI} + Application.ProcessMessages; + {$ENDIF} { if the main process fired, do the follow set too } for liLoop := Low(pcFollowSet) to High(pcFollowSet) do diff --git a/components/jcf2/ReadWrite/Converter.pas b/components/jcf2/ReadWrite/Converter.pas index 5e8e12e8e8..d6d45cd954 100644 --- a/components/jcf2/ReadWrite/Converter.pas +++ b/components/jcf2/ReadWrite/Converter.pas @@ -37,7 +37,11 @@ unit Converter; interface uses - SysUtils, strutils, LazFileUtils, + SysUtils, strutils, + // LazUtils + LazFileUtils, + // LCL + Controls, Forms, // local ConvertTypes, ParseTreeNode, BuildTokenList, BuildParseTree, BaseVisitor; @@ -65,6 +69,9 @@ type This could be in batch file on a server } fbGuiMessages: Boolean; fbShowParseTree: Boolean; + {$IFnDEF LCLNOGUI} + leOldCursor: TCursor; + {$ENDIF} function GetOnStatusMessage: TStatusMessageProc; procedure SetOnStatusMessage(const Value: TStatusMessageProc); @@ -109,10 +116,9 @@ type implementation uses - AllProcesses, - JcfRegistrySettings, + AllProcesses, fShowParseTree, JcfRegistrySettings, JcfSettings, JcfStringUtils, ParseError, PreProcessorParseTree, - SourceToken, SourceTokenList, TreeWalker, VisitSetNesting, VisitSetXY, JcfUiTools; + SourceToken, SourceTokenList, TreeWalker, VisitSetNesting, VisitSetXY; function StrInsert(const psSub, psMain: String; const piPos: Integer): String; begin @@ -152,10 +158,12 @@ var lcTokenList: TSourceTokenList; begin fbConvertError := False; + {$IFnDEF LCLNOGUI} + leOldCursor := Screen.Cursor; try { finally normal cursor } // this can take a long time for large files - SetWaitCursorUI; - + Screen.Cursor := crHourGlass; + {$ENDIF} // turn text into tokens fcTokeniser.SourceCode := InputCode; @@ -224,9 +232,12 @@ begin SendExceptionMessage(E); end; end; + + {$IFnDEF LCLNOGUI} finally - RestoreCursorUI; + Screen.Cursor := leOldCursor; end; + {$ENDIF} end; { this is what alters the code (in parse tree form) from source to output } @@ -346,10 +357,12 @@ end; procedure TConverter.ShowParseTree; begin + {$IFnDEF LCLNOGUI} // This is always called from a Cursor:=crHourGlass block. Restore old cursor. - RestoreCursorUI; + Screen.Cursor := leOldCursor; + {$ENDIF} if fcBuildParseTree.Root <> nil then - ShowParseTreeUI(fcBuildParseTree.Root); + fShowParseTree.ShowParseTree(fcBuildParseTree.Root); end; procedure TConverter.ConvertPart(const piStartIndex, piEndIndex: Integer; diff --git a/components/jcf2/ReadWrite/EditorConverter.pas b/components/jcf2/ReadWrite/EditorConverter.pas index 87a18a2070..f3d31b5181 100644 --- a/components/jcf2/ReadWrite/EditorConverter.pas +++ b/components/jcf2/ReadWrite/EditorConverter.pas @@ -35,6 +35,7 @@ interface uses Classes, SysUtils, + // IdeIntf SrcEditorIntf, { local } Converter, ConvertTypes; diff --git a/components/jcf2/ReadWrite/FileConverter.pas b/components/jcf2/ReadWrite/FileConverter.pas index 22d5fe7cb3..ecb0e9ba32 100644 --- a/components/jcf2/ReadWrite/FileConverter.pas +++ b/components/jcf2/ReadWrite/FileConverter.pas @@ -31,6 +31,7 @@ interface uses Classes, SysUtils, + Dialogs, Controls, Forms, // local Converter, ConvertTypes; @@ -113,9 +114,9 @@ implementation uses { local } - JcfStringUtils, FileUtil, + JcfStringUtils, JcfSystemUtils, JcfMiscFunctions, JcfLog, - JcfRegistrySettings, JcfSettings, JcfUnicodeFiles, JcfUiTools, System.UITypes; + JcfRegistrySettings, JcfSettings, JcfUnicodeFiles; constructor TFileConverter.Create; begin @@ -150,7 +151,7 @@ begin exit; end; - if FileSize(psInputFileName) < 1 then + if FileGetSize(psInputFileName) < 1 then begin SendStatusMessage(psInputFileName, 'The file "' + psInputFileName + '" is empty', mtInputError, @@ -249,7 +250,8 @@ begin else lsOutType := 'Output'; - wRes :=MessageDlgUI(lsOutType + ' file ' + lsOut + ' exists already. Remove it?'); + wRes := MessageDlg(lsOutType + ' file ' + lsOut + ' exists already. Remove it?', + mtConfirmation, [mbYes, mbNo, mbAll, mbAbort], 0); end; if wRes = mrAll then @@ -359,7 +361,11 @@ begin ProcessFile(lsDir + lsNames[liLoop]); if fbAbort then break; - UpdateGUI; + + {$IFnDEF LCLNOGUI} + // refresh the GUI + Application.ProcessMessages; + {$ENDIF} end; { all subdirs } diff --git a/components/jcf2/Settings/JcfRegistrySettings.pas b/components/jcf2/Settings/JcfRegistrySettings.pas index 4ad8e0f3f2..b9bc2b3d5d 100644 --- a/components/jcf2/Settings/JcfRegistrySettings.pas +++ b/components/jcf2/Settings/JcfRegistrySettings.pas @@ -41,6 +41,7 @@ interface uses Registry, Classes, SysUtils, + Dialogs, { local } ConvertTypes; @@ -190,11 +191,7 @@ implementation uses { jcf } - JcfStringUtils, JcfSystemUtils, JcfMiscFunctions, JcfUiTools - {$ifndef COMMAND_LINE} - ,lclintf //< OpenDocument - {$endif} - ; + JcfStringUtils, JcfSystemUtils, JcfMiscFunctions; const REG_GENERAL_SECTION = 'General'; @@ -524,17 +521,14 @@ procedure TJCFRegistrySettings.ViewLog; var lsFile: string; begin - {$ifndef COMMAND_LINE} lsFile := LogFileName; if FileExists(lsFile) then begin - //ShellExecEx('notepad.exe ', lsFile); - OpenDocument(lsFile); + ShellExecEx('notepad.exe ', lsFile); end else - ShowErrorMessageUI('No log file found at ' + lsFile); - {$endif} + ShowMessage('No log file found at ' + lsFile); end; function TJCFRegistrySettings.DirIsExcluded(const psDir: string): boolean; diff --git a/components/jcf2/Settings/JcfSettings.pas b/components/jcf2/Settings/JcfSettings.pas index 657cd14483..e3b0a7a1d9 100644 --- a/components/jcf2/Settings/JcfSettings.pas +++ b/components/jcf2/Settings/JcfSettings.pas @@ -35,26 +35,24 @@ interface uses SysUtils, - {$ifdef LAZARUS_PLUGIN} + // LCL + Dialogs, + // BuildIntf IDEOptionsIntf, + // IdeIntf IDEOptEditorIntf, - {$endif} // local SetObfuscate, SetClarify, SetIndent, SetSpaces, SetReturns, SetComments, SetCaps, SetWordList, SetAlign, SetReplace, SetUses, SetPreProcessor, SettingsStream, SetTransform, SetAsm, JcfVersionConsts, - JcfStringUtils, JcfSetBase, JcfRegistrySettings, - JcfUIConsts, - JcfUiTools; + JcfStringUtils, JcfSetBase, JcfRegistrySettings, JcfUIConsts; + type { TFormattingSettings } - {$ifdef LAZARUS_PLUGIN} + TFormattingSettings = class(TAbstractIDEEnvironmentOptions) - {$else} - TFormattingSettings = class - {$endif} private fcObfuscate: TSetObfuscate; fcClarify: TSetClarify; @@ -92,11 +90,10 @@ type public constructor Create(const pbReadRegFile: boolean); destructor Destroy; override; - {$ifdef LAZARUS_PLUGIN} class function GetGroupCaption: String; override; class function GetInstance: TAbstractIDEOptions; override; procedure DoAfterWrite({%H-}Restore: boolean); override; - {$endif} + procedure Read; procedure ReadFromFile(const psFileName: string; const pbMustExist: boolean); procedure ReadDefaults; @@ -244,7 +241,6 @@ begin inherited; end; -{$ifdef LAZARUS_PLUGIN} class function TFormattingSettings.GetGroupCaption: String; begin Result := lisJCFFormatSettings; @@ -264,7 +260,6 @@ begin { save to file } Write; end; -{$endif} const CODEFORMAT_SETTINGS_SECTION = 'JediCodeFormatSettings'; @@ -302,7 +297,8 @@ begin end; end else if pbMustExist then - ShowErrorMessageUI(Format(lisTheSettingsFileDoesNotExist, [psFileName, NativeLineBreak])); + MessageDlg(Format(lisTheSettingsFileDoesNotExist, [psFileName, NativeLineBreak]), + mtError, [mbOK], 0); end; @@ -338,7 +334,7 @@ begin begin { fail quietly? } if lcReg.FormatFileWriteOption = eAlwaysWrite then - ShowErrorMessageUI(Format(lisErrorWritingSettingsFileReadOnly, [lcReg.FormatConfigFileName])); + MessageDlg(Format(lisErrorWritingSettingsFileReadOnly, [lcReg.FormatConfigFileName]), mtError, [mbOK], 0); exit; end; @@ -358,7 +354,8 @@ begin begin if lcReg.FormatFileWriteOption = eAlwaysWrite then begin - ShowErrorMessageUI(Format(lisErrorWritingSettingsException, [GetRegSettings.FormatConfigFileName, NativeLineBreak, E.Message])); + MessageDlg(Format(lisErrorWritingSettingsException, [GetRegSettings.FormatConfigFileName, NativeLineBreak, E.Message]), + mtError, [mbOK], 0); end; end; end; @@ -445,7 +442,7 @@ begin lcAllSettings := pcStream.ExtractSection(CODEFORMAT_SETTINGS_SECTION); if lcAllSettings = nil then begin - ShowErrorMessageUI(lisNoSettingsFound); + ShowMessage(lisNoSettingsFound); exit; end; @@ -513,10 +510,8 @@ begin end; initialization - {$ifdef LAZARUS_PLUGIN} JCFOptionsGroup := GetFreeIDEOptionsGroupIndex(GroupEditor); RegisterIDEOptionsGroup(JCFOptionsGroup, TFormattingSettings); - {$endif} finalization FreeAndNil(mcFormattingSettings); end. diff --git a/components/jcf2/TestApplication/TestJCF.lpi b/components/jcf2/TestApplication/TestJCF.lpi index 4b322b3692..292a8f7198 100644 --- a/components/jcf2/TestApplication/TestJCF.lpi +++ b/components/jcf2/TestApplication/TestJCF.lpi @@ -34,7 +34,7 @@ - + @@ -162,11 +162,6 @@ - - - - - @@ -177,13 +172,10 @@ - + - - - diff --git a/components/jcf2/TestApplication/TestJCF.lpr b/components/jcf2/TestApplication/TestJCF.lpr index 76cd7854b7..13ca184622 100644 --- a/components/jcf2/TestApplication/TestJCF.lpr +++ b/components/jcf2/TestApplication/TestJCF.lpr @@ -10,7 +10,7 @@ uses {$IFDEF UNIX} unit1, BuildParseTree, fShowParseTree, - Converter, JcfUiTools, SettingsStream, + Converter, SettingsStream, ReturnBefore, MoveSpaceToBeforeColon, Indenter, diff --git a/components/jcf2/Ui/jcfuitools.pas b/components/jcf2/Ui/jcfuitools.pas deleted file mode 100644 index f5fb6a4c52..0000000000 --- a/components/jcf2/Ui/jcfuitools.pas +++ /dev/null @@ -1,111 +0,0 @@ -unit JcfUiTools; - -{$mode ObjFPC} - -interface - -uses - Classes, SysUtils, System.UITypes, ParseTreeNode; - -procedure UpdateGUI(aCounter:integer=0;aUpdateInterval:integer=512); -function MessageDlgUI(const aMessage:string):TModalResult; -procedure ShowErrorMessageUI(const aMessage:string); -procedure SetWaitCursorUI; -procedure RestoreCursorUI; -procedure ShowParseTreeUI(const pcRoot: TParseTreeNode); - -implementation - -{$ifdef COMMAND_LINE} -uses - crt; - -procedure UpdateGUI(aCounter:integer=0;aUpdateInterval:integer=512); -begin -end; - -function MessageDlgUI(const aMessage:string):TModalResult; -const - MR:array[1..4] of TModalResult = (mrYes, mrNo, mrAbort, mrAll); -var - C:char; - I:integer; -begin - WriteLn(aMessage); - Write('Yes No Abort aLl ? '); - I:=0; - repeat - C:=ReadKey; - C:=UpCase(C); - I:=Pos(C,'YNAL'); - until I>0; - WriteLn(C); - result:=MR[I]; -end; - -procedure ShowErrorMessageUI(const aMessage:string); -begin - writeln(aMessage); -end; - - -procedure SetWaitCursorUI; -begin -end; - -procedure RestoreCursorUI; -begin -end; - -procedure ShowParseTreeUI; -begin -end; - -procedure ShowParseTreeUI(const pcRoot: TParseTreeNode); -begin -end; - - -{$else} -uses - Forms, Dialogs, Controls, fShowParseTree; - -procedure UpdateGUI(aCounter:integer=0;aUpdateInterval:integer=512); -begin - if (aCounter mod aUpdateInterval) = 0 then - Application.ProcessMessages; -end; - -function MessageDlgUI(const aMessage:string):TModalResult; -begin - result := MessageDlg(aMessage, mtConfirmation, [mbYes, mbNo, mbAll, mbAbort], 0); -end; - -procedure ShowErrorMessageUI(const aMessage:string); -begin - MessageDlg(aMessage, mtError, [mbOK], 0); -end; - -var - OldCursor:TCursor; - -procedure SetWaitCursorUI; -begin - OldCursor := Screen.Cursor; - Screen.Cursor := crHourGlass; -end; - -procedure RestoreCursorUI; -begin - Screen.Cursor := OldCursor; -end; - -procedure ShowParseTreeUI(const pcRoot: TParseTreeNode); -begin - fShowParseTree.ShowParseTree(pcRoot); -end; - -{$endif} - -end. - diff --git a/components/jcf2/Utils/JcfMiscFunctions.pas b/components/jcf2/Utils/JcfMiscFunctions.pas index abbc1c42aa..ff64aa50b2 100644 --- a/components/jcf2/Utils/JcfMiscFunctions.pas +++ b/components/jcf2/Utils/JcfMiscFunctions.pas @@ -48,7 +48,10 @@ See http://www.gnu.org/licenses/gpl.html interface uses - Classes, SysUtils, JcfStringUtils; + Classes, SysUtils, + Forms, + // local + JcfStringUtils; function GetApplicationFolder: string; @@ -69,7 +72,7 @@ implementation function GetApplicationFolder: string; begin - Result := ExtractFilePath(ParamStr(0)); + Result := ExtractFilePath(Application.ExeName); end; { these come from Ralf Steinhaeusser diff --git a/components/jcf2/Utils/JcfStringUtils.pas b/components/jcf2/Utils/JcfStringUtils.pas index 3029ffb2e1..269cad78fb 100644 --- a/components/jcf2/Utils/JcfStringUtils.pas +++ b/components/jcf2/Utils/JcfStringUtils.pas @@ -711,6 +711,7 @@ end; function StrTrimLastEndOfLine(const aStr:string):string; var len:integer; + c:char; begin len:=length(aStr); if (len>0) then diff --git a/components/jcf2/Utils/JcfSystemUtils.pas b/components/jcf2/Utils/JcfSystemUtils.pas index 765aa5de54..b42bb3e92b 100644 --- a/components/jcf2/Utils/JcfSystemUtils.pas +++ b/components/jcf2/Utils/JcfSystemUtils.pas @@ -38,6 +38,10 @@ uses function GetWindowsTempFolder: string; +function FileIsReadOnly(const ps: string): boolean; +function FileGetSize(const FileName: string): Int64; + +procedure ShellExecEx(const FileName: string; const Parameters: string = ''); function IsMultiByte(const {%H-}pcChar: Char): Boolean; function IsWinServer2008R2: Boolean; @@ -55,18 +59,42 @@ implementation uses {$ifdef MSWINDOWS} - Windows + Windows, ShellApi {$endif} {$ifdef Unix} Unix {$endif} - ,FileUtil; + ,LCLIntf, fileutil; function GetWindowsTempFolder: string; begin Result := GetTempDir; end; +function FileIsReadOnly(const ps: string): boolean; +var + liAttr: integer; +begin + Assert(FileExists(ps)); + liAttr := FileGetAttr(ps); + Result := (liAttr and faReadOnly) <> 0; +end; + +function FileGetSize(const FileName: string): Int64; +begin + Result := FileUtil.FileSize(FileName); +end; + +procedure ShellExecEx(const FileName: string; const Parameters: string = ''); +begin + {$ifdef MSWINDOWS} + ShellApi.ShellExecute(0, 'open', PChar(FileName), PChar(Parameters), nil, SW_SHOW); + {$endif} + {$ifdef unix} + fpsystem(format('%s %s',[FileName, Parameters])); + {$endif} +end; + function IsMultiByte(const pcChar: Char): Boolean; begin //Result := IsDBCSLeadByte(Byte(pcChar));