/Turbo5/TurboPhp/bin/PhpEdit.pas

http://turbophp.googlecode.com/ · Pascal · 114 lines · 95 code · 17 blank · 2 comment · 4 complexity · 6f39c0a1226821ec0e676cbb4c4db590 MD5 · raw file

  1. unit PhpEdit;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, ExtCtrls, ComCtrls, ToolWin,
  6. LMDCustomScrollBox, LMDScrollBox, LMDSplt,
  7. LMDCustomControl, LMDCustomPanel, LMDCustomBevelPanel,
  8. EasyEditor, EasyEditSource, EasyClasses, EasyParser,
  9. CodeExplorer;
  10. type
  11. TPhpEditForm = class(TForm)
  12. PhpParser: TEasyEditorParser;
  13. Source: TEasyEditSource;
  14. ChangeTimer: TTimer;
  15. LMDSplitterPanel1: TLMDSplitterPanel;
  16. ExplorerPane: TLMDSplitterPane;
  17. LMDSplitterPane2: TLMDSplitterPane;
  18. Edit: TEasyEdit;
  19. ToolBar1: TToolBar;
  20. CollapseButton: TToolButton;
  21. procedure FormCreate(Sender: TObject);
  22. procedure EditSourceChanged(Sender: TObject;
  23. State: TEasyEditSourceStates);
  24. procedure ChangeTimerTimer(Sender: TObject);
  25. procedure EditAutoComplete(Sender: TObject; Strings: TStrings;
  26. AKey: Char; var AllowPopup: Boolean);
  27. procedure CollapseButtonClick(Sender: TObject);
  28. private
  29. FOnModified: TNotifyEvent;
  30. procedure SetStrings(const Value: TStrings);
  31. protected
  32. function GetStrings: TStrings;
  33. procedure Modified;
  34. procedure LazyUpdate;
  35. public
  36. CodeExplorerForm: TCodeExplorerForm;
  37. property OnModified: TNotifyEvent read FOnModified write FOnModified;
  38. property Strings: TStrings read GetStrings write SetStrings;
  39. end;
  40. var
  41. PhpEditForm: TPhpEditForm;
  42. implementation
  43. uses
  44. LrUtils;
  45. {$R *.dfm}
  46. procedure TPhpEditForm.FormCreate(Sender: TObject);
  47. begin
  48. AddForm(CodeExplorerForm, TCodeExplorerForm, ExplorerPane);
  49. CodeExplorerForm.EasyEdit := Edit;
  50. end;
  51. procedure TPhpEditForm.EditSourceChanged(Sender: TObject;
  52. State: TEasyEditSourceStates);
  53. begin
  54. if (State <> [csPositionChanged]) or ChangeTimer.Enabled then
  55. if Edit.Modified then
  56. begin
  57. ChangeTimer.Enabled := false;
  58. ChangeTimer.Enabled := true;
  59. Modified;
  60. end;
  61. end;
  62. procedure TPhpEditForm.Modified;
  63. begin
  64. if {Edit.Modified and} Assigned(OnModified) then
  65. OnModified(Self);
  66. end;
  67. procedure TPhpEditForm.ChangeTimerTimer(Sender: TObject);
  68. begin
  69. ChangeTimer.Enabled := false;
  70. LazyUpdate;
  71. end;
  72. procedure TPhpEditForm.LazyUpdate;
  73. begin
  74. CodeExplorerForm.UpdateExplorer;
  75. end;
  76. function TPhpEditForm.GetStrings: TStrings;
  77. begin
  78. Result := Source.Strings;
  79. end;
  80. procedure TPhpEditForm.SetStrings(const Value: TStrings);
  81. begin
  82. Source.Strings.Assign(Value);
  83. LazyUpdate;
  84. end;
  85. procedure TPhpEditForm.EditAutoComplete(Sender: TObject; Strings: TStrings;
  86. AKey: Char; var AllowPopup: Boolean);
  87. begin
  88. //
  89. end;
  90. procedure TPhpEditForm.CollapseButtonClick(Sender: TObject);
  91. begin
  92. if CollapseButton.Down then
  93. Edit.CollapseCode([ '{' ], [ '}'], [ {'*'} ], [], true, true, true, true)
  94. else
  95. Edit.UnCollapseCode;
  96. end;
  97. end.