• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

コミットメタ情報

リビジョン5 (tree)
日時2018-12-11 20:29:21
作者kentamaken

ログメッセージ

GRID保存

変更サマリ

差分

--- textdefindunit.pas (revision 4)
+++ textdefindunit.pas (revision 5)
@@ -15,10 +15,6 @@
1515 function this:TStringList;
1616 end;
1717
18- TIniFileHelper=class helper for TInifile
19- procedure readstrings(sc:string;sl:TStrings);
20- procedure writestrings(sc:string;sl:TStrings);
21- end;
2218
2319 TStringsHelper=class helper for TStrings
2420 function setstrings(sa:TStringDynArray):Integer;
@@ -41,7 +37,6 @@
4137 end;
4238
4339 TGrid=class(TStringGrid)
44-
4540 type
4641 TFuncXY=reference to procedure(X,Y:Integer);
4742
@@ -52,6 +47,8 @@
5247 procedure MouseDown(Button:TMouseButton;Shift:TShiftState;X,Y:Integer);override;
5348 procedure MouseMove(Shift:TShiftState;X,Y:Integer);override;
5449
50+ procedure SetEditText(ACol, ARow: Integer; const Value: string);override;
51+
5552 function DoMouseWheelDown(Shift:TShiftState;MousePos:TPoint):boolean;override;
5653 function DoMouseWheelUp(Shift:TShiftState;MousePos:TPoint):boolean;override;
5754 function ColExpand(min:Integer):Integer;
@@ -67,7 +64,9 @@
6764 procedure cutcopy(modecut:boolean);
6865 function paste:TGridRect;
6966 function selrowdo(func:TFuncXY):Integer;
67+ function rowdo(func:TFuncXY):Integer;
7068 function seldo(func:TFuncXY):Integer;
69+ function alldo(func:TFuncXY):Integer;
7170 procedure copy(G:TGrid);
7271 procedure savebuf;
7372 procedure seldel;
@@ -79,6 +78,12 @@
7978 property InplaceEditor;
8079 end;
8180
81+ TMemIniFileHelper=class helper for TMemInifile
82+ procedure readstrings(sc:string;sl:TStrings);
83+ procedure writestrings(sc:string;sl:TStrings);
84+ procedure readgrid(sc:string;G:TGrid);
85+ procedure writegrid(sc:string;G:TGrid);
86+ end;
8287
8388 TTextDeFindForm=class(TForm,IDropSource)
8489 Panel1:TPanel;
@@ -101,22 +106,23 @@
101106 TMP:TComboBox;
102107 SaveDialog:TSaveDialog;
103108 OpenDialog:TOpenDialog;
104- LeftPanel: TPanel;
109+ LeftPanel: TPanel;
105110 Name: TComboBox;
106111 Text: TRichEdit;
107112 Tree: TTreeView;
108113 Button1: TButton;
109114 Splitter1: TSplitter;
110- PFileExec: TMenuItem;
111- PFileFolder: TMenuItem;
112- Panel3: TPanel;
113- Url: TComboBox;
114- FindUrlButton: TButton;
115- UrlEditButton: TButton;
116- PathEditButton: TButton;
117- PTextFind: TMenuItem;
118- PTextFindUrl: TMenuItem;
119- N1: TMenuItem;
115+ PFileExec: TMenuItem;
116+ PFileFolder: TMenuItem;
117+ Panel3: TPanel;
118+ Url: TComboBox;
119+ FindUrlButton: TButton;
120+ UrlEditButton: TButton;
121+ PathEditButton: TButton;
122+ PTextFind: TMenuItem;
123+ PTextFindUrl: TMenuItem;
124+ N1: TMenuItem;
125+ PathSelButton: TButton;
120126 procedure FindClick(Sender:TObject);
121127 procedure FormCreate(Sender:TObject);
122128 procedure GridFilesMouseDown(Sender:TObject;Button:TMouseButton;
@@ -135,7 +141,7 @@
135141 procedure NameChange(Sender: TObject);
136142 procedure TreeClick(Sender: TObject);
137143 procedure Button1Click(Sender: TObject);
138- procedure PFileFolderClick(Sender: TObject);
144+ procedure PFileFolderClick(Sender: TObject);
139145 procedure PFileExecClick(Sender: TObject);
140146 procedure FindUrlButtonClick(Sender: TObject);
141147 procedure TextMouseUp(Sender: TObject; Button: TMouseButton;
@@ -144,6 +150,9 @@
144150 procedure PathEditButtonClick(Sender: TObject);
145151 procedure PTextFindClick(Sender: TObject);
146152 procedure PTextFindUrlClick(Sender: TObject);
153+ procedure PathSelButtonClick(Sender: TObject);
154+ procedure GridFilesSetEditText(Sender: TObject; ACol, ARow: Integer;
155+ const Value: string);
147156 private
148157 { Private 宣言 }
149158 public
@@ -161,13 +170,13 @@
161170
162171 implementation
163172
164-uses strutils,IOUtils,masks,clipbrd,SHELLAPI;
173+uses strutils,IOUtils,masks,clipbrd,SHELLAPI,Vcl.FileCtrl;
165174
166175 var
167176 Malloc :IMalloc;
168177 FMouseDownPt:TPoint;
169178 SL :TStringDynArray;
170- Ini :TIniFile;
179+ Ini :TMemIniFile;
171180 inidir :string;
172181 pname :string;
173182
@@ -182,7 +191,7 @@
182191 CFILE =2;
183192 CPATH =3;
184193 var
185- CHEAD:TStringDynArray =['','テキスト','ファイル','パス'];
194+ CHEAD:TStringDynArray =['','検索文字','ファイル','パス'];
186195
187196 {$R *.dfm}
188197
@@ -202,7 +211,7 @@
202211
203212 procedure TTextDeFindForm.FormCreate(Sender:TObject);
204213 begin
205- Ini:=TIniFile.Create(ChangeFileExt(Application.ExeName,'.INI'));
214+ Ini:=TMemIniFile.Create(ChangeFileExt(Application.ExeName,'.INI'));
206215 inidir:=Ini.ReadString('','inidir',inidir);
207216 OpenDialog.InitialDir:=ExtractFileDir(Application.ExeName);
208217 SaveDialog.InitialDir:=ExtractFileDir(Application.ExeName);
@@ -220,7 +229,6 @@
220229 Files:=TGrid.CreateEX(GridFiles);
221230
222231 Tree.LoadFromFile(ChangeFileExt(Application.ExeName,'.txt'));
223- files.Load(ChangeFileExt(Application.ExeName,'.csv'));
224232 NameChange(Sender);
225233 pname:=Name.Text;
226234 TreeClick(Sender);
@@ -235,12 +243,14 @@
235243 Ini.WriteString('','Path.Text',Path.Text);
236244 Ini.WriteString('','Url.Text',Url.Text);
237245 Ini.writestrings('Url.Items',Url.Items);
238- Ini.Free;
239246
240247 NameChange(Sender);
241248 Tree.SaveToFile(ChangeFileExt(Application.ExeName,'.txt'));
242- files.save(ChangeFileExt(Application.ExeName,'.csv'));
243249
250+
251+ Ini.UpdateFile;
252+ Ini.Free;
253+
244254 end;
245255
246256
@@ -401,6 +411,14 @@
401411 end;
402412
403413
414+procedure TTextDeFindForm.GridFilesSetEditText(Sender: TObject; ACol,
415+ ARow: Integer; const Value: string);
416+begin
417+// ShowMessage(Value);
418+// GridFiles.Options:=GridFiles.Options-[goEditing]+[goRangeSelect];
419+
420+end;
421+
404422 procedure TTextDeFindForm.TextMouseUp(Sender: TObject; Button: TMouseButton;
405423 Shift: TShiftState; X, Y: Integer);
406424 var l:integer;
@@ -476,6 +494,16 @@
476494 end;
477495
478496
497+procedure TTextDeFindForm.PathSelButtonClick(Sender: TObject);
498+var
499+ SelectFolder : String;
500+begin
501+ SelectFolder := Path.text;
502+ if SelectDirectory(Path.text,'',SelectFolder,[sdNewUI, sdNewFolder, sdShowEdit],Self) then begin
503+ Path.text:=SelectFolder;
504+ end;
505+end;
506+
479507 procedure TTextDeFindForm.UrlEditButtonClick(Sender: TObject);
480508 begin
481509 Url.Items.Text:=inputtextbox(self,Url,Url.Items.Text);
@@ -528,6 +556,7 @@
528556 for s in Text.lines do
529557 Tree.Items.AddChild(NN,s);
530558
559+ Ini.writegrid('grid\'+pname,TGrid(GridFiles));
531560 end;
532561
533562 end;
@@ -537,6 +566,7 @@
537566 while N<>nil do begin
538567 if N.text=Name.text then begin
539568 childtext(N);
569+ Ini.readgrid('grid\'+Name.text,TGrid(GridFiles));
540570 end;
541571 N:=N.getNextSibling;
542572 end;
@@ -694,39 +724,33 @@
694724
695725 function TTextDeFindForm.GetFilePathDataObject(G:TStringGrid):IDataObject;
696726 var
697- fDesktop,fTargetFolder:IShellFolder;
698- Filepidl :packed array of PItemIDList;
699- Dirpidl :PItemIDList;
727+ ISFD,ISF:IShellFolder;
728+ PItems :packed array of PItemIDList;
729+ PItem :PItemIDList;
700730 pchEaten,dwAttributes :Cardinal;
701- Dir,FileName :Widestring;
702- i,r,count :Integer;
703- SourceFile :string;
731+ fn,fnpath :Widestring;
732+ i,count :Integer;
704733 begin
705734 Result:=nil;
735+ count:=0;
706736
707- count:=G.selection.Bottom-G.selection.top+1;
708- SetLength(Filepidl,count);
709- SHGetDesktopFolder(fDesktop);
710- if Failed(fDesktop.ParseDisplayName(0,nil,PWideChar(Path.text),pchEaten,Dirpidl,dwAttributes)) then exit;
711- if Failed(fDesktop.BindToObject(Dirpidl,nil,IID_IShellFolder,fTargetFolder)) then exit;
737+ SHGetDesktopFolder(ISFD);
738+ if Failed(ISFD.ParseDisplayName(0,nil,PWideChar(Path.text),pchEaten,PItem,dwAttributes)) then exit;
739+ if Failed(ISFD.BindToObject(PItem,nil,IID_IShellFolder,ISF)) then exit;
712740
741+ for i:=G.selection.top to G.selection.Bottom do begin
742+ fn:=INCBS(G.cells[CPATH,i])+G.cells[CFILE,i];
713743
714- for i:=0 to count-1 do begin
715- r:=i+G.selection.top;
744+ if not FileExists(fn) then continue;
745+ inc(count);
746+ SetLength(PItems,count);
747+ fnpath:=ExtractRelativePath(INCBS(Path.text),fn);
716748
717- SourceFile:=INCBS(G.cells[CPATH,r])+G.cells[CFILE,r];
718- if not FileExists(SourceFile) then exit;
719-
720- Dir:=ExtractFileDir(SourceFile);
721- FileName:=ExtractRelativePath(INCBS(Path.text),SourceFile);
722-
723- if Failed(fTargetFolder.ParseDisplayName(0,nil,PWideChar(FileName),pchEaten,Filepidl[i],dwAttributes)) then exit;
724-
749+ if Failed(ISF.ParseDisplayName(0,nil,PWideChar(fnpath),pchEaten,PItems[count-1],dwAttributes)) then exit;
725750 end;
726-
727751 if count<1 then exit;
728752
729- fTargetFolder.GetUIObjectOf(0,count,Filepidl[0],IDataObject,nil,Pointer(Result));
753+ ISF.GetUIObjectOf(0,count,PItems[0],IDataObject,nil,Pointer(Result));
730754 end;
731755
732756
@@ -960,6 +984,14 @@
960984 for j:=selection.left to selection.right do func(j,i);
961985 end;
962986
987+function TGrid.alldo(func:TFuncXY):Integer;
988+var
989+ i,j:Integer;
990+begin
991+ for i:=0 to rowcount-1 do
992+ for j:=0 to colcount-1 do func(j,i);
993+end;
994+
963995 function TGrid.selrowdo(func:TFuncXY):Integer;
964996 var
965997 i:Integer;
@@ -967,6 +999,21 @@
967999 for i:=selection.top to selection.Bottom do func(0,i);
9681000 end;
9691001
1002+procedure TGrid.SetEditText(ACol, ARow: Integer;
1003+ const Value: string);
1004+begin
1005+ inherited;
1006+ Options:=Options-[goEditing]+[goRangeSelect];
1007+end;
1008+
1009+function TGrid.rowdo(func: TFuncXY): Integer;
1010+var
1011+ i:Integer;
1012+begin
1013+ for i:=0 to rowcount-1 do func(0,i);
1014+
1015+end;
1016+
9701017 procedure TGrid.KeyDown(var Key:Word;Shift:TShiftState);
9711018 var
9721019 w:Word;
@@ -995,6 +1042,12 @@
9951042 begin
9961043 MouseToCell(X,Y,ACol,ARow);
9971044 downinselection:=gridInRect(ACol,ARow,selection);
1045+ if ssDouble in Shift then begin
1046+ Options:=Options+[goEditing]-[goRangeSelect];
1047+ Col:=ACol;
1048+ Row:=ARow;
1049+ EditorMode:=true;
1050+ end;
9981051 if downinselection then exit;
9991052
10001053 // Options:=Options-[goEditing]+[goRangeSelect];
@@ -1116,6 +1169,7 @@
11161169 RowCount:=w;
11171170 end;
11181171
1172+
11191173 function TGrid.RowInsert(Y,cnt:Integer):Integer;
11201174 var
11211175 i :Integer;
@@ -1238,25 +1292,55 @@
12381292 for i:=0 to sa.Count-1 do
12391293 if i<Count then
12401294 Self[i]:=sa[i];
1295+end;
12411296
1297+{ TIniFileHelper }
12421298
1299+procedure TMemIniFileHelper.readgrid(sc: string; G: TGrid);
1300+var x,y:integer;
1301+ s:string;
1302+begin
1303+ G.rowdo(procedure(X,Y:Integer)begin
1304+ G.rows[y].clear;
1305+ end);
1306+ G.rowcount:=1;
1307+ for y:=0 to 1024 do begin
1308+ for x:=0 to G.ColCount-1 do begin
1309+ s:=inttostr(y)+','+inttostr(x);
1310+ if not ini.ValueExists(sc,s) then break;
1311+ if x>=G.colcount then G.colcount:=x+1;
1312+ if y>=G.rowcount then G.rowcount:=y+1;
1313+ G.cells[x,y]:=Ini.ReadString(sc,inttostr(y)+','+inttostr(x),'');
1314+ end;
1315+ end;
1316+ if G.rowcount<2 then G.rowcount:=2;
1317+ G.fixedrows:=1;
1318+ G.Rows[0].setstrings(CHEAD);
1319+ G.ColExpand(10);
12431320 end;
12441321
1245-{ TIniFileHelper }
1322+procedure TMemIniFileHelper.writegrid(sc: string; G: TGrid);
1323+begin
1324+ Ini.EraseSection(sc);
1325+ G.alldo(procedure(X,Y:Integer)begin
1326+ Ini.WriteString(sc,inttostr(y)+','+inttostr(x),G.cells[x,y]);
1327+ end);
1328+
1329+end;
12461330
1247-procedure TIniFileHelper.readstrings(sc: string; sl:TStrings);
1331+procedure TMemIniFileHelper.readstrings(sc: string; sl:TStrings);
12481332 var i:integer;
12491333 s:string;
12501334 begin
12511335 sl.Clear;
12521336 for i:=0 to 1024 do begin
1253- if not ini.ValueExists(sc,inttostr(i)) then
1254- break;
1337+ if not ini.ValueExists(sc,inttostr(i)) then break;
12551338 sl.add(Ini.ReadString(sc,inttostr(i),''));
12561339 end;
12571340 end;
12581341
1259-procedure TIniFileHelper.writestrings(sc: string; sl: TStrings);
1342+
1343+procedure TMemIniFileHelper.writestrings(sc: string; sl: TStrings);
12601344 var i:integer;
12611345 begin
12621346 Ini.EraseSection(sc);