root/trunk/UOutputDlg.pas

Revision 7, 2.5 kB (checked in by DavidM, 7 years ago)

Added a folder remotely

Line 
1 unit UOutputDlg;
2
3 interface
4
5 uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
6   Buttons, ExtCtrls, Projects;
7
8 type
9   TOutputDlg = class(TForm)
10     CancelBtn: TButton;
11     Bevel1: TBevel;
12     Listbox: TListBox;
13     procedure ListboxDblClick(Sender: TObject);
14   private
15     { Private declarations }
16   public
17     { Public declarations }
18     project : TProject;
19
20     function ShowMoreOutput( pr: TProject ; list : TStringList ; title : string ) : Integer;
21     function ShowOutput( pr: TProject ;list : TStringList; title:string ) : Integer;
22   end;
23
24 var
25   OutputDlg: TOutputDlg;
26
27
28 implementation
29
30 {$R *.DFM}
31
32 uses Workspaces, MyUtils, UMain;
33
34 type  ErrorLineInfo = record
35         path : string;
36         lineno : Integer ;
37       end;
38
39
40 function GetLineInfo( line : string ) : ErrorLineInfo;
41 var
42   line_no : Integer;
43   lparen, rparen : Integer;
44   filename : string;
45 begin
46   result.path := '';
47   result.lineno := -1;
48   line := Trim( line );
49
50   if Length( line ) < 1 then Exit;
51
52   lparen := Pos( '(', line );
53   rparen := Pos( ')', line );
54   if (lparen<1) or (rparen<1) or (lparen>rparen) then Exit;
55   filename := Copy( line, 1, lparen-1 );
56
57   line_no:=-1;
58   if not MyUtils.ParseInt( Copy( line, lparen+1, rparen-lparen-1 ), line_no )
59     then Exit;
60    
61   if line_no < 1 then Exit;
62
63   if not FileExists( filename ) then
64      filename := OutputDlg.project.FindFilePath( filename );
65
66   if not FileExists( filename ) then Exit;
67
68   result.path := filename;
69   result.lineno := line_no;
70 end;
71
72
73 function TOutputDlg.ShowMoreOutput( pr: TProject ; list : TStringList ; title : string ) : Integer;
74 begin
75   project := pr;
76   self.Caption := title;
77   TrimAll( list );
78   if list.Count = 0 then list.Add( '<no output>' );
79   ListBox.Items.AddStrings( list );
80   Result:=Self.ShowModal;
81   Exit;
82 end;
83
84 function TOutputDlg.ShowOutput( pr: TProject; list: TStringList ; title : string ) : Integer;
85 begin
86   Listbox.Items.Clear;
87   result:=ShowMoreOutput( pr, list, title );
88 end;
89
90 procedure TOutputDlg.ListboxDblClick(Sender: TObject);
91 var
92   N : Integer;
93   ws : TWorkspace;
94   info : ErrorLineInfo;
95 begin
96   for N:=0 to ListBox.Items.Count-1 do begin
97       if ListBox.Selected[N] then begin
98         info := GetLineInfo( Listbox.items[N] );
99         if FileExists( info.path ) then
100         begin
101           ws := TWorkspace(project.parent);
102           ws.EditFile( info.path, info.lineno );
103         end;
104         Exit;
105       end;
106   end;
107 end;
108
109 end.
Note: See TracBrowser for help on using the browser.