3 // *** Color Schemes ***
5 //guiApp.currentSkin.selectionColor:
7 Color selectionColor = Color { 10, 36, 106 };
8 Color selectionText = white;
9 Color viewsBackground = white;
10 Color viewsText = black;
11 Color projectViewBackground = white;
12 Color projectViewText = black;
13 Color outputBackground = white;
14 Color outputText = black;
16 Color codeEditorBG = white;
17 Color codeEditorFG = black;
18 Color marginColor = Color {230, 230, 230};
19 Color lineNumbersColor = Color {60, 60, 60};
20 Color selectedMarginColor = Color {200, 200, 200};
21 SyntaxColorScheme colorScheme
23 keywordColors = { blue, blue };
24 commentColor = dimGray;
26 charLiteralColor = crimson;
27 stringLiteralColor = crimson;
28 preprocessorColor = green;
33 Color selectionColor = lightYellow;
34 Color selectionText = Color { 30, 40, 50 };
36 Color viewsBackground = Color { 30, 40, 50 };
37 Color viewsText = lightGray;
39 Color outputBackground = black;
40 Color outputText = lime;
42 Color projectViewBackground = Color { 30, 40, 50 };
43 Color projectViewText = lightGray;
45 Color marginColor = Color {24, 24, 24};
46 Color selectedMarginColor = Color {64, 64, 64};
47 Color lineNumbersColor = Color {160, 160, 160};
48 Color codeEditorBG = black;
49 Color codeEditorFG = ivory;
50 SyntaxColorScheme colorScheme
52 keywordColors = [ skyBlue, skyBlue ];
53 commentColor = dimGray;
54 charLiteralColor = Color { 245, 50, 245 };
55 stringLiteralColor = Color { 245, 50, 245 };
56 preprocessorColor = { 120, 220, 140 };
59 // *********************
65 // UNTIL IMPLEMENTED IN GRAMMAR
66 #define ACCESS_CLASSDATA(_class, baseClass) \
67 (_class ? ((void *)(((char *)_class.data) + baseClass.offsetClass)) : null)
70 extern int __attribute__((__stdcall__)) __ecereDll_Load_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
71 extern int __attribute__((__stdcall__)) __ecereDll_Unload_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
74 static FileFilter fileFilters[] =
77 "C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)",
78 "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx"
81 "Header Files for C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)",
85 "C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)",
95 static FileType fileTypes[] =
97 { "eC Source Code", "ec", whenNoneGiven },
98 { "Text Files", "txt", never }
101 static char * iconNames[] =
103 "<:ecere>constructs/class.png",
104 "<:ecere>constructs/data.png",
105 "<:ecere>constructs/method.png",
106 "<:ecere>constructs/event.png",
107 "<:ecere>constructs/property.png",
108 "<:ecere>constructs/namespace.png",
109 "<:ecere>constructs/dataType.png",
110 "<:ecere>constructs/enumValue.png",
111 "<:ecere>constructs/dataPrivate.png",
112 "<:ecere>constructs/methodPrivate.png",
113 "<:ecere>constructs/propertyPrivate.png"
116 enum SheetType { methods, properties };
118 extern int __ecereVMethodID_class_OnEdit;
119 extern int __ecereVMethodID_class_OnDisplay;
120 extern int __ecereVMethodID_class_OnGetString;
121 extern int __ecereVMethodID_class_OnFree;
122 extern int __ecereVMethodID_class_OnCompare;
123 extern int __ecereVMethodID_class_OnCopy;
124 extern int __ecereVMethodID_class_OnSaveEdit;
125 extern int __ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad;
127 class EditFileDialog : FileDialog
131 if(!ide.projectView && ideSettings.ideFileDialogLocation)
132 currentDirectory = ideSettings.ideFileDialogLocation;
133 return FileDialog::OnCreate();
137 EditFileDialog codeEditorFileDialog
139 type = multiOpen, text = "Open",
140 types = fileTypes, sizeTypes = sizeof(fileTypes);
141 filters = fileFilters, sizeFilters = sizeof(fileFilters)
144 EditFileDialog codeEditorFormFileDialog
146 type = open, text = "Open Project",
147 types = fileTypes, sizeTypes = sizeof(fileTypes), filters = fileFilters, sizeFilters = sizeof(fileFilters)
150 define OpenBracket = '{';
151 define CloseBracket = '}';
156 actionDeleteMethod = 2,
157 actionDetachMethod = 3,
158 actionAttachMethod = 4,
159 actionReattachMethod = 5
162 //extern StatusField pos, ovr, caps, num;
163 //extern Class thisClass;
169 bool parseError = false;
174 Expression ctxInsideExp;
175 Expression paramsInsideExp;
176 ClassFunction insideFunction;
184 /****************************************************************************
186 ****************************************************************************/
188 static void OutputString(File f, char * string)
191 for(c = 0; string[c]; c++)
193 if(string[c] == '\"')
195 else if(string[c] == '\\')
202 void OutputType(File f, Type type, bool outputName)
212 if(!type.isSigned) f.Printf("unsigned ");
216 if(!type.isSigned) f.Printf("unsigned ");
220 if(!type.isSigned) f.Printf("unsigned ");
224 if(!type.isSigned) f.Printf("unsigned ");
228 if(!type.isSigned) f.Printf("unsigned ");
238 // ADD CODE TO DECIDE WHETHER TO OUTPUT FULLY QUAlIFIED OR NOT:
239 f.Printf(type._class.shortName ? type._class.shortName : type._class.string);
248 OutputType(f, type.type, false);
251 OutputType(f, type.type, false);
270 if(type.kind == arrayType)
273 f.Printf("%d", type.arraySize);
279 void DeleteJunkBefore(EditBoxStream f, int pos, int * position)
285 f.Seek(pos - *position, current);
287 // Try to delete spaces and \n before...
293 /*else if(ch == '\n')
295 // Look for // comments on the line before
296 EditBox editBox = f.editBox;
297 EditLine line = editBox.line;
304 for(c = 0; text[c]; c++)
313 if(text[c] == '/' && last == '/')
325 f.DeleteBytes(before);
330 void GetLocText(EditBox editBox, File f, int position, Location loc, char ** text, int * size, int pad, int linePad)
335 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
337 // Cut & Paste function
343 f.Seek(loc.start.pos - position, current);
345 x1 = editBox.charPos;
346 y1 = editBox.lineNumber;
347 f.Seek(loc.end.pos - loc.start.pos, current);
349 x2 = editBox.charPos;
350 y2 = editBox.lineNumber;
351 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
353 *size = editBox.SelSize();
354 *text = new char[*size+1 + (y2-y1+1) * linePad + pad]; // Add pad for tabs and new name
355 editBox.GetSel(*text, false);
358 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
359 f.Printf(""); // Make the stream point to where the editbox is
362 void Code_FixProperty(Property prop, Instance object)
364 Designer::FixProperty(prop, object);
367 bool Code_IsPropertyModified(Instance test, ObjectInfo selected, Property prop)
370 if(prop.dataTypeString && (!prop.IsSet || prop.IsSet(selected.instance)))
372 Class dataType = prop.dataTypeClass;
373 char string[1024] = "";
376 dataType = prop.dataTypeClass = eSystem_FindClass(test._class.module, prop.dataTypeString);
378 if(dataType && dataType._vTbl && dataType.type == structClass)
380 void * dataForm = new0 byte[dataType.structSize];
381 void * dataTest = new0 byte[dataType.structSize];
383 prop.Get(selected.instance, dataForm);
384 prop.Get(test, dataTest);
386 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
388 prop.Set(test, dataForm);
394 else if(dataType && dataType._vTbl && (dataType.type == normalClass || dataType.type == noHeadClass))
396 void * dataForm, * dataTest;
398 dataForm = (void *)prop.Get(selected.instance);
399 dataTest = (void *)prop.Get(test);
401 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
403 prop.Set(test, dataForm);
407 else if(dataType && dataType._vTbl)
409 DataValue dataForm, dataTest;
411 GetProperty(prop, selected.instance, &dataForm);
412 GetProperty(prop, test, &dataTest);
414 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
416 SetProperty(prop, test, dataForm);
418 // In case setting on test unset on real instance (e.g. isDefault)
419 if(strcmp(prop.name, "name"))
421 GetProperty(prop, selected.instance, &dataTest);
422 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
423 SetProperty(prop, selected.instance, dataForm);
432 bool Code_IsPropertyDisabled(ObjectInfo selected, char * name)
434 bool disabled = false;
435 if(selected.oClass == selected)
438 if(selected.classDefinition)
440 for(def = selected.classDefinition.definitions->first; def; def = def.next)
442 if(def.type == defaultPropertiesClassDef)
445 for(prop = def.defProperties->first; prop; prop = prop.next)
447 if(prop.identifiers && prop.identifiers->first)
449 Identifier id = prop.identifiers->first;
450 if(prop.variable && !strcmp(id.string, name))
462 else if(selected.instCode)
465 if(selected.instCode.members)
467 for(members = selected.instCode.members->first; members; members = members.next)
469 if(members.type == dataMembersInit && members.dataMembers)
472 for(prop = members.dataMembers->first; prop; prop = prop.next)
474 if(prop.identifiers && prop.identifiers->first)
476 Identifier id = prop.identifiers->first;
477 if(prop.variable && !strcmp(id.string, name))
492 static bool CheckCompatibleMethod(Method method, Type type, Class regClass, bool isForm, Symbol selectedClass)
497 method.dataType = ProcessTypeString(method.dataTypeString, false);
498 if(!method.dataType.thisClass && !isForm)
501 method.dataType.thisClass = selectedClass;
503 //result = MatchTypes(method.dataType, type, null, regClass, regClass, false);
504 result = MatchTypes(type, method.dataType, null, regClass, regClass, false, true, true, false);
506 method.dataType.thisClass = null;
510 bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo object)
512 bool confirmation = true;
513 Statement body = function.body;
514 // Check if it contains any code
515 if((!body.compound.declarations || !body.compound.declarations->count) && (!body.compound.statements || body.compound.statements->count <= 1))
517 Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
518 Statement stmt = body.compound.statements ? body.compound.statements->first : null;
519 Type dataType = method.dataType;
520 Type returnType = dataType.returnType;
521 Expression exp = null;
524 method.dataType = ProcessTypeString(method.dataTypeString, false);
526 confirmation = false;
528 // Check if default function should be calling base class:
529 if(object.instance._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
531 if(returnType.kind != voidType)
533 if(!stmt || stmt.type != returnStmt || !stmt.expressions || stmt.expressions->count != 1)
537 exp = stmt.expressions->first;
538 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
540 if( (exp.type != identifierExp || strcmp(exp.identifier.string, "true")) &&
541 (exp.type != constantExp || strcmp(exp.constant, "1")))
546 if(exp.type != constantExp || strcmp(exp.constant, "0"))
561 if(returnType.kind != voidType)
563 if(stmt.type == returnStmt && stmt.expressions && stmt.expressions->count == 1)
564 exp = stmt.expressions->first;
566 else if(stmt.type == expressionStmt && stmt.expressions && stmt.expressions->count == 1)
567 exp = stmt.expressions->first;
570 if(!exp || exp.type != callExp || exp.call.exp.type != identifierExp)
574 Identifier id = exp.call.exp.identifier;
575 Class base = object.instance._class;
576 if(!id._class || (id._class.name && !strcmp(id._class.name, base.name)) || strcmp(id.string, method.name))
580 Expression arg = exp.call.arguments ? exp.call.arguments->first : null;
581 if(!arg || arg.type != identifierExp || strcmp("this", arg.identifier.string))
587 for(param = dataType.params.first; param; param = param.next)
589 if(!arg || arg.type != identifierExp || strcmp(param.name, arg.identifier.string))
594 arg = arg ?arg.next : null;
601 return !confirmation;
604 class CodeEditor : Window
606 background = marginColor;
607 borderStyle = sizableDeep;
612 isActiveClient = true;
613 anchor = Anchor { left = 300, right = 150, top = 0, bottom = 0 };
616 // eWindow_SetX(A_CASCADE); eWindow_SetY(A_CASCADE);
617 // eWindow_SetWidth(A_RELATIVE|80); eWindow_SetHeight(A_RELATIVE|80);
619 SheetType sheetSelected;
624 Context globalContext { };
625 OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
638 MethodAction methodAction;
640 ClassFunction function;
642 char methodName[1024];
646 bool membersListShown;
649 EditLine membersLine;
651 Type functionType, instanceType;
655 Point paramsPosition;
656 Expression functionExp;
659 BitmapResource icons[CodeObjectType];
661 FontResource boldFont { "Tahoma", 8.25f, bold = true, window = this };
662 FontResource normalFont { "Tahoma", 8.25f, window = this };
664 Module privateModule;
665 NameSpace globalData;
668 OpenedFileInfo openedFileInfo;
670 FontResource font { "Courier New", 10 };
671 saveDialog = codeEditorFileDialog;
673 Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
675 void ProcessCaretMove(EditBox editBox, int line, int charPos)
678 ObjectInfo classItem;
680 // OnActivateClient is called after OnActivate
683 sprintf(temp, "Ln %d, Col %d", line, editBox.column + 1);
686 if(sheet.codeEditor != this) return;
690 for(classItem = classes.first; classItem; classItem = classItem.next)
692 ClassDefinition classDef = classItem.classDefinition;
693 if(classDef && classDef.loc.Inside(line, charPos))
700 for(object = classItem.instances.first; object; object = object.next)
704 if(object.instCode.loc.Inside(line, charPos))
709 sheet.SelectObject(object);
711 sheet.SelectObject(classItem);
716 //sheet.SelectObject(null);
720 sprintf(temp, "Ln %d, Col %d", line, editBox.column + 1);
724 expectingMove = false;
730 if(line-1 != membersLoc.start.line)
734 char * buffer = membersLine.text;
737 if(charPos - 1 < membersLoc.start.charPos)
739 else if(charPos - 1 > membersLoc.end.charPos)
741 char * buffer = membersLine.text;
742 //if(membersList.currentRow)
746 for(c = membersLoc.start.charPos; c<=charPos && buffer[c]; c++)
747 if(buffer[c] != ' ' && buffer[c] != '\t')
749 if(c < charPos && buffer[c])
756 membersList.Destroy(0);
757 membersListShown = false;
761 bool back = codeModified;
762 codeModified = false;
764 InvokeParameters(false, false, false);
765 /*if(membersListShown)
766 InvokeAutoComplete(false, 0, true);*/
773 watch(modifiedDocument)
775 ProjectView projectView = ide.projectView;
778 ProjectNode node = projectView.GetNodeFromWindow(this, null);
781 node.modified = modifiedDocument;
782 projectView.Update(null);
790 textVertScroll = true, multiLine = true, /*lineNumbers = ideSettings.showLineNumbers,*/
791 freeCaret = ideSettings.useFreeCaret, caretFollowsScrolling = ideSettings.caretFollowsScrolling,
792 tabKey = true, smartHome = true;
793 tabSelection = true, maxLineSize = 65536, parent = this, hasHorzScroll = true, hasVertScroll = true;
794 selectionColor = selectionColor, selectionText = selectionText,
795 background = codeEditorBG, foreground = codeEditorFG, syntaxColorScheme = colorScheme,
796 font = font, borderStyle = none;
797 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
799 bool OnMouseOver(int x, int y, Modifiers mods)
801 CodeEditor editor = (CodeEditor)master;
802 if(editor.designer && editor.designer.isDragging && !mods.isSideEffect)
807 void NotifyCaretMove(EditBox editBox, int line, int charPos)
809 // Update Line Numbers
811 int oldLine = lastLine;
812 display.FontExtent(font.font, " ", 1, null, &spaceH);
814 Box box { 0, (Min(oldLine,oldLine)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(oldLine, oldLine))*spaceH-1 - editBox.scroll.y };
818 Box box { 0, (Min(line,line)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(line, line))*spaceH-1 - editBox.scroll.y };
823 if(ide.activeClient == this)
824 ProcessCaretMove(editBox, line, charPos);
826 openedFileInfo.CaretMove(line, charPos);
829 void NotifyOvrToggle(EditBox editBox, bool overwrite)
831 ide.ovr.color = overwrite ? black : Color { 128, 128, 128 };
834 void NotifyUpdate(EditBox editBox)
841 designer.modifiedDocument = true;
844 modifiedDocument = true;
847 bool NotifyUnsetModified(EditBox editBox)
849 modifiedDocument = false;
853 bool NotifyCharsAdded(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
859 if(after.y != before.y)
861 ProjectView projectView = ide.projectView;
862 if(projectView && fileName)
865 // HOW WE MIGHT WANT TO DO IT:
866 char * text = before.line.text;
867 for(c = before.x-1; c>= 0; c--)
868 if(!isspace(text[c]))
870 ide.debugger.MoveIcons(fileName, before.y + (((!pasteOperation && c > -1) || !after.line.count) ? 1 : 0), after.y - before.y, false);
872 // HOW VISUAL STUDIO DOES IT:
874 char * text = after.line.text;
875 for(c = after.line.count-1; c>= 0; c--)
876 if(!isspace(text[c]))
878 ide.debugger.MoveIcons(fileName, before.y + ((c < 0) ? 1 : 0), after.y - before.y, false);
885 for(oClass = classes.first; oClass; oClass = oClass.next)
888 for(object = oClass.instances.first; object; object = object.next)
892 object.instCode.loc.start.AdjustAdd(before, after);
893 object.instCode.loc.end.AdjustAdd(before, after);
898 oClass.classDefinition.loc.start.AdjustAdd(before, after);
899 oClass.classDefinition.loc.end.AdjustAdd(before, after);
905 expectingMove = true;
909 if(before.y != after.y)
913 char * buffer = membersLine.text;
915 bool firstChar = true;
916 bool addedChar = false;
922 membersLoc.end.charPos += after.x - Max(membersLoc.start.charPos, before.x);
924 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
926 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
927 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar)) //|| membersList.currentRow
936 membersLoc.start.charPos++;
941 string[len++] = buffer[c];
945 row = membersList.currentRow;
946 if(row && row.selected)
950 membersLoc.start.charPos--;
958 row = membersList.FindSubString(string);
960 membersList.currentRow = row;
963 row = membersList.FindSubStringi(string);
965 membersList.currentRow = row;
966 membersList.currentRow.selected = false;
969 membersList.SetScrollPosition(0, (row.index) * membersList.rowHeight);
973 row = membersList.currentRow;
976 // Accept current string if hiding typing char
977 if(hide && row && row.selected)
979 char * string = row.string;
980 int len = strlen(string);
981 membersLoc.end.charPos -= after.x - before.x;
982 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
983 editBox.Delete(membersLine, membersLoc.start.line, membersLoc.start.charPos,
984 membersLine, membersLoc.end.line, membersLoc.end.charPos);
985 editBox.PutS(string);
986 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos + len + 1 /*after.x - before.x*/);
988 after.x += membersLoc.start.charPos + len - before.x;
989 before.x = membersLoc.start.charPos + len;
994 membersList.Destroy(0);
995 membersListShown = false;
998 if(/*after.x - before.x == 1 && */after.y == before.y && !membersListShown)
1000 EditLine line = editBox.line;
1001 char * text = line.text;
1002 char ch = text[after.x-1];
1003 if(ch == '.' || (ch == '>' && after.x-1 > 0 && text[after.x-1-1] == '-') || (ch == ':' && after.x-1 > 0 && text[after.x-1-1] == ':'))
1007 // Can we call invoke auto complete here instead?
1017 // Force caret update already...
1018 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1019 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1021 editBox.GetCaretPosition(&caret);
1025 // Go back in the buffer until no space before
1027 codeModified = true;
1031 EditBoxStream f { editBox = editBox };
1035 if(text[after.x-1] == '>')
1041 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1045 if(!f.Seek(-1, current))
1048 if(!isspace(ch)) break;
1049 f.Seek(-1, current);
1051 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1053 line = editBox.lineNumber + 1;
1054 charPos = editBox.charPos + 1;
1058 exp = FindExpTree(ast, line, charPos);
1062 Type type = exp.expType;
1064 if(type && text[after.x-1] != '.')
1066 if(type.kind == TypePointer || type.kind == TypeArray)
1072 membersList.Clear();
1075 if(membersList.rowCount)
1077 membersList.Sort(null, 1);
1078 membersList.master = this;
1080 caret.y += editBox.GetCaretSize();
1083 membersList.Create();
1086 int x = caret.x + editBox.GetAbsX() - app.desktop.GetAbsX() - editBox.GetScrollX();
1087 int y = caret.y + editBox.GetAbsY() - app.desktop.GetAbsY() - editBox.GetScrollY();
1088 Window parent = membersList.parent;
1090 if(!paramsAbove && (paramsShown || y + membersList.GetHeight() > parent.GetClientHeight()))
1092 y -= editBox.GetCaretSize() + membersList.GetHeight();
1093 membersAbove = true;
1096 membersAbove = false;
1098 membersList.position = { x, y };
1102 membersLoc.start.line = line - 1;
1103 membersLoc.start.charPos = oldCharPos;
1104 membersLoc.end = membersLoc.start;
1105 membersListShown = true;
1110 SetCurrentContext(globalContext);
1112 codeModified = true;
1113 skipModified = true;
1114 if(text[after.x-1] == ':')
1115 InvokeAutoComplete(false, 0, false);
1116 else if(text[after.x-1] == '.')
1117 InvokeAutoComplete(false, 1, false);
1118 else if(text[after.x-1] == '>')
1119 InvokeAutoComplete(false, 2, false);
1120 skipModified = false;
1122 else if(ch == '(' || ch == OpenBracket || ch == ',' || ch == '=' || ch == '?' || ch == ':')
1124 codeModified = true;
1125 skipModified = true;
1127 if(InvokeAutoComplete(true, 0, false))
1129 if(ch == '(' || ch == OpenBracket)
1130 InvokeParameters(true, true, false);
1132 InvokeParameters(this.functionType ? false : true, false, false);
1135 // InvokeAutoComplete(true, 0, false);
1136 skipModified = false;
1138 else if(ch == ')' || ch == '}' || ch == ';')
1140 codeModified = true;
1141 skipModified = true;
1143 InvokeParameters(false, true, false);
1144 skipModified = false;
1148 bool back = codeModified;
1149 codeModified = false;
1151 InvokeParameters(false, false, true);
1152 if(membersListShown)
1153 InvokeAutoComplete(false, 0, true);
1154 codeModified = back;
1159 bool back = codeModified;
1160 codeModified = false;
1163 InvokeParameters(false, false, true);
1164 /*if(membersListShown)
1165 InvokeAutoComplete(false, 0, true);*/
1167 codeModified = back;
1174 bool NotifyCharsDeleted(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
1180 if(after.y != before.y)
1182 ProjectView projectView = ide.projectView;
1183 if(projectView && fileName)
1185 ide.debugger.MoveIcons(fileName, before.y + 1, before.y - after.y, before.x == 0);
1190 for(oClass = classes.first; oClass; oClass = oClass.next)
1194 for(object = oClass.instances.first; object; object = object.next)
1198 loc = &object.instCode.loc;
1200 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1201 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1203 object.instCode = null;
1207 loc->start.AdjustDelete(before, after);
1208 loc->end.AdjustDelete(before, after);
1212 if(oClass.classDefinition)
1214 loc = &oClass.classDefinition.loc;
1215 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1216 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1218 oClass.classDefinition = null;
1222 loc->start.AdjustDelete(before, after);
1223 loc->end.AdjustDelete(before, after);
1228 if(membersListShown)
1231 if(pasteOperation || before.y != after.y)
1235 char * buffer = membersLine.text;
1237 bool firstChar = true;
1241 if(before.x >= membersLoc.start.charPos)
1243 for(c = membersLoc.start.charPos; c<before.x; c++)
1245 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1246 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1251 if(!isSpace) firstChar = false;
1254 string[len++] = buffer[c];
1259 // If deleting spaces before...
1260 for(c = before.x; c<membersLoc.start.charPos; c++)
1262 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1270 membersLoc.start.charPos = before.x;
1273 if(membersLoc.end.charPos >= after.x)
1275 for(c = after.x; c<membersLoc.end.charPos; c++)
1277 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1278 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1283 if(!isSpace) firstChar = false;
1286 string[len++] = buffer[c];
1294 membersLoc.end.charPos -= after.x - before.x;
1298 row = membersList.FindSubString(string);
1301 row = membersList.FindSubStringi(string);
1303 membersList.currentRow = row;
1304 membersList.currentRow.selected = false;
1307 membersList.currentRow = row;
1309 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
1314 membersList.Destroy(0);
1315 membersListShown = false;
1321 InvokeParameters(false, false);
1329 bool NotifyDropped(EditBox editBox, int x, int y)
1331 char * controlClass = toolBox.controlClass;
1332 if(controlClass && controlClass[0])
1336 ObjectInfo classObject;
1338 //editBox.NotifyCaretMove(this, editBox, y, x);
1339 editBox.GoToLineNum(y);
1340 editBox.GoToPosition(editBox.line, y, x);
1342 classObject = selected ? selected.oClass : null;
1344 if((!selected || selected == classObject) && classObject && classObject.instances.first)
1345 selected = classObject.instances.last;
1348 control = eInstance_New(eSystem_FindClass(privateModule, controlClass));
1351 AddObject(control, &object);
1353 designer.CreateObject(control, object, false, classObject.instance);
1354 // designer.PostCreateObject(control, object, false, classObject.instance);
1355 designer.DroppedObject(control, object, false, classObject.instance);
1357 sheet.AddObject(object, object.name, typeData /* className*/, true);
1360 //codeModified = true;
1367 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
1369 if(key == Key { space, ctrl = true })
1371 membersList.Destroy(0);
1372 membersListShown = false;
1373 InvokeAutoComplete(false, 0, false);
1376 else if(key == Key { space, ctrl = true, shift = true })
1377 InvokeParameters(false, true, false);
1378 else if(key == escape)
1379 ide.RepositionWindows(true);
1380 else if(key == ctrlF7)
1384 ProjectNode node = ide.projectView.GetNodeFromWindow(this, null);
1388 s = PrintString("The ", fileName, " file is not part of any project.\n",
1389 "It can't be compiled.");
1390 MessageBox { type = ok, parent = ide, master = ide, text = "File not in project error", contents = s }.Modal();
1399 bool OnKeyDown(Key key, unichar ch)
1401 CodeEditor editor = (CodeEditor)master;
1402 if(key == escape /*|| key == leftAlt || key == rightAlt || (key.ctrl && key.code != left && key.code != right && key.code != leftShift && key.code != rightShift && key.code != space)*/)
1404 if(editor.membersListShown)
1406 editor.membersList.Destroy(0);
1407 editor.membersListShown = false;
1410 if(editor.paramsShown)
1412 editor.paramsList.Destroy(0);
1413 editor.paramsShown = false;
1414 FreeType(editor.functionType);
1415 FreeType(editor.instanceType);
1417 editor.functionType = null;
1418 editor.instanceType = null;
1419 editor.paramsID = -1;
1423 return EditBox::OnKeyDown(key, ch);
1426 void OnVScroll(ScrollBarAction action, int position, Key key)
1428 if(anchor.left.distance)
1430 Box box { 0, 0, anchor.left.distance-1, parent.clientSize.h - 1 };
1433 EditBox::OnVScroll(action, position, key);
1435 CodeEditor ce = (CodeEditor)parent;
1436 if(ce.openedFileInfo)
1437 ce.openedFileInfo.ScrollChange({ scroll.x, position });
1441 void OnHScroll(ScrollBarAction action, int position, Key key)
1443 EditBox::OnHScroll(action, position, key);
1445 CodeEditor ce = (CodeEditor)parent;
1446 if(ce.openedFileInfo)
1447 ce.openedFileInfo.ScrollChange({ position, scroll.y });
1454 fullRowSelect = false,
1457 borderStyle = bevel;
1458 // size = { 200, 400 };
1460 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
1462 DataRow row = listBox.currentRow;
1465 char * string = row.string;
1467 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1469 membersLine, membersLoc.start.line, membersLoc.start.charPos,
1470 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1471 editBox.PutS(string);
1474 membersListShown = false;
1479 bool OnKeyDown(Key key, unichar ch)
1481 CodeEditor editor = (CodeEditor) master;
1482 if(key == escape || key == leftAlt || key == rightAlt ||
1483 (key.ctrl && key.code != left && key.code != right &&
1484 key.code != leftShift && key.code != rightShift && key.code != space))
1486 if(editor.paramsShown)
1487 editor.paramsList.Destroy(0);
1488 if(editor.membersListShown)
1489 editor.membersList.Destroy(0);
1491 editor.paramsShown = false;
1492 FreeType(editor.functionType);
1493 FreeType(editor.instanceType);
1495 editor.functionType = null;
1496 editor.instanceType = null;
1497 editor.paramsID = -1;
1499 editor.membersListShown = false;
1503 return editor.editBox.OnKeyDown(key, ch);
1507 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1509 CodeEditor editor = (CodeEditor)master;
1513 editor.membersListShown = false;
1515 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1518 bool OnKeyHit(Key key, unichar ch)
1520 CodeEditor editor = (CodeEditor) master;
1524 case enter: case tab:
1526 DataRow row = currentRow;
1527 if(row && row.selected)
1529 char * string = row.string;
1531 editor.editBox.GoToPosition(editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos);
1532 editor.editBox.Delete(
1533 editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos,
1534 editor.membersLine, editor.membersLoc.end.line, editor.membersLoc.end.charPos);
1535 editor.editBox.PutS(string);
1538 editor.membersListShown = false;
1541 editor.editBox.OnKeyHit(key, ch);
1551 return ListBox::OnKeyHit(key, ch);
1557 // If before . or after
1558 //listBox.Destroy(true);
1559 result = editor.editBox.OnKeyHit(key, ch);
1574 clickThrough = true,
1576 borderStyle = contour,
1578 background = { 255,255,225 },
1580 OnKeyDown = membersList.OnKeyDown;
1582 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1584 CodeEditor editor = (CodeEditor)master;
1588 editor.membersListShown = false;
1590 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1593 bool OnKeyHit(Key key, unichar ch)
1595 CodeEditor editor = (CodeEditor)master;
1597 if(!editor.membersListShown || editor.membersList.OnKeyHit(key, ch))
1600 bool result = true; editor.editBox.OnKeyHit(key, ch);
1601 return (!created) ? false : result;
1608 void OnRedraw(Surface surface)
1610 CodeEditor editor = (CodeEditor) master;
1611 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1613 Type methodType = null;
1617 int functionW, nameW = 0;
1619 int spaceW, spaceH, commaW, commaWB, parW;
1621 int maxW = 0, lineW = 0;
1627 Font font = editor.normalFont.font;
1628 Font boldFont = editor.boldFont.font;
1629 Display display = this.display;
1631 if(!type) { return; };
1633 if(type.kind == TypeKind::methodType) { methodType = type; type = type.method.dataType; }
1635 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1636 display.FontExtent(font, ", ", 2, &commaW, null);
1637 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1638 display.FontExtent(font, ")", 1, &parW, null);
1641 if(editor.functionType)
1643 PrintType(type.returnType, string, true, true);
1644 display.FontExtent(font, string, strlen(string), &functionW, null);
1646 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1647 totalW = nameW + functionW + 2 * parW;
1651 PrintType(type, string, (type.kind == functionType) ? true : false, true); // true);
1652 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1653 if(instanceName && type.kind != functionType)
1654 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1655 totalW = functionW + nameW;
1656 surface.TextFont(boldFont);
1659 surface.WriteText(x, y, string, strlen(string));
1660 x += functionW + spaceW;
1662 if(editor.functionType)
1665 surface.WriteText(x, y, type.name, strlen(type.name));
1667 surface.WriteText(x, y, "(", 1);
1670 if(methodType && !methodType.staticMethod)
1674 if(id == editor.paramsID)
1675 surface.TextFont(boldFont);
1677 if(methodType.methodClass)
1678 surface.TextExtent(methodType.methodClass.name, strlen(methodType.methodClass.name), &tw, null);
1682 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1683 width += ((id == editor.paramsID) ? commaWB : commaW);
1688 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1693 x = 2 + nameW + spaceW + functionW + parW;
1697 if(methodType.methodClass)
1698 surface.WriteText(x, y, methodType.methodClass.name, strlen(methodType.methodClass.name));
1701 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1703 surface.WriteText(x, y, ",", 1);
1704 x += ((id == editor.paramsID) ? commaWB : commaW);
1712 if(id == editor.paramsID)
1713 surface.TextFont(font);
1717 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1719 for(param = type.params.first; param; param = param.next)
1721 char paramString[1024];
1724 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1725 surface.TextFont(boldFont);
1728 PrintType(param, paramString, true, true);
1729 surface.TextExtent(paramString, strlen(paramString), &tw, null);
1731 if(param.next) width += ((id == editor.paramsID) ? commaWB : commaW);
1736 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1741 x = 2 + nameW + spaceW + functionW + parW;
1745 surface.WriteText(x, y, paramString, strlen(paramString));
1749 surface.WriteText(x, y, ",", 1);
1750 x += ((id == editor.paramsID) ? commaWB : commaW);
1758 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1759 surface.TextFont(font);
1764 surface.WriteText(x, y, ")", 1);
1766 else if(instanceName && type.kind != functionType)
1768 surface.WriteText(x, y, instanceName, strlen(instanceName));
1772 bool OnResizing(int * w, int * h)
1774 CodeEditor editor = (CodeEditor) master;
1775 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1777 Type methodType = null;
1781 int functionW = 0, nameW = 0;
1783 int spaceW, spaceH, commaW, commaWB, parW;
1785 int maxW = 0, lineW = 0;
1790 Font font = editor.normalFont.font;
1791 Font boldFont = editor.boldFont.font;
1792 Display display = this.display;
1794 if(type.kind == TypeKind::methodType)
1797 ProcessMethodType(type.method);
1798 type = type.method.dataType;
1801 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1802 display.FontExtent(font, ", ", 2, &commaW, null);
1803 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1804 display.FontExtent(font, ")", 1, &parW, null);
1807 if(editor.functionType && type)
1809 PrintType(type.returnType, string, true, true);
1810 display.FontExtent(font, string, strlen(string), &functionW, null);
1812 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1813 totalW = nameW + spaceW + functionW + 2 * parW;
1817 PrintType(type, string, false, true); // /*true);
1818 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1819 if(instanceName && type.kind != functionType)
1820 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1821 totalW = functionW + nameW + spaceW;
1824 if(editor.functionType)
1830 if(methodType.methodClass)
1831 display.FontExtent((id == editor.paramsID) ? boldFont : font, methodType.methodClass.name, strlen(methodType.methodClass.name), &width, null);
1832 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1833 width += ((id == editor.paramsID) ? commaWB : commaW);
1838 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1851 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1853 for(param = type.params.first; param; param = param.next)
1855 char paramString[1024];
1859 PrintType(param, paramString, true, true);
1860 display.FontExtent((id == editor.paramsID || param.kind == ellipsisType) ? boldFont : font, paramString, strlen(paramString), &width, null);
1862 width += ((id == editor.paramsID) ? commaWB : commaW);
1867 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1884 *w = realW + totalW + 4;
1890 Menu fileMenu { menu, "File", f }; // MenuPlacement?
1891 MenuItem { fileMenu, "Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
1892 MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
1894 Menu debugMenu { menu, "Debug", d }; // MenuPlacement?
1895 MenuItem debugRunToCursor
1897 debugMenu, "Run To Cursor", c, Key { f10, ctrl = true };
1898 bool NotifySelect(MenuItem selection, Modifiers mods)
1900 ProjectView projectView = ide.projectView;
1901 if(!projectView.buildInProgress)
1903 int line = editBox.lineNumber + 1;
1905 ide.debugger.RunToCursor(fileName, line, false);
1910 MenuItem debugSkipRunToCursor
1912 debugMenu, "Run To Cursor Skipping Breakpoints", u, Key { f10, ctrl = true, shift = true };
1913 bool NotifySelect(MenuItem selection, Modifiers mods)
1915 ProjectView projectView = ide.projectView;
1916 int line = editBox.lineNumber + 1;
1918 ide.debugger.RunToCursor(fileName, line, true);
1922 MenuDivider { debugMenu };
1923 MenuItem debugToggleBreakpoint
1925 debugMenu, "Toggle Breakpoint", t, f9;
1926 bool NotifySelect(MenuItem selection, Modifiers mods)
1928 ProjectView projectView = ide.projectView;
1929 if(projectView && fileName)
1931 int line = editBox.lineNumber + 1;
1932 char name[MAX_LOCATION];
1934 // TOFIX: This only looks at the filename...
1935 GetLastDirectory(fileName, name);
1936 if(ide && ide.workspace)
1938 for(p : ide.workspace.projects)
1940 if(p.topNode.Find(name, false))
1948 for(p : ide.workspace.projects)
1950 if(eString_PathInsideOf(fileName, p.topNode.path))
1958 ide.debugger.ToggleBreakpoint(fileName, line, prj);
1968 //MenuItem viewDesignerItem, viewProperties, viewMethods;
1972 designer.parent = parent;
1975 toolBox = ((IDE)master).toolBox;
1977 // Debugger bug here: value of toolBox appears as 0
1979 sheet = ((IDE)master).sheet;
1984 bool OnClose(bool parentClosing)
1988 if(ide.workspace && fileName)
1989 ide.workspace.UpdateOpenedFileInfo(fileName, closed);
1991 if(inUseDebug && !debugClosing)
1993 debugClosing = true;
1995 if(CloseConfirmation(false))
1998 OnFileModified({ modified = true }, null);
2000 debugClosing = false;
2003 if(designer && !designer.closing)
2005 if(designer.visible)
2012 //Window formEditor = designer;
2013 //formEditor.Destroy(0);
2020 void OnDestroy(void)
2022 ObjectInfo oClass, next;
2023 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2025 FreeType(this.functionType);
2026 FreeType(this.instanceType);
2031 designer.codeEditor = null;
2032 designer.Destroy(0);
2036 for(oClass = (classes).first, next = oClass ? oClass.next : null; oClass; oClass = next, next = next ? (next.next) : null)
2038 ObjectInfo object, next;
2040 for(object = oClass.instances.first; object; object = next)
2045 Designer::DestroyObject(object.instance);
2046 delete object.instance;
2048 sheet.DeleteObject(object);
2050 oClass.instances.Delete(object);
2054 Designer::DestroyObject(oClass.instance);
2055 delete oClass.instance;
2057 sheet.DeleteObject(oClass);
2059 classes.Delete(oClass);
2062 if(windowClass && windowClass.data)
2063 UnapplySkin(windowClass);
2067 if(sheet.codeEditor == this)
2069 sheet.codeEditor = null;
2070 toolBox.codeEditor = null;
2076 ProjectView projectView = ide.projectView;
2079 ProjectNode node = projectView.GetNodeFromWindow(this, null);
2080 if(node && node.modified)
2082 node.modified = false;
2083 projectView.Update(null);
2089 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool directActivation)
2091 // 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
2093 if(directActivation)
2094 ide.RepositionWindows(false); // Moved this up before as resizing causes NotifyCaretMove to be called on all editors
2096 if(active && directActivation)
2099 openedFileInfo.Activate();
2103 Location * loc = null;
2104 UpdateFormCode(); // To ensure update when modifying properties...
2106 // Got to the right spot in code so we don't lose our form selection...
2109 if(selected.instCode)
2110 loc = &selected.instCode.loc;
2111 else if(selected.classDefinition)
2112 loc = &selected.classDefinition.loc;
2114 line = editBox.lineNumber + 1;
2115 charPos = editBox.charPos + 1;
2120 if(selected && !loc->Inside(line, charPos))
2122 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2123 line = editBox.lineNumber + 1;
2124 charPos = editBox.charPos + 1;
2126 else if(selected && selected.classDefinition)
2129 for(object = selected.instances.first; object; object = object.next)
2133 if(object.instCode.loc.Inside(line, charPos))
2139 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2140 line = editBox.lineNumber + 1;
2141 charPos = editBox.charPos + 1;
2146 ProcessCaretMove(editBox, line, charPos);
2152 bool OnSaveFile(char * fileName)
2159 f = FileOpen(fileName, write);
2162 if(!ide.projectView)
2163 ide.ChangeFileDialogsDirectory(codeEditorFileDialog.currentDirectory, true);
2167 this.fileName = fileName; // Put this here because the form designer will check for it...
2168 designer.fileName = fileName;
2169 designer.modifiedDocument = false;
2171 editBox.Save(f, false);
2172 modifiedDocument = false;
2180 bool OnFileModified(FileChange fileChange, char * param)
2182 bool reload = false;
2183 if(visible == false && inUseDebug == true)
2189 sprintf(message, "The document %s was modified by another application.\n"
2190 "Would you like to reload it and lose your changes?", fileName);
2191 if(MessageBox { type = yesNo, master = /*parent = */parent, text = "Document has been modified",
2192 contents = message }.Modal() == yes)
2198 File f = FileOpen(fileName, read);
2201 int lineNumber, charPos, len;
2204 updatingCode = true;
2205 lineNumber = editBox.lineNumber;
2206 charPos = editBox.charPos;
2207 scroll = editBox.scroll;
2210 lineNumber = lineNumber < editBox.numLines ? lineNumber : editBox.numLines - 1;
2211 len = strlen(editBox.line.text);
2212 editBox.GoToLineNum(lineNumber);
2213 editBox.GoToPosition(editBox.line, lineNumber, charPos <= len ? charPos - 1 : (len ? len - 1 : 0));
2214 editBox.scroll = scroll;
2215 updatingCode = false;
2217 codeModified = true;
2221 designer.modifiedDocument = false;
2223 modifiedDocument = false;
2231 void OnRedraw(Surface surface)
2234 surface.SetBackground(marginColor);
2235 surface.Area(0, 0, editBox.anchor.left.distance, clientSize.h - 1);
2236 if(ideSettings.showLineNumbers)
2238 int currentLineNumber;
2243 surface.textOpacity = false;
2244 surface.font = font.font;
2245 surface.TextExtent(" ", 1, null, &spaceH);
2246 currentLineNumber = editBox.scroll.y / spaceH + 1;
2248 surface.SetForeground(lineNumbersColor);
2249 for(i = 0; i < editBox.clientSize.h - 4; i += spaceH)
2251 // Highlight current line
2252 if(editBox.lineNumber == currentLineNumber - 1)
2254 surface.SetBackground(selectedMarginColor);
2255 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2256 surface.SetBackground(marginColor);
2258 sprintf(lineText,"%5u ", currentLineNumber % 100000);
2259 if(currentLineNumber <= editBox.numLines)
2260 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,6);
2262 currentLineNumber++;
2266 if(editBox.syntaxHighlighting && fileName && ide.projectView)
2268 bool error, bpOnCursor, bpOnTopFrame, breakpointEnabled[128];
2269 int lineCursor, lineTopFrame, breakpointLines[128];
2270 int count, i, lineH, boxH, scrollY; //, firstLine; firstLine = editBox.firstLine;
2271 Debugger debugger = ide.debugger;
2272 BitmapResource bmpRes;
2274 boxH = clientSize.h;
2275 scrollY = editBox.scroll.y;
2276 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
2278 bpOnCursor = bpOnTopFrame = false;
2279 count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
2282 for(i = 0; i < count; i++)
2284 if(breakpointLines[i] == lineCursor || breakpointLines[i] == lineTopFrame)
2286 bmpRes = breakpointEnabled[i] ? ide.bmpBpHalf : ide.bmpBpHalfDisabled;
2287 if(breakpointLines[i] == lineCursor)
2289 if(breakpointLines[i] == lineTopFrame)
2290 bpOnTopFrame = true;
2293 bmpRes = breakpointEnabled[i] ? ide.bmpBp : ide.bmpBpDisabled;
2295 DrawLineMarginIcon(surface, bmpRes, breakpointLines[i], lineH, scrollY, boxH);
2298 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
2299 bmpRes = bpOnTopFrame ? (error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf) : (error ? ide.bmpTopFrameError : ide.bmpTopFrame);
2300 DrawLineMarginIcon(surface, bmpRes, lineTopFrame, lineH, scrollY, boxH);
2302 if(editBox.anchor.left.distance)
2304 if(editBox.horzScroll && editBox.horzScroll.visible)
2306 surface.SetBackground(control);
2307 surface.Area(0, editBox.clientSize.h, editBox.anchor.left.distance, clientSize.h - 1);
2312 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
2317 lineY = (line - 1) * lineH;
2318 if(lineY + lineH > scrollY && lineY /*+ lineH*/ < scrollY + boxH)
2320 Bitmap bitmap = resource.bitmap;
2322 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
2329 char ext[MAX_EXTENSION];
2330 char * fileName = property::fileName;
2332 if(SearchString(fileName, 0, "Makefile", false, true))
2333 editBox.useTab = true;
2334 designer.fileName = fileName;
2338 GetExtension(fileName, ext);
2339 if(!strcmpi(ext, "ec"))
2341 codeModified = true;
2345 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"))
2346 editBox.syntaxHighlighting = true;
2348 editBox.syntaxHighlighting = false;
2351 display.FontExtent(font.font, " ", 1, &spaceW, null);
2352 editBox.anchor = Anchor
2354 left = (editBox.syntaxHighlighting ? 20 : 0) + (ideSettings.showLineNumbers ? (6 * spaceW) : 0),
2355 right = 0, top = 0, bottom = 0
2364 display.FontExtent(font.font, " ", 1, &spaceW, null);
2365 editBox.anchor = Anchor
2367 left = (editBox.syntaxHighlighting ? 20 : 0) + (ideSettings.showLineNumbers ? (6 * spaceW) : 0),
2368 right = 0, top = 0, bottom = 0
2373 bool LoadFile(char * filePath)
2375 File f = FileOpen(filePath, read);
2378 // Added this here...
2379 fileName = filePath;
2380 updatingCode = true;
2382 updatingCode = false;
2391 void DebugMenusDisabled()
2393 bool debugMenusDisabled = ide.GetDebugMenusDisabled();
2394 debugRunToCursor.disabled = debugMenusDisabled;
2395 debugSkipRunToCursor.disabled = debugMenusDisabled;
2396 debugToggleBreakpoint.disabled = debugMenusDisabled;
2402 ProjectView projectView = ide.projectView;
2405 designer.fileName = fileName;
2411 sprintf(title, "Untitled %d", documentID);
2412 // designer.fileName = CopyString(title);
2413 designer.fileName = title;
2416 DebugMenusDisabled();
2418 for(c = 0; c < CodeObjectType::enumSize; c++)
2419 icons[c] = BitmapResource { iconNames[c], window = this };
2421 codeModified = true;
2433 selected.modified = true;
2434 selected.oClass.modified = true;
2436 designer.modifiedDocument = true;
2437 modifiedDocument = true;
2438 formModified = true;
2441 /****************************************************************************
2443 ****************************************************************************/
2446 this.defines.Free(FreeModuleDefine);
2447 this.imports.Free(FreeModuleImport);
2454 FreeExcludedSymbols(this.excludedSymbols);
2455 FreeContext(this.globalContext);
2457 if(GetGlobalContext() == globalContext)
2459 SetGlobalData(null);
2460 SetGlobalContext(null);
2461 SetExcludedSymbols(null);
2462 SetTopContext(null);
2463 SetCurrentContext(null);
2466 SetPrivateModule(null);
2469 if(this.privateModule)
2471 FreeTypeData(this.privateModule);
2472 delete this.privateModule;
2473 this.privateModule = null;
2479 static bool reentrant = false;
2484 char * selectedClassName = null, * selectedName = null;
2485 int selectedPos = 0;
2486 Designer backDesigner;
2487 char oldWorkDir[MAX_LOCATION];
2488 char mainModuleName[MAX_FILENAME] = "";
2490 ImportedModule module;
2491 char extension[MAX_EXTENSION];
2493 Time parseCodeStart = GetTime();
2494 Time startTime, startFindClass;
2496 findClassTotalTime = 0;
2497 checkTypeTotalTime = 0;
2498 externalImportTotalTime = 0;
2499 findClassIgnoreNSTotalTime = 0;
2500 findSymbolTotalTime = 0;
2501 //ResetClassFindTime();
2505 // 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)
2506 if(reentrant) return;
2513 selectedClassName = CopyString(oClass.name);
2514 if(selected != oClass)
2516 ObjectInfo object = this.selected;
2517 selectedName = CopyString(object.name);
2521 for(check = this.oClass.instances.first; check; check = check.next)
2533 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
2535 defines.Free(FreeModuleDefine);
2536 imports.Free(FreeModuleImport);
2538 SetGlobalData(&globalData);
2539 SetGlobalContext(globalContext);
2540 SetExcludedSymbols(&excludedSymbols);
2541 SetTopContext(globalContext);
2542 SetCurrentContext(globalContext);
2543 SetDefines(&defines);
2544 SetImports(&imports);
2545 SetCurrentNameSpace(null);
2548 sprintf(command, "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin\\cl "
2549 "/nologo /D \"MSC\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" "
2550 "/I \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include\" "
2551 "/I T:\\ecere\\include /E %s", argv[1]);
2555 ChangeWorkingDir("e:\\ec");
2556 sprintf(command, "gcc -x c -E -");
2557 fileInput = DualPipeOpen({ output = true, input = true }, command);
2558 SetFileInput(fileInput);
2563 uint count = editFile.Read(buffer, 1, sizeof(buffer));
2565 fileInput.Write(buffer, 1, count);
2570 fileInput.CloseOutput();
2574 // TOCHECK: COULDN'T WE CALL FreeParser here?
2576 this.functionType = null;
2577 this.instanceType = null;
2580 sheet.SelectObject(null);
2586 // We don't want the designer to be notified of selection when deleting rows...
2587 backDesigner = designer;
2592 ObjectInfo _class, next;
2594 for(_class = classes.first; _class; _class = next)
2600 for(;object = _class.instances.first;)
2604 Designer::DestroyObject(object.instance);
2605 delete object.instance;
2607 sheet.DeleteObject(object);
2609 _class.instances.Delete(object);
2613 Designer::DestroyObject(_class.instance);
2614 delete _class.instance;
2616 sheet.DeleteObject(_class);
2618 classes.Delete(_class);
2624 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2625 if(windowClass && windowClass.data)
2626 UnapplySkin(windowClass);
2629 designer = backDesigner;
2632 fileInput = editFile = EditBoxStream { editBox = editBox };
2633 SetFileInput(fileInput);
2642 FreeContext(this.globalContext);
2643 FreeExcludedSymbols(this.excludedSymbols);
2646 FreeGlobalData(&this.globalData);
2648 if(this.privateModule)
2650 FreeTypeData(this.privateModule);
2651 delete this.privateModule;
2655 startTime = GetTime();
2656 printf("Cleaning up took %.3f seconds\n", startTime - parseCodeStart);
2658 printf("classes.count: %d\n", globalContext.classes.count);
2661 this.privateModule = __ecere_COM_Initialize(false, 1, null);
2663 SetPrivateModule(privateModule);
2666 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint"), type = ProcessTypeString("unsigned int", false) });
2667 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint64"), type = ProcessTypeString("unsigned int64", false) });
2668 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint32"), type = ProcessTypeString("unsigned int", false) });
2669 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint16"), type = ProcessTypeString("unsigned short", false) });
2670 globalContext.types.Add((BTNode)Symbol { string = CopyString("byte"), type = ProcessTypeString("unsigned char", false) });
2673 fileName = this.fileName;
2675 if(ide.workspace && ide.workspace.projects && fileName)
2677 for(p : ide.workspace.projects)
2679 char path[MAX_LOCATION];
2681 MakePathRelative(fileName, p.topNode.path, path);
2682 MakeSlashPath(path);
2684 pn = p.topNode.FindWithPath(path, false);
2693 project = ide.project;
2695 GetWorkingDir(oldWorkDir, MAX_LOCATION);
2697 ChangeWorkingDir(project.topNode.path);
2699 SetSomeSourceFileStack(fileName ? fileName : "", 0); //strcpy(sourceFileStack[0], fileName ? fileName : "");
2701 GetLastDirectory(fileName, mainModuleName);
2702 GetExtension(mainModuleName, extension);
2704 SetBuildingEcereCom(false);
2705 SetBuildingEcereComModule(false);
2707 // TODO: Get symbolsDir from project settings instead...
2710 DirExpression objDir = project.objDir;
2711 SetSymbolsDir(objDir.dir);
2713 // SetIncludeDirs(ide.projectView.project.config.includeDirs);
2714 // SetSysIncludeDirs(ide.ideSettings.systemDirs[includes]);
2718 switch(GetRuntimePlatform())
2720 case win32: SetSymbolsDir("obj/debug.win32"); break;
2721 case tux: SetSymbolsDir("obj/debug.linux"); break;
2722 case apple: SetSymbolsDir("obj/debug.apple"); break;
2724 SetIncludeDirs(null);
2725 SetSysIncludeDirs(null);
2729 if(ide.projectView && ide.projectView.IsModuleInProject(this.fileName))
2731 // TODO FIX for configless project
2732 if(ide.project.config && ide.project.config.options && ide.project.config.options.preprocessorDefinitions)
2734 for(item : ide.project.config.options.preprocessorDefinitions)
2736 if(!strcmp(item, "BUILDING_ECERE_COM"))
2738 SetBuildingEcereCom(true);
2745 if(!(strcmpi(mainModuleName, "instance.ec") && strcmpi(mainModuleName, "BinaryTree.ec") &&
2746 strcmpi(mainModuleName, "dataTypes.ec") && strcmpi(mainModuleName, "OldList.ec") &&
2747 strcmpi(mainModuleName, "String.ec") && strcmpi(mainModuleName, "BTNode.ec") &&
2748 strcmpi(mainModuleName, "Array.ec") && strcmpi(mainModuleName, "AVLTree.ec") &&
2749 strcmpi(mainModuleName, "BuiltInContainer.ec") && strcmpi(mainModuleName, "Container.ec") &&
2750 strcmpi(mainModuleName, "CustomAVLTree.ec") && strcmpi(mainModuleName, "LinkList.ec") &&
2751 strcmpi(mainModuleName, "List.ec") && strcmpi(mainModuleName, "Map.ec") &&
2752 strcmpi(mainModuleName, "Mutex.ec")))
2754 SetBuildingEcereComModule(true);
2757 // Predeclare all classes
2759 char symFile[MAX_FILENAME];
2760 char symLocation[MAX_LOCATION];
2761 ImportedModule module, next;
2763 GetLastDirectory(fileName, symFile);
2764 ChangeExtension(symFile, "sym", symFile);
2766 strcpy(symLocation, GetSymbolsDir());
2767 PathCat(symLocation, symFile);
2769 // if(!GetEcereImported() && !GetBuildingEcereCom())
2770 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2773 startTime = GetTime();
2775 eModule_LoadStrict(privateModule, "ecereCOM", privateAccess);
2777 printf("Loading ecereCOM took %.3f seconds\n", GetTime() - startTime);
2782 startTime = GetTime();
2784 // LoadSymbols(symLocation, normalImport, true);
2785 LoadSymbols(symLocation, preDeclImport, false);
2787 printf("Loading symbols took %.3f seconds\n", GetTime() - startTime);
2790 for(module = defines.first; module; module = next)
2793 if(module.type == moduleDefinition && strcmpi(module.name, mainModuleName))
2796 defines.Delete(module);
2801 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2802 SetDefaultDeclMode(privateAccess);
2804 SetDefaultDeclMode(defaultAccess);
2806 StripExtension(mainModuleName);
2807 module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };
2808 defines.AddName(module);
2816 startTime = GetTime();
2817 startFindClass = checkTypeTotalTime;
2821 printf("ParseEc took %.3f seconds, out of which %.3f seconds were in CheckType\n", GetTime() - startTime, checkTypeTotalTime - startFindClass);
2823 CheckDataRedefinitions();
2826 SetIncludeDirs(null);
2827 SetSysIncludeDirs(null);
2838 startTime = GetTime();
2840 PrePreProcessClassDefinitions();
2841 ComputeModuleClasses(privateModule);
2842 PreProcessClassDefinitions();
2843 ProcessClassDefinitions();
2845 printf("Initial Passes took %.3f seconds\n", GetTime() - startTime);
2846 startTime = GetTime();
2851 printf("ComputeDataTypes took %.3f seconds\n", GetTime() - startTime);
2852 startTime = GetTime();
2854 ProcessInstantiations();
2856 printf("ProcessInstantiations took %.3f seconds\n", GetTime() - startTime);
2859 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2861 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2862 if(!windowClass || windowClass.internalDecl)
2865 startTime = GetTime();
2867 // *** COMMENTED THIS OUT DUE TO ecereCOM issues
2868 // eModule_Load(this.privateModule.application.allModules.first ? this.privateModule.application.allModules.first : this.privateModule, "ecere", privateAccess);
2869 eModule_Load(this.privateModule, "ecere", privateAccess);
2871 printf("Loading ecere.dll took %.3f seconds\n", GetTime() - startTime);
2874 windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2876 if(windowClass && windowClass.data)
2877 ApplySkin(windowClass, app.currentSkin.name, null);
2881 startTime = GetTime();
2883 for(external = ast->first; external; external = external.next)
2885 if(external.type == classExternal)
2887 ClassDefinition _class = external._class;
2888 if(_class.baseSpecs && _class.baseSpecs->first && ((Specifier)_class.baseSpecs->first).type == nameSpecifier ) // classSpecifier
2890 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)_class.baseSpecs->first).name);
2893 if(eClass_GetDesigner(regClass) && !GetBuildingEcereComModule())
2895 Instance instance = eInstance_New(regClass);
2896 ObjectInfo classObject
2898 name = CopyString(_class._class.name);
2899 instance = instance;
2900 classDefinition = _class;
2901 oClass = classObject;
2904 classes.Add(classObject);
2908 // Moved this at bottom so that the file dialog doesn't show up in eCom
2909 designer.CreateObject(instance, classObject, true, null);
2910 sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, typeClass, false);
2912 if(_class.definitions)
2916 for(def = _class.definitions->first; def; def = def.next)
2920 case defaultPropertiesClassDef:
2923 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
2925 Identifier id = propDef.identifiers->first;
2928 Property prop = eClass_FindProperty(regClass, id.string, this.privateModule);
2931 Class propertyClass = prop.dataTypeClass;
2933 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
2934 if(prop.compiled && prop.Set && prop.Get && propertyClass && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp)
2936 FreeType(propDef.initializer.exp.destType);
2937 propDef.initializer.exp.destType = MkClassType(propertyClass.name);
2938 ProcessExpressionType(propDef.initializer.exp);
2940 if(propertyClass.type == structClass || propertyClass.type == noHeadClass || propertyClass.type == normalClass)
2942 Expression computed = CopyExpression(propDef.initializer.exp);
2943 ComputeExpression(computed);
2945 if(computed.isConstant && computed.type == instanceExp && !id.next)
2949 if(computed.instance._class && computed.instance._class.symbol &&
2950 computed.instance._class.symbol.registered &&
2951 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
2953 prop.Set(instance, computed.instance.data);
2955 // This was saved in the control and shouldn't be freed by FreeExpression...
2956 if(propertyClass.type == normalClass)
2957 computed.instance.data = null;
2961 // MOVED THIS UP NOW THAT char * IS A NORMAL CLASS
2962 else if(computed.type == stringExp)
2965 ReadString(temp, computed.string);
2966 prop.Set(instance, temp);
2969 propDef.variable = true;
2971 FreeExpression(computed);
2975 Expression computed = CopyExpression(propDef.initializer.exp);
2976 ComputeExpression(computed);
2977 if(computed.isConstant)
2979 //if(computed.type == memberExp) computed = computed.member.exp;
2981 if(computed.type == constantExp)
2983 Operand value = GetOperand(computed);
2984 DataValue valueData;
2985 valueData.i64 = value.i64;
2986 SetProperty(prop, instance, valueData);
2988 else if(computed.type == stringExp)
2991 ReadString(temp, computed.string);
2992 prop.Set(instance, temp);
2996 propDef.variable = true;
2998 FreeExpression(computed);
3002 propDef.variable = true;
3006 Method method = eClass_FindMethod(regClass, id.string, this.privateModule);
3007 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer &&
3008 propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
3011 // Maintain a list in FunctionDefinition of who is attached to it
3012 for(def = _class.definitions->first; def; def = def.next)
3014 if(def.type == functionClassDef)
3016 ClassFunction function = def.function;
3017 if(!strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
3019 function.attached.Add(OldLink { data = method });
3029 case declarationClassDef:
3031 Declaration decl = def.decl;
3034 case instDeclaration:
3036 Instantiation inst = decl.inst;
3037 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3038 if(instClass && eClass_GetDesigner(instClass))
3040 Instance control = eInstance_New(instClass);
3045 oClass = classObject;
3049 classObject.instances.Add(object);
3051 // TOCHECK: Why is this needed now?
3052 object.name = CopyString((inst.exp.type == memberExp) ? inst.exp.member.member.string : inst.exp.identifier.string);
3053 def.object = object;
3055 // if(object.name) { symbol = eList_Add(&curContext.symbols, sizeof(Symbol)); symbol.string = object.name; symbol.type = MkClassType(instClass.name); }
3057 designer.CreateObject(control, object, false, classObject.instance);
3058 sheet.AddObject(object, object.name ? object.name : inst._class.name, typeData, false);
3068 // Second pass, process instantiation members
3070 for(def = _class.definitions->first; def; def = def.next)
3074 case declarationClassDef:
3076 Declaration decl = def.decl;
3079 case instDeclaration:
3081 Instantiation inst = decl.inst;
3082 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3083 if(instClass && eClass_GetDesigner(instClass))
3086 object = object ? object.next : classObject.instances.first;
3087 control = object.instance;
3091 MembersInit members;
3092 for(members = inst.members->first; members; members = members.next)
3094 switch(members.type)
3096 case dataMembersInit:
3098 if(members.dataMembers)
3101 DataMember curMember = null;
3102 Class curClass = null;
3103 DataMember subMemberStack[256];
3104 int subMemberStackPos = 0;
3106 for(member = members.dataMembers->first; member; member = member.next)
3109 Identifier ident = member.identifiers ? member.identifiers->first : null;
3112 DataMember _subMemberStack[256];
3113 int _subMemberStackPos = 0;
3114 DataMember thisMember = (DataMember)eClass_FindDataMember(instClass, ident.string, privateModule, _subMemberStack, &_subMemberStackPos);
3118 thisMember = (DataMember)eClass_FindProperty(instClass, ident.string, privateModule);
3120 if(thisMember && thisMember.memberAccess == publicAccess)
3122 curMember = thisMember;
3123 curClass = curMember._class;
3124 memcpy(subMemberStack, _subMemberStack, sizeof(int) * _subMemberStackPos);
3125 subMemberStackPos = _subMemberStackPos;
3131 eClass_FindNextMember(instClass, &curClass, (DataMember *)&curMember, subMemberStack, &subMemberStackPos);
3132 if(curMember) found = true;
3134 if(found && curMember.isProperty)
3136 Property prop = (Property) curMember;
3137 Class propertyClass = prop.dataTypeClass;
3139 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3141 if(prop.compiled && prop.Set && prop.Get && propertyClass && member.initializer && member.initializer.type == expInitializer && member.initializer.exp)
3143 FreeType(member.initializer.exp.destType);
3144 member.initializer.exp.destType = MkClassType(propertyClass.name);
3147 ProcessExpressionType(member.initializer.exp);
3149 if(propertyClass.type == structClass || propertyClass.type == normalClass || propertyClass.type == noHeadClass)
3151 Expression 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);
4775 codeModified = false;
4776 formModified = false;
4778 moveAttached = false;
4784 int FindMethod(char * methodName /*Method method*/, ClassFunction*functionPtr, Location propLoc)
4787 ClassFunction function = null;
4790 ObjectInfo object = this.selected;
4792 if(object && object == this.oClass)
4794 ClassDefinition classDef = object.oClass.classDefinition;
4796 if(classDef && classDef.definitions)
4798 for(def = classDef.definitions->first; def; def = def.next)
4800 if(def.type == functionClassDef && def.function.declarator)
4802 if(!strcmp(def.function.declarator.symbol.string, methodName))
4804 function = def.function;
4809 else if(def.type == defaultPropertiesClassDef)
4813 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4815 Identifier ident = propDef.identifiers ? propDef.identifiers->first : null;
4816 if(ident && !ident.next)
4818 if(!strcmp(ident.string, methodName) && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4822 propLoc = propDef.loc;
4825 ClassDefinition classDef = object.oClass.classDefinition;
4827 if(classDef.definitions)
4829 for(def = classDef.definitions->first; def; def = def.next)
4831 if(def.type == functionClassDef)
4833 if(!strcmp(def.function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
4835 function = def.function;
4854 Instantiation inst = object.instCode;
4856 // Check here to see if the method already exists, no need to call ModifyCode in that case
4857 if(inst && inst.members)
4859 MembersInit members;
4860 for(members = inst.members->first; members; members = members.next)
4862 switch(members.type)
4864 case dataMembersInit:
4866 if(members.dataMembers)
4869 for(member = members.dataMembers->first; member; member = member.next)
4871 Identifier ident = member.identifiers ? member.identifiers->first : null;
4872 if(ident && !ident.next)
4874 if(!strcmp(ident.string, methodName) && member.initializer && member.initializer.type == expInitializer && member.initializer.exp && member.initializer.exp.type == memberExp /*ExpIdentifier*/)
4878 propLoc = member.loc;
4881 ClassDefinition classDef = object.oClass.classDefinition;
4883 if(classDef.definitions)
4885 for(def = classDef.definitions->first; def; def = def.next)
4887 if(def.type == functionClassDef)
4889 if(def.function.declarator && !strcmp(def.function.declarator.symbol.string, member.initializer.exp.identifier.string))
4891 function = def.function;
4900 // TODO: Fix memory leak
4901 function = ClassFunction
4903 declarator = Declarator { symbol = Symbol { string = CopyString(member.initializer.exp.member.member ? member.initializer.exp.member.member.string : "") } }
4915 case methodMembersInit:
4917 if(members.function.declarator && !strcmp(members.function.declarator.symbol.string, methodName))
4919 function = members.function;
4931 if(functionPtr) *functionPtr = function;
4935 void GoToMethod(char * methodName /*Method method*/)
4939 ObjectInfo object = selected;
4940 EditBoxStream f { editBox = editBox };
4941 ClassFunction function = null;
4942 bool atChar = false;
4946 Location propLoc = { {0,0,-1} };
4949 if(FindMethod(methodName, &function, &propLoc) == 1 && object != this.oClass) indent = 9;
4950 if(function && function.body)
4953 f.Seek(function.body.loc.start.pos+1, current);
4963 f.Seek(-1, current);
4968 else if(!isspace(ch))
4970 f.Seek(-1, current);
4976 else if(propLoc.start.pos > -1)
4978 f.Seek(propLoc.start.pos, current);
4981 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
4983 if(function || propLoc.start.pos > -1)
4985 editBox.SetSelPos(l1, y1, atChar ? x1 : indent, l2, y2, atChar ? x2 : indent);
4986 editBox.CenterOnCursor();
4987 SetState(normal, false, 0);
4990 if(function && function.declarator && function.declarator.symbol && !function.declarator.symbol.type)
4992 FreeClassFunction(function);
4998 void FindCompatibleMethods(Method method, OldList compatible)
5000 ClassDefinition classDef = this.oClass.classDefinition;
5001 if(classDef && classDef.definitions)
5004 Class baseClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5007 Symbol classSym { };
5008 Symbol selectedClass;
5009 if(this.selected == this.oClass)
5010 selectedClass = classSym;
5012 selectedClass = FindClass(this.selected.instance._class.name);
5014 regClass.name = classDef._class.name;
5015 regClass.base = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5016 for(def = classDef.definitions->first; def; def = def.next)
5018 if(def.type == functionClassDef && def.function.declarator)
5020 Method vMethod = eClass_FindMethod(baseClass, def.function.declarator.symbol.string, this.privateModule);
5022 vMethod = eClass_FindMethod(this.selected.instance._class, def.function.declarator.symbol.string, this.privateModule);
5025 Type type = def.function.declarator.symbol.type;
5026 if(CheckCompatibleMethod(method, type, regClass, this.selected == this.oClass, FindClass(this.selected.instance._class.name)))
5028 compatible.Add(OldLink { data = def.function });
5034 if(this.oClass && this.oClass.instance)
5036 classSym.registered = regClass;
5037 //classSym.registered = this.oClass.oClass;
5039 for(_class = regClass.base; _class; _class = _class.base)
5042 for(testMethod = (Method)_class.methods.first; testMethod; testMethod = (Method)((BTNode)testMethod).next)
5044 // TODO: Understand why these functions popup in attach list
5045 if(testMethod.type != virtualMethod /*&& testMethod.function != Window_OnGetString && testMethod.function != Window_OnGetDataFromString*/)
5047 if(!testMethod.dataType)
5048 testMethod.dataType = ProcessTypeString(testMethod.dataTypeString, false);
5050 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5051 if(CheckCompatibleMethod(method, testMethod.dataType, this.oClass.instance._class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5052 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, this.selected == this.oClass, FindClass(this.oClass.oClass.name)))
5054 // TODO: Fix memory leak, Figure out if it should be ClassFunction or FunctionDefinition
5055 // ClassFunction function { };
5056 FunctionDefinition function { };
5058 function.declarator = Declarator { };
5059 function.declarator.symbol = Symbol { string = CopyString(testMethod.name) };
5060 excludedSymbols.Add(function.declarator.symbol);
5062 compatible.Add(OldLink { data = function });
5073 void AddMethod(Method method)
5077 char methodName[1024];
5078 strcpy(methodName, method.name);
5079 if(!FindMethod(methodName, null, null))
5081 methodAction = actionAddMethod;
5082 this.method = method;
5086 GoToMethod(methodName);
5090 void DeleteMethod(ClassFunction function)
5094 methodAction = actionDeleteMethod;
5095 this.function = function;
5103 void AttachMethod(Method method, ClassFunction function)
5107 // If it's an instance we'll ask if we want to move it inside...
5108 if(!function.attached.count && function.body)
5110 // Find the function in the _class to check if it's a virtual function
5111 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5112 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5113 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5115 for(def = this.classDefinition.first; def; def = def.next)
5117 if(def.type == functionClassDef)
5119 if(def.function == function)
5124 if(!method || method.type != virtualMethod)
5127 sprintf(title, "Attach %s", function.declarator.symbol.string);
5128 if(MessageBox { type = yesNo, master = parent, text = title, contents = "Method is unused. Move method inside instance?"}.Modal() == yes)
5130 moveAttached = true;
5135 methodAction = actionAttachMethod;
5136 this.method = method;
5137 this.function = function;
5144 void ReAttachMethod(Method method, ClassFunction function)
5148 // If it's an instance we'll ask if we want to move it inside...
5149 if(!function.attached.count && function.body)
5151 // Find the function in the _class to check if it's a virtual function
5152 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5153 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5154 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5156 for(def = this.classDefinition.first; def; def = def.next)
5158 if(def.type == functionClassDef)
5160 if(def.function == function)
5165 if(!method || method.type != virtualMethod)
5168 sprintf(title, "Attach %s", function.declarator.symbol.string);
5169 if(MessageBox { type = yesNo, master = parent, text = title,
5170 contents = "Method is unused. Move method inside instance?" }.Modal() == yes)
5172 moveAttached = true;
5177 methodAction = actionReattachMethod;
5178 this.method = method;
5179 this.function = function;
5186 void DetachMethod(Method method, ClassFunction function, int type)
5194 hasClose = true, borderStyle = sizable, minClientSize = { 300, 55 },
5195 master = sheet, text = "Name detached method", background = activeBorder
5199 dialog, anchor = { horz = 45, top = 30 }, size = { 80 }, text = "Cancel", hotKey = escape,
5200 id = DialogResult::cancel, NotifyClicked = ButtonCloseDialog
5204 dialog, anchor = { horz = -45, top = 30 }, size = { 80 }, text = "OK", isDefault = true,
5205 id = DialogResult::ok, NotifyClicked = ButtonCloseDialog
5209 dialog, anchor = { left = 5, right = 5, top = 5 }
5211 sprintf(methodName, "%s_%s", selected.name, method.name);
5212 nameBox.contents = methodName;
5214 result = dialog.Modal() == ok;
5215 strcpy(methodName, nameBox.contents);
5220 // If the method is not attached, move it outside
5223 // Add this class to the methodName
5224 char name[1024] = "";
5226 if(this.selected != this.oClass && !method.dataType.thisClass)
5228 strcat(name, this.selected.instance._class.name);
5230 strcat(name, this.methodName);
5231 strcpy(this.methodName, name);
5233 else if(method.dataType.thisClass && (this.selected == this.oClass || !eClass_IsDerived(this.oClass.instance._class, method.dataType.thisClass.registered)))
5235 strcat(name, method.dataType.thisClass.string);
5237 strcat(name, this.methodName);
5238 strcpy(this.methodName, name);
5241 this.moveAttached = true;
5244 this.methodAction = actionDetachMethod;
5245 this.method = method;
5246 this.function = function;
5253 void AddObject(Instance instance, ObjectInfo * object)
5257 //*object = _class.instances.Add(sizeof(ObjectInfo));
5258 *object = ObjectInfo { };
5259 oClass.instances.Insert((selected.oClass == selected) ? null : selected, *object);
5260 (*object).oClass = oClass;
5261 (*object).instance = instance;
5266 sprintf(name, "%c%s%d", tolower(instance._class.name[0]), instance._class.name+1, id);
5268 // if(strcmp(name, this.oClass.instance.name))
5271 for(check = oClass.instances.first; check; check = check.next)
5272 if(!check.deleted && check.name && !strcmp(name, check.name))
5276 (*object).name = CopyString(name);
5281 toolBox.controlClass = null;
5285 //sheet.AddObject(*object, (*object).name, TypeData, true);
5290 void EnsureUpToDate()
5292 if(sheet && codeModified)
5296 void SelectObject(ObjectInfo object)
5299 oClass = object ? object.oClass : null;
5301 designer.SelectObject(object, object ? object.instance : null);
5304 void SelectObjectFromDesigner(ObjectInfo object)
5307 sheet.SelectObject(object);
5310 void EnumerateObjects(Sheet sheet)
5314 for(oClass = classes.first; oClass; oClass = oClass.next)
5318 sheet.AddObject(oClass, oClass.name ? oClass.name : oClass.instance._class.name, typeClass, false);
5319 for(object = oClass.instances.first; object; object = object.next)
5320 sheet.AddObject(object, object.name ? object.name : object.instance._class.name, typeData, false);
5322 sheet.SelectObject(selected);
5327 designer.AddObject();
5330 void DeleteObject(ObjectInfo object)
5332 delete object.instance;
5333 object.deleted = true;
5334 object.modified = true;
5335 object.oClass.modified = true;
5337 if(selected == object)
5339 bool looped = false;
5340 ObjectInfo select = object;
5344 select = select.prev;
5348 select = object.oClass.instances.last;
5355 sheet.SelectObject(select ? select : oClass);
5358 if(!object.instCode && object.oClass != object)
5361 oClass.instances.Delete(object);
5364 if(sheet.codeEditor == this)
5365 sheet.DeleteObject(object);
5368 void RenameObject(ObjectInfo object, char * name)
5372 // Validate the name:
5373 if(object != oClass && (!name || !name[0])) valid = true; // What's this one again?
5374 else if(name[0] && (isalpha(name[0]) || name[0] == '_'))
5377 for(c = 0; name[c]; c++)
5378 if(!isalnum(name[c]) && name[c] != '_' && name[c] != '_')
5386 object.name = (name && name[0]) ? CopyString(name) : null;
5388 sheet.RenameObject(object, object.name ? object.name : object.instance._class.name);
5392 void DesignerModifiedObject()
5394 sheet.ListProperties(false);
5398 void ListSubMembers(Type member)
5402 for(subMember = member.members.first; subMember; subMember = subMember.next)
5406 DataRow row = membersList.AddString(subMember.name);
5407 row.icon = icons[typeData];
5411 ListSubMembers(subMember);
5416 void ListSubDataMembers(DataMember member, bool isPrivate)
5418 DataMember subMember;
5419 for(subMember = member.members.first; subMember; subMember = subMember.next)
5421 if((subMember.memberAccess == publicAccess && !isPrivate) || subMember._class.module == privateModule)
5425 DataRow row = membersList.AddString(subMember.name);
5426 BitmapResource bitmap = null;
5427 if(!subMember.dataType)
5428 subMember.dataType = ProcessTypeString(subMember.dataTypeString, false);
5430 if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
5432 char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
5435 bitmap = { bitmapName };
5436 membersList.AddResource(bitmap);
5439 row.icon = bitmap ? bitmap : icons[(subMember.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5443 ListSubDataMembers(subMember, isPrivate || member.memberAccess == privateAccess);
5449 void ListClassMembers(Class whatClass, bool methodsOnly)
5452 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5453 bool isPrivate = false;
5455 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5457 Method method, methodIt;
5459 DataMember memberIt;
5461 for(methodIt = (Method)_class.methods.first; methodIt; methodIt = (Method)((BTNode)methodIt).next)
5463 method = eClass_FindMethod(whatClass, methodIt.name, privateModule);
5464 if(methodIt.memberAccess == privateAccess && method && method.memberAccess == publicAccess)
5466 if(method && method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5468 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5470 DataRow row = membersList.FindString(method.name);
5473 row = membersList.AddString(method.name);
5475 if(!method.dataType)
5476 method.dataType = ProcessTypeString(method.dataTypeString, false);
5478 row.icon = icons[(method.type == virtualMethod && method.dataType && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5486 for(memberIt = _class.membersAndProperties.first; memberIt; memberIt = memberIt.next)
5490 if(memberIt.isProperty)
5492 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5494 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5498 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5500 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5503 if(memberIt.memberAccess == privateAccess && member && member.memberAccess == publicAccess)
5509 if(member && (member.memberAccess == publicAccess || member._class.module == privateModule))
5511 if(member.isProperty)
5513 Property prop = (Property) member;
5514 if(!membersList.FindString(prop.name))
5516 DataRow row = membersList.AddString(prop.name);
5517 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5520 else if(member.name && !membersList.FindString(member.name))
5522 DataRow row = membersList.AddString(member.name);
5524 BitmapResource bitmap = null;
5525 if(!member.dataType)
5526 member.dataType = ProcessTypeString(member.dataTypeString, false);
5528 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5530 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5533 bitmap = { bitmapName };
5534 membersList.AddResource(bitmap);
5537 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5540 ListSubDataMembers(member, member.memberAccess == privateAccess);
5544 if(_class.inheritanceAccess == privateAccess)
5547 if(_class.module != privateModule) break;
5552 void ListClassMembersMatch(Class whatClass, Type methodType)
5555 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5556 bool isPrivate = false;
5558 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5564 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5566 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5568 if(method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5570 if(!method.dataType)
5571 method.dataType = ProcessTypeString(method.dataTypeString, false);
5573 if(MatchTypes(method.dataType, methodType, null, whatClass, /*null, */whatClass, false, true, false, false))
5575 DataRow row = membersList.FindString(method.name);
5578 row = membersList.AddString(method.name);
5579 row.icon = icons[(method.type == virtualMethod && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5585 if(_class.inheritanceAccess == privateAccess)
5588 if(_class.module != privateModule) break;
5593 void ListClassPropertiesAndVirtual(Class whatClass)
5596 bool isPrivate = false;
5597 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5603 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5605 if(method.type == virtualMethod)
5607 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5609 DataRow row = membersList.FindString(method.name);
5612 row = membersList.AddString(method.name);
5614 if(!method.dataType)
5615 method.dataType = ProcessTypeString(method.dataTypeString, false);
5617 row.icon = icons[method.dataType.thisClass ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5623 for(member = _class.membersAndProperties.first; member; member = member.next)
5625 if(member.memberAccess == publicAccess || member._class.module == privateModule)
5627 if(member.isProperty)
5629 Property prop = (Property)member;
5631 DataRow row = membersList.AddString(prop.name);
5632 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5635 else if(member.name)
5637 DataRow row = membersList.AddString(member.name);
5639 BitmapResource bitmap = null;
5640 if(!member.dataType)
5641 member.dataType = ProcessTypeString(member.dataTypeString, false);
5643 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5645 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5648 bitmap = { bitmapName };
5649 membersList.AddResource(bitmap);
5652 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5655 ListSubDataMembers(member, member.memberAccess == privateAccess || isPrivate);
5658 if(_class.inheritanceAccess == privateAccess)
5661 if(_class.module != privateModule) break;
5666 void ListMembers(Type type)
5668 if(type && (type.kind == classType || type.kind == structType || type.kind == unionType))
5672 if(type.kind == classType)
5675 ListClassMembers(type._class.registered, false);
5680 for(member = type.members.first; member; member = member.next)
5684 DataRow row = membersList.AddString(member.name);
5685 row.icon = icons[typeData];
5687 else if(member.kind == structType || member.kind == unionType)
5688 ListSubMembers(member);
5694 void ListModule(Module mainModule, int recurse, bool listClasses)
5697 ListNameSpace(mainModule.application.systemNameSpace, 1, listClasses);
5698 ListNameSpace(mainModule.application.privateNameSpace, 1, listClasses);
5699 ListNameSpace(mainModule.application.publicNameSpace, 1, listClasses);
5700 for(module = mainModule.application.allModules.first; module; module = module.next)
5702 if(ModuleVisibility(mainModule, module))
5703 ListNameSpace(module.publicNameSpace, recurse, listClasses);
5707 void ListNameSpace(NameSpace nameSpace, int recurse, bool listClasses)
5714 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5716 Class _class = link.data;
5717 if(_class.type != systemClass)
5719 DataRow row = membersList.AddString(_class.name);
5720 row.icon = (_class.type == unitClass || _class.type == enumClass) ? icons[typeDataType] : icons[typeClass];
5725 for(link = (BTNamedLink)nameSpace.defines.first; link; link = (BTNamedLink)((BTNode)link).next )
5727 DefinedExpression definedExp = link.data;
5728 DataRow row = membersList.AddString(link /*definedExp*/.name);
5729 row.icon = icons[typeData];
5732 for(link = (BTNamedLink)nameSpace.functions.first; link; link = (BTNamedLink)((BTNode)link).next)
5734 GlobalFunction function = link.data;
5735 DataRow row = membersList.AddString(link /*function*/.name);
5736 row.icon = icons[typeMethod];
5740 for(ns = (NameSpace *)nameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
5742 if(recurse != 2 && listClasses)
5744 if(!membersList.FindString(ns->name))
5746 DataRow row = membersList.AddString(ns->name);
5747 row.icon = icons[typeNameSpace];
5752 ListNameSpace(ns, 2, listClasses);
5756 void ListEnumValues(Class _class)
5758 for(; _class && _class.type == enumClass; _class = _class.base)
5760 EnumClassData enumeration = (EnumClassData)_class.data;
5762 for(item = enumeration.values.first; item; item = item.next)
5764 DataRow row = membersList.AddString(item.name);
5765 row.icon = icons[typeEnumValue];
5770 bool ListEnumsModule(Module mainModule, Type dest)
5772 bool result = false;
5774 result |= ListEnums(mainModule.application.systemNameSpace, dest);
5775 result |= ListEnums(mainModule.application.privateNameSpace, dest);
5776 result |= ListEnums(mainModule.application.publicNameSpace, dest);
5777 for(module = mainModule.application.allModules.first; module; module = module.next)
5779 if(ModuleVisibility(mainModule, module))
5780 result |= ListEnums(module.publicNameSpace, dest);
5785 void ListNameSpaceByString(Module mainModule, char * string)
5787 NameSpace * nameSpace;
5789 nameSpace = FindNameSpace(mainModule.application.systemNameSpace, string);
5790 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5791 nameSpace = FindNameSpace(mainModule.application.privateNameSpace, string);
5792 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5793 nameSpace = FindNameSpace(mainModule.application.publicNameSpace, string);
5794 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5795 for(module = mainModule.application.allModules.first; module; module = module.next)
5797 if(ModuleVisibility(mainModule, module))
5799 nameSpace = FindNameSpace(module.publicNameSpace, string);
5800 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5805 bool ListEnums(NameSpace nameSpace, Type dest)
5808 bool result = false;
5810 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5812 Class _class = link.data;
5813 if(_class.type == enumClass && (dest.kind != classType || !dest._class || dest._class.registered != _class))
5815 OldList conversions { };
5817 type.kind = classType;
5818 type._class = FindClass(_class.name);
5819 if(MatchTypes(type, dest, &conversions, null, null, true, false, false, false))
5821 ListEnumValues(_class);
5824 conversions.Free(null);
5828 for(nameSpace = (NameSpace *)nameSpace.nameSpaces.first; nameSpace != null; nameSpace = (NameSpace *)((BTNode)nameSpace).next)
5830 result |= ListEnums(nameSpace, dest);
5835 NameSpace * FindNameSpace(NameSpace nameSpace, char * name)
5839 for(c = 0; (ch = name[c]); c++)
5841 if(ch == '.' || (ch == ':' && name[c+1] == ':'))
5843 NameSpace * newSpace;
5844 char * spaceName = new char[c - start + 1];
5845 memcpy(spaceName, name + start, c - start);
5846 spaceName[c-start] = '\0';
5847 newSpace = (NameSpace *)nameSpace.nameSpaces.FindString(spaceName);
5851 nameSpace = newSpace;
5860 return (NameSpace *)nameSpace;
5863 void ListSymbols(Expression exp, bool enumOnly, char * string, Identifier realIdentifier)
5865 bool listedEnums = false;
5866 Type destType = (exp && exp.destType && !exp.destType.truth) ? exp.destType : null;
5867 bool listClasses = true;
5869 if(exp && (exp.type == identifierExp || exp.type == memberExp))
5871 // TOCHECK: This memberExp check wasn't here... Some stuff isn't quite done
5872 Identifier id = (exp.type == memberExp) ? exp.member.member : exp.identifier;
5873 char * colons = id ? RSearchString(id.string, "::", strlen(id.string), true, false) : null;
5875 if(exp.type == identifierExp)
5876 id = realIdentifier;
5878 if(id && id._class && !id._class.name)
5880 listClasses = false;
5883 else if(id && id._class && id._class.name)
5887 Class _class = id.classSym.registered;
5888 if(_class && _class.type == enumClass)
5890 ListEnumValues(_class);
5893 ListClassMembers(id.classSym.registered, true);
5898 else if(id && colons)
5900 ListNameSpaceByString(this.privateModule, id.string);
5905 if(this.privateModule && destType && (destType.kind != pointerType || destType.type.kind != voidType) && destType.kind != ellipsisType)
5907 listedEnums = ListEnumsModule(this.privateModule, destType);
5910 if(destType && destType.kind == classType && destType._class.registered && destType._class.registered.type == enumClass)
5912 ListEnumValues(destType._class.registered);
5915 ListClassPropertiesAndVirtual(insideClass);
5919 else if(destType && destType.kind == enumType)
5923 for(value = destType.members.first; value; value = value.next)
5925 DataRow row = membersList.AddString(value.name);
5926 row.icon = icons[typeEnumValue];
5930 ListClassPropertiesAndVirtual(insideClass);
5934 else if(insideClass && !enumOnly)
5936 ListClassPropertiesAndVirtual(insideClass);
5939 if(listedEnums && string && string[0])
5941 DataRow row = membersList.FindSubString(string);
5943 listedEnums = false;
5946 if(!insideClass && exp && exp.destType && exp.destType.kind == functionType && GetThisClass())
5948 ListClassMembersMatch(GetThisClass(), exp.destType);
5950 else if(!insideClass && !enumOnly && !listedEnums)
5953 Symbol symbol = null;
5957 ListClassMembers(GetThisClass(), false);
5960 for(ctx = listClasses ? GetCurrentContext() : GetTopContext(); ctx != GetTopContext().parent && !symbol; ctx = ctx.parent)
5962 for(symbol = (Symbol)ctx.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
5964 // Don't list enum values?
5965 //if(symbol.type.kind != TypeEnum)
5966 DataRow row = membersList.FindString(symbol.string);
5969 if(GetBuildingEcereComModule() && symbol.type && symbol.type.kind == functionType && eSystem_FindFunction(privateModule, symbol.string))
5971 row = membersList.AddString(symbol.string);
5972 if(symbol.type && symbol.type.kind == functionType)
5973 row.icon = icons[typeMethod];
5974 else if(symbol.type && symbol.type.kind == enumType)
5976 row.icon = icons[typeEnumValue];
5980 BitmapResource bitmap = null;
5981 if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
5983 char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
5986 bitmap = { bitmapName };
5987 membersList.AddResource(bitmap);
5990 row.icon = bitmap ? bitmap : icons[typeData];
5997 for(symbol = (Symbol)ctx.types.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
5999 DataRow row = membersList.FindString(symbol.string);
6002 row = membersList.AddString(symbol.string);
6003 if(symbol.type.kind == functionType)
6004 row.icon = icons[typeMethod];
6005 else if(symbol.type.kind == classType && (!symbol.type._class.registered || (symbol.type._class.registered.type != unitClass && symbol.type._class.registered.type != enumClass)))
6007 row.icon = icons[typeClass];
6011 row.icon = icons[typeDataType];
6018 ListModule(this.privateModule, 1, listClasses);
6019 // TODO: Implement this with name space
6023 for(data = globalData.first; data; data = data.next)
6025 DataRow row = membersList.FindString(data.name);
6027 data.dataType = ProcessTypeString(data.dataTypeString, false);
6030 row = membersList.AddString(data.name);
6032 if(data.dataType && data.dataType.kind == TypeEnum)
6034 row.icon = icons[typeEnumValue];
6038 BitmapResource bitmap = null;
6039 if(data.dataType && data.dataType.kind == classType && data.dataType._class && data.dataType._class)
6041 char * bitmapName = (char *)eClass_GetProperty(data.dataType._class.registered, "icon");
6044 bitmap = { bitmapName };
6045 membersList.AddResource(bitmap);
6048 row.icon = bitmap ? bitmap : icons[typeData];
6056 DataRow row = membersList.AddString("Min");
6057 row.icon = icons[typeMethod];
6059 row = membersList.AddString("Max");
6060 row.icon = icons[typeMethod];
6062 row = membersList.AddString("Abs");
6063 row.icon = icons[typeMethod];
6065 row = membersList.AddString("Sgn");
6066 row.icon = icons[typeMethod];
6072 void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
6074 EditBoxStream f { editBox = editBox };
6079 updatingCode = true;
6081 if(!method.dataType)
6082 method.dataType = ProcessTypeString(method.dataTypeString, false);
6084 DeleteJunkBefore(f, function.loc.start.pos, &position);
6085 f.DeleteBytes(function.loc.end.pos - function.loc.start.pos - 1);
6087 // ADDING METHOD HERE
6089 Type dataType = method.dataType;
6090 Type returnType = dataType.returnType;
6092 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
6098 if(extraIndent) f.Printf(" ");
6100 OutputType(f, returnType, false);
6104 if(dataType.thisClass && !dataType.classObjectType && (!isInstance || !insideClass || !eClass_IsDerived(insideClass, dataType.thisClass.registered)))
6106 if(dataType.thisClass.shortName)
6107 f.Printf(dataType.thisClass.shortName);
6109 f.Printf(dataType.thisClass.string);
6112 f.Printf(method.name);
6114 for(param = dataType.params.first; param; param = param.next)
6116 // Decided not to write void...
6117 if(param.kind != voidType)
6119 OutputType(f, param, true);
6125 if(extraIndent) f.Printf(" ");
6126 f.Printf(" %c\n", OpenBracket);
6128 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6132 //if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
6134 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
6136 if(extraIndent) f.Printf(" ");
6137 f.Printf(" return true;\n");
6139 else if(returnType && returnType.kind != voidType)
6141 if(extraIndent) f.Printf(" ");
6142 f.Printf(" return 0;\n");
6148 if(returnType.kind != voidType)
6149 f.Printf("return ");
6150 f.Printf("%s::%s(this", classDef.base.name, method.name);
6151 for(param = dataType.params.first; param; param = param.next)
6154 f.Printf(param.name);
6161 if(extraIndent) f.Printf(" ");
6162 f.Printf(" %c", CloseBracket);
6167 if(extraIndent) { x1 += 3; x2 += 3; }
6168 editBox.SetSelPos(l1, y1, x1 + 6, l2, y2, x2 + 6);
6170 this.updatingCode = false;
6174 // Return false if we overrided a function and don't want to run params listing
6175 bool InvokeAutoComplete(bool enumOnly, int pointer, bool caretMove)
6177 bool didOverride = false;
6178 EditLine line = editBox.line;
6179 char * text = line.text;
6180 int lineNum, charPos;
6181 Expression exp = null;
6184 //Identifier id = null;
6185 Expression memberExp = null;
6186 Identifier realIdentifier = null;
6188 if(!privateModule) return !didOverride;
6190 insideFunction = null;
6192 charPos = editBox.charPos + 1;
6193 if(!membersListShown)
6198 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6200 EditBoxStream f { editBox = editBox };
6202 updatingCode = true;
6203 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6207 if(!f.Seek(-1, current))
6210 if(!isspace(ch)) break;
6211 f.Seek(-1, current);
6213 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6215 lineNum = editBox.lineNumber + 1;
6216 charPos = editBox.charPos + 1;
6218 updatingCode = false;
6221 if(!membersListShown)
6223 memberExp = FindExpTree(ast, lineNum, charPos);
6224 if(memberExp && (memberExp.type == TypeKind::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6229 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6231 EditBoxStream f { editBox = editBox };
6234 updatingCode = true;
6236 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6239 if(ch == '}' || ch == ',' || ch == ')')
6241 f.Seek(-1, current);
6249 if(!f.Seek(-1, current))
6252 if(!isspace(ch)) break;
6253 f.Seek(-1, current);
6257 f.Seek(-1, current);
6259 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6261 lineNum = editBox.lineNumber + 1;
6262 charPos = editBox.charPos + 1;
6264 updatingCode = false;
6267 realIdentifier = FindCtxTree(ast, lineNum, charPos);
6272 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6273 lineNum = editBox.lineNumber + 1;
6274 charPos = editBox.charPos/* + 1*/;
6278 char tempString[1024];
6279 char * string = null;
6280 CodePosition idStart, idEnd;
6282 if(membersListShown)
6284 char * buffer = membersLine.text;
6286 bool firstChar = true;
6288 string = tempString;
6290 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
6292 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6293 if(!isSpace) firstChar = false;
6295 string[len++] = buffer[c];
6299 else //if(realIdentifier)//if(id)
6302 char * buffer = id.string;
6304 bool firstChar = true;
6306 string = tempString;
6307 for(c = 0; c<= charPos - id.loc.start.charPos; c++)
6309 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6310 if(!isSpace) firstChar = false;
6312 string[len++] = buffer[c];
6318 EditLine editLine = editBox.line;
6319 bool firstChar = true;
6322 string = tempString;
6323 for(y = lineNum-1; y >= 0; y--)
6325 char * buffer = editLine.text;
6326 int lineCount = editLine.count;
6327 for(x = (y == lineNum-1) ? (Min(charPos, lineCount) - 1 ): lineCount-1; x >= 0; x--)
6329 bool isSpace = (buffer[x] == ' ' || buffer[x] == '\t');
6334 idEnd.charPos = x + 2;
6339 // TESTING THIS CODE HERE FOR NOT CONSIDERING bool when doing ctrl-space past it
6342 idEnd.charPos = x + 2;
6349 if(!isalnum(buffer[x]) && buffer[x] != '_')
6355 memmove(string+1, string, len++);
6356 string[0] = buffer[x];
6360 //if(done || firstChar)
6361 if(done || !firstChar)
6363 editLine = editLine.prev;
6366 if(!strcmp(string, "case"))
6372 else if(!strcmp(string, "return"))
6378 else if(!strcmp(string, "delete"))
6384 else if(!strcmp(string, "new"))
6390 else if(!strcmp(string, "renew"))
6398 idStart.charPos = x + 1;
6399 idStart.line = y + 1;
6402 if(!membersListShown)
6404 membersList.Clear();
6405 if(memberExp && (memberExp.type == ExpressionType::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6407 Type type = memberExp.member.exp.expType;
6408 if(pointer == 2 && type)
6410 if(type.kind == pointerType || type.kind == arrayType)
6419 ListSymbols(exp, enumOnly, string, realIdentifier);
6421 membersList.Sort(null, 1);
6426 // Virtual function override
6427 Identifier id = GetDeclId(insideFunction.declarator);
6428 char * string = id ? id.string : null;
6430 Method method = eClass_FindMethod(GetThisClass(), string, this.privateModule);
6433 if(method.type != virtualMethod || (!insideInstance && method._class == GetThisClass()))
6434 insideFunction = null;
6437 OverrideVirtualFunction(insideFunction, method, GetThisClass(), insideInstance, insideInstance && insideClass);
6442 if(!didOverride) //insideFunction)
6444 rowCount = membersList.rowCount;
6447 DataRow row = string ? membersList.FindSubString(string) : null;
6448 if(row && !membersList.FindSubStringAfter(row, string) && !caretMove)
6450 char * newString = row.string;
6451 if(!membersListShown)
6453 membersLoc.start.line = idStart.line-1;
6454 membersLoc.start.charPos = idStart.charPos-1;
6455 //membersLoc.end = membersLoc.start;
6456 membersLoc.end.charPos = idEnd.charPos-1;
6457 membersLoc.end.line = idEnd.line-1;
6458 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6459 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6464 membersList.Destroy(0);
6465 membersListShown = false;
6468 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
6470 line, membersLoc.start.line, membersLoc.start.charPos,
6471 line, membersLoc.end.line, membersLoc.end.charPos);
6472 editBox.PutS(newString);
6478 row = membersList.FindSubStringi(string);
6480 membersList.currentRow = row;
6481 membersList.currentRow.selected = false;
6484 membersList.currentRow = row;
6486 if(!membersListShown)
6490 // TESTING THESE ADDITIONS TO THE IF SO THAT CARET ISNT MOVED IF NOT ON TOP OF A WORD
6491 if(string && string[0] && lineNum == idStart.line && charPos >= idStart.charPos-1 && charPos <= idEnd.charPos-1)
6492 editBox.SetSelPos(l1, y1, idStart.charPos-1, l2, y2, idStart.charPos-1);
6493 editBox.GetCaretPosition(caret);
6494 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6496 membersList.master = this;
6498 caret.y += editBox.GetCaretSize();
6500 membersList.Create();
6503 int x = caret.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6504 int y = caret.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6505 Window parent = membersList.parent;
6507 if(!paramsAbove && (paramsShown || y + membersList.size.h > parent.clientSize.h))
6509 y -= editBox.GetCaretSize() + membersList.size.h;
6510 membersAbove = true;
6513 membersAbove = false;
6515 membersList.position = { x, y };
6519 membersLoc.start.line = lineNum - 1;
6521 if(string && string[0])
6523 membersLoc.start.charPos = idStart.charPos-1;
6524 membersLoc.end = membersLoc.start;
6525 //membersLoc.end.charPos = id.loc.end.charPos-1;
6526 membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6530 membersLoc.start.charPos = charPos;
6531 membersLoc.end = membersLoc.start;
6532 membersLoc.end.charPos = charPos;
6534 membersListShown = true;
6536 // Hack to keep caret shown
6537 editBox.GetCaretPosition(caret);
6538 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6541 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
6547 SetCurrentContext(globalContext);
6550 return !didOverride;
6553 void InvokeParameters(bool exact, bool reposition, bool caretMove)
6555 EditLine line = editBox.line;
6556 char * text = line.text;
6557 int lineNum, charPos;
6558 Expression exp = null;
6562 charPos = editBox.charPos + 1;
6565 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6567 EditBoxStream f { editBox = editBox };
6570 updatingCode = true;
6571 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6574 if(ch == '}' || ch == ',' || ch == ')')
6576 f.Seek(-1, current);
6584 if(!f.Seek(-1, current))
6587 if(!isspace(ch)) break;
6588 f.Seek(-1, current);
6592 f.Seek(-1, current);
6594 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6596 lineNum = editBox.lineNumber + 1;
6597 charPos = editBox.charPos + 1;
6599 updatingCode = false;
6602 charPos = Min(charPos, l1.count + 1);
6604 FindParamsTree(ast, lineNum, charPos);
6606 // Not sure about this == ExpCall... paramsInsideExp doesn't seem to necessarily be a ExpCall
6607 if(exact && ((::functionType && paramsInsideExp.type == callExp && paramsInsideExp.call.exp.loc.end.charPos != charPos-1) /*|| instanceType*/))
6609 ::functionType = null;
6610 ::instanceType = null;
6613 //if((::functionType || ::instanceType) && (!paramsShown || insideExp != functionExp || ::paramsID != this.paramsID))
6614 if((::functionType || ::instanceType) && (!paramsShown || true /*paramsInsideExp.destType != functionExp.destType */|| ::paramsID != this.paramsID))
6618 Window parent = paramsList.parent;
6620 if(this.functionType != ::functionType || this.instanceType != ::instanceType)
6623 if(!this.paramsShown || reposition || paramsInsideExp != functionExp || ::instanceType) // Added instanceType here, otherwise instance popups never reposition...
6624 // ( Dummy exp: always ends up with same memory)
6626 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6627 editBox.GetCaretPosition(paramsPosition);
6628 this.paramsPosition.y += editBox.GetCaretSize();
6631 FreeType(this.functionType);
6632 FreeType(this.instanceType);
6634 this.functionType = ::functionType;
6635 this.instanceType = ::instanceType;
6637 if(this.functionType) this.functionType.refCount++;
6638 if(this.instanceType) this.instanceType.refCount++;
6640 this.paramsID = ::paramsID;
6641 functionExp = paramsInsideExp;
6643 paramsList.master = this;
6645 paramsList.Create();
6647 x = paramsPosition.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6648 y = paramsPosition.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6650 if(!this.membersAbove && ( this.membersListShown || y + paramsList.size.h > parent.clientSize.h) )
6652 y -= editBox.GetCaretSize() + paramsList.clientSize.h;
6656 paramsAbove = false;
6657 if(x + paramsList.size.w > parent.clientSize.w)
6659 x = parent.clientSize.w - paramsList.size.w;
6663 paramsList.position = { x, y };
6665 // Hack to keep caret shown
6668 editBox.GetCaretPosition(caret);
6669 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6672 this.paramsShown = true;
6674 else if((!::functionType && !::instanceType) || reposition)
6676 paramsList.Destroy(0);
6677 paramsShown = false;
6679 FreeType(this.functionType);
6680 FreeType(this.instanceType);
6681 this.functionType = null;
6682 this.instanceType = null;
6686 SetCurrentContext(globalContext);
6694 designer.visible = true;
6695 designer.Activate();
6701 CodeEditor NewCodeEditor(Window parent, WindowState state, bool modified)
6703 CodeEditor document { state = state, parent = parent, modifiedDocument = modified };
6708 void CodeEditor_Terminate()
6710 FindParams_Terminate();
6711 FindCtx_Terminate();