umain.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. unit umain;
  2. {
  3. How to write:
  4. - Separate commands by line (only one command in one line)
  5. - Separate parameters by single space ' ' or comma ','
  6. - All parameters are obligatory
  7. - Put strings with double quotes "text"
  8. - Put float numbers as strings "1,5"
  9. - Comments are threated as the first parameter
  10. - Comment with '// comment' and '{ comment }' or '//,comment' and '{,comment}'
  11. - Multi line comments not allowed
  12. - Use 'let' to store values: "let a 100" "let key value"
  13. Error handling:
  14. - If one line fails and program not crash it will continue running other lines
  15. - Empty lines will not run and will not be printed in debug
  16. - Wrong number of parameters will not run and will show an error in debug
  17. - Wrong command name will not run and will show an error in debug
  18. }
  19. {$mode objfpc}{$H+}
  20. interface
  21. uses
  22. Classes, SysUtils, FileUtil, SynEdit, SynCompletion, SynHighlighterAny, Forms,
  23. Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, BGRAGraphicControl,
  24. BGRABitmap, BCTypes, BGRAScript, BGRAVirtualScreen, BCButton, bgrabitmaptypes;
  25. type
  26. { TForm1 }
  27. TForm1 = class(TForm)
  28. BCButton1: TBCButton;
  29. BGRAGraphicControl1: TBGRAGraphicControl;
  30. BGRAVirtualScreen1: TBGRAVirtualScreen;
  31. ListBox1: TListBox;
  32. Splitter1: TSplitter;
  33. SynAnySyn1: TSynAnySyn;
  34. SynCompletion1: TSynCompletion;
  35. SynEdit1: TSynEdit;
  36. procedure BCButton1Click(Sender: TObject);
  37. procedure BGRAGraphicControl1Click(Sender: TObject);
  38. procedure BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  39. procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  40. procedure FormCreate(Sender: TObject);
  41. procedure ListBox1DblClick(Sender: TObject);
  42. private
  43. { private declarations }
  44. public
  45. { public declarations }
  46. end;
  47. var
  48. Form1: TForm1;
  49. implementation
  50. {$R *.lfm}
  51. { TForm1 }
  52. procedure TForm1.BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  53. begin
  54. BGRAScript.ScriptCommandList(SynEdit1.Lines, Bitmap);
  55. end;
  56. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  57. begin
  58. Bitmap.DrawHorizLine(0,Bitmap.Height-3,Bitmap.Width-1,BGRA(215,215,215,255));
  59. Bitmap.DrawHorizLine(0,Bitmap.Height-2,Bitmap.Width-1,BGRA(235,235,235,255));
  60. Bitmap.DrawHorizLine(0,Bitmap.Height-1,Bitmap.Width-1,BGRA(240,240,240,255));
  61. end;
  62. procedure TForm1.BGRAGraphicControl1Click(Sender: TObject);
  63. begin
  64. BGRAGraphicControl1.DiscardBitmap;
  65. end;
  66. procedure TForm1.BCButton1Click(Sender: TObject);
  67. begin
  68. ListBox1.Visible := not ListBox1.Visible;
  69. end;
  70. procedure TForm1.FormCreate(Sender: TObject);
  71. begin
  72. BGRAScript.SynCompletionList(SynCompletion1.ItemList);
  73. BGRAScript.SynCompletionList(ListBox1.Items);
  74. end;
  75. procedure TForm1.ListBox1DblClick(Sender: TObject);
  76. begin
  77. SynEdit1.Lines.Add(ListBox1.GetSelectedText);
  78. end;
  79. end.