• R/O
  • SSH
  • HTTPS

dzlargetextview: Commit


Commit MetaInfo

Revision245 (tree)
Zeit2013-02-17 20:34:14
Autortwm

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- dzlib/trunk/tools/LargeTextViewer/src/LargeTextViewer.dpr (revision 244)
+++ dzlib/trunk/tools/LargeTextViewer/src/LargeTextViewer.dpr (nonexistent)
@@ -1,16 +0,0 @@
1-program LargeTextViewer;
2-
3-uses
4- Forms,
5- w_LargeTextViewer in 'w_LargeTextViewer.pas' {f_LargeTextViewer},
6- u_TextFileIndexer in 'u_TextFileIndexer.pas',
7- u_Int64List in 'u_Int64List.pas';
8-
9-{$R *.res}
10-
11-begin
12- Application.Initialize;
13- Application.MainFormOnTaskbar := True;
14- Application.CreateForm(Tf_LargeTextViewer, f_LargeTextViewer);
15- Application.Run;
16-end.
--- dzlib/trunk/tools/LargeTextViewer/src/u_Int64List.pas (revision 244)
+++ dzlib/trunk/tools/LargeTextViewer/src/u_Int64List.pas (nonexistent)
@@ -1,78 +0,0 @@
1-unit u_Int64List;
2-
3-interface
4-
5-uses
6- SysUtils,
7- Classes,
8- u_dzTranslator;
9-
10-type
11- TInt64List = class
12- private
13- FData: array of Int64;
14- FCapacity: integer;
15- FCount: integer;
16- procedure Grow;
17- procedure SetCapacity(_NewCapacity: Integer);
18- function GetItems(_Idx: integer): Int64;
19- procedure SetItems(_Idx: integer; const Value: Int64);
20- public
21- function Add(_Value: Int64): integer;
22- property Items[_Idx: integer]: Int64 read GetItems write SetItems;
23- property Count: integer read FCount;
24- end;
25-
26-implementation
27-
28-uses
29- RTLConsts;
30-
31-{ TInt64List }
32-
33-function TInt64List.Add(_Value: Int64): integer;
34-begin
35- Result := FCount;
36- if Result = FCapacity then
37- Grow;
38- FData[Result] := _Value;
39- Inc(FCount);
40-end;
41-
42-procedure TInt64List.Grow;
43-var
44- Delta: Integer;
45-begin
46- if FCapacity > 64 then
47- Delta := FCapacity div 4
48- else if FCapacity > 8 then
49- Delta := 16
50- else
51- Delta := 4;
52- SetCapacity(FCapacity + Delta);
53-end;
54-
55-procedure TInt64List.SetCapacity(_NewCapacity: Integer);
56-begin
57- if (_NewCapacity < FCount) or (_NewCapacity > MaxListSize) then
58- raise Exception.CreateFmt(_('List capacity out of bounds (%d)'), [_NewCapacity]);
59- if _NewCapacity <> FCapacity then begin
60- SetLength(FData, _NewCapacity);
61- FCapacity := _NewCapacity;
62- end;
63-end;
64-
65-function TInt64List.GetItems(_Idx: integer): Int64;
66-begin
67- if (_Idx < 0) or (_Idx >= FCount) then
68- raise Exception.CreateFmt(_('List index out of bounds (%d)'), [_Idx]);
69- Result := FData[_Idx];
70-end;
71-
72-procedure TInt64List.SetItems(_Idx: integer; const Value: Int64);
73-begin
74-
75-end;
76-
77-end.
78-
--- dzlib/trunk/tools/LargeTextViewer/src/w_LargeTextViewer.pas (revision 244)
+++ dzlib/trunk/tools/LargeTextViewer/src/w_LargeTextViewer.pas (nonexistent)
@@ -1,169 +0,0 @@
1-unit w_LargeTextViewer;
2-
3-interface
4-
5-uses
6- Windows,
7- Messages,
8- SysUtils,
9- Variants,
10- Classes,
11- Graphics,
12- Controls,
13- Forms,
14- Dialogs,
15- Grids,
16- c_dzVirtualStringGrid,
17- u_dzTranslator,
18- u_TextFileIndexer,
19- u_dzNamedThread,
20- u_dzFileStreams,
21- ExtCtrls,
22- ComCtrls,
23- Menus;
24-
25-type
26- TIndexerThread = class(TNamedThread)
27- private
28- FIndexer: TTextFileIndexer;
29- protected
30- constructor Create(_Indexer: TTextFileIndexer);
31- procedure Execute; override;
32- end;
33-
34-type
35- Tf_LargeTextViewer = class(TForm)
36- sg_Display: TdzVirtualStringGrid;
37- tim_Update: TTimer;
38- TheStatusBar: TStatusBar;
39- TheMainMenu: TMainMenu;
40- mi_File: TMenuItem;
41- mi_Open: TMenuItem;
42- mi_Exit: TMenuItem;
43- TheOpenDialog: TOpenDialog;
44- procedure sg_DisplayGetNonfixedCellData(_Sender: TObject; _DataCol, _DataRow: Integer;
45- _State: TGridDrawState; var _Text: string; var _HAlign: TAlignment;
46- var _VAlign: TdzCellVertAlign; _Font: TFont; var _Color: TColor);
47- procedure sg_DisplayResize(Sender: TObject);
48- procedure tim_UpdateTimer(Sender: TObject);
49- procedure mi_OpenClick(Sender: TObject);
50- procedure mi_ExitClick(Sender: TObject);
51- private
52- FIndexer: TTextFileIndexer;
53- FIndexThread: TIndexerThread;
54- FFile: TdzFile;
55- procedure OpenFile;
56- public
57- constructor Create(_Owner: TComponent); override;
58- destructor Destroy; override;
59- procedure LoadFile(const _Filename: string);
60- end;
61-
62-var
63- f_LargeTextViewer: Tf_LargeTextViewer;
64-
65-implementation
66-
67-{$R *.dfm}
68-
69-uses
70- u_dzClassUtils;
71-
72-{ TIndexerThread }
73-
74-constructor TIndexerThread.Create(_Indexer: TTextFileIndexer);
75-begin
76- FIndexer := _Indexer;
77- inherited Create(false);
78-end;
79-
80-procedure TIndexerThread.Execute;
81-begin
82- inherited;
83- try
84- FIndexer.Execute;
85- except
86- on EAbort do
87- // itnore;
88- else
89- raise;
90- end;
91-end;
92-
93-constructor Tf_LargeTextViewer.Create(_Owner: TComponent);
94-begin
95- inherited;
96- OpenFile;
97-end;
98-
99-destructor Tf_LargeTextViewer.Destroy;
100-begin
101- FreeAndNil(FFile);
102- if Assigned(FIndexer) then
103- FIndexer.Abort;
104- FreeAndNil(FIndexThread);
105- inherited;
106-end;
107-
108-procedure Tf_LargeTextViewer.LoadFile(const _Filename: string);
109-begin
110- FIndexer := TTextFileIndexer.Create(_Filename);
111- FIndexThread := TIndexerThread.Create(FIndexer);
112- tim_Update.Enabled := true;
113- FFile := TdzFile.Create(_Filename);
114- FFile.OpenReadonly;
115-end;
116-
117-procedure Tf_LargeTextViewer.mi_ExitClick(Sender: TObject);
118-begin
119- Close;
120-end;
121-
122-procedure Tf_LargeTextViewer.OpenFile;
123-begin
124- TheOpenDialog.Filter := 'all files (*.*)|*.*';
125- if not TheOpenDialog.Execute then
126- exit;
127- LoadFile(TheOpenDialog.FileName);
128-end;
129-
130-procedure Tf_LargeTextViewer.mi_OpenClick(Sender: TObject);
131-begin
132- OpenFile;
133-end;
134-
135-procedure Tf_LargeTextViewer.sg_DisplayGetNonfixedCellData(_Sender: TObject; _DataCol, _DataRow: Integer;
136- _State: TGridDrawState; var _Text: string; var _HAlign: TAlignment; var _VAlign: TdzCellVertAlign;
137- _Font: TFont; var _Color: TColor);
138-var
139- SeekIdx: Int64;
140- s: string;
141-begin
142- if not Assigned(FIndexer) or (FIndexer.LineIndexCount < _DataRow) then
143- exit;
144- SeekIdx := FIndexer.LineIndex[_DataRow];
145- FFile.Position := SeekIdx;
146- TStream_ReadStringLn(FFile, s);
147- _Text := s;
148-end;
149-
150-procedure Tf_LargeTextViewer.sg_DisplayResize(Sender: TObject);
151-begin
152- sg_Display.ColWidths[0] := sg_Display.ClientWidth;
153-end;
154-
155-procedure Tf_LargeTextViewer.tim_UpdateTimer(Sender: TObject);
156-var
157- LineCount: integer;
158-begin
159- LineCount := FIndexer.LineIndexCount;
160- sg_Display.RowCount := LineCount;
161- if FIndexer.isDone then begin
162- tim_Update.Enabled := false;
163- TheStatusBar.SimpleText := Format(_('%d lines'), [LineCount]);
164- end else
165- TheStatusBar.SimpleText := Format(_('Indexing (%d lines)'), [LineCount]);
166-end;
167-
168-end.
169-
--- dzlib/trunk/tools/LargeTextViewer/src/u_TextFileIndexer.pas (revision 244)
+++ dzlib/trunk/tools/LargeTextViewer/src/u_TextFileIndexer.pas (nonexistent)
@@ -1,121 +0,0 @@
1-unit u_TextFileIndexer;
2-
3-interface
4-
5-uses
6- SysUtils,
7- Classes,
8- u_Int64List,
9- u_dzCriticalSection;
10-
11-type
12- TTextFileIndexer = class
13- private
14- FCritSect: TdzCriticalSection;
15- FLineIndexes: TInt64List;
16- FIsDone: boolean;
17- FFilename: string;
18- FAbortRequested: Boolean;
19- function GetLineIndex(_Idx: integer): Int64;
20- function GetLineIndexCount: integer;
21- public
22- constructor Create(const _Filename: string);
23- destructor Destroy; override;
24- procedure Execute;
25- procedure Abort;
26- property LineIndex[_Idx: integer]: Int64 read GetLineIndex;
27- property LineIndexCount: integer read GetLineIndexCount;
28- property isDone: boolean read FIsDone;
29- end;
30-
31-implementation
32-
33-uses
34- u_dzFileStreams;
35-
36-{ TTextFileIndexer }
37-
38-constructor TTextFileIndexer.Create(const _Filename: string);
39-begin
40- inherited Create;
41- FLineIndexes := TInt64List.Create;
42- FFilename := _Filename;
43- FCritSect := TdzCriticalSection.Create;
44-end;
45-
46-destructor TTextFileIndexer.Destroy;
47-begin
48- FreeAndNil(FCritSect);
49- FreeAndNil(FLineIndexes);
50- inherited;
51-end;
52-
53-procedure TTextFileIndexer.Execute;
54-const
55- BUFFER_SIZE = 1024 * 128;
56-var
57- st: TdzFile;
58- buffer: array[0..BUFFER_SIZE - 1] of char;
59- Offset: Int64;
60- BytesRead: Integer;
61- i: Integer;
62-begin
63- FAbortRequested := False;
64- FIsDone := False;
65- st := TdzFile.Create(FFilename);
66- try
67- st.OpenReadonly;
68- FCritSect.Enter;
69- try
70- FLineIndexes.Add(0);
71- finally
72- FCritSect.Leave;
73- end;
74- while not st.EOF do begin
75- Offset := st.Position;
76- BytesRead := st.Read(Buffer, SizeOf(Buffer));
77- for i := 0 to BytesRead - 1 do
78- if buffer[i] = #10 then begin
79- FCritSect.Enter;
80- try
81- FLineIndexes.Add(Offset + i + 1);
82- finally
83- FCritSect.Leave;
84- end;
85- end;
86- if FAbortRequested then
87- SysUtils.Abort;
88- end;
89- finally
90- FreeAndNil(st);
91- end;
92- FIsDone := true;
93-end;
94-
95-function TTextFileIndexer.GetLineIndex(_Idx: integer): Int64;
96-begin
97- FCritSect.Enter;
98- try
99- Result := FLineIndexes.Items[_Idx];
100- finally
101- FCritSect.Leave;
102- end;
103-end;
104-
105-function TTextFileIndexer.GetLineIndexCount: integer;
106-begin
107- FCritSect.Enter;
108- try
109- Result := FLineIndexes.Count;
110- finally
111- FCritSect.Leave;
112- end;
113-end;
114-
115-procedure TTextFileIndexer.Abort;
116-begin
117- FAbortRequested := true;
118-end;
119-
120-end.
121-
--- dzlib/trunk/tools/LargeTextViewer/src/LargeTextViewer.dproj (revision 244)
+++ dzlib/trunk/tools/LargeTextViewer/src/LargeTextViewer.dproj (nonexistent)
@@ -1,288 +0,0 @@
1-<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2- <PropertyGroup>
3- <ProjectGuid>{b6113310-a312-491b-823e-3a1e137966ec}</ProjectGuid>
4- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6- <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
7- <DCC_DependencyCheckOutputName>..\LargeTextViewer.exe</DCC_DependencyCheckOutputName>
8- <MainSource>LargeTextViewer.dpr</MainSource>
9- </PropertyGroup>
10- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
11- <Version>7.0</Version>
12- <DCC_DebugInformation>False</DCC_DebugInformation>
13- <DCC_LocalDebugSymbols>False</DCC_LocalDebugSymbols>
14- <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
15- <DCC_Define>RELEASE</DCC_Define>
16- </PropertyGroup>
17- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18- <Version>7.0</Version>
19- <DCC_Optimize>False</DCC_Optimize>
20- <DCC_ExeOutput>..</DCC_ExeOutput>
21- <DCC_DcuOutput>..\dcu</DCC_DcuOutput>
22- <DCC_ObjOutput>..\dcu</DCC_ObjOutput>
23- <DCC_HppOutput>..\dcu</DCC_HppOutput>
24- <DCC_UnitSearchPath>$(BDS)\lib\Debug;..\..\..\src;..\..\..\..\jcl\source\include;..\..\..\..\jcl\source\common;..\..\..\..\jcl\source\windows;..\..\..\..\jcl\source\include\jedi;..\..\..\jvcl\common;..\..\libs\jvcl\run;..\..\libs\jvcl\resources;..\..\..\components;..\..\..\templates</DCC_UnitSearchPath>
25- <DCC_ResourcePath>$(BDS)\lib\Debug;..\..\..\src;..\..\..\..\jcl\source\include;..\..\..\..\jcl\source\common;..\..\..\..\jcl\source\windows;..\..\..\..\jcl\source\include\jedi;..\..\..\jvcl\common;..\..\libs\jvcl\run;..\..\libs\jvcl\resources;..\..\..\components;..\..\..\templates</DCC_ResourcePath>
26- <DCC_ObjPath>$(BDS)\lib\Debug;..\..\..\src;..\..\..\..\jcl\source\include;..\..\..\..\jcl\source\common;..\..\..\..\jcl\source\windows;..\..\..\..\jcl\source\include\jedi;..\..\..\jvcl\common;..\..\libs\jvcl\run;..\..\libs\jvcl\resources;..\..\..\components;..\..\..\templates</DCC_ObjPath>
27- <DCC_IncludePath>$(BDS)\lib\Debug;..\..\..\src;..\..\..\..\jcl\source\include;..\..\..\..\jcl\source\common;..\..\..\..\jcl\source\windows;..\..\..\..\jcl\source\include\jedi;..\..\..\jvcl\common;..\..\libs\jvcl\run;..\..\libs\jvcl\resources;..\..\..\components;..\..\..\templates</DCC_IncludePath>
28- <DCC_Define>DEBUG;NO_TRANSLATION</DCC_Define>
29- <DCC_SYMBOL_PLATFORM>False</DCC_SYMBOL_PLATFORM>
30- <DCC_UNIT_PLATFORM>False</DCC_UNIT_PLATFORM>
31- </PropertyGroup>
32- <ProjectExtensions>
33- <Borland.Personality>Delphi.Personality</Borland.Personality>
34- <Borland.ProjectType />
35- <BorlandProject>
36-<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">False</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">2057</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Excluded_Packages>
37-
38-
39-
40-
41-
42-
43-
44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
69-
70-
71-
72-
73-
74-
75-
76-
77-
78-
79-
80-
81-
82-
83-
84-
85-
86-
87-
88-
89-
90-
91-
92-
93-
94-
95-
96-
97-
98-
99-
100-
101-
102-
103-
104-
105-
106-
107-
108-
109-
110-
111-
112-
113-
114-
115-
116-
117-
118-
119-
120-
121-
122-
123-
124-
125-
126-
127-
128-
129-
130-
131-
132-
133-
134-
135-
136-
137-
138-
139-
140-
141-
142-
143-
144-
145-
146-
147-
148-
149-
150-
151-
152-
153-
154-
155-
156-
157-
158-
159-
160-
161-
162-
163-
164-
165-
166-
167-
168-
169-
170-
171-
172-
173-
174-
175-
176-
177-
178-
179-
180-
181-
182-
183-
184-
185-
186-
187-
188-
189-
190-
191-
192-
193-
194-
195-
196-
197-
198-
199-
200-
201-
202-
203-
204-
205-
206-
207-
208-
209-
210-
211-
212-
213-
214-
215-
216-
217-
218-
219-
220-
221-
222-
223-
224-
225-
226-
227-
228-
229-
230-
231-
232-
233-
234-
235-
236-
237-
238-
239-
240-
241-
242-
243-
244-
245-
246-
247-
248-
249-
250-
251-
252-
253-
254-
255-
256-
257-
258- <Excluded_Packages Name="$(BDS)\bin\dcloffice2k100.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
259- <Excluded_Packages Name="$(BDS)\bin\dclofficexp100.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
260- <Excluded_Packages Name="$(BDS)\bin\bcbie100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\bcbie100.bpl not found</Excluded_Packages>
261- <Excluded_Packages Name="$(BDS)\bin\dclbcbsmp100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\dclbcbsmp100.bpl not found</Excluded_Packages>
262- <Excluded_Packages Name="$(BDS)\Bin\dclib100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\Bin\dclib100.bpl not found</Excluded_Packages>
263- <Excluded_Packages Name="$(BDS)\bin\dcldbx4100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\dcldbx4100.bpl not found</Excluded_Packages>
264- <Excluded_Packages Name="$(BDS)\bin\dcldbxcds4100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\dcldbxcds4100.bpl not found</Excluded_Packages>
265- <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\dclfsIBX11.bpl">FastScript 1.9 IBX Components</Excluded_Packages>
266- <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclDebugExpert110.bpl">JCL Debug IDE extension</Excluded_Packages>
267- <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclBaseExpert110.bpl">JCL Package containing common units for JCL Experts</Excluded_Packages>
268- <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclFavoriteFoldersExpert110.bpl">JCL Open and Save IDE dialogs with favorite folders</Excluded_Packages>
269- <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclProjectAnalysisExpert110.bpl">JCL Project Analyzer</Excluded_Packages>
270- <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclStackTraceViewerExpert110.bpl">JCL Stack Trace Viewer</Excluded_Packages>
271- <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\DclArgVideoComponents100.bpl">Schniering ArgVideo components</Excluded_Packages>
272- <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\dclfsTee11.bpl">FastScript 1.9 Tee Components</Excluded_Packages>
273- <Excluded_Packages Name="$(BDS)\bin\bcboffice2k100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\bcboffice2k100.bpl not found</Excluded_Packages>
274- <Excluded_Packages Name="$(BDS)\bin\bcbofficexp100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\bcbofficexp100.bpl not found</Excluded_Packages>
275- </Excluded_Packages><Source><Source Name="MainSource">LargeTextViewer.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject>
276- </ProjectExtensions>
277- <Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" />
278- <ItemGroup>
279- <DelphiCompile Include="LargeTextViewer.dpr">
280- <MainSource>MainSource</MainSource>
281- </DelphiCompile>
282- <DCCReference Include="u_Int64List.pas" />
283- <DCCReference Include="u_TextFileIndexer.pas" />
284- <DCCReference Include="w_LargeTextViewer.pas">
285- <Form>f_LargeTextViewer</Form>
286- </DCCReference>
287- </ItemGroup>
288-</Project>
\ No newline at end of file
--- trunk/trunk/tools/LargeTextViewer/src/LargeTextViewer.dpr (nonexistent)
+++ trunk/trunk/tools/LargeTextViewer/src/LargeTextViewer.dpr (revision 245)
@@ -0,0 +1,16 @@
1+program LargeTextViewer;
2+
3+uses
4+ Forms,
5+ w_LargeTextViewer in 'w_LargeTextViewer.pas' {f_LargeTextViewer},
6+ u_TextFileIndexer in 'u_TextFileIndexer.pas',
7+ u_Int64List in 'u_Int64List.pas';
8+
9+{$R *.res}
10+
11+begin
12+ Application.Initialize;
13+ Application.MainFormOnTaskbar := True;
14+ Application.CreateForm(Tf_LargeTextViewer, f_LargeTextViewer);
15+ Application.Run;
16+end.
--- trunk/trunk/tools/LargeTextViewer/src/LargeTextViewer.dproj (nonexistent)
+++ trunk/trunk/tools/LargeTextViewer/src/LargeTextViewer.dproj (revision 245)
@@ -0,0 +1,288 @@
1+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+ <PropertyGroup>
3+ <ProjectGuid>{b6113310-a312-491b-823e-3a1e137966ec}</ProjectGuid>
4+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+ <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
7+ <DCC_DependencyCheckOutputName>..\LargeTextViewer.exe</DCC_DependencyCheckOutputName>
8+ <MainSource>LargeTextViewer.dpr</MainSource>
9+ </PropertyGroup>
10+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
11+ <Version>7.0</Version>
12+ <DCC_DebugInformation>False</DCC_DebugInformation>
13+ <DCC_LocalDebugSymbols>False</DCC_LocalDebugSymbols>
14+ <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
15+ <DCC_Define>RELEASE</DCC_Define>
16+ </PropertyGroup>
17+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+ <Version>7.0</Version>
19+ <DCC_Optimize>False</DCC_Optimize>
20+ <DCC_ExeOutput>..</DCC_ExeOutput>
21+ <DCC_DcuOutput>..\dcu</DCC_DcuOutput>
22+ <DCC_ObjOutput>..\dcu</DCC_ObjOutput>
23+ <DCC_HppOutput>..\dcu</DCC_HppOutput>
24+ <DCC_UnitSearchPath>$(BDS)\lib\Debug;..\..\..\src;..\..\..\..\jcl\source\include;..\..\..\..\jcl\source\common;..\..\..\..\jcl\source\windows;..\..\..\..\jcl\source\include\jedi;..\..\..\jvcl\common;..\..\libs\jvcl\run;..\..\libs\jvcl\resources;..\..\..\components;..\..\..\templates</DCC_UnitSearchPath>
25+ <DCC_ResourcePath>$(BDS)\lib\Debug;..\..\..\src;..\..\..\..\jcl\source\include;..\..\..\..\jcl\source\common;..\..\..\..\jcl\source\windows;..\..\..\..\jcl\source\include\jedi;..\..\..\jvcl\common;..\..\libs\jvcl\run;..\..\libs\jvcl\resources;..\..\..\components;..\..\..\templates</DCC_ResourcePath>
26+ <DCC_ObjPath>$(BDS)\lib\Debug;..\..\..\src;..\..\..\..\jcl\source\include;..\..\..\..\jcl\source\common;..\..\..\..\jcl\source\windows;..\..\..\..\jcl\source\include\jedi;..\..\..\jvcl\common;..\..\libs\jvcl\run;..\..\libs\jvcl\resources;..\..\..\components;..\..\..\templates</DCC_ObjPath>
27+ <DCC_IncludePath>$(BDS)\lib\Debug;..\..\..\src;..\..\..\..\jcl\source\include;..\..\..\..\jcl\source\common;..\..\..\..\jcl\source\windows;..\..\..\..\jcl\source\include\jedi;..\..\..\jvcl\common;..\..\libs\jvcl\run;..\..\libs\jvcl\resources;..\..\..\components;..\..\..\templates</DCC_IncludePath>
28+ <DCC_Define>DEBUG;NO_TRANSLATION</DCC_Define>
29+ <DCC_SYMBOL_PLATFORM>False</DCC_SYMBOL_PLATFORM>
30+ <DCC_UNIT_PLATFORM>False</DCC_UNIT_PLATFORM>
31+ </PropertyGroup>
32+ <ProjectExtensions>
33+ <Borland.Personality>Delphi.Personality</Borland.Personality>
34+ <Borland.ProjectType />
35+ <BorlandProject>
36+<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">False</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">2057</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Excluded_Packages>
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
147+
148+
149+
150+
151+
152+
153+
154+
155+
156+
157+
158+
159+
160+
161+
162+
163+
164+
165+
166+
167+
168+
169+
170+
171+
172+
173+
174+
175+
176+
177+
178+
179+
180+
181+
182+
183+
184+
185+
186+
187+
188+
189+
190+
191+
192+
193+
194+
195+
196+
197+
198+
199+
200+
201+
202+
203+
204+
205+
206+
207+
208+
209+
210+
211+
212+
213+
214+
215+
216+
217+
218+
219+
220+
221+
222+
223+
224+
225+
226+
227+
228+
229+
230+
231+
232+
233+
234+
235+
236+
237+
238+
239+
240+
241+
242+
243+
244+
245+
246+
247+
248+
249+
250+
251+
252+
253+
254+
255+
256+
257+
258+ <Excluded_Packages Name="$(BDS)\bin\dcloffice2k100.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
259+ <Excluded_Packages Name="$(BDS)\bin\dclofficexp100.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
260+ <Excluded_Packages Name="$(BDS)\bin\bcbie100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\bcbie100.bpl not found</Excluded_Packages>
261+ <Excluded_Packages Name="$(BDS)\bin\dclbcbsmp100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\dclbcbsmp100.bpl not found</Excluded_Packages>
262+ <Excluded_Packages Name="$(BDS)\Bin\dclib100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\Bin\dclib100.bpl not found</Excluded_Packages>
263+ <Excluded_Packages Name="$(BDS)\bin\dcldbx4100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\dcldbx4100.bpl not found</Excluded_Packages>
264+ <Excluded_Packages Name="$(BDS)\bin\dcldbxcds4100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\dcldbxcds4100.bpl not found</Excluded_Packages>
265+ <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\dclfsIBX11.bpl">FastScript 1.9 IBX Components</Excluded_Packages>
266+ <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclDebugExpert110.bpl">JCL Debug IDE extension</Excluded_Packages>
267+ <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclBaseExpert110.bpl">JCL Package containing common units for JCL Experts</Excluded_Packages>
268+ <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclFavoriteFoldersExpert110.bpl">JCL Open and Save IDE dialogs with favorite folders</Excluded_Packages>
269+ <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclProjectAnalysisExpert110.bpl">JCL Project Analyzer</Excluded_Packages>
270+ <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\JclStackTraceViewerExpert110.bpl">JCL Stack Trace Viewer</Excluded_Packages>
271+ <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\DclArgVideoComponents100.bpl">Schniering ArgVideo components</Excluded_Packages>
272+ <Excluded_Packages Name="C:\Users\Public\Documents\RAD Studio\5.0\Bpl\dclfsTee11.bpl">FastScript 1.9 Tee Components</Excluded_Packages>
273+ <Excluded_Packages Name="$(BDS)\bin\bcboffice2k100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\bcboffice2k100.bpl not found</Excluded_Packages>
274+ <Excluded_Packages Name="$(BDS)\bin\bcbofficexp100.bpl">File c:\program files (x86)\codegear\rad studio\5.0\bin\bcbofficexp100.bpl not found</Excluded_Packages>
275+ </Excluded_Packages><Source><Source Name="MainSource">LargeTextViewer.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject>
276+ </ProjectExtensions>
277+ <Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" />
278+ <ItemGroup>
279+ <DelphiCompile Include="LargeTextViewer.dpr">
280+ <MainSource>MainSource</MainSource>
281+ </DelphiCompile>
282+ <DCCReference Include="u_Int64List.pas" />
283+ <DCCReference Include="u_TextFileIndexer.pas" />
284+ <DCCReference Include="w_LargeTextViewer.pas">
285+ <Form>f_LargeTextViewer</Form>
286+ </DCCReference>
287+ </ItemGroup>
288+</Project>
\ No newline at end of file
--- trunk/trunk/tools/LargeTextViewer/src/u_Int64List.pas (nonexistent)
+++ trunk/trunk/tools/LargeTextViewer/src/u_Int64List.pas (revision 245)
@@ -0,0 +1,78 @@
1+unit u_Int64List;
2+
3+interface
4+
5+uses
6+ SysUtils,
7+ Classes,
8+ u_dzTranslator;
9+
10+type
11+ TInt64List = class
12+ private
13+ FData: array of Int64;
14+ FCapacity: integer;
15+ FCount: integer;
16+ procedure Grow;
17+ procedure SetCapacity(_NewCapacity: Integer);
18+ function GetItems(_Idx: integer): Int64;
19+ procedure SetItems(_Idx: integer; const Value: Int64);
20+ public
21+ function Add(_Value: Int64): integer;
22+ property Items[_Idx: integer]: Int64 read GetItems write SetItems;
23+ property Count: integer read FCount;
24+ end;
25+
26+implementation
27+
28+uses
29+ RTLConsts;
30+
31+{ TInt64List }
32+
33+function TInt64List.Add(_Value: Int64): integer;
34+begin
35+ Result := FCount;
36+ if Result = FCapacity then
37+ Grow;
38+ FData[Result] := _Value;
39+ Inc(FCount);
40+end;
41+
42+procedure TInt64List.Grow;
43+var
44+ Delta: Integer;
45+begin
46+ if FCapacity > 64 then
47+ Delta := FCapacity div 4
48+ else if FCapacity > 8 then
49+ Delta := 16
50+ else
51+ Delta := 4;
52+ SetCapacity(FCapacity + Delta);
53+end;
54+
55+procedure TInt64List.SetCapacity(_NewCapacity: Integer);
56+begin
57+ if (_NewCapacity < FCount) or (_NewCapacity > MaxListSize) then
58+ raise Exception.CreateFmt(_('List capacity out of bounds (%d)'), [_NewCapacity]);
59+ if _NewCapacity <> FCapacity then begin
60+ SetLength(FData, _NewCapacity);
61+ FCapacity := _NewCapacity;
62+ end;
63+end;
64+
65+function TInt64List.GetItems(_Idx: integer): Int64;
66+begin
67+ if (_Idx < 0) or (_Idx >= FCount) then
68+ raise Exception.CreateFmt(_('List index out of bounds (%d)'), [_Idx]);
69+ Result := FData[_Idx];
70+end;
71+
72+procedure TInt64List.SetItems(_Idx: integer; const Value: Int64);
73+begin
74+
75+end;
76+
77+end.
78+
--- trunk/trunk/tools/LargeTextViewer/src/u_TextFileIndexer.pas (nonexistent)
+++ trunk/trunk/tools/LargeTextViewer/src/u_TextFileIndexer.pas (revision 245)
@@ -0,0 +1,121 @@
1+unit u_TextFileIndexer;
2+
3+interface
4+
5+uses
6+ SysUtils,
7+ Classes,
8+ u_Int64List,
9+ u_dzCriticalSection;
10+
11+type
12+ TTextFileIndexer = class
13+ private
14+ FCritSect: TdzCriticalSection;
15+ FLineIndexes: TInt64List;
16+ FIsDone: boolean;
17+ FFilename: string;
18+ FAbortRequested: Boolean;
19+ function GetLineIndex(_Idx: integer): Int64;
20+ function GetLineIndexCount: integer;
21+ public
22+ constructor Create(const _Filename: string);
23+ destructor Destroy; override;
24+ procedure Execute;
25+ procedure Abort;
26+ property LineIndex[_Idx: integer]: Int64 read GetLineIndex;
27+ property LineIndexCount: integer read GetLineIndexCount;
28+ property isDone: boolean read FIsDone;
29+ end;
30+
31+implementation
32+
33+uses
34+ u_dzFileStreams;
35+
36+{ TTextFileIndexer }
37+
38+constructor TTextFileIndexer.Create(const _Filename: string);
39+begin
40+ inherited Create;
41+ FLineIndexes := TInt64List.Create;
42+ FFilename := _Filename;
43+ FCritSect := TdzCriticalSection.Create;
44+end;
45+
46+destructor TTextFileIndexer.Destroy;
47+begin
48+ FreeAndNil(FCritSect);
49+ FreeAndNil(FLineIndexes);
50+ inherited;
51+end;
52+
53+procedure TTextFileIndexer.Execute;
54+const
55+ BUFFER_SIZE = 1024 * 128;
56+var
57+ st: TdzFile;
58+ buffer: array[0..BUFFER_SIZE - 1] of char;
59+ Offset: Int64;
60+ BytesRead: Integer;
61+ i: Integer;
62+begin
63+ FAbortRequested := False;
64+ FIsDone := False;
65+ st := TdzFile.Create(FFilename);
66+ try
67+ st.OpenReadonly;
68+ FCritSect.Enter;
69+ try
70+ FLineIndexes.Add(0);
71+ finally
72+ FCritSect.Leave;
73+ end;
74+ while not st.EOF do begin
75+ Offset := st.Position;
76+ BytesRead := st.Read(Buffer, SizeOf(Buffer));
77+ for i := 0 to BytesRead - 1 do
78+ if buffer[i] = #10 then begin
79+ FCritSect.Enter;
80+ try
81+ FLineIndexes.Add(Offset + i + 1);
82+ finally
83+ FCritSect.Leave;
84+ end;
85+ end;
86+ if FAbortRequested then
87+ SysUtils.Abort;
88+ end;
89+ finally
90+ FreeAndNil(st);
91+ end;
92+ FIsDone := true;
93+end;
94+
95+function TTextFileIndexer.GetLineIndex(_Idx: integer): Int64;
96+begin
97+ FCritSect.Enter;
98+ try
99+ Result := FLineIndexes.Items[_Idx];
100+ finally
101+ FCritSect.Leave;
102+ end;
103+end;
104+
105+function TTextFileIndexer.GetLineIndexCount: integer;
106+begin
107+ FCritSect.Enter;
108+ try
109+ Result := FLineIndexes.Count;
110+ finally
111+ FCritSect.Leave;
112+ end;
113+end;
114+
115+procedure TTextFileIndexer.Abort;
116+begin
117+ FAbortRequested := true;
118+end;
119+
120+end.
121+
--- trunk/trunk/tools/LargeTextViewer/src/w_LargeTextViewer.pas (nonexistent)
+++ trunk/trunk/tools/LargeTextViewer/src/w_LargeTextViewer.pas (revision 245)
@@ -0,0 +1,169 @@
1+unit w_LargeTextViewer;
2+
3+interface
4+
5+uses
6+ Windows,
7+ Messages,
8+ SysUtils,
9+ Variants,
10+ Classes,
11+ Graphics,
12+ Controls,
13+ Forms,
14+ Dialogs,
15+ Grids,
16+ c_dzVirtualStringGrid,
17+ u_dzTranslator,
18+ u_TextFileIndexer,
19+ u_dzNamedThread,
20+ u_dzFileStreams,
21+ ExtCtrls,
22+ ComCtrls,
23+ Menus;
24+
25+type
26+ TIndexerThread = class(TNamedThread)
27+ private
28+ FIndexer: TTextFileIndexer;
29+ protected
30+ constructor Create(_Indexer: TTextFileIndexer);
31+ procedure Execute; override;
32+ end;
33+
34+type
35+ Tf_LargeTextViewer = class(TForm)
36+ sg_Display: TdzVirtualStringGrid;
37+ tim_Update: TTimer;
38+ TheStatusBar: TStatusBar;
39+ TheMainMenu: TMainMenu;
40+ mi_File: TMenuItem;
41+ mi_Open: TMenuItem;
42+ mi_Exit: TMenuItem;
43+ TheOpenDialog: TOpenDialog;
44+ procedure sg_DisplayGetNonfixedCellData(_Sender: TObject; _DataCol, _DataRow: Integer;
45+ _State: TGridDrawState; var _Text: string; var _HAlign: TAlignment;
46+ var _VAlign: TdzCellVertAlign; _Font: TFont; var _Color: TColor);
47+ procedure sg_DisplayResize(Sender: TObject);
48+ procedure tim_UpdateTimer(Sender: TObject);
49+ procedure mi_OpenClick(Sender: TObject);
50+ procedure mi_ExitClick(Sender: TObject);
51+ private
52+ FIndexer: TTextFileIndexer;
53+ FIndexThread: TIndexerThread;
54+ FFile: TdzFile;
55+ procedure OpenFile;
56+ public
57+ constructor Create(_Owner: TComponent); override;
58+ destructor Destroy; override;
59+ procedure LoadFile(const _Filename: string);
60+ end;
61+
62+var
63+ f_LargeTextViewer: Tf_LargeTextViewer;
64+
65+implementation
66+
67+{$R *.dfm}
68+
69+uses
70+ u_dzClassUtils;
71+
72+{ TIndexerThread }
73+
74+constructor TIndexerThread.Create(_Indexer: TTextFileIndexer);
75+begin
76+ FIndexer := _Indexer;
77+ inherited Create(false);
78+end;
79+
80+procedure TIndexerThread.Execute;
81+begin
82+ inherited;
83+ try
84+ FIndexer.Execute;
85+ except
86+ on EAbort do
87+ // itnore;
88+ else
89+ raise;
90+ end;
91+end;
92+
93+constructor Tf_LargeTextViewer.Create(_Owner: TComponent);
94+begin
95+ inherited;
96+ OpenFile;
97+end;
98+
99+destructor Tf_LargeTextViewer.Destroy;
100+begin
101+ FreeAndNil(FFile);
102+ if Assigned(FIndexer) then
103+ FIndexer.Abort;
104+ FreeAndNil(FIndexThread);
105+ inherited;
106+end;
107+
108+procedure Tf_LargeTextViewer.LoadFile(const _Filename: string);
109+begin
110+ FIndexer := TTextFileIndexer.Create(_Filename);
111+ FIndexThread := TIndexerThread.Create(FIndexer);
112+ tim_Update.Enabled := true;
113+ FFile := TdzFile.Create(_Filename);
114+ FFile.OpenReadonly;
115+end;
116+
117+procedure Tf_LargeTextViewer.mi_ExitClick(Sender: TObject);
118+begin
119+ Close;
120+end;
121+
122+procedure Tf_LargeTextViewer.OpenFile;
123+begin
124+ TheOpenDialog.Filter := 'all files (*.*)|*.*';
125+ if not TheOpenDialog.Execute then
126+ exit;
127+ LoadFile(TheOpenDialog.FileName);
128+end;
129+
130+procedure Tf_LargeTextViewer.mi_OpenClick(Sender: TObject);
131+begin
132+ OpenFile;
133+end;
134+
135+procedure Tf_LargeTextViewer.sg_DisplayGetNonfixedCellData(_Sender: TObject; _DataCol, _DataRow: Integer;
136+ _State: TGridDrawState; var _Text: string; var _HAlign: TAlignment; var _VAlign: TdzCellVertAlign;
137+ _Font: TFont; var _Color: TColor);
138+var
139+ SeekIdx: Int64;
140+ s: string;
141+begin
142+ if not Assigned(FIndexer) or (FIndexer.LineIndexCount < _DataRow) then
143+ exit;
144+ SeekIdx := FIndexer.LineIndex[_DataRow];
145+ FFile.Position := SeekIdx;
146+ TStream_ReadStringLn(FFile, s);
147+ _Text := s;
148+end;
149+
150+procedure Tf_LargeTextViewer.sg_DisplayResize(Sender: TObject);
151+begin
152+ sg_Display.ColWidths[0] := sg_Display.ClientWidth;
153+end;
154+
155+procedure Tf_LargeTextViewer.tim_UpdateTimer(Sender: TObject);
156+var
157+ LineCount: integer;
158+begin
159+ LineCount := FIndexer.LineIndexCount;
160+ sg_Display.RowCount := LineCount;
161+ if FIndexer.isDone then begin
162+ tim_Update.Enabled := false;
163+ TheStatusBar.SimpleText := Format(_('%d lines'), [LineCount]);
164+ end else
165+ TheStatusBar.SimpleText := Format(_('Indexing (%d lines)'), [LineCount]);
166+end;
167+
168+end.
169+
Show on old repository browser