FindFileIcons.diff
FindFile.cpp (kopia robocza) | ||
---|---|---|
1 |
#include "ide.h" |
|
2 | ||
3 |
static int CharFilterFindFileMask(int c) |
|
4 |
{ |
|
5 |
return ToUpper(ToAscii(c)); |
|
6 |
} |
|
7 | ||
8 |
class FindFileWindow final : public WithFindFileLayout<TopWindow> { |
|
9 |
private: |
|
10 |
struct FindFileFileDisplay : public Display { |
|
11 |
void Paint(Draw& w, const Rect& r, const Value& q, |
|
12 |
Color ink, Color paper, dword style) const override |
|
13 |
{ |
|
14 |
String txt = q; |
|
15 |
Image fileImage = IdeFileImage(txt, false, false); |
|
16 |
|
|
17 |
int cellHeight = r.bottom - r.top; |
|
18 |
|
|
19 |
w.DrawRect(r, paper); |
|
20 |
w.DrawImage(r.left, r.top + ((cellHeight - fileImage.GetHeight()) / 2), fileImage); |
|
21 |
w.DrawText(r.left + fileImage.GetWidth() + Zx(5), r.top + ((cellHeight - StdFont().GetCy()) / 2), txt, StdFont(), ink); |
|
22 |
} |
|
23 |
}; |
|
24 | ||
25 |
public: |
|
26 |
FindFileWindow(const Workspace& wspc, const String& serachString); |
|
27 |
|
|
28 |
String GetFile() const; |
|
29 |
String GetPackage() const; |
|
30 |
|
|
31 |
private: |
|
32 |
void OnSearch(); |
|
33 | ||
34 |
private: |
|
35 |
const Workspace& wspc; |
|
36 |
}; |
|
37 | ||
38 |
FindFileWindow::FindFileWindow(const Workspace& wspc, const String& serachString) |
|
39 |
: wspc(wspc) |
|
40 |
{ |
|
41 |
CtrlLayoutOKCancel(*this, "Find File"); |
|
42 |
|
|
43 |
Sizeable().Zoomable(); |
|
44 |
list.AutoHideSb(); |
|
45 |
list.AddColumn("File").SetDisplay(Single<FindFileFileDisplay>()); |
|
46 |
list.AddColumn("Package"); |
|
47 |
list.WhenLeftDouble = Acceptor(IDOK); |
|
48 |
mask.NullText("Search"); |
|
49 |
mask.SetText(serachString); |
|
50 |
mask.SelectAll(); |
|
51 |
mask.SetFilter(CharFilterFindFileMask); |
|
52 |
mask << [=] { OnSearch(); }; |
|
53 |
|
|
54 |
OnSearch(); |
|
55 |
} |
|
56 | ||
57 |
String FindFileWindow::GetFile() const |
|
58 |
{ |
|
59 |
return list.Get(0); |
|
60 |
} |
|
61 | ||
62 |
String FindFileWindow::GetPackage() const |
|
63 |
{ |
|
64 |
return list.Get(1); |
|
65 |
} |
|
66 | ||
67 |
void FindFileWindow::OnSearch() |
|
68 |
{ |
|
69 |
list.Clear(); |
|
70 |
String maskValue = ~mask; |
|
71 |
for(int p = 0; p < wspc.GetCount(); p++) { |
|
72 |
String packname = wspc[p]; |
|
73 |
const Package& pack = wspc.GetPackage(p); |
|
74 |
for(const auto& file : pack.file) |
|
75 |
if(!file.separator && (ToUpper(packname).Find(maskValue) >= 0 || ToUpper(file).Find(maskValue) >= 0)) |
|
76 |
list.Add(file, packname); |
|
77 |
} |
|
78 |
if(list.GetCount() > 0) |
|
79 |
list.SetCursor(0); |
|
80 | ||
81 |
ok.Enable(list.IsCursor()); |
|
82 |
} |
|
83 | ||
84 |
void Ide::FindFileName() |
|
85 |
{ |
|
86 |
FindFileWindow findFileWindow(IdeWorkspace(), find_file_search_string); |
|
87 |
if(findFileWindow.Execute() == IDOK) { |
|
88 |
if(findFileWindow.list.IsCursor()) { |
|
89 |
find_file_search_string = ~findFileWindow.mask; |
|
90 |
EditFile(SourcePath(findFileWindow.GetPackage(), findFileWindow.GetFile())); |
|
91 |
} |
|
92 |
} |
|
93 |
} |
FindInFiles.cpp (kopia robocza) | ||
---|---|---|
183 | 183 |
return true; |
184 | 184 |
} |
185 | 185 | |
186 |
int CharFilterFindFileMask(int c) |
|
187 |
{ |
|
188 |
return ToUpper(ToAscii(c)); |
|
189 |
} |
|
190 | ||
191 |
void Ide::FindFileName() { |
|
192 |
const Workspace& wspc = IdeWorkspace(); |
|
193 | ||
194 |
WithFindFileLayout<TopWindow> ffdlg; |
|
195 |
CtrlLayoutOKCancel(ffdlg, "Find file"); |
|
196 |
ffdlg.list.AutoHideSb(); |
|
197 |
ffdlg.list.AddColumn("Package"); |
|
198 |
ffdlg.list.AddColumn("File"); |
|
199 |
ffdlg.list.WhenLeftDouble = ffdlg.Acceptor(IDOK); |
|
200 |
ffdlg.mask.NullText("Search"); |
|
201 |
ffdlg.mask.SetText(find_file_search_string); |
|
202 |
ffdlg.mask.SelectAll(); |
|
203 |
ffdlg.mask.SetFilter(CharFilterFindFileMask); |
|
204 |
ffdlg.mask <<= ffdlg.Breaker(IDYES); |
|
205 |
for(;;) { |
|
206 |
ffdlg.list.Clear(); |
|
207 |
String mask = ~ffdlg.mask; |
|
208 |
for(int p = 0; p < wspc.GetCount(); p++) { |
|
209 |
String packname = wspc[p]; |
|
210 |
const Package& pack = wspc.GetPackage(p); |
|
211 |
for(const auto& file : pack.file) |
|
212 |
if(!file.separator && (ToUpper(packname).Find(mask) >= 0 || ToUpper(file).Find(mask) >= 0)) |
|
213 |
ffdlg.list.Add(packname, file); |
|
214 |
} |
|
215 |
if(ffdlg.list.GetCount() > 0) |
|
216 |
ffdlg.list.SetCursor(0); |
|
217 |
switch(ffdlg.Run()) { |
|
218 |
case IDCANCEL: |
|
219 |
return; |
|
220 |
case IDOK: |
|
221 |
if(ffdlg.list.IsCursor()) { |
|
222 |
find_file_search_string = ~ffdlg.mask; |
|
223 |
EditFile(SourcePath(ffdlg.list.Get(0), ffdlg.list.Get(1))); |
|
224 |
return; |
|
225 |
} |
|
226 |
break; |
|
227 |
case IDYES: |
|
228 |
break; |
|
229 |
} |
|
230 |
} |
|
231 |
} |
|
232 | ||
233 | 186 |
void Ide::FindInFiles(bool replace) { |
234 | 187 |
CodeEditor::FindReplaceData d = editor.GetFindReplaceData(); |
235 | 188 |
CtrlRetriever rf; |
ide.upp (kopia robocza) | ||
---|---|---|
38 | 38 |
Template.cpp, |
39 | 39 |
ide.key, |
40 | 40 |
Console.cpp, |
41 |
FindFile.cpp, |
|
41 | 42 |
FindInFiles.cpp, |
42 | 43 |
Config.cpp, |
43 | 44 |
ide.cpp, |