/
ProjectView.ec
1887 lines (1711 loc) · 61.1 KB
/
ProjectView.ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import "ide"
import "FileSystemIterator"
class ImportFolderFSI : NormalFileSystemIterator
{
ProjectView projectView;
Array<ProjectNode> stack { };
bool OnFolder(char * folderPath)
{
char name[MAX_LOCATION];
ProjectNode parentNode = stack.lastIterator.data;
ProjectNode folder;
GetLastDirectory(folderPath, name);
folder = parentNode.FindSpecial(name, false, true, true);
if(!folder)
folder = projectView.NewFolder(parentNode, name, false);
stack.Add(folder);
return true;
}
void OutFolder(char * folderPath, bool isRoot)
{
stack.lastIterator.Remove(); //stack.Remove();
}
bool OnFile(char * filePath)
{
ProjectNode parentNode = stack.lastIterator.data;
projectView.AddFile(parentNode, filePath, parentNode.isInResources, false);
return true;
}
}
static FileFilter fileFilters[] =
{
{
"EC/C/C++ Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)",
"ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx"
},
{
"EC/C/C++ Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)",
"ec, eh, c, cpp, cc, cxx"
},
{
"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)",
"eh, h, hpp, hh, hxx"
},
{ "All files", null }
};
static FileFilter resourceFilters[] =
{
{
"Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png,*.gif)",
"jpg, jpeg, bmp, pcx, png, gif"
},
{
"3D Studio Model Files (*.3ds)",
"3ds"
},
{ "All files", null }
};
static FileType fileTypes[] =
{
{ "Based on extension", null },
{ "Text", "txt" },
{ "Image", "jpg" },
{ "3D Studio Model", "3ds" }
};
static FileFilter projectFilters[] =
{
{ "Project Files (*.epj)", ProjectExtension },
{ "Workspace Files (*.ews)", WorkspaceExtension }
};
static FileType projectTypes[] =
{
{ "ECERE Project", ProjectExtension },
{ "ECERE Workspace", WorkspaceExtension }
};
static char * iconNames[] =
{
"<:ecere>mimeTypes/file.png", /*genFile*/
"<:ecere>mimeTypes/textEcereWorkspace.png", /*ewsFile*/
"<:ecere>mimeTypes/textEcereProject.png", /*epjFile*/
"<:ecere>places/folder.png", /*folder*/
"<:ecere>status/folderOpen.png", /*openFolder*/
"<:ecere>mimeTypes/textEcereSource.png", /*ecFile*/
"<:ecere>mimeTypes/textEcereHeader.png", /*ehFile*/
"<:ecere>mimeTypes/textCSource.png", /*cFile*/
"<:ecere>mimeTypes/textCHeader.png", /*hFile*/
"<:ecere>mimeTypes/textC++Source.png", /*cppFile*/
"<:ecere>mimeTypes/textC++Header.png", /*hppFile*/
"<:ecere>mimeTypes/text.png", /*textFile*/
"<:ecere>mimeTypes/textHyperTextMarkup.png", /*webFile*/
"<:ecere>mimeTypes/image.png", /*pictureFile*/
"<:ecere>status/audioVolumeHigh.png", /*soundFile*/
"<:ecere>mimeTypes/package.png", /*archiveFile*/
"<:ecere>mimeTypes/packageSoftware.png", /*packageFile*/
"<:ecere>mimeTypes/packageOpticalDisc.png" /*opticalMediaImageFile*/
};
enum PrepareMakefileMethod { normal, force, forceExists };
enum BuildType { build, rebuild, relink, run, debug };
class ProjectView : Window
{
isDocument = true;
//hasMinimize = true;
hasClose = true;
borderStyle = sizable;
hasHorzScroll = true;
hasVertScroll = true;
background = white;
size = { 300 };
anchor = Anchor { left = 0, top = 0, bottom = 0 };
menu = Menu { };
//hasMinimize = true;
saveDialog = projectFileDialog;
DataRow resourceRow;
bool buildInProgress;
BitmapResource icons[NodeIcons];
Project project;
Workspace workspace;
property Workspace workspace
{
set
{
if(workspace)
{
for(prj : workspace.projects)
{
DeleteNode(prj.topNode);
}
workspace.projects.Free();
ide.debugger.CleanUp();
}
workspace = value;
if(workspace)
{
fileDialog.currentDirectory = workspace.workspaceDir;
resourceFileDialog.currentDirectory = workspace.workspaceDir;
for(prj : workspace.projects)
AddNode(prj.topNode, null);
ide.statusBar.text = "Generating Makefile & Dependencies...";
app.UpdateDisplay();
for(prj : workspace.projects)
prj.ModifiedAllConfigs(true, false, false, false);
ide.statusBar.text = "Initializing Debugger"; app.UpdateDisplay();
ide.statusBar.text = null;
app.UpdateDisplay();
}
}
get { return workspace; }
}
/*property Project project
{
set
{
if(project)
{
DeleteNode(project.topNode);
project.Free();
}
project = value;
if(project)
{
AddNode(project.topNode, null);
fileDialog.currentDirectory = project.topNode.path;
resourceFileDialog.currentDirectory = project.topNode.path;
// Make sure this is done already...
{
char filePath[MAX_LOCATION];
strcpy(filePath, project.topNode.path);
PathCat(filePath, project.topNode.name);
strcat(filePath, ".epj");
fileName = filePath;
}
ide.statusBar.text = "Generating Makefile & Dependencies...";
app.UpdateDisplay();
// REDJ set makefile generation flag so generation occurs only when compiling instead of generating on the spot
project.config.makingModified = true;
ide.statusBar.text = "Initializing Debugger";
ide.statusBar.text = null;
app.UpdateDisplay();
}
}
get { return project; }
}*/
bool drawingInProjectSettingsDialog;
bool drawingInProjectSettingsDialogHeader;
ProjectSettings projectSettingsDialog;
ListBox fileList
{
multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
{
if(!active) Update(null);
return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
}
bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
{
OpenSelectedNodes();
return true;
}
bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
{
DataRow row = listBox.currentRow;
if(row)
{
ProjectNode node = (ProjectNode)row.tag;
if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
{
PopupMenu popupMenu;
Menu popupContent { };
if(node.type == NodeTypes::project)
{
//if(node == ((Project)workspace.projects.first).topNode)
{
MenuItem { popupContent, "Build", b, NotifySelect = ProjectBuild }.disabled = buildInProgress;
MenuItem { popupContent, "Relink", l, NotifySelect = ProjectLink }.disabled = buildInProgress;
MenuItem { popupContent, "Rebuild", r, NotifySelect = ProjectRebuild }.disabled = buildInProgress;
MenuItem { popupContent, "Clean", c, NotifySelect = ProjectClean }.disabled = buildInProgress;
MenuItem { popupContent, "Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildInProgress;
MenuDivider { popupContent };
}
MenuItem { popupContent, "New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
MenuItem { popupContent, "New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
MenuItem { popupContent, "Import Folder...", i, NotifySelect = ProjectImportFolder };
MenuItem { popupContent, "Add Files to Project...", f, NotifySelect = ProjectAddFiles };
MenuDivider { popupContent };
MenuItem { popupContent, "Add New Form...", o, NotifySelect = ProjectAddNewForm };
// MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
MenuDivider { popupContent };
if(node != ((Project)workspace.projects.first).topNode)
{
MenuItem { popupContent, "Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildInProgress;
MenuDivider { popupContent };
}
MenuItem { popupContent, "Active Configuration...", s, Key { f5, alt = true } , NotifySelect = MenuConfig };
MenuItem { popupContent, "Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
MenuDivider { popupContent };
MenuItem { popupContent, "Browse Folder", w, NotifySelect = MenuBrowseFolder };
MenuDivider { popupContent };
MenuItem { popupContent, "Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
MenuDivider { popupContent };
MenuItem { popupContent, "Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
}
else if(node.type == resources)
{
MenuItem { popupContent, "New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
MenuItem { popupContent, "New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
MenuItem { popupContent, "Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
MenuItem { popupContent, "Browse Folder", w, NotifySelect = MenuBrowseFolder };
MenuDivider { popupContent };
MenuItem { popupContent, "Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
MenuItem { popupContent, "Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
}
else if(node.type == file)
{
MenuItem { popupContent, "Open", o, NotifySelect = FileOpenFile };
MenuItem { popupContent, "Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildInProgress;
MenuDivider { popupContent };
MenuItem { popupContent, "Remove", r, NotifySelect = FileRemoveFile };
MenuDivider { popupContent };
MenuItem { popupContent, "Browse Folder", w, NotifySelect = MenuBrowseFolder };
MenuDivider { popupContent };
MenuItem { popupContent, "Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
MenuItem { popupContent, "Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
}
else if(node.type == folder)
{
bool isInResources = node.isInResources;
MenuItem { popupContent, "New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
MenuItem { popupContent, "New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
MenuItem { popupContent, "Import Folder...", i, NotifySelect = ProjectImportFolder };
if(isInResources)
{
MenuItem { popupContent, "Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
}
else
{
MenuItem { popupContent, "Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
}
if(!isInResources)
{
MenuDivider { popupContent };
MenuItem { popupContent, "Add New Form...", o, NotifySelect = ProjectAddNewForm };
MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
}
MenuDivider { popupContent };
MenuItem { popupContent, "Remove", r, NotifySelect = FileRemoveFile };
MenuDivider { popupContent };
MenuItem { popupContent, "Browse Folder", w, NotifySelect = MenuBrowseFolder };
MenuDivider { popupContent };
MenuItem { popupContent, "Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
MenuItem { popupContent, "Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
}
popupMenu =
{
master = this, menu = popupContent;
position = {
x + clientStart.x + absPosition.x - app.desktop.position.x,
y + clientStart.y + absPosition.y - app.desktop.position.y };
};
popupMenu.Create();
}
}
return true;
}
bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
{
if(row)
{
ProjectNode node = (ProjectNode)row.tag;
switch(key)
{
case altEnter: case Key { keyPadEnter, alt = true }:
{
NodeProperties { parent = parent, master = this,
position = { position.x + 100, position.y + 100 }, node = node }.Create();
return false;
}
case enter: case keyPadEnter:
{
ProjectNode resNode;
for(resNode = node.parent; resNode; resNode = resNode.parent)
if(resNode.type == resources)
break;
if(node.type == project || (node.type == folder && !resNode))
{
AddFiles(false);
return false;
}
else if(node.type == resources || node.type == folder)
{
AddFiles(true);
return false;
}
break;
}
case ctrlI:
{
if(node.type == project || node.type == folder || node.type == resources)
{
ImportFolder(node);
return false;
}
break;
}
case ctrlF:
{
if(node.type == project || node.type == folder || node.type == resources)
{
NewFolder(node, null, true);
return false;
}
break;
}
case ctrlF7:
{
if(node.type == file)
{
FileCompile(null, (Modifiers)key);
return false;
}
break;
}
case Key { space, shift = true }:
case space:
{
if(node.type == NodeTypes::project)
{
Project prj = null;
for(p : workspace.projects)
{
if(p.topNode == node)
{
prj = p;
break;
}
}
prj.RotateActiveConfig(!key.shift);
if(prj == project)
ide.UpdateDisabledMenus();
return false;
}
break;
}
}
}
switch(key)
{
case enter: case keyPadEnter: OpenSelectedNodes(); break;
case del: RemoveSelectedNodes(); break;
case escape:
{
Window activeClient = ide.activeClient;
if(activeClient)
activeClient.Activate();
else
ide.RepositionWindows(true);
break;
}
}
return true;
}
bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
{
ProjectNode node = (ProjectNode)row.tag;
if(node.type == folder)
node.icon = collapsed ? folder : openFolder;
return true;
}
};
FileDialog importFileDialog { autoCreate = false, type = selectDir, text = "Import Folder" };
FileDialog projectFileDialog
{
autoCreate = false, filters = projectFilters, sizeFilters = sizeof(projectFilters);
types = projectTypes, sizeTypes = sizeof(projectTypes);
};
FileDialog fileDialog
{
autoCreate = false, mayNotExist = true, filters = fileFilters, sizeFilters = sizeof(fileFilters);
types = fileTypes, sizeTypes = sizeof(fileTypes);
};
FileDialog resourceFileDialog
{
autoCreate = false, mayNotExist = true, filters = resourceFilters, sizeFilters = sizeof(resourceFilters);
types = fileTypes, sizeTypes = sizeof(fileTypes);
};
Menu fileMenu { menu, "File", f };
MenuItem { fileMenu, "Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
// MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
bool OnClose(bool parentClosing)
{
if(!parentClosing && visible)
{
visible = false;
return false;
}
if(buildInProgress)
return false;
return true;
}
void OnDestroy(void)
{
//if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
// ide.findInFilesDialog.SearchStop();
ide.outputView.buildBox.Clear();
ide.outputView.debugBox.Clear();
//ide.outputView.findBox.Clear();
ide.callStackView.Clear();
ide.watchesView.Clear();
ide.threadsView.Clear();
ide.breakpointsView.Clear();
ide.outputView.ShowClearSelectTab(find); // why this?
}
bool OnSaveFile(char * fileName)
{
for(prj : ide.workspace.projects)
{
if(prj.topNode.modified && prj.Save(prj.filePath))
{
// ProjectUpdateMakefileForAllConfigs(prj, true, true);
prj.topNode.modified = false;
}
}
modifiedDocument = false;
Update(null);
return true;
}
bool IsModuleInProject(char * filePath)
{
char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
GetLastDirectory(filePath, moduleName);
return project.topNode.Find(moduleName, false) != null;
}
bool GetRelativePath(char * filePath, char * relativePath)
{
/*ProjectNode node;
char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
GetLastDirectory(filePath, moduleName);
// try with workspace dir first?
if((node = project.topNode.Find(moduleName, false)))
{
strcpy(relativePath, node.path);
PathCatSlash(relativePath, node.name);
return true;
}
// WARNING: On failure, relative path is uninitialized
return false; */
return project.GetRelativePath(filePath, relativePath);
}
ProjectNode GetNodeFromWindow(Window document, Project project)
{
if(document.fileName)
{
char winFileName[MAX_LOCATION];
char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
for(p : ide.workspace.projects)
{
Project prj = project ? project : p;
ProjectNode node;
char moduleName[MAX_FILENAME], modulePath[MAX_LOCATION];
GetLastDirectory(document.fileName, moduleName);
if((node = prj.topNode.Find(moduleName, false)))
{
strcpy(modulePath, prj.topNode.path);
PathCatSlash(modulePath, node.path);
PathCatSlash(modulePath, node.name);
if(!fstrcmp(documentFileName, modulePath))
{
return node;
}
}
if(project) break;
}
}
return null;
}
void Compile(ProjectNode node)
{
char fileName[MAX_LOCATION];
char extension[MAX_EXTENSION];
Window document;
Project prj = node.project;
CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
DirExpression objDir = prj.objDir;
strcpy(fileName, prj.topNode.path);
PathCatSlash(fileName, objDir.dir);
PathCatSlash(fileName, node.name);
StripExtension(fileName);
strcat(fileName, ".o");
if(FileExists(fileName))
DeleteFile(fileName);
GetExtension(node.name, extension);
if(!strcmp(extension, "ec"))
{
// Delete generated C file
strcpy(fileName, prj.topNode.path);
PathCat(fileName, objDir.dir);
PathCat(fileName, node.name);
StripExtension(fileName);
strcat(fileName, ".c");
if(FileExists(fileName))
DeleteFile(fileName);
// Delete symbol file
strcpy(fileName, prj.topNode.path);
PathCat(fileName, node.path);
PathCat(fileName, node.name);
StripExtension(fileName);
strcat(fileName, ".sym");
if(FileExists(fileName))
DeleteFile(fileName);
}
ide.StopBuild(false);
// Check if we have to save
strcpy(fileName, prj.topNode.path);
PathCatSlash(fileName, node.path);
PathCatSlash(fileName, node.name);
for(document = ide.firstChild; document; document = document.next)
{
if(document.modifiedDocument)
{
char documentFileName[MAX_LOCATION];
if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
if(!document.MenuFileSave(null, 0))
return;
}
}
if(ProjectPrepareForToolchain(prj, normal, true, true))
{
if(!node.isExcluded)
{
buildInProgress = true;
//ide.outputView.ShowClearSelectTab(build);
// this stuff doesn't even appear
//ide.outputView.buildBox.Logf("%s Compiler\n", compiler.name);
if(prj.config)
ide.outputView.buildBox.Logf("Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, prj.config.name);
else
ide.outputView.buildBox.Logf("Compiling single file %s in project %s...\n", node.name, prj.name);
ide.DisableBuildItems(true, false);
prj.Compile(node);
ide.DisableBuildItems(false, false);
buildInProgress = false;
}
else
ide.outputView.buildBox.Logf("File %s is excluded from current build configuration.\n", node.name);
}
delete objDir;
delete compiler;
}
void GoToError(const char * line)
{
char * colon;
while(isspace(*line)) line++;
colon = strstr(line, ":");
{
int lineNumber = 0;
int col = 1;
bool lookForLineNumber = true;
// deal with linking error
if(colon && colon[1] == ' ')
{
colon = strstr(colon + 1, ":");
if(colon && !colon[1])
{
colon = strstr(line, ":");
lookForLineNumber = false;
}
else if(colon && !isdigit(colon[1]))
{
line = colon + 1;
colon = strstr(line, ":");
}
}
// Don't be mistaken by the drive letter colon
if(colon && (colon[1] == '/' || colon[1] == '\\'))
colon = strstr(colon + 1, ":");
if(colon && lookForLineNumber)
{
char * comma;
// MSVS Errors
char * par = RSearchString(line, "(", colon - line, true, false);
if(par && strstr(par, ")"))
colon = par;
else if((colon+1)[0] == ' ')
{
// NOTE: This is the same thing as saying 'colon = line'
for( ; colon != line; colon--)
/*if(*colon == '(')
break*/;
}
lineNumber = atoi(colon + 1);
/*
comma = strchr(colon, ',');
if(comma)
col = atoi(comma+1);
*/
comma = strchr(colon+1, ':');
if(comma)
col = atoi(comma+1);
}
{
char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
char * bracket;
if(colon)
{
// Cut module name
strncpy(moduleName, line, colon - line);
moduleName[colon - line] = '\0';
}
else
strcpy(moduleName, line);
// Remove stuff in brackets
/*
bracket = strstr(moduleName, "(");
if(bracket) *bracket = '\0';
*/
MakeSlashPath(moduleName);
if(!colon)
{
// Check if it's one of our modules
ProjectNode node = project.topNode.Find(moduleName, false);
if(node)
{
strcpy(moduleName, node.path);
PathCatSlash(moduleName, node.name);
}
else
moduleName[0] = '\0';
}
if(moduleName[0])
{
CodeEditor codeEditor;
strcpy(filePath, project.topNode.path);
PathCatSlash(filePath, moduleName);
codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
if(!codeEditor)
{
char name[MAX_LOCATION];
// TOFIX: Improve on this, don't use only filename, make a function
if(ide && ide.workspace)
{
for(prj : ide.workspace.projects)
{
if(prj.topNode.FindWithPath(moduleName, false))
{
strcpy(filePath, prj.topNode.path);
PathCatSlash(filePath, moduleName);
codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
if(codeEditor)
break;
}
}
}
}
if(codeEditor && lineNumber)
{
EditBox editBox = codeEditor.editBox;
editBox.GoToLineNum(lineNumber - 1);
editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
}
}
}
}
}
bool OpenNode(ProjectNode node)
{
char filePath[MAX_LOCATION];
node.GetFullFilePath(filePath);
return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
}
void AddNode(ProjectNode node, DataRow addTo)
{
DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
row.tag = (int)node;
node.row = row;
if(node.type == resources)
resourceRow = row;
row.SetData(null, node);
if(node.files && node.files.first && node.parent &&
!(!node.parent.parent &&
(!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
!strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
row.collapsed = true;
else if(node.type == folder)
node.icon = openFolder;
if(node.files)
{
for(child : node.files)
AddNode(child, row);
}
}
void DeleteNode(ProjectNode projectNode)
{
if(projectNode.files)
{
ProjectNode child;
while(child = projectNode.files.first)
DeleteNode(child);
}
fileList.DeleteRow(projectNode.row);
projectNode.Delete();
}
ProjectView()
{
NodeIcons c;
for(c = 0; c < NodeIcons::enumSize; c++)
{
icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
AddResource(icons[c]);
}
fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
}
~ProjectView()
{
DebugStop();
ide.DestroyTemporaryProjectDir();
if(project)
{
workspace.Free();
delete workspace;
}
}
bool ProjectSave(MenuItem selection, Modifiers mods)
{
DataRow row = fileList.currentRow;
ProjectNode node = row ? (ProjectNode)row.tag : null;
Project prj = node ? node.project : null;
if(prj)
{
if(prj.Save(prj.filePath))
{
// ProjectUpdateMakefileForAllConfigs(prj, true, true);
prj.topNode.modified = false;
prj = null;
for(p : ide.workspace.projects)
{
if(p.topNode.modified)
{
prj = p;
break;
}
}
if(!prj)
modifiedDocument = false;
Update(null);
}
}
return true;
}
bool ShowOutputBuildLog(bool cleanLog)
{
OutputView output = ide.outputView;
if(cleanLog)
output.ShowClearSelectTab(build);
else
{
output.SelectTab(build);
output.Show();
}
}
bool DisplayCompiler(bool cleanLog)
{
CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
LogBox logBox = ide.outputView.buildBox;
ShowOutputBuildLog(cleanLog);
logBox.Logf("%s Compiler\n", compiler ? compiler.name : "{problem with compiler selection}");
delete compiler;
}
bool ProjectUpdateMakefileForAllConfigs(Project project, bool cleanLog, bool displayCompiler)
{
ProjectConfig currentConfig = project.config;
ShowOutputBuildLog(cleanLog);
if(displayCompiler)
DisplayCompiler(false);
for(config : project.configurations)
{
project.config = config;
ProjectPrepareMakefile(project, forceExists, false, false);
}
project.config = currentConfig;
ide.Update(null);
}
bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler)
{
bool isReady = true;
char message[MAX_F_STRING];
LogBox logBox = ide.outputView.buildBox;
ShowOutputBuildLog(cleanLog);
if(displayCompiler)
DisplayCompiler(false);
ProjectPrepareMakefile(project, method, false, false);
return true;
}
bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler)
{
char makefilePath[MAX_LOCATION];
char makefileName[MAX_LOCATION];
bool exists;
LogBox logBox = ide.outputView.buildBox;
ShowOutputBuildLog(cleanLog);
if(displayCompiler)
DisplayCompiler(false);
strcpy(makefilePath, project.topNode.path);
project.CatMakeFileName(makefileName);
PathCatSlash(makefilePath, makefileName);
exists = FileExists(makefilePath);
if((method == normal && (!exists || project.config.makingModified/*|| project.topNode.modified*/)) ||
(method == forceExists && exists) ||
method == force) // || project.config.makingModified || makefileDirty
{
char * reason;
char * action;
ide.statusBar.text = "Generating Makefile & Dependencies..."; // Dependencies?
app.UpdateDisplay();
if((method == normal && !exists) || (method == force && !exists))
action = "Generating ";
else if(method == force)
action = "Regenerating ";
else if(method == normal || method == forceExists)
action = "Updating ";
else
action = "";
if(!exists)
reason = "Makefile doesn't exist. ";
else if(project.topNode.modified)
reason = "Project has been modified. ";
else
reason = "";
//logBox.Logf("%s\n", makefileName);
logBox.Logf("%s - %s%smakefile for %s config...\n", makefileName, reason, action, project.configName);
project.GenerateMakefile(null, false, null);
ide.statusBar.text = null;
app.UpdateDisplay();
return true;
}
return false;
}
bool ProjectBuild(MenuItem selection, Modifiers mods)
{
Project prj = project;
if(selection || !ide.activeClient || activeClient == this)
{
DataRow row = fileList.currentRow;
ProjectNode node = row ? (ProjectNode)row.tag : null;
if(node) prj = node.project;
}
// Added this code here until dependencies work:
else //if(ide.activeClient)
{
ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
if(node)
prj = node.project;
}
if(/*prj != project || */!prj.configIsInDebugSession || !ide.DontTerminateDebugSession("Project Build"))
BuildInterrim(prj, build, false);
return true;
}
bool BuildInterrim(Project prj, BuildType buildType, bool disableDebugStart)
{
if(ProjectPrepareForToolchain(prj, normal, true, true))
{
ide.outputView.buildBox.Logf("Building project %s using the %s configuration...\n", prj.name, prj.configName);
return Build(prj, buildType, disableDebugStart);
}
return false;
}
bool ProjectLink(MenuItem selection, Modifiers mods)
{
Project prj = project;
if(selection || !ide.activeClient || activeClient == this)
{