Ignore:
Timestamp:
May 6, 2019, 11:03:00 AM (6 years ago)
Author:
chronos
Message:
  • Added: TargetCode form use SynEdit for syntax highlighting.
  • Fixed: Do not show error if specific target doesn't have assigned compiler. Not all targets use compiler. Some of them are just interpreted.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormTargetCode.pas

    r91 r106  
    66
    77uses
    8   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   Menus, ActnList, strutils;
     8  Classes, SysUtils, FileUtil, SynEdit, SynHighlighterAny, SynHighlighterPas,
     9  SynHighlighterCpp, SynHighlighterPHP, SynHighlighterJava,
     10  SynHighlighterPython, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
     11  ActnList, strutils;
    1012
    1113type
     
    1719    AFormatCode: TAction;
    1820    ActionList1: TActionList;
    19     MemoTarget: TMemo;
    2021    MenuItem1: TMenuItem;
    2122    MenuItem20: TMenuItem;
    2223    PopupMenuTarget: TPopupMenu;
     24    SynEditTarget: TSynEdit;
    2325    procedure AFormatCodeExecute(Sender: TObject);
    2426    procedure AShrinkCodeExecute(Sender: TObject);
     
    2628    { private declarations }
    2729  public
    28     { public declarations }
     30    procedure SetHighlighter(SourceExt: string);
    2931  end;
    3032
     
    4749  IndentText = '  ';
    4850begin
    49   Source := MemoTarget.Text;
     51  Source := SynEditTarget.Text;
    5052  NewSource := '';
    5153  Indent := 0;
     
    6365      NewSource := NewSource + Source[I];
    6466  end;
    65   MemoTarget.Text := NewSource;
     67  SynEditTarget.Text := NewSource;
    6668end;
    6769
     
    7274  I: Integer;
    7375begin
    74   Source := MemoTarget.Text;
     76  Source := SynEditTarget.Text;
    7577  Pos := 1;
    7678  for I := 1 to Length(Source) do begin
     
    8183  end;
    8284  SetLength(Source, Pos - 1);
    83   MemoTarget.Text := Source;
     85  SynEditTarget.Text := Source;
     86end;
     87
     88procedure TFormTargetCode.SetHighlighter(SourceExt: string);
     89begin
     90  if Assigned(SynEditTarget.Highlighter) then
     91    SynEditTarget.Highlighter.Free;
     92  if SourceExt = '.pas' then SynEditTarget.Highlighter := TSynPasSyn.Create(nil)
     93  else if SourceExt = '.c' then SynEditTarget.Highlighter := TSynCppSyn.Create(nil)
     94  else if SourceExt = '.php' then SynEditTarget.Highlighter := TSynPhpSyn.Create(nil)
     95  else if SourceExt = '.java' then SynEditTarget.Highlighter := TSynJavaSyn.Create(nil)
     96  else if SourceExt = '.py' then SynEditTarget.Highlighter := TSynPythonSyn.Create(nil);
    8497end;
    8598
Note: See TracChangeset for help on using the changeset viewer.