Jedi Code Format: Refactoring. Remove obsolete code and units. Issue #39929, patch by Domingo Galmés.

This commit is contained in:
Juha 2022-10-14 18:21:44 +03:00
parent 9140e0e4a2
commit 1e8303a356
17 changed files with 341 additions and 876 deletions

View File

@ -75,7 +75,7 @@
<PackageName Value="FCL"/>
</Item2>
</RequiredPackages>
<Units Count="122">
<Units Count="121">
<Unit0>
<Filename Value="jcf.lpr"/>
<IsPartOfProject Value="True"/>
@ -560,14 +560,10 @@
<IsPartOfProject Value="True"/>
</Unit119>
<Unit120>
<Filename Value="../../Utils/JcfSystemUtils.pas"/>
<IsPartOfProject Value="True"/>
</Unit120>
<Unit121>
<Filename Value="../../Ui/jcfuitools.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="JcfUiTools"/>
</Unit121>
</Unit120>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -29,7 +29,6 @@ See http://www.gnu.org/licenses/gpl.html
uses
SysUtils,
JcfStringUtils in '..\..\Utils\JcfStringUtils.pas',
JcfSystemUtils in '..\..\Utils\JcfSystemUtils.pas',
Converter in '..\..\ReadWrite\Converter.pas',
FileConverter in '..\..\ReadWrite\FileConverter.pas',
ConvertTypes in '..\..\ReadWrite\ConvertTypes.pas',

View File

@ -491,10 +491,6 @@
<Filename Value="..\..\Utils\IntList.pas"/>
<UnitName Value="IntList"/>
</Item>
<Item>
<Filename Value="..\..\Utils\JcfFontSetFunctions.pas"/>
<UnitName Value="JcfFontSetFunctions"/>
</Item>
<Item>
<Filename Value="..\..\Utils\JcfHelp.pas"/>
<UnitName Value="JcfHelp"/>
@ -727,10 +723,6 @@
<Filename Value="..\..\Utils\JcfStringUtils.pas"/>
<UnitName Value="JcfStringUtils"/>
</Item>
<Item>
<Filename Value="..\..\Utils\JcfSystemUtils.pas"/>
<UnitName Value="JcfSystemUtils"/>
</Item>
<Item>
<Filename Value="..\..\Utils\JcfUnicodeFiles.pas"/>
<UnitName Value="JcfUnicodeFiles"/>

View File

@ -34,14 +34,14 @@ uses
SetClarify, SetComments, SetIndent, SetObfuscate, SetPreProcessor,
SetReplace, SetReturns, SetSpaces, SettingsTypes, SetTransform, SetUses,
SetWordList, SettingsStream, fJcfErrorDisplay, Delay, IntList,
JcfFontSetFunctions, JcfHelp, JcfLog, JcfMiscFunctions, fAbout,
JcfHelp, JcfLog, JcfMiscFunctions, fAbout,
JcfVersionConsts, frFiles, frObfuscateSettings, frClarify, frClarifySpaces,
frClarifyIndent, frBlankLines, frClarifyAlign, frClarifyLongLineBreaker,
frClarifyReturns, frCompilerDirectReturns, frClarifyBlocks,
frClarifyCaseBlocks, frComments, frWarnings, frReservedCapsSettings,
frAnyCapsSettings, frIdentifierCapsSettings, frNotIdentifierCapsSettings,
frUnitCaps, frReplace, frUses, frTransform, frAsm, frPreProcessor,
JcfUIConsts, Diff, diffmerge, JcfStringUtils, JcfSystemUtils,
JcfUIConsts, Diff, diffmerge, JcfStringUtils,
JcfUnicodeFiles, JcfUiTools, LazarusPackageIntf;
implementation

View File

@ -110,8 +110,7 @@ implementation
uses
{ local }
JcfStringUtils, JcfSystemUtils,
JcfRegistrySettings, ParseError;
JcfStringUtils, JcfRegistrySettings, ParseError;
const
CurlyLeft = '{'; //widechar(123);
@ -120,8 +119,8 @@ const
function CheckMultiByte(const pcChar: char): boolean;
begin
Result := False;
if GetRegSettings.CheckMultiByteChars then
Result := IsMultiByte(pcChar);
// if GetRegSettings.CheckMultiByteChars then
// Result := IsMultiByte(pcChar); //IsMultiByte(pcChar)-->Result := IsDBCSLeadByte(Byte(pcChar));
end;
function CharIsOctDigit(const c: Char): Boolean;

View File

@ -9,15 +9,14 @@ object frmShowParseTree: TfrmShowParseTree
ClientHeight = 555
ClientWidth = 581
KeyPreview = True
OnCreate = FormCreate
OnKeyUp = FormKeyUp
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.9.0.0'
LCLVersion = '2.3.0.0'
object StatusBar1: TStatusBar
Left = 0
Height = 21
Top = 534
Height = 23
Top = 532
Width = 581
Panels = <>
end
@ -35,25 +34,27 @@ object frmShowParseTree: TfrmShowParseTree
TabOrder = 1
object lblTreeCount: TLabel
Left = 11
Height = 17
Height = 15
Top = 31
Width = 110
Width = 87
Caption = 'Tree has ? nodes'
Color = clDefault
ParentColor = False
end
object lblTreeDepth: TLabel
Left = 11
Height = 17
Height = 15
Top = 55
Width = 165
Width = 130
Caption = 'Tree has max depth of ??'
Color = clDefault
ParentColor = False
end
object cbShowWhiteSpace: TCheckBox
Left = 11
Height = 24
Height = 19
Top = 5
Width = 145
Width = 109
Caption = 'Show whitespace'
OnClick = cbShowWhiteSpaceClick
TabOrder = 0
@ -62,7 +63,7 @@ object frmShowParseTree: TfrmShowParseTree
object pnlBottom: TPanel
Left = 0
Height = 50
Top = 484
Top = 482
Width = 581
Align = alBottom
BevelOuter = bvNone
@ -71,40 +72,44 @@ object frmShowParseTree: TfrmShowParseTree
TabOrder = 2
object lblCurrent: TLabel
Left = 11
Height = 17
Height = 15
Top = 2
Width = 57
Width = 43
Caption = 'Current:'
Color = clDefault
ParentColor = False
end
object lblDepth: TLabel
Left = 11
Height = 17
Height = 15
Top = 26
Width = 47
Width = 35
Caption = 'Depth:'
Color = clDefault
ParentColor = False
end
object lblTotalNodeCount: TLabel
Left = 271
Height = 17
Height = 15
Top = 26
Width = 119
Width = 94
Caption = 'Total node count:'
Color = clDefault
ParentColor = False
end
object lblImmediateChildCount: TLabel
Left = 271
Height = 17
Height = 15
Top = 2
Width = 156
Width = 123
Caption = 'Immediate child count:'
Color = clDefault
ParentColor = False
end
end
object pcPages: TPageControl
Left = 6
Height = 387
Height = 385
Top = 91
Width = 569
ActivePage = tsTokens
@ -114,13 +119,13 @@ object frmShowParseTree: TfrmShowParseTree
TabOrder = 3
object tsTokens: TTabSheet
Caption = 'Tokens'
ClientHeight = 356
ClientWidth = 565
ClientHeight = 357
ClientWidth = 561
object lvTokens: TListView
Left = 0
Height = 356
Height = 357
Top = 0
Width = 565
Width = 561
Align = alClient
Columns = <
item
@ -146,14 +151,14 @@ object frmShowParseTree: TfrmShowParseTree
end
object tsTree: TTabSheet
Caption = 'Tree'
ClientHeight = 356
ClientWidth = 565
ClientHeight = 357
ClientWidth = 561
ImageIndex = 1
object tvParseTree: TTreeView
Left = 0
Height = 363
Height = 357
Top = 0
Width = 577
Width = 561
Align = alClient
HideSelection = False
Indent = 22

View File

@ -68,7 +68,6 @@ type
procedure lvTokensDblClick(Sender: TObject);
procedure tvParseTreeDblClick(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: word; {%H-}Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
fcRootNode: TParseTreeNode;
procedure ShowTreeNodeDetails(const pcNode: TParseTreeNode);
@ -86,7 +85,7 @@ implementation
{$R *.lfm}
uses
SourceToken, Tokens, JcfHelp, JcfFontSetFunctions;
SourceToken, Tokens, JcfHelp;
procedure ShowParseTree(const pcRoot: TParseTreeNode);
var
@ -302,11 +301,6 @@ begin
end;
end;
procedure TfrmShowParseTree.FormCreate(Sender: TObject);
begin
SetObjectFontToSystemFont(Self);
end;
procedure TfrmShowParseTree.FormKeyUp(Sender: TObject; var Key: word;
Shift: TShiftState);
begin

View File

@ -190,7 +190,7 @@ implementation
uses
{ jcf }
JcfStringUtils, JcfSystemUtils, JcfMiscFunctions, JcfUiTools
JcfStringUtils, JcfMiscFunctions, JcfUiTools
{$ifndef COMMAND_LINE}
,lclintf //< OpenDocument
{$endif}
@ -505,7 +505,7 @@ function TJCFRegistrySettings.LogDirectory: string;
begin
case feLogPlace of
eLogTempDir:
Result := GetWindowsTempFolder;
Result := GetTempDir;
eLogAppDir:
Result := ExtractFileDir(ParamStr(0));
eLogSpecifiedDir:

View File

@ -1,536 +0,0 @@
{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
The Original Code is Settings.pas, released April 2000.
The Initial Developer of the Original Code is Anthony Steele.
Portions created by Anthony Steele are Copyright (C) 1999-2008 Anthony Steele.
All Rights Reserved.
Contributor(s): Anthony Steele.
The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"). you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and limitations
under the License.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 or later (the "GPL")
See http://www.gnu.org/licenses/gpl.html
------------------------------------------------------------------------------*)
{*)}
unit JcfSettings;
{ this is the settings on how to parse. As of 2.0 this is always from a file
The file name is stored in registry
This allows centralised settings on a shared dir }
{$I JcfGlobal.inc}
interface
uses
{ local }
SetObfuscate, SetClarify,
SetIndent, SetSpaces, SetReturns,
SetComments, SetCaps, SetWordList,
SetAlign, SetReplace, SetUses, SetPreProcessor,
SettingsStream, SetTransform, SetAsm,
JcfVersionConsts; //, IDEOptionsIntf;
type
{ TFormatSettings }
//TFormatSettings = class(TAbstractIDEEnvironmentOptions)
TFormatSettings = class(TObject)
private
fcObfuscate: TSetObfuscate;
fcClarify: TSetClarify;
fcSpaces: TSetSpaces;
fcIndent: TSetIndent;
fcReturns: TSetReturns;
fcComments: TSetComments;
fcCaps: TSetCaps;
fcSpecificWordCaps: TSetWordList;
fcIdentifierCaps: TSetWordList;
fcNotIdentifierCaps: TSetWordList;
fcUnitNameCaps: TSetWordList;
fcSetAsm: TSetAsm;
fcPreProcessor: TSetPreProcessor;
fcAlign: TSetAlign;
fcUses: TSetUses;
fcReplace: TSetReplace;
fcTransform: TSetTransform;
fbWriteOnExit: boolean;
fbHasRead: boolean;
fbDirty: boolean;
fsDescription: string;
fdtWriteDateTime: TDateTime;
fsWriteVersion: string;
procedure FromStream(const pcStream: TSettingsInput);
public
constructor Create(const pbReadRegFile: boolean);
destructor Destroy; override;
//class function GetGroupCaption: String; override;
//class function GetInstance: TAbstractIDEOptions; override;
//procedure DoAfterWrite({%H-}Restore: boolean); override;
procedure Read;
procedure ReadFromFile(const psFileName: string; const pbMustExist: boolean);
procedure ReadDefaults;
procedure Write;
procedure MakeConsistent;
procedure ToStream(const pcStream: TSettingsOutput);
property Description: string Read fsDescription Write fsDescription;
property WriteDateTime: TDateTime Read fdtWriteDateTime Write fdtWriteDateTime;
property WriteVersion: string Read fsWriteVersion Write fsWriteVersion;
property Obfuscate: TSetObfuscate Read fcObfuscate;
property Clarify: TSetClarify Read fcClarify;
property Indent: TSetIndent Read fcIndent;
property Spaces: TSetSpaces Read fcSpaces;
property Returns: TSetReturns Read fcReturns;
property Comments: TSetComments Read fcComments;
property Caps: TSetCaps Read fcCaps;
property SpecificWordCaps: TSetWordList Read fcSpecificWordCaps;
property IdentifierCaps: TSetWordList Read fcIdentifierCaps;
property NotIdentifierCaps: TSetWordList Read fcNotIdentifierCaps;
property UnitNameCaps: TSetWordList Read fcUnitNameCaps;
property SetAsm: TSetAsm Read fcSetAsm;
property PreProcessor: TSetPreProcessor Read fcPreProcessor;
property Align: TSetAlign Read fcAlign;
property Replace: TSetReplace Read fcReplace;
property UsesClause: TSetUses Read fcUses;
property Transform: TSetTransform read fcTransform;
property WriteOnExit: boolean Read fbWriteOnExit Write fbWriteOnExit;
property Dirty: boolean Read fbDirty Write fbDirty;
property HasRead: boolean read fbHasRead write fbHasRead;
end;
function FormattingSettings: TFormatSettings;
// create from a settings file
function FormatSettingsFromFile(const psFileName: string): TFormatSettings;
var
JCFOptionsGroup: Integer;
const
JCFOptionFormatFile = 1;
JCFOptionObfuscate = 2;
JCFOptionClarify = 3;
JCFOptionSpaces = 4;
JCFOptionIndentation = 5;
JCFOptionBlankLines = 6;
JCFOptionAlign = 7;
JCFOptionLongLines = 8;
JCFOptionReturns = 9;
JCFOptionCaseBlocks = 10;
JCFOptionBlocks = 11;
JCFOptionCompilerDirectives = 12;
JCFOptionComments = 13;
JCFOptionWarnings = 14;
JCFOptionObjectPascal = 15;
JCFOptionAnyWord = 16;
JCFOptionIdentifiers = 17;
JCFOptionNotIdentifiers = 18;
JCFOptionUnitName = 19;
JCFOptionFindAndReplace = 20;
JCFOptionUses = 21;
JCFOptionBasic = 22;
JCFOptionTransform = 23;
JCFOptionAsm = 24;
JCFOptionPreProcessor = 25;
const
GUI_PAD = 3;
implementation
uses
{ delphi }
{$IFNDEF FPC}Windows,{$ELSE}LazFileUtils, LazUTF8,{$ENDIF} SysUtils, Dialogs,
{ local }
JcfStringUtils,
JcfSetBase,
JcfRegistrySettings,
jcfuiconsts in '../IdePlugin/lazarus/jcfuiconsts.pas';
constructor TFormatSettings.Create(const pbReadRegFile: boolean);
begin
inherited Create();
fcObfuscate := TSetObfuscate.Create;
fcClarify := TSetClarify.Create;
fcIndent := TSetIndent.Create;
fcSpaces := TSetSpaces.Create;
fcReturns := TSetReturns.Create;
fcComments := TSetComments.Create;
fcCaps := TSetCaps.Create;
fcSpecificWordCaps := TSetWordList.Create('SpecificWordCaps');
fcIdentifierCaps := TSetWordList.Create('Identifiers');
fcNotIdentifierCaps := TSetWordList.Create('NotIdent');
fcUnitNameCaps := TSetWordList.Create('UnitNameCaps');
fcSetAsm := TSetAsm.Create();
fcPreProcessor := TSetPreProcessor.Create;
fcAlign := TSetAlign.Create;
fcReplace := TSetReplace.Create;
fcUses := TSetUses.Create;
fcTransform := TSetTransform.Create;
if pbReadRegFile then
begin
Read;
end;
fbWriteOnExit := True;
fbDirty := False;
end;
destructor TFormatSettings.Destroy;
begin
if WriteOnExit then
Write;
FreeAndNil(fcObfuscate);
FreeAndNil(fcClarify);
FreeAndNil(fcIndent);
FreeAndNil(fcSpaces);
FreeAndNil(fcReturns);
FreeAndNil(fcComments);
FreeAndNil(fcCaps);
FreeAndNil(fcSpecificWordCaps);
FreeAndNil(fcIdentifierCaps);
FreeAndNil(fcNotIdentifierCaps);
FreeAndNil(fcUnitNameCaps);
FreeAndNil(fcSetAsm);
FreeAndNil(fcPreProcessor);
FreeAndNil(fcReplace);
FreeAndNil(fcAlign);
FreeAndNil(fcUses);
FreeAndNil(fcTransform);
inherited;
end;
//class function TFormatSettings.GetGroupCaption: String;
//begin
// Result := lisJCFFormatSettings;
//end;
//
//class function TFormatSettings.GetInstance: TAbstractIDEOptions;
//begin
// Result := FormatSettings;
//end;
//
//procedure TFormatSettings.DoAfterWrite(Restore: boolean);
//begin
// { settings are now in need of saving }
// Dirty := True;
// { check consistency of settings }
// MakeConsistent;
// { save to file }
// Write;
//end;
const
CODEFORMAT_SETTINGS_SECTION = 'JediCodeFormatSettings';
REG_VERSION = 'WriteVersion';
REG_WRITE_DATETIME = 'WriteDateTime';
REG_DESCRIPTION = 'Description';
procedure TFormatSettings.Read;
var
lcReg: TJCFRegistrySettings;
begin
// use the Settings File if it exists
lcReg := GetRegSettings;
ReadFromFile(lcReg.FormatConfigFileName, lcReg.FormatConfigNameSpecified);
end;
procedure TFormatSettings.ReadFromFile(const psFileName: string; const pbMustExist: boolean);
var
lsText: string;
lcFile: TSettingsInputString;
begin
if {$ifdef FPC}FileExistsUTF8(psFileName){$else}FileExists(psFileName){$endif} then
begin
// debug ShowMessage('Reading settings from file ' + lsSettingsFileName);
// now we know the file exists - try get settings from it
{$ifdef FPC}
lsText := string(FileToString(UTF8ToSys(psFileName)));
{$else}
lsText := string(FileToString(psFileName));
{$endif}
lcFile := TSettingsInputString.Create(lsText);
try
FromStream(lcFile);
finally
lcFile.Free;
end;
end
else
begin
if pbMustExist then
begin
//MessageDlg(Format(lisTheSettingsFileDoesNotExist, [psFileName, NativeLineBreak]), mtError, [mbOK], 0);
writeln(Format(lisTheSettingsFileDoesNotExist, [psFileName, NativeLineBreak]));
end;
end;
end;
procedure TFormatSettings.ReadDefaults;
var
lcSetDummy: TSettingsInputDummy;
begin
lcSetDummy := TSettingsInputDummy.Create;
try
FromStream(lcSetDummy);
finally
lcSetDummy.Free;
end;
end;
procedure TFormatSettings.Write;
var
lcReg: TJCFRegistrySettings;
lcFile: TSettingsStreamOutput;
begin
if not Dirty then
exit;
{ user may have specified no-write }
lcReg := GetRegSettings;
if lcReg.FormatFileWriteOption = eNeverWrite then
exit;
if lcReg.FormatConfigFileName = '' then
exit;
{$ifdef FPC}
if FileExistsUTF8(lcReg.FormatConfigFileName) and FileIsReadOnlyUTF8(lcReg.FormatConfigFileName) then
{$else}
if FileExists(lcReg.FormatConfigFileName) and FileIsReadOnly(lcReg.FormatConfigFileName) then
{$endif}
begin
{ fail quietly? }
if lcReg.FormatFileWriteOption = eAlwaysWrite then
//MessageDlg(Format(lisErrorWritingSettingsFileReadOnly, [lcReg.FormatConfigFileName]), mtError, [mbOK], 0);
writeln(Format(lisErrorWritingSettingsFileReadOnly, [lcReg.FormatConfigFileName]));
exit;
end;
try
// use the Settings file name
{$ifdef FPC}
lcFile := TSettingsStreamOutput.Create(UTF8ToSys(GetRegSettings.FormatConfigFileName));
{$else}
lcFile := TSettingsStreamOutput.Create(GetRegSettings.FormatConfigFileName);
{$endif}
try
ToStream(lcFile);
// not dirty any more
fbDirty := False;
finally
lcFile.Free;
end;
except
on e: Exception do
begin
if lcReg.FormatFileWriteOption = eAlwaysWrite then
begin
//MessageDlg(Format(lisErrorWritingSettingsException, [GetRegSettings.FormatConfigFileName, NativeLineBreak, E.Message]), mtError, [mbOK], 0);
writeln(Format(lisErrorWritingSettingsException, [GetRegSettings.FormatConfigFileName, NativeLineBreak, E.Message]));
end;
end;
end;
end;
procedure TFormatSettings.ToStream(const pcStream: TSettingsOutput);
procedure WriteToStream(const pcSet: TSetBase);
begin
Assert(pcSet <> nil);
pcStream.OpenSection(pcSet.Section);
pcSet.WriteToStream(pcStream);
pcStream.CloseSection(pcSet.Section);
end;
begin
Assert(pcStream <> nil);
pcStream.WriteXMLHeader;
pcStream.OpenSection(CODEFORMAT_SETTINGS_SECTION);
pcStream.Write(REG_VERSION, PROGRAM_VERSION);
pcStream.Write(REG_WRITE_DATETIME, Now);
pcStream.Write(REG_DESCRIPTION, Description);
WriteToStream(fcObfuscate);
WriteToStream(fcClarify);
WriteToStream(fcIndent);
WriteToStream(fcSpaces);
WriteToStream(fcReturns);
WriteToStream(fcComments);
WriteToStream(fcCaps);
WriteToStream(fcSpecificWordCaps);
WriteToStream(fcIdentifierCaps);
WriteToStream(fcNotIdentifierCaps);
WriteToStream(fcUnitNameCaps);
WriteToStream(fcSetAsm);
WriteToStream(fcPreProcessor);
WriteToStream(fcAlign);
WriteToStream(fcReplace);
WriteToStream(fcUses);
WriteToStream(fcTransform);
pcStream.CloseSection(CODEFORMAT_SETTINGS_SECTION);
end;
procedure TFormatSettings.FromStream(const pcStream: TSettingsInput);
var
lcAllSettings: TSettingsInput;
procedure ReadFromStream(const pcSet: TSetBase);
var
lcSection: TSettingsInput;
begin
Assert(pcSet <> nil);
lcSection := lcAllSettings.ExtractSection(pcSet.Section);
if lcSection <> nil then
begin
pcSet.ReadFromStream(lcSection);
lcSection.Free;
end
else
begin
lcSection := TSettingsInputDummy.Create;
try
pcSet.ReadFromStream(lcSection);
finally
lcSection.Free;
end;
//ShowMessage('Skipping section ' + pcSet.Section + ' as it was not found');
end;
end;
begin
{ basic test - we are only interested in the
<JediCodeFormaTFormatSettings> ... </JediCodeFormaTFormatSettings> part of the file
If this start & end is not present, then is is the wrong file }
lcAllSettings := pcStream.ExtractSection(CODEFORMAT_SETTINGS_SECTION);
if lcAllSettings = nil then
begin
//ShowMessage(lisNoSettingsFound);
writeln(lisNoSettingsFound);
exit;
end;
try
fsWriteVersion := pcStream.Read(REG_VERSION, '');
fsDescription := pcStream.Read(REG_DESCRIPTION, '');
fdtWriteDateTime := pcStream.Read(REG_WRITE_DATETIME, 0.0);
ReadFromStream(fcObfuscate);
ReadFromStream(fcClarify);
ReadFromStream(fcIndent);
ReadFromStream(fcSpaces);
ReadFromStream(fcReturns);
ReadFromStream(fcComments);
ReadFromStream(fcCaps);
ReadFromStream(fcSpecificWordCaps);
ReadFromStream(fcIdentifierCaps);
ReadFromStream(fcNotIdentifierCaps);
ReadFromStream(fcUnitNameCaps);
ReadFromStream(fcSetAsm);
ReadFromStream(fcPreProcessor);
ReadFromStream(fcAlign);
ReadFromStream(fcReplace);
ReadFromStream(fcUses);
ReadFromStream(fcTransform);
fbHasRead := True;
finally
lcAllSettings.Free;
end;
end;
var
// a module var
mcFormatSettings: TFormatSettings = nil;
function FormattingSettings: TFormatSettings;
begin
if mcFormatSettings = nil then
mcFormatSettings := TFormatSettings.Create(true);
Result := mcFormatSettings;
end;
function FormatSettingsFromFile(const psFileName: string): TFormatSettings;
begin
if mcFormatSettings = nil then
mcFormatSettings := TFormatSettings.Create(false);
mcFormatSettings.ReadFromFile(psFileName, true);
Result := mcFormatSettings;
end;
procedure TFormatSettings.MakeConsistent;
begin
{ one consistency check so far
- if linebreaking is off, then "remove returns in expressions" must also be off }
if Returns.RebreakLines = rbOff then
Returns.RemoveExpressionReturns := False;
end;
initialization
//JCFOptionsGroup := GetFreeIDEOptionsGroupIndex(GroupEditor);
//RegisterIDEOptionsGroup(JCFOptionsGroup, TFormatSettings);
finalization
FreeAndNil(mcFormatSettings);
end.

View File

@ -34,7 +34,7 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="31">
<Units Count="97">
<Unit0>
<Filename Value="TestJCF.lpr"/>
<IsPartOfProject Value="True"/>
@ -147,26 +147,290 @@
<IsPartOfProject Value="True"/>
</Unit25>
<Unit26>
<Filename Value="JcfSettings.pas"/>
<Filename Value="..\Include\JcfGlobal.inc"/>
<IsPartOfProject Value="True"/>
</Unit26>
<Unit27>
<Filename Value="..\Include\JcfGlobal.inc"/>
<Filename Value="..\Settings\Streams\SettingsStream.pas"/>
<IsPartOfProject Value="True"/>
</Unit27>
<Unit28>
<Filename Value="..\Settings\Streams\SettingsStream.pas"/>
<Filename Value="..\JcfVersionConsts.pas"/>
<IsPartOfProject Value="True"/>
</Unit28>
<Unit29>
<Filename Value="..\JcfVersionConsts.pas"/>
<IsPartOfProject Value="True"/>
</Unit29>
<Unit30>
<Filename Value="..\Ui\jcfuitools.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="JcfUiTools"/>
</Unit29>
<Unit30>
<Filename Value="..\Settings\JcfSettings.pas"/>
<IsPartOfProject Value="True"/>
</Unit30>
<Unit31>
<Filename Value="..\Process\Returns\NoReturnBefore.pas"/>
<IsPartOfProject Value="True"/>
</Unit31>
<Unit32>
<Filename Value="..\Process\Returns\ReturnAfter.pas"/>
<IsPartOfProject Value="True"/>
</Unit32>
<Unit33>
<Filename Value="..\Process\Spacing\SingleSpaceBefore.pas"/>
<IsPartOfProject Value="True"/>
</Unit33>
<Unit34>
<Filename Value="..\Process\Spacing\SingleSpaceAfter.pas"/>
<IsPartOfProject Value="True"/>
</Unit34>
<Unit35>
<Filename Value="..\Process\Spacing\NoSpaceAfter.pas"/>
<IsPartOfProject Value="True"/>
</Unit35>
<Unit36>
<Filename Value="..\Process\Spacing\NoSpaceBefore.pas"/>
<IsPartOfProject Value="True"/>
</Unit36>
<Unit37>
<Filename Value="..\Process\Returns\LongLineBreaker.pas"/>
<IsPartOfProject Value="True"/>
</Unit37>
<Unit38>
<Filename Value="..\Process\Returns\NoReturnAfter.pas"/>
<IsPartOfProject Value="True"/>
</Unit38>
<Unit39>
<Filename Value="..\Process\Returns\RemoveReturnsBeforeEnd.pas"/>
<IsPartOfProject Value="True"/>
</Unit39>
<Unit40>
<Filename Value="..\Process\Returns\PropertyOnOneLine.pas"/>
<IsPartOfProject Value="True"/>
</Unit40>
<Unit41>
<Filename Value="..\Process\SwitchableVisitor.pas"/>
<IsPartOfProject Value="True"/>
</Unit41>
<Unit42>
<Filename Value="..\Process\TreeWalker.pas"/>
<IsPartOfProject Value="True"/>
</Unit42>
<Unit43>
<Filename Value="..\Process\Returns\RemoveConsecutiveReturns.pas"/>
<IsPartOfProject Value="True"/>
</Unit43>
<Unit44>
<Filename Value="..\Process\Spacing\MaxSpaces.pas"/>
<IsPartOfProject Value="True"/>
</Unit44>
<Unit45>
<Filename Value="..\Process\Spacing\SpaceToTab.pas"/>
<IsPartOfProject Value="True"/>
</Unit45>
<Unit46>
<Filename Value="..\Process\Spacing\TabToSpace.pas"/>
<IsPartOfProject Value="True"/>
</Unit46>
<Unit47>
<Filename Value="..\Process\Spacing\SpaceBeforeColon.pas"/>
<IsPartOfProject Value="True"/>
</Unit47>
<Unit48>
<Filename Value="..\Process\Spacing\RemoveSpaceAtLineEnd.pas"/>
<IsPartOfProject Value="True"/>
</Unit48>
<Unit49>
<Filename Value="..\Process\Returns\BlockStyles.pas"/>
<IsPartOfProject Value="True"/>
</Unit49>
<Unit50>
<Filename Value="..\Process\Returns\RemoveBlankLinesAfterProcHeader.pas"/>
<IsPartOfProject Value="True"/>
</Unit50>
<Unit51>
<Filename Value="..\Process\Returns\RemoveBlankLinesInVars.pas"/>
<IsPartOfProject Value="True"/>
</Unit51>
<Unit52>
<Filename Value="..\Process\Returns\RemoveReturnsAfter.pas"/>
<IsPartOfProject Value="True"/>
</Unit52>
<Unit53>
<Filename Value="..\Process\Returns\RemoveReturnsAfterBegin.pas"/>
<IsPartOfProject Value="True"/>
</Unit53>
<Unit54>
<Filename Value="..\Process\Returns\ReturnChars.pas"/>
<IsPartOfProject Value="True"/>
</Unit54>
<Unit55>
<Filename Value="..\Process\Returns\ReturnsAfterFinalEnd.pas"/>
<IsPartOfProject Value="True"/>
</Unit55>
<Unit56>
<Filename Value="..\Process\Indent\IndentAsmParam.pas"/>
<IsPartOfProject Value="True"/>
</Unit56>
<Unit57>
<Filename Value="..\Process\Align\AlignAssign.pas"/>
<IsPartOfProject Value="True"/>
</Unit57>
<Unit58>
<Filename Value="..\Process\Align\AlignComment.pas"/>
<IsPartOfProject Value="True"/>
</Unit58>
<Unit59>
<Filename Value="..\Process\Align\AlignConst.pas"/>
<IsPartOfProject Value="True"/>
</Unit59>
<Unit60>
<Filename Value="..\Process\Align\AlignField.pas"/>
<IsPartOfProject Value="True"/>
</Unit60>
<Unit61>
<Filename Value="..\Process\Align\AlignTypedef.pas"/>
<IsPartOfProject Value="True"/>
</Unit61>
<Unit62>
<Filename Value="..\Process\Align\AlignVars.pas"/>
<IsPartOfProject Value="True"/>
</Unit62>
<Unit63>
<Filename Value="..\Process\Capitalisation\Capitalisation.pas"/>
<IsPartOfProject Value="True"/>
</Unit63>
<Unit64>
<Filename Value="..\Process\Capitalisation\IdentifierCaps.pas"/>
<IsPartOfProject Value="True"/>
</Unit64>
<Unit65>
<Filename Value="..\Process\Capitalisation\SpecificWordCaps.pas"/>
<IsPartOfProject Value="True"/>
</Unit65>
<Unit66>
<Filename Value="..\Process\Transform\AddBeginEnd.pas"/>
<IsPartOfProject Value="True"/>
</Unit66>
<Unit67>
<Filename Value="..\Process\Transform\AddBlockEndSemicolon.pas"/>
<IsPartOfProject Value="True"/>
</Unit67>
<Unit68>
<Filename Value="..\Process\Transform\FindReplace.pas"/>
<IsPartOfProject Value="True"/>
</Unit68>
<Unit69>
<Filename Value="..\Process\Transform\SortUses.pas"/>
<IsPartOfProject Value="True"/>
</Unit69>
<Unit70>
<Filename Value="..\Process\Transform\SortUsesData.pas"/>
<IsPartOfProject Value="True"/>
</Unit70>
<Unit71>
<Filename Value="..\Process\Transform\UsesClauseFindReplace.pas"/>
<IsPartOfProject Value="True"/>
</Unit71>
<Unit72>
<Filename Value="..\Process\Transform\UsesClauseRemove.pas"/>
<IsPartOfProject Value="True"/>
</Unit72>
<Unit73>
<Filename Value="..\Process\Obfuscate\RebreakLines.pas"/>
<IsPartOfProject Value="True"/>
</Unit73>
<Unit74>
<Filename Value="..\Process\Obfuscate\ReduceWhiteSpace.pas"/>
<IsPartOfProject Value="True"/>
</Unit74>
<Unit75>
<Filename Value="..\Process\Obfuscate\RemoveBlankLine.pas"/>
<IsPartOfProject Value="True"/>
</Unit75>
<Unit76>
<Filename Value="..\Process\Obfuscate\RemoveComment.pas"/>
<IsPartOfProject Value="True"/>
</Unit76>
<Unit77>
<Filename Value="..\Process\Obfuscate\RemoveConsecutiveWhiteSpace.pas"/>
<IsPartOfProject Value="True"/>
</Unit77>
<Unit78>
<Filename Value="..\Process\Obfuscate\RemoveReturn.pas"/>
<IsPartOfProject Value="True"/>
</Unit78>
<Unit79>
<Filename Value="..\Process\Obfuscate\RemoveUnneededWhiteSpace.pas"/>
<IsPartOfProject Value="True"/>
</Unit79>
<Unit80>
<Filename Value="..\Process\Warnings\WarnAssignToFunctionName.pas"/>
<IsPartOfProject Value="True"/>
</Unit80>
<Unit81>
<Filename Value="..\Process\Warnings\WarnCaseNoElse.pas"/>
<IsPartOfProject Value="True"/>
</Unit81>
<Unit82>
<Filename Value="..\Process\Warnings\WarnDestroy.pas"/>
<IsPartOfProject Value="True"/>
</Unit82>
<Unit83>
<Filename Value="..\Process\Warnings\WarnEmptyBlock.pas"/>
<IsPartOfProject Value="True"/>
</Unit83>
<Unit84>
<Filename Value="..\Process\Warnings\WarnImbalancedComment.pas"/>
<IsPartOfProject Value="True"/>
</Unit84>
<Unit85>
<Filename Value="..\Process\Warnings\WarnRealType.pas"/>
<IsPartOfProject Value="True"/>
</Unit85>
<Unit86>
<Filename Value="..\Process\Warnings\WarnUnusedParam.pas"/>
<IsPartOfProject Value="True"/>
</Unit86>
<Unit87>
<Filename Value="..\Process\AllProcesses.pas"/>
<IsPartOfProject Value="True"/>
</Unit87>
<Unit88>
<Filename Value="..\Process\BaseVisitor.pas"/>
<IsPartOfProject Value="True"/>
</Unit88>
<Unit89>
<Filename Value="..\Process\Nesting.pas"/>
<IsPartOfProject Value="True"/>
</Unit89>
<Unit90>
<Filename Value="..\Process\RemoveEmptyComment.pas"/>
<IsPartOfProject Value="True"/>
</Unit90>
<Unit91>
<Filename Value="..\Process\VisitSetNesting.pas"/>
<IsPartOfProject Value="True"/>
</Unit91>
<Unit92>
<Filename Value="..\Process\VisitSetXY.pas"/>
<IsPartOfProject Value="True"/>
</Unit92>
<Unit93>
<Filename Value="..\Process\VisitStripEmptySpace.pas"/>
<IsPartOfProject Value="True"/>
</Unit93>
<Unit94>
<Filename Value="..\Parse\PreProcessor\PreProcessorExpressionParser.pas"/>
<IsPartOfProject Value="True"/>
</Unit94>
<Unit95>
<Filename Value="..\Parse\PreProcessor\PreProcessorExpressionTokenise.pas"/>
<IsPartOfProject Value="True"/>
</Unit95>
<Unit96>
<Filename Value="..\Parse\PreProcessor\PreProcessorExpressionTokens.pas"/>
<IsPartOfProject Value="True"/>
</Unit96>
</Units>
</ProjectOptions>
<CompilerOptions>
@ -177,7 +441,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);..\Include"/>
<OtherUnitFiles Value="..\Parse;..\Utils;..\Settings;..\Process;..\Process\Returns;..\Process\Spacing;..\ReadWrite;..\Process\Indent;..\Process\Obfuscate;..\Process\Transform;..\Process\Warnings;..\Process\Capitalisation;..\Process\Info;..\Process\Align;..\Parse\UI;..\Parse\PreProcessor;..\Include;..\Settings\Streams;..;..\Ui"/>
<OtherUnitFiles Value="..\Parse;..\Utils;..\Settings;..\Process;..\Process\Returns;..\Process\Spacing;..\ReadWrite;..\Process\Indent;..\Process\Obfuscate;..\Process\Transform;..\Process\Warnings;..\Process\Capitalisation;..\Process\Info;..\Process\Align;..\Parse\UI;..\Parse\PreProcessor;..\Include;..\Settings\Streams;..;..\Ui;..\IdePlugin\lazarus"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>

View File

@ -6,21 +6,33 @@ uses {$IFDEF UNIX}
cthreads, {$ENDIF} {$IFDEF HASAMIGA}
athreads, {$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms,
unit1,
BuildParseTree,
fShowParseTree,
Converter, JcfUiTools, SettingsStream,
ReturnBefore,
MoveSpaceToBeforeColon,
Indenter,
SysUtils;
Forms, unit1, JcfSettings, BuildParseTree, PreProcessorExpressionParser,
PreProcessorExpressionTokenise, PreProcessorExpressionTokens,
PreProcessorParseTree, fShowParseTree, Converter, JcfUiTools, JcfStringUtils,
SettingsStream, ReturnAfter, NoReturnBefore, RemoveReturnsBeforeEnd,
PropertyOnOneLine, NoReturnAfter, LongLineBreaker, BlockStyles,
RemoveBlankLinesAfterProcHeader, RemoveBlankLinesInVars,
RemoveConsecutiveReturns, RemoveReturnsAfter, RemoveReturnsAfterBegin,
ReturnBefore, ReturnChars, ReturnsAfterFinalEnd, SingleSpaceBefore,
NoSpaceAfter, NoSpaceBefore, MaxSpaces, SingleSpaceAfter, SpaceToTab,
TabToSpace, MoveSpaceToBeforeColon, SpaceBeforeColon, RemoveSpaceAtLineEnd,
IndentAsmParam, Indenter, AlignAssign, AlignBase, AlignComment, AlignConst,
AlignField, AlignTypedef, AlignVars, Capitalisation, IdentifierCaps,
SpecificWordCaps, UnitNameCaps, AddBeginEnd, AddBlockEndSemicolon,
FindReplace, SortUses, SortUsesData, UsesClauseFindReplace, UsesClauseInsert,
UsesClauseRemove, BasicStats, FixCase, RebreakLines, ReduceWhiteSpace,
RemoveBlankLine, RemoveComment, RemoveConsecutiveWhiteSpace, RemoveReturn,
RemoveUnneededWhiteSpace, WarnAssignToFunctionName, WarnCaseNoElse,
WarnDestroy, WarnEmptyBlock, WarnImbalancedComment, Warning, WarnRealType,
WarnUnusedParam, AllProcesses, BaseVisitor, FormatFlags, Nesting,
RemoveEmptyComment, SwitchableVisitor, TreeWalker, VisitSetNesting,
VisitSetXY, VisitStripEmptySpace, SysUtils;
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Scaled := True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;

View File

@ -59,11 +59,8 @@ implementation
uses
JcfStringUtils in '..\..\Utils\JcfStringUtils.pas',
//JcfFileUtils in '..\..\Utils\JcfFileUtils.pas',
JcfSystemUtils in '..\..\Utils\JcfSystemUtils.pas',
Converter in '..\..\ReadWrite\Converter.pas',
FileConverter in '..\..\ReadWrite\FileConverter.pas',
// ConvertTypes in '..\..\ReadWrite\ConvertTypes.pas',
BuildParseTree in '..\..\Parse\BuildParseTree.pas',
BuildTokenList in '..\..\Parse\BuildTokenList.pas',
ParseError in '..\..\Parse\ParseError.pas',
@ -74,12 +71,10 @@ uses
VisitSetXY in '..\..\Process\VisitSetXY.pas',
BaseVisitor in '..\..\Process\BaseVisitor.pas',
JcfMiscFunctions in '..\..\Utils\JcfMiscFunctions.pas',
//FileUtils in '..\..\Utils\FileUtils.pas',
JcfLog in '..\..\Utils\JcfLog.pas',
//fShowParseTree in '..\..\Parse\UI\fShowParseTree.pas' {frmShowParseTree},
SetUses in '..\..\Settings\SetUses.pas',
JcfSetBase in '..\..\Settings\JcfSetBase.pas',
JcfSettings,
JcfSettings in '..\..\Settings\JcfSettings.pas',
SetAlign in '..\..\Settings\SetAlign.pas',
SetCaps in '..\..\Settings\SetCaps.pas',
SetClarify in '..\..\Settings\SetClarify.pas',
@ -155,7 +150,6 @@ uses
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',
@ -174,7 +168,6 @@ 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',

View File

@ -7,8 +7,7 @@ object ExceptionDialog: TExceptionDialog
Caption = 'JCF Exception'
ClientHeight = 180
ClientWidth = 420
OnCreate = FormCreate
LCLVersion = '1.9.0.0'
LCLVersion = '2.3.0.0'
object mExceptionMessage: TMemo
Left = 6
Height = 133

View File

@ -43,7 +43,6 @@ type
TExceptionDialog = class(TForm)
BtnPanel: TButtonPanel;
mExceptionMessage: TMemo;
procedure FormCreate(Sender: TObject);
private
public
procedure DisplayException(const pE: Exception);
@ -59,7 +58,7 @@ implementation
uses
{ local }
ParseError, JcfStringUtils, JcfFontSetFunctions, JcfUIConsts;
ParseError, JcfStringUtils, JcfUIConsts;
{$R *.lfm}
@ -140,9 +139,4 @@ begin
ShowModal;
end;
procedure TExceptionDialog.FormCreate(Sender: TObject);
begin
SetObjectFontToSystemFont(Self);
end;
end.

View File

@ -57,10 +57,6 @@ procedure RestoreCursorUI;
begin
end;
procedure ShowParseTreeUI;
begin
end;
procedure ShowParseTreeUI(const pcRoot: TParseTreeNode);
begin
end;

View File

@ -1,98 +0,0 @@
unit JcfFontSetFunctions;
{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
The Original Code is JcfFontSetFunctions, released May 2007.
The Initial Developer of the Original Code is Jean-Fabien Connault.
Portions created by Jean-Fabien Connault are Copyright (C) 1999-2008 Jean-Fabien Connault.
All Rights Reserved.
Contributor(s):
SetObjectFontToSystemFont by Jean-Fabien Connault
Integrated to JCF by Anthony Steele
The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"). you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and limitations
under the License.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 or later (the "GPL")
See http://www.gnu.org/licenses/gpl.html
------------------------------------------------------------------------------*)
{*)}
{$I JcfGlobal.inc}
interface
uses
TypInfo,
Graphics;
type
TFontType = (ftAuto, ftCaption, ftContent);
procedure SetObjectFontToSystemFont(
const AObject: TObject; const FontType: TFontType = ftAuto);
implementation
uses
JcfSystemUtils;
procedure SetCaptionFont(const AObjectFont: TFont);
begin
if IsWinVista or IsWinServer2008 or IsWin7 or IsWinServer2008R2 then
begin
AObjectFont.Name := 'Segoe UI';
AObjectFont.Size := 9;
end
else if IsWinXP or IsWin2k or IsWin2003 then
begin
// MS Shell Dlg 2
AObjectFont.Name := 'Tahoma';
AObjectFont.Size := 8;
end
else
begin
// MS Shell Dlg
AObjectFont.Name := 'default';
AObjectFont.Size := 10;
end;
end;
procedure SetContentFont(const AObjectFont: TFont);
begin
if IsWinVista or IsWinServer2008 or IsWin7 or IsWinServer2008R2 then
begin
AObjectFont.Name := 'Calibri';
AObjectFont.Size := 9;
end
else if IsWinXP or IsWin2k or IsWin2003 then
begin
// MS Shell Dlg 2
AObjectFont.Name := 'Verdana';
AObjectFont.Size := 8;
end
else
begin
// MS Shell Dlg
AObjectFont.Name := 'default';
AObjectFont.Size := 10;
end;
end;
procedure SetObjectFontToSystemFont(const AObject: TObject; const FontType: TFontType);
begin
exit; // Lazarus forms have "default" font set
end;
end.

View File

@ -1,144 +0,0 @@
unit JcfSystemUtils;
{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
The Original Code is JcfSystemUtils, released Jan 2009
The Initial Developer of the Original Code is Paul Ishenin
Portions created by Paul Ishenin are Copyright (C) 1999-2008 Paul Ishenin
All Rights Reserved.
Contributor(s): Anthony Steele.
The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"). you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and limitations
under the License.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 or later (the "GPL")
See http://www.gnu.org/licenses/gpl.html
------------------------------------------------------------------------------*)
{*)}
{$I JcfGlobal.inc}
{
This unit contains OS and File utility code
For use when the JCL functions are not available
}
interface
uses
SysUtils, Classes;
function GetWindowsTempFolder: string;
function IsMultiByte(const {%H-}pcChar: Char): Boolean;
function IsWinServer2008R2: Boolean;
function IsWin7: Boolean;
function IsWinServer2008: Boolean;
function IsWinVista: Boolean;
function IsWinXP: Boolean;
function IsWin2k: Boolean;
function IsWin2003: Boolean;
implementation
// We know that this unit contains platform-specific code guarded by ifdefs
{$WARN SYMBOL_PLATFORM OFF}
uses
{$ifdef MSWINDOWS}
Windows
{$endif}
{$ifdef Unix}
Unix
{$endif}
,FileUtil;
function GetWindowsTempFolder: string;
begin
Result := GetTempDir;
end;
function IsMultiByte(const pcChar: Char): Boolean;
begin
//Result := IsDBCSLeadByte(Byte(pcChar));
Result := False;
end;
function IsWinServer2008R2: Boolean;
begin
{$IFDEF MSWINDOWS}
Result := (Win32MajorVersion = 6) and (Win32MinorVersion = 1);
// Should also make sure it's a server (see JclSysInfo)
{$ELSE}
Result := False;
{$ENDIF}
end;
function IsWin7: Boolean;
begin
{$IFDEF MSWINDOWS}
Result := (Win32MajorVersion = 6) and (Win32MinorVersion = 1);
// Should also make sure it's a workstation (see JclSysInfo)
{$ELSE}
Result := False;
{$ENDIF}
end;
function IsWinServer2008: Boolean;
begin
{$IFDEF MSWINDOWS}
Result := (Win32MajorVersion = 6) and (Win32MinorVersion = 0);
// Should also make sure it's a server (see JclSysInfo)
{$ELSE}
Result := False;
{$ENDIF}
end;
function IsWinVista: Boolean;
begin
{$IFDEF MSWINDOWS}
Result := (Win32MajorVersion = 6) and (Win32MinorVersion = 0);
// Should also make sure it's a workstation (see JclSysInfo)
{$ELSE}
Result := False;
{$ENDIF}
end;
function IsWinXP: Boolean;
begin
{$IFDEF MSWINDOWS}
Result := (Win32MajorVersion = 5) and (Win32MinorVersion = 1);
{$ELSE}
Result := False;
{$ENDIF}
end;
function IsWin2k: Boolean;
begin
{$IFDEF MSWINDOWS}
Result := (Win32MajorVersion = 5) and (Win32MinorVersion = 0);
{$ELSE}
Result := False;
{$ENDIF}
end;
function IsWin2003: Boolean;
begin
{$IFDEF MSWINDOWS}
Result := (Win32MajorVersion = 5) and (Win32MinorVersion = 2);
// can be also window xp 64 bit
{$ELSE}
Result := False;
{$ENDIF}
end;
end.