Subversion Repositories fastphp

Rev

Rev 93 | Rev 96 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 93 Rev 94
Line 1... Line 1...
1
unit EditorMain;
1
unit EditorMain;
2
 
2
 
3
{$Include 'FastPHP.inc'}
3
{$Include 'FastPHP.inc'}
4
 
4
 
5
(*
5
(*
6
  This program requires
6
  This program requires
Line 23... Line 23...
23
 
23
 
24
// In regards Unicode:
24
// In regards Unicode:
25
// - Solve compiler warnings
25
// - Solve compiler warnings
26
// - If you place Unicode symbols in a ANSI file, they will be replaced during saving
26
// - If you place Unicode symbols in a ANSI file, they will be replaced during saving
27
//   by "?" without asking the user if the code should be converted to Unicode!
27
//   by "?" without asking the user if the code should be converted to Unicode!
28
// - FastPHP can only read a UTF-8 file correctly if it has a BOM
-
 
29
//   However, the PSR-1 standard requires that files have UTF-8 without BOM!
-
 
30
//   So we need auto-detect (since many people are working with ANSI!)
-
 
31
// - When a file is correctly loaded with UTF-8/BOM,
-
 
32
//   the run output (Plaintext and HTML) will show UTF-8 instead of Unicode
-
 
33
//   (that COULD be intended since the Windows CMD is not Unicode ready?)
-
 
34
//   But HTML is also shown as UTF-8 even though I have added <meta charset="UTF-8"> ?!
-
 
35
// - Is it possible that UTF8 BOM automatically gets removed by FastPHP, generating pure ANSI?
28
// - Is it possible that UTF8 BOM automatically gets removed by FastPHP, generating pure ANSI?
36
 
29
 
-
 
30
// Note in re Unicode:
-
 
31
// - In Embarcadero® Delphi 10.4 Version 27.0.40680.4203:
-
 
32
//   SynEdit correctly detects UTF-8 files without BOM as well as ANSI files with Umlauts.
-
 
33
//   (Previous versions could not detect UTF-8 files without BOM?!)
-
 
34
// - If BOM is existing, it will be removed. (which is good, because this is defined by PSR-1)
-
 
35
 
37
// Small things:
36
// Small things:
38
// - The scroll bars of SynEdit are not affected by the dark theme
37
// - The scroll bars of SynEdit are not affected by the dark theme
39
 
38
 
40
// Future ideas
39
// Future ideas
41
// - code insight
40
// - code insight
42
// - verschiedene php versionen?
41
// - verschiedene php versionen?
43
// - webbrowser1 nur laden, wenn man den tab anwählt?
42
// - webbrowser1 nur laden, wenn man den tab anw�hlt?
44
// - doppelklick auf tab soll diesen schließen
43
// - doppelklick auf tab soll diesen schlie�en
45
// - Onlinehelp (www) aufrufen oder CHM datei
44
// - Onlinehelp (www) aufrufen oder CHM datei
46
// - Let all colors be adjustable
45
// - Let all colors be adjustable
47
// - code in bildschirmmitte (horizontal)?
46
// - code in bildschirmmitte (horizontal)?
48
// - search in files of a directory
47
// - search in files of a directory
49
// - Files in multiple tabs?
48
// - Files in multiple tabs?
Line 55... Line 54...
55
  // TODO: "{$IFDEF USE_SHDOCVW_TLB}_TLB{$ENDIF}" does not work with Delphi 10.2
54
  // TODO: "{$IFDEF USE_SHDOCVW_TLB}_TLB{$ENDIF}" does not work with Delphi 10.2
56
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
55
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
57
  Dialogs, StdCtrls, OleCtrls, ComCtrls, ExtCtrls, ToolWin, IniFiles,
56
  Dialogs, StdCtrls, OleCtrls, ComCtrls, ExtCtrls, ToolWin, IniFiles,
58
  SynEditHighlighter, SynHighlighterPHP, SynEdit, ShDocVw, FindReplace,
57
  SynEditHighlighter, SynHighlighterPHP, SynEdit, ShDocVw, FindReplace,
59
  ActnList, SynEditMiscClasses, SynEditSearch, RunPHP, ImgList, SynUnicode,
58
  ActnList, SynEditMiscClasses, SynEditSearch, RunPHP, ImgList, SynUnicode,
60
  System.ImageList, System.Actions, Vcl.Menus, Vcl.Themes, System.UITypes;
59
  System.ImageList, System.Actions, Vcl.Menus, Vcl.Themes, System.UITypes,
-
 
60
  SynEditCodeFolding;
61
 
61
 
62
{.$DEFINE OnlineHelp}
62
{.$DEFINE OnlineHelp}
63
 
63
 
64
type
64
type
65
  TForm1 = class(TForm)
65
  TForm1 = class(TForm)
Line 552... Line 552...
552
  Application.ProcessMessages;
552
  Application.ProcessMessages;
553
 
553
 
554
  try
554
  try
555
    ActionSave.Execute; // TODO: if it is not the scrap file: do not save the file, since the user did not intended to save... better create a temporary file and run it instead.
555
    ActionSave.Execute; // TODO: if it is not the scrap file: do not save the file, since the user did not intended to save... better create a temporary file and run it instead.
556
 
556
 
557
    // TODO 70421 * <fastphp> flush() mittels ContentCallBack implementieren... ich möchte bei langen scripts statusanzeigen realisieren können mit javascript das stück für stück geladen wird !!!!!!!!
557
    // TODO 70421 * <fastphp> implement flush() with ContentCallBack implementieren... For long running scripts I want to see status changes via javascript which are loaded step by step
558
    // TODO 70422 * <fastphp> wenn ein script hängt, soll man es abwürgen dürfen!!!!!!
558
    // TODO 70422 * <fastphp> when a script has an endless loop, i want to have a possibility to cancel it
-
 
559
    if SynEdit1.Lines.Encoding = TEncoding.UTF8 then
-
 
560
      memo2.Lines.Text := Utf8Decode(RunPHPScript(GetScrapFile, Sender=ActionLint, False)) // if we have a UTF-8 file, then the DOS output is double-UTF8 encoded
-
 
561
    else
559
    memo2.Lines.Text := RunPHPScript(GetScrapFile, Sender=ActionLint, False);
562
      memo2.Lines.Text := RunPHPScript(GetScrapFile, Sender=ActionLint, False);
560
 
563
 
561
    {$REGION 'Show in Web Browser'}
564
    {$REGION 'Show in Web Browser'}
-
 
565
    if SynEdit1.Lines.Encoding = TEncoding.UTF8 then
-
 
566
      Webbrowser1.LoadHTML(MarkUpLineReference('<meta charset="utf-8">'+memo2.Lines.Text), GetScrapFile)
-
 
567
    else
562
    Webbrowser1.LoadHTML(MarkUpLineReference(memo2.Lines.Text), GetScrapFile);
568
      Webbrowser1.LoadHTML(MarkUpLineReference(memo2.Lines.Text), GetScrapFile);
563
 
569
 
564
    // Alternatively:
570
    // Alternatively:
565
    (*
571
    (*
566
    ss := TstringStream.Create;
572
    ss := TstringStream.Create;