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
35 FontResource panelFont { "Courier New", 10 };
36 FontResource codeFont { "Courier New", 10 };
38 FontResource panelFont { "Consolas", 10.5f };
39 FontResource codeFont { "Consolas", 10.5f };
41 Color selectionColor = lightYellow;
42 Color selectionText = Color { 30, 40, 50 };
43 Color viewsBackground = Color { 30, 40, 50 };
44 Color viewsText = lightGray;
45 Color outputBackground = black;
46 Color outputText = lime;
47 Color projectViewBackground = Color { 30, 40, 50 };
48 Color projectViewText = lightGray;
49 Color codeEditorBG = black;
50 Color codeEditorFG = ivory;
51 Color marginColor = Color {24, 24, 24};
52 Color selectedMarginColor = Color {64, 64, 64};
53 Color lineNumbersColor = Color {160, 160, 160};
54 SyntaxColorScheme colorScheme
56 keywordColors = [ skyBlue, skyBlue ];
57 commentColor = Color { 125, 125, 125 };
58 charLiteralColor = Color { 245, 50, 245 };
59 stringLiteralColor = Color { 245, 50, 245 };
60 preprocessorColor = { 120, 220, 140 };
61 numberColor = Color { 0, 192, 192 };
64 // *********************
70 // UNTIL IMPLEMENTED IN GRAMMAR
71 #define ACCESS_CLASSDATA(_class, baseClass) \
72 (_class ? ((void *)(((char *)_class.data) + baseClass.offsetClass)) : null)
75 extern int __attribute__((__stdcall__)) __ecereDll_Load_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
76 extern int __attribute__((__stdcall__)) __ecereDll_Unload_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
79 static Array<FileFilter> fileFilters
81 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
82 { $"Header Files for C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
83 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
84 { $"Text files (*.txt)", "txt" },
85 { $"All files", null }
88 static Array<FileType> fileTypes
90 { $"eC Source Code", "ec", whenNoneGiven },
91 { $"Text Files", "txt", never }
94 static char * iconNames[] =
96 "<:ecere>constructs/class.png",
97 "<:ecere>constructs/data.png",
98 "<:ecere>constructs/method.png",
99 "<:ecere>constructs/event.png",
100 "<:ecere>constructs/property.png",
101 "<:ecere>constructs/namespace.png",
102 "<:ecere>constructs/dataType.png",
103 "<:ecere>constructs/enumValue.png",
104 "<:ecere>constructs/dataPrivate.png",
105 "<:ecere>constructs/methodPrivate.png",
106 "<:ecere>constructs/propertyPrivate.png"
109 enum SheetType { methods, properties };
111 extern int __ecereVMethodID_class_OnEdit;
112 extern int __ecereVMethodID_class_OnDisplay;
113 extern int __ecereVMethodID_class_OnGetString;
114 extern int __ecereVMethodID_class_OnFree;
115 extern int __ecereVMethodID_class_OnCompare;
116 extern int __ecereVMethodID_class_OnCopy;
117 extern int __ecereVMethodID_class_OnSaveEdit;
118 extern int __ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad;
120 class EditFileDialog : FileDialog
124 if(!ide.projectView && ideSettings.ideFileDialogLocation)
125 currentDirectory = ideSettings.ideFileDialogLocation;
126 return FileDialog::OnCreate();
130 EditFileDialog codeEditorFileDialog
132 type = multiOpen, text = $"Open",
133 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType);
134 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
137 EditFileDialog codeEditorFormFileDialog
139 type = open, text = $"Open Project",
140 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType),
141 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
144 define OpenBracket = '{';
145 define CloseBracket = '}';
150 actionDeleteMethod = 2,
151 actionDetachMethod = 3,
152 actionAttachMethod = 4,
153 actionReattachMethod = 5
156 //extern StatusField pos, ovr, caps, num;
157 //extern Class thisClass;
163 bool parseError = false;
168 Expression ctxInsideExp;
169 Expression paramsInsideExp;
170 ClassFunction insideFunction;
178 /****************************************************************************
180 ****************************************************************************/
182 static void OutputString(File f, char * string)
185 for(c = 0; string[c]; c++)
187 if(string[c] == '\"')
189 else if(string[c] == '\\')
196 void OutputType(File f, Type type, bool outputName)
206 if(!type.isSigned) f.Printf("unsigned ");
210 if(!type.isSigned) f.Printf("unsigned ");
214 if(!type.isSigned) f.Printf("unsigned ");
218 if(!type.isSigned) f.Printf("unsigned ");
222 if(!type.isSigned) f.Printf("unsigned ");
232 // ADD CODE TO DECIDE WHETHER TO OUTPUT FULLY QUAlIFIED OR NOT:
233 f.Printf(type._class.shortName ? type._class.shortName : type._class.string);
242 OutputType(f, type.type, false);
245 OutputType(f, type.type, false);
264 if(type.kind == arrayType)
267 f.Printf("%d", type.arraySize);
273 void DeleteJunkBefore(EditBoxStream f, int pos, int * position)
279 f.Seek(pos - *position, current);
281 // Try to delete spaces and \n before...
287 /*else if(ch == '\n')
289 // Look for // comments on the line before
290 EditBox editBox = f.editBox;
291 EditLine line = editBox.line;
298 for(c = 0; text[c]; c++)
307 if(text[c] == '/' && last == '/')
319 f.DeleteBytes(before);
324 void GetLocText(EditBox editBox, File f, int position, Location loc, char ** text, int * size, int pad, int linePad)
329 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
331 // Cut & Paste function
337 f.Seek(loc.start.pos - position, current);
339 x1 = editBox.charPos;
340 y1 = editBox.lineNumber;
341 f.Seek(loc.end.pos - loc.start.pos, current);
343 x2 = editBox.charPos;
344 y2 = editBox.lineNumber;
345 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
347 *size = editBox.SelSize();
348 *text = new char[*size+1 + (y2-y1+1) * linePad + pad]; // Add pad for tabs and new name
349 editBox.GetSel(*text, false);
352 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
353 f.Printf(""); // Make the stream point to where the editbox is
356 void Code_FixProperty(Property prop, Instance object)
358 Designer::FixProperty(prop, object);
361 bool Code_IsPropertyModified(Instance test, ObjectInfo selected, Property prop)
364 if(prop.dataTypeString && (!prop.IsSet || prop.IsSet(selected.instance)))
366 Class dataType = prop.dataTypeClass;
367 char string[1024] = "";
370 dataType = prop.dataTypeClass = eSystem_FindClass(test._class.module, prop.dataTypeString);
372 if(dataType && dataType._vTbl && dataType.type == structClass)
374 void * dataForm = new0 byte[dataType.structSize];
375 void * dataTest = new0 byte[dataType.structSize];
377 prop.Get(selected.instance, dataForm);
378 prop.Get(test, dataTest);
380 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
382 prop.Set(test, dataForm);
388 else if(dataType && dataType._vTbl && (dataType.type == normalClass || dataType.type == noHeadClass))
390 void * dataForm, * dataTest;
392 dataForm = (void *)prop.Get(selected.instance);
393 dataTest = (void *)prop.Get(test);
395 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
397 prop.Set(test, dataForm);
401 else if(dataType && dataType._vTbl)
403 DataValue dataForm, dataTest;
405 GetProperty(prop, selected.instance, &dataForm);
406 GetProperty(prop, test, &dataTest);
408 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
410 SetProperty(prop, test, dataForm);
412 // In case setting on test unset on real instance (e.g. isDefault)
413 if(strcmp(prop.name, "name"))
415 GetProperty(prop, selected.instance, &dataTest);
416 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
417 SetProperty(prop, selected.instance, dataForm);
426 bool Code_IsPropertyDisabled(ObjectInfo selected, char * name)
428 bool disabled = false;
429 if(selected.oClass == selected)
432 if(selected.classDefinition)
434 for(def = selected.classDefinition.definitions->first; def; def = def.next)
436 if(def.type == defaultPropertiesClassDef)
439 for(prop = def.defProperties->first; prop; prop = prop.next)
441 if(prop.identifiers && prop.identifiers->first)
443 Identifier id = prop.identifiers->first;
444 if(prop.variable && !strcmp(id.string, name))
456 else if(selected.instCode)
459 if(selected.instCode.members)
461 for(members = selected.instCode.members->first; members; members = members.next)
463 if(members.type == dataMembersInit && members.dataMembers)
466 for(prop = members.dataMembers->first; prop; prop = prop.next)
468 if(prop.identifiers && prop.identifiers->first)
470 Identifier id = prop.identifiers->first;
471 if(prop.variable && !strcmp(id.string, name))
486 static bool CheckCompatibleMethod(Method method, Type type, Class regClass, bool isForm, Symbol selectedClass)
491 method.dataType = ProcessTypeString(method.dataTypeString, false);
492 if(!method.dataType.thisClass && !isForm)
495 method.dataType.thisClass = selectedClass;
497 //result = MatchTypes(method.dataType, type, null, regClass, regClass, false);
498 result = MatchTypes(type, method.dataType, null, regClass, regClass, false, true, true, false);
500 method.dataType.thisClass = null;
504 bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo object)
506 bool confirmation = true;
507 Statement body = function.body;
508 // Check if it contains any code
509 if((!body.compound.declarations || !body.compound.declarations->count) && (!body.compound.statements || body.compound.statements->count <= 1))
511 Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
512 Statement stmt = body.compound.statements ? body.compound.statements->first : null;
513 Type dataType = method.dataType;
514 Type returnType = dataType.returnType;
515 Expression exp = null;
518 method.dataType = ProcessTypeString(method.dataTypeString, false);
520 confirmation = false;
522 // Check if default function should be calling base class:
523 if(object.instance._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
525 if(returnType.kind != voidType)
527 if(!stmt || stmt.type != returnStmt || !stmt.expressions || stmt.expressions->count != 1)
531 exp = stmt.expressions->first;
532 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
534 if( (exp.type != identifierExp || strcmp(exp.identifier.string, "true")) &&
535 (exp.type != constantExp || strcmp(exp.constant, "1")))
540 if(exp.type != constantExp || strcmp(exp.constant, "0"))
555 if(returnType.kind != voidType)
557 if(stmt.type == returnStmt && stmt.expressions && stmt.expressions->count == 1)
558 exp = stmt.expressions->first;
560 else if(stmt.type == expressionStmt && stmt.expressions && stmt.expressions->count == 1)
561 exp = stmt.expressions->first;
564 if(!exp || exp.type != callExp || exp.call.exp.type != identifierExp)
568 Identifier id = exp.call.exp.identifier;
569 Class base = object.instance._class;
570 if(!id._class || (id._class.name && !strcmp(id._class.name, base.name)) || strcmp(id.string, method.name))
574 Expression arg = exp.call.arguments ? exp.call.arguments->first : null;
575 if(!arg || arg.type != identifierExp || strcmp("this", arg.identifier.string))
581 for(param = dataType.params.first; param; param = param.next)
583 if(!arg || arg.type != identifierExp || strcmp(param.name, arg.identifier.string))
588 arg = arg ?arg.next : null;
595 return !confirmation;
598 class CodeEditor : Window
600 background = marginColor;
601 borderStyle = sizableDeep;
606 isActiveClient = true;
607 anchor = Anchor { left = 300, right = 150, top = 0, bottom = 0 };
610 // eWindow_SetX(A_CASCADE); eWindow_SetY(A_CASCADE);
611 // eWindow_SetWidth(A_RELATIVE|80); eWindow_SetHeight(A_RELATIVE|80);
613 SheetType sheetSelected;
618 Context globalContext { };
619 OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
632 MethodAction methodAction;
634 ClassFunction function;
636 char methodName[1024];
640 bool membersListShown;
643 EditLine membersLine;
645 Type functionType, instanceType;
649 Point paramsPosition;
650 Expression functionExp;
653 BitmapResource icons[CodeObjectType];
655 FontResource boldFont { "Tahoma", 8.25f, bold = true, window = this };
656 FontResource normalFont { "Tahoma", 8.25f, window = this };
658 Module privateModule;
659 NameSpace globalData;
662 OpenedFileInfo openedFileInfo;
664 FontResource font { codeFont.faceName, codeFont.size };
665 saveDialog = codeEditorFileDialog;
667 Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
669 void ProcessCaretMove(EditBox editBox, int line, int charPos)
672 ObjectInfo classItem;
674 // OnActivateClient is called after OnActivate
677 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
680 if(sheet.codeEditor != this) return;
684 for(classItem = classes.first; classItem; classItem = classItem.next)
686 ClassDefinition classDef = classItem.classDefinition;
687 if(classDef && classDef.loc.Inside(line, charPos))
694 for(object = classItem.instances.first; object; object = object.next)
698 if(object.instCode.loc.Inside(line, charPos))
703 sheet.SelectObject(object);
705 sheet.SelectObject(classItem);
710 //sheet.SelectObject(null);
714 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
718 expectingMove = false;
724 if(line-1 != membersLoc.start.line)
728 char * buffer = membersLine.text;
731 if(charPos - 1 < membersLoc.start.charPos)
733 else if(charPos - 1 > membersLoc.end.charPos)
735 char * buffer = membersLine.text;
736 //if(membersList.currentRow)
740 for(c = membersLoc.start.charPos; c<=charPos && buffer[c]; c++)
741 if(buffer[c] != ' ' && buffer[c] != '\t')
743 if(c < charPos && buffer[c])
750 membersList.Destroy(0);
751 membersListShown = false;
755 bool back = codeModified;
756 codeModified = false;
758 InvokeParameters(false, false, false);
759 /*if(membersListShown)
760 InvokeAutoComplete(false, 0, true);*/
767 watch(modifiedDocument)
769 ProjectView projectView = ide.projectView;
772 ProjectNode node = projectView.GetNodeFromWindow(this, null);
775 node.modified = modifiedDocument;
776 projectView.Update(null);
784 textVertScroll = true, multiLine = true, /*lineNumbers = ideSettings.showLineNumbers,*/
785 freeCaret = ideSettings.useFreeCaret, caretFollowsScrolling = ideSettings.caretFollowsScrolling,
786 tabKey = true, smartHome = true;
787 tabSelection = true, maxLineSize = 65536, parent = this, hasHorzScroll = true, hasVertScroll = true;
788 selectionColor = selectionColor, selectionText = selectionText,
789 background = codeEditorBG, foreground = codeEditorFG, syntaxColorScheme = colorScheme,
790 font = font, borderStyle = none;
791 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
793 bool OnMouseOver(int x, int y, Modifiers mods)
795 CodeEditor editor = (CodeEditor)master;
796 if(editor.designer && editor.designer.isDragging && !mods.isSideEffect)
801 void NotifyCaretMove(EditBox editBox, int line, int charPos)
803 // Update Line Numbers
805 int oldLine = lastLine;
806 display.FontExtent(font.font, " ", 1, null, &spaceH);
808 Box box { 0, (Min(oldLine,oldLine)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(oldLine, oldLine))*spaceH-1 - editBox.scroll.y };
812 Box box { 0, (Min(line,line)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(line, line))*spaceH-1 - editBox.scroll.y };
817 if(ide.activeClient == this)
818 ProcessCaretMove(editBox, line, charPos);
820 openedFileInfo.CaretMove(line, charPos);
823 void NotifyOvrToggle(EditBox editBox, bool overwrite)
825 ide.ovr.color = overwrite ? black : Color { 128, 128, 128 };
828 void NotifyUpdate(EditBox editBox)
835 designer.modifiedDocument = true;
838 modifiedDocument = true;
841 bool NotifyUnsetModified(EditBox editBox)
843 modifiedDocument = false;
847 bool NotifyCharsAdded(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
853 if(after.y != before.y)
855 ProjectView projectView = ide.projectView;
856 if(projectView && fileName)
859 // HOW WE MIGHT WANT TO DO IT:
860 char * text = before.line.text;
861 for(c = before.x-1; c>= 0; c--)
862 if(!isspace(text[c]))
864 ide.debugger.MoveIcons(fileName, before.y + (((!pasteOperation && c > -1) || !after.line.count) ? 1 : 0), after.y - before.y, false);
866 // HOW VISUAL STUDIO DOES IT:
868 char * text = after.line.text;
869 for(c = after.line.count-1; c>= 0; c--)
870 if(!isspace(text[c]))
872 ide.debugger.MoveIcons(fileName, before.y + ((c < 0) ? 1 : 0), after.y - before.y, false);
879 for(oClass = classes.first; oClass; oClass = oClass.next)
882 for(object = oClass.instances.first; object; object = object.next)
886 object.instCode.loc.start.AdjustAdd(before, after);
887 object.instCode.loc.end.AdjustAdd(before, after);
892 oClass.classDefinition.loc.start.AdjustAdd(before, after);
893 oClass.classDefinition.loc.end.AdjustAdd(before, after);
899 expectingMove = true;
903 if(before.y != after.y)
907 char * buffer = membersLine.text;
909 bool firstChar = true;
910 bool addedChar = false;
916 membersLoc.end.charPos += after.x - Max(membersLoc.start.charPos, before.x);
918 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
920 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
921 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar)) //|| membersList.currentRow
930 membersLoc.start.charPos++;
935 string[len++] = buffer[c];
939 row = membersList.currentRow;
940 if(row && row.selected)
944 membersLoc.start.charPos--;
952 row = membersList.FindSubString(string);
954 membersList.currentRow = row;
957 row = membersList.FindSubStringi(string);
959 membersList.currentRow = row;
960 membersList.currentRow.selected = false;
963 membersList.SetScrollPosition(0, (row.index) * membersList.rowHeight);
967 row = membersList.currentRow;
970 // Accept current string if hiding typing char
971 if(hide && row && row.selected)
973 char * string = row.string;
974 int len = strlen(string);
975 membersLoc.end.charPos -= after.x - before.x;
976 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
977 editBox.Delete(membersLine, membersLoc.start.line, membersLoc.start.charPos,
978 membersLine, membersLoc.end.line, membersLoc.end.charPos);
979 editBox.PutS(string);
980 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos + len + 1 /*after.x - before.x*/);
982 after.x += membersLoc.start.charPos + len - before.x;
983 before.x = membersLoc.start.charPos + len;
988 membersList.Destroy(0);
989 membersListShown = false;
992 if(/*after.x - before.x == 1 && */after.y == before.y && !membersListShown)
994 EditLine line = editBox.line;
995 char * text = line.text;
996 char ch = text[after.x-1];
997 if(ch == '.' || (ch == '>' && after.x-1 > 0 && text[after.x-1-1] == '-') || (ch == ':' && after.x-1 > 0 && text[after.x-1-1] == ':'))
1001 // Can we call invoke auto complete here instead?
1011 // Force caret update already...
1012 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1013 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1015 editBox.GetCaretPosition(&caret);
1019 // Go back in the buffer until no space before
1021 codeModified = true;
1025 EditBoxStream f { editBox = editBox };
1029 if(text[after.x-1] == '>')
1035 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1039 if(!f.Seek(-1, current))
1042 if(!isspace(ch)) break;
1043 f.Seek(-1, current);
1045 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1047 line = editBox.lineNumber + 1;
1048 charPos = editBox.charPos + 1;
1052 exp = FindExpTree(ast, line, charPos);
1056 Type type = exp.expType;
1058 if(type && text[after.x-1] != '.')
1060 if(type.kind == TypePointer || type.kind == TypeArray)
1066 membersList.Clear();
1069 if(membersList.rowCount)
1071 membersList.Sort(null, 1);
1072 membersList.master = this;
1074 caret.y += editBox.GetCaretSize();
1077 membersList.Create();
1080 int x = caret.x + editBox.GetAbsX() - app.desktop.GetAbsX() - editBox.GetScrollX();
1081 int y = caret.y + editBox.GetAbsY() - app.desktop.GetAbsY() - editBox.GetScrollY();
1082 Window parent = membersList.parent;
1084 if(!paramsAbove && (paramsShown || y + membersList.GetHeight() > parent.GetClientHeight()))
1086 y -= editBox.GetCaretSize() + membersList.GetHeight();
1087 membersAbove = true;
1090 membersAbove = false;
1092 membersList.position = { x, y };
1096 membersLoc.start.line = line - 1;
1097 membersLoc.start.charPos = oldCharPos;
1098 membersLoc.end = membersLoc.start;
1099 membersListShown = true;
1104 SetCurrentContext(globalContext);
1106 codeModified = true;
1107 skipModified = true;
1108 if(text[after.x-1] == ':')
1109 InvokeAutoComplete(false, 0, false);
1110 else if(text[after.x-1] == '.')
1111 InvokeAutoComplete(false, 1, false);
1112 else if(text[after.x-1] == '>')
1113 InvokeAutoComplete(false, 2, false);
1114 skipModified = false;
1116 else if(ch == '(' || ch == OpenBracket || ch == ',' || ch == '=' || ch == '?' || ch == ':')
1118 codeModified = true;
1119 skipModified = true;
1121 if(InvokeAutoComplete(true, 0, false))
1123 if(ch == '(' || ch == OpenBracket)
1124 InvokeParameters(true, true, false);
1126 InvokeParameters(this.functionType ? false : true, false, false);
1129 // InvokeAutoComplete(true, 0, false);
1130 skipModified = false;
1132 else if(ch == ')' || ch == '}' || ch == ';')
1134 codeModified = true;
1135 skipModified = true;
1137 InvokeParameters(false, true, false);
1138 skipModified = false;
1142 bool back = codeModified;
1143 codeModified = false;
1145 InvokeParameters(false, false, true);
1146 if(membersListShown)
1147 InvokeAutoComplete(false, 0, true);
1148 codeModified = back;
1153 bool back = codeModified;
1154 codeModified = false;
1157 InvokeParameters(false, false, true);
1158 /*if(membersListShown)
1159 InvokeAutoComplete(false, 0, true);*/
1161 codeModified = back;
1168 bool NotifyCharsDeleted(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
1174 if(after.y != before.y)
1176 ProjectView projectView = ide.projectView;
1177 if(projectView && fileName)
1179 ide.debugger.MoveIcons(fileName, before.y + 1, before.y - after.y, before.x == 0);
1184 for(oClass = classes.first; oClass; oClass = oClass.next)
1188 for(object = oClass.instances.first; object; object = object.next)
1192 loc = &object.instCode.loc;
1194 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1195 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1197 object.instCode = null;
1201 loc->start.AdjustDelete(before, after);
1202 loc->end.AdjustDelete(before, after);
1206 if(oClass.classDefinition)
1208 loc = &oClass.classDefinition.loc;
1209 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1210 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1212 oClass.classDefinition = null;
1216 loc->start.AdjustDelete(before, after);
1217 loc->end.AdjustDelete(before, after);
1222 if(membersListShown)
1225 if(pasteOperation || before.y != after.y)
1229 char * buffer = membersLine.text;
1231 bool firstChar = true;
1235 if(before.x >= membersLoc.start.charPos)
1237 for(c = membersLoc.start.charPos; c<before.x; c++)
1239 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1240 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1245 if(!isSpace) firstChar = false;
1248 string[len++] = buffer[c];
1253 // If deleting spaces before...
1254 for(c = before.x; c<membersLoc.start.charPos; c++)
1256 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1264 membersLoc.start.charPos = before.x;
1267 if(membersLoc.end.charPos >= after.x)
1269 for(c = after.x; c<membersLoc.end.charPos; c++)
1271 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1272 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1277 if(!isSpace) firstChar = false;
1280 string[len++] = buffer[c];
1288 membersLoc.end.charPos -= after.x - before.x;
1292 row = membersList.FindSubString(string);
1295 row = membersList.FindSubStringi(string);
1297 membersList.currentRow = row;
1298 membersList.currentRow.selected = false;
1301 membersList.currentRow = row;
1303 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
1308 membersList.Destroy(0);
1309 membersListShown = false;
1315 InvokeParameters(false, false);
1323 bool NotifyDropped(EditBox editBox, int x, int y)
1325 char * controlClass = toolBox.controlClass;
1326 if(controlClass && controlClass[0])
1330 ObjectInfo classObject;
1332 //editBox.NotifyCaretMove(this, editBox, y, x);
1333 editBox.GoToLineNum(y);
1334 editBox.GoToPosition(editBox.line, y, x);
1336 classObject = selected ? selected.oClass : null;
1338 if((!selected || selected == classObject) && classObject && classObject.instances.first)
1339 selected = classObject.instances.last;
1342 control = eInstance_New(eSystem_FindClass(privateModule, controlClass));
1345 AddObject(control, &object);
1347 designer.CreateObject(control, object, false, classObject.instance);
1348 // designer.PostCreateObject(control, object, false, classObject.instance);
1349 designer.DroppedObject(control, object, false, classObject.instance);
1351 sheet.AddObject(object, object.name, typeData /* className*/, true);
1354 //codeModified = true;
1361 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
1363 if(key == Key { space, ctrl = true })
1365 membersList.Destroy(0);
1366 membersListShown = false;
1367 InvokeAutoComplete(false, 0, false);
1370 else if(key == Key { space, ctrl = true, shift = true })
1371 InvokeParameters(false, true, false);
1372 else if(key == escape)
1373 ide.RepositionWindows(true);
1374 else if(key == ctrlF7)
1378 ProjectNode node = ide.projectView.GetNodeFromWindow(this, null);
1382 s = PrintString($"The ", fileName, $" file is not part of any project.\n",
1383 $"It can't be compiled.");
1384 MessageBox { type = ok, parent = ide, master = ide, text = $"File not in project error", contents = s }.Modal();
1393 bool OnKeyDown(Key key, unichar ch)
1395 CodeEditor editor = (CodeEditor)master;
1396 if(key == escape /*|| key == leftAlt || key == rightAlt || (key.ctrl && key.code != left && key.code != right && key.code != leftShift && key.code != rightShift && key.code != space)*/)
1398 if(editor.membersListShown)
1400 editor.membersList.Destroy(0);
1401 editor.membersListShown = false;
1404 if(editor.paramsShown)
1406 editor.paramsList.Destroy(0);
1407 editor.paramsShown = false;
1408 FreeType(editor.functionType);
1409 FreeType(editor.instanceType);
1411 editor.functionType = null;
1412 editor.instanceType = null;
1413 editor.paramsID = -1;
1417 return EditBox::OnKeyDown(key, ch);
1420 void OnVScroll(ScrollBarAction action, int position, Key key)
1422 if(anchor.left.distance)
1424 Box box { 0, 0, anchor.left.distance-1, parent.clientSize.h - 1 };
1427 EditBox::OnVScroll(action, position, key);
1429 CodeEditor ce = (CodeEditor)parent;
1430 if(ce.openedFileInfo)
1431 ce.openedFileInfo.ScrollChange({ scroll.x, position });
1435 void OnHScroll(ScrollBarAction action, int position, Key key)
1437 EditBox::OnHScroll(action, position, key);
1439 CodeEditor ce = (CodeEditor)parent;
1440 if(ce.openedFileInfo)
1441 ce.openedFileInfo.ScrollChange({ position, scroll.y });
1448 fullRowSelect = false,
1451 borderStyle = bevel;
1452 // size = { 200, 400 };
1454 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
1456 DataRow row = listBox.currentRow;
1459 char * string = row.string;
1461 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1463 membersLine, membersLoc.start.line, membersLoc.start.charPos,
1464 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1465 editBox.PutS(string);
1468 membersListShown = false;
1473 bool OnKeyDown(Key key, unichar ch)
1475 CodeEditor editor = (CodeEditor) master;
1476 if(key == escape || key == leftAlt || key == rightAlt ||
1477 (key.ctrl && key.code != left && key.code != right &&
1478 key.code != leftShift && key.code != rightShift && key.code != space))
1480 if(editor.paramsShown)
1481 editor.paramsList.Destroy(0);
1482 if(editor.membersListShown)
1483 editor.membersList.Destroy(0);
1485 editor.paramsShown = false;
1486 FreeType(editor.functionType);
1487 FreeType(editor.instanceType);
1489 editor.functionType = null;
1490 editor.instanceType = null;
1491 editor.paramsID = -1;
1493 editor.membersListShown = false;
1497 return editor.editBox.OnKeyDown(key, ch);
1501 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1503 CodeEditor editor = (CodeEditor)master;
1507 editor.membersListShown = false;
1509 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1512 bool OnKeyHit(Key key, unichar ch)
1514 CodeEditor editor = (CodeEditor) master;
1518 case enter: case tab:
1520 DataRow row = currentRow;
1521 if(row && row.selected)
1523 char * string = row.string;
1525 editor.editBox.GoToPosition(editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos);
1526 editor.editBox.Delete(
1527 editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos,
1528 editor.membersLine, editor.membersLoc.end.line, editor.membersLoc.end.charPos);
1529 editor.editBox.PutS(string);
1532 editor.membersListShown = false;
1535 editor.editBox.OnKeyHit(key, ch);
1545 return ListBox::OnKeyHit(key, ch);
1551 // If before . or after
1552 //listBox.Destroy(true);
1553 result = editor.editBox.OnKeyHit(key, ch);
1568 clickThrough = true,
1570 borderStyle = contour,
1572 background = { 255,255,225 },
1574 OnKeyDown = membersList.OnKeyDown;
1576 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1578 CodeEditor editor = (CodeEditor)master;
1582 editor.membersListShown = false;
1584 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1587 bool OnKeyHit(Key key, unichar ch)
1589 CodeEditor editor = (CodeEditor)master;
1591 if(!editor.membersListShown || editor.membersList.OnKeyHit(key, ch))
1594 bool result = true; editor.editBox.OnKeyHit(key, ch);
1595 return (!created) ? false : result;
1602 void OnRedraw(Surface surface)
1604 CodeEditor editor = (CodeEditor) master;
1605 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1607 Type methodType = null;
1611 int functionW, nameW = 0;
1613 int spaceW, spaceH, commaW, commaWB, parW;
1615 int maxW = 0, lineW = 0;
1621 Font font = editor.normalFont.font;
1622 Font boldFont = editor.boldFont.font;
1623 Display display = this.display;
1625 if(!type) { return; };
1627 if(type.kind == TypeKind::methodType) { methodType = type; type = type.method.dataType; }
1629 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1630 display.FontExtent(font, ", ", 2, &commaW, null);
1631 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1632 display.FontExtent(font, ")", 1, &parW, null);
1635 if(editor.functionType)
1637 PrintType(type.returnType, string, true, true);
1638 display.FontExtent(font, string, strlen(string), &functionW, null);
1640 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1641 totalW = nameW + functionW + 2 * parW;
1645 PrintType(type, string, (type.kind == functionType) ? true : false, true); // true);
1646 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1647 if(instanceName && type.kind != functionType)
1648 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1649 totalW = functionW + nameW;
1650 surface.TextFont(boldFont);
1653 surface.WriteText(x, y, string, strlen(string));
1654 x += functionW + spaceW;
1656 if(editor.functionType)
1659 surface.WriteText(x, y, type.name, strlen(type.name));
1661 surface.WriteText(x, y, "(", 1);
1664 if(methodType && !methodType.staticMethod)
1668 if(id == editor.paramsID)
1669 surface.TextFont(boldFont);
1671 if(methodType.methodClass)
1672 surface.TextExtent(methodType.methodClass.name, strlen(methodType.methodClass.name), &tw, null);
1676 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1677 width += ((id == editor.paramsID) ? commaWB : commaW);
1682 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1687 x = 2 + nameW + spaceW + functionW + parW;
1691 if(methodType.methodClass)
1692 surface.WriteText(x, y, methodType.methodClass.name, strlen(methodType.methodClass.name));
1695 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1697 surface.WriteText(x, y, ",", 1);
1698 x += ((id == editor.paramsID) ? commaWB : commaW);
1706 if(id == editor.paramsID)
1707 surface.TextFont(font);
1711 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1713 for(param = type.params.first; param; param = param.next)
1715 char paramString[1024];
1718 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1719 surface.TextFont(boldFont);
1722 PrintType(param, paramString, true, true);
1723 surface.TextExtent(paramString, strlen(paramString), &tw, null);
1725 if(param.next) width += ((id == editor.paramsID) ? commaWB : commaW);
1730 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1735 x = 2 + nameW + spaceW + functionW + parW;
1739 surface.WriteText(x, y, paramString, strlen(paramString));
1743 surface.WriteText(x, y, ",", 1);
1744 x += ((id == editor.paramsID) ? commaWB : commaW);
1752 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1753 surface.TextFont(font);
1758 surface.WriteText(x, y, ")", 1);
1760 else if(instanceName && type.kind != functionType)
1762 surface.WriteText(x, y, instanceName, strlen(instanceName));
1766 bool OnResizing(int * w, int * h)
1768 CodeEditor editor = (CodeEditor) master;
1769 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1771 Type methodType = null;
1775 int functionW = 0, nameW = 0;
1777 int spaceW, spaceH, commaW, commaWB, parW;
1779 int maxW = 0, lineW = 0;
1784 Font font = editor.normalFont.font;
1785 Font boldFont = editor.boldFont.font;
1786 Display display = this.display;
1788 if(type.kind == TypeKind::methodType)
1791 ProcessMethodType(type.method);
1792 type = type.method.dataType;
1795 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1796 display.FontExtent(font, ", ", 2, &commaW, null);
1797 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1798 display.FontExtent(font, ")", 1, &parW, null);
1801 if(editor.functionType && type)
1803 PrintType(type.returnType, string, true, true);
1804 display.FontExtent(font, string, strlen(string), &functionW, null);
1806 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1807 totalW = nameW + spaceW + functionW + 2 * parW;
1811 PrintType(type, string, false, true); // /*true);
1812 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1813 if(instanceName && type.kind != functionType)
1814 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1815 totalW = functionW + nameW + spaceW;
1818 if(editor.functionType)
1824 if(methodType.methodClass)
1825 display.FontExtent((id == editor.paramsID) ? boldFont : font, methodType.methodClass.name, strlen(methodType.methodClass.name), &width, null);
1826 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1827 width += ((id == editor.paramsID) ? commaWB : commaW);
1832 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1845 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1847 for(param = type.params.first; param; param = param.next)
1849 char paramString[1024];
1853 PrintType(param, paramString, true, true);
1854 display.FontExtent((id == editor.paramsID || param.kind == ellipsisType) ? boldFont : font, paramString, strlen(paramString), &width, null);
1856 width += ((id == editor.paramsID) ? commaWB : commaW);
1861 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1878 *w = realW + totalW + 4;
1884 Menu fileMenu { menu, $"File", f }; // MenuPlacement?
1885 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
1886 MenuItem { fileMenu, $"Save As...", a, NotifySelect = MenuFileSaveAs };
1888 Menu debugMenu { menu, $"Debug", d }; // MenuPlacement?
1889 MenuItem debugRunToCursor
1891 debugMenu, $"Run To Cursor", c, Key { f10, ctrl = true };
1892 bool NotifySelect(MenuItem selection, Modifiers mods)
1894 ProjectView projectView = ide.projectView;
1895 if(!projectView.buildInProgress)
1897 int line = editBox.lineNumber + 1;
1899 ide.debugger.RunToCursor(fileName, line, false);
1904 MenuItem debugSkipRunToCursor
1906 debugMenu, $"Run To Cursor Skipping Breakpoints", u, Key { f10, ctrl = true, shift = true };
1907 bool NotifySelect(MenuItem selection, Modifiers mods)
1909 ProjectView projectView = ide.projectView;
1910 int line = editBox.lineNumber + 1;
1912 ide.debugger.RunToCursor(fileName, line, true);
1916 MenuDivider { debugMenu };
1917 MenuItem debugToggleBreakpoint
1919 debugMenu, $"Toggle Breakpoint", t, f9;
1920 bool NotifySelect(MenuItem selection, Modifiers mods)
1922 ProjectView projectView = ide.projectView;
1923 if(projectView && fileName)
1925 int line = editBox.lineNumber + 1;
1926 char name[MAX_LOCATION];
1928 // TOFIX: This only looks at the filename...
1929 GetLastDirectory(fileName, name);
1930 if(ide && ide.workspace)
1932 for(p : ide.workspace.projects)
1934 if(p.topNode.Find(name, false))
1942 for(p : ide.workspace.projects)
1944 if(eString_PathInsideOf(fileName, p.topNode.path))
1952 ide.debugger.ToggleBreakpoint(fileName, line, prj);
1962 //MenuItem viewDesignerItem, viewProperties, viewMethods;
1966 designer.parent = parent;
1969 toolBox = ((IDE)master).toolBox;
1971 // Debugger bug here: value of toolBox appears as 0
1973 sheet = ((IDE)master).sheet;
1978 bool OnClose(bool parentClosing)
1982 if(ide.workspace && fileName)
1983 ide.workspace.UpdateOpenedFileInfo(fileName, closed);
1985 if(inUseDebug && !debugClosing)
1987 debugClosing = true;
1989 if(CloseConfirmation(false))
1992 OnFileModified({ modified = true }, null);
1994 debugClosing = false;
1997 if(designer && !designer.closing)
1999 if(designer.visible)
2006 //Window formEditor = designer;
2007 //formEditor.Destroy(0);
2014 void OnDestroy(void)
2016 ObjectInfo oClass, next;
2017 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2019 FreeType(this.functionType);
2020 FreeType(this.instanceType);
2025 designer.codeEditor = null;
2026 designer.Destroy(0);
2030 for(oClass = (classes).first, next = oClass ? oClass.next : null; oClass; oClass = next, next = next ? (next.next) : null)
2032 ObjectInfo object, next;
2034 for(object = oClass.instances.first; object; object = next)
2039 Designer::DestroyObject(object.instance);
2040 delete object.instance;
2042 sheet.DeleteObject(object);
2044 oClass.instances.Delete(object);
2048 Designer::DestroyObject(oClass.instance);
2049 delete oClass.instance;
2051 sheet.DeleteObject(oClass);
2053 classes.Delete(oClass);
2056 if(windowClass && windowClass.data)
2057 UnapplySkin(windowClass);
2061 if(sheet.codeEditor == this)
2063 sheet.codeEditor = null;
2064 toolBox.codeEditor = null;
2070 ProjectView projectView = ide.projectView;
2073 ProjectNode node = projectView.GetNodeFromWindow(this, null);
2074 if(node && node.modified)
2076 node.modified = false;
2077 projectView.Update(null);
2083 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool directActivation)
2085 // 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
2087 if(directActivation)
2088 ide.RepositionWindows(false); // Moved this up before as resizing causes NotifyCaretMove to be called on all editors
2090 if(active && directActivation)
2093 openedFileInfo.Activate();
2097 Location * loc = null;
2098 UpdateFormCode(); // To ensure update when modifying properties...
2100 // Got to the right spot in code so we don't lose our form selection...
2103 if(selected.instCode)
2104 loc = &selected.instCode.loc;
2105 else if(selected.classDefinition)
2106 loc = &selected.classDefinition.loc;
2108 line = editBox.lineNumber + 1;
2109 charPos = editBox.charPos + 1;
2114 if(selected && !loc->Inside(line, charPos))
2116 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2117 line = editBox.lineNumber + 1;
2118 charPos = editBox.charPos + 1;
2120 else if(selected && selected.classDefinition)
2123 for(object = selected.instances.first; object; object = object.next)
2127 if(object.instCode.loc.Inside(line, charPos))
2133 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2134 line = editBox.lineNumber + 1;
2135 charPos = editBox.charPos + 1;
2140 ProcessCaretMove(editBox, line, charPos);
2146 bool OnSaveFile(char * fileName)
2153 f = FileOpen(fileName, write);
2156 if(!ide.projectView)
2157 ide.ChangeFileDialogsDirectory(codeEditorFileDialog.currentDirectory, true);
2161 this.fileName = fileName; // Put this here because the form designer will check for it...
2162 designer.fileName = fileName;
2163 designer.modifiedDocument = false;
2165 editBox.Save(f, false);
2166 modifiedDocument = false;
2174 bool OnFileModified(FileChange fileChange, char * param)
2176 bool reload = false;
2177 if(visible == false && inUseDebug == true)
2183 sprintf(message, $"The document %s was modified by another application.\n"
2184 "Would you like to reload it and lose your changes?", fileName);
2185 if(MessageBox { type = yesNo, master = /*parent = */parent, text = $"Document has been modified",
2186 contents = message }.Modal() == yes)
2192 File f = FileOpen(fileName, read);
2195 int lineNumber, charPos, len;
2198 updatingCode = true;
2199 lineNumber = editBox.lineNumber;
2200 charPos = editBox.charPos;
2201 scroll = editBox.scroll;
2204 lineNumber = lineNumber < editBox.numLines ? lineNumber : editBox.numLines - 1;
2205 len = strlen(editBox.line.text);
2206 editBox.GoToLineNum(lineNumber);
2207 editBox.GoToPosition(editBox.line, lineNumber, charPos <= len ? charPos - 1 : (len ? len - 1 : 0));
2208 editBox.scroll = scroll;
2209 updatingCode = false;
2211 codeModified = true;
2215 designer.modifiedDocument = false;
2217 modifiedDocument = false;
2225 void OnRedraw(Surface surface)
2228 surface.SetBackground(marginColor);
2229 surface.Area(0, 0, editBox.anchor.left.distance, clientSize.h - 1);
2230 if(ideSettings.showLineNumbers)
2232 int currentLineNumber;
2237 surface.textOpacity = false;
2238 surface.font = font.font;
2239 surface.TextExtent(" ", 1, null, &spaceH);
2240 currentLineNumber = editBox.scroll.y / spaceH + 1;
2242 surface.SetForeground(lineNumbersColor);
2243 for(i = 0; i < editBox.clientSize.h - 4; i += spaceH)
2245 // Highlight current line
2246 if(editBox.lineNumber == currentLineNumber - 1)
2248 surface.SetBackground(selectedMarginColor);
2249 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2250 surface.SetBackground(marginColor);
2252 sprintf(lineText,"%5u ", currentLineNumber % 100000);
2253 if(currentLineNumber <= editBox.numLines)
2254 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,6);
2256 currentLineNumber++;
2260 if(editBox.syntaxHighlighting && fileName && ide.projectView)
2262 bool error, bpOnCursor, bpOnTopFrame, breakpointEnabled[128];
2263 int lineCursor, lineTopFrame, breakpointLines[128];
2264 int count, i, lineH, boxH, scrollY; //, firstLine; firstLine = editBox.firstLine;
2265 Debugger debugger = ide.debugger;
2266 BitmapResource bmpRes;
2268 boxH = clientSize.h;
2269 scrollY = editBox.scroll.y;
2270 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
2272 bpOnCursor = bpOnTopFrame = false;
2273 count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
2276 for(i = 0; i < count; i++)
2278 if(breakpointLines[i] == lineCursor || breakpointLines[i] == lineTopFrame)
2280 bmpRes = breakpointEnabled[i] ? ide.bmpBpHalf : ide.bmpBpHalfDisabled;
2281 if(breakpointLines[i] == lineCursor)
2283 if(breakpointLines[i] == lineTopFrame)
2284 bpOnTopFrame = true;
2287 bmpRes = breakpointEnabled[i] ? ide.bmpBp : ide.bmpBpDisabled;
2289 DrawLineMarginIcon(surface, bmpRes, breakpointLines[i], lineH, scrollY, boxH);
2292 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
2293 bmpRes = bpOnTopFrame ? (error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf) : (error ? ide.bmpTopFrameError : ide.bmpTopFrame);
2294 DrawLineMarginIcon(surface, bmpRes, lineTopFrame, lineH, scrollY, boxH);
2296 if(editBox.anchor.left.distance)
2298 if(editBox.horzScroll && editBox.horzScroll.visible)
2300 surface.SetBackground(control);
2301 surface.Area(0, editBox.clientSize.h, editBox.anchor.left.distance, clientSize.h - 1);
2306 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
2311 lineY = (line - 1) * lineH;
2312 if(lineY + lineH > scrollY && lineY /*+ lineH*/ < scrollY + boxH)
2314 Bitmap bitmap = resource.bitmap;
2316 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
2323 char ext[MAX_EXTENSION];
2324 char * fileName = property::fileName;
2326 if(SearchString(fileName, 0, "Makefile", false, true))
2327 editBox.useTab = true;
2328 designer.fileName = fileName;
2332 GetExtension(fileName, ext);
2333 if(!strcmpi(ext, "ec"))
2335 codeModified = true;
2339 if(!strcmpi(ext, "ec") || !strcmpi(ext, "c") || !strcmpi(ext, "cc") || !strcmpi(ext, "cpp") || !strcmpi(ext, "eh") || !strcmpi(ext, "hh") || !strcmpi(ext, "hpp") || !strcmpi(ext, "h") || !strcmpi(ext, "hxx") || !strcmpi(ext, "cxx"))
2340 editBox.syntaxHighlighting = true;
2342 editBox.syntaxHighlighting = false;
2345 display.FontExtent(font.font, " ", 1, &spaceW, null);
2346 editBox.anchor = Anchor
2348 left = (editBox.syntaxHighlighting ? 20 : 0) + (ideSettings.showLineNumbers ? (6 * spaceW) : 0),
2349 right = 0, top = 0, bottom = 0
2358 display.FontExtent(font.font, " ", 1, &spaceW, null);
2359 editBox.anchor = Anchor
2361 left = (editBox.syntaxHighlighting ? 20 : 0) + (ideSettings.showLineNumbers ? (6 * spaceW) : 0),
2362 right = 0, top = 0, bottom = 0
2367 bool LoadFile(char * filePath)
2369 File f = FileOpen(filePath, read);
2372 // Added this here...
2373 fileName = filePath;
2374 updatingCode = true;
2376 updatingCode = false;
2385 void DebugMenusDisabled()
2387 bool debugMenusDisabled = ide.GetDebugMenusDisabled();
2388 debugRunToCursor.disabled = debugMenusDisabled;
2389 debugSkipRunToCursor.disabled = debugMenusDisabled;
2390 debugToggleBreakpoint.disabled = debugMenusDisabled;
2396 ProjectView projectView = ide.projectView;
2399 designer.fileName = fileName;
2405 sprintf(title, $"Untitled %d", documentID);
2406 // designer.fileName = CopyString(title);
2407 designer.fileName = title;
2410 DebugMenusDisabled();
2412 for(c = 0; c < CodeObjectType::enumSize; c++)
2413 icons[c] = BitmapResource { iconNames[c], window = this };
2415 codeModified = true;
2427 selected.modified = true;
2428 selected.oClass.modified = true;
2430 designer.modifiedDocument = true;
2431 modifiedDocument = true;
2432 formModified = true;
2435 /****************************************************************************
2437 ****************************************************************************/
2440 this.defines.Free(FreeModuleDefine);
2441 this.imports.Free(FreeModuleImport);
2448 FreeExcludedSymbols(this.excludedSymbols);
2449 FreeContext(this.globalContext);
2451 if(GetGlobalContext() == globalContext)
2453 SetGlobalData(null);
2454 SetGlobalContext(null);
2455 SetExcludedSymbols(null);
2456 SetTopContext(null);
2457 SetCurrentContext(null);
2460 SetPrivateModule(null);
2463 if(this.privateModule)
2465 FreeTypeData(this.privateModule);
2466 delete this.privateModule;
2467 this.privateModule = null;
2473 static bool reentrant = false;
2478 char * selectedClassName = null, * selectedName = null;
2479 int selectedPos = 0;
2480 Designer backDesigner;
2481 char oldWorkDir[MAX_LOCATION];
2482 char mainModuleName[MAX_FILENAME] = "";
2484 ImportedModule module;
2485 char extension[MAX_EXTENSION];
2487 Time parseCodeStart = GetTime();
2488 Time startTime, startFindClass;
2490 findClassTotalTime = 0;
2491 checkTypeTotalTime = 0;
2492 externalImportTotalTime = 0;
2493 findClassIgnoreNSTotalTime = 0;
2494 findSymbolTotalTime = 0;
2495 //ResetClassFindTime();
2499 // 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)
2500 if(reentrant) return;
2507 selectedClassName = CopyString(oClass.name);
2508 if(selected != oClass)
2510 ObjectInfo object = this.selected;
2511 selectedName = CopyString(object.name);
2515 for(check = this.oClass.instances.first; check; check = check.next)
2527 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
2529 defines.Free(FreeModuleDefine);
2530 imports.Free(FreeModuleImport);
2532 SetGlobalData(&globalData);
2533 SetGlobalContext(globalContext);
2534 SetExcludedSymbols(&excludedSymbols);
2535 SetTopContext(globalContext);
2536 SetCurrentContext(globalContext);
2537 SetDefines(&defines);
2538 SetImports(&imports);
2539 SetCurrentNameSpace(null);
2542 sprintf(command, "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin\\cl "
2543 "/nologo /D \"MSC\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" "
2544 "/I \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include\" "
2545 "/I T:\\ecere\\include /E %s", argv[1]);
2549 ChangeWorkingDir("e:\\ec");
2550 sprintf(command, "gcc -x c -E -");
2551 fileInput = DualPipeOpen({ output = true, input = true }, command);
2552 SetFileInput(fileInput);
2557 uint count = editFile.Read(buffer, 1, sizeof(buffer));
2559 fileInput.Write(buffer, 1, count);
2564 fileInput.CloseOutput();
2568 // TOCHECK: COULDN'T WE CALL FreeParser here?
2570 this.functionType = null;
2571 this.instanceType = null;
2574 sheet.SelectObject(null);
2580 // We don't want the designer to be notified of selection when deleting rows...
2581 backDesigner = designer;
2586 ObjectInfo _class, next;
2588 for(_class = classes.first; _class; _class = next)
2594 for(;object = _class.instances.first;)
2598 Designer::DestroyObject(object.instance);
2599 delete object.instance;
2601 sheet.DeleteObject(object);
2603 _class.instances.Delete(object);
2607 Designer::DestroyObject(_class.instance);
2608 delete _class.instance;
2610 sheet.DeleteObject(_class);
2612 classes.Delete(_class);
2618 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2619 if(windowClass && windowClass.data)
2620 UnapplySkin(windowClass);
2623 designer = backDesigner;
2626 fileInput = editFile = EditBoxStream { editBox = editBox };
2627 SetFileInput(fileInput);
2636 FreeContext(this.globalContext);
2637 FreeExcludedSymbols(this.excludedSymbols);
2640 FreeGlobalData(&this.globalData);
2642 if(this.privateModule)
2644 FreeTypeData(this.privateModule);
2645 delete this.privateModule;
2649 startTime = GetTime();
2650 printf("Cleaning up took %.3f seconds\n", startTime - parseCodeStart);
2652 printf("classes.count: %d\n", globalContext.classes.count);
2655 this.privateModule = __ecere_COM_Initialize(false, 1, null);
2657 SetPrivateModule(privateModule);
2660 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint"), type = ProcessTypeString("unsigned int", false) });
2661 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint64"), type = ProcessTypeString("unsigned int64", false) });
2662 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint32"), type = ProcessTypeString("unsigned int", false) });
2663 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint16"), type = ProcessTypeString("unsigned short", false) });
2664 globalContext.types.Add((BTNode)Symbol { string = CopyString("byte"), type = ProcessTypeString("unsigned char", false) });
2667 fileName = this.fileName;
2669 if(ide.workspace && ide.workspace.projects && fileName)
2671 for(p : ide.workspace.projects)
2673 char path[MAX_LOCATION];
2675 MakePathRelative(fileName, p.topNode.path, path);
2676 MakeSlashPath(path);
2678 pn = p.topNode.FindWithPath(path, false);
2687 project = ide.project;
2689 GetWorkingDir(oldWorkDir, MAX_LOCATION);
2691 ChangeWorkingDir(project.topNode.path);
2693 SetSomeSourceFileStack(fileName ? fileName : "", 0); //strcpy(sourceFileStack[0], fileName ? fileName : "");
2695 GetLastDirectory(fileName, mainModuleName);
2696 GetExtension(mainModuleName, extension);
2698 SetBuildingEcereCom(false);
2699 SetBuildingEcereComModule(false);
2701 // TODO: Get symbolsDir from project settings instead...
2704 DirExpression objDir = project.objDir;
2705 SetSymbolsDir(objDir.dir);
2707 // SetIncludeDirs(ide.projectView.project.config.includeDirs);
2708 // SetSysIncludeDirs(ide.ideSettings.systemDirs[includes]);
2712 switch(GetRuntimePlatform())
2714 case win32: SetSymbolsDir("obj/debug.win32"); break;
2715 case tux: SetSymbolsDir("obj/debug.linux"); break;
2716 case apple: SetSymbolsDir("obj/debug.apple"); break;
2718 SetIncludeDirs(null);
2719 SetSysIncludeDirs(null);
2723 if(ide.projectView && ide.projectView.IsModuleInProject(this.fileName))
2725 // TODO FIX for configless project
2726 if(ide.project.config && ide.project.config.options && ide.project.config.options.preprocessorDefinitions)
2728 for(item : ide.project.config.options.preprocessorDefinitions)
2730 if(!strcmp(item, "BUILDING_ECERE_COM"))
2732 SetBuildingEcereCom(true);
2739 if(!(strcmpi(mainModuleName, "instance.ec") && strcmpi(mainModuleName, "BinaryTree.ec") &&
2740 strcmpi(mainModuleName, "dataTypes.ec") && strcmpi(mainModuleName, "OldList.ec") &&
2741 strcmpi(mainModuleName, "String.ec") && strcmpi(mainModuleName, "BTNode.ec") &&
2742 strcmpi(mainModuleName, "Array.ec") && strcmpi(mainModuleName, "AVLTree.ec") &&
2743 strcmpi(mainModuleName, "BuiltInContainer.ec") && strcmpi(mainModuleName, "Container.ec") &&
2744 strcmpi(mainModuleName, "CustomAVLTree.ec") && strcmpi(mainModuleName, "LinkList.ec") &&
2745 strcmpi(mainModuleName, "List.ec") && strcmpi(mainModuleName, "Map.ec") &&
2746 strcmpi(mainModuleName, "Mutex.ec")))
2748 SetBuildingEcereComModule(true);
2751 // Predeclare all classes
2753 char symFile[MAX_FILENAME];
2754 char symLocation[MAX_LOCATION];
2755 ImportedModule module, next;
2757 GetLastDirectory(fileName, symFile);
2758 ChangeExtension(symFile, "sym", symFile);
2760 strcpy(symLocation, GetSymbolsDir());
2761 PathCat(symLocation, symFile);
2763 // if(!GetEcereImported() && !GetBuildingEcereCom())
2764 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2767 startTime = GetTime();
2769 eModule_LoadStrict(privateModule, "ecereCOM", privateAccess);
2771 printf("Loading ecereCOM took %.3f seconds\n", GetTime() - startTime);
2776 startTime = GetTime();
2778 // LoadSymbols(symLocation, normalImport, true);
2779 LoadSymbols(symLocation, preDeclImport, false);
2781 printf("Loading symbols took %.3f seconds\n", GetTime() - startTime);
2784 for(module = defines.first; module; module = next)
2787 if(module.type == moduleDefinition && strcmpi(module.name, mainModuleName))
2790 defines.Delete(module);
2795 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2796 SetDefaultDeclMode(privateAccess);
2798 SetDefaultDeclMode(defaultAccess);
2800 StripExtension(mainModuleName);
2801 module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };
2802 defines.AddName(module);
2810 startTime = GetTime();
2811 startFindClass = checkTypeTotalTime;
2815 printf("ParseEc took %.3f seconds, out of which %.3f seconds were in CheckType\n", GetTime() - startTime, checkTypeTotalTime - startFindClass);
2817 CheckDataRedefinitions();
2820 SetIncludeDirs(null);
2821 SetSysIncludeDirs(null);
2832 startTime = GetTime();
2834 PrePreProcessClassDefinitions();
2835 ComputeModuleClasses(privateModule);
2836 PreProcessClassDefinitions();
2837 ProcessClassDefinitions();
2839 printf("Initial Passes took %.3f seconds\n", GetTime() - startTime);
2840 startTime = GetTime();
2845 printf("ComputeDataTypes took %.3f seconds\n", GetTime() - startTime);
2846 startTime = GetTime();
2848 ProcessInstantiations();
2850 printf("ProcessInstantiations took %.3f seconds\n", GetTime() - startTime);
2853 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2855 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2856 if(!windowClass || windowClass.internalDecl)
2859 startTime = GetTime();
2861 // *** COMMENTED THIS OUT DUE TO ecereCOM issues
2862 // eModule_Load(this.privateModule.application.allModules.first ? this.privateModule.application.allModules.first : this.privateModule, "ecere", privateAccess);
2863 eModule_Load(this.privateModule, "ecere", privateAccess);
2865 printf("Loading ecere.dll took %.3f seconds\n", GetTime() - startTime);
2868 windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2870 if(windowClass && windowClass.data)
2871 ApplySkin(windowClass, app.currentSkin.name, null);
2875 startTime = GetTime();
2877 for(external = ast->first; external; external = external.next)
2879 if(external.type == classExternal)
2881 ClassDefinition _class = external._class;
2882 if(_class.baseSpecs && _class.baseSpecs->first && ((Specifier)_class.baseSpecs->first).type == nameSpecifier ) // classSpecifier
2884 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)_class.baseSpecs->first).name);
2887 if(eClass_GetDesigner(regClass) && !GetBuildingEcereComModule())
2889 Instance instance = eInstance_New(regClass);
2890 ObjectInfo classObject
2892 name = CopyString(_class._class.name);
2893 instance = instance;
2894 classDefinition = _class;
2895 oClass = classObject;
2898 classes.Add(classObject);
2902 // Moved this at bottom so that the file dialog doesn't show up in eCom
2903 designer.CreateObject(instance, classObject, true, null);
2904 sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, typeClass, false);
2906 if(_class.definitions)
2910 for(def = _class.definitions->first; def; def = def.next)
2914 case defaultPropertiesClassDef:
2917 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
2919 Identifier id = propDef.identifiers->first;
2922 Property prop = eClass_FindProperty(regClass, id.string, this.privateModule);
2925 Class propertyClass = prop.dataTypeClass;
2927 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
2928 if(prop.compiled && prop.Set && prop.Get && propertyClass && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp)
2930 FreeType(propDef.initializer.exp.destType);
2931 propDef.initializer.exp.destType = MkClassType(propertyClass.name);
2932 ProcessExpressionType(propDef.initializer.exp);
2934 if(propertyClass.type == structClass || propertyClass.type == noHeadClass || propertyClass.type == normalClass)
2936 Expression computed = CopyExpression(propDef.initializer.exp);
2937 ComputeExpression(computed);
2939 if(computed.isConstant && computed.type == instanceExp && !id.next)
2943 if(computed.instance._class && computed.instance._class.symbol &&
2944 computed.instance._class.symbol.registered &&
2945 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
2947 prop.Set(instance, computed.instance.data);
2949 // This was saved in the control and shouldn't be freed by FreeExpression...
2950 if(propertyClass.type == normalClass)
2951 computed.instance.data = null;
2955 // MOVED THIS UP NOW THAT char * IS A NORMAL CLASS
2956 else if(computed.type == stringExp)
2959 ReadString(temp, computed.string);
2960 prop.Set(instance, temp);
2963 propDef.variable = true;
2965 FreeExpression(computed);
2969 Expression computed = CopyExpression(propDef.initializer.exp);
2970 ComputeExpression(computed);
2971 if(computed.isConstant)
2973 //if(computed.type == memberExp) computed = computed.member.exp;
2975 if(computed.type == constantExp)
2977 Operand value = GetOperand(computed);
2978 DataValue valueData;
2979 valueData.i64 = value.i64;
2980 SetProperty(prop, instance, valueData);
2982 else if(computed.type == stringExp)
2985 ReadString(temp, computed.string);
2986 prop.Set(instance, temp);
2990 propDef.variable = true;
2992 FreeExpression(computed);
2996 propDef.variable = true;
3000 Method method = eClass_FindMethod(regClass, id.string, this.privateModule);
3001 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer &&
3002 propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
3005 // Maintain a list in FunctionDefinition of who is attached to it
3006 for(def = _class.definitions->first; def; def = def.next)
3008 if(def.type == functionClassDef)
3010 ClassFunction function = def.function;
3011 if(!strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
3013 function.attached.Add(OldLink { data = method });
3023 case declarationClassDef:
3025 Declaration decl = def.decl;
3028 case instDeclaration:
3030 Instantiation inst = decl.inst;
3031 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3032 if(instClass && eClass_GetDesigner(instClass))
3034 Instance control = eInstance_New(instClass);
3039 oClass = classObject;
3043 classObject.instances.Add(object);
3045 // TOCHECK: Why is this needed now?
3046 object.name = CopyString((inst.exp.type == memberExp) ? inst.exp.member.member.string : inst.exp.identifier.string);
3047 def.object = object;
3049 // if(object.name) { symbol = eList_Add(&curContext.symbols, sizeof(Symbol)); symbol.string = object.name; symbol.type = MkClassType(instClass.name); }
3051 designer.CreateObject(control, object, false, classObject.instance);
3052 sheet.AddObject(object, object.name ? object.name : inst._class.name, typeData, false);
3062 // Second pass, process instantiation members
3064 for(def = _class.definitions->first; def; def = def.next)
3068 case declarationClassDef:
3070 Declaration decl = def.decl;
3073 case instDeclaration:
3075 Instantiation inst = decl.inst;
3076 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3077 if(instClass && eClass_GetDesigner(instClass))
3080 object = object ? object.next : classObject.instances.first;
3081 control = object.instance;
3085 MembersInit members;
3086 for(members = inst.members->first; members; members = members.next)
3088 switch(members.type)
3090 case dataMembersInit:
3092 if(members.dataMembers)
3095 DataMember curMember = null;
3096 Class curClass = null;
3097 DataMember subMemberStack[256];
3098 int subMemberStackPos = 0;
3100 for(member = members.dataMembers->first; member; member = member.next)
3103 Identifier ident = member.identifiers ? member.identifiers->first : null;
3106 DataMember _subMemberStack[256];
3107 int _subMemberStackPos = 0;
3108 DataMember thisMember = (DataMember)eClass_FindDataMember(instClass, ident.string, privateModule, _subMemberStack, &_subMemberStackPos);
3112 thisMember = (DataMember)eClass_FindProperty(instClass, ident.string, privateModule);
3114 if(thisMember && thisMember.memberAccess == publicAccess)
3116 curMember = thisMember;
3117 curClass = curMember._class;
3118 memcpy(subMemberStack, _subMemberStack, sizeof(int) * _subMemberStackPos);
3119 subMemberStackPos = _subMemberStackPos;
3125 eClass_FindNextMember(instClass, &curClass, (DataMember *)&curMember, subMemberStack, &subMemberStackPos);
3126 if(curMember) found = true;
3128 if(found && curMember.isProperty)
3130 Property prop = (Property) curMember;
3131 Class propertyClass = prop.dataTypeClass;
3133 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3135 if(prop.compiled && prop.Set && prop.Get && propertyClass && member.initializer && member.initializer.type == expInitializer && member.initializer.exp)
3137 FreeType(member.initializer.exp.destType);
3138 member.initializer.exp.destType = MkClassType(propertyClass.name);
3141 ProcessExpressionType(member.initializer.exp);
3143 if(propertyClass.type == structClass || propertyClass.type == normalClass || propertyClass.type == noHeadClass)
3145 Expression computed;
3147 /*char debugExpString[4096];
3148 debugExpString[0] = '\0';
3149 PrintExpression(member.initializer.exp, debugExpString);*/
3151 computed = CopyExpression(member.initializer.exp);
3154 ComputeExpression(computed);
3156 if(computed.type == instanceExp && computed.isConstant && computed.isConstant)
3158 if(computed.instance.data)
3160 if(computed.instance._class && computed.instance._class.symbol &&
3161 computed.instance._class.symbol.registered &&
3162 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3164 prop.Set(control, computed.instance.data);
3166 // This was saved in the control and shouldn't be freed by FreeExpression...
3167 if(propertyClass.type == normalClass)
3168 computed.instance.data = null;
3172 else if(computed.type == identifierExp)
3174 member.variable = true;
3176 if(eClass_GetDesigner(propertyClass))
3179 char * name = computed.identifier.string;
3180 if(!strcmp(name, "this"))
3183 prop.Set(control, instance);
3184 member.variable = false;
3189 for(check = classObject.instances.first; check; check = check.next)
3190 if(check.name && !strcmp(name, check.name))
3193 prop.Set(control, check.instance);
3194 member.variable = false;
3200 else if(computed.type == memberExp)
3202 member.variable = true;
3203 if(computed.member.exp.type == identifierExp)
3205 char * name = computed.member.exp.identifier.string;
3206 if(!strcmp(name, "this"))
3208 char * name = computed.member.member.string;
3211 for(check = classObject.instances.first; check; check = check.next)
3212 if(check.name && !strcmp(name, check.name))
3215 prop.Set(control, check.instance);
3216 member.variable = false;
3224 for(check = classObject.instances.first; check; check = check.next)
3226 if(check.name && !strcmp(name, check.name))
3228 Property getProperty = eClass_FindProperty(check.instance._class, computed.member.member.string, this.privateModule);
3231 DataValue value { };
3232 GetProperty(getProperty, check.instance, &value);
3233 SetProperty(prop, control, value);
3234 member.variable = false;
3242 // MOVED THIS UP NOW THAT char * IS A NORMAL CLASS
3243 else if(computed.isConstant && computed.type == stringExp && (propertyClass.dataTypeString && !strcmp(propertyClass.dataTypeString, "char *")))
3246 ReadString(temp, computed.string);
3247 prop.Set(control, temp);
3250 member.variable = true;
3252 FreeExpression(computed);
3257 Expression computed = CopyExpression(member.initializer.exp);
3260 ComputeExpression(computed);
3261 if(computed.isConstant)
3263 if(computed.type == constantExp && (!propertyClass.dataTypeString || strcmp(propertyClass.dataTypeString, "char *"))) //(strcmp(propertyClass.name, "char *") && (strcmp(propertyClass.name, "String"))))
3265 if(!strcmp(propertyClass.dataTypeString, "float"))
3266 ((void (*)(void *, float))(void *)prop.Set)(control, (float)strtod(computed.constant, null));
3267 else if(!strcmp(propertyClass.dataTypeString, "double"))
3268 ((void (*)(void *, double))(void *)prop.Set)(control, strtod(computed.constant, null));
3270 prop.Set(control, strtol(computed.constant, null, 0));
3272 else if(computed.type == stringExp && (propertyClass.dataTypeString && !strcmp(propertyClass.dataTypeString, "char *"))) // || (!strcmp(propertyClass.name, "String"))))
3275 ReadString(temp, computed.string);
3276 prop.Set(control, temp);
3280 member.variable = true;
3282 FreeExpression(computed);
3288 member.variable = true;
3290 else if(ident && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3291 member.initializer.exp.type == memberExp) // identifierExp
3293 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3294 if(method && method.type == virtualMethod)
3297 // Maintain a list in FunctionDefinition of who is attached to it
3298 for(def = _class.definitions->first; def; def = def.next)
3300 if(def.type == functionClassDef)
3302 ClassFunction function = def.function;
3303 Identifier id = (member.initializer.exp.type == memberExp) ? member.initializer.exp.member.member : member.initializer.exp.identifier;
3304 if(function.declarator && !strcmp(function.declarator.symbol.string, id.string))
3306 function.attached.Add(OldLink { data = method });
3307 // Reference this particular instance?
3322 designer.PostCreateObject(object.instance, object, false, classObject.instance);
3333 //designer.CreateObject(instance, classObject, true, null);
3334 //sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, classType, false);
3336 designer.PostCreateObject(instance, classObject, true, null);
3338 //instance.state = Hidden;
3339 //instance.Create();
3340 //instance.SetState(Normal, true, 0);
3349 printf("Class/Instance Processing took %.3f seconds\n", GetTime() - startTime);
3353 // Restore Selection
3354 if(selectedClassName)
3357 for(oClass = classes.first; oClass; oClass = oClass.next)
3359 if(!strcmp(oClass.name, selectedClassName))
3361 this.oClass = oClass;
3365 delete selectedClassName;
3374 for(check = this.oClass.instances.first; check; check = check.next)
3376 if(check.name && !strcmp(check.name, selectedName))
3378 this.selected = check;
3384 if(this.oClass.instances.first)
3385 this.selected = this.oClass.instances.first;
3387 this.selected = this.oClass;
3390 else if(selectedPos == -1 || !this.oClass.instances.count)
3391 this.selected = this.oClass;
3397 if(selectedPos > this.oClass.instances.count)
3399 for(check = this.oClass.instances.first; check; check = check.next)
3401 if(selectedPos == pos++)
3403 this.selected = check;
3411 this.oClass = classes.first;
3412 this.selected = (this.oClass && this.oClass.instances.first) ? this.oClass.instances.first : this.oClass;
3414 delete selectedName;
3415 SetSymbolsDir(null);
3417 if(sheet.codeEditor == this)
3418 sheet.SelectObject(selected);
3421 codeModified = false;
3423 // TESTING THIS TO NOT GET EMPTY PARAMETERS
3426 InvokeParameters(false, false, false);
3429 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
3435 ChangeWorkingDir(oldWorkDir);
3437 printf("Total FindClass time is %.3f seconds, out of which %.3f is in Ignore NS\n\n", findClassTotalTime, findClassIgnoreNSTotalTime);
3438 printf("Total CheckType time is %.3f seconds\n\n", checkTypeTotalTime);
3439 printf("Total MkExternalImport time is %.3f seconds\n\n", externalImportTotalTime);
3440 printf("Total FindSymbol time is %.3f seconds\n\n", findSymbolTotalTime);
3441 // printf("Total Class Members Find time is %.3f seconds\n\n", GetClassFindTime());
3443 printf("Whole ParseCode function took %.3f seconds\n\n", GetTime() - parseCodeStart);
3445 if(inUseDebug && ide.projectView)
3446 ide.debugger.EvaluateWatches();
3449 void UpdateInstanceCodeClass(Class _class, ObjectInfo object, EditBoxStream f, Instance test, bool * prev, bool * lastIsMethod, DataMember * curMember, Class * curClass)
3452 Window control = (Window)object.instance;
3453 ObjectInfo classObject = object.oClass;
3455 if(_class.base && _class.base.type != systemClass) UpdateInstanceCodeClass(_class.base, object, f, test, prev, lastIsMethod, curMember, curClass);
3457 if(!strcmp(_class.name, "DesignerBase")) return;
3459 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
3461 Property prop = eClass_FindProperty(object.instance._class, propIt.name, privateModule);
3462 if(prop && prop.isProperty && !prop.conversion && eClass_FindProperty(object.instance._class, prop.name, privateModule))
3464 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(object, prop.name) &&
3465 (!prop.IsSet || prop.IsSet(control)))
3467 Class dataType = prop.dataTypeClass;
3469 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3473 if(dataType.type == structClass)
3475 void * dataForm = new0 byte[dataType.structSize];
3476 void * dataTest = new0 byte[dataType.structSize];
3478 ((void (*)())(void *)prop.Get)(control, dataForm);
3479 prop.Get(test, dataTest);
3481 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
3483 char tempString[1024] = "";
3485 bool needClass = true;
3489 prop.Set(test, dataForm);
3491 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
3493 eClass_FindNextMember(_class, curClass, curMember, null, null);
3494 if(*curMember != (DataMember)prop)
3495 f.Printf("%s = ", prop.name);
3497 *curMember = (DataMember)prop;
3498 *curClass = curMember->_class;
3501 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3503 f.Printf("%s", string);
3510 else if(dataType.type == normalClass || dataType.type == noHeadClass)
3512 void * dataForm, * dataTest;
3514 dataForm = (void *)prop.Get(control);
3515 dataTest = (void *)prop.Get(test);
3517 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
3519 char tempString[1024] = "";
3524 prop.Set(test, dataForm);
3526 eClass_FindNextMember(_class, curClass, curMember, null, null);
3527 if(*curMember != (DataMember)prop)
3528 f.Printf("%s = ", prop.name);
3529 *curMember = (DataMember)prop;
3530 *curClass = curMember->_class;
3532 if(eClass_GetDesigner(dataType))
3534 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
3535 //if(!strcmp(classObject.instance._class.name, dataType.name) && classObject.instance == dataForm)
3536 f.Printf("this", prop.name);
3539 //ObjectInfo classObject;
3540 //for(classObject = classes.first; classObject; classObject = classObject.next)
3544 for(object = classObject.instances.first; object; object = object.next)
3546 if(!object.deleted && eClass_IsDerived(object.instance._class, dataType) && object.instance == dataForm && object.name)
3548 f.Printf("%s", object.name);
3555 bool needClass = true;
3556 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
3557 f.Printf("%s", string);
3564 bool needClass = true;
3565 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
3567 if(!strcmp(dataType.dataTypeString, "char *"))
3570 OutputString(f, string);
3574 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3576 f.Printf("%s", string);
3579 *lastIsMethod = false;
3584 DataValue dataForm, dataTest;
3586 GetProperty(prop, control, &dataForm);
3587 GetProperty(prop, test, &dataTest);
3589 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
3592 char tempString[1024] = "";
3593 SetProperty(prop, test, dataForm);
3595 if(dataType.type != bitClass)
3597 bool needClass = true;
3599 if(dataType.type == enumClass)
3602 Class enumClass = eSystem_FindClass(privateModule, "enum");
3603 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
3605 for(value = e.values.first; value; value = value.next)
3607 if((int)value.data == dataForm.i)
3609 string = value.name;
3615 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, &dataForm, tempString, null, &needClass);
3617 if(string && string[0])
3622 eClass_FindNextMember(_class, curClass, curMember, null, null);
3623 if(*curMember != (DataMember)prop)
3624 f.Printf("%s = ", prop.name);
3625 *curMember = (DataMember)prop;
3626 *curClass = curMember->_class;
3628 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
3629 f.Printf("%sf", string);
3631 f.Printf("%s", string);
3635 else if(dataType.type == bitClass)
3637 bool needClass = true;
3639 if(*prev) f.Printf(", ");
3641 eClass_FindNextMember(_class, curClass, curMember, null, null);
3642 if(*curMember != (DataMember)prop)
3643 f.Printf("%s = ", prop.name);
3644 *curMember = (DataMember)prop;
3645 *curClass = curMember->_class;
3647 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, &dataForm.ui, tempString, null, &needClass);
3649 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3651 f.Printf("%s", string);
3653 *lastIsMethod = false;
3663 int UpdateInstanceCode(EditBoxStream f, int position, Class regClass, ObjectInfo object, bool * firstObject, char ** text, int * textSize, int movedFuncIdLen, int movedFuncIdPos)
3665 Instantiation inst = object.instCode;
3666 Window control = (Window)object.instance;
3668 bool methodPresent = false;
3670 bool lastIsMethod = true;
3671 ObjectInfo classObject = object.oClass;
3677 // Instance removed, delete it
3678 DeleteJunkBefore(f, inst.loc.start.pos, &position);
3680 f.DeleteBytes(inst.loc.end.pos - inst.loc.start.pos + 1);
3681 position = inst.loc.end.pos + 1;
3685 bool multiLine = false;
3688 // Check if it's an unnamed instance
3691 f.Seek(inst.nameLoc.start.pos - position, current);
3692 f.DeleteBytes(inst.nameLoc.end.pos - inst.nameLoc.start.pos);
3693 position = inst.nameLoc.end.pos;
3695 f.Printf(object.name);
3700 if(isspace(ch) && ch != '\n')
3702 f.Seek(-1, current);
3710 int pos = inst.loc.start.pos; // + strlen(inst._class.name);
3712 f.Seek(pos - position, current);
3717 f.Seek(-1, current);
3726 f.Puts(object.name);
3731 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
3732 methodPresent = true;
3740 if(ch == OpenBracket)
3746 // TODO: Simplify this?
3755 f.Seek(-1, current);
3767 if(ch == '\n') { toDelete = count; count = 0; }
3768 else if(isspace(ch)) count++;
3771 f.Seek(-1, current);
3775 toDelete += count - 6;
3785 f.Seek(-toDelete-count, current);
3786 f.DeleteBytes(toDelete);
3787 f.Seek(count, current);
3792 for(c = 0; c<toAdd; c++)
3798 methodPresent = multiLine;
3801 f.Printf(methodPresent ? "\n " : " ");
3807 // Instance not there, create a brand new one
3808 DeleteJunkBefore(f, position, &position);
3809 f.Printf(*firstObject ? "\n\n" : "\n");
3810 *firstObject = false;
3812 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
3813 methodPresent = true;
3818 f.Printf(" %s %s\n %c\n ", control._class.name, object.name, OpenBracket);
3820 f.Printf(" %s\n %c\n ", control._class.name, OpenBracket);
3825 f.Printf(" %s %s %c ", control._class.name, object.name, OpenBracket);
3827 f.Printf(" %s %c ", control._class.name, OpenBracket);
3833 Instance test = eInstance_New(control._class);
3834 DataMember curMember = null;
3835 Class curClass = null;
3838 UpdateInstanceCodeClass(control._class, object, f, test, &prev, &lastIsMethod, &curMember, &curClass);
3842 // Attach Method here
3843 if((this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod) && !this.moveAttached && this.selected == object)
3845 if(prev) f.Printf(", ");
3846 f.Printf("%s = %s", this.method.name, function.declarator.symbol.string);
3851 if(inst && !object.deleted)
3853 MembersInit members;
3854 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3856 DeleteJunkBefore(f, position, &position);
3858 // Instance already there, clear out the properties
3859 for(members = inst.members->first; members; members = members.next)
3861 if(members.type == dataMembersInit)
3865 if(members.dataMembers)
3867 bool keptMember = false;
3868 MemberInit lastKept = null;
3870 for(member = members.dataMembers->first; member; member = member.next)
3872 Identifier ident = member.identifiers ? member.identifiers->first : null;
3873 bool deleted = false;
3875 // For now delete if it's not a method
3876 if(!member.variable) // && ident)
3878 if(!ident || !ident.next)
3880 Property prop = ident ? eClass_FindProperty(instClass, ident.string, this.privateModule) : null;
3883 f.Seek(member.loc.start.pos - position, current);
3884 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
3885 position = member.loc.end.pos;
3890 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3891 if(method && method.type == virtualMethod && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3892 member.initializer.exp.type == memberExp /*ExpIdentifier*/)
3894 if(((this.methodAction == actionDetachMethod || this.methodAction == actionReattachMethod) && this.method == method && this.selected == object) ||
3895 (this.methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, member.initializer.exp.identifier.string)))
3897 f.Seek(member.loc.start.pos - position, current);
3898 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
3899 position = member.loc.end.pos;
3911 //f.Seek(member.loc.start.pos - position, current);
3912 //position = member.loc.start.pos;
3913 DeleteJunkBefore(f, member.loc.start.pos, &position);
3914 if(prev) f.Printf(", ");
3915 else if(keptMember) f.Printf(" ");
3920 if(!keptMember || !members.next)
3925 if(keptMember && lastKept != members.dataMembers->last)
3930 f.Seek(-1, current);
3936 f.Seek(-1, current);
3939 else if(!isspace(ch))
3941 f.Seek(-2, current);
3946 f.DeleteBytes(count);
3949 f.Seek(members.loc.end.pos - position, current);
3954 f.Seek(-1, current);
3956 position = members.loc.end.pos + 1;
3960 f.Seek(-1, current);
3961 position = members.loc.end.pos;
3967 lastIsMethod = false;
3972 DeleteJunkBefore(f, position, &position);
3975 if(lastKept != members.dataMembers->last)
3980 f.Seek(-1, current);
3986 f.Seek(-1, current);
3989 else if(!isspace(ch))
3991 f.Seek(-2, current);
3996 f.DeleteBytes(count);
4000 f.Seek(members.loc.end.pos - position, current);
4001 position = members.loc.end.pos;
4005 lastIsMethod = true;
4008 lastIsMethod = false;
4014 f.Seek(members.loc.end.pos - position, current);
4015 position = members.loc.end.pos;
4017 lastIsMethod = true;
4020 else if(members.type == methodMembersInit)
4022 if(this.methodAction == actionDeleteMethod && members.function == function);
4024 methodPresent = true;
4026 // Delete instance method here
4027 if((this.methodAction == actionDeleteMethod || (this.methodAction == actionDetachMethod && this.moveAttached)) &&
4028 members.function == function)
4030 if(this.moveAttached && !*text)
4031 GetLocText(editBox, f, position, &function.loc, text, textSize, Max((int)strlen(this.methodName) - movedFuncIdLen,0), 0);
4033 DeleteJunkBefore(f, members.loc.start.pos, &position);
4034 f.DeleteBytes(members.loc.end.pos - members.loc.start.pos + 1);
4035 position = members.loc.end.pos + 1;
4040 DeleteJunkBefore(f, position, &position);
4044 DeleteJunkBefore(f, members.loc.start.pos, &position);
4045 lastIsMethod = true;
4049 f.Seek(members.loc.end.pos - position, current);
4050 position = members.loc.end.pos;
4052 DeleteJunkBefore(f, position, &position);
4061 if((this.methodAction == actionAddMethod || (this.moveAttached && (this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod))) && this.selected == object)
4063 Method method = this.method;
4064 DeleteJunkBefore(f, position, &position);
4070 if(!method.dataType)
4071 method.dataType = ProcessTypeString(method.dataTypeString, false);
4074 Type dataType = method.dataType;
4075 Type returnType = dataType.returnType;
4078 if(this.moveAttached)
4080 // Move function here:
4081 int newLen = strlen(method.name);
4086 GetLocText(editBox, f, position, &function.loc, text, textSize, Max(newLen - movedFuncIdLen, 0), 3);
4088 // First change name of function
4089 memmove(*text + movedFuncIdPos + newLen, *text + movedFuncIdPos + movedFuncIdLen, *textSize - movedFuncIdPos - movedFuncIdLen + 1);
4090 *textSize += newLen - movedFuncIdLen;
4091 memcpy(*text + movedFuncIdPos, method.name, newLen);
4093 // Second, tab right
4096 for(c = 0; (*text)[c]; )
4099 for(i = c; (*text)[i] && (*text)[i] != '\n'; i++);
4102 memmove((*text)+c+3, (*text)+c, *textSize+1-c);
4103 (*text)[c] = (*text)[c+1] = (*text)[c+2] = ' ';
4107 for(; (*text)[c] && (*text)[c] != '\n'; c++);
4117 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4119 // ADDING METHOD HERE
4121 OutputType(f, returnType, false);
4124 if(dataType.thisClass)
4126 if(!eClass_IsDerived(regClass, dataType.thisClass.registered) && !dataType.classObjectType) // Just fixed this... was backwards.
4128 if(dataType.thisClass.shortName)
4129 f.Printf(dataType.thisClass.shortName);
4131 f.Printf(dataType.thisClass.string);
4135 f.Printf(method.name);
4137 for(param = dataType.params.first; param; param = param.next)
4139 OutputType(f, param, true);
4144 f.Printf(" %c\n\n", OpenBracket);
4146 if(control._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4148 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4149 f.Printf(" return true;\n");
4150 else if(returnType.kind != voidType)
4151 f.Printf(" return 0;\n");
4156 if(returnType.kind != voidType)
4157 f.Printf("return ");
4158 f.Printf("%s::%s(", control._class.name, method.name);
4159 for(param = dataType.params.first; param; param = param.next)
4161 if(param.prev) f.Printf(", ");
4162 f.Printf(param.name);
4166 f.Printf(" %c\n", CloseBracket);
4172 if(!object.instCode)
4175 f.Printf(" %c;\n", CloseBracket);
4177 f.Printf("%c;\n", CloseBracket);
4179 else if(!object.deleted)
4181 // Turn this into a multiline instance when adding a method
4182 DeleteJunkBefore(f, inst.loc.end.pos-1, &position);
4184 f.Printf(methodPresent ? "\n " : " ");
4186 f.Seek(inst.loc.end.pos + 1 - position, current);
4187 position = inst.loc.end.pos + 1;
4192 void OutputClassProperties(Class _class, ObjectInfo classObject, EditBoxStream f, Instance test)
4195 Class regClass = eSystem_FindClass(privateModule, classObject.name);
4197 if(_class.base && _class.base.type != systemClass) OutputClassProperties(_class.base, classObject, f, test);
4199 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
4201 Property prop = eClass_FindProperty(selected.instance._class, propIt.name, privateModule);
4202 if(prop && prop.isProperty && !prop.conversion)
4204 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(classObject, prop.name) &&
4205 (!prop.IsSet || prop.IsSet(classObject.instance)))
4207 Class dataType = prop.dataTypeClass;
4208 char tempString[1024] = "";
4210 bool specify = false;
4213 member = eClass_FindDataMember(regClass, prop.name, privateModule, null, null);
4214 if(member && member._class == regClass)
4218 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
4220 if(dataType && dataType.type == structClass)
4222 void * dataForm = new0 byte[dataType.structSize];
4223 void * dataTest = new0 byte[dataType.structSize];
4225 prop.Get(classObject.instance, dataForm);
4226 prop.Get(test, dataTest);
4228 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
4230 bool needClass = true;
4232 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
4233 prop.Set(test, dataForm);
4235 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4237 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4242 else if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
4244 void * dataForm, * dataTest;
4246 dataForm = (void *)prop.Get(classObject.instance);
4247 dataTest = (void *)prop.Get(test);
4249 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
4251 char tempString[1024] = "";
4253 prop.Set(test, dataForm);
4255 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
4257 // Shouldn't go here ...
4258 f.Printf("\n %s%s = this;", specify ? "property::" : "", prop.name);
4262 bool needClass = true;
4264 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
4266 if(!strcmp(dataType.dataTypeString, "char *"))
4268 f.Printf("\n %s%s = \"", specify ? "property::" : "", prop.name);
4269 OutputString(f, string);
4273 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4275 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4281 DataValue dataForm, dataTest;
4283 GetProperty(prop, classObject.instance, &dataForm);
4284 GetProperty(prop, test, &dataTest);
4286 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
4288 SetProperty(prop, test, dataForm);
4289 if(dataType.type == bitClass)
4291 bool needClass = true;
4292 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, &dataForm, tempString, null, &needClass);
4294 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4296 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4300 bool needClass = true;
4301 if(dataType.type == enumClass)
4304 Class enumClass = eSystem_FindClass(privateModule, "enum");
4305 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
4307 for(value = e.values.first; value; value = value.next)
4309 if((int)value.data == dataForm.i)
4311 string = value.name;
4317 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, &dataForm, tempString, null, &needClass);
4318 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
4319 f.Printf("\n %s%s = %sf;", specify ? "property::" : "", prop.name, string);
4321 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4330 void UpdateFormCode()
4339 else if(formModified)
4341 EditBoxStream f { editBox = editBox };
4345 Identifier movedFuncId;
4346 int movedFuncIdLen = 0, movedFuncIdPos = 0;
4347 ObjectInfo classObject;
4353 movedFuncId = GetDeclId(function.declarator);
4354 movedFuncIdLen = movedFuncId.loc.end.pos - movedFuncId.loc.start.pos;
4355 movedFuncIdPos = movedFuncId.loc.start.pos - function.loc.start.pos;
4358 for(classObject = classes.first; classObject; classObject = classObject.next)
4361 ClassDefinition classDef = classObject.classDefinition;
4362 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
4365 bool firstObject = true;
4366 ObjectInfo object = classObject.instances.first;
4367 bool lastIsDecl = false;
4369 if(!classObject.modified) continue;
4371 test = eInstance_New(regClass);
4374 // Put it in the same desktop window...
4375 designer.PrepareTestObject(test);
4377 //f.Printf("class %s : %s\n", classObject.name, classObject.oClass.name);
4378 //f.Printf("%c\n\n", OpenBracket);
4380 // Change the _class name
4381 f.Seek(classDef.nameLoc.start.pos - position, current);
4382 f.DeleteBytes(classDef.nameLoc.end.pos - classDef.nameLoc.start.pos);
4383 f.Printf(classObject.name);
4384 position = classDef.nameLoc.end.pos;
4387 // Go to block start, delete all until no white space, put \n
4391 f.Seek(classDef.blockStart.end.pos - position, current);
4392 position = classDef.blockStart.end.pos;
4394 for(; f.Getc(&ch); count++)
4398 f.Seek(-1, current);
4408 f.Seek(-count, current);
4410 f.DeleteBytes(count-back);
4412 position += count-back;
4415 // Output properties
4416 OutputClassProperties(classObject.instance._class, classObject, f, test);
4418 for(def = classDef.definitions->first; def; def = def.next)
4422 case defaultPropertiesClassDef:
4424 bool keptMember = false;
4426 MemberInit lastKept = null;
4429 DeleteJunkBefore(f, def.loc.start.pos, &position);
4432 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4434 Identifier ident = propDef.identifiers->first;
4435 bool deleted = false;
4437 // For now delete if it's a prop
4438 if(!propDef.variable && ident)
4442 Property prop = eClass_FindProperty(regClass, ident.string, this.privateModule);
4445 f.Seek(propDef.loc.start.pos - position, current);
4446 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4447 position = propDef.loc.end.pos;
4452 Method method = eClass_FindMethod(regClass, ident.string, this.privateModule);
4453 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4455 if(((methodAction == actionDetachMethod || methodAction == actionReattachMethod) && method == this.method && selected == classObject) ||
4456 (methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string)))
4458 f.Seek(propDef.loc.start.pos - position, current);
4459 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4460 position = propDef.loc.end.pos;
4478 f.Seek(def.loc.end.pos - position - 1, current);
4483 f.Seek(-1, current);
4486 position = def.loc.end.pos;
4490 if(lastKept != def.defProperties->last)
4495 f.Seek(-1, current);
4501 f.Seek(-1, current);
4504 else if(!isspace(ch))
4506 f.Seek(-2, current);
4511 f.DeleteBytes(count);
4515 f.Seek(def.loc.end.pos - position, current);
4516 position = def.loc.end.pos;
4521 case declarationClassDef:
4523 Declaration decl = def.decl;
4525 if(decl.type == instDeclaration)
4527 if(def.object/* && ((ObjectInfo)def.object).modified*/)
4529 while(def.object && object != def.object)
4531 if(object /*&& ((ObjectInfo)def.object).modified*/)
4532 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4533 object = object.next;
4536 DeleteJunkBefore(f, def.loc.start.pos, &position);
4537 f.Printf(firstObject ? "\n\n " : "\n ");
4538 firstObject = false;
4540 if(def.object && ((ObjectInfo)def.object).modified)
4541 position = UpdateInstanceCode(f, position, regClass, def.object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4543 object = object ? object.next : null;
4547 DeleteJunkBefore(f, def.loc.start.pos, &position);
4548 f.Printf(firstObject ? "\n\n " : "\n ");
4549 firstObject = false;
4555 DeleteJunkBefore(f, def.loc.start.pos, &position);
4556 f.Printf(lastIsDecl ? "\n " : "\n\n ");
4561 case functionClassDef:
4563 // TESTING IF THIS IS GOOD ENOUGH FOR GENERATED FUNCTION...
4564 if(!def.function.body) continue;
4568 DeleteJunkBefore(f, def.loc.start.pos, &position);
4571 // Delete _class methods
4572 if((methodAction == actionDeleteMethod || (moveAttached && selected != classObject)) &&
4573 def.function == function)
4578 if(moveAttached && !text)
4580 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max((int)strlen(methodName) - movedFuncIdLen,0), 3);
4583 f.Seek(def.loc.end.pos - position, current);
4584 for(; f.Getc(&ch); count++)
4588 f.Seek(-1, current);
4592 f.Seek(def.loc.start.pos - def.loc.end.pos - count, current);
4594 f.DeleteBytes(def.loc.end.pos - def.loc.start.pos + count);
4595 position = def.loc.end.pos + count;
4598 // In case of detaching methods in the _class, simply rename the method
4599 if(methodAction == actionDetachMethod && moveAttached && selected == classObject && function == def.function)
4601 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4602 f.DeleteBytes(movedFuncIdLen);
4604 position = function.loc.start.pos + movedFuncIdPos + movedFuncIdLen;
4607 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && moveAttached &&
4608 function == def.function)
4610 // In case of attaching methods in the _class, simply rename the method
4611 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4612 position = function.loc.start.pos + movedFuncIdPos;
4613 f.DeleteBytes(movedFuncIdLen);
4614 if(method.dataType.thisClass)
4615 f.Printf("%s::", method.dataType.thisClass.string);
4616 f.Puts(method.name);
4617 position += movedFuncIdLen;
4622 DeleteJunkBefore(f, def.loc.start.pos, &position);
4623 if(def.type == memberAccessClassDef)
4626 firstObject = false;
4636 f.Seek(def.loc.end.pos - position, current);
4637 position = def.loc.end.pos;
4640 // Output attached methods
4641 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && !moveAttached)
4643 DeleteJunkBefore(f, position, &position);
4644 f.Printf("\n %s = %s;\n", method.name, function.declarator.symbol.string);
4647 // ********** INSTANCES ***************
4648 for(; object; object = object.next)
4650 if(!object.instCode)
4652 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4656 DeleteJunkBefore(f, position, &position);
4658 // ****************** METHODS ***********************
4659 if(methodAction == actionDetachMethod && moveAttached && classObject == oClass)
4661 // If detaching an instance method
4662 if(selected != classObject)
4664 int newLen = strlen(methodName);
4667 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max(newLen - movedFuncIdLen,0), 0);
4668 // Tab selection left
4671 for(c = 0; text[c]; )
4674 for(i = 0; i<3 && text[c] == ' '; i++, c++);
4675 memmove(text+start, text+start+i, textSize+1-start-i);
4678 for(; text[c] && text[c] != '\n'; c++);
4684 memmove(text + movedFuncIdPos + newLen, text + movedFuncIdPos + movedFuncIdLen, textSize - movedFuncIdPos - movedFuncIdLen + 1);
4685 textSize += newLen - movedFuncIdLen;
4686 memcpy(text + movedFuncIdPos, methodName, newLen);
4693 if(methodAction == actionAddMethod && selected == classObject)
4695 Method method = this.method;
4697 if(!method.dataType)
4698 method.dataType = ProcessTypeString(method.dataTypeString, false);
4700 // ADDING METHOD HERE
4702 Type dataType = method.dataType;
4703 Type returnType = dataType.returnType;
4705 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4709 OutputType(f, returnType, false);
4712 if(dataType.thisClass && !dataType.classObjectType)
4714 if(dataType.thisClass.shortName)
4715 f.Printf(dataType.thisClass.shortName);
4717 f.Printf(dataType.thisClass.string);
4720 f.Printf(method.name);
4722 for(param = dataType.params.first; param; param = param.next)
4724 OutputType(f, param, true);
4729 f.Printf(" %c\n\n", OpenBracket);
4731 if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4733 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4734 f.Printf(" return true;\n");
4735 else if(returnType && returnType.kind != voidType)
4736 f.Printf(" return 0;\n");
4741 if(returnType.kind != voidType)
4742 f.Printf("return ");
4744 char * name = ((Specifier)classDef.baseSpecs->first).name;
4745 Symbol _class = FindClass(name);
4746 f.Printf("%s::%s(", (_class && _class.registered) ? _class.registered.name : name, method.name);
4748 for(param = dataType.params.first; param; param = param.next)
4750 if(param.prev) f.Printf(", ");
4751 if(param.kind != voidType)
4752 f.Printf(param.name);
4757 f.Printf(" %c", CloseBracket);
4761 DeleteJunkBefore(f, classDef.loc.end.pos-1, &position);
4773 // TOFIX: Patch for a glitch where clicking at the end of the view seems one line off. No idea what could be going on?
4774 editBox.OnVScroll(setRange, editBox.scroll.y, 0);
4778 codeModified = false;
4779 formModified = false;
4781 moveAttached = false;
4786 int FindMethod(char * methodName /*Method method*/, ClassFunction*functionPtr, Location propLoc)
4789 ClassFunction function = null;
4792 ObjectInfo object = this.selected;
4794 if(object && object == this.oClass)
4796 ClassDefinition classDef = object.oClass.classDefinition;
4798 if(classDef && classDef.definitions)
4800 for(def = classDef.definitions->first; def; def = def.next)
4802 if(def.type == functionClassDef && def.function.declarator)
4804 if(!strcmp(def.function.declarator.symbol.string, methodName))
4806 function = def.function;
4811 else if(def.type == defaultPropertiesClassDef)
4815 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4817 Identifier ident = propDef.identifiers ? propDef.identifiers->first : null;
4818 if(ident && !ident.next)
4820 if(!strcmp(ident.string, methodName) && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4824 propLoc = propDef.loc;
4827 ClassDefinition classDef = object.oClass.classDefinition;
4829 if(classDef.definitions)
4831 for(def = classDef.definitions->first; def; def = def.next)
4833 if(def.type == functionClassDef)
4835 if(!strcmp(def.function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
4837 function = def.function;
4856 Instantiation inst = object.instCode;
4858 // Check here to see if the method already exists, no need to call ModifyCode in that case
4859 if(inst && inst.members)
4861 MembersInit members;
4862 for(members = inst.members->first; members; members = members.next)
4864 switch(members.type)
4866 case dataMembersInit:
4868 if(members.dataMembers)
4871 for(member = members.dataMembers->first; member; member = member.next)
4873 Identifier ident = member.identifiers ? member.identifiers->first : null;
4874 if(ident && !ident.next)
4876 if(!strcmp(ident.string, methodName) && member.initializer && member.initializer.type == expInitializer && member.initializer.exp && member.initializer.exp.type == memberExp /*ExpIdentifier*/)
4880 propLoc = member.loc;
4883 ClassDefinition classDef = object.oClass.classDefinition;
4885 if(classDef.definitions)
4887 for(def = classDef.definitions->first; def; def = def.next)
4889 if(def.type == functionClassDef)
4891 if(def.function.declarator && !strcmp(def.function.declarator.symbol.string, member.initializer.exp.identifier.string))
4893 function = def.function;
4902 // TODO: Fix memory leak
4903 function = ClassFunction
4905 declarator = Declarator { symbol = Symbol { string = CopyString(member.initializer.exp.member.member ? member.initializer.exp.member.member.string : "") } }
4917 case methodMembersInit:
4919 if(members.function.declarator && !strcmp(members.function.declarator.symbol.string, methodName))
4921 function = members.function;
4933 if(functionPtr) *functionPtr = function;
4937 void GoToMethod(char * methodName /*Method method*/)
4941 ObjectInfo object = selected;
4942 EditBoxStream f { editBox = editBox };
4943 ClassFunction function = null;
4944 bool atChar = false;
4948 Location propLoc = { {0,0,-1} };
4951 if(FindMethod(methodName, &function, &propLoc) == 1 && object != this.oClass) indent = 9;
4952 if(function && function.body)
4955 f.Seek(function.body.loc.start.pos+1, current);
4965 f.Seek(-1, current);
4970 else if(!isspace(ch))
4972 f.Seek(-1, current);
4978 else if(propLoc.start.pos > -1)
4980 f.Seek(propLoc.start.pos, current);
4983 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
4985 if(function || propLoc.start.pos > -1)
4987 editBox.SetSelPos(l1, y1, atChar ? x1 : indent, l2, y2, atChar ? x2 : indent);
4988 editBox.CenterOnCursor();
4989 SetState(normal, false, 0);
4992 if(function && function.declarator && function.declarator.symbol && !function.declarator.symbol.type)
4994 FreeClassFunction(function);
5000 void FindCompatibleMethods(Method method, OldList compatible)
5002 ClassDefinition classDef = this.oClass.classDefinition;
5003 if(classDef && classDef.definitions)
5006 Class baseClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5009 Symbol classSym { };
5010 Symbol selectedClass;
5011 if(this.selected == this.oClass)
5012 selectedClass = classSym;
5014 selectedClass = FindClass(this.selected.instance._class.name);
5016 regClass.name = classDef._class.name;
5017 regClass.base = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5018 for(def = classDef.definitions->first; def; def = def.next)
5020 if(def.type == functionClassDef && def.function.declarator)
5022 Method vMethod = eClass_FindMethod(baseClass, def.function.declarator.symbol.string, this.privateModule);
5024 vMethod = eClass_FindMethod(this.selected.instance._class, def.function.declarator.symbol.string, this.privateModule);
5027 Type type = def.function.declarator.symbol.type;
5028 if(CheckCompatibleMethod(method, type, regClass, this.selected == this.oClass, FindClass(this.selected.instance._class.name)))
5030 compatible.Add(OldLink { data = def.function });
5036 if(this.oClass && this.oClass.instance)
5038 classSym.registered = regClass;
5039 //classSym.registered = this.oClass.oClass;
5041 for(_class = regClass.base; _class; _class = _class.base)
5044 for(testMethod = (Method)_class.methods.first; testMethod; testMethod = (Method)((BTNode)testMethod).next)
5046 // TODO: Understand why these functions popup in attach list
5047 if(testMethod.type != virtualMethod /*&& testMethod.function != Window_OnGetString && testMethod.function != Window_OnGetDataFromString*/)
5049 if(!testMethod.dataType)
5050 testMethod.dataType = ProcessTypeString(testMethod.dataTypeString, false);
5052 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5053 if(CheckCompatibleMethod(method, testMethod.dataType, this.oClass.instance._class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5054 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, this.selected == this.oClass, FindClass(this.oClass.oClass.name)))
5056 // TODO: Fix memory leak, Figure out if it should be ClassFunction or FunctionDefinition
5057 // ClassFunction function { };
5058 FunctionDefinition function { };
5060 function.declarator = Declarator { };
5061 function.declarator.symbol = Symbol { string = CopyString(testMethod.name) };
5062 excludedSymbols.Add(function.declarator.symbol);
5064 compatible.Add(OldLink { data = function });
5075 void AddMethod(Method method)
5079 char methodName[1024];
5080 strcpy(methodName, method.name);
5081 if(!FindMethod(methodName, null, null))
5083 methodAction = actionAddMethod;
5084 this.method = method;
5088 GoToMethod(methodName);
5092 void DeleteMethod(ClassFunction function)
5096 methodAction = actionDeleteMethod;
5097 this.function = function;
5105 void AttachMethod(Method method, ClassFunction function)
5109 // If it's an instance we'll ask if we want to move it inside...
5110 if(!function.attached.count && function.body)
5112 // Find the function in the _class to check if it's a virtual function
5113 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5114 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5115 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5117 for(def = this.classDefinition.first; def; def = def.next)
5119 if(def.type == functionClassDef)
5121 if(def.function == function)
5126 if(!method || method.type != virtualMethod)
5129 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5130 if(MessageBox { type = yesNo, master = parent, text = title, contents = $"Method is unused. Move method inside instance?"}.Modal() == yes)
5132 moveAttached = true;
5137 methodAction = actionAttachMethod;
5138 this.method = method;
5139 this.function = function;
5146 void ReAttachMethod(Method method, ClassFunction function)
5150 // If it's an instance we'll ask if we want to move it inside...
5151 if(!function.attached.count && function.body)
5153 // Find the function in the _class to check if it's a virtual function
5154 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5155 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5156 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5158 for(def = this.classDefinition.first; def; def = def.next)
5160 if(def.type == functionClassDef)
5162 if(def.function == function)
5167 if(!method || method.type != virtualMethod)
5170 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5171 if(MessageBox { type = yesNo, master = parent, text = title,
5172 contents = $"Method is unused. Move method inside instance?" }.Modal() == yes)
5174 moveAttached = true;
5179 methodAction = actionReattachMethod;
5180 this.method = method;
5181 this.function = function;
5188 void DetachMethod(Method method, ClassFunction function, int type)
5196 hasClose = true, borderStyle = sizable, minClientSize = { 300, 55 },
5197 master = sheet, text = $"Name detached method", background = activeBorder
5201 dialog, anchor = { horz = 45, top = 30 }, size = { 80 }, text = $"Cancel", hotKey = escape,
5202 id = DialogResult::cancel, NotifyClicked = ButtonCloseDialog
5206 dialog, anchor = { horz = -45, top = 30 }, size = { 80 }, text = $"OK", isDefault = true,
5207 id = DialogResult::ok, NotifyClicked = ButtonCloseDialog
5211 dialog, anchor = { left = 5, right = 5, top = 5 }
5213 sprintf(methodName, "%s_%s", selected.name, method.name);
5214 nameBox.contents = methodName;
5216 result = dialog.Modal() == ok;
5217 strcpy(methodName, nameBox.contents);
5222 // If the method is not attached, move it outside
5225 // Add this class to the methodName
5226 char name[1024] = "";
5228 if(this.selected != this.oClass && !method.dataType.thisClass)
5230 strcat(name, this.selected.instance._class.name);
5232 strcat(name, this.methodName);
5233 strcpy(this.methodName, name);
5235 else if(method.dataType.thisClass && (this.selected == this.oClass || !eClass_IsDerived(this.oClass.instance._class, method.dataType.thisClass.registered)))
5237 strcat(name, method.dataType.thisClass.string);
5239 strcat(name, this.methodName);
5240 strcpy(this.methodName, name);
5243 this.moveAttached = true;
5246 this.methodAction = actionDetachMethod;
5247 this.method = method;
5248 this.function = function;
5255 void AddObject(Instance instance, ObjectInfo * object)
5259 //*object = _class.instances.Add(sizeof(ObjectInfo));
5260 *object = ObjectInfo { };
5261 oClass.instances.Insert((selected.oClass == selected) ? null : selected, *object);
5262 (*object).oClass = oClass;
5263 (*object).instance = instance;
5268 sprintf(name, "%c%s%d", tolower(instance._class.name[0]), instance._class.name+1, id);
5270 // if(strcmp(name, this.oClass.instance.name))
5273 for(check = oClass.instances.first; check; check = check.next)
5274 if(!check.deleted && check.name && !strcmp(name, check.name))
5278 (*object).name = CopyString(name);
5283 toolBox.controlClass = null;
5287 //sheet.AddObject(*object, (*object).name, TypeData, true);
5292 void EnsureUpToDate()
5294 if(sheet && codeModified)
5298 void SelectObject(ObjectInfo object)
5301 oClass = object ? object.oClass : null;
5303 designer.SelectObject(object, object ? object.instance : null);
5306 void SelectObjectFromDesigner(ObjectInfo object)
5309 sheet.SelectObject(object);
5312 void EnumerateObjects(Sheet sheet)
5316 for(oClass = classes.first; oClass; oClass = oClass.next)
5320 sheet.AddObject(oClass, oClass.name ? oClass.name : oClass.instance._class.name, typeClass, false);
5321 for(object = oClass.instances.first; object; object = object.next)
5322 sheet.AddObject(object, object.name ? object.name : object.instance._class.name, typeData, false);
5324 sheet.SelectObject(selected);
5329 designer.AddObject();
5332 void DeleteObject(ObjectInfo object)
5334 delete object.instance;
5335 object.deleted = true;
5336 object.modified = true;
5337 object.oClass.modified = true;
5339 if(selected == object)
5341 bool looped = false;
5342 ObjectInfo select = object;
5346 select = select.prev;
5350 select = object.oClass.instances.last;
5357 sheet.SelectObject(select ? select : oClass);
5360 if(!object.instCode && object.oClass != object)
5363 oClass.instances.Delete(object);
5366 if(sheet.codeEditor == this)
5367 sheet.DeleteObject(object);
5370 void RenameObject(ObjectInfo object, char * name)
5374 // Validate the name:
5375 if(object != oClass && (!name || !name[0])) valid = true; // What's this one again?
5376 else if(name[0] && (isalpha(name[0]) || name[0] == '_'))
5379 for(c = 0; name[c]; c++)
5380 if(!isalnum(name[c]) && name[c] != '_' && name[c] != '_')
5388 object.name = (name && name[0]) ? CopyString(name) : null;
5390 sheet.RenameObject(object, object.name ? object.name : object.instance._class.name);
5394 void DesignerModifiedObject()
5396 sheet.ListProperties(false);
5400 void ListSubMembers(Type member)
5404 for(subMember = member.members.first; subMember; subMember = subMember.next)
5408 DataRow row = membersList.AddString(subMember.name);
5409 row.icon = icons[typeData];
5413 ListSubMembers(subMember);
5418 void ListSubDataMembers(DataMember member, bool isPrivate)
5420 DataMember subMember;
5421 for(subMember = member.members.first; subMember; subMember = subMember.next)
5423 if((subMember.memberAccess == publicAccess && !isPrivate) || subMember._class.module == privateModule)
5427 DataRow row = membersList.AddString(subMember.name);
5428 BitmapResource bitmap = null;
5429 if(!subMember.dataType)
5430 subMember.dataType = ProcessTypeString(subMember.dataTypeString, false);
5432 if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
5434 char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
5437 bitmap = { bitmapName };
5438 membersList.AddResource(bitmap);
5441 row.icon = bitmap ? bitmap : icons[(subMember.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5445 ListSubDataMembers(subMember, isPrivate || member.memberAccess == privateAccess);
5451 void ListClassMembers(Class whatClass, bool methodsOnly)
5454 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5455 bool isPrivate = false;
5457 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5459 Method method, methodIt;
5461 DataMember memberIt;
5463 for(methodIt = (Method)_class.methods.first; methodIt; methodIt = (Method)((BTNode)methodIt).next)
5465 method = eClass_FindMethod(whatClass, methodIt.name, privateModule);
5466 if(methodIt.memberAccess == privateAccess && method && method.memberAccess == publicAccess)
5468 if(method && method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5470 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5472 DataRow row = membersList.FindString(method.name);
5475 row = membersList.AddString(method.name);
5477 if(!method.dataType)
5478 method.dataType = ProcessTypeString(method.dataTypeString, false);
5480 row.icon = icons[(method.type == virtualMethod && method.dataType && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5488 for(memberIt = _class.membersAndProperties.first; memberIt; memberIt = memberIt.next)
5492 if(memberIt.isProperty)
5494 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5496 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5500 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5502 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5505 if(memberIt.memberAccess == privateAccess && member && member.memberAccess == publicAccess)
5511 if(member && (member.memberAccess == publicAccess || member._class.module == privateModule))
5513 if(member.isProperty)
5515 Property prop = (Property) member;
5516 if(!membersList.FindString(prop.name))
5518 DataRow row = membersList.AddString(prop.name);
5519 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5522 else if(member.name && !membersList.FindString(member.name))
5524 DataRow row = membersList.AddString(member.name);
5526 BitmapResource bitmap = null;
5527 if(!member.dataType)
5528 member.dataType = ProcessTypeString(member.dataTypeString, false);
5530 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5532 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5535 bitmap = { bitmapName };
5536 membersList.AddResource(bitmap);
5539 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5542 ListSubDataMembers(member, member.memberAccess == privateAccess);
5546 if(_class.inheritanceAccess == privateAccess)
5549 if(_class.module != privateModule) break;
5554 void ListClassMembersMatch(Class whatClass, Type methodType)
5557 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5558 bool isPrivate = false;
5560 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5566 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5568 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5570 if(method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5572 if(!method.dataType)
5573 method.dataType = ProcessTypeString(method.dataTypeString, false);
5575 if(MatchTypes(method.dataType, methodType, null, whatClass, /*null, */whatClass, false, true, false, false))
5577 DataRow row = membersList.FindString(method.name);
5580 row = membersList.AddString(method.name);
5581 row.icon = icons[(method.type == virtualMethod && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5587 if(_class.inheritanceAccess == privateAccess)
5590 if(_class.module != privateModule) break;
5595 void ListClassPropertiesAndVirtual(Class whatClass)
5598 bool isPrivate = false;
5599 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5605 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5607 if(method.type == virtualMethod)
5609 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5611 DataRow row = membersList.FindString(method.name);
5614 row = membersList.AddString(method.name);
5616 if(!method.dataType)
5617 method.dataType = ProcessTypeString(method.dataTypeString, false);
5619 row.icon = icons[method.dataType.thisClass ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5625 for(member = _class.membersAndProperties.first; member; member = member.next)
5627 if(member.memberAccess == publicAccess || member._class.module == privateModule)
5629 if(member.isProperty)
5631 Property prop = (Property)member;
5633 DataRow row = membersList.AddString(prop.name);
5634 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5637 else if(member.name)
5639 DataRow row = membersList.AddString(member.name);
5641 BitmapResource bitmap = null;
5642 if(!member.dataType)
5643 member.dataType = ProcessTypeString(member.dataTypeString, false);
5645 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5647 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5650 bitmap = { bitmapName };
5651 membersList.AddResource(bitmap);
5654 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5657 ListSubDataMembers(member, member.memberAccess == privateAccess || isPrivate);
5660 if(_class.inheritanceAccess == privateAccess)
5663 if(_class.module != privateModule) break;
5668 void ListMembers(Type type)
5670 if(type && (type.kind == classType || type.kind == structType || type.kind == unionType))
5674 if(type.kind == classType)
5677 ListClassMembers(type._class.registered, false);
5682 for(member = type.members.first; member; member = member.next)
5686 DataRow row = membersList.AddString(member.name);
5687 row.icon = icons[typeData];
5689 else if(member.kind == structType || member.kind == unionType)
5690 ListSubMembers(member);
5696 void ListModule(Module mainModule, int recurse, bool listClasses)
5699 ListNameSpace(mainModule.application.systemNameSpace, 1, listClasses);
5700 ListNameSpace(mainModule.application.privateNameSpace, 1, listClasses);
5701 ListNameSpace(mainModule.application.publicNameSpace, 1, listClasses);
5702 for(module = mainModule.application.allModules.first; module; module = module.next)
5704 if(ModuleVisibility(mainModule, module))
5705 ListNameSpace(module.publicNameSpace, recurse, listClasses);
5709 void ListNameSpace(NameSpace nameSpace, int recurse, bool listClasses)
5716 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5718 Class _class = link.data;
5719 if(_class.type != systemClass)
5721 DataRow row = membersList.AddString(_class.name);
5722 row.icon = (_class.type == unitClass || _class.type == enumClass) ? icons[typeDataType] : icons[typeClass];
5727 for(link = (BTNamedLink)nameSpace.defines.first; link; link = (BTNamedLink)((BTNode)link).next )
5729 DefinedExpression definedExp = link.data;
5730 DataRow row = membersList.AddString(link /*definedExp*/.name);
5731 row.icon = icons[typeData];
5734 for(link = (BTNamedLink)nameSpace.functions.first; link; link = (BTNamedLink)((BTNode)link).next)
5736 GlobalFunction function = link.data;
5737 DataRow row = membersList.AddString(link /*function*/.name);
5738 row.icon = icons[typeMethod];
5742 for(ns = (NameSpace *)nameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
5744 if(recurse != 2 && listClasses)
5746 if(!membersList.FindString(ns->name))
5748 DataRow row = membersList.AddString(ns->name);
5749 row.icon = icons[typeNameSpace];
5754 ListNameSpace(ns, 2, listClasses);
5758 void ListEnumValues(Class _class)
5760 for(; _class && _class.type == enumClass; _class = _class.base)
5762 EnumClassData enumeration = (EnumClassData)_class.data;
5764 for(item = enumeration.values.first; item; item = item.next)
5766 DataRow row = membersList.AddString(item.name);
5767 row.icon = icons[typeEnumValue];
5772 bool ListEnumsModule(Module mainModule, Type dest)
5774 bool result = false;
5776 result |= ListEnums(mainModule.application.systemNameSpace, dest);
5777 result |= ListEnums(mainModule.application.privateNameSpace, dest);
5778 result |= ListEnums(mainModule.application.publicNameSpace, dest);
5779 for(module = mainModule.application.allModules.first; module; module = module.next)
5781 if(ModuleVisibility(mainModule, module))
5782 result |= ListEnums(module.publicNameSpace, dest);
5787 void ListNameSpaceByString(Module mainModule, char * string)
5789 NameSpace * nameSpace;
5791 nameSpace = FindNameSpace(mainModule.application.systemNameSpace, string);
5792 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5793 nameSpace = FindNameSpace(mainModule.application.privateNameSpace, string);
5794 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5795 nameSpace = FindNameSpace(mainModule.application.publicNameSpace, string);
5796 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5797 for(module = mainModule.application.allModules.first; module; module = module.next)
5799 if(ModuleVisibility(mainModule, module))
5801 nameSpace = FindNameSpace(module.publicNameSpace, string);
5802 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5807 bool ListEnums(NameSpace nameSpace, Type dest)
5810 bool result = false;
5812 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5814 Class _class = link.data;
5815 if(_class.type == enumClass && (dest.kind != classType || !dest._class || dest._class.registered != _class))
5817 OldList conversions { };
5819 type.kind = classType;
5820 type._class = FindClass(_class.name);
5821 if(MatchTypes(type, dest, &conversions, null, null, true, false, false, false))
5823 ListEnumValues(_class);
5826 conversions.Free(null);
5830 for(nameSpace = (NameSpace *)nameSpace.nameSpaces.first; nameSpace != null; nameSpace = (NameSpace *)((BTNode)nameSpace).next)
5832 result |= ListEnums(nameSpace, dest);
5837 NameSpace * FindNameSpace(NameSpace nameSpace, char * name)
5841 for(c = 0; (ch = name[c]); c++)
5843 if(ch == '.' || (ch == ':' && name[c+1] == ':'))
5845 NameSpace * newSpace;
5846 char * spaceName = new char[c - start + 1];
5847 memcpy(spaceName, name + start, c - start);
5848 spaceName[c-start] = '\0';
5849 newSpace = (NameSpace *)nameSpace.nameSpaces.FindString(spaceName);
5853 nameSpace = newSpace;
5862 return (NameSpace *)nameSpace;
5865 void ListSymbols(Expression exp, bool enumOnly, char * string, Identifier realIdentifier)
5867 bool listedEnums = false;
5868 Type destType = (exp && exp.destType && !exp.destType.truth) ? exp.destType : null;
5869 bool listClasses = true;
5871 if(exp && (exp.type == identifierExp || exp.type == memberExp))
5873 // TOCHECK: This memberExp check wasn't here... Some stuff isn't quite done
5874 Identifier id = (exp.type == memberExp) ? exp.member.member : exp.identifier;
5875 char * colons = id ? RSearchString(id.string, "::", strlen(id.string), true, false) : null;
5877 if(exp.type == identifierExp)
5878 id = realIdentifier;
5880 if(id && id._class && !id._class.name)
5882 listClasses = false;
5885 else if(id && id._class && id._class.name)
5889 Class _class = id.classSym.registered;
5890 if(_class && _class.type == enumClass)
5892 ListEnumValues(_class);
5895 ListClassMembers(id.classSym.registered, true);
5900 else if(id && colons)
5902 ListNameSpaceByString(this.privateModule, id.string);
5907 if(this.privateModule && destType && (destType.kind != pointerType || destType.type.kind != voidType) && destType.kind != ellipsisType)
5909 listedEnums = ListEnumsModule(this.privateModule, destType);
5912 if(destType && destType.kind == classType && destType._class.registered && destType._class.registered.type == enumClass)
5914 ListEnumValues(destType._class.registered);
5917 ListClassPropertiesAndVirtual(insideClass);
5921 else if(destType && destType.kind == enumType)
5925 for(value = destType.members.first; value; value = value.next)
5927 DataRow row = membersList.AddString(value.name);
5928 row.icon = icons[typeEnumValue];
5932 ListClassPropertiesAndVirtual(insideClass);
5936 else if(insideClass && !enumOnly)
5938 ListClassPropertiesAndVirtual(insideClass);
5941 if(listedEnums && string && string[0])
5943 DataRow row = membersList.FindSubString(string);
5945 listedEnums = false;
5948 if(!insideClass && exp && exp.destType && exp.destType.kind == functionType && GetThisClass())
5950 ListClassMembersMatch(GetThisClass(), exp.destType);
5952 else if(!insideClass && !enumOnly && !listedEnums)
5955 Symbol symbol = null;
5959 ListClassMembers(GetThisClass(), false);
5962 for(ctx = listClasses ? GetCurrentContext() : GetTopContext(); ctx != GetTopContext().parent && !symbol; ctx = ctx.parent)
5964 for(symbol = (Symbol)ctx.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
5966 // Don't list enum values?
5967 //if(symbol.type.kind != TypeEnum)
5968 DataRow row = membersList.FindString(symbol.string);
5971 if(GetBuildingEcereComModule() && symbol.type && symbol.type.kind == functionType && eSystem_FindFunction(privateModule, symbol.string))
5973 row = membersList.AddString(symbol.string);
5974 if(symbol.type && symbol.type.kind == functionType)
5975 row.icon = icons[typeMethod];
5976 else if(symbol.type && symbol.type.kind == enumType)
5978 row.icon = icons[typeEnumValue];
5982 BitmapResource bitmap = null;
5983 if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
5985 char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
5988 bitmap = { bitmapName };
5989 membersList.AddResource(bitmap);
5992 row.icon = bitmap ? bitmap : icons[typeData];
5999 for(symbol = (Symbol)ctx.types.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6001 DataRow row = membersList.FindString(symbol.string);
6004 row = membersList.AddString(symbol.string);
6005 if(symbol.type.kind == functionType)
6006 row.icon = icons[typeMethod];
6007 else if(symbol.type.kind == classType && (!symbol.type._class.registered || (symbol.type._class.registered.type != unitClass && symbol.type._class.registered.type != enumClass)))
6009 row.icon = icons[typeClass];
6013 row.icon = icons[typeDataType];
6020 ListModule(this.privateModule, 1, listClasses);
6021 // TODO: Implement this with name space
6025 for(data = globalData.first; data; data = data.next)
6027 DataRow row = membersList.FindString(data.name);
6029 data.dataType = ProcessTypeString(data.dataTypeString, false);
6032 row = membersList.AddString(data.name);
6034 if(data.dataType && data.dataType.kind == TypeEnum)
6036 row.icon = icons[typeEnumValue];
6040 BitmapResource bitmap = null;
6041 if(data.dataType && data.dataType.kind == classType && data.dataType._class && data.dataType._class)
6043 char * bitmapName = (char *)eClass_GetProperty(data.dataType._class.registered, "icon");
6046 bitmap = { bitmapName };
6047 membersList.AddResource(bitmap);
6050 row.icon = bitmap ? bitmap : icons[typeData];
6058 DataRow row = membersList.AddString("Min");
6059 row.icon = icons[typeMethod];
6061 row = membersList.AddString("Max");
6062 row.icon = icons[typeMethod];
6064 row = membersList.AddString("Abs");
6065 row.icon = icons[typeMethod];
6067 row = membersList.AddString("Sgn");
6068 row.icon = icons[typeMethod];
6074 void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
6076 EditBoxStream f { editBox = editBox };
6081 updatingCode = true;
6083 if(!method.dataType)
6084 method.dataType = ProcessTypeString(method.dataTypeString, false);
6086 DeleteJunkBefore(f, function.loc.start.pos, &position);
6087 f.DeleteBytes(function.loc.end.pos - function.loc.start.pos - 1);
6089 // ADDING METHOD HERE
6091 Type dataType = method.dataType;
6092 Type returnType = dataType.returnType;
6094 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
6100 if(extraIndent) f.Printf(" ");
6102 OutputType(f, returnType, false);
6106 if(dataType.thisClass && !dataType.classObjectType && (!isInstance || !insideClass || !eClass_IsDerived(insideClass, dataType.thisClass.registered)))
6108 if(dataType.thisClass.shortName)
6109 f.Printf(dataType.thisClass.shortName);
6111 f.Printf(dataType.thisClass.string);
6114 f.Printf(method.name);
6116 for(param = dataType.params.first; param; param = param.next)
6118 // Decided not to write void...
6119 if(param.kind != voidType)
6121 OutputType(f, param, true);
6127 if(extraIndent) f.Printf(" ");
6128 f.Printf(" %c\n", OpenBracket);
6130 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6134 //if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
6136 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
6138 if(extraIndent) f.Printf(" ");
6139 f.Printf(" return true;\n");
6141 else if(returnType && returnType.kind != voidType)
6143 if(extraIndent) f.Printf(" ");
6144 f.Printf(" return 0;\n");
6150 if(returnType.kind != voidType)
6151 f.Printf("return ");
6152 f.Printf("%s::%s(this", classDef.base.name, method.name);
6153 for(param = dataType.params.first; param; param = param.next)
6156 f.Printf(param.name);
6163 if(extraIndent) f.Printf(" ");
6164 f.Printf(" %c", CloseBracket);
6169 if(extraIndent) { x1 += 3; x2 += 3; }
6170 editBox.SetSelPos(l1, y1, x1 + 6, l2, y2, x2 + 6);
6172 this.updatingCode = false;
6176 // Return false if we overrided a function and don't want to run params listing
6177 bool InvokeAutoComplete(bool enumOnly, int pointer, bool caretMove)
6179 bool didOverride = false;
6180 EditLine line = editBox.line;
6181 char * text = line.text;
6182 int lineNum, charPos;
6183 Expression exp = null;
6186 //Identifier id = null;
6187 Expression memberExp = null;
6188 Identifier realIdentifier = null;
6190 if(!privateModule) return !didOverride;
6192 insideFunction = null;
6194 charPos = editBox.charPos + 1;
6195 if(!membersListShown)
6200 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6202 EditBoxStream f { editBox = editBox };
6204 updatingCode = true;
6205 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6209 if(!f.Seek(-1, current))
6212 if(!isspace(ch)) break;
6213 f.Seek(-1, current);
6215 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6217 lineNum = editBox.lineNumber + 1;
6218 charPos = editBox.charPos + 1;
6220 updatingCode = false;
6223 if(!membersListShown)
6225 memberExp = FindExpTree(ast, lineNum, charPos);
6226 if(memberExp && (memberExp.type == TypeKind::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6231 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6233 EditBoxStream f { editBox = editBox };
6236 updatingCode = true;
6238 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6241 if(ch == '}' || ch == ',' || ch == ')')
6243 f.Seek(-1, current);
6251 if(!f.Seek(-1, current))
6254 if(!isspace(ch)) break;
6255 f.Seek(-1, current);
6259 f.Seek(-1, current);
6261 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6263 lineNum = editBox.lineNumber + 1;
6264 charPos = editBox.charPos + 1;
6266 updatingCode = false;
6269 realIdentifier = FindCtxTree(ast, lineNum, charPos);
6274 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6275 lineNum = editBox.lineNumber + 1;
6276 charPos = editBox.charPos/* + 1*/;
6280 char tempString[1024];
6281 char * string = null;
6282 CodePosition idStart, idEnd;
6284 if(membersListShown)
6286 char * buffer = membersLine.text;
6288 bool firstChar = true;
6290 string = tempString;
6292 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
6294 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6295 if(!isSpace) firstChar = false;
6297 string[len++] = buffer[c];
6301 else //if(realIdentifier)//if(id)
6304 char * buffer = id.string;
6306 bool firstChar = true;
6308 string = tempString;
6309 for(c = 0; c<= charPos - id.loc.start.charPos; c++)
6311 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6312 if(!isSpace) firstChar = false;
6314 string[len++] = buffer[c];
6320 EditLine editLine = editBox.line;
6321 bool firstChar = true;
6324 string = tempString;
6325 for(y = lineNum-1; y >= 0; y--)
6327 char * buffer = editLine.text;
6328 int lineCount = editLine.count;
6329 for(x = (y == lineNum-1) ? (Min(charPos, lineCount) - 1 ): lineCount-1; x >= 0; x--)
6331 bool isSpace = (buffer[x] == ' ' || buffer[x] == '\t');
6336 idEnd.charPos = x + 2;
6341 // TESTING THIS CODE HERE FOR NOT CONSIDERING bool when doing ctrl-space past it
6344 idEnd.charPos = x + 2;
6351 if(!isalnum(buffer[x]) && buffer[x] != '_')
6357 memmove(string+1, string, len++);
6358 string[0] = buffer[x];
6362 //if(done || firstChar)
6363 if(done || !firstChar)
6365 editLine = editLine.prev;
6368 if(!strcmp(string, "case"))
6374 else if(!strcmp(string, "return"))
6380 else if(!strcmp(string, "delete"))
6386 else if(!strcmp(string, "new"))
6392 else if(!strcmp(string, "renew"))
6400 idStart.charPos = x + 1;
6401 idStart.line = y + 1;
6404 if(!membersListShown)
6406 membersList.Clear();
6407 if(memberExp && (memberExp.type == ExpressionType::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6409 Type type = memberExp.member.exp.expType;
6410 if(pointer == 2 && type)
6412 if(type.kind == pointerType || type.kind == arrayType)
6421 ListSymbols(exp, enumOnly, string, realIdentifier);
6423 membersList.Sort(null, 1);
6428 // Virtual function override
6429 Identifier id = GetDeclId(insideFunction.declarator);
6430 char * string = id ? id.string : null;
6432 Method method = eClass_FindMethod(GetThisClass(), string, this.privateModule);
6435 if(method.type != virtualMethod || (!insideInstance && method._class == GetThisClass()))
6436 insideFunction = null;
6439 OverrideVirtualFunction(insideFunction, method, GetThisClass(), insideInstance, insideInstance && insideClass);
6444 if(!didOverride) //insideFunction)
6446 rowCount = membersList.rowCount;
6449 DataRow row = string ? membersList.FindSubString(string) : null;
6450 if(row && !membersList.FindSubStringAfter(row, string) && !caretMove)
6452 char * newString = row.string;
6453 if(!membersListShown)
6455 membersLoc.start.line = idStart.line-1;
6456 membersLoc.start.charPos = idStart.charPos-1;
6457 //membersLoc.end = membersLoc.start;
6458 membersLoc.end.charPos = idEnd.charPos-1;
6459 membersLoc.end.line = idEnd.line-1;
6460 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6461 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6466 membersList.Destroy(0);
6467 membersListShown = false;
6470 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
6472 line, membersLoc.start.line, membersLoc.start.charPos,
6473 line, membersLoc.end.line, membersLoc.end.charPos);
6474 editBox.PutS(newString);
6480 row = membersList.FindSubStringi(string);
6482 membersList.currentRow = row;
6483 membersList.currentRow.selected = false;
6486 membersList.currentRow = row;
6488 if(!membersListShown)
6492 // TESTING THESE ADDITIONS TO THE IF SO THAT CARET ISNT MOVED IF NOT ON TOP OF A WORD
6493 if(string && string[0] && lineNum == idStart.line && charPos >= idStart.charPos-1 && charPos <= idEnd.charPos-1)
6494 editBox.SetSelPos(l1, y1, idStart.charPos-1, l2, y2, idStart.charPos-1);
6495 editBox.GetCaretPosition(caret);
6496 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6498 membersList.master = this;
6500 caret.y += editBox.GetCaretSize();
6502 membersList.Create();
6505 int x = caret.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6506 int y = caret.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6507 Window parent = membersList.parent;
6509 if(!paramsAbove && (paramsShown || y + membersList.size.h > parent.clientSize.h))
6511 y -= editBox.GetCaretSize() + membersList.size.h;
6512 membersAbove = true;
6515 membersAbove = false;
6517 membersList.position = { x, y };
6521 membersLoc.start.line = lineNum - 1;
6523 if(string && string[0])
6525 membersLoc.start.charPos = idStart.charPos-1;
6526 membersLoc.end = membersLoc.start;
6527 //membersLoc.end.charPos = id.loc.end.charPos-1;
6528 membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6532 membersLoc.start.charPos = charPos;
6533 membersLoc.end = membersLoc.start;
6534 membersLoc.end.charPos = charPos;
6536 membersListShown = true;
6538 // Hack to keep caret shown
6539 editBox.GetCaretPosition(caret);
6540 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6543 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
6549 SetCurrentContext(globalContext);
6552 return !didOverride;
6555 void InvokeParameters(bool exact, bool reposition, bool caretMove)
6557 EditLine line = editBox.line;
6558 char * text = line.text;
6559 int lineNum, charPos;
6560 Expression exp = null;
6564 charPos = editBox.charPos + 1;
6567 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6569 EditBoxStream f { editBox = editBox };
6572 updatingCode = true;
6573 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6576 if(ch == '}' || ch == ',' || ch == ')')
6578 f.Seek(-1, current);
6586 if(!f.Seek(-1, current))
6589 if(!isspace(ch)) break;
6590 f.Seek(-1, current);
6594 f.Seek(-1, current);
6596 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6598 lineNum = editBox.lineNumber + 1;
6599 charPos = editBox.charPos + 1;
6601 updatingCode = false;
6604 charPos = Min(charPos, l1.count + 1);
6606 FindParamsTree(ast, lineNum, charPos);
6608 // Not sure about this == ExpCall... paramsInsideExp doesn't seem to necessarily be a ExpCall
6609 if(exact && ((::functionType && paramsInsideExp.type == callExp && paramsInsideExp.call.exp.loc.end.charPos != charPos-1) /*|| instanceType*/))
6611 ::functionType = null;
6612 ::instanceType = null;
6615 //if((::functionType || ::instanceType) && (!paramsShown || insideExp != functionExp || ::paramsID != this.paramsID))
6616 if((::functionType || ::instanceType) && (!paramsShown || true /*paramsInsideExp.destType != functionExp.destType */|| ::paramsID != this.paramsID))
6620 Window parent = paramsList.parent;
6622 if(this.functionType != ::functionType || this.instanceType != ::instanceType)
6625 if(!this.paramsShown || reposition || paramsInsideExp != functionExp || ::instanceType) // Added instanceType here, otherwise instance popups never reposition...
6626 // ( Dummy exp: always ends up with same memory)
6628 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6629 editBox.GetCaretPosition(paramsPosition);
6630 this.paramsPosition.y += editBox.GetCaretSize();
6633 FreeType(this.functionType);
6634 FreeType(this.instanceType);
6636 this.functionType = ::functionType;
6637 this.instanceType = ::instanceType;
6639 if(this.functionType) this.functionType.refCount++;
6640 if(this.instanceType) this.instanceType.refCount++;
6642 this.paramsID = ::paramsID;
6643 functionExp = paramsInsideExp;
6645 paramsList.master = this;
6647 paramsList.Create();
6649 x = paramsPosition.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6650 y = paramsPosition.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6652 if(!this.membersAbove && ( this.membersListShown || y + paramsList.size.h > parent.clientSize.h) )
6654 y -= editBox.GetCaretSize() + paramsList.clientSize.h;
6658 paramsAbove = false;
6659 if(x + paramsList.size.w > parent.clientSize.w)
6661 x = parent.clientSize.w - paramsList.size.w;
6665 paramsList.position = { x, y };
6667 // Hack to keep caret shown
6670 editBox.GetCaretPosition(caret);
6671 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6674 this.paramsShown = true;
6676 else if((!::functionType && !::instanceType) || reposition)
6678 paramsList.Destroy(0);
6679 paramsShown = false;
6681 FreeType(this.functionType);
6682 FreeType(this.instanceType);
6683 this.functionType = null;
6684 this.instanceType = null;
6688 SetCurrentContext(globalContext);
6696 designer.visible = true;
6697 designer.Activate();
6703 CodeEditor NewCodeEditor(Window parent, WindowState state, bool modified)
6705 CodeEditor document { state = state, parent = parent, modifiedDocument = modified };
6710 void CodeEditor_Terminate()
6712 FindParams_Terminate();
6713 FindCtx_Terminate();