• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision7 (tree)
Time2018-12-17 12:29:53
Authorkentamaken

Log Message

(empty log message)

Change Summary

Incremental Difference

--- textdefindunit.pas (revision 6)
+++ textdefindunit.pas (revision 7)
@@ -83,6 +83,8 @@
8383 procedure writestrings(sc:string;sl:TStrings);
8484 procedure readgrid(sc:string;G:TGrid);
8585 procedure writegrid(sc:string;G:TGrid);
86+ procedure readtreeview(sc:string;T:TTreeView);
87+ procedure writetreeview(sc:string;T:TTreeView);
8688 end;
8789
8890 TTextDeFindForm=class(TForm,IDropSource)
@@ -153,6 +155,7 @@
153155 procedure PathSelButtonClick(Sender: TObject);
154156 procedure GridFilesSetEditText(Sender: TObject; ACol, ARow: Integer;
155157 const Value: string);
158+ procedure FormClose(Sender: TObject; var Action: TCloseAction);
156159 private
157160 { Private 宣言 }
158161 public
@@ -177,10 +180,12 @@
177180 FMouseDownPt:TPoint;
178181 SL :TStringDynArray;
179182 Ini :TMemIniFile;
183+ Inifile :TMemIniFile;
180184 inidir :string;
181185 pname :string;
182186
183187 const
188+ MAXLIST =4096;
184189 TKNMAXLEN=1024;
185190 NULLNULL =#0#0;
186191 CR =#13;
@@ -209,9 +214,11 @@
209214
210215
211216
217+
212218 procedure TTextDeFindForm.FormCreate(Sender:TObject);
213219 begin
214- Ini:=TMemIniFile.Create(ChangeFileExt(Application.ExeName,'.INI'));
220+ Ini:=TMemIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
221+ Inifile:=TMemIniFile.Create(ChangeFileExt(Application.ExeName,'.txt'));
215222 inidir:=Ini.ReadString('','inidir',inidir);
216223 OpenDialog.InitialDir:=ExtractFileDir(Application.ExeName);
217224 SaveDialog.InitialDir:=ExtractFileDir(Application.ExeName);
@@ -224,18 +231,26 @@
224231 Path.Text:=Ini.ReadString('','Path.Text','');
225232 Url.Text:=Ini.ReadString('','Url.Text','');
226233 Ini.readstrings('Url.Items',Url.Items);
234+ Inifile.readtreeview('Tree',Tree);
227235
228236 // Files:=GridFiles;
229237 Files:=TGrid.CreateEX(GridFiles);
230238
231- Tree.LoadFromFile(ChangeFileExt(Application.ExeName,'.txt'));
232- NameChange(Sender);
233- pname:=Name.Text;
234- TreeClick(Sender);
239+ try
240+// Tree.LoadFromFile(ChangeFileExt(Application.ExeName,'.txt'));
241+ NameChange(Sender);
242+ pname:=Name.Text;
243+ TreeClick(Sender);
244+ except
245+ ShowMessage('ツリーテキストを読み込めませんでした');
246+ Application.Terminate;
247+ end;
235248 end;
236249
237-procedure TTextDeFindForm.FormDestroy(Sender:TObject);
250+procedure TTextDeFindForm.FormClose(Sender: TObject; var Action: TCloseAction);
238251 begin
252+ if Application.Terminated then exit;
253+
239254 Ini.WriteInteger('','Width',Width);
240255 Ini.WriteInteger('','Height',Height);
241256 Ini.WriteInteger('','LeftPanel.Width',LeftPanel.Width);
@@ -245,11 +260,18 @@
245260 Ini.writestrings('Url.Items',Url.Items);
246261
247262 NameChange(Sender);
248- Tree.SaveToFile(ChangeFileExt(Application.ExeName,'.txt'));
263+ Inifile.writetreeview('Tree',Tree);
264+// Tree.SaveToFile(ChangeFileExt(Application.ExeName,'.txt'));
249265
266+ Ini.UpdateFile;
267+ Inifile.UpdateFile;
268+end;
250269
251- Ini.UpdateFile;
270+procedure TTextDeFindForm.FormDestroy(Sender:TObject);
271+begin
272+
252273 Ini.Free;
274+ Inifile.Free;
253275
254276 end;
255277
@@ -554,9 +576,9 @@
554576
555577 NN.DeleteChildren;
556578 for s in Text.lines do
557- Tree.Items.AddChild(NN,s);
579+ Tree.Items.AddChild(NN,Trim(s));
558580
559- Ini.writegrid('grid\'+pname,TGrid(GridFiles));
581+ Inifile.writegrid('grid\'+pname,TGrid(GridFiles));
560582 end;
561583
562584 end;
@@ -566,7 +588,7 @@
566588 while N<>nil do begin
567589 if N.text=Name.text then begin
568590 childtext(N);
569- Ini.readgrid('grid\'+Name.text,TGrid(GridFiles));
591+ Inifile.readgrid('grid\'+Name.text,TGrid(GridFiles));
570592 end;
571593 N:=N.getNextSibling;
572594 end;
@@ -602,6 +624,7 @@
602624 sub :boolean;
603625 hit :boolean;
604626 ls,le,i,j,count:integer;
627+ pathtext:string;
605628
606629
607630 function zenkaku(Str : String) : String;//半角全角
@@ -679,7 +702,12 @@
679702 try
680703 Screen.Cursor:=crHourGlass;
681704 Application.ProcessMessages;
682- Path.Text:=incbs(Path.Text);
705+
706+ ls:=Text.Perform(EM_LINEFROMCHAR,Text.SelStart, 0);
707+ pathtext:=Path.Text;
708+ pathtext:=pathtext.Replace('%リスト名%',Name.text);
709+ pathtext:=pathtext.Replace('%検索文字%',Text.lines[ls]);
710+ pathtext:=incbs(pathtext);
683711 // snm:=ExtractFileName(Path.Text);
684712 // if snm='' then
685713 snm:='*';
@@ -688,7 +716,7 @@
688716 op:=TSearchOption.soAllDirectories;
689717 // else
690718 // op := TSearchOption.soTopDirectoryOnly;
691- SA:=TDirectory.GetFiles(Path.Text,snm,op);
719+ SA:=TDirectory.GetFiles(PathText,snm,op);
692720 Files.RowCount:=1;
693721 Files.ColCount:=4;
694722 Files.Rows[0].setstrings(['','検索文字','ファイル','パス']);
@@ -696,7 +724,7 @@
696724 if sender=Find then begin
697725 ls:=0;
698726 le:=Text.Lines.Count-1;
699-
727+
700728 end else begin
701729 ls:=Text.Perform(EM_LINEFROMCHAR,Text.SelStart, 0);
702730 le:=Text.Perform(EM_LINEFROMCHAR,Text.SelStart+Text.SelLength-1*integer(Text.SelLength>0),0);
@@ -1304,13 +1332,13 @@
13041332 G.rows[y].clear;
13051333 end);
13061334 G.rowcount:=1;
1307- for y:=0 to 1024 do begin
1335+ for y:=0 to MAXLIST do begin
13081336 for x:=0 to G.ColCount-1 do begin
13091337 s:=inttostr(y)+','+inttostr(x);
1310- if not ini.ValueExists(sc,s) then break;
1338+ if not ValueExists(sc,s) then break;
13111339 if x>=G.colcount then G.colcount:=x+1;
13121340 if y>=G.rowcount then G.rowcount:=y+1;
1313- G.cells[x,y]:=Ini.ReadString(sc,inttostr(y)+','+inttostr(x),'');
1341+ G.cells[x,y]:=ReadString(sc,inttostr(y)+','+inttostr(x),'');
13141342 end;
13151343 end;
13161344 if G.rowcount<2 then G.rowcount:=2;
@@ -1321,11 +1349,11 @@
13211349
13221350 procedure TMemIniFileHelper.writegrid(sc: string; G: TGrid);
13231351 begin
1324- Ini.EraseSection(sc);
1352+ EraseSection(sc);
13251353 G.alldo(procedure(X,Y:Integer)begin
1326- Ini.WriteString(sc,inttostr(y)+','+inttostr(x),G.cells[x,y]);
1354+ WriteString(sc,inttostr(y)+','+inttostr(x),G.cells[x,y]);
13271355 end);
1328-
1356+
13291357 end;
13301358
13311359 procedure TMemIniFileHelper.readstrings(sc: string; sl:TStrings);
@@ -1332,22 +1360,76 @@
13321360 var i:integer;
13331361 s:string;
13341362 begin
1335- if ini.SectionExists(sc) then sl.clear;
1336- for i:=0 to 1024 do begin
1337- if not ini.ValueExists(sc,inttostr(i)) then break;
1338- sl.add(Ini.ReadString(sc,inttostr(i),''));
1363+ if SectionExists(sc) then sl.clear;
1364+ for i:=0 to MAXLIST do begin
1365+ if not ValueExists(sc,inttostr(i)) then break;
1366+ sl.add(ReadString(sc,inttostr(i),''));
13391367 end;
13401368 end;
13411369
13421370
1371+
13431372 procedure TMemIniFileHelper.writestrings(sc: string; sl: TStrings);
13441373 var i:integer;
13451374 begin
1346- Ini.EraseSection(sc);
1375+ EraseSection(sc);
13471376 for i:=0 to sl.Count-1 do
1348- Ini.WriteString(sc,inttostr(i),sl[i]);
1377+ WriteString(sc,inttostr(i),sl[i]);
13491378 end;
13501379
1380+procedure TMemIniFileHelper.readtreeview(sc: string; T: TTreeView);
1381+var
1382+ N:TTreeNode;
1383+ i:integer;
1384+ procedure sub(key:string;N:TTreeNode);
1385+ var i:integer;
1386+ k:string;
1387+ begin
1388+ for i:=0 to MAXLIST do begin
1389+ k:=key+','+inttostr(i);
1390+ if not ValueExists(sc,k) then break;
1391+ T.Items.AddChild(N,ReadString(sc,k,''));
1392+ sub(k,N);
1393+ end;
1394+ end;
1395+begin
1396+ if SectionExists(sc) then T.Items.clear;
1397+ for i:=0 to MAXLIST do begin
1398+ if not ValueExists(sc,inttostr(i)) then break;
1399+ N:=T.Items.Add(nil,ReadString(sc,inttostr(i),''));
1400+ sub(inttostr(i),N);
1401+ end;
1402+
1403+end;
1404+
1405+procedure TMemIniFileHelper.writetreeview(sc: string; T: TTreeView);
1406+var
1407+ N:TTreeNode;
1408+ i:integer;
1409+ procedure sub(key: string;N:TTreeNode);
1410+ var i:integer;
1411+ begin
1412+ N:=N.getFirstChild;
1413+ i:=0;
1414+ while N<>nil do begin
1415+ WriteString(sc,key+','+inttostr(N.index),N.text);
1416+ sub(sc,N);
1417+ N:=N.getNextSibling;
1418+ inc(i);
1419+ end;
1420+ end;
1421+begin
1422+ EraseSection(sc);
1423+ i:=0;
1424+ N:=T.Items.GetFirstNode;
1425+ while N<>nil do begin
1426+ WriteString(sc,inttostr(N.index),N.text);
1427+ sub(inttostr(N.index),N);
1428+ N:=N.getNextSibling;
1429+ inc(i);
1430+ end;
1431+end;
1432+
13511433 initialization
13521434
13531435 SHGetMalloc(Malloc);