Subversion Repositories fastphp

Compare Revisions

No changes between revisions

Regard whitespace Rev 4 → Rev 5

/trunk/FastPHP.dproj
0,0 → 1,132
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{18E129E3-BE9B-4BD1-9FD0-1E4365C0B337}</ProjectGuid>
<MainSource>FastPHP.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Application</AppType>
<FrameworkType>VCL</FrameworkType>
<ProjectVersion>18.2</ProjectVersion>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
<Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
<Cfg_1_Win32>true</Cfg_1_Win32>
<CfgParent>Cfg_1</CfgParent>
<Cfg_1>true</Cfg_1>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
<Cfg_2_Win32>true</Cfg_2_Win32>
<CfgParent>Cfg_2</CfgParent>
<Cfg_2>true</Cfg_2>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<SanitizedProjectName>FastPHP</SanitizedProjectName>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<DCC_F>false</DCC_F>
<DCC_S>false</DCC_S>
<DCC_E>false</DCC_E>
<DCC_K>false</DCC_K>
<DCC_N>true</DCC_N>
<VerInfo_Locale>1031</VerInfo_Locale>
<VerInfo_MinorVer>1</VerInfo_MinorVer>
<DCC_DebugInformation>1</DCC_DebugInformation>
<DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo>
<VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_Keys>CompanyName=ViaThinkSoft;FileDescription=FastPHP Editor;FileVersion=0.1.0.0;InternalName=FastPHP;LegalCopyright=(C) 2016 ViaThinkSoft;LegalTrademarks=;OriginalFilename=FastPHP.exe;ProductName=ViaThinkSoft FastPHP Editor;ProductVersion=0.1;Comments=</VerInfo_Keys>
<DCC_ImageBase>00400000</DCC_ImageBase>
<DCC_Namespace>Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;FMXTee.Chart;$(DCC_Namespace)</DCC_Namespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
<VerInfo_Locale>1033</VerInfo_Locale>
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
<Icon_MainIcon>FastPHP_Icon.ico</Icon_MainIcon>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(ModuleName)</VerInfo_Keys>
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_DebugInformation>0</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppEnableHighDPI>true</AppEnableHighDPI>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
<DCC_Optimize>false</DCC_Optimize>
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
<VerInfo_Locale>1033</VerInfo_Locale>
<Icon_MainIcon>FastPHP_Icon2.ico</Icon_MainIcon>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
<VerInfo_MinorVer>0</VerInfo_MinorVer>
<VerInfo_MajorVer>1</VerInfo_MajorVer>
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppEnableHighDPI>true</AppEnableHighDPI>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="Unit1.pas">
<Form>Form1</Form>
</DCCReference>
<DCCReference Include="Functions.pas"/>
<BuildConfiguration Include="Debug">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="Release">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType>VCLApplication</Borland.ProjectType>
<BorlandProject>
<Delphi.Personality>
<Source>
<Source Name="MainSource">FastPHP.dpr</Source>
</Source>
</Delphi.Personality>
<Platforms>
<Platform value="Win32">True</Platform>
</Platforms>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
</Project>
/trunk/FastPHP.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/FastPHP_Icon.ico
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/FastPHP_Icon1.ico
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/FastPHP_Icon2.ico
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/Functions.pas
350,12 → 350,14
Line := AMemo.Perform(EM_LINEFROMCHAR,AMemo.SelStart, 0);
Column := AMemo.SelStart - AMemo.Perform(EM_LINEINDEX, Line, 0);
end;
*)
if AMemo is TSynEdit then
begin
*)
Line := AMemo.CaretY-1;
Column := AMemo.CaretX-1;
(*
end;
*)
 
//Validate the line number
if AMemo.Lines.Count-1 < Line then Exit;
363,6 → 365,8
//Get the text of the line
LineText := AMemo.Lines[Line];
 
if LineText = '' then exit('');
 
// Column zeigt auf das Zeichen LINKS vom Cursor!
 
InitPos := Column;
/trunk/Unit1.dfm
53,6 → 53,7
ReadOnly = True
ScrollBars = ssBoth
TabOrder = 0
OnDblClick = Memo2DblClick
end
end
object HtmlTabSheet: TTabSheet
65,6 → 66,7
Height = 245
Align = alClient
TabOrder = 0
OnBeforeNavigate2 = WebBrowser1BeforeNavigate2
ExplicitWidth = 348
ExplicitHeight = 150
ControlData = {
78,21 → 80,25
end
object PageControl2: TPageControl
Left = 0
Top = 0
Top = 36
Width = 1120
Height = 385
ActivePage = TabSheet3
Height = 349
ActivePage = HelpTabsheet
Align = alClient
TabOrder = 1
OnChanging = PageControl2Changing
ExplicitTop = 0
ExplicitHeight = 385
object TabSheet3: TTabSheet
Caption = 'Scrap'
ExplicitHeight = 357
object SynEdit1: TSynEdit
Left = 0
Top = 0
Width = 1112
Height = 357
Height = 321
Align = alClient
ActiveLineColor = clInfoBk
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
99,7 → 105,6
Font.Name = 'Courier New'
Font.Style = []
TabOrder = 0
OnKeyDown = Memo1KeyDown
Gutter.Font.Charset = DEFAULT_CHARSET
Gutter.Font.Color = clWindowText
Gutter.Font.Height = -11
109,25 → 114,28
Highlighter = SynPHPSyn1
Lines.Strings = (
'SynEdit1')
Options = [eoAutoIndent, eoDragDropEditing, eoEnhanceEndKey, eoGroupUndo, eoHideShowScrollbars, eoScrollByOneLess, eoShowScrollHint, eoSmartTabDelete, eoSmartTabs, eoTabIndent, eoTabsToSpaces, eoTrimTrailingSpaces]
Options = [eoAutoIndent, eoDragDropEditing, eoEnhanceHomeKey, eoEnhanceEndKey, eoGroupUndo, eoHideShowScrollbars, eoScrollByOneLess, eoShowScrollHint, eoTabIndent, eoTrimTrailingSpaces]
WantTabs = True
FontSmoothing = fsmNone
ExplicitTop = 1
ExplicitHeight = 316
end
end
object HelpTabsheet: TTabSheet
Caption = 'Help'
ImageIndex = 1
ExplicitHeight = 357
object WebBrowser2: TWebBrowser
Left = 0
Top = 0
Width = 1112
Height = 357
Height = 321
Align = alClient
TabOrder = 0
ExplicitWidth = 300
ExplicitHeight = 150
ControlData = {
4C000000EE720000E62400000000000000000000000000000000000000000000
4C000000EE7200002D2100000000000000000000000000000000000000000000
000000004C000000000000000000000001000000E0D057007335CF11AE690800
2B2E126208000000000000004C0000000114020000000000C000000000000046
8000000000000000000000000000000000000000000000000000000000000000
144,6 → 152,41
TabOrder = 2
Visible = False
end
object Panel2: TPanel
Left = 0
Top = 0
Width = 1120
Height = 36
Align = alTop
TabOrder = 3
object Button1: TButton
Left = 4
Top = 0
Width = 75
Height = 35
Caption = 'Run'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 85
Top = 0
Width = 75
Height = 35
Caption = 'Help'
TabOrder = 1
OnClick = Button2Click
end
object Button3: TButton
Left = 166
Top = 0
Width = 75
Height = 35
Caption = 'Goto'
TabOrder = 2
OnClick = Button3Click
end
end
object OpenDialog1: TOpenDialog
DefaultExt = '.chm'
FileName = 'php_manual_en.chm'
185,4 → 228,11
Left = 72
Top = 80
end
object SynEditFocusTimer: TTimer
Enabled = False
Interval = 500
OnTimer = SynEditFocusTimerTimer
Left = 668
Top = 249
end
end
/trunk/Unit1.pas
13,7 → 13,14
 
// TODO: wieso geht copy paste im twebbrowser nicht???
// Wieso dauert webbrowser1 erste kompilierung so lange???
// TODO: wieso kommt syntax fehler zweimal? einmal stderr einmal stdout?
// TODO: Browser titlebar (link preview)
 
// TODO: strg+f / h
// TODO: font bigger
// TODO: code in bildschirmmitte?
// TODO: regelmäßig scrap zwischenspeichern, oder bei strg+s
 
// Future ideas
// - ToDo list
// - Open/Save real files
22,8 → 29,7
// - webbrowser1 nur laden, wenn man den tab anwählt?
// - doppelklick auf tab soll diesen schließen
// - Strg+S
// - tastenkombo für "springe zu zeile"
// - Onlinehelp aufrufen
// - Onlinehelp (www) aufrufen
 
interface
 
50,21 → 56,35
OpenDialog3: TOpenDialog;
SynEdit1: TSynEdit;
SynPHPSyn1: TSynPHPSyn;
Panel2: TPanel;
SynEditFocusTimer: TTimer;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Run(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure PageControl2Changing(Sender: TObject; var AllowChange: Boolean);
procedure Memo2DblClick(Sender: TObject);
procedure WebBrowser1BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
procedure SynEditFocusTimerTimer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
CurSearchTerm: string;
HlpPrevPageIndex: integer;
procedure Help;
procedure ApplicationOnMessage(var Msg: tagMSG; var Handled: Boolean);
function MarkUpLineReference(cont: string): string;
protected
FastPHPConfig: TMemIniFile;
ChmIndex: TMemIniFile;
procedure GotoLineNo(LineNo:integer);
function GetScrapFile: string;
end;
 
76,16 → 96,21
{$R *.dfm}
 
uses
Functions;
Functions, StrUtils;
 
procedure TForm1.ApplicationOnMessage(var Msg: tagMSG; var Handled: Boolean);
var
val: string;
lineno: integer;
begin
case Msg.message of
WM_KEYUP:
begin
case Msg.wParam of
{$REGION 'Esc'}
VK_ESCAPE:
begin
Handled := true;
// It is necessary to use Application.OnMessage, because Form1.KeyPreview does not work when TWebBrowser has the focus
if (HlpPrevPageIndex <> -1) and (PageControl2.ActivePage = HelpTabSheet) and
(HelpTabsheet.TabVisible) then
93,17 → 118,57
PageControl2.ActivePageIndex := HlpPrevPageIndex;
HelpTabsheet.TabVisible := false;
end;
end;
{$ENDREGION}
 
{$REGION 'Ctrl+G : Go to line'}
ord('G'):
begin
// TODO: VK_LMENU does not work! only works with AltGr but not Alt
// http://stackoverflow.com/questions/16828250/delphi-xe2-how-to-prevent-the-alt-key-stealing-focus ?
if (GetKeyState(VK_CONTROL) < 0) then
begin
Handled := true;
InputQuery('Go to', 'Line number:', val);
if not TryStrToInt(val, lineno) then exit;
GotoLineNo(lineno);
end;
end;
{$ENDREGION}
 
VK_F1:
begin
if SynEdit1.Focused then
begin
Handled := true;
Help;
end;
end;
 
VK_F5:
begin
Run(Self);
end;
 
VK_F9:
begin
Run(Self);
end;
end;
end;
end;
end;
 
procedure TForm1.Run(Sender: TObject);
var
phpExe: string;
begin
memo2.Lines.Text := '';
BrowseContent(Webbrowser1, memo2.Lines.Text);
Screen.Cursor := crHourGlass;
Application.ProcessMessages;
 
try
if not FileExists(phpExe) then
begin
phpExe := FastPHPConfig.ReadString('Paths', 'PHPInterpreter', '');
128,14 → 193,71
 
memo2.Lines.Text := GetDosOutput('"'+phpExe+'" "'+GetScrapFile+'"', ExtractFileDir(Application.ExeName));
 
BrowseContent(Webbrowser1, memo2.Lines.Text);
BrowseContent(Webbrowser1, MarkUpLineReference(memo2.Lines.Text));
 
if IsTextHTML(memo2.lines.text) then
PageControl1.ActivePage := HtmlTabSheet
else
PageControl1.ActivePage := PlaintextTabSheet;
finally
Screen.Cursor := crDefault;
end;
end;
 
procedure TForm1.SynEditFocusTimerTimer(Sender: TObject);
begin
SynEditFocusTimer.Enabled := false;
Button1.SetFocus; // Workaround for weird bug... This (and the timer) is necessary to get the focus to SynEdit1
SynEdit1.SetFocus;
end;
 
procedure TForm1.WebBrowser1BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
const
MAG_BEGIN = 'fastphp://gotoline/';
var
s: string;
lineno: integer;
begin
if Copy(URL, 1, length(MAG_BEGIN)) = MAG_BEGIN then
begin
try
s := copy(URL, length(MAG_BEGIN)+1, 99);
if not TryStrToInt(s, lineno) then exit;
GotoLineNo(lineno);
SynEditFocusTimer.Enabled := true;
finally
Cancel := true;
end;
end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
Run(Sender);
SynEdit1.SetFocus;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
begin
Help;
if PageControl2.ActivePage = HelpTabsheet then
WebBrowser2.SetFocus
else if PageControl2.ActivePage = TabSheet3{Scrap} then
SynEdit1.SetFocus;
end;
 
procedure TForm1.Button3Click(Sender: TObject);
var
val: string;
lineno: integer;
begin
InputQuery('Go to', 'Line number:', val);
if not TryStrToInt(val, lineno) then exit;
GotoLineNo(lineno);
end;
 
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SynEdit1.Lines.SaveToFile(GetScrapFile);
177,6 → 299,8
 
PageControl2.ActivePageIndex := 0; // Scraps
HelpTabsheet.TabVisible := false;
 
SynEdit1.SetFocus;
end;
 
function TForm1.GetScrapFile: string;
297,15 → 421,41
BrowseURL(WebBrowser2, url);
end;
 
procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure TForm1.GotoLineNo(LineNo:integer);
var
line: string;
i: integer;
begin
if (Key = VK_F9) or (Key = VK_F5) then
Run(Sender)
else if Key = VK_F1 then
Help;
SynEdit1.GotoLineAndCenter(LineNo);
 
// Skip indent
line := SynEdit1.Lines[SynEdit1.CaretY];
for i := 1 to Length(line) do
begin
if not (line[i] in [' ', #9]) then
begin
SynEdit1.CaretX := i-1;
break;
end;
end;
 
PageControl2.ActivePage := TabSheet3{Scrap};
if SynEdit1.CanFocus then SynEdit1.SetFocus;
end;
 
procedure TForm1.Memo2DblClick(Sender: TObject);
var
line: string;
p, lineno: integer;
begin
line := memo2.Lines.Strings[Memo2.CaretPos.Y];
p := Pos(' on line ', line);
if p = 0 then exit;
line := copy(line, p+length(' on line '), 99);
if not TryStrToInt(line, lineno) then exit;
GotoLineNo(lineno);
end;
 
procedure TForm1.PageControl2Changing(Sender: TObject;
var AllowChange: Boolean);
begin
317,4 → 467,37
AllowChange := true;
end;
 
function TForm1.MarkUpLineReference(cont: string): string;
var
p, a, b: integer;
num: integer;
insert_a, insert_b: string;
begin
// TODO: make it more specific to PHP error messages. "on line" is too broad.
p := Pos(' on line ', cont);
while p >= 1 do
begin
a := p+1;
b := p+length(' on line ');
num := 0;
while cont[b] in ['0'..'9'] do
begin
num := num*10 + StrToInt(cont[b]);
inc(b);
end;
 
insert_b := '</a>';
insert_a := '<a href="fastphp://gotoline/'+IntToStr(num)+'">';
 
insert(insert_b, cont, b);
insert(insert_a, cont, a);
 
p := b + Length(insert_a) + Length(insert_b);
 
p := PosEx(' on line ', cont, p+1);
end;
 
result := cont;
end;
 
end.