Ignore:
Timestamp:
Aug 9, 2010, 2:24:24 PM (14 years ago)
Author:
george
Message:

Added support for setting cursor position to place of error code for error messages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/UMainForm.pas

    r46 r49  
    99  Dialogs, StdCtrls, UPascalSource, UPascalCompiler, UAssemblerSource,
    1010  UProducerC, ComCtrls, SynEdit, SynHighlighterPas, USourceTree,
    11   UProducerPascal;
     11  UProducerPascal, Contnrs;
    1212
    1313const
     
    1515
    1616type
    17 
    1817  { TMainForm }
    1918
     
    2120    Button1: TButton;
    2221    ComboBox1: TComboBox;
     22    ListBox1: TListBox;
    2323    Memo2: TMemo;
    24     Memo3: TMemo;
    2524    SynEdit1: TSynEdit;
    2625    SynPasSyn1: TSynPasSyn;
     
    3231    procedure FormCreate(Sender: TObject);
    3332    procedure FormDestroy(Sender: TObject);
    34     procedure ErrorMessage(Text: string);
     33    procedure ListBox1Click(Sender: TObject);
     34    procedure LoadErrorMessages;
    3535  private
    3636  public
     
    5252  I: Integer;
    5353begin
    54   MainForm.Memo3.Clear;
     54  MainForm.ListBox1.Clear;
    5555  Compiler.SourceCode.Assign(SynEdit1.Lines);
    5656
     
    8181      Memo2.Lines.Add(TAssemblerLine(AssemblyCode[I]).AsString);
    8282  end;
     83  LoadErrorMessages;
    8384
    8485  SourceTree.TreeView := TreeView1;
     
    8788end;
    8889
    89 procedure TMainForm.ErrorMessage(Text: string);
     90procedure TMainForm.ListBox1Click(Sender: TObject);
    9091begin
    91   MainForm.Memo3.Lines.Add(Text);
     92  if ListBox1.ItemIndex <> - 1 then begin
     93    SynEdit1.CaretXY := TErrorMessage(Compiler.ErrorMessages[ListBox1.ItemIndex]).Position;
     94    SynEdit1.SetFocus;
     95  end;
     96end;
     97
     98procedure TMainForm.LoadErrorMessages;
     99var
     100  I: Integer;
     101begin
     102  ListBox1.Clear;
     103  for I := 0 to Compiler.ErrorMessages.Count - 1 do
     104  with TErrorMessage(Compiler.ErrorMessages[I]) do
     105    MainForm.ListBox1.Items.Add('(' + IntToStr(Position.X) +
     106      ',' + IntToStr(Position.Y) + ') ' + Text);
    92107end;
    93108
     
    100115begin
    101116  Compiler := TCompiler.Create;
    102   Compiler.OnErrorMessage := ErrorMessage;
    103117  SourceTree := TSourceTree.Create;
    104118end;
Note: See TracChangeset for help on using the changeset viewer.