Browse Source

Added bgrascript.pas and test_bgrascript

lainz 11 years ago
parent
commit
45f8f7a23e

+ 33 - 29
bgracontrols.lpk

@@ -26,8 +26,8 @@
         <CompilerPath Value="$(CompPath)"/>
       </Other>
     </CompilerOptions>
-    <Version Major="3" Minor="2"/>
-    <Files Count="32">
+    <Version Major="3" Minor="3"/>
+    <Files Count="33">
       <Item1>
         <Filename Value="bcbasectrls.pas"/>
         <UnitName Value="BCBaseCtrls"/>
@@ -113,74 +113,78 @@
         <UnitName Value="BGRAResizeSpeedButton"/>
       </Item18>
       <Item19>
+        <Filename Value="bgrascript.pas"/>
+        <UnitName Value="BGRAScript"/>
+      </Item19>
+      <Item20>
         <Filename Value="bgrashape.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="BGRAShape"/>
-      </Item19>
-      <Item20>
+      </Item20>
+      <Item21>
         <Filename Value="bgraspeedbutton.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="BGRASpeedButton"/>
-      </Item20>
-      <Item21>
+      </Item21>
+      <Item22>
         <Filename Value="bgraspriteanimation.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="BGRASpriteAnimation"/>
-      </Item21>
-      <Item22>
+      </Item22>
+      <Item23>
         <Filename Value="bgravirtualscreen.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="BGRAVirtualScreen"/>
-      </Item22>
-      <Item23>
+      </Item23>
+      <Item24>
         <Filename Value="dtanalogclock.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="DTAnalogClock"/>
-      </Item23>
-      <Item24>
-        <Filename Value="dtanalogcommon.pp"/>
-        <UnitName Value="DTAnalogCommon"/>
       </Item24>
       <Item25>
+        <Filename Value="dtanalogcommon.pp"/>
+        <UnitName Value="DTAnalogCommon"/>
+      </Item25>
+      <Item26>
         <Filename Value="dtanaloggauge.pp"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="DTAnalogGauge"/>
-      </Item25>
-      <Item26>
+      </Item26>
+      <Item27>
         <Filename Value="dtthemedclock.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="dtthemedclock"/>
-      </Item26>
-      <Item27>
+      </Item27>
+      <Item28>
         <Filename Value="dtthemedgauge.pp"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="dtthemedgauge"/>
-      </Item27>
-      <Item28>
+      </Item28>
+      <Item29>
         <Filename Value="ueknob.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="uEKnob"/>
-      </Item28>
-      <Item29>
+      </Item29>
+      <Item30>
         <Filename Value="ueled.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="ueled"/>
-      </Item29>
-      <Item30>
+      </Item30>
+      <Item31>
         <Filename Value="uemultiturn.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="uEMultiTurn"/>
-      </Item30>
-      <Item31>
+      </Item31>
+      <Item32>
         <Filename Value="uerotimage.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="uERotImage"/>
-      </Item31>
-      <Item32>
+      </Item32>
+      <Item33>
         <Filename Value="ueselector.pas"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="uESelector"/>
-      </Item32>
+      </Item33>
     </Files>
     <Type Value="RunAndDesignTime"/>
     <RequiredPkgs Count="2">

+ 4 - 4
bgracontrols.pas

@@ -10,10 +10,10 @@ uses
   BCBaseCtrls, BCButton, BCEffect, bcfilters, BCGameGrid, BCImageButton, 
   BCLabel, BCPanel, BCRTTI, BCStylesForm, BCTools, BGRAFlashProgressBar, 
   BGRAGraphicControl, BGRAImageList, BGRAImageManipulation, BGRAKnob, 
-  BGRAResizeSpeedButton, BGRAShape, BGRASpeedButton, BGRASpriteAnimation, 
-  BGRAVirtualScreen, DTAnalogClock, DTAnalogCommon, DTAnalogGauge, 
-  dtthemedclock, dtthemedgauge, uEKnob, ueled, uEMultiTurn, uERotImage, 
-  uESelector, LazarusPackageIntf;
+  BGRAResizeSpeedButton, BGRAScript, BGRAShape, BGRASpeedButton, 
+  BGRASpriteAnimation, BGRAVirtualScreen, DTAnalogClock, DTAnalogCommon, 
+  DTAnalogGauge, dtthemedclock, dtthemedgauge, uEKnob, ueled, uEMultiTurn, 
+  uERotImage, uESelector, LazarusPackageIntf;
 
 implementation
 

+ 255 - 0
bgrascript.pas

@@ -0,0 +1,255 @@
+unit BGRAScript;
+
+{$mode objfpc}{$H+}
+{$define debug}
+
+interface
+
+uses
+  Classes, SysUtils, BGRABitmap, BGRABitmapTypes;
+
+{Template}
+procedure SynCompletionList(itemlist: TStrings);
+{Scripting}
+function ScriptCommand(command: string; bitmap: TBGRABitmap): boolean;
+function ScriptCommandList(commandlist: TStrings; bitmap: TBGRABitmap): boolean;
+
+implementation
+
+procedure SynCompletionList(itemlist: TStrings);
+begin
+  with itemlist do
+  begin
+    {TFPCustomImage override}
+    Add('SetSize,320,240');
+    {Loading functions}
+    Add('SaveToFile,"file.png"');
+    {Loading functions}
+    Add('SetHorizLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('XorHorizLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('DrawHorizLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('FastBlendHorizLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('AlphaHorizLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('SetVertLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('XorVertLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('DrawVertLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('FastBlendVertLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('AlphaVertLine,0,0,100,"rgba(0,0,0,255)"');
+    Add('DrawHorizLinediff,0,0,100,"rgba(0,0,0,255)","rgba(255,255,255,255)",128');
+    //--
+    Add('FillTransparent');
+    Add('Rectangle,0,0,100,100,"rgba(0,0,0,255)","rgba(255,255,255,255)"');
+    Add('RectangleAntiAlias,"0,5","0,5","99,5","99,5","rgba(0,0,0,255)","1,5","rgba(255,255,255,255)"');
+  end;
+end;
+
+function ScriptCommand(command: string; bitmap: TBGRABitmap): boolean;
+
+  function ParamCheck(passed, mustbe: integer): boolean;
+  begin
+    Result := True;
+    if passed <> mustbe then
+      Result := False;
+
+  {$ifdef debug}
+    if not Result then
+    begin
+      writeln('>> Wrong number of parameters: ' + IntToStr(passed));
+      writeln('>> Must be: ' + IntToStr(mustbe));
+    end;
+  {$endif}
+  end;
+
+var
+  list: TStringList;
+  passed: integer;
+  {$ifdef debug}
+  i: integer;
+  {$endif}
+begin
+  {$ifdef debug}
+  writeln('---Script Command---');
+  {$endif}
+
+  Result := True;
+  list := TStringList.Create;
+  list.CommaText := command;
+  passed := list.Count;
+
+  case LowerCase(list[0]) of
+
+    {TFPCustomImage override}
+    'setsize':
+    begin
+      Result := ParamCheck(passed, 3);
+      if Result then
+        bitmap.SetSize(StrToInt(list[1]), StrToInt(list[2]));
+    end;
+
+    {Loading functions}
+    'savetofile':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+        bitmap.SaveToFile(list[1]);
+    end;
+
+    {Pixel functions}
+
+    {Loading functions}
+    {* Horiz *}
+    'sethorizline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.SetHorizLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]));
+    end;
+    'xorhorizline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.XorHorizLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]));
+    end;
+    'drawhorizline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.DrawHorizLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]));
+    end;
+    'fastblendhorizline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.FastBlendHorizLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]));
+    end;
+    'alphahorizline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.AlphaHorizLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToInt(list[4]));
+    end;
+    {* Vert *}
+    'setvertline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.SetVertLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]));
+    end;
+    'xorvertline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.XorVertLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]));
+    end;
+    'drawvertline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.DrawVertLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]));
+    end;
+    'fastblendvertline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.FastBlendVertLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]));
+    end;
+    'alphavertline':
+    begin
+      Result := ParamCheck(passed, 5);
+      if Result then
+        bitmap.AlphaVertLine(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToInt(list[4]));
+    end;
+    {* Misc *}
+    'drawhorizlinediff':
+    begin
+      Result := ParamCheck(passed, 7);
+      if Result then
+        bitmap.DrawHorizLineDiff(StrToInt(list[1]), StrToInt(list[2]),
+          StrToInt(list[3]), StrToBGRA(list[4]), StrToBGRA(list[5]), StrToInt(list[6]));
+    end;
+
+    //---
+    'filltransparent':
+    begin
+      Result := ParamCheck(passed, 1);
+      if Result then
+        bitmap.FillTransparent;
+    end;
+
+    'rectangle':
+    begin
+      Result := ParamCheck(passed, 7);
+      if Result then
+        bitmap.Rectangle(StrToInt(list[1]), StrToInt(list[2]), StrToInt(
+          list[3]), StrToInt(list[4]), StrToBGRA(list[5]), StrToBGRA(list[6]),
+          dmDrawWithTransparency);
+    end;
+
+    'rectangleantialias':
+    begin
+      Result := ParamCheck(passed, 8);
+      if Result then
+        bitmap.RectangleAntialias(StrToFloat(list[1]), StrToFloat(list[2]),
+          StrToFloat(list[3]), StrToFloat(list[4]), StrToBGRA(list[5]),
+          StrToFloat(list[6]), StrToBGRA(list[7]));
+    end;
+
+    '//':
+    begin
+      //,comment
+    end;
+
+    '{':
+    begin
+      {,comment}
+    end;
+
+    else
+    begin
+      Result := False;
+    end;
+  end;
+
+  {$ifdef debug}
+  if not Result then
+    writeln('>> ERROR');
+  for i := 0 to list.Count - 1 do
+    writeln(' ' + list[i]);
+  writeln('--------------------');
+  {$endif}
+end;
+
+function ScriptCommandList(commandlist: TStrings; bitmap: TBGRABitmap): boolean;
+var
+  i: integer;
+begin
+  {$ifdef debug}
+  writeln('----Script  List----');
+  writeln(' Executing ' + IntToStr(commandlist.Count) + ' lines...');
+  writeln('--------------------');
+  {$endif}
+
+  Result := True;
+  for i := 0 to commandlist.Count - 1 do
+    if commandlist[i] <> '' then
+      ScriptCommand(commandlist[i], bitmap);
+
+  {$ifdef debug}
+  writeln('----Script  List----');
+  writeln(' END');
+  writeln('--------------------');
+  {$endif}
+end;
+
+end.
+

+ 87 - 0
test/test_bgrascript/test_bgrascript.lpi

@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+  <ProjectOptions>
+    <Version Value="9"/>
+    <PathDelim Value="\"/>
+    <General>
+      <SessionStorage Value="InProjectDir"/>
+      <MainUnit Value="0"/>
+      <Title Value="test_bgrascript"/>
+      <ResourceType Value="res"/>
+      <UseXPManifest Value="True"/>
+      <Icon Value="0"/>
+    </General>
+    <i18n>
+      <EnableI18N LFM="False"/>
+    </i18n>
+    <VersionInfo>
+      <StringTable ProductVersion=""/>
+    </VersionInfo>
+    <BuildModes Count="1">
+      <Item1 Name="Default" Default="True"/>
+    </BuildModes>
+    <PublishOptions>
+      <Version Value="2"/>
+    </PublishOptions>
+    <RunParams>
+      <local>
+        <FormatVersion Value="1"/>
+      </local>
+    </RunParams>
+    <RequiredPackages Count="3">
+      <Item1>
+        <PackageName Value="SynEdit"/>
+      </Item1>
+      <Item2>
+        <PackageName Value="bgracontrols"/>
+      </Item2>
+      <Item3>
+        <PackageName Value="LCL"/>
+      </Item3>
+    </RequiredPackages>
+    <Units Count="2">
+      <Unit0>
+        <Filename Value="test_bgrascript.lpr"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="test_bgrascript"/>
+      </Unit0>
+      <Unit1>
+        <Filename Value="umain.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="Form1"/>
+        <ResourceBaseClass Value="Form"/>
+        <UnitName Value="umain"/>
+      </Unit1>
+    </Units>
+  </ProjectOptions>
+  <CompilerOptions>
+    <Version Value="11"/>
+    <PathDelim Value="\"/>
+    <Target>
+      <Filename Value="test_bgrascript"/>
+    </Target>
+    <SearchPaths>
+      <IncludeFiles Value="$(ProjOutDir)"/>
+      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
+    </SearchPaths>
+    <Other>
+      <CompilerMessages>
+        <MsgFileName Value=""/>
+      </CompilerMessages>
+      <CompilerPath Value="$(CompPath)"/>
+    </Other>
+  </CompilerOptions>
+  <Debugging>
+    <Exceptions Count="3">
+      <Item1>
+        <Name Value="EAbort"/>
+      </Item1>
+      <Item2>
+        <Name Value="ECodetoolError"/>
+      </Item2>
+      <Item3>
+        <Name Value="EFOpenError"/>
+      </Item3>
+    </Exceptions>
+  </Debugging>
+</CONFIG>

+ 21 - 0
test/test_bgrascript/test_bgrascript.lpr

@@ -0,0 +1,21 @@
+program test_bgrascript;
+
+{$mode objfpc}{$H+}
+
+uses
+  {$IFDEF UNIX}{$IFDEF UseCThreads}
+  cthreads,
+  {$ENDIF}{$ENDIF}
+  Interfaces, // this includes the LCL widgetset
+  Forms, umain
+  { you can add units after this };
+
+{$R *.res}
+
+begin
+  RequireDerivedFormResource := True;
+  Application.Initialize;
+  Application.CreateForm(TForm1, Form1);
+  Application.Run;
+end.
+

+ 597 - 0
test/test_bgrascript/umain.lfm

@@ -0,0 +1,597 @@
+object Form1: TForm1
+  Left = 542
+  Height = 531
+  Top = 150
+  Width = 1050
+  Caption = 'BGRAScript'
+  ClientHeight = 531
+  ClientWidth = 1050
+  OnCreate = FormCreate
+  Position = poDesktopCenter
+  ShowHint = True
+  LCLVersion = '1.2.0.3'
+  object BGRAGraphicControl1: TBGRAGraphicControl
+    Left = 0
+    Height = 232
+    Hint = 'Click to update.'
+    Top = 0
+    Width = 1050
+    Align = alClient
+    OnRedraw = BGRAGraphicControl1Redraw
+    Color = clWhite
+    ColorOpacity = 128
+    Alignment = taCenter
+    OnClick = BGRAGraphicControl1Click
+    Caption = 'BGRAGraphicControl1'
+  end
+  inline SynEdit1: TSynEdit
+    Left = 0
+    Height = 294
+    Hint = 'Ctrl + Spacebar to show templates.'
+    Top = 237
+    Width = 1050
+    Align = alBottom
+    Font.Height = -16
+    Font.Name = 'Courier New'
+    Font.Pitch = fpFixed
+    Font.Quality = fqCleartypeNatural
+    ParentColor = False
+    ParentFont = False
+    TabOrder = 0
+    Gutter.Width = 61
+    Gutter.MouseActions = <>
+    RightGutter.Width = 0
+    RightGutter.MouseActions = <>
+    Highlighter = SynAnySyn1
+    Keystrokes = <    
+      item
+        Command = ecUp
+        ShortCut = 38
+      end    
+      item
+        Command = ecSelUp
+        ShortCut = 8230
+      end    
+      item
+        Command = ecScrollUp
+        ShortCut = 16422
+      end    
+      item
+        Command = ecDown
+        ShortCut = 40
+      end    
+      item
+        Command = ecSelDown
+        ShortCut = 8232
+      end    
+      item
+        Command = ecScrollDown
+        ShortCut = 16424
+      end    
+      item
+        Command = ecLeft
+        ShortCut = 37
+      end    
+      item
+        Command = ecSelLeft
+        ShortCut = 8229
+      end    
+      item
+        Command = ecWordLeft
+        ShortCut = 16421
+      end    
+      item
+        Command = ecSelWordLeft
+        ShortCut = 24613
+      end    
+      item
+        Command = ecRight
+        ShortCut = 39
+      end    
+      item
+        Command = ecSelRight
+        ShortCut = 8231
+      end    
+      item
+        Command = ecWordRight
+        ShortCut = 16423
+      end    
+      item
+        Command = ecSelWordRight
+        ShortCut = 24615
+      end    
+      item
+        Command = ecPageDown
+        ShortCut = 34
+      end    
+      item
+        Command = ecSelPageDown
+        ShortCut = 8226
+      end    
+      item
+        Command = ecPageBottom
+        ShortCut = 16418
+      end    
+      item
+        Command = ecSelPageBottom
+        ShortCut = 24610
+      end    
+      item
+        Command = ecPageUp
+        ShortCut = 33
+      end    
+      item
+        Command = ecSelPageUp
+        ShortCut = 8225
+      end    
+      item
+        Command = ecPageTop
+        ShortCut = 16417
+      end    
+      item
+        Command = ecSelPageTop
+        ShortCut = 24609
+      end    
+      item
+        Command = ecLineStart
+        ShortCut = 36
+      end    
+      item
+        Command = ecSelLineStart
+        ShortCut = 8228
+      end    
+      item
+        Command = ecEditorTop
+        ShortCut = 16420
+      end    
+      item
+        Command = ecSelEditorTop
+        ShortCut = 24612
+      end    
+      item
+        Command = ecLineEnd
+        ShortCut = 35
+      end    
+      item
+        Command = ecSelLineEnd
+        ShortCut = 8227
+      end    
+      item
+        Command = ecEditorBottom
+        ShortCut = 16419
+      end    
+      item
+        Command = ecSelEditorBottom
+        ShortCut = 24611
+      end    
+      item
+        Command = ecToggleMode
+        ShortCut = 45
+      end    
+      item
+        Command = ecCopy
+        ShortCut = 16429
+      end    
+      item
+        Command = ecPaste
+        ShortCut = 8237
+      end    
+      item
+        Command = ecDeleteChar
+        ShortCut = 46
+      end    
+      item
+        Command = ecCut
+        ShortCut = 8238
+      end    
+      item
+        Command = ecDeleteLastChar
+        ShortCut = 8
+      end    
+      item
+        Command = ecDeleteLastChar
+        ShortCut = 8200
+      end    
+      item
+        Command = ecDeleteLastWord
+        ShortCut = 16392
+      end    
+      item
+        Command = ecUndo
+        ShortCut = 32776
+      end    
+      item
+        Command = ecRedo
+        ShortCut = 40968
+      end    
+      item
+        Command = ecLineBreak
+        ShortCut = 13
+      end    
+      item
+        Command = ecSelectAll
+        ShortCut = 16449
+      end    
+      item
+        Command = ecCopy
+        ShortCut = 16451
+      end    
+      item
+        Command = ecBlockIndent
+        ShortCut = 24649
+      end    
+      item
+        Command = ecLineBreak
+        ShortCut = 16461
+      end    
+      item
+        Command = ecInsertLine
+        ShortCut = 16462
+      end    
+      item
+        Command = ecDeleteWord
+        ShortCut = 16468
+      end    
+      item
+        Command = ecBlockUnindent
+        ShortCut = 24661
+      end    
+      item
+        Command = ecPaste
+        ShortCut = 16470
+      end    
+      item
+        Command = ecCut
+        ShortCut = 16472
+      end    
+      item
+        Command = ecDeleteLine
+        ShortCut = 16473
+      end    
+      item
+        Command = ecDeleteEOL
+        ShortCut = 24665
+      end    
+      item
+        Command = ecUndo
+        ShortCut = 16474
+      end    
+      item
+        Command = ecRedo
+        ShortCut = 24666
+      end    
+      item
+        Command = ecGotoMarker0
+        ShortCut = 16432
+      end    
+      item
+        Command = ecGotoMarker1
+        ShortCut = 16433
+      end    
+      item
+        Command = ecGotoMarker2
+        ShortCut = 16434
+      end    
+      item
+        Command = ecGotoMarker3
+        ShortCut = 16435
+      end    
+      item
+        Command = ecGotoMarker4
+        ShortCut = 16436
+      end    
+      item
+        Command = ecGotoMarker5
+        ShortCut = 16437
+      end    
+      item
+        Command = ecGotoMarker6
+        ShortCut = 16438
+      end    
+      item
+        Command = ecGotoMarker7
+        ShortCut = 16439
+      end    
+      item
+        Command = ecGotoMarker8
+        ShortCut = 16440
+      end    
+      item
+        Command = ecGotoMarker9
+        ShortCut = 16441
+      end    
+      item
+        Command = ecSetMarker0
+        ShortCut = 24624
+      end    
+      item
+        Command = ecSetMarker1
+        ShortCut = 24625
+      end    
+      item
+        Command = ecSetMarker2
+        ShortCut = 24626
+      end    
+      item
+        Command = ecSetMarker3
+        ShortCut = 24627
+      end    
+      item
+        Command = ecSetMarker4
+        ShortCut = 24628
+      end    
+      item
+        Command = ecSetMarker5
+        ShortCut = 24629
+      end    
+      item
+        Command = ecSetMarker6
+        ShortCut = 24630
+      end    
+      item
+        Command = ecSetMarker7
+        ShortCut = 24631
+      end    
+      item
+        Command = ecSetMarker8
+        ShortCut = 24632
+      end    
+      item
+        Command = ecSetMarker9
+        ShortCut = 24633
+      end    
+      item
+        Command = EcFoldLevel1
+        ShortCut = 41009
+      end    
+      item
+        Command = EcFoldLevel2
+        ShortCut = 41010
+      end    
+      item
+        Command = EcFoldLevel1
+        ShortCut = 41011
+      end    
+      item
+        Command = EcFoldLevel1
+        ShortCut = 41012
+      end    
+      item
+        Command = EcFoldLevel1
+        ShortCut = 41013
+      end    
+      item
+        Command = EcFoldLevel6
+        ShortCut = 41014
+      end    
+      item
+        Command = EcFoldLevel7
+        ShortCut = 41015
+      end    
+      item
+        Command = EcFoldLevel8
+        ShortCut = 41016
+      end    
+      item
+        Command = EcFoldLevel9
+        ShortCut = 41017
+      end    
+      item
+        Command = EcFoldLevel0
+        ShortCut = 41008
+      end    
+      item
+        Command = EcFoldCurrent
+        ShortCut = 41005
+      end    
+      item
+        Command = EcUnFoldCurrent
+        ShortCut = 41003
+      end    
+      item
+        Command = EcToggleMarkupWord
+        ShortCut = 32845
+      end    
+      item
+        Command = ecNormalSelect
+        ShortCut = 24654
+      end    
+      item
+        Command = ecColumnSelect
+        ShortCut = 24643
+      end    
+      item
+        Command = ecLineSelect
+        ShortCut = 24652
+      end    
+      item
+        Command = ecTab
+        ShortCut = 9
+      end    
+      item
+        Command = ecShiftTab
+        ShortCut = 8201
+      end    
+      item
+        Command = ecMatchBracket
+        ShortCut = 24642
+      end    
+      item
+        Command = ecColSelUp
+        ShortCut = 40998
+      end    
+      item
+        Command = ecColSelDown
+        ShortCut = 41000
+      end    
+      item
+        Command = ecColSelLeft
+        ShortCut = 40997
+      end    
+      item
+        Command = ecColSelRight
+        ShortCut = 40999
+      end    
+      item
+        Command = ecColSelPageDown
+        ShortCut = 40994
+      end    
+      item
+        Command = ecColSelPageBottom
+        ShortCut = 57378
+      end    
+      item
+        Command = ecColSelPageUp
+        ShortCut = 40993
+      end    
+      item
+        Command = ecColSelPageTop
+        ShortCut = 57377
+      end    
+      item
+        Command = ecColSelLineStart
+        ShortCut = 40996
+      end    
+      item
+        Command = ecColSelLineEnd
+        ShortCut = 40995
+      end    
+      item
+        Command = ecColSelEditorTop
+        ShortCut = 57380
+      end    
+      item
+        Command = ecColSelEditorBottom
+        ShortCut = 57379
+      end>
+    MouseActions = <>
+    MouseSelActions = <>
+    Lines.Strings = (
+      '{,BGRAScript}'
+      'FillTransparent'
+      ''
+      '//,SetHorizLine,10,10,100,"rgba(0,0,0,255)"'
+      '//,SetVertLine,10,10,100,"rgba(0,0,0,255)"'
+      '//,RectangleAntiAlias,"0,5","0,5","99,5","99,5","rgba(0,0,0,255)","1,5","rgba(255,255,255,255)"'
+      ''
+      'Rectangle,0,0,100,100,"rgba(0,0,0,255)","rgba(255,255,255,255)"'
+      'SaveToFile,"file.png"'
+    )
+    VisibleSpecialChars = [vscSpace, vscTabAtLast]
+    SelectedColor.FrameEdges = sfeAround
+    SelectedColor.BackPriority = 50
+    SelectedColor.ForePriority = 50
+    SelectedColor.FramePriority = 50
+    SelectedColor.BoldPriority = 50
+    SelectedColor.ItalicPriority = 50
+    SelectedColor.UnderlinePriority = 50
+    SelectedColor.StrikeOutPriority = 50
+    IncrementColor.FrameEdges = sfeAround
+    HighlightAllColor.FrameEdges = sfeAround
+    BracketHighlightStyle = sbhsBoth
+    BracketMatchColor.Background = clNone
+    BracketMatchColor.Foreground = clNone
+    BracketMatchColor.FrameEdges = sfeAround
+    BracketMatchColor.Style = [fsBold]
+    FoldedCodeColor.Background = clNone
+    FoldedCodeColor.Foreground = clGray
+    FoldedCodeColor.FrameColor = clGray
+    FoldedCodeColor.FrameEdges = sfeAround
+    MouseLinkColor.Background = clNone
+    MouseLinkColor.Foreground = clBlue
+    MouseLinkColor.FrameEdges = sfeAround
+    LineHighlightColor.Background = clNone
+    LineHighlightColor.Foreground = clNone
+    LineHighlightColor.FrameEdges = sfeAround
+    inline SynLeftGutterPartList1: TSynGutterPartList
+      object SynGutterMarks1: TSynGutterMarks
+        Width = 24
+        MouseActions = <>
+      end
+      object SynGutterLineNumber1: TSynGutterLineNumber
+        Width = 21
+        MouseActions = <>
+        MarkupInfo.Background = clBtnFace
+        MarkupInfo.Foreground = clNone
+        MarkupInfo.FrameEdges = sfeAround
+        DigitCount = 2
+        ShowOnlyLineNumbersMultiplesOf = 1
+        ZeroStart = False
+        LeadingZeros = False
+      end
+      object SynGutterChanges1: TSynGutterChanges
+        Width = 4
+        MouseActions = <>
+        ModifiedColor = 59900
+        SavedColor = clGreen
+      end
+      object SynGutterSeparator1: TSynGutterSeparator
+        Width = 2
+        MouseActions = <>
+        MarkupInfo.Background = clWhite
+        MarkupInfo.Foreground = clGray
+        MarkupInfo.FrameEdges = sfeAround
+      end
+      object SynGutterCodeFolding1: TSynGutterCodeFolding
+        MouseActions = <>
+        MarkupInfo.Background = clNone
+        MarkupInfo.Foreground = clGray
+        MarkupInfo.FrameEdges = sfeAround
+        MouseActionsExpanded = <>
+        MouseActionsCollapsed = <>
+      end
+    end
+  end
+  object Splitter1: TSplitter
+    Cursor = crVSplit
+    Left = 0
+    Height = 5
+    Top = 232
+    Width = 1050
+    Align = alBottom
+    ResizeAnchor = akBottom
+  end
+  object SynCompletion1: TSynCompletion
+    Position = 0
+    LinesInWindow = 6
+    SelectedColor = clHighlight
+    CaseSensitive = False
+    Width = 500
+    LongLineHintType = sclpNone
+    ShortCut = 16416
+    EndOfTokenChr = '()[].'
+    ExecCommandID = ecSynCompletionExecute
+    Editor = SynEdit1
+    left = 664
+    top = 248
+  end
+  object SynAnySyn1: TSynAnySyn
+    CommentAttri.Foreground = clGreen
+    CommentAttri.FrameEdges = sfeAround
+    Comments = [csPasStyle]
+    DetectPreprocessor = False
+    IdentifierAttri.FrameEdges = sfeAround
+    IdentifierChars = '!"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
+    KeyAttri.FrameEdges = sfeAround
+    ConstantAttri.FrameEdges = sfeAround
+    ObjectAttri.FrameEdges = sfeAround
+    EntityAttri.FrameEdges = sfeAround
+    VariableAttri.FrameEdges = sfeAround
+    DotAttri.FrameEdges = sfeAround
+    NumberAttri.Foreground = clMaroon
+    NumberAttri.FrameEdges = sfeAround
+    PreprocessorAttri.FrameEdges = sfeAround
+    SpaceAttri.FrameEdges = sfeAround
+    StringAttri.Foreground = 16744448
+    StringAttri.FrameEdges = sfeAround
+    SymbolAttri.Foreground = 4227327
+    SymbolAttri.FrameEdges = sfeAround
+    StringDelim = sdDoubleQuote
+    Markup = False
+    Entity = False
+    DollarVariables = False
+    ActiveDot = False
+    left = 220
+    top = 111
+  end
+end

+ 57 - 0
test/test_bgrascript/umain.pas

@@ -0,0 +1,57 @@
+unit umain;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, FileUtil, SynEdit, SynCompletion, SynHighlighterAny, Forms,
+  Controls, Graphics, Dialogs, ExtCtrls, BGRAGraphicControl, BGRABitmap,
+  BCTypes, BGRAScript;
+
+type
+
+  { TForm1 }
+
+  TForm1 = class(TForm)
+    BGRAGraphicControl1: TBGRAGraphicControl;
+    Splitter1: TSplitter;
+    SynAnySyn1: TSynAnySyn;
+    SynCompletion1: TSynCompletion;
+    SynEdit1: TSynEdit;
+    procedure BGRAGraphicControl1Click(Sender: TObject);
+    procedure BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
+    procedure FormCreate(Sender: TObject);
+  private
+    { private declarations }
+  public
+    { public declarations }
+  end;
+
+var
+  Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+
+procedure TForm1.BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
+begin
+  BGRAScript.ScriptCommandList(SynEdit1.Lines, Bitmap);
+end;
+
+procedure TForm1.BGRAGraphicControl1Click(Sender: TObject);
+begin
+  BGRAGraphicControl1.DiscardBitmap;
+end;
+
+procedure TForm1.FormCreate(Sender: TObject);
+begin
+  BGRAScript.SynCompletionList(SynCompletion1.ItemList);
+end;
+
+end.
+
+