Skip to content

Commit

Permalink
Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
quadroid committed Nov 6, 2022
0 parents commit 749937a
Show file tree
Hide file tree
Showing 240 changed files with 135,241 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
test.fmt.pas
__history/
__recovery/
backup/
release/
debug/
*.res
*.bak
*.exe
*.dcu
*.ppu
*.o
100 changes: 100 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{ // shortcut: cmd+shift+B (run build task)
"label" : "pascal-format: Build Release",
"type" : "shell",
"group" : {
"kind" : "build",
"isDefault": true,
},
"options": {
"cwd" : "App",
},
"command": "fpc",
"args" : [
"pascal_format.dpr", // source code file
"-Px86_64", // target platform 64-bit
"-Mobjfpc", // object pascal mode
"-Schi", // pascal syntax setting
"-CX", // generated code setting
"-O3", // code optimization setting
"-XXs", // executable setting
"-B", // always build all
"-v", // verbose message
"-Fi../Include", // include file path
"-Fu../lazutils", // unit file path
"-FU../Output", // unit output path
"-FE..", // executable output path
],
"problemMatcher": []
},
{ // shortcut: cmd+shift+R (run test task)
"label": "pascal-format: Test CLI Program",
"type" : "shell",
"group": {
"kind" : "test",
"isDefault": true,
},
"command": "pascal_format",
"args" : [
"test.pas",
"-clarify",
"-inplace",
"-config=pascal-format.cfg"
],
"presentation": {
// open test.pas file to see the result
"reveal": "never"
},
"problemMatcher": []
},
{ // shortcut: none
"label" : "pascal-format: Clean Files",
"type" : "shell",
"command": "rm",
"options": {
"cwd" : "Output",
},
"args" : [
//"pascal_format", // executable file
"*.a", // generated linker file
"*.o", // generated object file
"*.s", // generated assembler file
"*.out", // generated formatted code
"*.ppu", // generated unit file
"*.res", // generated resource file
"*.rsj", // generated resource file
"*.sh", // generated script code
],
"problemMatcher": []
},
{ // shortcut: none
"label" : "pascal-format: Open CLI Project",
"type" : "shell",
"command": "code",
"args" : [
"App/pascal_format.lpi",
],
"presentation": {
"reveal" : "never"
},
"problemMatcher": []
},
{ // shortcut: none
"label" : "pascal-format: Deploy Executable",
"type" : "shell",
"command": "mv",
"args" : [
"pascal_format",
"~/Documents/pascal/pascal-format",
],
"presentation": {
"reveal" : "silent"
},
"problemMatcher": []
},
],
}
68 changes: 68 additions & 0 deletions App/CommandLineConstants.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
unit CommandLineConstants;

{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
The Original Code is CommandLineConstants, released August 2008.
The Initial Developer of the Original Code is Anthony Steele.
Portions created by Anthony Steele are Copyright (C) 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
------------------------------------------------------------------------------*)
{*)}

{$I JcfGlobal.inc}

interface

uses
JcfStringUtils,
JcfVersionConsts;

const
ABOUT_COMMANDLINE =
'Pascal Code Format ' + PROGRAM_VERSION + NativeLineBreak +
NativeLineBreak +
'Object-Pascal source code formatter.' + NativeLineBreak +
'Latest version at ' + PROGRAM_HOME_PAGE + NativeLineBreak +
NativeLineBreak +
'Usage: pascal-format [options] directory/file' + NativeLineBreak +
NativeLineBreak +
'Mode of operation:' + NativeLineBreak +
' -obfuscate: obfuscate mode or' + NativeLineBreak +
' -clarify: clarify mode.' + NativeLineBreak +
' Default: clarify.' + NativeLineBreak +
NativeLineBreak +
'Mode of source:' + NativeLineBreak +
' -f Format a file: the file path must be specified.' + NativeLineBreak +
' -d Format a directory: the directory path must be specified.' + NativeLineBreak +
' -r Format a directory tree.' + NativeLineBreak +
NativeLineBreak +
'Mode of output:' + NativeLineBreak +
' -inplace: change the source file without backup.' + NativeLineBreak +
' -out: output to a separate file.' + NativeLineBreak +
' -backup: change the source file and leave a backup copy.' + NativeLineBreak +
' Default: inplace.' + NativeLineBreak +
NativeLineBreak +
'Other options:' + NativeLineBreak +
' -config=<path>: specify a configuration file.' + NativeLineBreak +
' -y: overwrite files without confirmation.' + NativeLineBreak +
' -?: display this help.';

implementation

end.
65 changes: 65 additions & 0 deletions App/CommandLineReturnCode.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
unit CommandLineReturnCode;

{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
The Original Code is CommandLineReturnCode, released August 2008.
The Initial Developer of the Original Code is Anthony Steele.
Portions created by Anthony Steele are Copyright (C) 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
------------------------------------------------------------------------------*)
{*)}

{$I JcfGlobal.inc}

interface

{
command line return code
0 for sucess
non-sero for failure codes
}
type
TJcfCommandLineReturnCode =
(
rcSuccess = 0,
rcGeneralFailure = 1,
rcNoPathFound = 2,
rcConfigFileNotFound = 3,
rcSettingsNotRead = 4,
rcFileNotFound = 5,
rcDirectoryNotFound = 6,
rcConvertError = 7
);

procedure HaltOnError(const returnCode: TJcfCommandLineReturnCode);

implementation

procedure HaltOnError(const returnCode: TJcfCommandLineReturnCode);
var
liCode: integer;
begin
liCode := Ord(returnCode);

if liCode > 0 then
Halt(liCode);

end;

end.
4 changes: 4 additions & 0 deletions App/Dummy.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
unit Dummy;
interface
implementation
end.
40 changes: 40 additions & 0 deletions App/JcfVersionConsts.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
unit JcfVersionConsts;

{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
The Original Code is JcfVersionConsts, released May 2003.
The Initial Developer of the Original Code is Anthony Steele.
Portions created by Anthony Steele are Copyright (C) 2003-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
------------------------------------------------------------------------------*)
{*)}

{$I JcfGlobal.inc}

interface

const
PROGRAM_VERSION = '2.45';
PROGRAM_HOME_PAGE = 'https://github.com/quadroid/pascal-format';
PROGRAM_SOURCEFORGE_HOME_PAGE = 'https://github.com/quadroid/pascal-format';
PROGRAM_SVN_TRUNK = 'https://github.com/quadroid/pascal-format.git';

implementation

end.
74 changes: 74 additions & 0 deletions App/StatusMessageReceiver.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
unit StatusMessageReceiver;

{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
The Original Code is StatusMessageReceiver, released August 2008.
The Initial Developer of the Original Code is Anthony Steele.
Portions created by Anthony Steele are Copyright (C) 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
------------------------------------------------------------------------------*)
{*)}

{$I JcfGlobal.inc}

interface

uses
ConvertTypes;

type
TStatusMesssageReceiver = class(TObject)
public
procedure OnReceiveStatusMessage(const psFile, psMessage: string;
const peMessageType: TStatusMessageType;
const piY, piX: integer);
end;

implementation

uses
SysUtils;

procedure TStatusMesssageReceiver.OnReceiveStatusMessage(const psFile, psMessage: string;
const peMessageType: TStatusMessageType;
const piY, piX: integer);
var
lsPrefix: string;
lsMessage: string;
begin
case peMessageType of
mtException, mtInputError, mtParseError:
lsPrefix := 'Error';
mtCodeWarning:
lsPrefix := 'Warning';
else
lsPrefix := 'Info';
end;

if (piX < 0) or (piY < 0) then
lsMessage := Format('[%s] %s: %s', [lsPrefix, psFile, psMessage]) // format with no line and col
else
lsMessage := Format('[%s] %s: (%s:%s) %s',
[lsPrefix, psFile, IntToStr(piY), IntToStr(piX), psMessage]) // format with a line and col
;

WriteLn(lsMessage);
end;

end.
Loading

0 comments on commit 749937a

Please sign in to comment.