Subversion Repositories fastphp

Compare Revisions

Regard whitespace Rev 48 → Rev 49

/trunk/EditorMain.dfm
1,7 → 1,7
object Form1: TForm1
Left = 0
Top = 0
Caption = 'ViaThinkSoft FastPHP'
Caption = 'ViaThinkSoft FastPHP 0.1'
ClientHeight = 661
ClientWidth = 1120
Color = clBtnFace
124,7 → 124,7
Gutter.Gradient = True
Gutter.GradientStartColor = cl3DLight
Highlighter = SynPHPSyn1
Options = [eoAutoIndent, eoDragDropEditing, eoEnhanceHomeKey, eoEnhanceEndKey, eoGroupUndo, eoHideShowScrollbars, eoScrollByOneLess, eoShowScrollHint, eoTabIndent, eoTrimTrailingSpaces]
Options = [eoAutoIndent, eoDragDropEditing, eoEnhanceHomeKey, eoEnhanceEndKey, eoGroupUndo, eoHideShowScrollbars, eoKeepCaretX, eoScrollByOneLess, eoShowScrollHint, eoSmartTabDelete, eoTabIndent, eoTrimTrailingSpaces]
SearchEngine = SynEditSearch1
WantTabs = True
OnChange = SynEdit1Change
/trunk/EditorMain.pas
13,10 → 13,11
 
// TODO: localize
// TODO: wieso geht copy paste im twebbrowser nicht???
// Wieso dauert webbrowser1 erste kompilierung so lange???
// TODO: Wieso dauert webbrowser1 erste kompilierung so lange???
// TODO: wieso kommt syntax fehler zweimal? einmal stderr einmal stdout?
// TODO: Browser titlebar (link preview)
// TODO: todo liste
// TODO: "jump to next/prev todo" buttons/shortcuts
// TODO: "increase/decrease indent" buttons/shortcuts
 
// Future ideas
// - code insight
174,7 → 175,7
 
uses
Functions, StrUtils, WebBrowserUtils, FastPHPUtils, Math, ShellAPI, RichEdit,
FastPHPTreeView, ImageListEx;
FastPHPTreeView, ImageListEx, FastPHPConfig;
 
const
crMouseGutter = 1;
343,7 → 344,7
 
if not SpacesAvailable(SynEdit1.Lines) then
begin
ShowMessage(SNoLinesAvailable);
MessageDlg(SNoLinesAvailable, mtInformation, [mbOk], 0);
exit;
end;
 
718,7 → 719,7
 
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FastPHPConfig.WriteInteger('User', 'FontSize', SynEdit1.Font.Size);
TFastPHPConfig.FontSize := SynEdit1.Font.Size;
end;
 
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
786,6 → 787,7
procedure TForm1.FormShow(Sender: TObject);
var
ScrapFile: string;
tmpFontSize: integer;
begin
ScrapFile := GetScrapFile;
if ScrapFile = '' then
803,7 → 805,8
PageControl2.ActivePage := CodeTabsheet;
HelpTabsheet.TabVisible := false;
 
SynEdit1.Font.Size := FastPHPConfig.ReadInteger('User', 'FontSize', SynEdit1.Font.Size);
tmpFontSize := TFastPHPConfig.FontSize;
if tmpFontSize <> -1 then SynEdit1.Font.Size := tmpFontSize;
SynEdit1.SetFocus;
 
DoubleBuffered := true;
822,6 → 825,8
end;
 
function TForm1.GetScrapFile: string;
var
tmpPath: string;
begin
if FScrapFile <> '' then
begin
830,12 → 835,70
end;
 
if ParamStr(1) <> '' then
result := ParamStr(1)
begin
// Program was started with a filename
 
result := ParamStr(1);
 
if not FileExists(result) then
begin
case MessageDlg(Format('File %s does not exist. Create it?', [result]), mtConfirmation, mbYesNoCancel, 0) of
mrYes:
try
SynEdit1.Lines.SaveToFile(result);
except
on E: Exception do
begin
MessageDlg(E.Message, mtError, [mbOk], 0);
Application.Terminate;
result := '';
exit;
end;
end;
mrNo:
begin
Application.Terminate;
result := '';
exit;
end;
mrCancel:
begin
Application.Terminate;
result := '';
exit;
end;
end;
end;
end
else
result := FastPHPConfig.ReadString('Paths', 'ScrapFile', '');
begin
// Program is started without filename -> use scrap file
 
result := TFastPHPConfig.ScrapFile;
 
if not FileExists(result) then
begin
repeat
{$REGION 'Determinate opendialog initial directory'}
if result <> '' then
begin
tmpPath := ExtractFilePath(result);
if DirectoryExists(tmpPath) then
begin
OpenDialog3.InitialDir := tmpPath;
OpenDialog3.FileName := Result;
end
else
begin
OpenDialog3.InitialDir := GetMyDocumentsFolder;
end;
end
else
begin
OpenDialog3.InitialDir := GetMyDocumentsFolder;
end;
{$ENDREGION}
 
if not OpenDialog3.Execute then
begin
Application.Terminate;
845,7 → 908,7
 
if not DirectoryExists(ExtractFilePath(OpenDialog3.FileName)) then
begin
ShowMessage('Path does not exist! Please try again.');
MessageDlg('Path does not exist! Please try again.', mtWarning, [mbOk], 0);
end
else
begin
853,13 → 916,28
end;
until result <> '';
 
if not FileExists(result) then
begin
try
// Try saving the file; check if we have permissions
//SynEdit1.Lines.Clear;
//SynEdit1.Lines.SaveToFile(result);
SynEdit1.Lines.SaveToFile(result);
except
on E: Exception do
begin
MessageDlg(E.Message, mtError, [mbOk], 0);
Application.Terminate;
result := '';
exit;
end;
end;
end;
 
FastPHPConfig.WriteString('Paths', 'ScrapFile', result);
TFastPHPConfig.ScrapFile := result;
FScrapFile := result;
end;
end;
end;
 
procedure TForm1.Help;
var
868,7 → 946,7
begin
if not Assigned(ChmIndex) then
begin
IndexFile := FastPHPConfig.ReadString('Paths', 'HelpIndex', '');
IndexFile := TFastPHPConfig.HelpIndex;
IndexFile := ChangeFileExt(IndexFile, '.ini'); // Just to be sure. Maybe someone wrote manually the ".chm" file in there
if FileExists(IndexFile) then
begin
878,7 → 956,7
 
if Assigned(ChmIndex) then
begin
IndexFile := FastPHPConfig.ReadString('Paths', 'HelpIndex', '');
IndexFile := TFastPHPConfig.HelpIndex;
// We don't check if IndexFile still exists. It is not important since we have ChmIndex pre-loaded in memory
 
chmFile := ChangeFileExt(IndexFile, '.chm');
907,7 → 985,7
try
if not ParseCHM(chmFile) then
begin
ShowMessage('The CHM file is not a valid PHP documentation. Cannot use help.');
MessageDlg('The CHM file is not a valid PHP documentation. Cannot use help.', mtError, [mbOk], 0);
exit;
end;
finally
917,13 → 995,12
 
if not FileExists(IndexFile) then
begin
ShowMessage('Unknown error. Cannot use help.');
MessageDlg('Unknown error. Cannot use help.', mtError, [mbOk], 0);
exit;
end;
end;
 
FastPHPConfig.WriteString('Paths', 'HelpIndex', IndexFile);
FastPHPConfig.UpdateFile;
TFastPHPConfig.HelpIndex := IndexFile;
 
ChmIndex := TMemIniFile.Create(IndexFile);
end;
/trunk/FastPHP.iss
0,0 → 1,91
; FastPHP Setup Script for InnoSetup
; by Daniel Marschall, ViaThinkSoft
; http://www.viathinksoft.de/
 
[Setup]
AppName=FastPHP
AppVerName=FastPHP 0.1
AppVersion=0.1
AppCopyright=© Copyright 2017 - 2018 ViaThinkSoft.
AppPublisher=ViaThinkSoft
AppPublisherURL=http://www.viathinksoft.de/
AppSupportURL=http://www.daniel-marschall.de/
AppUpdatesURL=http://www.viathinksoft.de/
DefaultDirName={pf}\FastPHP
DefaultGroupName=FastPHP
VersionInfoCompany=ViaThinkSoft
VersionInfoCopyright=© Copyright 2017 - 2018 ViaThinkSoft.
VersionInfoDescription=FastPHP Setup
VersionInfoTextVersion=1.0.0.0
VersionInfoVersion=0.1
Compression=zip/9
ChangesAssociations=yes
OutputBaseFilename=FastPHP
 
[CustomMessages]
Assoc=File associations:
 
[Languages]
;Name: de; MessagesFile: "compiler:Languages\German.isl"
 
[LangOptions]
LanguageName=English
LanguageID=$0409
 
[Components]
Name: "editor"; Description: "FastPHP Editor"; Types: full compact custom
Name: "browser"; Description: "FastPHP Browser"; Types: full
 
[Tasks]
; xphp = executable PHP (only for PHP browser)
Name: fileassocEditor; Description: "{cm:AssocFileExtension,'FastPHP Editor','.php(s)'}"; GroupDescription: "{cm:Assoc}"; Components: editor
Name: fileassocBrowser; Description: "{cm:AssocFileExtension,'FastPHP Browser','.xphp'}"; GroupDescription: "{cm:Assoc}"; Components: browser
 
[Files]
Source: "FastPHPEditor.exe"; DestDir: "{app}"; Flags: ignoreversion; Components: editor
Source: "codeexplorer.bmp"; DestDir: "{app}"; Flags: ignoreversion; Components: editor
Source: "codeexplorer.php"; DestDir: "{app}"; Flags: ignoreversion; Components: editor
Source: "codeexplorer_api.inc.php"; DestDir: "{app}"; Flags: ignoreversion; Components: editor
 
Source: "FastPHPBrowser.exe"; DestDir: "{app}"; Flags: ignoreversion; Components: browser
Source: "fastphp_server.inc.php"; DestDir: "{app}"; Flags: ignoreversion; Components: browser
 
[Dirs]
 
[Icons]
Name: "{group}\FastPHP Editor"; Filename: "{app}\FastPHPEditor.exe"; Components: editor
Name: "{group}\FastPHP Browser"; Filename: "{app}\FastPHPBrowser.exe"; Components: browser
 
[Run]
Filename: "{app}\FastPHPEditor.exe"; Description: "Run FastPHP Editor"; Flags: nowait postinstall skipifsilent; Components: editor
Filename: "{app}\FastPHPBrowser.exe"; Description: "Run FastPHP Browser"; Flags: nowait postinstall skipifsilent unchecked; Components: browser
 
[Registry]
Root: HKCR; Subkey: ".php"; ValueData: "FastPHPScript"; ValueType: string; ValueName: ""; Flags: uninsdeletevalue; Components: editor; Tasks: fileassocEditor
Root: HKCR; Subkey: ".phps"; ValueData: "FastPHPScript"; ValueType: string; ValueName: ""; Flags: uninsdeletevalue; Components: editor; Tasks: fileassocEditor
Root: HKCR; Subkey: "FastPHPScript"; ValueData: "PHP script"; ValueType: string; ValueName: ""; Flags: uninsdeletekey; Components: editor; Tasks: fileassocEditor
Root: HKCR; Subkey: "FastPHPScript\DefaultIcon"; ValueData: "{app}\FastPHPEditor.exe"; ValueType: string; ValueName: ""; Components: editor; Tasks: fileassocEditor
Root: HKCR; Subkey: "FastPHPScript\shell\open\command"; ValueData: """{app}\FastPHPEditor.exe"" ""%1"""; ValueType: string; ValueName: ""; Components: editor; Tasks: fileassocEditor
Root: HKCR; Subkey: ".php\ShellNew"; ValueData: "PHP script"; ValueType: string; ValueName: "ItemName"; Components: editor; Tasks: fileassocEditor
Root: HKCR; Subkey: ".php\ShellNew"; ValueData: ""; ValueType: string; ValueName: "NullFile"; Components: editor; Tasks: fileassocEditor
 
Root: HKCR; Subkey: ".xphp"; ValueData: "FastPHPExecutableScript"; ValueType: string; ValueName: ""; Flags: uninsdeletevalue; Components: browser; Tasks: fileassocBrowser
Root: HKCR; Subkey: "FastPHPExecutableScript"; ValueData: "Executable PHP application"; ValueType: string; ValueName: ""; Flags: uninsdeletekey; Components: browser; Tasks: fileassocBrowser
Root: HKCR; Subkey: "FastPHPExecutableScript\DefaultIcon"; ValueData: "{app}\FastPHPEditor.exe"; ValueType: string; ValueName: ""; Components: browser; Tasks: fileassocBrowser
Root: HKCR; Subkey: "FastPHPExecutableScript\shell\open\command"; ValueData: """{app}\FastPHPBrowser.exe"" ""%1"""; ValueType: string; ValueName: ""; Components: browser; Tasks: fileassocBrowser
Root: HKCR; Subkey: "FastPHPExecutableScript\shell\edit\command"; ValueData: """{app}\FastPHPEditor.exe"" ""%1"""; ValueType: string; ValueName: ""; Components: browser; Tasks: fileassocBrowser
 
[Code]
function InitializeSetup(): Boolean;
begin
if CheckForMutexes('FastPHPSetup')=false then
begin
Createmutex('FastPHPSetup');
Result := true;
end
else
begin
Result := False;
end;
end;
/trunk/FastPHPBrowser.dproj
5,7 → 5,7
<FrameworkType>VCL</FrameworkType>
<MainSource>FastPHPBrowser.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Config Condition="'$(Config)'==''">Release</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Application</AppType>
/trunk/FastPHPBrowser.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/FastPHPConfig.pas
0,0 → 1,172
unit FastPHPConfig;
 
interface
 
type
TFastPHPConfig = class(TObject)
private
class function GetFontSize: integer; static;
class procedure SetFontSize(Value: integer); static;
class function GetScrapFile: string; static;
class procedure SetScrapFile(Value: string); static;
class function GetHelpIndex: string; static;
class procedure SetHelpIndex(const Value: string); static;
class function GetPhpInterpreter: string; static;
class procedure SetPhpInterpreter(const Value: string); static;
public
class property FontSize: integer read GetFontSize write SetFontSize;
class property ScrapFile: string read GetScrapFile write SetScrapFile;
class property HelpIndex: string read GetHelpIndex write SetHelpIndex;
class property PhpInterpreter: string read GetPhpInterpreter write SetPhpInterpreter;
end;
 
implementation
 
uses
Windows, Registry;
 
class function TFastPHPConfig.GetHelpIndex: string;
var
reg: TRegistry;
begin
result := '';
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if reg.OpenKey('Software\ViaThinkSoft\FastPHP\Editor', false) then
begin
if reg.ValueExists('HelpIndex') then
result := reg.ReadString('HelpIndex');
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
class function TFastPHPConfig.GetPhpInterpreter: string;
var
reg: TRegistry;
begin
result := '';
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if reg.OpenKey('Software\ViaThinkSoft\FastPHP\Common', false) then
begin
if reg.ValueExists('PhpInterpreter') then
result := reg.ReadString('PhpInterpreter');
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
class function TFastPHPConfig.GetScrapFile: string;
var
reg: TRegistry;
begin
result := '';
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if reg.OpenKey('Software\ViaThinkSoft\FastPHP\Editor', false) then
begin
if reg.ValueExists('ScrapFile') then
result := reg.ReadString('ScrapFile');
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
class function TFastPHPConfig.GetFontSize: integer;
var
reg: TRegistry;
begin
result := -1;
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if reg.OpenKey('Software\ViaThinkSoft\FastPHP\Editor', false) then
begin
if reg.ValueExists('FontSize') then
result := reg.ReadInteger('FontSize');
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
class procedure TFastPHPConfig.SetFontSize(Value: integer);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if reg.OpenKey('Software\ViaThinkSoft\FastPHP\Editor', true) then
begin
reg.WriteInteger('FontSize', Value);
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
class procedure TFastPHPConfig.SetHelpIndex(const Value: string);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if reg.OpenKey('Software\ViaThinkSoft\FastPHP\Editor', true) then
begin
reg.WriteString('HelpIndex', Value);
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
class procedure TFastPHPConfig.SetPhpInterpreter(const Value: string);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if reg.OpenKey('Software\ViaThinkSoft\FastPHP\Common', true) then
begin
reg.WriteString('PhpInterpreter', Value);
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
class procedure TFastPHPConfig.SetScrapFile(Value: string);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if reg.OpenKey('Software\ViaThinkSoft\FastPHP\Editor', true) then
begin
reg.WriteString('ScrapFile', Value);
reg.CloseKey;
end;
finally
reg.Free;
end;
end;
 
end.
 
/trunk/FastPHPEditor.dpr
9,7 → 9,8
FindReplace in 'FindReplace.pas',
RunPHP in 'RunPHP.pas',
FastPHPTreeView in 'FastPHPTreeView.pas',
ImageListEx in 'ImageListEx.pas';
ImageListEx in 'ImageListEx.pas',
FastPHPConfig in 'FastPHPConfig.pas';
 
{$R *.res}
 
/trunk/FastPHPEditor.dproj
3,7 → 3,7
<ProjectGuid>{18E129E3-BE9B-4BD1-9FD0-1E4365C0B337}</ProjectGuid>
<MainSource>FastPHPEditor.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Config Condition="'$(Config)'==''">Release</Config>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Application</AppType>
<FrameworkType>VCL</FrameworkType>
107,6 → 107,7
<DCCReference Include="RunPHP.pas"/>
<DCCReference Include="FastPHPTreeView.pas"/>
<DCCReference Include="ImageListEx.pas"/>
<DCCReference Include="FastPHPConfig.pas"/>
<BuildConfiguration Include="Debug">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
/trunk/FastPHPEditor.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/FastPHPUtils.pas
8,7 → 8,6
const
FASTPHP_GOTO_URI_PREFIX = 'fastphp://editor/gotoline/';
 
function FastPHPConfig: TMemIniFile;
function GetPHPExe: string;
function RunPHPScript(APHPFileName: string; lint: boolean=false; inConsole: boolean=False): string;
function ParseCHM(const chmFile: TFileName): boolean;
17,25 → 16,13
implementation
 
uses
Functions;
Functions, FastPHPConfig;
 
var
__FastPHPConfig: TMemIniFile;
 
function FastPHPConfig: TMemIniFile;
begin
if not Assigned(__FastPHPConfig) then
begin
__FastPHPConfig := TMemIniFile.Create(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'FastPHP.ini');
end;
result := __FastPHPConfig;
end;
 
function GetPHPExe: string;
var
od: TOpenDialog;
begin
result := FastPHPConfig.ReadString('Paths', 'PHPInterpreter', '');
result := TFastPHPConfig.PhpInterpreter;
if not FileExists(result) then
begin
od := TOpenDialog.Create(nil);
44,7 → 31,7
od.FileName := 'php.exe';
od.Filter := 'Executable file (*.exe)|*.exe';
od.Options := [ofReadOnly, ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing];
od.Title := 'Please chose your PHP interpreter (php.exe)';
od.Title := 'Please choose your PHP interpreter (php.exe)';
 
if not od.Execute then exit;
if not FileExists(od.FileName) then exit;
55,12 → 42,11
 
if not IsValidPHPExe(result) then
begin
ShowMessage('This is not a valid PHP executable.');
MessageDlg('This is not a valid PHP executable.', mtError, [mbOk], 0);
exit;
end;
 
FastPHPConfig.WriteString('Paths', 'PHPInterpreter', result);
FastPHPConfig.UpdateFile;
TFastPHPConfig.PhpInterpreter := result;
end;
end;
 
231,11 → 217,4
(Pos('PHP_SELF', cont) >= 0);
end;
 
initialization
finalization
if Assigned(__FastPHPConfig) then
begin
__FastPHPConfig.UpdateFile;
FreeAndNil(__FastPHPConfig);
end;
end.
/trunk/FindReplace.pas
140,9 → 140,9
if not found then
begin
if direction = sdForwards then
ShowMessage('End of document reached.')
MessageDlg('End of document reached.', mtInformation, [mbOk], 0)
else
ShowMessage('Begin of document reached.');
MessageDlg('Begin of document reached.', mtInformation, [mbOk], 0);
end;
 
if fAutofocus and fEditor.CanFocus then fEditor.SetFocus;
/trunk/Functions.pas
17,9 → 17,14
function FileSystemCaseSensitive: boolean;
function HighColorWindows: boolean;
function GetTempDir: string;
function GetSpecialFolder(const aCSIDL: Integer): string;
function GetMyDocumentsFolder: string;
 
implementation
 
uses
ShlObj; // Needed for the CSIDL constants
 
function GetDosOutput(CommandLine: string; Work: string = ''): string;
var
SA: TSecurityAttributes;
299,4 → 304,22
RaiseLastOSError;
end;
 
function SHGetFolderPath(hwnd: HWND; csidl: Integer; hToken: THandle;
dwFlags: DWord; pszPath: LPWSTR): HRESULT; stdcall;
external 'SHFolder.dll' name 'SHGetFolderPathW';
 
function GetSpecialFolder(const aCSIDL: Integer): string;
var
FolderPath: array[0 .. MAX_PATH] of Char;
begin
SetLastError(ERROR_SUCCESS);
if SHGetFolderPath(0, aCSIDL, 0, 0, @FolderPath) = S_OK then
Result := FolderPath;
end;
 
function GetMyDocumentsFolder: string;
begin
Result := GetSpecialFolder(CSIDL_PERSONAL);
end;
 
end.
/trunk/codeexplorer.php
37,7 → 37,7
else if (($this->getType() == ICON_TYPE_VAR) && ($this->isPublic()) ) return 13; // public var
else if (($this->isMethod()) && ($this->isPublic()) && (!$this->isAbstract())) return 14; // public function
else if (($this->isMethod()) && ($this->isPublic()) && ( $this->isAbstract())) return 15; // public abstract function
else if (($this->getType() == ICON_TYPE_TODO) ) return 16; // ToDo comment
else if (($this->getType() == ICON_TYPE_TODO) ) return 16; // To-Do comment
else return -1;
}