3 // *** Color Schemes ***
5 // *** The Old Color Scheme that was causing me auras and ophtalmic migraines -- Uncomment at your own risk! ***
7 FontResource panelFont { $"Courier New", 10 };
8 FontResource codeFont { $"Courier New", 10 };
9 Color selectionColor = Color { 10, 36, 106 };
10 Color selectionText = white;
11 Color viewsBackground = white;
12 Color viewsText = black;
13 Color outputBackground = white;
14 Color outputText = black;
15 Color projectViewBackground = white;
16 Color projectViewText = black;
17 Color codeEditorBG = white;
18 Color codeEditorFG = black;
19 Color marginColor = Color {230, 230, 230};
20 Color selectedMarginColor = Color {200, 200, 200};
21 Color lineNumbersColor = Color {60, 60, 60};
22 SyntaxColorScheme colorScheme
24 keywordColors = [ blue, blue ];
25 commentColor = dimGray;
26 charLiteralColor = crimson;
27 stringLiteralColor = crimson;
28 preprocessorColor = green;
33 // The new nice dark scheme -- so peaceful on my brain
37 //FontResource panelFont { $"Courier New", 10 };
38 //FontResource codeFont { $"Courier New", 10 };
40 FontResource panelFont { $"Consolas", 12 };
41 FontResource codeFont { $"Consolas", 12 };
45 //FontResource panelFont { $"Droid Sans Mono", 12 };
46 //FontResource codeFont { $"Droid Sans Mono", 12 };
48 //FontResource panelFont { $"Anonymous Pro", 11 };
49 //FontResource codeFont { $"Anonymous Pro", 11 };
51 //FontResource panelFont { $"Inconsolata", 12 };
52 //FontResource codeFont { $"Inconsolata", 12 };
54 //FontResource panelFont { $"Source Code Pro", 10, true };
55 //FontResource codeFont { $"Source Code Pro", 10, true };
57 //FontResource panelFont { $"DejaVu Sans Mono", 12/*, true*/ };
58 //FontResource codeFont { $"DejaVu Sans Mono", 12/*, true*/ };
60 //FontResource panelFont { $"Monaco", 10/*, true*/ };
61 //FontResource codeFont { $"Monaco", 10/*, true*/ };
63 FontResource panelFont { $"Monospace", 10, true };
64 FontResource codeFont { $"Monospace", 10, true };
68 Color selectionColor = lightBlue;
69 Color selectionText = Color { 30, 40, 50 };
70 Color viewsBackground = Color { 30, 40, 50 };
71 Color viewsText = lightGray;
72 Color outputBackground = Color { 34, 38, 44 };
73 Color outputText = ivory;
74 Color projectViewBackground = Color { 30, 40, 50 };
75 Color projectViewText = lightGray;
76 Color codeEditorBG = Color { 34, 38, 44 };
77 Color codeEditorFG = white;
78 Color marginColor = Color { 16, 28, 40 };
79 Color selectedMarginColor = Color {64, 64, 64};
80 Color lineNumbersColor = Color {160, 160, 160};
81 SyntaxColorScheme colorScheme
83 keywordColors = [ skyBlue, skyBlue ];
84 commentColor = Color { 125, 125, 125 };
85 charLiteralColor = Color { 245, 50, 245 };
86 stringLiteralColor = Color { 245, 50, 245 };
87 preprocessorColor = { 120, 220, 140 };
88 numberColor = Color { 0, 192, 192 };
91 // *********************
97 // UNTIL IMPLEMENTED IN GRAMMAR
98 #define ACCESS_CLASSDATA(_class, baseClass) \
99 (_class ? ((void *)(((char *)_class.data) + baseClass.offsetClass)) : null)
102 extern int __attribute__((__stdcall__)) __ecereDll_Load_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
103 extern int __attribute__((__stdcall__)) __ecereDll_Unload_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
106 static Array<FileFilter> fileFilters
108 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
109 { $"Header Files for C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
110 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
111 { $"Text files (*.txt)", "txt" },
112 { $"All files", null }
115 static Array<FileType> fileTypes
117 { $"eC Source Code", "ec", whenNoneGiven },
118 { $"Text Files", "txt", never }
121 static const char * iconNames[] =
123 "<:ecere>constructs/class.png",
124 "<:ecere>constructs/data.png",
125 "<:ecere>constructs/method.png",
126 "<:ecere>constructs/event.png",
127 "<:ecere>constructs/property.png",
128 "<:ecere>constructs/namespace.png",
129 "<:ecere>constructs/dataType.png",
130 "<:ecere>constructs/enumValue.png",
131 "<:ecere>constructs/dataPrivate.png",
132 "<:ecere>constructs/methodPrivate.png",
133 "<:ecere>constructs/propertyPrivate.png"
136 enum SheetType { methods, properties };
138 extern int __ecereVMethodID_class_OnEdit;
139 extern int __ecereVMethodID_class_OnDisplay;
140 extern int __ecereVMethodID_class_OnGetString;
141 extern int __ecereVMethodID_class_OnFree;
142 extern int __ecereVMethodID_class_OnCompare;
143 extern int __ecereVMethodID_class_OnCopy;
144 extern int __ecereVMethodID_class_OnSaveEdit;
145 extern int __ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad;
150 bool ignoreBreakpoints:1;
152 bool oldImplementation:1;
155 class EditFileDialog : FileDialog
159 if(!ide.projectView && ideSettings.ideFileDialogLocation)
160 currentDirectory = ideSettings.ideFileDialogLocation;
161 return FileDialog::OnCreate();
165 EditFileDialog codeEditorFileDialog
167 type = multiOpen, text = $"Open",
168 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType);
169 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
172 EditFileDialog codeEditorFormFileDialog
174 type = open, text = $"Open Project",
175 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType),
176 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
179 define OpenBracket = '{';
180 define CloseBracket = '}';
185 actionDeleteMethod = 2,
186 actionDetachMethod = 3,
187 actionAttachMethod = 4,
188 actionReattachMethod = 5
191 //extern StatusField pos, ovr, caps, num;
192 //extern Class thisClass;
201 Expression ctxInsideExp;
202 Expression paramsInsideExp;
203 ClassFunction insideFunction;
206 const char * instanceName;
211 /****************************************************************************
213 ****************************************************************************/
215 static void OutputString(File f, const char * string)
218 for(c = 0; string[c]; c++)
220 if(string[c] == '\"')
222 else if(string[c] == '\\')
224 else if(string[c] == '\n')
235 // Consider merging with PrintType ?
236 void OutputType(File f, Type type, bool outputName)
240 if(type.kind != pointerType && type.constant)
248 if(!type.isSigned) f.Printf("unsigned ");
252 if(!type.isSigned) f.Printf("unsigned ");
256 if(!type.isSigned) f.Printf("unsigned ");
260 if(!type.isSigned) f.Printf("unsigned ");
264 if(!type.isSigned) f.Printf("unsigned ");
275 if(type._class && !strcmp(type._class.string, "class"))
277 switch(type.classObjectType)
280 f.Printf("any_object");
283 f.Printf("typed_object");
290 // ADD CODE TO DECIDE WHETHER TO OUTPUT FULLY QUAlIFIED OR NOT:
291 f.Printf(type._class.shortName ? type._class.shortName : type._class.string);
301 OutputType(f, type.type, false);
304 OutputType(f, type.type, false);
325 if(type.kind == arrayType)
328 f.Printf("%d", type.arraySize);
334 void DeleteJunkBefore(EditBoxStream f, int pos, int * position)
340 f.Seek(pos - *position, current);
342 // Try to delete spaces and \n before...
348 /*else if(ch == '\n')
350 // Look for // comments on the line before
351 EditBox editBox = f.editBox;
352 EditLine line = editBox.line;
359 for(c = 0; text[c]; c++)
368 if(text[c] == '/' && last == '/')
380 f.DeleteBytes(before);
385 void GetLocText(EditBox editBox, File f, int position, Location loc, char ** text, int * size, int pad, int linePad)
390 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
392 // Cut & Paste function
398 f.Seek(loc.start.pos - position, current);
400 x1 = editBox.charPos;
401 y1 = editBox.lineNumber;
402 f.Seek(loc.end.pos - loc.start.pos, current);
404 x2 = editBox.charPos;
405 y2 = editBox.lineNumber;
406 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
408 *size = editBox.SelSize();
409 *text = new char[*size+1 + (y2-y1+1) * linePad + pad]; // Add pad for tabs and new name
410 editBox.GetSel(*text, false);
413 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
414 f.Printf(""); // Make the stream point to where the editbox is
417 static int64 GetI64EnumValue(Class dataType, DataValue dataForm)
420 switch(dataType.typeSize)
423 if(!strcmp(dataType.dataTypeString, "byte"))
424 i64Value = dataForm.uc;
426 i64Value = dataForm.c;
429 if(!strcmp(dataType.dataTypeString, "uint16"))
430 i64Value = dataForm.us;
432 i64Value = dataForm.s;
435 if(!strcmp(dataType.dataTypeString, "uint"))
436 i64Value = dataForm.ui;
438 i64Value = dataForm.i;
441 if(!strcmp(dataType.dataTypeString, "uint64"))
442 i64Value = *(int64 *)&dataForm.ui64;
444 i64Value = dataForm.i64;
450 void Code_FixProperty(Property prop, Instance object)
452 Designer::FixProperty(prop, object);
455 bool Code_IsPropertyModified(Instance test, ObjectInfo selected, Property prop)
458 if(prop.dataTypeString && (!prop.IsSet || prop.IsSet(selected.instance)))
460 Class dataType = prop.dataTypeClass;
463 dataType = prop.dataTypeClass = eSystem_FindClass(test._class.module, prop.dataTypeString);
465 if(dataType && dataType._vTbl && dataType.type == structClass)
467 void * dataForm = new0 byte[dataType.structSize];
468 void * dataTest = new0 byte[dataType.structSize];
470 ((void (*)(void *, void *))(void *)prop.Get)(selected.instance, dataForm);
471 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
473 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
475 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
481 else if(dataType && dataType._vTbl && (dataType.type == normalClass || dataType.type == noHeadClass))
483 void * dataForm, * dataTest;
484 bool isEditBoxContents = false;
485 bool freeDataForm = false, freeDataTest = false;
487 // Because contents property is broken for mutiline EditBox at the moment
488 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
489 isEditBoxContents = true;
491 if(isEditBoxContents && ((EditBox)selected.instance).multiLine)
493 dataForm = ((EditBox)selected.instance).multiLineContents;
497 dataForm = ((void *(*)(void *))(void *)prop.Get)(selected.instance);
498 if(isEditBoxContents && ((EditBox)test).multiLine)
500 dataTest = ((EditBox)test).multiLineContents;
504 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
506 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
508 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
512 // Temporary work around until we standardize how properties should manage memory
513 if(!strcmp(prop.name, "strings") && !strcmp(prop._class.name, "DirectoriesBox"))
514 freeDataForm = freeDataTest = true;
515 if(dataType.type == normalClass && dataType.structSize)
517 if(freeDataForm) eInstance_Delete(dataForm);
518 if(freeDataTest) eInstance_Delete(dataTest);
522 if(freeDataForm) delete dataForm;
523 if(freeDataTest) delete dataTest;
526 else if(dataType && dataType._vTbl)
528 DataValue dataForm, dataTest;
530 GetProperty(prop, selected.instance, &dataForm);
531 GetProperty(prop, test, &dataTest);
533 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
535 SetProperty(prop, test, dataForm);
537 // In case setting on test unset on real instance (e.g. isDefault)
538 if(strcmp(prop.name, "name"))
540 GetProperty(prop, selected.instance, &dataTest);
541 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
542 SetProperty(prop, selected.instance, dataForm);
551 bool Code_IsPropertyDisabled(ObjectInfo selected, const char * name)
553 bool disabled = false;
554 if(selected.oClass == selected)
557 if(selected.classDefinition)
559 for(def = selected.classDefinition.definitions->first; def; def = def.next)
561 if(def.type == defaultPropertiesClassDef)
564 for(prop = def.defProperties->first; prop; prop = prop.next)
566 if(prop.identifiers && prop.identifiers->first)
568 Identifier id = prop.identifiers->first;
569 if(prop.variable && !strcmp(id.string, name))
581 else if(selected.instCode)
584 if(selected.instCode.members)
586 for(members = selected.instCode.members->first; members; members = members.next)
588 if(members.type == dataMembersInit && members.dataMembers)
591 for(prop = members.dataMembers->first; prop; prop = prop.next)
593 if(prop.identifiers && prop.identifiers->first)
595 Identifier id = prop.identifiers->first;
596 if(prop.variable && !strcmp(id.string, name))
611 static bool CheckCompatibleMethod(Method method, Type type, Class regClass, bool isForm, Symbol selectedClass)
616 method.dataType = ProcessTypeString(method.dataTypeString, false);
617 if(!method.dataType.thisClass && !isForm)
620 method.dataType.thisClass = selectedClass;
622 //result = MatchTypes(method.dataType, type, null, regClass, regClass, false);
623 result = MatchTypes(type, method.dataType, null, regClass, regClass, false, true, true, false, true);
625 method.dataType.thisClass = null;
629 bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo object)
631 bool confirmation = true;
632 Statement body = function.body;
633 // Check if it contains any code
634 if((!body.compound.declarations || !body.compound.declarations->count) && (!body.compound.statements || body.compound.statements->count <= 1))
636 // Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
637 Statement stmt = body.compound.statements ? body.compound.statements->first : null;
638 Type dataType = method.dataType;
639 Type returnType = dataType.returnType;
640 Expression exp = null;
643 method.dataType = ProcessTypeString(method.dataTypeString, false);
645 confirmation = false;
647 // Check if default function should be calling base class:
648 if(object.instance._class._vTbl[method.vid] == null /*moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]*/) // Temp Check for DefaultFunction
650 if(returnType.kind != voidType)
652 if(!stmt || stmt.type != returnStmt || !stmt.expressions || stmt.expressions->count != 1)
656 exp = stmt.expressions->first;
657 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
659 if( (exp.type != identifierExp || strcmp(exp.identifier.string, "true")) &&
660 (exp.type != constantExp || strcmp(exp.constant, "1")))
665 if(exp.type != constantExp || strcmp(exp.constant, "0"))
680 if(returnType.kind != voidType)
682 if(stmt.type == returnStmt && stmt.expressions && stmt.expressions->count == 1)
683 exp = stmt.expressions->first;
685 else if(stmt.type == expressionStmt && stmt.expressions && stmt.expressions->count == 1)
686 exp = stmt.expressions->first;
689 if(!exp || exp.type != callExp || exp.call.exp.type != identifierExp)
693 Identifier id = exp.call.exp.identifier;
694 Class base = object.instance._class;
695 if(!id._class || (id._class.name && !strcmp(id._class.name, base.name)) || strcmp(id.string, method.name))
699 Expression arg = exp.call.arguments ? exp.call.arguments->first : null;
700 if(!arg || arg.type != identifierExp || strcmp("this", arg.identifier.string))
706 for(param = dataType.params.first; param; param = param.next)
708 if(!arg || arg.type != identifierExp || strcmp(param.name, arg.identifier.string))
713 arg = arg ?arg.next : null;
720 return !confirmation;
723 class CodeEditor : Window
725 background = marginColor;
726 borderStyle = sizableDeep;
731 isActiveClient = true;
732 anchor = Anchor { left = 300, right = 150, top = 0, bottom = 0 };
735 // eWindow_SetX(A_CASCADE); eWindow_SetY(A_CASCADE);
736 // eWindow_SetWidth(A_RELATIVE|80); eWindow_SetHeight(A_RELATIVE|80);
738 SheetType sheetSelected;
743 Context globalContext { };
744 OldList excludedSymbols { offset = (uint)(uintptr)&((Symbol)0).left };
757 MethodAction methodAction;
759 ClassFunction function;
761 char methodName[1024];
766 bool membersListShown;
769 EditLine membersLine;
771 Type functionType, instanceType;
775 Point paramsPosition;
776 Expression functionExp;
779 BitmapResource icons[CodeObjectType];
781 FontResource boldFont { $"Tahoma", 8.25f, bold = true, window = this };
782 FontResource normalFont { $"Tahoma", 8.25f, window = this };
784 Module privateModule;
785 NameSpace globalData;
788 OpenedFileInfo openedFileInfo;
790 FontResource font { codeFont.faceName, codeFont.size, codeFont.bold };
791 saveDialog = codeEditorFileDialog;
793 Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
796 int maxLineNumberLength;
798 property bool parsing { get { return editBox.syntaxHighlighting && !noParsing && !ide.noParsing; } };
800 void ProcessCaretMove(EditBox editBox, int line, int charPos)
803 ObjectInfo classItem;
805 // OnActivateClient is called after OnActivate
808 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
811 if(sheet.codeEditor != this) return;
815 for(classItem = classes.first; classItem; classItem = classItem.next)
817 ClassDefinition classDef = classItem.classDefinition;
818 if(classDef && classDef.loc.Inside(line, charPos))
825 for(object = classItem.instances.first; object; object = object.next)
829 if(object.instCode.loc.Inside(line, charPos))
834 sheet.SelectObject(object);
836 sheet.SelectObject(classItem);
841 //sheet.SelectObject(null);
845 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
849 expectingMove = false;
855 if(line-1 != membersLoc.start.line)
861 if(charPos - 1 < membersLoc.start.charPos)
863 else if(charPos - 1 > membersLoc.end.charPos)
865 const char * buffer = membersLine.text;
866 //if(membersList.currentRow)
870 for(c = membersLoc.start.charPos; c<=charPos && buffer[c]; c++)
871 if(buffer[c] != ' ' && buffer[c] != '\t')
873 if(c < charPos && buffer[c])
880 membersList.Destroy(0);
881 membersListShown = false;
885 bool back = codeModified;
886 codeModified = false;
888 InvokeParameters(false, false, false);
889 /*if(membersListShown)
890 InvokeAutoComplete(false, 0, true);*/
897 watch(modifiedDocument)
899 ProjectView projectView = ide.projectView;
902 char buffer[MAX_LOCATION];
903 char * fullPath = GetSlashPathBuffer(buffer, fileName);
904 Array<ProjectNode> nodes = ide.workspace.GetAllProjectNodes(fullPath, false);
908 node.modified = modifiedDocument;
909 projectView.Update(null);
918 textVertScroll = true, multiLine = true, /*lineNumbers = ideSettings.showLineNumbers,*/
919 freeCaret = ideSettings.useFreeCaret, caretFollowsScrolling = ideSettings.caretFollowsScrolling,
920 tabKey = true, smartHome = true;
921 tabSelection = true, /*maxLineSize = 65536, */parent = this, hasHorzScroll = true, hasVertScroll = true;
922 selectionColor = selectionColor, selectionText = selectionText,
923 background = codeEditorBG, foreground = codeEditorFG, syntaxColorScheme = colorScheme,
924 font = font, borderStyle = none;
925 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
927 bool OnMouseOver(int x, int y, Modifiers mods)
929 CodeEditor editor = (CodeEditor)master;
930 if(editor.designer && editor.designer.isDragging && !mods.isSideEffect)
935 void NotifyCaretMove(EditBox editBox, int line, int charPos)
937 // Update Line Numbers
938 static int oy1 = 0, oy2 = 0;
941 display.FontExtent(font.font, " ", 1, null, &spaceH);
942 editBox.GetSelPos(null, &y1, null, null, &y2, null, false);
951 Box box { 0, (oy1-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, oy2*spaceH-1 - editBox.scroll.y };
955 Box box { 0, (y1-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, y2*spaceH-1 - editBox.scroll.y };
962 if(ide.activeClient == this)
963 ProcessCaretMove(editBox, line, charPos);
965 openedFileInfo.CaretMove(line, charPos);
968 void NotifyOvrToggle(EditBox editBox, bool overwrite)
970 ide.UpdateStateLight(ide.ovr, overwrite);
973 void NotifyUpdate(EditBox editBox)
980 designer.modifiedDocument = true;
983 modifiedDocument = true;
986 bool NotifyUnsetModified(EditBox editBox)
988 modifiedDocument = false;
992 bool NotifyCharsAdded(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
994 if(!loadingFile && after.y != before.y)
996 ProjectView projectView = ide.projectView;
997 if(projectView && fileName)
1000 // HOW WE MIGHT WANT TO DO IT:
1001 const char * text = before.line.text;
1002 for(c = Min(before.line.count, before.x-1); c>= 0; c--)
1003 if(!isspace(text[c]))
1005 ide.debugger.MoveIcons(fileName, before.y + (((!pasteOperation && c > -1) || !after.line.count) ? 1 : 0), after.y - before.y, false);
1007 // HOW VISUAL STUDIO DOES IT:
1009 char * text = after.line.text;
1010 for(c = after.line.count-1; c>= 0; c--)
1011 if(!isspace(text[c]))
1013 ide.debugger.MoveIcons(fileName, before.y + ((c < 0) ? 1 : 0), after.y - before.y, false);
1016 Update({ 0, 0, editBox.position.x, clientSize.h });
1024 for(oClass = classes.first; oClass; oClass = oClass.next)
1027 for(object = oClass.instances.first; object; object = object.next)
1031 object.instCode.loc.start.AdjustAdd(before, after);
1032 object.instCode.loc.end.AdjustAdd(before, after);
1037 oClass.classDefinition.loc.start.AdjustAdd(before, after);
1038 oClass.classDefinition.loc.end.AdjustAdd(before, after);
1044 expectingMove = true;
1045 if(membersListShown)
1048 if(before.y != after.y)
1052 const char * buffer = membersLine.text;
1054 bool firstChar = true;
1055 bool addedChar = false;
1061 membersLoc.end.charPos += after.x - Max(membersLoc.start.charPos, before.x);
1063 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
1065 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1066 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar)) //|| membersList.currentRow
1075 membersLoc.start.charPos++;
1080 string[len++] = buffer[c];
1084 row = membersList.currentRow;
1085 if(row && row.selected)
1089 membersLoc.start.charPos--;
1097 row = membersList.FindSubString(string);
1099 membersList.currentRow = row;
1102 row = membersList.FindSubStringi(string);
1104 membersList.currentRow = row;
1105 membersList.currentRow.selected = false;
1108 membersList.SetScrollPosition(0, (row.index) * membersList.rowHeight);
1112 row = membersList.currentRow;
1115 // Accept current string if hiding typing char
1116 if(hide && row && row.selected)
1118 const char * string = row.string;
1119 int len = strlen(string);
1120 membersLoc.end.charPos -= after.x - before.x;
1121 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1122 editBox.Delete(membersLine, membersLoc.start.line, membersLoc.start.charPos,
1123 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1124 editBox.PutS(string);
1125 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos + len + 1 /*after.x - before.x*/);
1127 after.x += membersLoc.start.charPos + len - before.x;
1128 before.x = membersLoc.start.charPos + len;
1133 membersList.Destroy(0);
1134 membersListShown = false;
1137 if(/*after.x - before.x == 1 && */after.y == before.y && !membersListShown)
1139 EditLine line = editBox.line;
1140 const char * text = line.text;
1141 char ch = text[after.x-1];
1142 if(ch == '.' || (ch == '>' && after.x-1 > 0 && text[after.x-1-1] == '-') || (ch == ':' && after.x-1 > 0 && text[after.x-1-1] == ':'))
1146 // Can we call invoke auto complete here instead?
1156 // Force caret update already...
1157 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1158 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1160 editBox.GetCaretPosition(&caret);
1164 // Go back in the buffer until no space before
1166 codeModified = true;
1170 EditBoxStream f { editBox = editBox };
1174 if(text[after.x-1] == '>')
1180 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1184 if(!f.Seek(-1, current))
1187 if(!isspace(ch)) break;
1188 f.Seek(-1, current);
1190 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1192 line = editBox.lineNumber + 1;
1193 charPos = editBox.charPos + 1;
1197 exp = FindExpTree(ast, line, charPos);
1201 Type type = exp.expType;
1203 if(type && text[after.x-1] != '.')
1205 if(type.kind == TypePointer || type.kind == TypeArray)
1211 membersList.Clear();
1214 if(membersList.rowCount)
1216 membersList.Sort(null, 1);
1217 membersList.master = this;
1219 caret.y += editBox.GetCaretSize();
1222 membersList.Create();
1225 int x = caret.x + editBox.GetAbsX() - app.desktop.GetAbsX() - editBox.GetScrollX();
1226 int y = caret.y + editBox.GetAbsY() - app.desktop.GetAbsY() - editBox.GetScrollY();
1227 Window parent = membersList.parent;
1229 if(!paramsAbove && (paramsShown || y + membersList.GetHeight() > parent.GetClientHeight()))
1231 y -= editBox.GetCaretSize() + membersList.GetHeight();
1232 membersAbove = true;
1235 membersAbove = false;
1237 membersList.position = { x, y };
1241 membersLoc.start.line = line - 1;
1242 membersLoc.start.charPos = oldCharPos;
1243 membersLoc.end = membersLoc.start;
1244 membersListShown = true;
1249 SetCurrentContext(globalContext);
1251 codeModified = true;
1252 skipModified = true;
1253 if(text[after.x-1] == ':')
1254 InvokeAutoComplete(false, 0, false);
1255 else if(text[after.x-1] == '.')
1256 InvokeAutoComplete(false, 1, false);
1257 else if(text[after.x-1] == '>')
1258 InvokeAutoComplete(false, 2, false);
1259 skipModified = false;
1261 else if(ch == '(' || ch == OpenBracket || ch == ',' || ch == '=' || ch == '?' || ch == ':')
1263 codeModified = true;
1264 skipModified = true;
1266 if(InvokeAutoComplete(true, 0, false))
1268 if(ch == '(' || ch == OpenBracket)
1269 InvokeParameters(true, true, false);
1271 InvokeParameters(this.functionType ? false : true, false, false);
1274 // InvokeAutoComplete(true, 0, false);
1275 skipModified = false;
1277 else if(ch == ')' || ch == '}' || ch == ';')
1279 codeModified = true;
1280 skipModified = true;
1282 InvokeParameters(false, true, false);
1283 skipModified = false;
1287 bool back = codeModified;
1288 codeModified = false;
1290 InvokeParameters(false, false, true);
1291 if(membersListShown)
1292 InvokeAutoComplete(false, 0, true);
1293 codeModified = back;
1298 bool back = codeModified;
1299 codeModified = false;
1302 InvokeParameters(false, false, true);
1303 /*if(membersListShown)
1304 InvokeAutoComplete(false, 0, true);*/
1306 codeModified = back;
1313 bool NotifyCharsDeleted(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
1315 if(!loadingFile && after.y != before.y)
1317 ProjectView projectView = ide.projectView;
1318 if(projectView && fileName)
1319 ide.debugger.MoveIcons(fileName, before.y + 1, before.y - after.y, before.x == 0);
1320 Update({ 0, 0, editBox.position.x, clientSize.h });
1328 for(oClass = classes.first; oClass; oClass = oClass.next)
1332 for(object = oClass.instances.first; object; object = object.next)
1336 loc = &object.instCode.loc;
1338 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1339 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1341 object.instCode = null;
1345 loc->start.AdjustDelete(before, after);
1346 loc->end.AdjustDelete(before, after);
1350 if(oClass.classDefinition)
1352 loc = &oClass.classDefinition.loc;
1353 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1354 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1356 oClass.classDefinition = null;
1360 loc->start.AdjustDelete(before, after);
1361 loc->end.AdjustDelete(before, after);
1366 if(membersListShown)
1369 if(pasteOperation || before.y != after.y)
1373 const char * buffer = membersLine.text;
1375 bool firstChar = true;
1379 if(before.x >= membersLoc.start.charPos)
1381 for(c = membersLoc.start.charPos; c<before.x && len < sizeof(string)-1; c++)
1383 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1384 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1389 if(!isSpace) firstChar = false;
1392 string[len++] = buffer[c];
1397 // If deleting spaces before...
1398 for(c = before.x; c<membersLoc.start.charPos; c++)
1400 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1408 membersLoc.start.charPos = before.x;
1411 if(membersLoc.end.charPos >= after.x)
1413 for(c = after.x; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
1415 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1416 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1421 if(!isSpace) firstChar = false;
1424 string[len++] = buffer[c];
1432 membersLoc.end.charPos -= after.x - before.x;
1436 row = membersList.FindSubString(string);
1439 row = membersList.FindSubStringi(string);
1441 membersList.currentRow = row;
1442 membersList.currentRow.selected = false;
1445 membersList.currentRow = row;
1447 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
1452 membersList.Destroy(0);
1453 membersListShown = false;
1459 InvokeParameters(false, false);
1467 bool NotifyDropped(EditBox editBox, int x, int y)
1469 char * controlClass = toolBox.controlClass;
1470 if(controlClass && controlClass[0])
1474 ObjectInfo classObject;
1476 editBox.GoToLineNum(y);
1477 x = Min(x, editBox.line.count);
1478 editBox.GoToPosition(editBox.line, y, x);
1479 // Note: Uncommented this to drag objects after the member instance on which they are dropped
1480 editBox.NotifyCaretMove(this, editBox, y+1, x+1);
1482 classObject = selected ? selected.oClass : null;
1484 if((!selected || selected == classObject) && classObject && classObject.instances.first)
1485 selected = classObject.instances.last;
1488 control = eInstance_New(eSystem_FindClass(privateModule, controlClass));
1491 AddObject(control, &object);
1493 designer.CreateObject(control, object, false, classObject.instance);
1494 // designer.PostCreateObject(control, object, false, classObject.instance);
1495 designer.DroppedObject(control, object, false, classObject.instance);
1497 sheet.AddObject(object, object.name, typeData /* className*/, true);
1500 //codeModified = true;
1507 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
1509 if(key == ctrlSpace)
1511 membersList.Destroy(0);
1512 membersListShown = false;
1513 InvokeAutoComplete(false, 0, false);
1516 else if(key == Key { space, ctrl = true, shift = true })
1517 InvokeParameters(false, true, false);
1518 else if(key == escape)
1519 ide.RepositionWindows(true);
1520 else if(key == ctrlF7)
1524 ProjectNode node = ide.projectView.GetNodeForCompilationFromWindow(this, false, null, null);
1528 s = PrintString($"The ", fileName, $" file is not part of any project.\n",
1529 $"It can't be compiled.");
1530 MessageBox { type = ok, /*parent = ide, */master = ide, text = $"File not in project error", contents = s }.Modal();
1539 bool OnKeyDown(Key key, unichar ch)
1541 CodeEditor editor = (CodeEditor)master;
1542 if(key == escape /*|| key == leftAlt || key == rightAlt || (key.ctrl && key.code != left && key.code != right && key.code != leftShift && key.code != rightShift && key.code != space)*/)
1544 if(editor.membersListShown)
1546 editor.membersList.Destroy(0);
1547 editor.membersListShown = false;
1550 if(editor.paramsShown)
1552 editor.paramsList.Destroy(0);
1553 editor.paramsShown = false;
1554 FreeType(editor.functionType);
1555 FreeType(editor.instanceType);
1557 editor.functionType = null;
1558 editor.instanceType = null;
1559 editor.paramsID = -1;
1563 return EditBox::OnKeyDown(key, ch);
1566 void OnVScroll(ScrollBarAction action, int position, Key key)
1568 if(anchor.left.distance)
1570 Box box { 0, 0, anchor.left.distance-1, parent.clientSize.h - 1 };
1573 EditBox::OnVScroll(action, position, key);
1575 CodeEditor ce = (CodeEditor)parent;
1576 if(ce.openedFileInfo)
1577 ce.openedFileInfo.ScrollChange({ scroll.x, position });
1581 void OnHScroll(ScrollBarAction action, int position, Key key)
1583 EditBox::OnHScroll(action, position, key);
1585 CodeEditor ce = (CodeEditor)parent;
1586 if(ce.openedFileInfo)
1587 ce.openedFileInfo.ScrollChange({ position, scroll.y });
1594 fullRowSelect = false,
1597 borderStyle = bevel;
1598 // size = { 200, 400 };
1600 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
1602 DataRow row = listBox.currentRow;
1605 const char * string = row.string;
1607 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1609 membersLine, membersLoc.start.line, membersLoc.start.charPos,
1610 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1611 editBox.PutS(string);
1614 membersListShown = false;
1619 bool OnKeyDown(Key key, unichar ch)
1621 CodeEditor editor = (CodeEditor) master;
1622 if(key == escape || key == leftAlt || key == rightAlt ||
1623 (key.ctrl && key.code != left && key.code != right &&
1624 key.code != leftShift && key.code != rightShift && key.code != space))
1627 if(editor.paramsShown)
1631 editor.paramsList.Destroy(0);
1632 editor.paramsShown = false;
1634 if(editor.membersListShown)
1638 editor.membersList.Destroy(0);
1639 editor.membersListShown = false;
1642 FreeType(editor.functionType);
1643 editor.functionType = null;
1645 FreeType(editor.instanceType);
1646 editor.instanceType = null;
1648 editor.paramsID = -1;
1653 return editor.editBox.OnKeyDown(key, ch);
1657 /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1659 CodeEditor editor = (CodeEditor)master;
1660 Window rw = previous ? previous.rootWindow : null;
1661 if(!active && rw != editor.paramsList)
1664 editor.membersListShown = false;
1666 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1669 bool OnKeyHit(Key key, unichar ch)
1671 CodeEditor editor = (CodeEditor) master;
1675 case enter: case tab:
1677 DataRow row = currentRow;
1678 if(row && row.selected)
1680 const char * string = row.string;
1682 editor.editBox.GoToPosition(editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos);
1683 editor.editBox.Delete(
1684 editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos,
1685 editor.membersLine, editor.membersLoc.end.line, editor.membersLoc.end.charPos);
1686 editor.editBox.PutS(string);
1689 editor.membersListShown = false;
1692 editor.editBox.OnKeyHit(key, ch);
1702 return ListBox::OnKeyHit(key, ch);
1708 // If before . or after
1709 //listBox.Destroy(true);
1710 result = editor.editBox.OnKeyHit(key, ch);
1725 clickThrough = true,
1727 borderStyle = contour,
1729 background = { 255,255,225 },
1731 OnKeyDown = membersList.OnKeyDown;
1733 /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1735 CodeEditor editor = (CodeEditor)master;
1736 Window rw = previous ? previous.rootWindow : null;
1737 if(!active && previous != editor.editBox && rw != editor.membersList)
1740 editor.paramsShown = false;
1742 return Window::OnActivate(active, previous, goOnWithActivation, direct);
1745 bool OnKeyHit(Key key, unichar ch)
1747 CodeEditor editor = (CodeEditor)master;
1749 if(!editor.membersListShown || editor.membersList.OnKeyHit(key, ch))
1752 bool result = true; editor.editBox.OnKeyHit(key, ch);
1753 return (!created) ? false : result;
1760 void OnRedraw(Surface surface)
1762 CodeEditor editor = (CodeEditor) master;
1763 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1765 Type methodType = null;
1769 int functionW, nameW = 0;
1771 int spaceW, spaceH, commaW, commaWB, parW;
1773 int maxW = 0, lineW = 0;
1779 Font font = editor.normalFont.font;
1780 Font boldFont = editor.boldFont.font;
1781 Display display = this.display;
1783 if(!type) { return; };
1785 if(type.kind == TypeKind::methodType) { methodType = type; type = type.method.dataType; }
1787 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1788 display.FontExtent(font, ", ", 2, &commaW, null);
1789 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1790 display.FontExtent(font, ")", 1, &parW, null);
1793 if(editor.functionType && type.kind == functionType)
1795 PrintType(type.returnType, string, true, true);
1796 display.FontExtent(font, string, strlen(string), &functionW, null);
1798 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1799 totalW = nameW + functionW + 2 * parW;
1803 PrintType(type, string, (type.kind == functionType) ? true : false, true); // true);
1804 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1805 if(instanceName && type.kind != functionType)
1806 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1807 totalW = functionW + nameW;
1808 surface.TextFont(boldFont);
1811 surface.WriteText(x, y, string, strlen(string));
1812 x += functionW + spaceW;
1814 if(editor.functionType)
1817 surface.WriteText(x, y, type.name, strlen(type.name));
1819 surface.WriteText(x, y, "(", 1);
1822 if(methodType && !methodType.staticMethod && methodType.methodClass)
1826 if(id == editor.paramsID)
1827 surface.TextFont(boldFont);
1829 if(methodType.methodClass)
1830 surface.TextExtent(methodType.methodClass.name, strlen(methodType.methodClass.name), &tw, null);
1834 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1835 width += ((id == editor.paramsID) ? commaWB : commaW);
1840 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1845 x = 2 + nameW + spaceW + functionW + parW;
1849 if(methodType.methodClass)
1850 surface.WriteText(x, y, methodType.methodClass.name, strlen(methodType.methodClass.name));
1853 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1855 surface.WriteText(x, y, ",", 1);
1856 x += ((id == editor.paramsID) ? commaWB : commaW);
1864 if(id == editor.paramsID)
1865 surface.TextFont(font);
1869 if(!methodType || (methodType.staticMethod || !methodType.methodClass) || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1871 for(param = type.params.first; param; param = param.next)
1873 char paramString[1024];
1876 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1877 surface.TextFont(boldFont);
1880 PrintType(param, paramString, true, true);
1881 surface.TextExtent(paramString, strlen(paramString), &tw, null);
1883 if(param.next) width += ((id == editor.paramsID) ? commaWB : commaW);
1888 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1893 x = 2 + nameW + spaceW + functionW + parW;
1897 surface.WriteText(x, y, paramString, strlen(paramString));
1901 surface.WriteText(x, y, ",", 1);
1902 x += ((id == editor.paramsID) ? commaWB : commaW);
1910 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1911 surface.TextFont(font);
1916 surface.WriteText(x, y, ")", 1);
1918 else if(instanceName && type.kind != functionType)
1920 surface.WriteText(x, y, instanceName, strlen(instanceName));
1924 bool OnResizing(int * w, int * h)
1926 CodeEditor editor = (CodeEditor) master;
1927 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1929 Type methodType = null;
1933 int functionW = 0, nameW = 0;
1935 int spaceW, spaceH, commaW, commaWB, parW;
1937 int maxW = 0, lineW = 0;
1942 Font font = editor.normalFont.font;
1943 Font boldFont = editor.boldFont.font;
1944 Display display = this.display;
1946 if(type.kind == TypeKind::methodType)
1949 ProcessMethodType(type.method);
1950 type = type.method.dataType;
1953 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1954 display.FontExtent(font, ", ", 2, &commaW, null);
1955 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1956 display.FontExtent(font, ")", 1, &parW, null);
1959 if(editor.functionType && type && type.kind == functionType)
1961 PrintType(type.returnType, string, true, true);
1962 display.FontExtent(font, string, strlen(string), &functionW, null);
1964 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1965 totalW = nameW + spaceW + functionW + 2 * parW;
1969 PrintType(type, string, false, true); // /*true);
1970 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1971 if(instanceName && type.kind != functionType)
1972 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1973 totalW = functionW + nameW + spaceW;
1976 if(editor.functionType)
1982 if(methodType.methodClass)
1983 display.FontExtent((id == editor.paramsID) ? boldFont : font, methodType.methodClass.name, strlen(methodType.methodClass.name), &width, null);
1984 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1985 width += ((id == editor.paramsID) ? commaWB : commaW);
1990 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
2003 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
2005 for(param = type.params.first; param; param = param.next)
2007 char paramString[1024];
2011 PrintType(param, paramString, true, true);
2012 display.FontExtent((id == editor.paramsID || param.kind == ellipsisType) ? boldFont : font, paramString, strlen(paramString), &width, null);
2014 width += ((id == editor.paramsID) ? commaWB : commaW);
2019 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
2036 *w = realW + totalW + 4;
2042 Menu fileMenu { menu, $"File", f };
2043 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
2044 MenuItem { fileMenu, $"Save As...", a, NotifySelect = MenuFileSaveAs };
2046 Menu editMenu { menu, $"Edit", e };
2047 MenuDivider { editMenu };
2048 MenuItem clearTrailingSpacesItem
2050 editMenu, $"Clear trailing spaces", t, Key { t, ctrl = true, shift = true };
2052 bool NotifySelect(MenuItem selection, Modifiers mods)
2054 // Nuke trailing spaces
2057 editBox.recordUndoEvent = true;
2058 for(line = editBox.firstLine; line; line = line.next, y++)
2060 const String buffer = line.text;
2061 int count = line.count, i = count-1;
2062 while(i >= 0 && isspace(buffer[i])) i--;
2064 editBox.Delete(line, y, i + 1, line, y, count);
2066 editBox.recordUndoEvent = false;
2071 Menu debugMenu { menu, $"Debug", d };
2072 MenuItem debugRunToCursor { debugMenu, $"Run To Cursor", c, ctrlF10, id = RTCMenuBits { false, false, false }, NotifySelect = RTCMenu_NotifySelect; };
2073 MenuItem debugSkipRunToCursor { debugMenu, $"Run To Cursor Skipping Breakpoints", u, Key { f10, ctrl = true, shift = true }, id = RTCMenuBits { true, false, false }, NotifySelect = RTCMenu_NotifySelect; };
2074 MenuItem debugRunToCursorAtSameLevel { debugMenu, $"Run To Cursor At Same Level", l, altF10, id = RTCMenuBits { false, true, false }, NotifySelect = RTCMenu_NotifySelect; };
2075 MenuItem debugSkipRunToCursorAtSameLevel { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", g, Key { f10, shift = true, alt = true }, id = RTCMenuBits { true, true, false }, NotifySelect = RTCMenu_NotifySelect; };
2077 MenuItem debugBpRunToCursor { debugMenu, $"BP Run To Cursor"/*, c, ctrlF10*/, id = RTCMenuBits { false, false, true }, NotifySelect = RTCMenu_NotifySelect; };
2078 MenuItem debugBpSkipRunToCursor { debugMenu, $"BP Run To Cursor Skipping Breakpoints"/*, u, Key { f10, ctrl = true, shift = true }*/, id = RTCMenuBits { true, false, true }, NotifySelect = RTCMenu_NotifySelect; };
2079 MenuItem debugBpRunToCursorAtSameLevel { debugMenu, $"BP Run To Cursor At Same Level"/*, l, altF10*/, id = RTCMenuBits { false, true, true }, NotifySelect = RTCMenu_NotifySelect; };
2080 MenuItem debugBpSkipRunToCursorAtSameLevel { debugMenu, $"BP Run To Cursor At Same Level Skipping Breakpoints"/*, g, Key { f10, shift = true, alt = true }*/, id = RTCMenuBits { true, true, true }, NotifySelect = RTCMenu_NotifySelect; };
2082 bool RTCMenu_NotifySelect(MenuItem selection, Modifiers mods)
2084 ProjectView projectView = ide.projectView;
2085 if(!projectView.buildInProgress)
2087 RTCMenuBits bits = (RTCMenuBits)selection.id;
2088 int line = editBox.lineNumber + 1;
2091 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler);
2092 ProjectConfig config = projectView.project.config;
2093 int bitDepth = ide.workspace.bitDepth;
2094 bool useValgrind = ide.workspace.useValgrind;
2095 ide.debugger.RunToCursor(compiler, config, bitDepth, useValgrind, fileName, line, bits.ignoreBreakpoints, bits.atSameLevel, bits.oldImplementation);
2101 MenuDivider { debugMenu };
2102 MenuItem debugToggleBreakpoint
2104 debugMenu, $"Toggle Breakpoint", t, f9;
2105 bool NotifySelect(MenuItem selection, Modifiers mods)
2107 ProjectView projectView = ide.projectView;
2108 if(projectView && fileName)
2110 int line = editBox.lineNumber + 1;
2111 ide.debugger.ToggleBreakpoint(fileName, line);
2121 //MenuItem viewDesignerItem, viewProperties, viewMethods;
2125 designer.parent = parent;
2128 toolBox = ((IDEWorkSpace)master).toolBox;
2130 // Debugger bug here: value of toolBox appears as 0
2132 sheet = ((IDEWorkSpace)master).sheet;
2137 bool OnClose(bool parentClosing)
2141 if(ide.workspace && fileName)
2142 ide.workspace.UpdateOpenedFileInfo(fileName, closed);
2143 if(inUseDebug && !debugClosing)
2145 debugClosing = true;
2147 if(CloseConfirmation(false))
2150 if(modifiedDocument)
2151 OnFileModified({ modified = true }, null);
2153 debugClosing = false;
2156 if(designer && !designer.closing)
2158 if(designer.visible)
2165 //Window formEditor = designer;
2166 //formEditor.Destroy(0);
2169 ide.AdjustFileMenus();
2174 void OnDestroy(void)
2176 ObjectInfo oClass, next;
2177 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2179 FreeType(this.functionType);
2180 FreeType(this.instanceType);
2185 designer.codeEditor = null;
2186 designer.Destroy(0);
2190 for(oClass = (classes).first, next = oClass ? oClass.next : null; oClass; oClass = next, next = next ? (next.next) : null)
2192 ObjectInfo object, next;
2194 for(object = oClass.instances.first; object; object = next)
2199 Designer::DestroyObject(object.instance);
2200 delete object.instance;
2202 if(object.i18nStrings)
2204 Map<String, bool> i18nStrings = object.i18nStrings;
2207 sheet.DeleteObject(object);
2209 oClass.instances.Delete(object);
2213 Designer::DestroyObject(oClass.instance);
2214 delete oClass.instance;
2216 if(oClass.i18nStrings)
2218 Map<String, bool> i18nStrings = oClass.i18nStrings;
2221 sheet.DeleteObject(oClass);
2223 classes.Delete(oClass);
2226 if(windowClass && windowClass.data)
2227 UnapplySkin(windowClass);
2231 if(sheet.codeEditor == this)
2233 sheet.codeEditor = null;
2234 toolBox.codeEditor = null;
2240 ProjectView projectView = ide.projectView;
2243 ProjectNode node = projectView.GetNodeFromWindow(this, null, true, false, null);
2244 if(node && node.modified)
2246 node.modified = false;
2247 projectView.Update(null);
2253 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool directActivation)
2255 // WHY WAS THIS HERE? I think this was here because once you move a window in the ide it's hard to reposition it correctly
2257 if(directActivation)
2258 ide.RepositionWindows(false); // Moved this up before as resizing causes NotifyCaretMove to be called on all editors
2260 if(active && directActivation)
2264 openedFileInfo.Activate();
2268 Location * loc = null;
2269 UpdateFormCode(); // To ensure update when modifying properties...
2271 // Got to the right spot in code so we don't lose our form selection...
2274 if(selected.instCode)
2275 loc = &selected.instCode.loc;
2276 else if(selected.classDefinition)
2277 loc = &selected.classDefinition.loc;
2279 line = editBox.lineNumber + 1;
2280 charPos = editBox.charPos + 1;
2285 if(selected && !loc->Inside(line, charPos))
2287 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2288 line = editBox.lineNumber + 1;
2289 charPos = editBox.charPos + 1;
2291 else if(selected && selected.classDefinition)
2294 for(object = selected.instances.first; object; object = object.next)
2298 if(object.instCode.loc.Inside(line, charPos))
2304 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2305 line = editBox.lineNumber + 1;
2306 charPos = editBox.charPos + 1;
2311 ProcessCaretMove(editBox, line, charPos);
2316 if(membersListShown)
2318 membersList.Destroy(0);
2319 membersListShown = false;
2323 paramsList.Destroy(0);
2324 paramsShown = false;
2325 FreeType(functionType);
2326 FreeType(instanceType);
2328 functionType = null;
2329 instanceType = null;
2336 bool OnSaveFile(const char * fileName)
2343 f = FileOpen(fileName, write);
2346 if(!ide.projectView)
2347 ide.ChangeFileDialogsDirectory(codeEditorFileDialog.currentDirectory, true);
2351 this.fileName = fileName; // Put this here because the form designer will check for it...
2352 designer.fileName = fileName;
2353 designer.modifiedDocument = false;
2356 editBox.Save(f, false);
2357 modifiedDocument = false;
2365 bool OnFileModified(FileChange fileChange, const char * param)
2367 bool reload = false;
2368 if(visible == false && inUseDebug == true)
2369 ide.debugger.WatchesReleaseCodeEditor();
2374 sprintf(message, $"The document %s was modified by another application.\n"
2375 "Would you like to reload it and lose your changes?", fileName);
2376 if(MessageBox { type = yesNo, master = /*parent = */parent, text = $"Document has been modified",
2377 contents = message }.Modal() == yes)
2383 File f = FileOpen(fileName, read);
2386 int lineNumber, charPos, len;
2390 updatingCode = true;
2391 lineNumber = editBox.lineNumber;
2392 charPos = editBox.charPos;
2393 scroll = editBox.scroll;
2396 lineNumber = lineNumber < editBox.numLines ? lineNumber : editBox.numLines - 1;
2397 len = strlen(editBox.line.text);
2398 editBox.GoToLineNum(lineNumber);
2399 editBox.GoToPosition(editBox.line, lineNumber, charPos <= len ? charPos - 1 : (len ? len - 1 : 0));
2400 editBox.scroll = scroll;
2401 updatingCode = false;
2402 loadingFile = false;
2404 codeModified = true;
2408 designer.modifiedDocument = false;
2410 modifiedDocument = false;
2418 void OnRedraw(Surface surface)
2421 surface.SetBackground(marginColor);
2422 surface.Area(0, 0, editBox.anchor.left.distance, clientSize.h - 1);
2423 if(ideSettings.showLineNumbers)
2425 int currentLineNumber;
2427 char lineFormat[16];
2431 int lineNum = editBox.lineNumber + 1;
2434 Array<int> highlightLines = GetHighlightLines();
2436 surface.textOpacity = false;
2437 surface.font = font.font;
2438 surface.TextExtent(" ", 1, null, &spaceH);
2439 currentLineNumber = editBox.scroll.y / spaceH + 1;
2440 sprintf(lineFormat, " %%%du", maxLineNumberLength);
2441 editBox.GetSelPos(null, &y1, null, null, &y2, null, false);
2443 surface.SetForeground(lineNumbersColor);
2444 for(i = 0; i < editBox.clientSize.h - 4; i += spaceH)
2446 for(; n < highlightLines.count && highlightLines[n] < currentLineNumber; n++);
2447 if(currentLineNumber == lineNum)
2449 surface.SetBackground(selectedMarginColor);
2450 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2451 surface.SetBackground(marginColor);
2453 else if((currentLineNumber - 1 >= y1 && currentLineNumber - 1 <= y2) || (currentLineNumber - 1 <= y1 && currentLineNumber - 1 >= y2))
2455 surface.SetBackground(Color { (marginColor.r + selectedMarginColor.r) / 2, (marginColor.g + selectedMarginColor.g) / 2, (marginColor.b + selectedMarginColor.b) / 2 });
2456 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2457 surface.SetBackground(marginColor);
2461 surface.SetBackground(marginColor);
2462 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2464 if(currentLineNumber <= editBox.numLines)
2466 sprintf(lineText, lineFormat, currentLineNumber);
2467 if(currentLineNumber % 10 == 0 || (n < highlightLines.count && currentLineNumber == highlightLines[n]))
2469 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,maxLineNumberLength+1);
2473 surface.SetForeground(Color { 80, 80, 80 });
2474 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,maxLineNumberLength+1);
2475 sprintf(lineText, lineFormat, currentLineNumber % 10);
2476 surface.SetForeground(lineNumbersColor);
2477 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,maxLineNumberLength+1);
2480 currentLineNumber++;
2482 delete highlightLines;
2485 if(editBox.syntaxHighlighting && fileName && ide.projectView)
2487 bool error, bpOnTopFrame, breakpointEnabled[128];
2488 int lineCursor, lineTopFrame, breakpointLines[128];
2489 int count, i, lineH, boxH, scrollY; //, firstLine; firstLine = editBox.firstLine;
2490 Debugger debugger = ide.debugger;
2491 BitmapResource bmpRes;
2493 boxH = clientSize.h;
2494 scrollY = editBox.scroll.y;
2495 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
2497 bpOnTopFrame = false;
2498 count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
2501 for(i = 0; i < count; i++)
2503 if(breakpointLines[i] == lineCursor || breakpointLines[i] == lineTopFrame)
2505 bmpRes = breakpointEnabled[i] ? ide.bmpBpHalf : ide.bmpBpHalfDisabled;
2506 if(breakpointLines[i] == lineTopFrame)
2507 bpOnTopFrame = true;
2510 bmpRes = breakpointEnabled[i] ? ide.bmpBp : ide.bmpBpDisabled;
2512 DrawLineMarginIcon(surface, bmpRes, breakpointLines[i], lineH, scrollY, boxH);
2515 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
2516 bmpRes = bpOnTopFrame ? (error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf) : (error ? ide.bmpTopFrameError : ide.bmpTopFrame);
2517 DrawLineMarginIcon(surface, bmpRes, lineTopFrame, lineH, scrollY, boxH);
2519 if(editBox.anchor.left.distance)
2521 if(editBox.horzScroll && editBox.horzScroll.visible)
2523 surface.SetBackground(control);
2524 surface.Area(0, editBox.clientSize.h, editBox.anchor.left.distance, clientSize.h - 1);
2529 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
2534 lineY = (line - 1) * lineH;
2535 if(lineY + lineH > scrollY && lineY /*+ lineH*/ < scrollY + boxH)
2537 Bitmap bitmap = resource.bitmap;
2539 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
2546 char ext[MAX_EXTENSION];
2547 const char * fileName = property::fileName;
2549 if(SearchString(fileName, 0, "Makefile", false, true))
2550 editBox.useTab = true;
2551 designer.fileName = fileName;
2555 GetExtension(fileName, ext);
2557 if(!strcmpi(ext, "ec") || !strcmpi(ext, "eh") || !strcmpi(ext, "c") || !strcmpi(ext, "h") || !strcmpi(ext, "cpp") ||
2558 !strcmpi(ext, "hpp") || !strcmpi(ext, "cxx") || !strcmpi(ext, "hxx") || !strcmpi(ext, "cc") || !strcmpi(ext, "hh") ||
2559 !strcmpi(ext, "m") || !strcmpi(ext, "mm") || !strcmpi(ext, "cs") || !strcmpi(ext, "java") || !strcmpi(ext, "y") || !strcmpi(ext, "l"))
2560 editBox.syntaxHighlighting = true;
2562 editBox.syntaxHighlighting = false;
2564 if(parsing && !strcmpi(ext, "ec"))
2566 codeModified = true;
2570 maxLineNumberLength = 0;
2575 bool UpdateMarginSize()
2577 if(ideSettings.showLineNumbers)
2579 int numLen = Max(3, nofdigits(editBox.numLines));
2581 maxLineNumberLength = numLen;
2582 display.FontExtent(font.font, "0", 1, &digitWidth, null);
2583 editBox.anchor = Anchor
2585 left = editBox.syntaxHighlighting * 20 + ideSettings.showLineNumbers * (maxLineNumberLength+2) * digitWidth,
2586 right = 0, top = 0, bottom = 0
2591 maxLineNumberLength = 0;
2592 editBox.anchor = Anchor
2594 left = editBox.syntaxHighlighting * 20,
2595 right = 0, top = 0, bottom = 0
2607 bool LoadFile(const char * filePath)
2609 File f = FileOpen(filePath, read);
2612 // Added this here...
2613 fileName = filePath;
2615 updatingCode = true;
2617 updatingCode = false;
2618 loadingFile = false;
2627 void AdjustDebugMenus()
2629 bool unavailable = ide.areDebugMenusUnavailable;
2630 bool isNotNotRunning = unavailable || ide.isDebuggerRunning;
2631 bool isNotStopped = unavailable || !ide.isDebuggerStopped;
2632 bool noBreakpointToggle = ide.isBreakpointTogglingUnavailable;
2634 debugRunToCursor.disabled = isNotNotRunning;
2635 debugSkipRunToCursor.disabled = isNotNotRunning;
2636 debugRunToCursorAtSameLevel.disabled = isNotStopped;
2637 debugSkipRunToCursorAtSameLevel.disabled = isNotStopped;
2639 debugBpRunToCursor.disabled = isNotNotRunning;
2640 debugBpSkipRunToCursor.disabled = isNotNotRunning;
2641 debugBpRunToCursorAtSameLevel.disabled = isNotStopped;
2642 debugBpSkipRunToCursorAtSameLevel.disabled = isNotStopped;
2644 debugToggleBreakpoint.disabled = noBreakpointToggle;
2651 globalData.classes.CompareKey = (void *)BinaryTree::CompareString;
2652 globalData.defines.CompareKey = (void *)BinaryTree::CompareString;
2653 globalData.functions.CompareKey = (void *)BinaryTree::CompareString;
2654 globalData.nameSpaces.CompareKey = (void *)BinaryTree::CompareString;
2657 designer.fileName = fileName;
2663 sprintf(title, $"Untitled %d", documentID);
2664 // designer.fileName = CopyString(title);
2665 designer.fileName = title;
2670 for(c = 0; c < CodeObjectType::enumSize; c++)
2671 icons[c] = BitmapResource { iconNames[c], window = this };
2673 codeModified = true;
2685 selected.modified = true;
2686 selected.oClass.modified = true;
2688 designer.modifiedDocument = true;
2689 modifiedDocument = true;
2690 formModified = true;
2693 /****************************************************************************
2695 ****************************************************************************/
2698 SetCurrentNameSpace(null);
2704 this.defines.Free(FreeModuleDefine);
2705 this.imports.Free(FreeModuleImport); // Moved this after FreeAST because Debug printing causes ModuleImports to be created
2707 FreeExcludedSymbols(this.excludedSymbols);
2708 FreeContext(this.globalContext);
2710 FreeGlobalData(&this.globalData);
2711 FindCtx_Terminate();
2712 FindParams_Terminate();
2714 if(GetGlobalContext() == globalContext)
2716 SetGlobalData(null);
2717 SetGlobalContext(null);
2718 SetExcludedSymbols(null);
2719 SetTopContext(null);
2720 SetCurrentContext(null);
2723 SetPrivateModule(null);
2726 if(this.privateModule)
2728 FreeTypeData(this.privateModule);
2729 delete this.privateModule;
2730 this.privateModule = null;
2736 static bool reentrant = false;
2741 char * selectedClassName = null, * selectedName = null;
2742 int selectedPos = 0;
2743 Designer backDesigner;
2744 char oldWorkDir[MAX_LOCATION];
2745 char mainModuleName[MAX_FILENAME] = "";
2746 const char * fileName;
2747 ImportedModule module;
2748 char extension[MAX_EXTENSION];
2749 PathBackup pathBackup { };
2751 Time parseCodeStart = GetTime();
2752 Time startTime, startFindClass;
2754 findClassTotalTime = 0;
2755 checkTypeTotalTime = 0;
2756 externalImportTotalTime = 0;
2757 findClassIgnoreNSTotalTime = 0;
2758 findSymbolTotalTime = 0;
2759 //ResetClassFindTime();
2763 // This temporarily fixes issue with 2 overrides in release mode with VC6 (only happens with both ecere.dll and ide.exe compiled in release mode)
2764 if(reentrant) return;
2771 selectedClassName = CopyString(oClass.name);
2772 if(selected != oClass)
2774 ObjectInfo object = this.selected;
2775 selectedName = CopyString(object.name);
2779 for(check = this.oClass.instances.first; check; check = check.next)
2791 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
2793 FindCtx_Terminate();
2794 FindParams_Terminate();
2796 SetGlobalData(&globalData);
2797 SetGlobalContext(globalContext);
2798 SetExcludedSymbols(&excludedSymbols);
2799 SetTopContext(globalContext);
2800 SetCurrentContext(globalContext);
2801 SetDefines(&defines);
2802 SetImports(&imports);
2803 SetCurrentNameSpace(null);
2806 sprintf(command, "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin\\cl "
2807 "/nologo /D \"MSC\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" "
2808 "/I \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include\" "
2809 "/I T:\\ecere\\include /E %s", argv[1]);
2813 ChangeWorkingDir("e:\\ec");
2814 sprintf(command, "gcc -x c -E -");
2815 fileInput = DualPipeOpen({ output = true, input = true }, command);
2816 SetFileInput(fileInput);
2821 uint count = editFile.Read(buffer, 1, sizeof(buffer));
2823 fileInput.Write(buffer, 1, count);
2828 fileInput.CloseOutput();
2832 // TOCHECK: COULDN'T WE CALL FreeParser here?
2834 FreeType(this.functionType);
2835 FreeType(this.instanceType);
2836 this.functionType = null;
2837 this.instanceType = null;
2840 sheet.SelectObject(null);
2846 // We don't want the designer to be notified of selection when deleting rows...
2847 backDesigner = designer;
2852 ObjectInfo _class, next;
2854 for(_class = classes.first; _class; _class = next)
2860 while((object = _class.instances.first))
2864 Designer::DestroyObject(object.instance);
2865 delete object.instance;
2867 if(object.i18nStrings)
2869 Map<String, bool> i18nStrings = object.i18nStrings;
2872 sheet.DeleteObject(object);
2874 _class.instances.Delete(object);
2878 Designer::DestroyObject(_class.instance);
2879 delete _class.instance;
2881 if(_class.i18nStrings)
2883 Map<String, bool> i18nStrings = _class.i18nStrings;
2886 sheet.DeleteObject(_class);
2888 classes.Delete(_class);
2894 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2895 if(windowClass && windowClass.data)
2896 UnapplySkin(windowClass);
2899 designer = backDesigner;
2902 fileInput = editFile = EditBoxStream { editBox = editBox };
2903 SetFileInput(fileInput);
2911 defines.Free(FreeModuleDefine);
2912 imports.Free(FreeModuleImport);
2914 FreeContext(this.globalContext);
2915 FreeExcludedSymbols(this.excludedSymbols);
2918 FreeGlobalData(&this.globalData);
2920 if(this.privateModule)
2922 FreeTypeData(this.privateModule);
2923 delete this.privateModule;
2927 startTime = GetTime();
2928 printf("Cleaning up took %.3f seconds\n", startTime - parseCodeStart);
2930 printf("classes.count: %d\n", globalContext.classes.count);
2935 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler);
2936 SetTargetBits(ide.workspace.bitDepth ? ide.workspace.bitDepth : GetHostBits());
2939 this.privateModule = __ecere_COM_Initialize((bool)(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4)), 1, null);
2941 SetPrivateModule(privateModule);
2944 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint"), type = ProcessTypeString("unsigned int", false) });
2945 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint64"), type = ProcessTypeString("unsigned int64", false) });
2946 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint32"), type = ProcessTypeString("unsigned int", false) });
2947 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint16"), type = ProcessTypeString("unsigned short", false) });
2948 globalContext.types.Add((BTNode)Symbol { string = CopyString("byte"), type = ProcessTypeString("unsigned char", false) });
2951 fileName = this.fileName;
2953 if(ide.workspace && ide.workspace.projects && fileName)
2955 for(p : ide.workspace.projects)
2957 char path[MAX_LOCATION];
2959 MakePathRelative(fileName, p.topNode.path, path);
2960 MakeSlashPath(path);
2962 pn = p.topNode.FindWithPath(path, false);
2971 project = ide.project;
2973 GetWorkingDir(oldWorkDir, MAX_LOCATION);
2975 ChangeWorkingDir(project.topNode.path);
2977 SetSomeSourceFileStack(fileName ? fileName : "", 0); //strcpy(sourceFileStack[0], fileName ? fileName : "");
2979 GetLastDirectory(fileName, mainModuleName);
2980 GetExtension(mainModuleName, extension);
2982 SetBuildingEcereCom(false);
2983 SetBuildingEcereComModule(false);
2985 // TODO: Get symbolsDir from project settings instead...
2988 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler);
2989 ProjectConfig config = project.config;
2990 int bitDepth = ide.workspace.bitDepth;
2991 DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
2992 SetSymbolsDir(objDir.dir);
2993 SetDefaultNameSpace(project.GetDefaultNameSpace(config));
2994 ide.SetPath(true, compiler, config, bitDepth);
2998 // SetIncludeDirs(ide.projectView.project.config.includeDirs);
2999 // SetSysIncludeDirs(ide.ideSettings.systemDirs[includes]);
3003 switch(__runtimePlatform)
3005 case win32: SetSymbolsDir("obj/debug.win32"); break;
3006 case tux: SetSymbolsDir("obj/debug.linux"); break;
3007 case apple: SetSymbolsDir("obj/debug.apple"); break;
3009 SetIncludeDirs(null);
3010 SetSysIncludeDirs(null);
3011 SetDefaultNameSpace(null);
3015 if(ide.projectView && ide.projectView.IsModuleInProject(this.fileName))
3017 // TODO FIX for configless project
3018 if(ide.project.config && ide.project.config.options && ide.project.config.options.preprocessorDefinitions)
3020 for(item : ide.project.config.options.preprocessorDefinitions)
3022 if(!strcmp(item, "BUILDING_ECERE_COM"))
3024 SetBuildingEcereCom(true);
3031 if(!(strcmpi(mainModuleName, "instance.ec") && strcmpi(mainModuleName, "BinaryTree.ec") &&
3032 strcmpi(mainModuleName, "dataTypes.ec") && strcmpi(mainModuleName, "OldList.ec") &&
3033 strcmpi(mainModuleName, "String.ec") && strcmpi(mainModuleName, "BTNode.ec") &&
3034 strcmpi(mainModuleName, "Array.ec") && strcmpi(mainModuleName, "AVLTree.ec") &&
3035 strcmpi(mainModuleName, "BuiltInContainer.ec") && strcmpi(mainModuleName, "Container.ec") &&
3036 strcmpi(mainModuleName, "CustomAVLTree.ec") && strcmpi(mainModuleName, "LinkList.ec") &&
3037 strcmpi(mainModuleName, "List.ec") && strcmpi(mainModuleName, "Map.ec") &&
3038 strcmpi(mainModuleName, "Mutex.ec")))
3040 SetBuildingEcereComModule(true);
3043 // Predeclare all classes
3045 char symFile[MAX_FILENAME];
3046 char symLocation[MAX_LOCATION];
3047 ImportedModule module, next;
3049 GetLastDirectory(fileName, symFile);
3050 ChangeExtension(symFile, "sym", symFile);
3052 strcpy(symLocation, GetSymbolsDir());
3053 PathCat(symLocation, symFile);
3055 // if(!GetEcereImported() && !GetBuildingEcereCom())
3056 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
3059 startTime = GetTime();
3061 eModule_LoadStrict(privateModule, "ecereCOM", privateAccess);
3063 printf("Loading ecereCOM took %.3f seconds\n", GetTime() - startTime);
3068 startTime = GetTime();
3070 // LoadSymbols(symLocation, normalImport, true);
3071 LoadSymbols(symLocation, preDeclImport, false);
3073 printf("Loading symbols took %.3f seconds\n", GetTime() - startTime);
3076 for(module = defines.first; module; module = next)
3079 if(module.type == moduleDefinition && strcmpi(module.name, mainModuleName))
3082 defines.Delete(module);
3087 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
3089 SetDefaultDeclMode(privateAccess);
3090 SetDeclMode(privateAccess);
3094 SetDefaultDeclMode(defaultAccess);
3095 SetDeclMode(defaultAccess);
3098 StripExtension(mainModuleName);
3099 module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };
3100 defines.AddName(module);
3103 // SetYydebug(true);
3108 startTime = GetTime();
3109 startFindClass = checkTypeTotalTime;
3113 printf("ParseEc took %.3f seconds, out of which %.3f seconds were in CheckType\n", GetTime() - startTime, checkTypeTotalTime - startFindClass);
3115 CheckDataRedefinitions();
3118 SetIncludeDirs(null);
3119 SetSysIncludeDirs(null);
3130 startTime = GetTime();
3132 PrePreProcessClassDefinitions();
3133 ComputeModuleClasses(privateModule);
3134 PreProcessClassDefinitions();
3135 ProcessClassDefinitions();
3137 printf("Initial Passes took %.3f seconds\n", GetTime() - startTime);
3138 startTime = GetTime();
3143 printf("ComputeDataTypes took %.3f seconds\n", GetTime() - startTime);
3144 startTime = GetTime();
3146 ProcessInstantiations();
3148 printf("ProcessInstantiations took %.3f seconds\n", GetTime() - startTime);
3151 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
3153 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3154 if(!windowClass || windowClass.internalDecl)
3157 startTime = GetTime();
3159 // *** COMMENTED THIS OUT DUE TO ecereCOM issues
3160 // eModule_Load(this.privateModule.application.allModules.first ? this.privateModule.application.allModules.first : this.privateModule, "ecere", privateAccess);
3161 eModule_Load(this.privateModule, "ecere", privateAccess);
3163 printf("Loading ecere.dll took %.3f seconds\n", GetTime() - startTime);
3166 windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3168 if(windowClass && windowClass.data)
3169 ApplySkin(windowClass, app.currentSkin.name, null);
3173 startTime = GetTime();
3175 for(external = ast->first; external; external = external.next)
3177 if(external.type == classExternal)
3179 ClassDefinition _class = external._class;
3180 if(_class.baseSpecs && _class.baseSpecs->first && ((Specifier)_class.baseSpecs->first).type == nameSpecifier ) // classSpecifier
3182 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)_class.baseSpecs->first).name);
3185 if(eClass_GetDesigner(regClass) && !GetBuildingEcereComModule())
3187 Instance instance = eInstance_New(regClass);
3188 ObjectInfo classObject
3190 name = CopyString(_class._class.name);
3191 instance = instance;
3192 classDefinition = _class;
3193 oClass = classObject;
3195 classes.Add(classObject);
3199 // Moved this at bottom so that the file dialog doesn't show up in eCom
3200 designer.CreateObject(instance, classObject, true, null);
3201 sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, typeClass, false);
3203 if(_class.definitions)
3207 for(def = _class.definitions->first; def; def = def.next)
3211 case defaultPropertiesClassDef:
3214 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
3216 Identifier id = propDef.identifiers->first;
3219 Property prop = eClass_FindProperty(regClass, id.string, this.privateModule);
3222 Class propertyClass = prop.dataTypeClass;
3224 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3225 if(prop.compiled && prop.Set && prop.Get && propertyClass && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp)
3227 Expression computed;
3228 bool variable = true;
3230 FreeType(propDef.initializer.exp.destType);
3231 propDef.initializer.exp.destType = MkClassType(propertyClass.name);
3232 ProcessExpressionType(propDef.initializer.exp);
3234 computed = CopyExpression(propDef.initializer.exp);
3235 ComputeExpression(computed);
3236 if(computed.isConstant)
3238 switch(computed.type)
3241 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3243 String temp = new char[strlen(computed.string)+1];
3244 ReadString(temp, computed.string);
3245 ((void (*)(void *, void *))(void *)prop.Set)(instance, temp);
3248 if(!propDef.initializer.exp.intlString)
3250 Map<String, bool> i18nStrings = classObject.i18nStrings;
3252 classObject.i18nStrings = i18nStrings = { };
3253 i18nStrings[prop.name] = false;
3259 if((propertyClass.type == structClass || propertyClass.type == noHeadClass || propertyClass.type == normalClass) && !id.next)
3263 if(computed.instance._class && computed.instance._class.symbol &&
3264 computed.instance._class.symbol.registered &&
3265 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3267 ((void (*)(void *, void *))(void *)prop.Set)(instance, computed.instance.data);
3269 // This was saved in the control and shouldn't be freed by FreeExpression...
3270 // (Not doing this anymore, incrementing refCount in pass15 instead)
3271 /*if(propertyClass.type == normalClass)
3272 computed.instance.data = null;*/
3280 Operand value = GetOperand(computed);
3281 DataValue valueData;
3282 valueData.i64 = value.i64;
3283 SetProperty(prop, instance, valueData);
3290 propDef.variable = true;
3291 FreeExpression(computed);
3296 Method method = eClass_FindMethod(regClass, id.string, this.privateModule);
3297 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer &&
3298 propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
3301 // Maintain a list in FunctionDefinition of who is attached to it
3302 for(def = _class.definitions->first; def; def = def.next)
3304 if(def.type == functionClassDef)
3306 ClassFunction function = def.function;
3307 if(!strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
3309 function.attached.Add(OldLink { data = method });
3319 case declarationClassDef:
3321 Declaration decl = def.decl;
3324 case instDeclaration:
3326 Instantiation inst = decl.inst;
3327 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3328 if(instClass && eClass_GetDesigner(instClass))
3330 Instance control = eInstance_New(instClass);
3335 oClass = classObject;
3339 classObject.instances.Add(object);
3341 // TOCHECK: Why is this needed now?
3342 object.name = CopyString((inst.exp.type == memberExp) ? inst.exp.member.member.string : inst.exp.identifier.string);
3343 def.object = object;
3345 // if(object.name) { symbol = eList_Add(&curContext.symbols, sizeof(Symbol)); symbol.string = object.name; symbol.type = MkClassType(instClass.name); }
3347 designer.CreateObject(control, object, false, classObject.instance);
3348 sheet.AddObject(object, object.name ? object.name : inst._class.name, typeData, false);
3358 // Second pass, process instantiation members
3360 for(def = _class.definitions->first; def; def = def.next)
3364 case declarationClassDef:
3366 Declaration decl = def.decl;
3369 case instDeclaration:
3371 Instantiation inst = decl.inst;
3372 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3373 if(instClass && eClass_GetDesigner(instClass))
3376 object = object ? object.next : classObject.instances.first;
3377 control = object.instance;
3381 MembersInit members;
3382 for(members = inst.members->first; members; members = members.next)
3384 switch(members.type)
3386 case dataMembersInit:
3388 if(members.dataMembers)
3391 DataMember curMember = null;
3392 Class curClass = null;
3393 DataMember subMemberStack[256];
3394 int subMemberStackPos = 0;
3396 for(member = members.dataMembers->first; member; member = member.next)
3399 Identifier ident = member.identifiers ? member.identifiers->first : null;
3402 DataMember _subMemberStack[256];
3403 int _subMemberStackPos = 0;
3404 DataMember thisMember = (DataMember)eClass_FindDataMember(instClass, ident.string, privateModule, _subMemberStack, &_subMemberStackPos);
3408 thisMember = (DataMember)eClass_FindProperty(instClass, ident.string, privateModule);
3410 if(thisMember && thisMember.memberAccess == publicAccess)
3412 curMember = thisMember;
3413 curClass = curMember._class;
3414 memcpy(subMemberStack, _subMemberStack, sizeof(DataMember) * _subMemberStackPos);
3415 subMemberStackPos = _subMemberStackPos;
3421 eClass_FindNextMember(instClass, &curClass, (DataMember *)&curMember, subMemberStack, &subMemberStackPos);
3422 if(curMember) found = true;
3424 if(found && curMember.isProperty)
3426 Property prop = (Property) curMember;
3427 Class propertyClass = prop.dataTypeClass;
3428 bool variable = false;
3430 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3432 if(prop.compiled && prop.Set && prop.Get && propertyClass && member.initializer && member.initializer.type == expInitializer && member.initializer.exp)
3434 FreeType(member.initializer.exp.destType);
3435 member.initializer.exp.destType = MkClassType(propertyClass.name);
3438 Expression computed;
3440 ProcessExpressionType(member.initializer.exp);
3442 computed = CopyExpression(member.initializer.exp);
3445 bool isClass = propertyClass.type == structClass || propertyClass.type == normalClass || propertyClass.type == noHeadClass;
3448 /*char debugExpString[4096];
3449 debugExpString[0] = '\0';
3450 PrintExpression(member.initializer.exp, debugExpString);*/
3452 ComputeExpression(computed);
3454 switch(computed.type)
3457 if(isClass && computed.isConstant && computed.instance.data)
3459 if(computed.instance._class && computed.instance._class.symbol &&
3460 computed.instance._class.symbol.registered &&
3461 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3463 ((void (*)(void *, void *))(void *)prop.Set)(control, computed.instance.data);
3465 // This was saved in the control and shouldn't be freed by FreeExpression...
3466 // (Not doing this anymore, incrementing refCount in pass15 instead)
3467 /*if(propertyClass.type == normalClass)
3468 computed.instance.data = null;*/
3474 if(isClass && eClass_GetDesigner(propertyClass))
3477 char * name = computed.identifier.string;
3478 if(!strcmp(name, "this"))
3481 ((void (*)(void *, void *))(void *)prop.Set)(control, instance);
3487 for(check = classObject.instances.first; check; check = check.next)
3488 if(check.name && !strcmp(name, check.name))
3491 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3501 if(computed.member.exp.type == identifierExp)
3503 char * name = computed.member.exp.identifier.string;
3505 if(!strcmp(name, "this"))
3507 char * name = computed.member.member.string;
3509 for(check = classObject.instances.first; check; check = check.next)
3510 if(check.name && !strcmp(name, check.name))
3513 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3520 for(check = classObject.instances.first; check; check = check.next)
3522 if(check.name && !strcmp(name, check.name))
3524 Property getProperty = eClass_FindProperty(check.instance._class, computed.member.member.string, this.privateModule);
3527 DataValue value { };
3528 GetProperty(getProperty, check.instance, &value);
3529 SetProperty(prop, control, value);
3540 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3542 String temp = new char[strlen(computed.string)+1];
3543 ReadString(temp, computed.string);
3544 ((void (*)(void *, void *))(void *)prop.Set)(control, temp);
3547 if(!member.initializer.exp.intlString)
3549 Map<String, bool> i18nStrings = object.i18nStrings;
3551 object.i18nStrings = i18nStrings = { };
3552 i18nStrings[prop.name] = false;
3559 if(!isClass && computed.isConstant)
3561 if(!strcmp(propertyClass.dataTypeString, "float"))
3562 ((void (*)(void *, float))(void *)prop.Set)(control, (float)strtod(computed.constant, null));
3563 else if(!strcmp(propertyClass.dataTypeString, "double"))
3564 ((void (*)(void *, double))(void *)prop.Set)(control, strtod(computed.constant, null));
3566 ((void (*)(void *, int))(void *)prop.Set)(control, strtol(computed.constant, null, 0));
3573 FreeExpression(computed);
3577 member.variable = true;
3579 else if(ident && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3580 member.initializer.exp.type == memberExp) // identifierExp
3582 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3583 if(method && method.type == virtualMethod)
3586 // Maintain a list in FunctionDefinition of who is attached to it
3587 for(def = _class.definitions->first; def; def = def.next)
3589 if(def.type == functionClassDef)
3591 ClassFunction function = def.function;
3592 Identifier id = (member.initializer.exp.type == memberExp) ? member.initializer.exp.member.member : member.initializer.exp.identifier;
3593 if(function.declarator && !strcmp(function.declarator.symbol.string, id.string))
3595 function.attached.Add(OldLink { data = method });
3596 // Reference this particular instance?
3611 designer.PostCreateObject(object.instance, object, false, classObject.instance);
3622 //designer.CreateObject(instance, classObject, true, null);
3623 //sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, classType, false);
3625 designer.PostCreateObject(instance, classObject, true, null);
3627 //instance.state = Hidden;
3628 //instance.Create();
3629 //instance.SetState(Normal, true, 0);
3638 printf("Class/Instance Processing took %.3f seconds\n", GetTime() - startTime);
3642 // Restore Selection
3643 if(selectedClassName)
3646 for(oClass = classes.first; oClass; oClass = oClass.next)
3648 if(!strcmp(oClass.name, selectedClassName))
3650 this.oClass = oClass;
3654 delete selectedClassName;
3662 for(check = this.oClass.instances.first; check; check = check.next)
3664 if(check.name && !strcmp(check.name, selectedName))
3666 this.selected = check;
3672 if(this.oClass.instances.first)
3673 this.selected = this.oClass.instances.first;
3675 this.selected = this.oClass;
3678 else if(selectedPos == -1 || !this.oClass.instances.count)
3679 this.selected = this.oClass;
3685 if(selectedPos > this.oClass.instances.count)
3687 for(check = this.oClass.instances.first; check; check = check.next)
3689 if(selectedPos == pos++)
3691 this.selected = check;
3699 this.oClass = classes.first;
3700 this.selected = (this.oClass && this.oClass.instances.first) ? this.oClass.instances.first : this.oClass;
3702 delete selectedName;
3703 SetSymbolsDir(null);
3705 if(sheet.codeEditor == this)
3706 sheet.SelectObject(selected);
3709 codeModified = false;
3711 // TESTING THIS TO NOT GET EMPTY PARAMETERS
3714 InvokeParameters(false, false, false);
3717 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
3723 ChangeWorkingDir(oldWorkDir);
3725 printf("Total FindClass time is %.3f seconds, out of which %.3f is in Ignore NS\n\n", findClassTotalTime, findClassIgnoreNSTotalTime);
3726 printf("Total CheckType time is %.3f seconds\n\n", checkTypeTotalTime);
3727 printf("Total MkExternalImport time is %.3f seconds\n\n", externalImportTotalTime);
3728 printf("Total FindSymbol time is %.3f seconds\n\n", findSymbolTotalTime);
3729 // printf("Total Class Members Find time is %.3f seconds\n\n", GetClassFindTime());
3731 printf("Whole ParseCode function took %.3f seconds\n\n", GetTime() - parseCodeStart);
3733 if(inUseDebug && ide.projectView)
3734 ide.debugger.EvaluateWatches();
3739 void UpdateInstanceCodeClass(Class _class, ObjectInfo object, EditBoxStream f, Instance test, bool * prev, bool * lastIsMethod, DataMember * curMember, Class * curClass)
3742 Window control = (Window)object.instance;
3743 ObjectInfo classObject = object.oClass;
3745 if(_class.base && _class.base.type != systemClass) UpdateInstanceCodeClass(_class.base, object, f, test, prev, lastIsMethod, curMember, curClass);
3747 if(!strcmp(_class.name, "DesignerBase")) return;
3749 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
3751 Property prop = eClass_FindProperty(object.instance._class, propIt.name, privateModule);
3752 if(prop && prop.isProperty && !prop.conversion && eClass_FindProperty(object.instance._class, prop.name, privateModule))
3754 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(object, prop.name) &&
3755 prop.compiled && (!prop.IsSet || prop.IsSet(control)))
3757 Class dataType = prop.dataTypeClass;
3759 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3763 if(dataType.type == structClass)
3765 void * dataForm = new0 byte[dataType.structSize];
3766 void * dataTest = new0 byte[dataType.structSize];
3768 ((void (*)(void *, void *))(void *)prop.Get)(control, dataForm);
3769 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
3771 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3773 char tempString[1024] = "";
3774 const char * string = "";
3775 bool needClass = true;
3779 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3781 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3783 eClass_FindNextMember(_class, curClass, curMember, null, null);
3784 if(*curMember != (DataMember)prop)
3785 f.Printf("%s = ", prop.name);
3787 *curMember = (DataMember)prop;
3788 *curClass = curMember->_class;
3791 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3793 f.Printf("%s", string);
3800 else if(dataType.type == normalClass || dataType.type == noHeadClass)
3802 void * dataForm, * dataTest;
3803 bool isEditBoxContents = false;
3804 bool freeDataForm = false, freeDataTest = false;
3806 // Because contents property is broken for mutiline EditBox at the moment
3807 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
3808 isEditBoxContents = true;
3810 if(isEditBoxContents && ((EditBox)control).multiLine)
3812 dataForm = ((EditBox)control).multiLineContents;
3813 freeDataForm = true;
3816 dataForm = ((void *(*)(void *))(void *)prop.Get)(control);
3817 if(isEditBoxContents && ((EditBox)test).multiLine)
3819 dataTest = ((EditBox)test).multiLineContents;
3820 freeDataTest = true;
3823 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
3825 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3827 char tempString[1024] = "";
3828 const char * string = "";
3832 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3834 eClass_FindNextMember(_class, curClass, curMember, null, null);
3835 if(*curMember != (DataMember)prop)
3836 f.Printf("%s = ", prop.name);
3837 *curMember = (DataMember)prop;
3838 *curClass = curMember->_class;
3840 if(eClass_GetDesigner(dataType))
3842 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
3843 //if(!strcmp(classObject.instance._class.name, dataType.name) && classObject.instance == dataForm)
3844 f.Printf("this", prop.name);
3847 //ObjectInfo classObject;
3848 //for(classObject = classes.first; classObject; classObject = classObject.next)
3852 for(object = classObject.instances.first; object; object = object.next)
3854 if(!object.deleted && eClass_IsDerived(object.instance._class, dataType) && object.instance == dataForm && object.name)
3856 f.Printf("%s", object.name);
3863 bool needClass = true;
3864 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3865 f.Printf("%s", string);
3872 bool needClass = true;
3873 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3875 if(!strcmp(dataType.dataTypeString, "char *"))
3877 Map<String, bool> i18nStrings = object.i18nStrings;
3879 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false, null))
3882 f.Printf("%s\"", i18n ? "$" : "");
3883 OutputString(f, string);
3887 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3889 f.Printf("%s", string);
3892 *lastIsMethod = false;
3895 if(freeDataForm) delete dataForm;
3896 if(freeDataTest) delete dataTest;
3900 DataValue dataForm, dataTest;
3902 GetProperty(prop, control, &dataForm);
3903 GetProperty(prop, test, &dataTest);
3905 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
3907 char * string = null;
3908 char tempString[1024] = "";
3909 SetProperty(prop, test, dataForm);
3911 if(dataType.type != bitClass)
3913 bool needClass = true;
3915 if(dataType.type == enumClass)
3918 Class enumClass = eSystem_FindClass(privateModule, "enum");
3919 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
3920 int64 i64Value = GetI64EnumValue(dataType, dataForm);
3922 for(value = e.values.first; value; value = value.next)
3924 if(value.data == i64Value)
3926 string = value.name;
3932 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
3934 if(string && string[0])
3939 eClass_FindNextMember(_class, curClass, curMember, null, null);
3940 if(*curMember != (DataMember)prop)
3941 f.Printf("%s = ", prop.name);
3942 *curMember = (DataMember)prop;
3943 *curClass = curMember->_class;
3945 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
3946 f.Printf("%sf", string);
3948 f.Printf("%s", string);
3952 else if(dataType.type == bitClass)
3954 bool needClass = true;
3956 if(*prev) f.Printf(", ");
3958 eClass_FindNextMember(_class, curClass, curMember, null, null);
3959 if(*curMember != (DataMember)prop)
3960 f.Printf("%s = ", prop.name);
3961 *curMember = (DataMember)prop;
3962 *curClass = curMember->_class;
3964 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm.ui, tempString, null, &needClass);
3966 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3968 f.Printf("%s", string);
3970 *lastIsMethod = false;
3980 int UpdateInstanceCode(EditBoxStream f, int position, Class regClass, ObjectInfo object, bool * firstObject, char ** text, int * textSize, int movedFuncIdLen, int movedFuncIdPos)
3982 Instantiation inst = object.instCode;
3983 Window control = (Window)object.instance;
3985 bool methodPresent = false;
3986 bool lastIsMethod = true;
3992 // Instance removed, delete it
3993 DeleteJunkBefore(f, inst.loc.start.pos, &position);
3995 f.DeleteBytes(inst.loc.end.pos - inst.loc.start.pos + 1);
3996 position = inst.loc.end.pos + 1;
4000 bool multiLine = false;
4003 // Check if it's an unnamed instance
4006 f.Seek(inst.nameLoc.start.pos - position, current);
4007 f.DeleteBytes(inst.nameLoc.end.pos - inst.nameLoc.start.pos);
4008 position = inst.nameLoc.end.pos;
4010 f.Printf(object.name);
4015 if(isspace(ch) && ch != '\n')
4017 f.Seek(-1, current);
4025 int pos = inst.loc.start.pos; // + strlen(inst._class.name);
4027 f.Seek(pos - position, current);
4032 f.Seek(-1, current);
4041 f.Puts(object.name);
4046 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
4047 methodPresent = true;
4055 if(ch == OpenBracket)
4061 // TODO: Simplify this?
4070 f.Seek(-1, current);
4071 DeleteJunkBefore(f, position, &position);
4083 if(ch == '\n') { toDelete = count; count = 0; }
4084 else if(isspace(ch)) count++;
4087 f.Seek(-1, current);
4091 toDelete += count - 6;
4095 toAdd = 6 - count;*/
4101 f.Seek(-toDelete-count, current);
4102 f.DeleteBytes(toDelete);
4103 f.Seek(count, current);
4106 DeleteJunkBefore(f, position, &position);
4108 // Removed this here as it was adding trailing spaces when adding a method
4113 for(c = 0; c<toAdd; c++)
4120 methodPresent = multiLine;
4122 //if(!prev) -- always false
4123 f.Printf(methodPresent ? "\n " : " ");
4128 // Instance not there, create a brand new one
4129 DeleteJunkBefore(f, position, &position);
4130 f.Printf(*firstObject ? "\n\n" : "\n");
4131 *firstObject = false;
4133 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
4134 methodPresent = true;
4139 f.Printf(" %s %s\n %c\n ", control._class.name, object.name, OpenBracket);
4141 f.Printf(" %s\n %c\n ", control._class.name, OpenBracket);
4146 f.Printf(" %s %s %c ", control._class.name, object.name, OpenBracket);
4148 f.Printf(" %s %c ", control._class.name, OpenBracket);
4154 Instance test = eInstance_New(control._class);
4155 DataMember curMember = null;
4156 Class curClass = null;
4159 UpdateInstanceCodeClass(control._class, object, f, test, &prev, &lastIsMethod, &curMember, &curClass);
4163 // Attach Method here
4164 if((this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod) && !this.moveAttached && this.selected == object)
4166 if(prev) f.Printf(", ");
4167 f.Printf("%s = %s", this.method.name, function.declarator.symbol.string);
4172 if(inst && !object.deleted)
4174 MembersInit members;
4175 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
4177 DeleteJunkBefore(f, position, &position);
4179 // Instance already there, clear out the properties
4180 for(members = inst.members ? inst.members->first : null; members; members = members.next)
4182 if(members.type == dataMembersInit)
4186 if(members.dataMembers)
4188 bool keptMember = false;
4189 MemberInit lastKept = null;
4191 for(member = members.dataMembers->first; member; member = member.next)
4193 Identifier ident = member.identifiers ? member.identifiers->first : null;
4194 bool deleted = false;
4196 // For now delete if it's not a method
4197 if(!member.variable) // && ident)
4199 if(!ident || !ident.next)
4201 Property prop = ident ? eClass_FindProperty(instClass, ident.string, this.privateModule) : null;
4204 f.Seek(member.loc.start.pos - position, current);
4205 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4206 position = member.loc.end.pos;
4211 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
4212 if(method && method.type == virtualMethod && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
4213 member.initializer.exp.type == memberExp /*ExpIdentifier*/)
4215 if(((this.methodAction == actionDetachMethod || this.methodAction == actionReattachMethod) && this.method == method && this.selected == object) ||
4216 (this.methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, member.initializer.exp.identifier.string)))
4218 f.Seek(member.loc.start.pos - position, current);
4219 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4220 position = member.loc.end.pos;
4232 //f.Seek(member.loc.start.pos - position, current);
4233 //position = member.loc.start.pos;
4234 DeleteJunkBefore(f, member.loc.start.pos, &position);
4235 if(prev) f.Printf(", ");
4236 else if(keptMember) f.Printf(" ");
4241 if(!keptMember || !members.next)
4245 if(keptMember && lastKept != members.dataMembers->last)
4250 f.Seek(-1, current);
4256 f.Seek(-1, current);
4259 else if(!isspace(ch))
4261 f.Seek(-2, current);
4266 f.DeleteBytes(count);
4269 f.Seek(members.loc.end.pos - position, current);
4274 f.Seek(-1, current);
4276 position = members.loc.end.pos + 1;
4280 f.Seek(-1, current);
4281 position = members.loc.end.pos;
4287 lastIsMethod = false;
4292 DeleteJunkBefore(f, position, &position);
4295 if(lastKept != members.dataMembers->last)
4300 f.Seek(-1, current);
4306 f.Seek(-1, current);
4309 else if(!isspace(ch))
4311 f.Seek(-2, current);
4316 f.DeleteBytes(count);
4320 f.Seek(members.loc.end.pos - position, current);
4321 position = members.loc.end.pos;
4325 lastIsMethod = true;
4328 lastIsMethod = false;
4334 f.Seek(members.loc.end.pos - position, current);
4335 position = members.loc.end.pos;
4337 lastIsMethod = true;
4340 else if(members.type == methodMembersInit)
4342 if(this.methodAction == actionDeleteMethod && members.function == function);
4344 methodPresent = true;
4346 // Delete instance method here
4347 if((this.methodAction == actionDeleteMethod || (this.methodAction == actionDetachMethod && this.moveAttached)) &&
4348 members.function == function)
4350 if(this.moveAttached && !*text)
4351 GetLocText(editBox, f, position, &function.loc, text, textSize, Max((int)strlen(this.methodName) - movedFuncIdLen,0), 0);
4353 DeleteJunkBefore(f, members.loc.start.pos, &position);
4354 f.DeleteBytes(members.loc.end.pos - members.loc.start.pos + 1);
4355 position = members.loc.end.pos + 1;
4360 DeleteJunkBefore(f, position, &position);
4364 DeleteJunkBefore(f, members.loc.start.pos, &position);
4365 lastIsMethod = true;
4369 f.Seek(members.loc.end.pos - position, current);
4370 position = members.loc.end.pos;
4372 DeleteJunkBefore(f, position, &position);
4381 if((this.methodAction == actionAddMethod || (this.moveAttached && (this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod))) && this.selected == object)
4383 Method method = this.method;
4384 DeleteJunkBefore(f, position, &position);
4390 if(!method.dataType)
4391 method.dataType = ProcessTypeString(method.dataTypeString, false);
4394 Type dataType = method.dataType;
4395 Type returnType = dataType.returnType;
4398 if(this.moveAttached)
4400 // Move function here:
4401 int newLen = strlen(method.name);
4406 GetLocText(editBox, f, position, &function.loc, text, textSize, Max(newLen - movedFuncIdLen, 0), 3);
4408 // First change name of function
4409 memmove(*text + movedFuncIdPos + newLen, *text + movedFuncIdPos + movedFuncIdLen, *textSize - movedFuncIdPos - movedFuncIdLen + 1);
4410 *textSize += newLen - movedFuncIdLen;
4411 memcpy(*text + movedFuncIdPos, method.name, newLen);
4413 // Second, tab right
4416 for(c = 0; (*text)[c]; )
4419 for(i = c; (*text)[i] && (*text)[i] != '\n'; i++);
4422 memmove((*text)+c+3, (*text)+c, *textSize+1-c);
4423 (*text)[c] = (*text)[c+1] = (*text)[c+2] = ' ';
4427 for(; (*text)[c] && (*text)[c] != '\n'; c++);
4437 // Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4439 // ADDING METHOD HERE
4441 OutputType(f, returnType, false);
4444 if(dataType.thisClass)
4446 if(!eClass_IsDerived(regClass, dataType.thisClass.registered) && !dataType.classObjectType) // Just fixed this... was backwards.
4448 if(dataType.thisClass.shortName)
4449 f.Printf(dataType.thisClass.shortName);
4451 f.Printf(dataType.thisClass.string);
4455 f.Printf(method.name);
4457 for(param = dataType.params.first; param; param = param.next)
4459 OutputType(f, param, true);
4464 f.Printf(" %c\n\n", OpenBracket);
4466 if(control._class._vTbl[method.vid] == null /*moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]*/) // Temp Check for DefaultFunction
4468 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4469 f.Printf(" return true;\n");
4470 else if(returnType.kind != voidType)
4471 f.Printf(" return 0;\n");
4476 if(returnType.kind != voidType)
4477 f.Printf("return ");
4478 f.Printf("%s::%s(", control._class.name, method.name);
4479 for(param = dataType.params.first; param; param = param.next)
4481 if(param.prev) f.Printf(", ");
4482 if(param.kind != voidType)
4483 f.Printf(param.name);
4487 f.Printf(" %c\n", CloseBracket);
4493 if(!object.instCode)
4494 f.Printf(methodPresent ? " %c;" : "%c;", CloseBracket);
4495 else if(!object.deleted)
4497 // Turn this into a multiline instance when adding a method
4498 DeleteJunkBefore(f, inst.loc.end.pos-1, &position);
4500 f.Printf(methodPresent ? "\n " : " ");
4502 f.Seek(inst.loc.end.pos + 1 - position, current);
4503 position = inst.loc.end.pos + 1;
4508 void OutputClassProperties(Class _class, ObjectInfo classObject, EditBoxStream f, Instance test)
4511 Class regClass = eSystem_FindClass(privateModule, classObject.name);
4513 if(_class.base && _class.base.type != systemClass) OutputClassProperties(_class.base, classObject, f, test);
4515 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
4517 Property prop = eClass_FindProperty(selected.instance._class, propIt.name, privateModule);
4518 if(prop && prop.isProperty && !prop.conversion)
4520 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(classObject, prop.name) &&
4521 (!prop.IsSet || prop.IsSet(classObject.instance)))
4523 Class dataType = prop.dataTypeClass;
4524 char tempString[1024] = "";
4525 char * string = null;
4526 bool specify = false;
4529 member = eClass_FindDataMember(regClass, prop.name, privateModule, null, null);
4530 if(member && member._class == regClass)
4534 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
4536 if(dataType && dataType.type == structClass)
4538 void * dataForm = new0 byte[dataType.structSize];
4539 void * dataTest = new0 byte[dataType.structSize];
4541 ((void (*)(void *, void *))(void *)prop.Get)(classObject.instance, dataForm);
4542 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
4544 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4546 bool needClass = true;
4548 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4549 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4551 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4553 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4558 else if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
4560 void * dataForm, * dataTest;
4561 bool isEditBoxContents = false;
4562 bool freeDataForm = false, freeDataTest = false;
4564 // Because contents property is broken for mutiline EditBox at the moment
4565 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
4566 isEditBoxContents = true;
4568 if(isEditBoxContents && ((EditBox)classObject.instance).multiLine)
4570 dataForm = ((EditBox)classObject.instance).multiLineContents;
4571 freeDataForm = true;
4574 dataForm = ((void *(*)(void *))(void *)prop.Get)(classObject.instance);
4575 if(isEditBoxContents && ((EditBox)test).multiLine)
4577 dataTest = ((EditBox)test).multiLineContents;
4578 freeDataTest = true;
4581 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
4583 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4585 char tempString[1024] = "";
4586 char * string = null;
4587 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4589 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
4591 // Shouldn't go here ...
4592 f.Printf("\n %s%s = this;", specify ? "property::" : "", prop.name);
4596 bool needClass = true;
4598 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4600 if(!strcmp(dataType.dataTypeString, "char *"))
4602 Map<String, bool> i18nStrings = classObject.i18nStrings;
4604 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false, null))
4607 f.Printf("\n %s%s = %s\"", specify ? "property::" : "", prop.name, i18n ? "$" : "");
4608 OutputString(f, string);
4612 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4614 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4617 if(freeDataForm) delete dataForm;
4618 if(freeDataTest) delete dataTest;
4622 DataValue dataForm, dataTest;
4624 GetProperty(prop, classObject.instance, &dataForm);
4625 GetProperty(prop, test, &dataTest);
4627 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
4629 SetProperty(prop, test, dataForm);
4630 if(dataType.type == bitClass)
4632 bool needClass = true;
4633 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4635 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4637 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4641 bool needClass = true;
4642 if(dataType.type == enumClass)
4645 Class enumClass = eSystem_FindClass(privateModule, "enum");
4646 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
4647 int64 i64Value = GetI64EnumValue(dataType, dataForm);
4649 for(value = e.values.first; value; value = value.next)
4651 if(value.data == i64Value)
4653 string = value.name;
4659 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4660 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
4661 f.Printf("\n %s%s = %sf;", specify ? "property::" : "", prop.name, string);
4663 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4672 void UpdateFormCode()
4675 if(!parsing) return;
4682 else if(formModified)
4684 EditBoxStream f { editBox = editBox };
4688 Identifier movedFuncId;
4689 int movedFuncIdLen = 0, movedFuncIdPos = 0;
4690 ObjectInfo classObject;
4694 editBox.recordUndoEvent = true;
4698 movedFuncId = GetDeclId(function.declarator);
4699 movedFuncIdLen = movedFuncId.loc.end.pos - movedFuncId.loc.start.pos;
4700 movedFuncIdPos = movedFuncId.loc.start.pos - function.loc.start.pos;
4703 for(classObject = classes.first; classObject; classObject = classObject.next)
4705 ClassDefinition classDef = classObject.classDefinition;
4706 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
4709 bool firstObject = true;
4710 ObjectInfo object = classObject.instances.first;
4711 bool lastIsDecl = false;
4713 if(!classObject.modified) continue;
4715 test = eInstance_New(regClass);
4718 // Put it in the same desktop window...
4719 designer.PrepareTestObject(test);
4721 //f.Printf("class %s : %s\n", classObject.name, classObject.oClass.name);
4722 //f.Printf("%c\n\n", OpenBracket);
4724 // Change the _class name
4725 f.Seek(classDef.nameLoc.start.pos - position, current);
4726 f.DeleteBytes(classDef.nameLoc.end.pos - classDef.nameLoc.start.pos);
4727 f.Printf(classObject.name);
4728 position = classDef.nameLoc.end.pos;
4731 // Go to block start, delete all until no white space, put \n
4735 f.Seek(classDef.blockStart.end.pos - position, current);
4736 position = classDef.blockStart.end.pos;
4738 for(; f.Getc(&ch); count++)
4742 f.Seek(-1, current);
4752 f.Seek(-count, current);
4754 f.DeleteBytes(count-back);
4756 position += count-back;
4759 // Output properties
4760 OutputClassProperties(classObject.instance._class, classObject, f, test);
4762 for(def = classDef.definitions->first; def; def = def.next)
4766 case defaultPropertiesClassDef:
4768 bool keptMember = false;
4770 MemberInit lastKept = null;
4773 DeleteJunkBefore(f, def.loc.start.pos, &position);
4775 // This was adding blank spaces between comment and properties -- What was it for?
4778 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4780 Identifier ident = propDef.identifiers->first;
4781 bool deleted = false;
4783 // For now delete if it's a prop
4784 if(!propDef.variable && ident)
4788 Property prop = eClass_FindProperty(regClass, ident.string, this.privateModule);
4791 f.Seek(propDef.loc.start.pos - position, current);
4792 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4793 position = propDef.loc.end.pos;
4798 Method method = eClass_FindMethod(regClass, ident.string, this.privateModule);
4799 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4801 if(((methodAction == actionDetachMethod || methodAction == actionReattachMethod) && method == this.method && selected == classObject) ||
4802 (methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string)))
4804 f.Seek(propDef.loc.start.pos - position, current);
4805 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4806 position = propDef.loc.end.pos;
4823 f.Seek(def.loc.end.pos - position - 1, current);
4828 f.Seek(-1, current);
4831 position = def.loc.end.pos;
4835 if(lastKept != def.defProperties->last)
4840 f.Seek(-1, current);
4846 f.Seek(-1, current);
4849 else if(!isspace(ch))
4851 f.Seek(-2, current);
4856 f.DeleteBytes(count);
4860 f.Seek(def.loc.end.pos - position, current);
4861 position = def.loc.end.pos;
4866 case declarationClassDef:
4868 Declaration decl = def.decl;
4870 if(decl.type == instDeclaration)
4872 if(def.object/* && ((ObjectInfo)def.object).modified*/)
4874 while(def.object && object != def.object)
4876 if(object /*&& ((ObjectInfo)def.object).modified*/)
4877 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4878 object = object.next;
4881 DeleteJunkBefore(f, def.loc.start.pos, &position);
4882 f.Printf(firstObject ? "\n\n " : "\n ");
4883 firstObject = false;
4885 if(def.object && ((ObjectInfo)def.object).modified)
4886 position = UpdateInstanceCode(f, position, regClass, def.object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4888 object = object ? object.next : null;
4892 DeleteJunkBefore(f, def.loc.start.pos, &position);
4893 f.Printf(firstObject ? "\n\n " : "\n ");
4894 firstObject = false;
4900 DeleteJunkBefore(f, def.loc.start.pos, &position);
4901 f.Printf(lastIsDecl ? "\n " : "\n\n ");
4906 case functionClassDef:
4908 // TESTING IF THIS IS GOOD ENOUGH FOR GENERATED FUNCTION...
4909 if(!def.function.body) continue;
4913 DeleteJunkBefore(f, def.loc.start.pos, &position);
4916 // Delete _class methods
4917 if((methodAction == actionDeleteMethod || (moveAttached && selected != classObject)) &&
4918 def.function == function)
4923 if(moveAttached && !text)
4925 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max((int)strlen(methodName) - movedFuncIdLen,0), 3);
4928 f.Seek(def.loc.end.pos - position, current);
4929 for(; f.Getc(&ch); count++)
4933 f.Seek(-1, current);
4937 f.Seek(def.loc.start.pos - def.loc.end.pos - count, current);
4939 f.DeleteBytes(def.loc.end.pos - def.loc.start.pos + count);
4940 position = def.loc.end.pos + count;
4943 // In case of detaching methods in the _class, simply rename the method
4944 if(methodAction == actionDetachMethod && moveAttached && selected == classObject && function == def.function)
4946 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4947 f.DeleteBytes(movedFuncIdLen);
4949 position = function.loc.start.pos + movedFuncIdPos + movedFuncIdLen;
4952 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && moveAttached &&
4953 function == def.function)
4955 // In case of attaching methods in the _class, simply rename the method
4956 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4957 position = function.loc.start.pos + movedFuncIdPos;
4958 f.DeleteBytes(movedFuncIdLen);
4959 if(method.dataType.thisClass)
4960 f.Printf("%s::", method.dataType.thisClass.string);
4961 f.Puts(method.name);
4962 position += movedFuncIdLen;
4967 DeleteJunkBefore(f, def.loc.start.pos, &position);
4968 if(def.type == memberAccessClassDef)
4971 firstObject = false;
4981 f.Seek(def.loc.end.pos - position, current);
4982 position = def.loc.end.pos;
4985 // Output attached methods
4986 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && !moveAttached)
4988 DeleteJunkBefore(f, position, &position);
4989 f.Printf("\n %s = %s;\n", method.name, function.declarator.symbol.string);
4992 // ********** INSTANCES ***************
4993 for(; object; object = object.next)
4995 if(!object.instCode)
4997 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
5001 DeleteJunkBefore(f, position, &position);
5003 // ****************** METHODS ***********************
5004 if(methodAction == actionDetachMethod && moveAttached && classObject == oClass)
5006 // If detaching an instance method
5007 if(selected != classObject)
5009 int newLen = strlen(methodName);
5012 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max(newLen - movedFuncIdLen,0), 0);
5013 // Tab selection left
5016 for(c = 0; text[c]; )
5019 for(i = 0; i<3 && text[c] == ' '; i++, c++);
5020 memmove(text+start, text+start+i, textSize+1-start-i);
5023 for(; text[c] && text[c] != '\n'; c++);
5029 memmove(text + movedFuncIdPos + newLen, text + movedFuncIdPos + movedFuncIdLen, textSize - movedFuncIdPos - movedFuncIdLen + 1);
5030 textSize += newLen - movedFuncIdLen;
5031 memcpy(text + movedFuncIdPos, methodName, newLen);
5038 if(methodAction == actionAddMethod && selected == classObject)
5040 Method method = this.method;
5042 if(!method.dataType)
5043 method.dataType = ProcessTypeString(method.dataTypeString, false);
5045 // ADDING METHOD HERE
5047 Type dataType = method.dataType;
5048 Type returnType = dataType.returnType;
5050 // Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
5054 OutputType(f, returnType, false);
5057 if(dataType.thisClass && !dataType.classObjectType)
5059 if(dataType.thisClass.shortName)
5060 f.Printf(dataType.thisClass.shortName);
5062 f.Printf(dataType.thisClass.string);
5065 f.Printf(method.name);
5067 for(param = dataType.params.first; param; param = param.next)
5069 OutputType(f, param, true);
5074 f.Printf(" %c\n\n", OpenBracket);
5076 if(test._class._vTbl[method.vid] == null /*moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]*/) // Temp Check for DefaultFunction
5078 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
5079 f.Printf(" return true;\n");
5080 else if(returnType && returnType.kind != voidType)
5081 f.Printf(" return 0;\n");
5086 if(returnType.kind != voidType)
5087 f.Printf("return ");
5089 char * name = ((Specifier)classDef.baseSpecs->first).name;
5090 Symbol _class = FindClass(name);
5091 f.Printf("%s::%s(", (_class && _class.registered) ? _class.registered.name : name, method.name);
5093 for(param = dataType.params.first; param; param = param.next)
5095 if(param.prev) f.Printf(", ");
5096 if(param.kind != voidType)
5097 f.Printf(param.name);
5102 f.Printf(" %c", CloseBracket);
5106 DeleteJunkBefore(f, classDef.loc.end.pos-1, &position);
5112 editBox.recordUndoEvent = false;
5120 // TOFIX: Patch for a glitch where clicking at the end of the view seems one line off. No idea what could be going on?
5121 editBox.OnVScroll(setRange, editBox.scroll.y, 0);
5125 codeModified = false;
5126 formModified = false;
5128 moveAttached = false;
5133 int FindMethod(const char * methodName /*Method method*/, ClassFunction*functionPtr, Location propLoc)
5136 ClassFunction function = null;
5139 ObjectInfo object = this.selected;
5141 if(object && object == this.oClass)
5143 ClassDefinition classDef = object.oClass.classDefinition;
5145 if(classDef && classDef.definitions)
5147 for(def = classDef.definitions->first; def; def = def.next)
5149 if(def.type == functionClassDef && def.function.declarator)
5151 if(!strcmp(def.function.declarator.symbol.string, methodName))
5153 function = def.function;
5158 else if(def.type == defaultPropertiesClassDef)
5162 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
5164 Identifier ident = propDef.identifiers ? propDef.identifiers->first : null;
5165 if(ident && !ident.next)
5167 if(!strcmp(ident.string, methodName) && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
5171 propLoc = propDef.loc;
5174 ClassDefinition classDef = object.oClass.classDefinition;
5176 if(classDef.definitions)
5178 for(def = classDef.definitions->first; def; def = def.next)
5180 if(def.type == functionClassDef)
5182 if(!strcmp(def.function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
5184 function = def.function;
5203 Instantiation inst = object.instCode;
5205 // Check here to see if the method already exists, no need to call ModifyCode in that case
5206 if(inst && inst.members)
5208 MembersInit members;
5209 for(members = inst.members->first; members; members = members.next)
5211 switch(members.type)
5213 case dataMembersInit:
5215 if(members.dataMembers)
5218 for(member = members.dataMembers->first; member; member = member.next)
5220 Identifier ident = member.identifiers ? member.identifiers->first : null;
5221 if(ident && !ident.next)
5223 if(!strcmp(ident.string, methodName) && member.initializer && member.initializer.type == expInitializer && member.initializer.exp && member.initializer.exp.type == memberExp /*ExpIdentifier*/)
5227 propLoc = member.loc;
5230 ClassDefinition classDef = object.oClass.classDefinition;
5232 if(classDef.definitions)
5234 for(def = classDef.definitions->first; def; def = def.next)
5236 if(def.type == functionClassDef)
5238 if(def.function.declarator && !strcmp(def.function.declarator.symbol.string, member.initializer.exp.identifier.string))
5240 function = def.function;
5249 // TODO: Fix memory leak
5250 function = ClassFunction
5252 declarator = Declarator { symbol = Symbol { string = CopyString(member.initializer.exp.member.member ? member.initializer.exp.member.member.string : "") } }
5264 case methodMembersInit:
5266 if(members.function.declarator && !strcmp(members.function.declarator.symbol.string, methodName))
5268 function = members.function;
5280 if(functionPtr) *functionPtr = function;
5284 void GoToMethod(const char * methodName /*Method method*/)
5288 ObjectInfo object = selected;
5289 EditBoxStream f { editBox = editBox };
5290 ClassFunction function = null;
5291 bool atChar = false;
5295 Location propLoc = { {0,0,-1} };
5298 if(FindMethod(methodName, &function, &propLoc) == 1 && object != this.oClass) indent = 9;
5299 if(function && function.body)
5302 f.Seek(function.body.loc.start.pos+1, current);
5312 f.Seek(-1, current);
5317 else if(!isspace(ch))
5319 f.Seek(-1, current);
5325 else if(propLoc.start.pos > -1)
5327 f.Seek(propLoc.start.pos, current);
5330 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
5332 if(function || propLoc.start.pos > -1)
5334 editBox.SetSelPos(l1, y1, atChar ? x1 : indent, l2, y2, atChar ? x2 : indent);
5335 editBox.CenterOnCursor();
5336 SetState(normal, false, 0);
5339 if(function && function.declarator && function.declarator.symbol && !function.declarator.symbol.type)
5341 FreeClassFunction(function);
5347 void FindCompatibleMethods(Method method, OldList compatible)
5349 ClassDefinition classDef = this.oClass.classDefinition;
5350 if(classDef && classDef.definitions)
5353 Class baseClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5356 Symbol classSym { };
5357 Symbol selectedClass;
5358 if(this.selected == this.oClass)
5359 selectedClass = classSym;
5361 selectedClass = FindClass(this.selected.instance._class.name);
5363 regClass.name = classDef._class.name;
5364 regClass.base = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5365 for(def = classDef.definitions->first; def; def = def.next)
5367 if(def.type == functionClassDef && def.function.declarator)
5369 Method vMethod = eClass_FindMethod(baseClass, def.function.declarator.symbol.string, this.privateModule);
5371 vMethod = eClass_FindMethod(this.selected.instance._class, def.function.declarator.symbol.string, this.privateModule);
5374 Type type = def.function.declarator.symbol.type;
5375 if(CheckCompatibleMethod(method, type, regClass, this.selected == this.oClass, FindClass(this.selected.instance._class.name)))
5377 compatible.Add(OldLink { data = def.function });
5383 if(this.oClass && this.oClass.instance)
5385 classSym.registered = regClass;
5386 //classSym.registered = this.oClass.oClass;
5388 for(_class = regClass.base; _class; _class = _class.base)
5391 for(testMethod = (Method)_class.methods.first; testMethod; testMethod = (Method)((BTNode)testMethod).next)
5393 // TODO: Understand why these functions popup in attach list
5394 if(testMethod.type != virtualMethod /*&& testMethod.function != Window_OnGetString && testMethod.function != Window_OnGetDataFromString*/)
5396 if(!testMethod.dataType)
5397 testMethod.dataType = ProcessTypeString(testMethod.dataTypeString, false);
5399 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5400 if(CheckCompatibleMethod(method, testMethod.dataType, this.oClass.instance._class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5401 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, this.selected == this.oClass, FindClass(this.oClass.oClass.name)))
5403 // TODO: Fix memory leak, Figure out if it should be ClassFunction or FunctionDefinition
5404 // ClassFunction function { };
5405 FunctionDefinition function { };
5407 function.declarator = Declarator { };
5408 function.declarator.symbol = Symbol { string = CopyString(testMethod.name) };
5409 excludedSymbols.Add(function.declarator.symbol);
5411 compatible.Add(OldLink { data = function });
5422 void AddMethod(Method method)
5426 char methodName[1024];
5427 strcpy(methodName, method.name);
5428 if(!FindMethod(methodName, null, null))
5430 methodAction = actionAddMethod;
5431 this.method = method;
5435 GoToMethod(methodName);
5439 void DeleteMethod(ClassFunction function)
5443 methodAction = actionDeleteMethod;
5444 this.function = function;
5452 void AttachMethod(Method method, ClassFunction function)
5456 // If it's an instance we'll ask if we want to move it inside...
5457 if(!function.attached.count && function.body)
5459 // Find the function in the _class to check if it's a virtual function
5460 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5461 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5462 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5464 for(def = this.classDefinition.first; def; def = def.next)
5466 if(def.type == functionClassDef)
5468 if(def.function == function)
5473 if(!method || method.type != virtualMethod)
5476 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5477 if(MessageBox { type = yesNo, master = parent, text = title, contents = $"Method is unused. Move method inside instance?"}.Modal() == yes)
5479 moveAttached = true;
5484 methodAction = actionAttachMethod;
5485 this.method = method;
5486 this.function = function;
5493 void ReAttachMethod(Method method, ClassFunction function)
5497 // If it's an instance we'll ask if we want to move it inside...
5498 if(!function.attached.count && function.body)
5500 // Find the function in the _class to check if it's a virtual function
5501 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5502 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5503 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5505 for(def = this.classDefinition.first; def; def = def.next)
5507 if(def.type == functionClassDef)
5509 if(def.function == function)
5514 if(!method || method.type != virtualMethod)
5517 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5518 if(MessageBox { type = yesNo, master = parent, text = title,
5519 contents = $"Method is unused. Move method inside instance?" }.Modal() == yes)
5521 moveAttached = true;
5526 methodAction = actionReattachMethod;
5527 this.method = method;
5528 this.function = function;
5535 void DetachMethod(Method method, ClassFunction function, int type)
5543 hasClose = true, borderStyle = sizable, minClientSize = { 300, 55 },
5544 master = sheet, text = $"Name detached method", background = formColor
5548 dialog, anchor = { horz = 45, top = 30 }, size = { 80 }, text = $"Cancel", hotKey = escape,
5549 id = DialogResult::cancel, NotifyClicked = ButtonCloseDialog
5553 dialog, anchor = { horz = -45, top = 30 }, size = { 80 }, text = $"OK", isDefault = true,
5554 id = DialogResult::ok, NotifyClicked = ButtonCloseDialog
5558 dialog, anchor = { left = 5, right = 5, top = 5 }
5560 sprintf(methodName, "%s_%s", selected.name, method.name);
5561 nameBox.contents = methodName;
5563 result = dialog.Modal() == ok;
5564 strcpy(methodName, nameBox.contents);
5569 // If the method is not attached, move it outside
5572 // Add this class to the methodName
5573 char name[1024] = "";
5575 if(this.selected != this.oClass && !method.dataType.thisClass)
5577 strcat(name, this.selected.instance._class.name);
5579 strcat(name, this.methodName);
5580 strcpy(this.methodName, name);
5582 else if(method.dataType.thisClass && (this.selected == this.oClass || !eClass_IsDerived(this.oClass.instance._class, method.dataType.thisClass.registered)))
5584 strcat(name, method.dataType.thisClass.string);
5586 strcat(name, this.methodName);
5587 strcpy(this.methodName, name);
5590 this.moveAttached = true;
5593 this.methodAction = actionDetachMethod;
5594 this.method = method;
5595 this.function = function;
5602 void AddObject(Instance instance, ObjectInfo * object)
5606 //*object = _class.instances.Add(sizeof(ObjectInfo));
5607 *object = ObjectInfo { };
5608 oClass.instances.Insert((selected.oClass == selected) ? null : selected, *object);
5609 (*object).oClass = oClass;
5610 (*object).instance = instance;
5615 sprintf(name, "%c%s%d", tolower(instance._class.name[0]), instance._class.name+1, id);
5617 // if(strcmp(name, this.oClass.instance.name))
5620 for(check = oClass.instances.first; check; check = check.next)
5621 if(!check.deleted && check.name && !strcmp(name, check.name))
5625 (*object).name = CopyString(name);
5630 toolBox.controlClass = null;
5634 //sheet.AddObject(*object, (*object).name, TypeData, true);
5639 void EnsureUpToDate()
5641 if(sheet && codeModified && parsing)
5645 void SelectObject(ObjectInfo object)
5648 oClass = object ? object.oClass : null;
5650 designer.SelectObject(object, object ? object.instance : null);
5653 void SelectObjectFromDesigner(ObjectInfo object)
5656 sheet.SelectObject(object);
5659 void EnumerateObjects(Sheet sheet)
5663 for(oClass = classes.first; oClass; oClass = oClass.next)
5669 sheet.AddObject(oClass, oClass.name ? oClass.name : oClass.instance._class.name, typeClass, false);
5670 for(object = oClass.instances.first; object; object = object.next)
5671 sheet.AddObject(object, object.name ? object.name : object.instance._class.name, typeData, false);
5674 sheet.SelectObject(selected);
5679 designer.AddObject();
5682 void DeleteObject(ObjectInfo object)
5684 delete object.instance;
5685 object.deleted = true;
5686 object.modified = true;
5687 object.oClass.modified = true;
5689 if(selected == object)
5691 bool looped = false;
5692 ObjectInfo select = object;
5696 select = select.prev;
5700 select = object.oClass.instances.last;
5707 sheet.SelectObject(select ? select : oClass);
5710 if(!object.instCode && object.oClass != object)
5713 oClass.instances.Delete(object);
5716 if(sheet.codeEditor == this)
5717 sheet.DeleteObject(object);
5720 void RenameObject(ObjectInfo object, const char * name)
5724 // Validate the name:
5725 if(object != oClass && (!name || !name[0])) valid = true; // What's this one again?
5726 else if(name[0] && (isalpha(name[0]) || name[0] == '_'))
5729 for(c = 0; name[c]; c++)
5730 if(!isalnum(name[c]) && name[c] != '_' && name[c] != '_')
5738 object.name = (name && name[0]) ? CopyString(name) : null;
5740 sheet.RenameObject(object, object.name ? object.name : object.instance._class.name);
5744 void DesignerModifiedObject()
5746 sheet.ListProperties(false);
5750 void ListSubMembers(Type member)
5754 for(subMember = member.members.first; subMember; subMember = subMember.next)
5758 DataRow row = membersList.AddString(subMember.name);
5759 row.icon = icons[typeData];
5763 ListSubMembers(subMember);
5768 void ListSubDataMembers(DataMember member, bool isPrivate)
5770 DataMember subMember;
5771 for(subMember = member.members.first; subMember; subMember = subMember.next)
5773 if((subMember.memberAccess == publicAccess && !isPrivate) || subMember._class.module == privateModule)
5777 DataRow row = membersList.AddString(subMember.name);
5778 BitmapResource bitmap = null;
5779 if(!subMember.dataType)
5780 subMember.dataType = ProcessTypeString(subMember.dataTypeString, false);
5782 if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
5784 char * bitmapName = (char *)(intptr)eClass_GetProperty(subMember.dataType._class.registered, "icon");
5787 bitmap = { bitmapName };
5788 membersList.AddResource(bitmap);
5791 row.icon = bitmap ? bitmap : icons[(subMember.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5795 ListSubDataMembers(subMember, isPrivate || member.memberAccess == privateAccess);
5801 void ListClassMembers(Class whatClass, bool methodsOnly)
5804 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5805 bool isPrivate = false;
5807 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5809 Method method, methodIt;
5811 DataMember memberIt;
5813 for(methodIt = (Method)_class.methods.first; methodIt; methodIt = (Method)((BTNode)methodIt).next)
5815 method = eClass_FindMethod(whatClass, methodIt.name, privateModule);
5816 if(methodIt.memberAccess == privateAccess && method && method.memberAccess == publicAccess)
5818 if(method && method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5820 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5822 DataRow row = membersList.FindString(method.name);
5825 row = membersList.AddString(method.name);
5827 if(!method.dataType)
5828 method.dataType = ProcessTypeString(method.dataTypeString, false);
5830 row.icon = icons[(method.type == virtualMethod && method.dataType && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5838 for(memberIt = _class.membersAndProperties.first; memberIt; memberIt = memberIt.next)
5842 if(memberIt.isProperty)
5844 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5846 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5850 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5852 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5855 if(memberIt.memberAccess == privateAccess && member && member.memberAccess == publicAccess)
5861 if(member && (member.memberAccess == publicAccess || member._class.module == privateModule))
5863 if(member.isProperty)
5865 Property prop = (Property) member;
5866 if(!membersList.FindString(prop.name))
5868 DataRow row = membersList.AddString(prop.name);
5869 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5872 else if(member.name && !membersList.FindString(member.name))
5874 DataRow row = membersList.AddString(member.name);
5876 BitmapResource bitmap = null;
5877 if(!member.dataType)
5878 member.dataType = ProcessTypeString(member.dataTypeString, false);
5880 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5882 char * bitmapName = (char *)(intptr)eClass_GetProperty(member.dataType._class.registered, "icon");
5885 bitmap = { bitmapName };
5886 membersList.AddResource(bitmap);
5889 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5892 ListSubDataMembers(member, member.memberAccess == privateAccess);
5896 if(_class.inheritanceAccess == privateAccess)
5899 if(_class.module != privateModule) break;
5904 void ListClassMembersMatch(Class whatClass, Type methodType)
5907 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5908 bool isPrivate = false;
5910 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5914 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5916 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5918 if(method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5920 if(!method.dataType)
5921 method.dataType = ProcessTypeString(method.dataTypeString, false);
5923 if(MatchTypes(method.dataType, methodType, null, whatClass, /*null, */whatClass, false, true, false, false, true))
5925 DataRow row = membersList.FindString(method.name);
5928 row = membersList.AddString(method.name);
5929 row.icon = icons[(method.type == virtualMethod && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5935 if(_class.inheritanceAccess == privateAccess)
5938 if(_class.module != privateModule) break;
5943 void ListClassPropertiesAndVirtual(Class whatClass, const String curString)
5946 bool isPrivate = false;
5947 for(_class = whatClass; _class /*&& _class.type != systemClass*/; _class = _class.base)
5952 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5954 if(method.type == virtualMethod)
5956 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5958 DataRow row = membersList.FindString(method.name);
5961 row = membersList.AddString(method.name);
5963 if(!method.dataType)
5964 method.dataType = ProcessTypeString(method.dataTypeString, false);
5966 row.icon = icons[method.dataType.thisClass ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5972 for(member = _class.membersAndProperties.first; member; member = member.next)
5974 if(member.memberAccess == publicAccess || member._class.module == privateModule)
5976 if(member.isProperty)
5978 Property prop = (Property)member;
5980 DataRow row = membersList.AddString(prop.name);
5981 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5984 else if(member.name && (!curString || strcmp(curString, member.name)))
5986 DataRow row = membersList.AddString(member.name);
5988 BitmapResource bitmap = null;
5989 if(!member.dataType)
5990 member.dataType = ProcessTypeString(member.dataTypeString, false);
5992 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5994 char * bitmapName = (char *)(intptr)eClass_GetProperty(member.dataType._class.registered, "icon");
5997 bitmap = { bitmapName };
5998 membersList.AddResource(bitmap);
6001 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
6004 ListSubDataMembers(member, member.memberAccess == privateAccess || isPrivate);
6007 if(_class.inheritanceAccess == privateAccess)
6010 if(_class.module != privateModule) break;
6015 void ListMembers(Type type)
6017 if(type && (type.kind == classType || type.kind == structType || type.kind == unionType))
6019 if(type.kind == classType)
6022 ListClassMembers(type._class.registered, false);
6027 for(member = type.members.first; member; member = member.next)
6031 DataRow row = membersList.AddString(member.name);
6032 row.icon = icons[typeData];
6034 else if(member.kind == structType || member.kind == unionType)
6035 ListSubMembers(member);
6041 void ListModule(Module mainModule, int recurse, bool listClasses)
6044 ListNameSpace(mainModule.application.systemNameSpace, 1, listClasses);
6045 ListNameSpace(mainModule.application.privateNameSpace, 1, listClasses);
6046 ListNameSpace(mainModule.application.publicNameSpace, 1, listClasses);
6047 for(module = mainModule.application.allModules.first; module; module = module.next)
6049 if(ModuleVisibility(mainModule, module))
6050 ListNameSpace(module.publicNameSpace, recurse, listClasses);
6054 void ListNameSpace(NameSpace nameSpace, int recurse, bool listClasses)
6061 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
6063 Class _class = link.data;
6064 if(_class.type != systemClass && !_class.templateClass) // Omit templatized classes
6066 DataRow row = membersList.AddString(_class.name);
6067 row.icon = (_class.type == unitClass || _class.type == enumClass) ? icons[typeDataType] : icons[typeClass];
6072 for(link = (BTNamedLink)nameSpace.defines.first; link; link = (BTNamedLink)((BTNode)link).next )
6074 //DefinedExpression definedExp = link.data;
6075 DataRow row = membersList.AddString(link /*definedExp*/.name);
6076 row.icon = icons[typeData];
6079 for(link = (BTNamedLink)nameSpace.functions.first; link; link = (BTNamedLink)((BTNode)link).next)
6081 //GlobalFunction function = link.data;
6082 DataRow row = membersList.AddString(link /*function*/.name);
6083 row.icon = icons[typeMethod];
6087 for(ns = (NameSpace *)nameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
6089 if(recurse != 2 && listClasses)
6091 if(!membersList.FindString(ns->name))
6093 DataRow row = membersList.AddString(ns->name);
6094 row.icon = icons[typeNameSpace];
6099 ListNameSpace(ns, 2, listClasses);
6103 void ListEnumValues(Class _class)
6105 List<Class> classes { };
6106 for(; _class && _class.type == enumClass; _class = _class.base)
6107 classes.Insert(null, _class);
6108 for(_class : classes)
6110 EnumClassData enumeration = (EnumClassData)_class.data;
6112 for(item = enumeration.values.first; item; item = item.next)
6114 DataRow row = membersList.AddString(item.name);
6115 row.icon = icons[typeEnumValue];
6121 bool ListEnumsModule(Module mainModule, Type dest)
6123 bool result = false;
6125 result |= ListEnums(mainModule.application.systemNameSpace, dest);
6126 result |= ListEnums(mainModule.application.privateNameSpace, dest);
6127 result |= ListEnums(mainModule.application.publicNameSpace, dest);
6128 for(module = mainModule.application.allModules.first; module; module = module.next)
6130 if(ModuleVisibility(mainModule, module))
6131 result |= ListEnums(module.publicNameSpace, dest);
6136 void ListNameSpaceByString(Module mainModule, const char * string)
6138 NameSpace * nameSpace;
6140 nameSpace = FindNameSpace(mainModule.application.systemNameSpace, string);
6141 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6142 nameSpace = FindNameSpace(mainModule.application.privateNameSpace, string);
6143 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6144 nameSpace = FindNameSpace(mainModule.application.publicNameSpace, string);
6145 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6146 for(module = mainModule.application.allModules.first; module; module = module.next)
6148 if(ModuleVisibility(mainModule, module))
6150 nameSpace = FindNameSpace(module.publicNameSpace, string);
6151 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6156 bool ListEnums(NameSpace nameSpace, Type dest)
6159 bool result = false;
6161 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
6163 Class _class = link.data;
6164 if(_class.type == enumClass && (dest.kind != classType || ((!dest._class || !dest._class.registered || (dest._class.registered != _class && strcmp(dest._class.registered.dataTypeString, "char *") && strcmp(dest._class.string, "bool"))) && !dest.classObjectType)) &&
6165 dest.kind != pointerType && dest.kind != ellipsisType)
6167 OldList conversions { };
6169 type.kind = classType;
6170 type._class = FindClass(_class.name);
6171 if(MatchTypes(type, dest, &conversions, null, null, true, false, false, false, true))
6173 ListEnumValues(_class);
6176 conversions.Free(null);
6180 for(nameSpace = (NameSpace *)nameSpace.nameSpaces.first; nameSpace != null; nameSpace = (NameSpace *)((BTNode)nameSpace).next)
6182 result |= ListEnums(nameSpace, dest);
6187 NameSpace * FindNameSpace(NameSpace nameSpace, const char * name)
6191 for(c = 0; (ch = name[c]); c++)
6193 if(ch == '.' || (ch == ':' && name[c+1] == ':'))
6195 NameSpace * newSpace;
6196 char * spaceName = new char[c - start + 1];
6197 memcpy(spaceName, name + start, c - start);
6198 spaceName[c-start] = '\0';
6199 newSpace = (NameSpace *)nameSpace.nameSpaces.FindString(spaceName);
6203 nameSpace = newSpace;
6212 return (NameSpace *)nameSpace;
6215 void ListSymbols(Expression exp, bool enumOnly, const char * string, Identifier realIdentifier)
6217 bool listedEnums = false;
6218 Type destType = (exp && exp.destType && !exp.destType.truth) ? exp.destType : null;
6219 bool listClasses = true;
6221 if(exp && (exp.type == identifierExp || exp.type == memberExp))
6223 // TOCHECK: This memberExp check wasn't here... Some stuff isn't quite done
6224 Identifier id = (exp.type == memberExp) ? exp.member.member : exp.identifier;
6225 char * colons = id ? RSearchString(id.string, "::", strlen(id.string), true, false) : null;
6227 if(exp.type == identifierExp)
6228 id = realIdentifier;
6230 if(id && id._class && !id._class.name)
6232 listClasses = false;
6235 else if(id && id._class && id._class.name)
6239 Class _class = id.classSym.registered;
6240 if(_class && _class.type == enumClass)
6242 ListEnumValues(_class);
6245 ListClassMembers(id.classSym.registered, true);
6250 else if(id && colons)
6252 ListNameSpaceByString(this.privateModule, id.string);
6257 if(this.privateModule && destType && (destType.kind == _BoolType || destType.kind == classType || destType.kind == enumType || destType.kind == structType || destType.kind == templateType || destType.kind == thisClassType || destType.kind == unionType ||
6258 (destType.kind == pointerType && destType.type.kind != voidType)))
6259 //if(this.privateModule && destType && (destType.kind != pointerType || destType.type.kind != voidType) && destType.kind != ellipsisType)
6261 listedEnums = ListEnumsModule(this.privateModule, destType);
6264 if(destType && destType.kind == classType && destType._class.registered && destType._class.registered.type == enumClass)
6266 ListEnumValues(destType._class.registered);
6269 ListClassPropertiesAndVirtual(insideClass, null);
6273 else if(destType && destType.kind == enumType)
6277 for(value = destType.members.first; value; value = value.next)
6279 DataRow row = membersList.AddString(value.name);
6280 row.icon = icons[typeEnumValue];
6284 ListClassPropertiesAndVirtual(insideClass, null);
6288 else if(insideClass && !enumOnly)
6290 ListClassPropertiesAndVirtual(insideClass, string);
6293 if(listedEnums && string && string[0])
6295 DataRow row = membersList.FindSubString(string);
6297 listedEnums = false;
6300 if(!insideClass && exp && exp.destType && exp.destType.kind == functionType && GetThisClass())
6302 ListClassMembersMatch(GetThisClass(), exp.destType);
6304 else if(!insideClass && !enumOnly && !listedEnums)
6307 Symbol symbol = null;
6311 ListClassMembers(GetThisClass(), false);
6314 for(ctx = listClasses ? GetCurrentContext() : GetTopContext(); ctx != GetTopContext().parent && !symbol; ctx = ctx.parent)
6316 for(symbol = (Symbol)ctx.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6318 // Don't list enum values?
6319 //if(symbol.type.kind != TypeEnum)
6320 DataRow row = membersList.FindString(symbol.string);
6323 if(GetBuildingEcereComModule() && symbol.type && symbol.type.kind == functionType && eSystem_FindFunction(privateModule, symbol.string))
6325 row = membersList.AddString(symbol.string);
6326 if(symbol.type && symbol.type.kind == functionType)
6327 row.icon = icons[typeMethod];
6328 else if(symbol.type && symbol.type.kind == enumType)
6330 row.icon = icons[typeEnumValue];
6334 BitmapResource bitmap = null;
6335 if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
6337 char * bitmapName = (char *)(intptr)eClass_GetProperty(symbol.type._class.registered, "icon");
6340 bitmap = { bitmapName };
6341 membersList.AddResource(bitmap);
6344 row.icon = bitmap ? bitmap : icons[typeData];
6351 for(symbol = (Symbol)ctx.types.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6353 DataRow row = membersList.FindString(symbol.string);
6356 row = membersList.AddString(symbol.string);
6357 if(symbol.type.kind == functionType)
6358 row.icon = icons[typeMethod];
6359 else if(symbol.type.kind == classType && (!symbol.type._class.registered || (symbol.type._class.registered.type != unitClass && symbol.type._class.registered.type != enumClass)))
6361 row.icon = icons[typeClass];
6365 row.icon = icons[typeDataType];
6372 ListModule(this.privateModule, 1, listClasses);
6373 // TODO: Implement this with name space
6377 for(data = globalData.first; data; data = data.next)
6379 DataRow row = membersList.FindString(data.name);
6381 data.dataType = ProcessTypeString(data.dataTypeString, false);
6384 row = membersList.AddString(data.name);
6386 if(data.dataType && data.dataType.kind == TypeEnum)
6388 row.icon = icons[typeEnumValue];
6392 BitmapResource bitmap = null;
6393 if(data.dataType && data.dataType.kind == classType && data.dataType._class && data.dataType._class)
6395 char * bitmapName = (char *)eClass_GetProperty(data.dataType._class.registered, "icon");
6398 bitmap = { bitmapName };
6399 membersList.AddResource(bitmap);
6402 row.icon = bitmap ? bitmap : icons[typeData];
6410 DataRow row = membersList.AddString("Min");
6411 row.icon = icons[typeMethod];
6413 row = membersList.AddString("Max");
6414 row.icon = icons[typeMethod];
6416 row = membersList.AddString("Abs");
6417 row.icon = icons[typeMethod];
6419 row = membersList.AddString("Sgn");
6420 row.icon = icons[typeMethod];
6426 void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
6428 EditBoxStream f { editBox = editBox };
6433 updatingCode = true;
6435 if(!method.dataType)
6436 method.dataType = ProcessTypeString(method.dataTypeString, false);
6438 DeleteJunkBefore(f, function.loc.start.pos, &position);
6439 f.DeleteBytes(function.loc.end.pos - function.loc.start.pos - 1);
6441 // ADDING METHOD HERE
6443 Type dataType = method.dataType;
6444 Type returnType = dataType.returnType;
6446 // Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
6452 if(extraIndent) f.Printf(" ");
6454 OutputType(f, returnType, false);
6458 if(dataType.thisClass && !dataType.classObjectType && (!isInstance || !insideClass || !eClass_IsDerived(insideClass, dataType.thisClass.registered)))
6460 if(dataType.thisClass.shortName)
6461 f.Printf(dataType.thisClass.shortName);
6463 f.Printf(dataType.thisClass.string);
6466 f.Printf(method.name);
6468 for(param = dataType.params.first; param; param = param.next)
6470 // Decided not to write void...
6471 if(param.kind != voidType)
6473 OutputType(f, param, true);
6479 if(extraIndent) f.Printf(" ");
6480 f.Printf(" %c\n", OpenBracket);
6482 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6488 (isInstance ? _class : _class.base)._vTbl[method.vid] == null /*moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]*/ ||
6489 (isInstance ? _class : _class.base)._vTbl[method.vid] == DummyMethod)) // Temp Check for DefaultFunction
6491 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
6493 if(extraIndent) f.Printf(" ");
6494 f.Printf(" return true;\n");
6496 else if(returnType && returnType.kind != voidType)
6498 if(extraIndent) f.Printf(" ");
6499 f.Printf(" return 0;\n");
6504 if(extraIndent) f.Printf(" ");
6506 if(returnType.kind != voidType)
6507 f.Printf("return ");
6508 f.Printf("%s::%s(", isInstance ? _class.name : _class.base.name, method.name);
6509 for(param = dataType.params.first; param; param = param.next)
6511 if(param.prev) f.Printf(", ");
6512 if(param.kind != voidType)
6513 f.Printf(param.name);
6519 if(extraIndent) f.Printf(" ");
6520 f.Printf(" %c", CloseBracket);
6525 if(extraIndent) { x1 += 3; x2 += 3; }
6526 editBox.SetSelPos(l1, y1, x1 + 6, l2, y2, x2 + 6);
6528 this.updatingCode = false;
6532 // Return false if we overrided a function and don't want to run params listing
6533 bool InvokeAutoComplete(bool enumOnly, int pointer, bool caretMove)
6535 bool didOverride = false;
6536 EditLine line = editBox.line;
6537 int lineNum, charPos;
6538 Expression exp = null;
6541 //Identifier id = null;
6542 Expression memberExp = null;
6543 Identifier realIdentifier = null;
6545 if(!parsing) return true;
6546 if(!privateModule) return !didOverride;
6548 insideFunction = null;
6550 charPos = editBox.charPos + 1;
6551 if(!membersListShown)
6556 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6558 EditBoxStream f { editBox = editBox };
6560 updatingCode = true;
6561 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6565 if(!f.Seek(-1, current))
6568 if(!isspace(ch)) break;
6569 f.Seek(-1, current);
6571 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6573 lineNum = editBox.lineNumber + 1;
6574 charPos = editBox.charPos + 1;
6576 updatingCode = false;
6579 if(!membersListShown)
6581 memberExp = FindExpTree(ast, lineNum, charPos);
6582 if(memberExp && (memberExp.type == TypeKind::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6587 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6589 EditBoxStream f { editBox = editBox };
6592 updatingCode = true;
6594 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6597 if(ch == '}' || ch == ',' || ch == ')')
6599 f.Seek(-1, current);
6607 if(!f.Seek(-1, current))
6610 if(!isspace(ch)) break;
6611 f.Seek(-1, current);
6615 f.Seek(-1, current);
6617 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6619 lineNum = editBox.lineNumber + 1;
6620 charPos = editBox.charPos + 1;
6622 updatingCode = false;
6625 realIdentifier = FindCtxTree(ast, lineNum, charPos);
6630 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6631 lineNum = editBox.lineNumber + 1;
6632 charPos = editBox.charPos/* + 1*/;
6636 char tempString[1024];
6637 char * string = null;
6638 CodePosition idStart { };
6639 CodePosition idEnd { };
6641 if(membersListShown)
6643 const char * buffer = membersLine.text;
6645 bool firstChar = true;
6647 string = tempString;
6649 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
6651 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6652 if(!isSpace) firstChar = false;
6654 string[len++] = buffer[c];
6658 else //if(realIdentifier)//if(id)
6661 char * buffer = id.string;
6663 bool firstChar = true;
6665 string = tempString;
6666 for(c = 0; c<= charPos - id.loc.start.charPos; c++)
6668 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6669 if(!isSpace) firstChar = false;
6671 string[len++] = buffer[c];
6677 EditLine editLine = editBox.line;
6678 bool firstChar = true;
6681 string = tempString;
6682 for(y = lineNum-1; y >= 0; y--)
6684 const char * buffer = editLine.text;
6685 int lineCount = editLine.count;
6686 for(x = (y == lineNum-1) ? (Min(charPos, lineCount) - 1 ): lineCount-1; x >= 0; x--)
6688 bool isSpace = (buffer[x] == ' ' || buffer[x] == '\t');
6693 idEnd.charPos = x + 2;
6698 // TESTING THIS CODE HERE FOR NOT CONSIDERING bool when doing ctrl-space past it
6701 idEnd.charPos = x + 2;
6708 if(!isalnum(buffer[x]) && buffer[x] != '_')
6714 memmove(string+1, string, len++);
6715 string[0] = buffer[x];
6719 //if(done || firstChar)
6720 if(done || !firstChar)
6722 editLine = editLine.prev;
6725 if(!strcmp(string, "case"))
6731 else if(!strcmp(string, "return"))
6737 else if(!strcmp(string, "delete"))
6743 else if(!strcmp(string, "new"))
6749 else if(!strcmp(string, "renew"))
6757 idStart.charPos = x + 1;
6758 idStart.line = y + 1;
6761 if(!membersListShown)
6763 membersList.Clear();
6764 if(memberExp && (memberExp.type == ExpressionType::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6766 Type type = memberExp.member.exp.expType;
6767 if(pointer == 2 && type)
6769 if(type.kind == pointerType || type.kind == arrayType)
6778 ListSymbols(exp, enumOnly, string, realIdentifier);
6780 membersList.Sort(null, 1);
6785 // Virtual function override
6786 Identifier id = GetDeclId(insideFunction.declarator);
6787 char * string = id ? id.string : null;
6789 Method method = eClass_FindMethod(GetThisClass(), string, this.privateModule);
6792 if(method.type != virtualMethod || (!insideInstance && method._class == GetThisClass()))
6793 insideFunction = null;
6796 OverrideVirtualFunction(insideFunction, method, GetThisClass(), insideInstance, insideInstance && insideClass);
6801 if(!didOverride) //insideFunction)
6803 rowCount = membersList.rowCount;
6806 DataRow row = string ? membersList.FindSubString(string) : null;
6807 if(row && !membersList.FindSubStringAfter(row, string) && !caretMove)
6809 const char * newString = row.string;
6810 if(!membersListShown)
6812 membersLoc.start.line = idStart.line-1;
6813 membersLoc.start.charPos = idStart.charPos-1;
6814 //membersLoc.end = membersLoc.start;
6815 membersLoc.end.charPos = idEnd.charPos-1;
6816 membersLoc.end.line = idEnd.line-1;
6817 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6818 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6823 membersList.Destroy(0);
6824 membersListShown = false;
6827 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
6829 line, membersLoc.start.line, membersLoc.start.charPos,
6830 line, membersLoc.end.line, membersLoc.end.charPos);
6831 editBox.PutS(newString);
6837 row = membersList.FindSubStringi(string);
6839 membersList.currentRow = row;
6840 membersList.currentRow.selected = false;
6843 membersList.currentRow = row;
6845 if(!membersListShown)
6849 // TESTING THESE ADDITIONS TO THE IF SO THAT CARET ISNT MOVED IF NOT ON TOP OF A WORD
6850 if(string && string[0] && lineNum == idStart.line && charPos >= idStart.charPos-1 && charPos <= idEnd.charPos-1)
6851 editBox.SetSelPos(l1, y1, idStart.charPos-1, l2, y2, idStart.charPos-1);
6852 editBox.GetCaretPosition(caret);
6853 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6855 membersList.master = this;
6857 caret.y += editBox.GetCaretSize();
6859 membersList.Create();
6862 int x = caret.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6863 int y = caret.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6864 Window parent = membersList.parent;
6866 if(!paramsAbove && (paramsShown || y + membersList.size.h > parent.clientSize.h))
6868 y -= editBox.GetCaretSize() + membersList.size.h;
6869 membersAbove = true;
6872 membersAbove = false;
6874 membersList.position = { x, y };
6878 membersLoc.start.line = lineNum - 1;
6880 if(string && string[0])
6882 membersLoc.start.charPos = idStart.charPos-1;
6883 membersLoc.end = membersLoc.start;
6884 //membersLoc.end.charPos = id.loc.end.charPos-1;
6885 membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6889 membersLoc.start.charPos = charPos;
6890 membersLoc.end = membersLoc.start;
6891 membersLoc.end.charPos = charPos;
6893 membersListShown = true;
6895 // Hack to keep caret shown
6896 editBox.GetCaretPosition(caret);
6897 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6900 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
6906 SetCurrentContext(globalContext);
6909 return !didOverride;
6912 void InvokeParameters(bool exact, bool reposition, bool caretMove)
6914 int lineNum, charPos;
6918 if(!parsing) return;
6920 charPos = editBox.charPos + 1;
6923 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6925 EditBoxStream f { editBox = editBox };
6928 updatingCode = true;
6929 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6932 if(ch == '}' || ch == ',' || ch == ')')
6934 f.Seek(-1, current);
6942 if(!f.Seek(-1, current))
6945 if(!isspace(ch)) break;
6946 f.Seek(-1, current);
6950 f.Seek(-1, current);
6952 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6954 lineNum = editBox.lineNumber + 1;
6955 charPos = editBox.charPos + 1;
6957 updatingCode = false;
6960 charPos = Min(charPos, l1.count + 1);
6962 FindParamsTree(ast, lineNum, charPos);
6964 // Not sure about this == ExpCall... paramsInsideExp doesn't seem to necessarily be a ExpCall
6965 if(exact && ((::functionType && paramsInsideExp.type == callExp && paramsInsideExp.call.exp.loc.end.charPos != charPos-1) /*|| instanceType*/))
6967 ::functionType = null;
6968 ::instanceType = null;
6971 //if((::functionType || ::instanceType) && (!paramsShown || insideExp != functionExp || ::paramsID != this.paramsID))
6972 if((::functionType || ::instanceType) && (!paramsShown || true /*paramsInsideExp.destType != functionExp.destType */|| ::paramsID != this.paramsID))
6976 Window parent = paramsList.parent;
6978 if(this.functionType != ::functionType || this.instanceType != ::instanceType)
6981 if(!this.paramsShown || reposition || paramsInsideExp != functionExp || ::instanceType) // Added instanceType here, otherwise instance popups never reposition...
6982 // ( Dummy exp: always ends up with same memory)
6984 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6985 editBox.GetCaretPosition(paramsPosition);
6986 this.paramsPosition.y += editBox.GetCaretSize();
6989 FreeType(this.functionType);
6990 FreeType(this.instanceType);
6992 this.functionType = ::functionType;
6993 this.instanceType = ::instanceType;
6995 if(this.functionType) this.functionType.refCount++;
6996 if(this.instanceType) this.instanceType.refCount++;
6998 this.paramsID = ::paramsID;
6999 functionExp = paramsInsideExp;
7001 paramsList.master = this;
7003 paramsList.Create();
7005 x = paramsPosition.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
7006 y = paramsPosition.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
7008 if(!this.membersAbove && ( this.membersListShown || y + paramsList.size.h > parent.clientSize.h) )
7010 y -= editBox.GetCaretSize() + paramsList.clientSize.h;
7014 paramsAbove = false;
7015 if(x + paramsList.size.w > parent.clientSize.w)
7017 x = parent.clientSize.w - paramsList.size.w;
7021 paramsList.position = { x, y };
7023 // Hack to keep caret shown
7026 editBox.GetCaretPosition(caret);
7027 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
7030 this.paramsShown = true;
7032 else if((!::functionType && !::instanceType) || reposition)
7034 paramsList.Destroy(0);
7035 paramsShown = false;
7037 FreeType(this.functionType);
7038 FreeType(this.instanceType);
7039 this.functionType = null;
7040 this.instanceType = null;
7044 SetCurrentContext(globalContext);
7052 designer.visible = true;
7053 designer.Activate();
7058 Array<int> GetHighlightLines()
7060 Array<int> lines { };
7061 Map<int, bool> map { };
7062 MapNode<int, bool> mn;
7063 Debugger debugger = ide.debugger;
7064 map[editBox.lineNumber + 1] = true;
7065 if(editBox.syntaxHighlighting && fileName && ide.projectView)
7067 bool error, breakpointEnabled[128];
7068 int count, lineCursor, lineTopFrame, breakpointLines[128];
7069 count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
7073 map[lineCursor] = true;
7075 map[lineTopFrame] = true;
7079 for(i = 0; i < count; i++)
7080 map[breakpointLines[i]] = true;
7083 for(mn = map.root.minimum; mn; mn = mn.next)
7090 CodeEditor NewCodeEditor(Window parent, WindowState state, bool modified)
7092 CodeEditor document { state = state, parent = parent, modifiedDocument = modified };
7097 static int nofdigits(int v)
7099 if(v == MININT) return 10 + 1;
7100 if(v < 0) return nofdigits(-v) + 1;