Ignore:
Timestamp:
Aug 10, 2010, 1:48:38 PM (14 years ago)
Author:
george
Message:

Fix: View proper source file after click to error message.
Made partial changes to support unit interface and implementation sections.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/Forms/UMainForm.pas

    r54 r55  
    2020    ButtonCompile: TButton;
    2121    ComboBox1: TComboBox;
    22     ListBox1: TListBox;
     22    ListBoxMessages: TListBox;
    2323    Panel1: TPanel;
    24     SynEdit1: TSynEdit;
     24    SynEditSource: TSynEdit;
    2525    SynPasSyn1: TSynPasSyn;
    2626    TreeViewProject: TTreeView;
     
    3131    procedure FormCreate(Sender: TObject);
    3232    procedure FormDestroy(Sender: TObject);
    33     procedure ListBox1Click(Sender: TObject);
     33    procedure ListBoxMessagesClick(Sender: TObject);
    3434    procedure TreeViewProjectChange(Sender: TObject; Node: TTreeNode);
    3535  private
     
    7979
    8080  // Compile all project files
     81  Compiler.Init;
    8182  for I := 0 to Project.Items.Count - 1 do begin
    82     if TProjectNode(Project.Items[I]) is TProjectFile then begin
    83       Compiler.Compile(TProjectFile(Project.Items[I]).Source,
    84         TProjectFile(Project.Items[I]).ProducedCode);
     83    if TProjectNode(Project.Items[I]) is TProjectFile then
     84    with TProjectFile(Project.Items[I]) do begin
     85      Compiler.Compile(Parent.GetDir + Name, Source, ProducedCode);
    8586    end;
    8687  end;
     
    113114end;
    114115
    115 procedure TMainForm.ListBox1Click(Sender: TObject);
    116 begin
    117   if ListBox1.ItemIndex <> - 1 then begin
    118     SynEdit1.CaretXY := TErrorMessage(Compiler.ErrorMessages[ListBox1.ItemIndex]).Position;
    119     SynEdit1.SetFocus;
     116procedure TMainForm.ListBoxMessagesClick(Sender: TObject);
     117var
     118  ProjectFile: TProjectFile;
     119begin
     120  if ListBoxMessages.ItemIndex <> -1 then
     121  with TErrorMessage(Compiler.ErrorMessages[ListBoxMessages.ItemIndex]) do begin
     122    ProjectFile := Project.SearchFile(fileName);
     123    if Assigned(ProjectFile) then
     124      SynEditSource.Lines.Assign(ProjectFile.Source);
     125    SynEditSource.CaretXY := Position;
     126    SynEditSource.SetFocus;
    120127  end;
    121128end;
     
    125132  I: Integer;
    126133begin
    127   ListBox1.Clear;
     134  ListBoxMessages.Clear;
    128135  for I := 0 to Compiler.ErrorMessages.Count - 1 do
    129136  with TErrorMessage(Compiler.ErrorMessages[I]) do
    130     MainForm.ListBox1.Items.Add('(' + IntToStr(Position.X) +
     137    MainForm.ListBoxMessages.Items.Add(FileName + '(' + IntToStr(Position.X) +
    131138      ',' + IntToStr(Position.Y) + ') ' + Text);
    132139end;
     
    136143  if Assigned(Node) then begin
    137144    if TProjectNode(Node.Data) is TProjectFile then begin
    138       SynEdit1.Lines.Assign(TProjectFile(Node.Data).Source);
     145      SynEditSource.Lines.Assign(TProjectFile(Node.Data).Source);
    139146      if ProducerControl is TMemo then
    140147        TMemo(ProducerControl).Lines.Assign(TProjectFile(Node.Data).ProducedCode);
     
    193200  NewProjectFile: TProjectFile;
    194201begin
     202  Project.RootDir := '../../Project/';
    195203  Project.Name := 'Project';
     204
    196205  NewProjectFile := TProjectFile.Create;
     206  NewProjectFile.Parent := Project;
    197207  NewProjectFile.Name := 'Project.pas';
    198   NewProjectFile.FileName := ProjectDir + 'Project.pas';
    199208  Project.Items.Add(NewProjectFile);
     209
    200210  NewProjectFile := TProjectFile.Create;
     211  NewProjectFile.Parent := Project;
    201212  NewProjectFile.Name := 'System.pas';
    202   NewProjectFile.FileName := ProjectDir + 'System.pas';
    203213  Project.Items.Add(NewProjectFile);
     214
     215  NewProjectFile := TProjectFile.Create;
     216  NewProjectFile.Parent := Project;
     217  NewProjectFile.Name := 'Console.pas';
     218  Project.Items.Add(NewProjectFile);
     219
    204220  Project.Load;
    205221  UpdateProjectTree;
Note: See TracChangeset for help on using the changeset viewer.