3 // *** Color Schemes ***
5 // *** The Old Color Scheme that was causing me auras and ophtalmic migraines -- Uncomment at your own risk! ***
7 FontResource panelFont { $"Courier New", 10 };
8 FontResource codeFont { $"Courier New", 10 };
9 Color selectionColor = Color { 10, 36, 106 };
10 Color selectionText = white;
11 Color viewsBackground = white;
12 Color viewsText = black;
13 Color outputBackground = white;
14 Color outputText = black;
15 Color projectViewBackground = white;
16 Color projectViewText = black;
17 Color codeEditorBG = white;
18 Color codeEditorFG = black;
19 Color marginColor = Color {230, 230, 230};
20 Color selectedMarginColor = Color {200, 200, 200};
21 Color lineNumbersColor = Color {60, 60, 60};
22 SyntaxColorScheme colorScheme
24 keywordColors = [ blue, blue ];
25 commentColor = dimGray;
26 charLiteralColor = crimson;
27 stringLiteralColor = crimson;
28 preprocessorColor = green;
33 // The new nice dark scheme -- so peaceful on my brain
35 FontResource panelFont { $"Courier New", 10 };
36 FontResource codeFont { $"Courier New", 10 };
38 FontResource panelFont { $"Consolas", 12 };
39 FontResource codeFont { $"Consolas", 12 };
41 Color selectionColor = lightYellow;
42 Color selectionText = Color { 30, 40, 50 };
43 Color viewsBackground = Color { 30, 40, 50 };
44 Color viewsText = lightGray;
45 Color outputBackground = black;
46 Color outputText = lime;
47 Color projectViewBackground = Color { 30, 40, 50 };
48 Color projectViewText = lightGray;
49 Color codeEditorBG = black;
50 Color codeEditorFG = ivory;
51 Color marginColor = Color {24, 24, 24};
52 Color selectedMarginColor = Color {64, 64, 64};
53 Color lineNumbersColor = Color {160, 160, 160};
54 SyntaxColorScheme colorScheme
56 keywordColors = [ skyBlue, skyBlue ];
57 commentColor = Color { 125, 125, 125 };
58 charLiteralColor = Color { 245, 50, 245 };
59 stringLiteralColor = Color { 245, 50, 245 };
60 preprocessorColor = { 120, 220, 140 };
61 numberColor = Color { 0, 192, 192 };
64 // *********************
70 // UNTIL IMPLEMENTED IN GRAMMAR
71 #define ACCESS_CLASSDATA(_class, baseClass) \
72 (_class ? ((void *)(((char *)_class.data) + baseClass.offsetClass)) : null)
75 extern int __attribute__((__stdcall__)) __ecereDll_Load_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
76 extern int __attribute__((__stdcall__)) __ecereDll_Unload_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
79 static Array<FileFilter> fileFilters
81 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
82 { $"Header Files for C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
83 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
84 { $"Text files (*.txt)", "txt" },
85 { $"All files", null }
88 static Array<FileType> fileTypes
90 { $"eC Source Code", "ec", whenNoneGiven },
91 { $"Text Files", "txt", never }
94 static char * iconNames[] =
96 "<:ecere>constructs/class.png",
97 "<:ecere>constructs/data.png",
98 "<:ecere>constructs/method.png",
99 "<:ecere>constructs/event.png",
100 "<:ecere>constructs/property.png",
101 "<:ecere>constructs/namespace.png",
102 "<:ecere>constructs/dataType.png",
103 "<:ecere>constructs/enumValue.png",
104 "<:ecere>constructs/dataPrivate.png",
105 "<:ecere>constructs/methodPrivate.png",
106 "<:ecere>constructs/propertyPrivate.png"
109 enum SheetType { methods, properties };
111 extern int __ecereVMethodID_class_OnEdit;
112 extern int __ecereVMethodID_class_OnDisplay;
113 extern int __ecereVMethodID_class_OnGetString;
114 extern int __ecereVMethodID_class_OnFree;
115 extern int __ecereVMethodID_class_OnCompare;
116 extern int __ecereVMethodID_class_OnCopy;
117 extern int __ecereVMethodID_class_OnSaveEdit;
118 extern int __ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad;
120 class EditFileDialog : FileDialog
124 if(!ide.projectView && ideSettings.ideFileDialogLocation)
125 currentDirectory = ideSettings.ideFileDialogLocation;
126 return FileDialog::OnCreate();
130 EditFileDialog codeEditorFileDialog
132 type = multiOpen, text = $"Open",
133 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType);
134 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
137 EditFileDialog codeEditorFormFileDialog
139 type = open, text = $"Open Project",
140 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType),
141 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
144 define OpenBracket = '{';
145 define CloseBracket = '}';
150 actionDeleteMethod = 2,
151 actionDetachMethod = 3,
152 actionAttachMethod = 4,
153 actionReattachMethod = 5
156 //extern StatusField pos, ovr, caps, num;
157 //extern Class thisClass;
163 bool parseError = false;
168 Expression ctxInsideExp;
169 Expression paramsInsideExp;
170 ClassFunction insideFunction;
178 /****************************************************************************
180 ****************************************************************************/
182 static void OutputString(File f, char * string)
185 for(c = 0; string[c]; c++)
187 if(string[c] == '\"')
189 else if(string[c] == '\\')
196 void OutputType(File f, Type type, bool outputName)
206 if(!type.isSigned) f.Printf("unsigned ");
210 if(!type.isSigned) f.Printf("unsigned ");
214 if(!type.isSigned) f.Printf("unsigned ");
218 if(!type.isSigned) f.Printf("unsigned ");
222 if(!type.isSigned) f.Printf("unsigned ");
232 // ADD CODE TO DECIDE WHETHER TO OUTPUT FULLY QUAlIFIED OR NOT:
233 f.Printf(type._class.shortName ? type._class.shortName : type._class.string);
242 OutputType(f, type.type, false);
245 OutputType(f, type.type, false);
264 if(type.kind == arrayType)
267 f.Printf("%d", type.arraySize);
273 void DeleteJunkBefore(EditBoxStream f, int pos, int * position)
279 f.Seek(pos - *position, current);
281 // Try to delete spaces and \n before...
287 /*else if(ch == '\n')
289 // Look for // comments on the line before
290 EditBox editBox = f.editBox;
291 EditLine line = editBox.line;
298 for(c = 0; text[c]; c++)
307 if(text[c] == '/' && last == '/')
319 f.DeleteBytes(before);
324 void GetLocText(EditBox editBox, File f, int position, Location loc, char ** text, int * size, int pad, int linePad)
329 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
331 // Cut & Paste function
337 f.Seek(loc.start.pos - position, current);
339 x1 = editBox.charPos;
340 y1 = editBox.lineNumber;
341 f.Seek(loc.end.pos - loc.start.pos, current);
343 x2 = editBox.charPos;
344 y2 = editBox.lineNumber;
345 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
347 *size = editBox.SelSize();
348 *text = new char[*size+1 + (y2-y1+1) * linePad + pad]; // Add pad for tabs and new name
349 editBox.GetSel(*text, false);
352 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
353 f.Printf(""); // Make the stream point to where the editbox is
356 void Code_FixProperty(Property prop, Instance object)
358 Designer::FixProperty(prop, object);
361 bool Code_IsPropertyModified(Instance test, ObjectInfo selected, Property prop)
364 if(prop.dataTypeString && (!prop.IsSet || prop.IsSet(selected.instance)))
366 Class dataType = prop.dataTypeClass;
369 dataType = prop.dataTypeClass = eSystem_FindClass(test._class.module, prop.dataTypeString);
371 if(dataType && dataType._vTbl && dataType.type == structClass)
373 void * dataForm = new0 byte[dataType.structSize];
374 void * dataTest = new0 byte[dataType.structSize];
376 prop.Get(selected.instance, dataForm);
377 prop.Get(test, dataTest);
379 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
381 prop.Set(test, dataForm);
387 else if(dataType && dataType._vTbl && (dataType.type == normalClass || dataType.type == noHeadClass))
389 void * dataForm, * dataTest;
391 dataForm = (void *)prop.Get(selected.instance);
392 dataTest = (void *)prop.Get(test);
394 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
396 prop.Set(test, dataForm);
400 else if(dataType && dataType._vTbl)
402 DataValue dataForm, dataTest;
404 GetProperty(prop, selected.instance, &dataForm);
405 GetProperty(prop, test, &dataTest);
407 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
409 SetProperty(prop, test, dataForm);
411 // In case setting on test unset on real instance (e.g. isDefault)
412 if(strcmp(prop.name, "name"))
414 GetProperty(prop, selected.instance, &dataTest);
415 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
416 SetProperty(prop, selected.instance, dataForm);
425 bool Code_IsPropertyDisabled(ObjectInfo selected, char * name)
427 bool disabled = false;
428 if(selected.oClass == selected)
431 if(selected.classDefinition)
433 for(def = selected.classDefinition.definitions->first; def; def = def.next)
435 if(def.type == defaultPropertiesClassDef)
438 for(prop = def.defProperties->first; prop; prop = prop.next)
440 if(prop.identifiers && prop.identifiers->first)
442 Identifier id = prop.identifiers->first;
443 if(prop.variable && !strcmp(id.string, name))
455 else if(selected.instCode)
458 if(selected.instCode.members)
460 for(members = selected.instCode.members->first; members; members = members.next)
462 if(members.type == dataMembersInit && members.dataMembers)
465 for(prop = members.dataMembers->first; prop; prop = prop.next)
467 if(prop.identifiers && prop.identifiers->first)
469 Identifier id = prop.identifiers->first;
470 if(prop.variable && !strcmp(id.string, name))
485 static bool CheckCompatibleMethod(Method method, Type type, Class regClass, bool isForm, Symbol selectedClass)
490 method.dataType = ProcessTypeString(method.dataTypeString, false);
491 if(!method.dataType.thisClass && !isForm)
494 method.dataType.thisClass = selectedClass;
496 //result = MatchTypes(method.dataType, type, null, regClass, regClass, false);
497 result = MatchTypes(type, method.dataType, null, regClass, regClass, false, true, true, false);
499 method.dataType.thisClass = null;
503 bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo object)
505 bool confirmation = true;
506 Statement body = function.body;
507 // Check if it contains any code
508 if((!body.compound.declarations || !body.compound.declarations->count) && (!body.compound.statements || body.compound.statements->count <= 1))
510 Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
511 Statement stmt = body.compound.statements ? body.compound.statements->first : null;
512 Type dataType = method.dataType;
513 Type returnType = dataType.returnType;
514 Expression exp = null;
517 method.dataType = ProcessTypeString(method.dataTypeString, false);
519 confirmation = false;
521 // Check if default function should be calling base class:
522 if(object.instance._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
524 if(returnType.kind != voidType)
526 if(!stmt || stmt.type != returnStmt || !stmt.expressions || stmt.expressions->count != 1)
530 exp = stmt.expressions->first;
531 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
533 if( (exp.type != identifierExp || strcmp(exp.identifier.string, "true")) &&
534 (exp.type != constantExp || strcmp(exp.constant, "1")))
539 if(exp.type != constantExp || strcmp(exp.constant, "0"))
554 if(returnType.kind != voidType)
556 if(stmt.type == returnStmt && stmt.expressions && stmt.expressions->count == 1)
557 exp = stmt.expressions->first;
559 else if(stmt.type == expressionStmt && stmt.expressions && stmt.expressions->count == 1)
560 exp = stmt.expressions->first;
563 if(!exp || exp.type != callExp || exp.call.exp.type != identifierExp)
567 Identifier id = exp.call.exp.identifier;
568 Class base = object.instance._class;
569 if(!id._class || (id._class.name && !strcmp(id._class.name, base.name)) || strcmp(id.string, method.name))
573 Expression arg = exp.call.arguments ? exp.call.arguments->first : null;
574 if(!arg || arg.type != identifierExp || strcmp("this", arg.identifier.string))
580 for(param = dataType.params.first; param; param = param.next)
582 if(!arg || arg.type != identifierExp || strcmp(param.name, arg.identifier.string))
587 arg = arg ?arg.next : null;
594 return !confirmation;
597 class CodeEditor : Window
599 background = marginColor;
600 borderStyle = sizableDeep;
605 isActiveClient = true;
606 anchor = Anchor { left = 300, right = 150, top = 0, bottom = 0 };
609 // eWindow_SetX(A_CASCADE); eWindow_SetY(A_CASCADE);
610 // eWindow_SetWidth(A_RELATIVE|80); eWindow_SetHeight(A_RELATIVE|80);
612 SheetType sheetSelected;
617 Context globalContext { };
618 OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
631 MethodAction methodAction;
633 ClassFunction function;
635 char methodName[1024];
640 bool membersListShown;
643 EditLine membersLine;
645 Type functionType, instanceType;
649 Point paramsPosition;
650 Expression functionExp;
653 BitmapResource icons[CodeObjectType];
655 FontResource boldFont { $"Tahoma", 8.25f, bold = true, window = this };
656 FontResource normalFont { $"Tahoma", 8.25f, window = this };
658 Module privateModule;
659 NameSpace globalData;
662 OpenedFileInfo openedFileInfo;
664 FontResource font { codeFont.faceName, codeFont.size };
665 saveDialog = codeEditorFileDialog;
667 Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
669 void ProcessCaretMove(EditBox editBox, int line, int charPos)
672 ObjectInfo classItem;
674 // OnActivateClient is called after OnActivate
677 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
680 if(sheet.codeEditor != this) return;
684 for(classItem = classes.first; classItem; classItem = classItem.next)
686 ClassDefinition classDef = classItem.classDefinition;
687 if(classDef && classDef.loc.Inside(line, charPos))
694 for(object = classItem.instances.first; object; object = object.next)
698 if(object.instCode.loc.Inside(line, charPos))
703 sheet.SelectObject(object);
705 sheet.SelectObject(classItem);
710 //sheet.SelectObject(null);
714 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
718 expectingMove = false;
724 if(line-1 != membersLoc.start.line)
728 char * buffer = membersLine.text;
731 if(charPos - 1 < membersLoc.start.charPos)
733 else if(charPos - 1 > membersLoc.end.charPos)
735 char * buffer = membersLine.text;
736 //if(membersList.currentRow)
740 for(c = membersLoc.start.charPos; c<=charPos && buffer[c]; c++)
741 if(buffer[c] != ' ' && buffer[c] != '\t')
743 if(c < charPos && buffer[c])
750 membersList.Destroy(0);
751 membersListShown = false;
755 bool back = codeModified;
756 codeModified = false;
758 InvokeParameters(false, false, false);
759 /*if(membersListShown)
760 InvokeAutoComplete(false, 0, true);*/
767 watch(modifiedDocument)
769 ProjectView projectView = ide.projectView;
772 ProjectNode node = projectView.GetNodeFromWindow(this, null);
775 node.modified = modifiedDocument;
776 projectView.Update(null);
784 textVertScroll = true, multiLine = true, /*lineNumbers = ideSettings.showLineNumbers,*/
785 freeCaret = ideSettings.useFreeCaret, caretFollowsScrolling = ideSettings.caretFollowsScrolling,
786 tabKey = true, smartHome = true;
787 tabSelection = true, maxLineSize = 65536, parent = this, hasHorzScroll = true, hasVertScroll = true;
788 selectionColor = selectionColor, selectionText = selectionText,
789 background = codeEditorBG, foreground = codeEditorFG, syntaxColorScheme = colorScheme,
790 font = font, borderStyle = none;
791 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
793 bool OnMouseOver(int x, int y, Modifiers mods)
795 CodeEditor editor = (CodeEditor)master;
796 if(editor.designer && editor.designer.isDragging && !mods.isSideEffect)
801 void NotifyCaretMove(EditBox editBox, int line, int charPos)
803 // Update Line Numbers
805 int oldLine = lastLine;
806 display.FontExtent(font.font, " ", 1, null, &spaceH);
808 Box box { 0, (Min(oldLine,oldLine)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(oldLine, oldLine))*spaceH-1 - editBox.scroll.y };
812 Box box { 0, (Min(line,line)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(line, line))*spaceH-1 - editBox.scroll.y };
817 if(ide.activeClient == this)
818 ProcessCaretMove(editBox, line, charPos);
820 openedFileInfo.CaretMove(line, charPos);
823 void NotifyOvrToggle(EditBox editBox, bool overwrite)
825 ide.ovr.color = overwrite ? black : Color { 128, 128, 128 };
828 void NotifyUpdate(EditBox editBox)
835 designer.modifiedDocument = true;
838 modifiedDocument = true;
841 bool NotifyUnsetModified(EditBox editBox)
843 modifiedDocument = false;
847 bool NotifyCharsAdded(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
849 if(!loadingFile && after.y != before.y)
851 ProjectView projectView = ide.projectView;
852 if(projectView && fileName)
855 // HOW WE MIGHT WANT TO DO IT:
856 char * text = before.line.text;
857 for(c = before.x-1; c>= 0; c--)
858 if(!isspace(text[c]))
860 ide.debugger.MoveIcons(fileName, before.y + (((!pasteOperation && c > -1) || !after.line.count) ? 1 : 0), after.y - before.y, false);
862 // HOW VISUAL STUDIO DOES IT:
864 char * text = after.line.text;
865 for(c = after.line.count-1; c>= 0; c--)
866 if(!isspace(text[c]))
868 ide.debugger.MoveIcons(fileName, before.y + ((c < 0) ? 1 : 0), after.y - before.y, false);
871 Update({ 0, 0, editBox.position.x, clientSize.h });
878 for(oClass = classes.first; oClass; oClass = oClass.next)
881 for(object = oClass.instances.first; object; object = object.next)
885 object.instCode.loc.start.AdjustAdd(before, after);
886 object.instCode.loc.end.AdjustAdd(before, after);
891 oClass.classDefinition.loc.start.AdjustAdd(before, after);
892 oClass.classDefinition.loc.end.AdjustAdd(before, after);
898 expectingMove = true;
902 if(before.y != after.y)
906 char * buffer = membersLine.text;
908 bool firstChar = true;
909 bool addedChar = false;
915 membersLoc.end.charPos += after.x - Max(membersLoc.start.charPos, before.x);
917 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
919 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
920 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar)) //|| membersList.currentRow
929 membersLoc.start.charPos++;
934 string[len++] = buffer[c];
938 row = membersList.currentRow;
939 if(row && row.selected)
943 membersLoc.start.charPos--;
951 row = membersList.FindSubString(string);
953 membersList.currentRow = row;
956 row = membersList.FindSubStringi(string);
958 membersList.currentRow = row;
959 membersList.currentRow.selected = false;
962 membersList.SetScrollPosition(0, (row.index) * membersList.rowHeight);
966 row = membersList.currentRow;
969 // Accept current string if hiding typing char
970 if(hide && row && row.selected)
972 char * string = row.string;
973 int len = strlen(string);
974 membersLoc.end.charPos -= after.x - before.x;
975 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
976 editBox.Delete(membersLine, membersLoc.start.line, membersLoc.start.charPos,
977 membersLine, membersLoc.end.line, membersLoc.end.charPos);
978 editBox.PutS(string);
979 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos + len + 1 /*after.x - before.x*/);
981 after.x += membersLoc.start.charPos + len - before.x;
982 before.x = membersLoc.start.charPos + len;
987 membersList.Destroy(0);
988 membersListShown = false;
991 if(/*after.x - before.x == 1 && */after.y == before.y && !membersListShown)
993 EditLine line = editBox.line;
994 char * text = line.text;
995 char ch = text[after.x-1];
996 if(ch == '.' || (ch == '>' && after.x-1 > 0 && text[after.x-1-1] == '-') || (ch == ':' && after.x-1 > 0 && text[after.x-1-1] == ':'))
1000 // Can we call invoke auto complete here instead?
1010 // Force caret update already...
1011 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1012 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1014 editBox.GetCaretPosition(&caret);
1018 // Go back in the buffer until no space before
1020 codeModified = true;
1024 EditBoxStream f { editBox = editBox };
1028 if(text[after.x-1] == '>')
1034 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1038 if(!f.Seek(-1, current))
1041 if(!isspace(ch)) break;
1042 f.Seek(-1, current);
1044 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1046 line = editBox.lineNumber + 1;
1047 charPos = editBox.charPos + 1;
1051 exp = FindExpTree(ast, line, charPos);
1055 Type type = exp.expType;
1057 if(type && text[after.x-1] != '.')
1059 if(type.kind == TypePointer || type.kind == TypeArray)
1065 membersList.Clear();
1068 if(membersList.rowCount)
1070 membersList.Sort(null, 1);
1071 membersList.master = this;
1073 caret.y += editBox.GetCaretSize();
1076 membersList.Create();
1079 int x = caret.x + editBox.GetAbsX() - app.desktop.GetAbsX() - editBox.GetScrollX();
1080 int y = caret.y + editBox.GetAbsY() - app.desktop.GetAbsY() - editBox.GetScrollY();
1081 Window parent = membersList.parent;
1083 if(!paramsAbove && (paramsShown || y + membersList.GetHeight() > parent.GetClientHeight()))
1085 y -= editBox.GetCaretSize() + membersList.GetHeight();
1086 membersAbove = true;
1089 membersAbove = false;
1091 membersList.position = { x, y };
1095 membersLoc.start.line = line - 1;
1096 membersLoc.start.charPos = oldCharPos;
1097 membersLoc.end = membersLoc.start;
1098 membersListShown = true;
1103 SetCurrentContext(globalContext);
1105 codeModified = true;
1106 skipModified = true;
1107 if(text[after.x-1] == ':')
1108 InvokeAutoComplete(false, 0, false);
1109 else if(text[after.x-1] == '.')
1110 InvokeAutoComplete(false, 1, false);
1111 else if(text[after.x-1] == '>')
1112 InvokeAutoComplete(false, 2, false);
1113 skipModified = false;
1115 else if(ch == '(' || ch == OpenBracket || ch == ',' || ch == '=' || ch == '?' || ch == ':')
1117 codeModified = true;
1118 skipModified = true;
1120 if(InvokeAutoComplete(true, 0, false))
1122 if(ch == '(' || ch == OpenBracket)
1123 InvokeParameters(true, true, false);
1125 InvokeParameters(this.functionType ? false : true, false, false);
1128 // InvokeAutoComplete(true, 0, false);
1129 skipModified = false;
1131 else if(ch == ')' || ch == '}' || ch == ';')
1133 codeModified = true;
1134 skipModified = true;
1136 InvokeParameters(false, true, false);
1137 skipModified = false;
1141 bool back = codeModified;
1142 codeModified = false;
1144 InvokeParameters(false, false, true);
1145 if(membersListShown)
1146 InvokeAutoComplete(false, 0, true);
1147 codeModified = back;
1152 bool back = codeModified;
1153 codeModified = false;
1156 InvokeParameters(false, false, true);
1157 /*if(membersListShown)
1158 InvokeAutoComplete(false, 0, true);*/
1160 codeModified = back;
1167 bool NotifyCharsDeleted(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
1169 if(!loadingFile && after.y != before.y)
1171 ProjectView projectView = ide.projectView;
1172 if(projectView && fileName)
1173 ide.debugger.MoveIcons(fileName, before.y + 1, before.y - after.y, before.x == 0);
1174 Update({ 0, 0, editBox.position.x, clientSize.h });
1181 for(oClass = classes.first; oClass; oClass = oClass.next)
1185 for(object = oClass.instances.first; object; object = object.next)
1189 loc = &object.instCode.loc;
1191 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1192 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1194 object.instCode = null;
1198 loc->start.AdjustDelete(before, after);
1199 loc->end.AdjustDelete(before, after);
1203 if(oClass.classDefinition)
1205 loc = &oClass.classDefinition.loc;
1206 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1207 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1209 oClass.classDefinition = null;
1213 loc->start.AdjustDelete(before, after);
1214 loc->end.AdjustDelete(before, after);
1219 if(membersListShown)
1222 if(pasteOperation || before.y != after.y)
1226 char * buffer = membersLine.text;
1228 bool firstChar = true;
1232 if(before.x >= membersLoc.start.charPos)
1234 for(c = membersLoc.start.charPos; c<before.x && len < sizeof(string)-1; c++)
1236 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1237 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1242 if(!isSpace) firstChar = false;
1245 string[len++] = buffer[c];
1250 // If deleting spaces before...
1251 for(c = before.x; c<membersLoc.start.charPos; c++)
1253 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1261 membersLoc.start.charPos = before.x;
1264 if(membersLoc.end.charPos >= after.x)
1266 for(c = after.x; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
1268 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1269 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1274 if(!isSpace) firstChar = false;
1277 string[len++] = buffer[c];
1285 membersLoc.end.charPos -= after.x - before.x;
1289 row = membersList.FindSubString(string);
1292 row = membersList.FindSubStringi(string);
1294 membersList.currentRow = row;
1295 membersList.currentRow.selected = false;
1298 membersList.currentRow = row;
1300 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
1305 membersList.Destroy(0);
1306 membersListShown = false;
1312 InvokeParameters(false, false);
1320 bool NotifyDropped(EditBox editBox, int x, int y)
1322 char * controlClass = toolBox.controlClass;
1323 if(controlClass && controlClass[0])
1327 ObjectInfo classObject;
1329 //editBox.NotifyCaretMove(this, editBox, y, x);
1330 editBox.GoToLineNum(y);
1331 editBox.GoToPosition(editBox.line, y, x);
1333 classObject = selected ? selected.oClass : null;
1335 if((!selected || selected == classObject) && classObject && classObject.instances.first)
1336 selected = classObject.instances.last;
1339 control = eInstance_New(eSystem_FindClass(privateModule, controlClass));
1342 AddObject(control, &object);
1344 designer.CreateObject(control, object, false, classObject.instance);
1345 // designer.PostCreateObject(control, object, false, classObject.instance);
1346 designer.DroppedObject(control, object, false, classObject.instance);
1348 sheet.AddObject(object, object.name, typeData /* className*/, true);
1351 //codeModified = true;
1358 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
1360 if(key == Key { space, ctrl = true })
1362 membersList.Destroy(0);
1363 membersListShown = false;
1364 InvokeAutoComplete(false, 0, false);
1367 else if(key == Key { space, ctrl = true, shift = true })
1368 InvokeParameters(false, true, false);
1369 else if(key == escape)
1370 ide.RepositionWindows(true);
1371 else if(key == ctrlF7)
1375 ProjectNode node = ide.projectView.GetNodeFromWindow(this, null);
1379 s = PrintString($"The ", fileName, $" file is not part of any project.\n",
1380 $"It can't be compiled.");
1381 MessageBox { type = ok, parent = ide, master = ide, text = $"File not in project error", contents = s }.Modal();
1390 bool OnKeyDown(Key key, unichar ch)
1392 CodeEditor editor = (CodeEditor)master;
1393 if(key == escape /*|| key == leftAlt || key == rightAlt || (key.ctrl && key.code != left && key.code != right && key.code != leftShift && key.code != rightShift && key.code != space)*/)
1395 if(editor.membersListShown)
1397 editor.membersList.Destroy(0);
1398 editor.membersListShown = false;
1401 if(editor.paramsShown)
1403 editor.paramsList.Destroy(0);
1404 editor.paramsShown = false;
1405 FreeType(editor.functionType);
1406 FreeType(editor.instanceType);
1408 editor.functionType = null;
1409 editor.instanceType = null;
1410 editor.paramsID = -1;
1414 return EditBox::OnKeyDown(key, ch);
1417 void OnVScroll(ScrollBarAction action, int position, Key key)
1419 if(anchor.left.distance)
1421 Box box { 0, 0, anchor.left.distance-1, parent.clientSize.h - 1 };
1424 EditBox::OnVScroll(action, position, key);
1426 CodeEditor ce = (CodeEditor)parent;
1427 if(ce.openedFileInfo)
1428 ce.openedFileInfo.ScrollChange({ scroll.x, position });
1432 void OnHScroll(ScrollBarAction action, int position, Key key)
1434 EditBox::OnHScroll(action, position, key);
1436 CodeEditor ce = (CodeEditor)parent;
1437 if(ce.openedFileInfo)
1438 ce.openedFileInfo.ScrollChange({ position, scroll.y });
1445 fullRowSelect = false,
1448 borderStyle = bevel;
1449 // size = { 200, 400 };
1451 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
1453 DataRow row = listBox.currentRow;
1456 char * string = row.string;
1458 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1460 membersLine, membersLoc.start.line, membersLoc.start.charPos,
1461 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1462 editBox.PutS(string);
1465 membersListShown = false;
1470 bool OnKeyDown(Key key, unichar ch)
1472 CodeEditor editor = (CodeEditor) master;
1473 if(key == escape || key == leftAlt || key == rightAlt ||
1474 (key.ctrl && key.code != left && key.code != right &&
1475 key.code != leftShift && key.code != rightShift && key.code != space))
1477 if(editor.paramsShown)
1478 editor.paramsList.Destroy(0);
1479 if(editor.membersListShown)
1480 editor.membersList.Destroy(0);
1482 editor.paramsShown = false;
1483 FreeType(editor.functionType);
1484 FreeType(editor.instanceType);
1486 editor.functionType = null;
1487 editor.instanceType = null;
1488 editor.paramsID = -1;
1490 editor.membersListShown = false;
1494 return editor.editBox.OnKeyDown(key, ch);
1498 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1500 CodeEditor editor = (CodeEditor)master;
1504 editor.membersListShown = false;
1506 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1509 bool OnKeyHit(Key key, unichar ch)
1511 CodeEditor editor = (CodeEditor) master;
1515 case enter: case tab:
1517 DataRow row = currentRow;
1518 if(row && row.selected)
1520 char * string = row.string;
1522 editor.editBox.GoToPosition(editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos);
1523 editor.editBox.Delete(
1524 editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos,
1525 editor.membersLine, editor.membersLoc.end.line, editor.membersLoc.end.charPos);
1526 editor.editBox.PutS(string);
1529 editor.membersListShown = false;
1532 editor.editBox.OnKeyHit(key, ch);
1542 return ListBox::OnKeyHit(key, ch);
1548 // If before . or after
1549 //listBox.Destroy(true);
1550 result = editor.editBox.OnKeyHit(key, ch);
1565 clickThrough = true,
1567 borderStyle = contour,
1569 background = { 255,255,225 },
1571 OnKeyDown = membersList.OnKeyDown;
1573 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1575 CodeEditor editor = (CodeEditor)master;
1579 editor.membersListShown = false;
1581 return Window::OnActivate(active, previous, goOnWithActivation, direct);
1584 bool OnKeyHit(Key key, unichar ch)
1586 CodeEditor editor = (CodeEditor)master;
1588 if(!editor.membersListShown || editor.membersList.OnKeyHit(key, ch))
1591 bool result = true; editor.editBox.OnKeyHit(key, ch);
1592 return (!created) ? false : result;
1599 void OnRedraw(Surface surface)
1601 CodeEditor editor = (CodeEditor) master;
1602 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1604 Type methodType = null;
1608 int functionW, nameW = 0;
1610 int spaceW, spaceH, commaW, commaWB, parW;
1612 int maxW = 0, lineW = 0;
1618 Font font = editor.normalFont.font;
1619 Font boldFont = editor.boldFont.font;
1620 Display display = this.display;
1622 if(!type) { return; };
1624 if(type.kind == TypeKind::methodType) { methodType = type; type = type.method.dataType; }
1626 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1627 display.FontExtent(font, ", ", 2, &commaW, null);
1628 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1629 display.FontExtent(font, ")", 1, &parW, null);
1632 if(editor.functionType)
1634 PrintType(type.returnType, string, true, true);
1635 display.FontExtent(font, string, strlen(string), &functionW, null);
1637 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1638 totalW = nameW + functionW + 2 * parW;
1642 PrintType(type, string, (type.kind == functionType) ? true : false, true); // true);
1643 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1644 if(instanceName && type.kind != functionType)
1645 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1646 totalW = functionW + nameW;
1647 surface.TextFont(boldFont);
1650 surface.WriteText(x, y, string, strlen(string));
1651 x += functionW + spaceW;
1653 if(editor.functionType)
1656 surface.WriteText(x, y, type.name, strlen(type.name));
1658 surface.WriteText(x, y, "(", 1);
1661 if(methodType && !methodType.staticMethod)
1665 if(id == editor.paramsID)
1666 surface.TextFont(boldFont);
1668 if(methodType.methodClass)
1669 surface.TextExtent(methodType.methodClass.name, strlen(methodType.methodClass.name), &tw, null);
1673 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1674 width += ((id == editor.paramsID) ? commaWB : commaW);
1679 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1684 x = 2 + nameW + spaceW + functionW + parW;
1688 if(methodType.methodClass)
1689 surface.WriteText(x, y, methodType.methodClass.name, strlen(methodType.methodClass.name));
1692 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1694 surface.WriteText(x, y, ",", 1);
1695 x += ((id == editor.paramsID) ? commaWB : commaW);
1703 if(id == editor.paramsID)
1704 surface.TextFont(font);
1708 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1710 for(param = type.params.first; param; param = param.next)
1712 char paramString[1024];
1715 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1716 surface.TextFont(boldFont);
1719 PrintType(param, paramString, true, true);
1720 surface.TextExtent(paramString, strlen(paramString), &tw, null);
1722 if(param.next) width += ((id == editor.paramsID) ? commaWB : commaW);
1727 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1732 x = 2 + nameW + spaceW + functionW + parW;
1736 surface.WriteText(x, y, paramString, strlen(paramString));
1740 surface.WriteText(x, y, ",", 1);
1741 x += ((id == editor.paramsID) ? commaWB : commaW);
1749 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1750 surface.TextFont(font);
1755 surface.WriteText(x, y, ")", 1);
1757 else if(instanceName && type.kind != functionType)
1759 surface.WriteText(x, y, instanceName, strlen(instanceName));
1763 bool OnResizing(int * w, int * h)
1765 CodeEditor editor = (CodeEditor) master;
1766 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1768 Type methodType = null;
1772 int functionW = 0, nameW = 0;
1774 int spaceW, spaceH, commaW, commaWB, parW;
1776 int maxW = 0, lineW = 0;
1781 Font font = editor.normalFont.font;
1782 Font boldFont = editor.boldFont.font;
1783 Display display = this.display;
1785 if(type.kind == TypeKind::methodType)
1788 ProcessMethodType(type.method);
1789 type = type.method.dataType;
1792 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1793 display.FontExtent(font, ", ", 2, &commaW, null);
1794 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1795 display.FontExtent(font, ")", 1, &parW, null);
1798 if(editor.functionType && type)
1800 PrintType(type.returnType, string, true, true);
1801 display.FontExtent(font, string, strlen(string), &functionW, null);
1803 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1804 totalW = nameW + spaceW + functionW + 2 * parW;
1808 PrintType(type, string, false, true); // /*true);
1809 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1810 if(instanceName && type.kind != functionType)
1811 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1812 totalW = functionW + nameW + spaceW;
1815 if(editor.functionType)
1821 if(methodType.methodClass)
1822 display.FontExtent((id == editor.paramsID) ? boldFont : font, methodType.methodClass.name, strlen(methodType.methodClass.name), &width, null);
1823 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1824 width += ((id == editor.paramsID) ? commaWB : commaW);
1829 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1842 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1844 for(param = type.params.first; param; param = param.next)
1846 char paramString[1024];
1850 PrintType(param, paramString, true, true);
1851 display.FontExtent((id == editor.paramsID || param.kind == ellipsisType) ? boldFont : font, paramString, strlen(paramString), &width, null);
1853 width += ((id == editor.paramsID) ? commaWB : commaW);
1858 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1875 *w = realW + totalW + 4;
1881 Menu fileMenu { menu, $"File", f }; // MenuPlacement?
1882 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
1883 MenuItem { fileMenu, $"Save As...", a, NotifySelect = MenuFileSaveAs };
1885 Menu debugMenu { menu, $"Debug", d }; // MenuPlacement?
1886 MenuItem debugRunToCursor
1888 debugMenu, $"Run To Cursor", c, Key { f10, ctrl = true };
1889 bool NotifySelect(MenuItem selection, Modifiers mods)
1891 ProjectView projectView = ide.projectView;
1892 if(!projectView.buildInProgress)
1894 int line = editBox.lineNumber + 1;
1897 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1898 ProjectConfig config = projectView.project.config;
1899 ide.debugger.RunToCursor(compiler, config, fileName, line, false);
1906 MenuItem debugSkipRunToCursor
1908 debugMenu, $"Run To Cursor Skipping Breakpoints", u, Key { f10, ctrl = true, shift = true };
1909 bool NotifySelect(MenuItem selection, Modifiers mods)
1911 ProjectView projectView = ide.projectView;
1912 int line = editBox.lineNumber + 1;
1915 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1916 ProjectConfig config = projectView.project.config;
1917 ide.debugger.RunToCursor(compiler, config, fileName, line, true);
1923 MenuDivider { debugMenu };
1924 MenuItem debugToggleBreakpoint
1926 debugMenu, $"Toggle Breakpoint", t, f9;
1927 bool NotifySelect(MenuItem selection, Modifiers mods)
1929 ProjectView projectView = ide.projectView;
1930 if(projectView && fileName)
1932 int line = editBox.lineNumber + 1;
1933 char name[MAX_LOCATION];
1935 // TOFIX: This only looks at the filename...
1936 GetLastDirectory(fileName, name);
1937 if(ide && ide.workspace)
1939 for(p : ide.workspace.projects)
1941 if(p.topNode.Find(name, false))
1949 for(p : ide.workspace.projects)
1951 if(IsPathInsideOf(fileName, p.topNode.path))
1959 ide.debugger.ToggleBreakpoint(fileName, line, prj);
1969 //MenuItem viewDesignerItem, viewProperties, viewMethods;
1973 designer.parent = parent;
1976 toolBox = ((IDEWorkSpace)master).toolBox;
1978 // Debugger bug here: value of toolBox appears as 0
1980 sheet = ((IDEWorkSpace)master).sheet;
1985 bool OnClose(bool parentClosing)
1989 if(ide.workspace && fileName)
1990 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);
2016 ide.AdjustFileMenus();
2021 void OnDestroy(void)
2023 ObjectInfo oClass, next;
2024 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2026 FreeType(this.functionType);
2027 FreeType(this.instanceType);
2032 designer.codeEditor = null;
2033 designer.Destroy(0);
2037 for(oClass = (classes).first, next = oClass ? oClass.next : null; oClass; oClass = next, next = next ? (next.next) : null)
2039 ObjectInfo object, next;
2041 for(object = oClass.instances.first; object; object = next)
2046 Designer::DestroyObject(object.instance);
2047 delete object.instance;
2049 sheet.DeleteObject(object);
2051 oClass.instances.Delete(object);
2055 Designer::DestroyObject(oClass.instance);
2056 delete oClass.instance;
2058 sheet.DeleteObject(oClass);
2060 classes.Delete(oClass);
2063 if(windowClass && windowClass.data)
2064 UnapplySkin(windowClass);
2068 if(sheet.codeEditor == this)
2070 sheet.codeEditor = null;
2071 toolBox.codeEditor = null;
2077 ProjectView projectView = ide.projectView;
2080 ProjectNode node = projectView.GetNodeFromWindow(this, null);
2081 if(node && node.modified)
2083 node.modified = false;
2084 projectView.Update(null);
2090 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool directActivation)
2092 // 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
2094 if(directActivation)
2095 ide.RepositionWindows(false); // Moved this up before as resizing causes NotifyCaretMove to be called on all editors
2097 if(active && directActivation)
2100 openedFileInfo.Activate();
2104 Location * loc = null;
2105 UpdateFormCode(); // To ensure update when modifying properties...
2107 // Got to the right spot in code so we don't lose our form selection...
2110 if(selected.instCode)
2111 loc = &selected.instCode.loc;
2112 else if(selected.classDefinition)
2113 loc = &selected.classDefinition.loc;
2115 line = editBox.lineNumber + 1;
2116 charPos = editBox.charPos + 1;
2121 if(selected && !loc->Inside(line, charPos))
2123 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2124 line = editBox.lineNumber + 1;
2125 charPos = editBox.charPos + 1;
2127 else if(selected && selected.classDefinition)
2130 for(object = selected.instances.first; object; object = object.next)
2134 if(object.instCode.loc.Inside(line, charPos))
2140 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2141 line = editBox.lineNumber + 1;
2142 charPos = editBox.charPos + 1;
2147 ProcessCaretMove(editBox, line, charPos);
2153 bool OnSaveFile(char * fileName)
2160 f = FileOpen(fileName, write);
2163 if(!ide.projectView)
2164 ide.ChangeFileDialogsDirectory(codeEditorFileDialog.currentDirectory, true);
2168 this.fileName = fileName; // Put this here because the form designer will check for it...
2169 designer.fileName = fileName;
2170 designer.modifiedDocument = false;
2172 editBox.Save(f, false);
2173 modifiedDocument = false;
2181 bool OnFileModified(FileChange fileChange, char * param)
2183 bool reload = false;
2184 if(visible == false && inUseDebug == true)
2190 sprintf(message, $"The document %s was modified by another application.\n"
2191 "Would you like to reload it and lose your changes?", fileName);
2192 if(MessageBox { type = yesNo, master = /*parent = */parent, text = $"Document has been modified",
2193 contents = message }.Modal() == yes)
2199 File f = FileOpen(fileName, read);
2202 int lineNumber, charPos, len;
2206 updatingCode = true;
2207 lineNumber = editBox.lineNumber;
2208 charPos = editBox.charPos;
2209 scroll = editBox.scroll;
2212 lineNumber = lineNumber < editBox.numLines ? lineNumber : editBox.numLines - 1;
2213 len = strlen(editBox.line.text);
2214 editBox.GoToLineNum(lineNumber);
2215 editBox.GoToPosition(editBox.line, lineNumber, charPos <= len ? charPos - 1 : (len ? len - 1 : 0));
2216 editBox.scroll = scroll;
2217 updatingCode = false;
2218 loadingFile = false;
2220 codeModified = true;
2224 designer.modifiedDocument = false;
2226 modifiedDocument = false;
2234 void OnRedraw(Surface surface)
2237 surface.SetBackground(marginColor);
2238 surface.Area(0, 0, editBox.anchor.left.distance, clientSize.h - 1);
2239 if(ideSettings.showLineNumbers)
2241 int currentLineNumber;
2246 surface.textOpacity = false;
2247 surface.font = font.font;
2248 surface.TextExtent(" ", 1, null, &spaceH);
2249 currentLineNumber = editBox.scroll.y / spaceH + 1;
2251 surface.SetForeground(lineNumbersColor);
2252 for(i = 0; i < editBox.clientSize.h - 4; i += spaceH)
2254 // Highlight current line
2255 if(editBox.lineNumber == currentLineNumber - 1)
2257 surface.SetBackground(selectedMarginColor);
2258 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2259 surface.SetBackground(marginColor);
2261 sprintf(lineText,"%5u ", currentLineNumber % 100000);
2262 if(currentLineNumber <= editBox.numLines)
2263 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,6);
2265 currentLineNumber++;
2269 if(editBox.syntaxHighlighting && fileName && ide.projectView)
2271 bool error, bpOnCursor, bpOnTopFrame, breakpointEnabled[128];
2272 int lineCursor, lineTopFrame, breakpointLines[128];
2273 int count, i, lineH, boxH, scrollY; //, firstLine; firstLine = editBox.firstLine;
2274 Debugger debugger = ide.debugger;
2275 BitmapResource bmpRes;
2277 boxH = clientSize.h;
2278 scrollY = editBox.scroll.y;
2279 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
2281 bpOnCursor = bpOnTopFrame = false;
2282 count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
2285 for(i = 0; i < count; i++)
2287 if(breakpointLines[i] == lineCursor || breakpointLines[i] == lineTopFrame)
2289 bmpRes = breakpointEnabled[i] ? ide.bmpBpHalf : ide.bmpBpHalfDisabled;
2290 if(breakpointLines[i] == lineCursor)
2292 if(breakpointLines[i] == lineTopFrame)
2293 bpOnTopFrame = true;
2296 bmpRes = breakpointEnabled[i] ? ide.bmpBp : ide.bmpBpDisabled;
2298 DrawLineMarginIcon(surface, bmpRes, breakpointLines[i], lineH, scrollY, boxH);
2301 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
2302 bmpRes = bpOnTopFrame ? (error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf) : (error ? ide.bmpTopFrameError : ide.bmpTopFrame);
2303 DrawLineMarginIcon(surface, bmpRes, lineTopFrame, lineH, scrollY, boxH);
2305 if(editBox.anchor.left.distance)
2307 if(editBox.horzScroll && editBox.horzScroll.visible)
2309 surface.SetBackground(control);
2310 surface.Area(0, editBox.clientSize.h, editBox.anchor.left.distance, clientSize.h - 1);
2315 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
2320 lineY = (line - 1) * lineH;
2321 if(lineY + lineH > scrollY && lineY /*+ lineH*/ < scrollY + boxH)
2323 Bitmap bitmap = resource.bitmap;
2325 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
2332 char ext[MAX_EXTENSION];
2333 char * fileName = property::fileName;
2335 if(SearchString(fileName, 0, "Makefile", false, true))
2336 editBox.useTab = true;
2337 designer.fileName = fileName;
2341 GetExtension(fileName, ext);
2342 if(!strcmpi(ext, "ec"))
2344 codeModified = true;
2348 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"))
2349 editBox.syntaxHighlighting = true;
2351 editBox.syntaxHighlighting = false;
2354 display.FontExtent(font.font, " ", 1, &spaceW, null);
2355 editBox.anchor = Anchor
2357 left = (editBox.syntaxHighlighting ? 20 : 0) + (ideSettings.showLineNumbers ? (6 * spaceW) : 0),
2358 right = 0, top = 0, bottom = 0
2367 display.FontExtent(font.font, " ", 1, &spaceW, null);
2368 editBox.anchor = Anchor
2370 left = (editBox.syntaxHighlighting ? 20 : 0) + (ideSettings.showLineNumbers ? (6 * spaceW) : 0),
2371 right = 0, top = 0, bottom = 0
2376 bool LoadFile(char * filePath)
2378 File f = FileOpen(filePath, read);
2381 // Added this here...
2382 fileName = filePath;
2384 updatingCode = true;
2386 updatingCode = false;
2387 loadingFile = false;
2396 void DebugMenusDisabled()
2398 bool debugMenusDisabled = ide.GetDebugMenusDisabled();
2399 debugRunToCursor.disabled = debugMenusDisabled;
2400 debugSkipRunToCursor.disabled = debugMenusDisabled;
2401 debugToggleBreakpoint.disabled = debugMenusDisabled;
2407 ProjectView projectView = ide.projectView;
2410 designer.fileName = fileName;
2416 sprintf(title, $"Untitled %d", documentID);
2417 // designer.fileName = CopyString(title);
2418 designer.fileName = title;
2421 DebugMenusDisabled();
2423 for(c = 0; c < CodeObjectType::enumSize; c++)
2424 icons[c] = BitmapResource { iconNames[c], window = this };
2426 codeModified = true;
2438 selected.modified = true;
2439 selected.oClass.modified = true;
2441 designer.modifiedDocument = true;
2442 modifiedDocument = true;
2443 formModified = true;
2446 /****************************************************************************
2448 ****************************************************************************/
2451 this.defines.Free(FreeModuleDefine);
2452 this.imports.Free(FreeModuleImport);
2459 FreeExcludedSymbols(this.excludedSymbols);
2460 FreeContext(this.globalContext);
2462 FreeGlobalData(&this.globalData);
2464 if(GetGlobalContext() == globalContext)
2466 SetGlobalData(null);
2467 SetGlobalContext(null);
2468 SetExcludedSymbols(null);
2469 SetTopContext(null);
2470 SetCurrentContext(null);
2473 SetPrivateModule(null);
2476 if(this.privateModule)
2478 FreeTypeData(this.privateModule);
2479 delete this.privateModule;
2480 this.privateModule = null;
2486 static bool reentrant = false;
2491 char * selectedClassName = null, * selectedName = null;
2492 int selectedPos = 0;
2493 Designer backDesigner;
2494 char oldWorkDir[MAX_LOCATION];
2495 char mainModuleName[MAX_FILENAME] = "";
2497 ImportedModule module;
2498 char extension[MAX_EXTENSION];
2500 Time parseCodeStart = GetTime();
2501 Time startTime, startFindClass;
2503 findClassTotalTime = 0;
2504 checkTypeTotalTime = 0;
2505 externalImportTotalTime = 0;
2506 findClassIgnoreNSTotalTime = 0;
2507 findSymbolTotalTime = 0;
2508 //ResetClassFindTime();
2512 // 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)
2513 if(reentrant) return;
2520 selectedClassName = CopyString(oClass.name);
2521 if(selected != oClass)
2523 ObjectInfo object = this.selected;
2524 selectedName = CopyString(object.name);
2528 for(check = this.oClass.instances.first; check; check = check.next)
2540 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
2542 defines.Free(FreeModuleDefine);
2543 imports.Free(FreeModuleImport);
2545 SetGlobalData(&globalData);
2546 SetGlobalContext(globalContext);
2547 SetExcludedSymbols(&excludedSymbols);
2548 SetTopContext(globalContext);
2549 SetCurrentContext(globalContext);
2550 SetDefines(&defines);
2551 SetImports(&imports);
2552 SetCurrentNameSpace(null);
2555 sprintf(command, "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin\\cl "
2556 "/nologo /D \"MSC\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" "
2557 "/I \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include\" "
2558 "/I T:\\ecere\\include /E %s", argv[1]);
2562 ChangeWorkingDir("e:\\ec");
2563 sprintf(command, "gcc -x c -E -");
2564 fileInput = DualPipeOpen({ output = true, input = true }, command);
2565 SetFileInput(fileInput);
2570 uint count = editFile.Read(buffer, 1, sizeof(buffer));
2572 fileInput.Write(buffer, 1, count);
2577 fileInput.CloseOutput();
2581 // TOCHECK: COULDN'T WE CALL FreeParser here?
2583 this.functionType = null;
2584 this.instanceType = null;
2587 sheet.SelectObject(null);
2593 // We don't want the designer to be notified of selection when deleting rows...
2594 backDesigner = designer;
2599 ObjectInfo _class, next;
2601 for(_class = classes.first; _class; _class = next)
2607 for(;object = _class.instances.first;)
2611 Designer::DestroyObject(object.instance);
2612 delete object.instance;
2614 sheet.DeleteObject(object);
2616 _class.instances.Delete(object);
2620 Designer::DestroyObject(_class.instance);
2621 delete _class.instance;
2623 sheet.DeleteObject(_class);
2625 classes.Delete(_class);
2631 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2632 if(windowClass && windowClass.data)
2633 UnapplySkin(windowClass);
2636 designer = backDesigner;
2639 fileInput = editFile = EditBoxStream { editBox = editBox };
2640 SetFileInput(fileInput);
2649 FreeContext(this.globalContext);
2650 FreeExcludedSymbols(this.excludedSymbols);
2653 FreeGlobalData(&this.globalData);
2655 if(this.privateModule)
2657 FreeTypeData(this.privateModule);
2658 delete this.privateModule;
2662 startTime = GetTime();
2663 printf("Cleaning up took %.3f seconds\n", startTime - parseCodeStart);
2665 printf("classes.count: %d\n", globalContext.classes.count);
2670 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2671 SetTargetBits(compiler.supportsBitDepth ? 32 : GetHostBits());
2674 this.privateModule = __ecere_COM_Initialize(false, 1, null);
2676 SetPrivateModule(privateModule);
2679 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint"), type = ProcessTypeString("unsigned int", false) });
2680 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint64"), type = ProcessTypeString("unsigned int64", false) });
2681 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint32"), type = ProcessTypeString("unsigned int", false) });
2682 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint16"), type = ProcessTypeString("unsigned short", false) });
2683 globalContext.types.Add((BTNode)Symbol { string = CopyString("byte"), type = ProcessTypeString("unsigned char", false) });
2686 fileName = this.fileName;
2688 if(ide.workspace && ide.workspace.projects && fileName)
2690 for(p : ide.workspace.projects)
2692 char path[MAX_LOCATION];
2694 MakePathRelative(fileName, p.topNode.path, path);
2695 MakeSlashPath(path);
2697 pn = p.topNode.FindWithPath(path, false);
2706 project = ide.project;
2708 GetWorkingDir(oldWorkDir, MAX_LOCATION);
2710 ChangeWorkingDir(project.topNode.path);
2712 SetSomeSourceFileStack(fileName ? fileName : "", 0); //strcpy(sourceFileStack[0], fileName ? fileName : "");
2714 GetLastDirectory(fileName, mainModuleName);
2715 GetExtension(mainModuleName, extension);
2717 SetBuildingEcereCom(false);
2718 SetBuildingEcereComModule(false);
2720 // TODO: Get symbolsDir from project settings instead...
2723 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2724 ProjectConfig config = project.config;
2725 DirExpression objDir = project.GetObjDir(compiler, config);
2726 SetSymbolsDir(objDir.dir);
2729 // SetIncludeDirs(ide.projectView.project.config.includeDirs);
2730 // SetSysIncludeDirs(ide.ideSettings.systemDirs[includes]);
2734 switch(GetRuntimePlatform())
2736 case win32: SetSymbolsDir("obj/debug.win32"); break;
2737 case tux: SetSymbolsDir("obj/debug.linux"); break;
2738 case apple: SetSymbolsDir("obj/debug.apple"); break;
2740 SetIncludeDirs(null);
2741 SetSysIncludeDirs(null);
2745 if(ide.projectView && ide.projectView.IsModuleInProject(this.fileName))
2747 // TODO FIX for configless project
2748 if(ide.project.config && ide.project.config.options && ide.project.config.options.preprocessorDefinitions)
2750 for(item : ide.project.config.options.preprocessorDefinitions)
2752 if(!strcmp(item, "BUILDING_ECERE_COM"))
2754 SetBuildingEcereCom(true);
2761 if(!(strcmpi(mainModuleName, "instance.ec") && strcmpi(mainModuleName, "BinaryTree.ec") &&
2762 strcmpi(mainModuleName, "dataTypes.ec") && strcmpi(mainModuleName, "OldList.ec") &&
2763 strcmpi(mainModuleName, "String.ec") && strcmpi(mainModuleName, "BTNode.ec") &&
2764 strcmpi(mainModuleName, "Array.ec") && strcmpi(mainModuleName, "AVLTree.ec") &&
2765 strcmpi(mainModuleName, "BuiltInContainer.ec") && strcmpi(mainModuleName, "Container.ec") &&
2766 strcmpi(mainModuleName, "CustomAVLTree.ec") && strcmpi(mainModuleName, "LinkList.ec") &&
2767 strcmpi(mainModuleName, "List.ec") && strcmpi(mainModuleName, "Map.ec") &&
2768 strcmpi(mainModuleName, "Mutex.ec")))
2770 SetBuildingEcereComModule(true);
2773 // Predeclare all classes
2775 char symFile[MAX_FILENAME];
2776 char symLocation[MAX_LOCATION];
2777 ImportedModule module, next;
2779 GetLastDirectory(fileName, symFile);
2780 ChangeExtension(symFile, "sym", symFile);
2782 strcpy(symLocation, GetSymbolsDir());
2783 PathCat(symLocation, symFile);
2785 // if(!GetEcereImported() && !GetBuildingEcereCom())
2786 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2789 startTime = GetTime();
2791 eModule_LoadStrict(privateModule, "ecereCOM", privateAccess);
2793 printf("Loading ecereCOM took %.3f seconds\n", GetTime() - startTime);
2798 startTime = GetTime();
2800 // LoadSymbols(symLocation, normalImport, true);
2801 LoadSymbols(symLocation, preDeclImport, false);
2803 printf("Loading symbols took %.3f seconds\n", GetTime() - startTime);
2806 for(module = defines.first; module; module = next)
2809 if(module.type == moduleDefinition && strcmpi(module.name, mainModuleName))
2812 defines.Delete(module);
2817 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2819 SetDefaultDeclMode(privateAccess);
2820 SetDeclMode(privateAccess);
2824 SetDefaultDeclMode(defaultAccess);
2825 SetDeclMode(defaultAccess);
2828 StripExtension(mainModuleName);
2829 module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };
2830 defines.AddName(module);
2833 // SetYydebug(true);
2838 startTime = GetTime();
2839 startFindClass = checkTypeTotalTime;
2843 printf("ParseEc took %.3f seconds, out of which %.3f seconds were in CheckType\n", GetTime() - startTime, checkTypeTotalTime - startFindClass);
2845 CheckDataRedefinitions();
2848 SetIncludeDirs(null);
2849 SetSysIncludeDirs(null);
2860 startTime = GetTime();
2862 PrePreProcessClassDefinitions();
2863 ComputeModuleClasses(privateModule);
2864 PreProcessClassDefinitions();
2865 ProcessClassDefinitions();
2867 printf("Initial Passes took %.3f seconds\n", GetTime() - startTime);
2868 startTime = GetTime();
2873 printf("ComputeDataTypes took %.3f seconds\n", GetTime() - startTime);
2874 startTime = GetTime();
2876 ProcessInstantiations();
2878 printf("ProcessInstantiations took %.3f seconds\n", GetTime() - startTime);
2881 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2883 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2884 if(!windowClass || windowClass.internalDecl)
2887 startTime = GetTime();
2889 // *** COMMENTED THIS OUT DUE TO ecereCOM issues
2890 // eModule_Load(this.privateModule.application.allModules.first ? this.privateModule.application.allModules.first : this.privateModule, "ecere", privateAccess);
2891 eModule_Load(this.privateModule, "ecere", privateAccess);
2893 printf("Loading ecere.dll took %.3f seconds\n", GetTime() - startTime);
2896 windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2898 if(windowClass && windowClass.data)
2899 ApplySkin(windowClass, app.currentSkin.name, null);
2903 startTime = GetTime();
2905 for(external = ast->first; external; external = external.next)
2907 if(external.type == classExternal)
2909 ClassDefinition _class = external._class;
2910 if(_class.baseSpecs && _class.baseSpecs->first && ((Specifier)_class.baseSpecs->first).type == nameSpecifier ) // classSpecifier
2912 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)_class.baseSpecs->first).name);
2915 if(eClass_GetDesigner(regClass) && !GetBuildingEcereComModule())
2917 Instance instance = eInstance_New(regClass);
2918 ObjectInfo classObject
2920 name = CopyString(_class._class.name);
2921 instance = instance;
2922 classDefinition = _class;
2923 oClass = classObject;
2926 classes.Add(classObject);
2930 // Moved this at bottom so that the file dialog doesn't show up in eCom
2931 designer.CreateObject(instance, classObject, true, null);
2932 sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, typeClass, false);
2934 if(_class.definitions)
2938 for(def = _class.definitions->first; def; def = def.next)
2942 case defaultPropertiesClassDef:
2945 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
2947 Identifier id = propDef.identifiers->first;
2950 Property prop = eClass_FindProperty(regClass, id.string, this.privateModule);
2953 Class propertyClass = prop.dataTypeClass;
2955 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
2956 if(prop.compiled && prop.Set && prop.Get && propertyClass && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp)
2958 FreeType(propDef.initializer.exp.destType);
2959 propDef.initializer.exp.destType = MkClassType(propertyClass.name);
2960 ProcessExpressionType(propDef.initializer.exp);
2962 if(propertyClass.type == structClass || propertyClass.type == noHeadClass || propertyClass.type == normalClass)
2964 Expression computed = CopyExpression(propDef.initializer.exp);
2965 ComputeExpression(computed);
2967 if(computed.isConstant && computed.type == instanceExp && !id.next)
2971 if(computed.instance._class && computed.instance._class.symbol &&
2972 computed.instance._class.symbol.registered &&
2973 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
2975 prop.Set(instance, computed.instance.data);
2977 // This was saved in the control and shouldn't be freed by FreeExpression...
2978 if(propertyClass.type == normalClass)
2979 computed.instance.data = null;
2983 // MOVED THIS UP NOW THAT char * IS A NORMAL CLASS
2984 else if(computed.type == stringExp && propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
2986 String temp = new char[strlen(computed.string)+1];
2987 ReadString(temp, computed.string);
2988 prop.Set(instance, temp);
2992 propDef.variable = true;
2994 FreeExpression(computed);
2998 Expression computed = CopyExpression(propDef.initializer.exp);
2999 ComputeExpression(computed);
3000 if(computed.isConstant)
3002 //if(computed.type == memberExp) computed = computed.member.exp;
3004 if(computed.type == constantExp)
3006 Operand value = GetOperand(computed);
3007 DataValue valueData;
3008 valueData.i64 = value.i64;
3009 SetProperty(prop, instance, valueData);
3011 else if(computed.type == stringExp && propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3013 String temp = new char[strlen(computed.string)+1];
3014 ReadString(temp, computed.string);
3015 prop.Set(instance, temp);
3020 propDef.variable = true;
3022 FreeExpression(computed);
3026 propDef.variable = true;
3030 Method method = eClass_FindMethod(regClass, id.string, this.privateModule);
3031 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer &&
3032 propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
3035 // Maintain a list in FunctionDefinition of who is attached to it
3036 for(def = _class.definitions->first; def; def = def.next)
3038 if(def.type == functionClassDef)
3040 ClassFunction function = def.function;
3041 if(!strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
3043 function.attached.Add(OldLink { data = method });
3053 case declarationClassDef:
3055 Declaration decl = def.decl;
3058 case instDeclaration:
3060 Instantiation inst = decl.inst;
3061 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3062 if(instClass && eClass_GetDesigner(instClass))
3064 Instance control = eInstance_New(instClass);
3069 oClass = classObject;
3073 classObject.instances.Add(object);
3075 // TOCHECK: Why is this needed now?
3076 object.name = CopyString((inst.exp.type == memberExp) ? inst.exp.member.member.string : inst.exp.identifier.string);
3077 def.object = object;
3079 // if(object.name) { symbol = eList_Add(&curContext.symbols, sizeof(Symbol)); symbol.string = object.name; symbol.type = MkClassType(instClass.name); }
3081 designer.CreateObject(control, object, false, classObject.instance);
3082 sheet.AddObject(object, object.name ? object.name : inst._class.name, typeData, false);
3092 // Second pass, process instantiation members
3094 for(def = _class.definitions->first; def; def = def.next)
3098 case declarationClassDef:
3100 Declaration decl = def.decl;
3103 case instDeclaration:
3105 Instantiation inst = decl.inst;
3106 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3107 if(instClass && eClass_GetDesigner(instClass))
3110 object = object ? object.next : classObject.instances.first;
3111 control = object.instance;
3115 MembersInit members;
3116 for(members = inst.members->first; members; members = members.next)
3118 switch(members.type)
3120 case dataMembersInit:
3122 if(members.dataMembers)
3125 DataMember curMember = null;
3126 Class curClass = null;
3127 DataMember subMemberStack[256];
3128 int subMemberStackPos = 0;
3130 for(member = members.dataMembers->first; member; member = member.next)
3133 Identifier ident = member.identifiers ? member.identifiers->first : null;
3136 DataMember _subMemberStack[256];
3137 int _subMemberStackPos = 0;
3138 DataMember thisMember = (DataMember)eClass_FindDataMember(instClass, ident.string, privateModule, _subMemberStack, &_subMemberStackPos);
3142 thisMember = (DataMember)eClass_FindProperty(instClass, ident.string, privateModule);
3144 if(thisMember && thisMember.memberAccess == publicAccess)
3146 curMember = thisMember;
3147 curClass = curMember._class;
3148 memcpy(subMemberStack, _subMemberStack, sizeof(int) * _subMemberStackPos);
3149 subMemberStackPos = _subMemberStackPos;
3155 eClass_FindNextMember(instClass, &curClass, (DataMember *)&curMember, subMemberStack, &subMemberStackPos);
3156 if(curMember) found = true;
3158 if(found && curMember.isProperty)
3160 Property prop = (Property) curMember;
3161 Class propertyClass = prop.dataTypeClass;
3163 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3165 if(prop.compiled && prop.Set && prop.Get && propertyClass && member.initializer && member.initializer.type == expInitializer && member.initializer.exp)
3167 FreeType(member.initializer.exp.destType);
3168 member.initializer.exp.destType = MkClassType(propertyClass.name);
3171 ProcessExpressionType(member.initializer.exp);
3173 if(propertyClass.type == structClass || propertyClass.type == normalClass || propertyClass.type == noHeadClass)
3175 Expression computed;
3177 /*char debugExpString[4096];
3178 debugExpString[0] = '\0';
3179 PrintExpression(member.initializer.exp, debugExpString);*/
3181 computed = CopyExpression(member.initializer.exp);
3184 ComputeExpression(computed);
3186 if(computed.type == instanceExp && computed.isConstant && computed.isConstant)
3188 if(computed.instance.data)
3190 if(computed.instance._class && computed.instance._class.symbol &&
3191 computed.instance._class.symbol.registered &&
3192 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3194 prop.Set(control, computed.instance.data);
3196 // This was saved in the control and shouldn't be freed by FreeExpression...
3197 if(propertyClass.type == normalClass)
3198 computed.instance.data = null;
3202 else if(computed.type == identifierExp)
3204 member.variable = true;
3206 if(eClass_GetDesigner(propertyClass))
3209 char * name = computed.identifier.string;
3210 if(!strcmp(name, "this"))
3213 prop.Set(control, instance);
3214 member.variable = false;
3219 for(check = classObject.instances.first; check; check = check.next)
3220 if(check.name && !strcmp(name, check.name))
3223 prop.Set(control, check.instance);
3224 member.variable = false;
3230 else if(computed.type == memberExp)
3232 member.variable = true;
3233 if(computed.member.exp.type == identifierExp)
3235 char * name = computed.member.exp.identifier.string;
3236 if(!strcmp(name, "this"))
3238 char * name = computed.member.member.string;
3241 for(check = classObject.instances.first; check; check = check.next)
3242 if(check.name && !strcmp(name, check.name))
3245 prop.Set(control, check.instance);
3246 member.variable = false;
3254 for(check = classObject.instances.first; check; check = check.next)
3256 if(check.name && !strcmp(name, check.name))
3258 Property getProperty = eClass_FindProperty(check.instance._class, computed.member.member.string, this.privateModule);
3261 DataValue value { };
3262 GetProperty(getProperty, check.instance, &value);
3263 SetProperty(prop, control, value);
3264 member.variable = false;
3272 // MOVED THIS UP NOW THAT char * IS A NORMAL CLASS
3273 else if(computed.isConstant && computed.type == stringExp && propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3275 String temp = new char[strlen(computed.string)+1];
3276 ReadString(temp, computed.string);
3277 prop.Set(control, temp);
3281 member.variable = true;
3283 FreeExpression(computed);
3288 Expression computed = CopyExpression(member.initializer.exp);
3291 ComputeExpression(computed);
3292 if(computed.isConstant)
3294 if(computed.type == constantExp && (!propertyClass.dataTypeString || strcmp(propertyClass.dataTypeString, "char *"))) //(strcmp(propertyClass.name, "char *") && (strcmp(propertyClass.name, "String"))))
3296 if(!strcmp(propertyClass.dataTypeString, "float"))
3297 ((void (*)(void *, float))(void *)prop.Set)(control, (float)strtod(computed.constant, null));
3298 else if(!strcmp(propertyClass.dataTypeString, "double"))
3299 ((void (*)(void *, double))(void *)prop.Set)(control, strtod(computed.constant, null));
3301 prop.Set(control, strtol(computed.constant, null, 0));
3303 else if(computed.type == stringExp && propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3305 String temp = new char[strlen(computed.string)+1];
3306 ReadString(temp, computed.string);
3307 prop.Set(control, temp);
3312 member.variable = true;
3314 FreeExpression(computed);
3320 member.variable = true;
3322 else if(ident && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3323 member.initializer.exp.type == memberExp) // identifierExp
3325 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3326 if(method && method.type == virtualMethod)
3329 // Maintain a list in FunctionDefinition of who is attached to it
3330 for(def = _class.definitions->first; def; def = def.next)
3332 if(def.type == functionClassDef)
3334 ClassFunction function = def.function;
3335 Identifier id = (member.initializer.exp.type == memberExp) ? member.initializer.exp.member.member : member.initializer.exp.identifier;
3336 if(function.declarator && !strcmp(function.declarator.symbol.string, id.string))
3338 function.attached.Add(OldLink { data = method });
3339 // Reference this particular instance?
3354 designer.PostCreateObject(object.instance, object, false, classObject.instance);
3365 //designer.CreateObject(instance, classObject, true, null);
3366 //sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, classType, false);
3368 designer.PostCreateObject(instance, classObject, true, null);
3370 //instance.state = Hidden;
3371 //instance.Create();
3372 //instance.SetState(Normal, true, 0);
3381 printf("Class/Instance Processing took %.3f seconds\n", GetTime() - startTime);
3385 // Restore Selection
3386 if(selectedClassName)
3389 for(oClass = classes.first; oClass; oClass = oClass.next)
3391 if(!strcmp(oClass.name, selectedClassName))
3393 this.oClass = oClass;
3397 delete selectedClassName;
3406 for(check = this.oClass.instances.first; check; check = check.next)
3408 if(check.name && !strcmp(check.name, selectedName))
3410 this.selected = check;
3416 if(this.oClass.instances.first)
3417 this.selected = this.oClass.instances.first;
3419 this.selected = this.oClass;
3422 else if(selectedPos == -1 || !this.oClass.instances.count)
3423 this.selected = this.oClass;
3429 if(selectedPos > this.oClass.instances.count)
3431 for(check = this.oClass.instances.first; check; check = check.next)
3433 if(selectedPos == pos++)
3435 this.selected = check;
3443 this.oClass = classes.first;
3444 this.selected = (this.oClass && this.oClass.instances.first) ? this.oClass.instances.first : this.oClass;
3446 delete selectedName;
3447 SetSymbolsDir(null);
3449 if(sheet.codeEditor == this)
3450 sheet.SelectObject(selected);
3453 codeModified = false;
3455 // TESTING THIS TO NOT GET EMPTY PARAMETERS
3458 InvokeParameters(false, false, false);
3461 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
3467 ChangeWorkingDir(oldWorkDir);
3469 printf("Total FindClass time is %.3f seconds, out of which %.3f is in Ignore NS\n\n", findClassTotalTime, findClassIgnoreNSTotalTime);
3470 printf("Total CheckType time is %.3f seconds\n\n", checkTypeTotalTime);
3471 printf("Total MkExternalImport time is %.3f seconds\n\n", externalImportTotalTime);
3472 printf("Total FindSymbol time is %.3f seconds\n\n", findSymbolTotalTime);
3473 // printf("Total Class Members Find time is %.3f seconds\n\n", GetClassFindTime());
3475 printf("Whole ParseCode function took %.3f seconds\n\n", GetTime() - parseCodeStart);
3477 if(inUseDebug && ide.projectView)
3478 ide.debugger.EvaluateWatches();
3481 void UpdateInstanceCodeClass(Class _class, ObjectInfo object, EditBoxStream f, Instance test, bool * prev, bool * lastIsMethod, DataMember * curMember, Class * curClass)
3484 Window control = (Window)object.instance;
3485 ObjectInfo classObject = object.oClass;
3487 if(_class.base && _class.base.type != systemClass) UpdateInstanceCodeClass(_class.base, object, f, test, prev, lastIsMethod, curMember, curClass);
3489 if(!strcmp(_class.name, "DesignerBase")) return;
3491 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
3493 Property prop = eClass_FindProperty(object.instance._class, propIt.name, privateModule);
3494 if(prop && prop.isProperty && !prop.conversion && eClass_FindProperty(object.instance._class, prop.name, privateModule))
3496 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(object, prop.name) &&
3497 prop.compiled && (!prop.IsSet || prop.IsSet(control)))
3499 Class dataType = prop.dataTypeClass;
3501 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3505 if(dataType.type == structClass)
3507 void * dataForm = new0 byte[dataType.structSize];
3508 void * dataTest = new0 byte[dataType.structSize];
3510 ((void (*)())(void *)prop.Get)(control, dataForm);
3511 prop.Get(test, dataTest);
3513 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
3515 char tempString[1024] = "";
3517 bool needClass = true;
3521 prop.Set(test, dataForm);
3523 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
3525 eClass_FindNextMember(_class, curClass, curMember, null, null);
3526 if(*curMember != (DataMember)prop)
3527 f.Printf("%s = ", prop.name);
3529 *curMember = (DataMember)prop;
3530 *curClass = curMember->_class;
3533 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3535 f.Printf("%s", string);
3542 else if(dataType.type == normalClass || dataType.type == noHeadClass)
3544 void * dataForm, * dataTest;
3546 dataForm = (void *)prop.Get(control);
3547 dataTest = (void *)prop.Get(test);
3549 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
3551 char tempString[1024] = "";
3556 prop.Set(test, dataForm);
3558 eClass_FindNextMember(_class, curClass, curMember, null, null);
3559 if(*curMember != (DataMember)prop)
3560 f.Printf("%s = ", prop.name);
3561 *curMember = (DataMember)prop;
3562 *curClass = curMember->_class;
3564 if(eClass_GetDesigner(dataType))
3566 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
3567 //if(!strcmp(classObject.instance._class.name, dataType.name) && classObject.instance == dataForm)
3568 f.Printf("this", prop.name);
3571 //ObjectInfo classObject;
3572 //for(classObject = classes.first; classObject; classObject = classObject.next)
3576 for(object = classObject.instances.first; object; object = object.next)
3578 if(!object.deleted && eClass_IsDerived(object.instance._class, dataType) && object.instance == dataForm && object.name)
3580 f.Printf("%s", object.name);
3587 bool needClass = true;
3588 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
3589 f.Printf("%s", string);
3596 bool needClass = true;
3597 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
3599 if(!strcmp(dataType.dataTypeString, "char *"))
3602 OutputString(f, string);
3606 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3608 f.Printf("%s", string);
3611 *lastIsMethod = false;
3616 DataValue dataForm, dataTest;
3618 GetProperty(prop, control, &dataForm);
3619 GetProperty(prop, test, &dataTest);
3621 if((prop.IsSet && !prop.IsSet(test)) || dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
3624 char tempString[1024] = "";
3625 SetProperty(prop, test, dataForm);
3627 if(dataType.type != bitClass)
3629 bool needClass = true;
3631 if(dataType.type == enumClass)
3634 Class enumClass = eSystem_FindClass(privateModule, "enum");
3635 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
3637 for(value = e.values.first; value; value = value.next)
3639 if((int)value.data == dataForm.i)
3641 string = value.name;
3647 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, &dataForm, tempString, null, &needClass);
3649 if(string && string[0])
3654 eClass_FindNextMember(_class, curClass, curMember, null, null);
3655 if(*curMember != (DataMember)prop)
3656 f.Printf("%s = ", prop.name);
3657 *curMember = (DataMember)prop;
3658 *curClass = curMember->_class;
3660 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
3661 f.Printf("%sf", string);
3663 f.Printf("%s", string);
3667 else if(dataType.type == bitClass)
3669 bool needClass = true;
3671 if(*prev) f.Printf(", ");
3673 eClass_FindNextMember(_class, curClass, curMember, null, null);
3674 if(*curMember != (DataMember)prop)
3675 f.Printf("%s = ", prop.name);
3676 *curMember = (DataMember)prop;
3677 *curClass = curMember->_class;
3679 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, &dataForm.ui, tempString, null, &needClass);
3681 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3683 f.Printf("%s", string);
3685 *lastIsMethod = false;
3695 int UpdateInstanceCode(EditBoxStream f, int position, Class regClass, ObjectInfo object, bool * firstObject, char ** text, int * textSize, int movedFuncIdLen, int movedFuncIdPos)
3697 Instantiation inst = object.instCode;
3698 Window control = (Window)object.instance;
3700 bool methodPresent = false;
3702 bool lastIsMethod = true;
3703 ObjectInfo classObject = object.oClass;
3709 // Instance removed, delete it
3710 DeleteJunkBefore(f, inst.loc.start.pos, &position);
3712 f.DeleteBytes(inst.loc.end.pos - inst.loc.start.pos + 1);
3713 position = inst.loc.end.pos + 1;
3717 bool multiLine = false;
3720 // Check if it's an unnamed instance
3723 f.Seek(inst.nameLoc.start.pos - position, current);
3724 f.DeleteBytes(inst.nameLoc.end.pos - inst.nameLoc.start.pos);
3725 position = inst.nameLoc.end.pos;
3727 f.Printf(object.name);
3732 if(isspace(ch) && ch != '\n')
3734 f.Seek(-1, current);
3742 int pos = inst.loc.start.pos; // + strlen(inst._class.name);
3744 f.Seek(pos - position, current);
3749 f.Seek(-1, current);
3758 f.Puts(object.name);
3763 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
3764 methodPresent = true;
3772 if(ch == OpenBracket)
3778 // TODO: Simplify this?
3787 f.Seek(-1, current);
3799 if(ch == '\n') { toDelete = count; count = 0; }
3800 else if(isspace(ch)) count++;
3803 f.Seek(-1, current);
3807 toDelete += count - 6;
3817 f.Seek(-toDelete-count, current);
3818 f.DeleteBytes(toDelete);
3819 f.Seek(count, current);
3824 for(c = 0; c<toAdd; c++)
3830 methodPresent = multiLine;
3833 f.Printf(methodPresent ? "\n " : " ");
3839 // Instance not there, create a brand new one
3840 DeleteJunkBefore(f, position, &position);
3841 f.Printf(*firstObject ? "\n\n" : "\n");
3842 *firstObject = false;
3844 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
3845 methodPresent = true;
3850 f.Printf(" %s %s\n %c\n ", control._class.name, object.name, OpenBracket);
3852 f.Printf(" %s\n %c\n ", control._class.name, OpenBracket);
3857 f.Printf(" %s %s %c ", control._class.name, object.name, OpenBracket);
3859 f.Printf(" %s %c ", control._class.name, OpenBracket);
3865 Instance test = eInstance_New(control._class);
3866 DataMember curMember = null;
3867 Class curClass = null;
3870 UpdateInstanceCodeClass(control._class, object, f, test, &prev, &lastIsMethod, &curMember, &curClass);
3874 // Attach Method here
3875 if((this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod) && !this.moveAttached && this.selected == object)
3877 if(prev) f.Printf(", ");
3878 f.Printf("%s = %s", this.method.name, function.declarator.symbol.string);
3883 if(inst && !object.deleted)
3885 MembersInit members;
3886 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3888 DeleteJunkBefore(f, position, &position);
3890 // Instance already there, clear out the properties
3891 for(members = inst.members->first; members; members = members.next)
3893 if(members.type == dataMembersInit)
3897 if(members.dataMembers)
3899 bool keptMember = false;
3900 MemberInit lastKept = null;
3902 for(member = members.dataMembers->first; member; member = member.next)
3904 Identifier ident = member.identifiers ? member.identifiers->first : null;
3905 bool deleted = false;
3907 // For now delete if it's not a method
3908 if(!member.variable) // && ident)
3910 if(!ident || !ident.next)
3912 Property prop = ident ? eClass_FindProperty(instClass, ident.string, this.privateModule) : null;
3915 f.Seek(member.loc.start.pos - position, current);
3916 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
3917 position = member.loc.end.pos;
3922 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3923 if(method && method.type == virtualMethod && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3924 member.initializer.exp.type == memberExp /*ExpIdentifier*/)
3926 if(((this.methodAction == actionDetachMethod || this.methodAction == actionReattachMethod) && this.method == method && this.selected == object) ||
3927 (this.methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, member.initializer.exp.identifier.string)))
3929 f.Seek(member.loc.start.pos - position, current);
3930 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
3931 position = member.loc.end.pos;
3943 //f.Seek(member.loc.start.pos - position, current);
3944 //position = member.loc.start.pos;
3945 DeleteJunkBefore(f, member.loc.start.pos, &position);
3946 if(prev) f.Printf(", ");
3947 else if(keptMember) f.Printf(" ");
3952 if(!keptMember || !members.next)
3957 if(keptMember && lastKept != members.dataMembers->last)
3962 f.Seek(-1, current);
3968 f.Seek(-1, current);
3971 else if(!isspace(ch))
3973 f.Seek(-2, current);
3978 f.DeleteBytes(count);
3981 f.Seek(members.loc.end.pos - position, current);
3986 f.Seek(-1, current);
3988 position = members.loc.end.pos + 1;
3992 f.Seek(-1, current);
3993 position = members.loc.end.pos;
3999 lastIsMethod = false;
4004 DeleteJunkBefore(f, position, &position);
4007 if(lastKept != members.dataMembers->last)
4012 f.Seek(-1, current);
4018 f.Seek(-1, current);
4021 else if(!isspace(ch))
4023 f.Seek(-2, current);
4028 f.DeleteBytes(count);
4032 f.Seek(members.loc.end.pos - position, current);
4033 position = members.loc.end.pos;
4037 lastIsMethod = true;
4040 lastIsMethod = false;
4046 f.Seek(members.loc.end.pos - position, current);
4047 position = members.loc.end.pos;
4049 lastIsMethod = true;
4052 else if(members.type == methodMembersInit)
4054 if(this.methodAction == actionDeleteMethod && members.function == function);
4056 methodPresent = true;
4058 // Delete instance method here
4059 if((this.methodAction == actionDeleteMethod || (this.methodAction == actionDetachMethod && this.moveAttached)) &&
4060 members.function == function)
4062 if(this.moveAttached && !*text)
4063 GetLocText(editBox, f, position, &function.loc, text, textSize, Max((int)strlen(this.methodName) - movedFuncIdLen,0), 0);
4065 DeleteJunkBefore(f, members.loc.start.pos, &position);
4066 f.DeleteBytes(members.loc.end.pos - members.loc.start.pos + 1);
4067 position = members.loc.end.pos + 1;
4072 DeleteJunkBefore(f, position, &position);
4076 DeleteJunkBefore(f, members.loc.start.pos, &position);
4077 lastIsMethod = true;
4081 f.Seek(members.loc.end.pos - position, current);
4082 position = members.loc.end.pos;
4084 DeleteJunkBefore(f, position, &position);
4093 if((this.methodAction == actionAddMethod || (this.moveAttached && (this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod))) && this.selected == object)
4095 Method method = this.method;
4096 DeleteJunkBefore(f, position, &position);
4102 if(!method.dataType)
4103 method.dataType = ProcessTypeString(method.dataTypeString, false);
4106 Type dataType = method.dataType;
4107 Type returnType = dataType.returnType;
4110 if(this.moveAttached)
4112 // Move function here:
4113 int newLen = strlen(method.name);
4118 GetLocText(editBox, f, position, &function.loc, text, textSize, Max(newLen - movedFuncIdLen, 0), 3);
4120 // First change name of function
4121 memmove(*text + movedFuncIdPos + newLen, *text + movedFuncIdPos + movedFuncIdLen, *textSize - movedFuncIdPos - movedFuncIdLen + 1);
4122 *textSize += newLen - movedFuncIdLen;
4123 memcpy(*text + movedFuncIdPos, method.name, newLen);
4125 // Second, tab right
4128 for(c = 0; (*text)[c]; )
4131 for(i = c; (*text)[i] && (*text)[i] != '\n'; i++);
4134 memmove((*text)+c+3, (*text)+c, *textSize+1-c);
4135 (*text)[c] = (*text)[c+1] = (*text)[c+2] = ' ';
4139 for(; (*text)[c] && (*text)[c] != '\n'; c++);
4149 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4151 // ADDING METHOD HERE
4153 OutputType(f, returnType, false);
4156 if(dataType.thisClass)
4158 if(!eClass_IsDerived(regClass, dataType.thisClass.registered) && !dataType.classObjectType) // Just fixed this... was backwards.
4160 if(dataType.thisClass.shortName)
4161 f.Printf(dataType.thisClass.shortName);
4163 f.Printf(dataType.thisClass.string);
4167 f.Printf(method.name);
4169 for(param = dataType.params.first; param; param = param.next)
4171 OutputType(f, param, true);
4176 f.Printf(" %c\n\n", OpenBracket);
4178 if(control._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4180 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4181 f.Printf(" return true;\n");
4182 else if(returnType.kind != voidType)
4183 f.Printf(" return 0;\n");
4188 if(returnType.kind != voidType)
4189 f.Printf("return ");
4190 f.Printf("%s::%s(", control._class.name, method.name);
4191 for(param = dataType.params.first; param; param = param.next)
4193 if(param.prev) f.Printf(", ");
4194 if(param.kind != voidType)
4195 f.Printf(param.name);
4199 f.Printf(" %c\n", CloseBracket);
4205 if(!object.instCode)
4208 f.Printf(" %c;\n", CloseBracket);
4210 f.Printf("%c;\n", CloseBracket);
4212 else if(!object.deleted)
4214 // Turn this into a multiline instance when adding a method
4215 DeleteJunkBefore(f, inst.loc.end.pos-1, &position);
4217 f.Printf(methodPresent ? "\n " : " ");
4219 f.Seek(inst.loc.end.pos + 1 - position, current);
4220 position = inst.loc.end.pos + 1;
4225 void OutputClassProperties(Class _class, ObjectInfo classObject, EditBoxStream f, Instance test)
4228 Class regClass = eSystem_FindClass(privateModule, classObject.name);
4230 if(_class.base && _class.base.type != systemClass) OutputClassProperties(_class.base, classObject, f, test);
4232 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
4234 Property prop = eClass_FindProperty(selected.instance._class, propIt.name, privateModule);
4235 if(prop && prop.isProperty && !prop.conversion)
4237 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(classObject, prop.name) &&
4238 (!prop.IsSet || prop.IsSet(classObject.instance)))
4240 Class dataType = prop.dataTypeClass;
4241 char tempString[1024] = "";
4243 bool specify = false;
4246 member = eClass_FindDataMember(regClass, prop.name, privateModule, null, null);
4247 if(member && member._class == regClass)
4251 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
4253 if(dataType && dataType.type == structClass)
4255 void * dataForm = new0 byte[dataType.structSize];
4256 void * dataTest = new0 byte[dataType.structSize];
4258 prop.Get(classObject.instance, dataForm);
4259 prop.Get(test, dataTest);
4261 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
4263 bool needClass = true;
4265 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
4266 prop.Set(test, dataForm);
4268 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4270 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4275 else if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
4277 void * dataForm, * dataTest;
4279 dataForm = (void *)prop.Get(classObject.instance);
4280 dataTest = (void *)prop.Get(test);
4282 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, dataForm, dataTest))
4284 char tempString[1024] = "";
4286 prop.Set(test, dataForm);
4288 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
4290 // Shouldn't go here ...
4291 f.Printf("\n %s%s = this;", specify ? "property::" : "", prop.name);
4295 bool needClass = true;
4297 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, dataForm, tempString, null, &needClass);
4299 if(!strcmp(dataType.dataTypeString, "char *"))
4301 f.Printf("\n %s%s = \"", specify ? "property::" : "", prop.name);
4302 OutputString(f, string);
4306 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4308 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4314 DataValue dataForm, dataTest;
4316 GetProperty(prop, classObject.instance, &dataForm);
4317 GetProperty(prop, test, &dataTest);
4319 if(dataType._vTbl[__ecereVMethodID_class_OnCompare](dataType, &dataForm, &dataTest))
4321 SetProperty(prop, test, dataForm);
4322 if(dataType.type == bitClass)
4324 bool needClass = true;
4325 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, &dataForm, tempString, null, &needClass);
4327 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4329 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4333 bool needClass = true;
4334 if(dataType.type == enumClass)
4337 Class enumClass = eSystem_FindClass(privateModule, "enum");
4338 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
4340 for(value = e.values.first; value; value = value.next)
4342 if((int)value.data == dataForm.i)
4344 string = value.name;
4350 string = (char *)dataType._vTbl[__ecereVMethodID_class_OnGetString](dataType, &dataForm, tempString, null, &needClass);
4351 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
4352 f.Printf("\n %s%s = %sf;", specify ? "property::" : "", prop.name, string);
4354 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4363 void UpdateFormCode()
4372 else if(formModified)
4374 EditBoxStream f { editBox = editBox };
4378 Identifier movedFuncId;
4379 int movedFuncIdLen = 0, movedFuncIdPos = 0;
4380 ObjectInfo classObject;
4386 movedFuncId = GetDeclId(function.declarator);
4387 movedFuncIdLen = movedFuncId.loc.end.pos - movedFuncId.loc.start.pos;
4388 movedFuncIdPos = movedFuncId.loc.start.pos - function.loc.start.pos;
4391 for(classObject = classes.first; classObject; classObject = classObject.next)
4394 ClassDefinition classDef = classObject.classDefinition;
4395 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
4398 bool firstObject = true;
4399 ObjectInfo object = classObject.instances.first;
4400 bool lastIsDecl = false;
4402 if(!classObject.modified) continue;
4404 test = eInstance_New(regClass);
4407 // Put it in the same desktop window...
4408 designer.PrepareTestObject(test);
4410 //f.Printf("class %s : %s\n", classObject.name, classObject.oClass.name);
4411 //f.Printf("%c\n\n", OpenBracket);
4413 // Change the _class name
4414 f.Seek(classDef.nameLoc.start.pos - position, current);
4415 f.DeleteBytes(classDef.nameLoc.end.pos - classDef.nameLoc.start.pos);
4416 f.Printf(classObject.name);
4417 position = classDef.nameLoc.end.pos;
4420 // Go to block start, delete all until no white space, put \n
4424 f.Seek(classDef.blockStart.end.pos - position, current);
4425 position = classDef.blockStart.end.pos;
4427 for(; f.Getc(&ch); count++)
4431 f.Seek(-1, current);
4441 f.Seek(-count, current);
4443 f.DeleteBytes(count-back);
4445 position += count-back;
4448 // Output properties
4449 OutputClassProperties(classObject.instance._class, classObject, f, test);
4451 for(def = classDef.definitions->first; def; def = def.next)
4455 case defaultPropertiesClassDef:
4457 bool keptMember = false;
4459 MemberInit lastKept = null;
4462 DeleteJunkBefore(f, def.loc.start.pos, &position);
4465 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4467 Identifier ident = propDef.identifiers->first;
4468 bool deleted = false;
4470 // For now delete if it's a prop
4471 if(!propDef.variable && ident)
4475 Property prop = eClass_FindProperty(regClass, ident.string, this.privateModule);
4478 f.Seek(propDef.loc.start.pos - position, current);
4479 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4480 position = propDef.loc.end.pos;
4485 Method method = eClass_FindMethod(regClass, ident.string, this.privateModule);
4486 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4488 if(((methodAction == actionDetachMethod || methodAction == actionReattachMethod) && method == this.method && selected == classObject) ||
4489 (methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string)))
4491 f.Seek(propDef.loc.start.pos - position, current);
4492 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4493 position = propDef.loc.end.pos;
4511 f.Seek(def.loc.end.pos - position - 1, current);
4516 f.Seek(-1, current);
4519 position = def.loc.end.pos;
4523 if(lastKept != def.defProperties->last)
4528 f.Seek(-1, current);
4534 f.Seek(-1, current);
4537 else if(!isspace(ch))
4539 f.Seek(-2, current);
4544 f.DeleteBytes(count);
4548 f.Seek(def.loc.end.pos - position, current);
4549 position = def.loc.end.pos;
4554 case declarationClassDef:
4556 Declaration decl = def.decl;
4558 if(decl.type == instDeclaration)
4560 if(def.object/* && ((ObjectInfo)def.object).modified*/)
4562 while(def.object && object != def.object)
4564 if(object /*&& ((ObjectInfo)def.object).modified*/)
4565 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4566 object = object.next;
4569 DeleteJunkBefore(f, def.loc.start.pos, &position);
4570 f.Printf(firstObject ? "\n\n " : "\n ");
4571 firstObject = false;
4573 if(def.object && ((ObjectInfo)def.object).modified)
4574 position = UpdateInstanceCode(f, position, regClass, def.object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4576 object = object ? object.next : null;
4580 DeleteJunkBefore(f, def.loc.start.pos, &position);
4581 f.Printf(firstObject ? "\n\n " : "\n ");
4582 firstObject = false;
4588 DeleteJunkBefore(f, def.loc.start.pos, &position);
4589 f.Printf(lastIsDecl ? "\n " : "\n\n ");
4594 case functionClassDef:
4596 // TESTING IF THIS IS GOOD ENOUGH FOR GENERATED FUNCTION...
4597 if(!def.function.body) continue;
4601 DeleteJunkBefore(f, def.loc.start.pos, &position);
4604 // Delete _class methods
4605 if((methodAction == actionDeleteMethod || (moveAttached && selected != classObject)) &&
4606 def.function == function)
4611 if(moveAttached && !text)
4613 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max((int)strlen(methodName) - movedFuncIdLen,0), 3);
4616 f.Seek(def.loc.end.pos - position, current);
4617 for(; f.Getc(&ch); count++)
4621 f.Seek(-1, current);
4625 f.Seek(def.loc.start.pos - def.loc.end.pos - count, current);
4627 f.DeleteBytes(def.loc.end.pos - def.loc.start.pos + count);
4628 position = def.loc.end.pos + count;
4631 // In case of detaching methods in the _class, simply rename the method
4632 if(methodAction == actionDetachMethod && moveAttached && selected == classObject && function == def.function)
4634 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4635 f.DeleteBytes(movedFuncIdLen);
4637 position = function.loc.start.pos + movedFuncIdPos + movedFuncIdLen;
4640 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && moveAttached &&
4641 function == def.function)
4643 // In case of attaching methods in the _class, simply rename the method
4644 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4645 position = function.loc.start.pos + movedFuncIdPos;
4646 f.DeleteBytes(movedFuncIdLen);
4647 if(method.dataType.thisClass)
4648 f.Printf("%s::", method.dataType.thisClass.string);
4649 f.Puts(method.name);
4650 position += movedFuncIdLen;
4655 DeleteJunkBefore(f, def.loc.start.pos, &position);
4656 if(def.type == memberAccessClassDef)
4659 firstObject = false;
4669 f.Seek(def.loc.end.pos - position, current);
4670 position = def.loc.end.pos;
4673 // Output attached methods
4674 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && !moveAttached)
4676 DeleteJunkBefore(f, position, &position);
4677 f.Printf("\n %s = %s;\n", method.name, function.declarator.symbol.string);
4680 // ********** INSTANCES ***************
4681 for(; object; object = object.next)
4683 if(!object.instCode)
4685 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4689 DeleteJunkBefore(f, position, &position);
4691 // ****************** METHODS ***********************
4692 if(methodAction == actionDetachMethod && moveAttached && classObject == oClass)
4694 // If detaching an instance method
4695 if(selected != classObject)
4697 int newLen = strlen(methodName);
4700 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max(newLen - movedFuncIdLen,0), 0);
4701 // Tab selection left
4704 for(c = 0; text[c]; )
4707 for(i = 0; i<3 && text[c] == ' '; i++, c++);
4708 memmove(text+start, text+start+i, textSize+1-start-i);
4711 for(; text[c] && text[c] != '\n'; c++);
4717 memmove(text + movedFuncIdPos + newLen, text + movedFuncIdPos + movedFuncIdLen, textSize - movedFuncIdPos - movedFuncIdLen + 1);
4718 textSize += newLen - movedFuncIdLen;
4719 memcpy(text + movedFuncIdPos, methodName, newLen);
4726 if(methodAction == actionAddMethod && selected == classObject)
4728 Method method = this.method;
4730 if(!method.dataType)
4731 method.dataType = ProcessTypeString(method.dataTypeString, false);
4733 // ADDING METHOD HERE
4735 Type dataType = method.dataType;
4736 Type returnType = dataType.returnType;
4738 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4742 OutputType(f, returnType, false);
4745 if(dataType.thisClass && !dataType.classObjectType)
4747 if(dataType.thisClass.shortName)
4748 f.Printf(dataType.thisClass.shortName);
4750 f.Printf(dataType.thisClass.string);
4753 f.Printf(method.name);
4755 for(param = dataType.params.first; param; param = param.next)
4757 OutputType(f, param, true);
4762 f.Printf(" %c\n\n", OpenBracket);
4764 if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4766 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4767 f.Printf(" return true;\n");
4768 else if(returnType && returnType.kind != voidType)
4769 f.Printf(" return 0;\n");
4774 if(returnType.kind != voidType)
4775 f.Printf("return ");
4777 char * name = ((Specifier)classDef.baseSpecs->first).name;
4778 Symbol _class = FindClass(name);
4779 f.Printf("%s::%s(", (_class && _class.registered) ? _class.registered.name : name, method.name);
4781 for(param = dataType.params.first; param; param = param.next)
4783 if(param.prev) f.Printf(", ");
4784 if(param.kind != voidType)
4785 f.Printf(param.name);
4790 f.Printf(" %c", CloseBracket);
4794 DeleteJunkBefore(f, classDef.loc.end.pos-1, &position);
4806 // TOFIX: Patch for a glitch where clicking at the end of the view seems one line off. No idea what could be going on?
4807 editBox.OnVScroll(setRange, editBox.scroll.y, 0);
4811 codeModified = false;
4812 formModified = false;
4814 moveAttached = false;
4819 int FindMethod(char * methodName /*Method method*/, ClassFunction*functionPtr, Location propLoc)
4822 ClassFunction function = null;
4825 ObjectInfo object = this.selected;
4827 if(object && object == this.oClass)
4829 ClassDefinition classDef = object.oClass.classDefinition;
4831 if(classDef && classDef.definitions)
4833 for(def = classDef.definitions->first; def; def = def.next)
4835 if(def.type == functionClassDef && def.function.declarator)
4837 if(!strcmp(def.function.declarator.symbol.string, methodName))
4839 function = def.function;
4844 else if(def.type == defaultPropertiesClassDef)
4848 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4850 Identifier ident = propDef.identifiers ? propDef.identifiers->first : null;
4851 if(ident && !ident.next)
4853 if(!strcmp(ident.string, methodName) && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4857 propLoc = propDef.loc;
4860 ClassDefinition classDef = object.oClass.classDefinition;
4862 if(classDef.definitions)
4864 for(def = classDef.definitions->first; def; def = def.next)
4866 if(def.type == functionClassDef)
4868 if(!strcmp(def.function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
4870 function = def.function;
4889 Instantiation inst = object.instCode;
4891 // Check here to see if the method already exists, no need to call ModifyCode in that case
4892 if(inst && inst.members)
4894 MembersInit members;
4895 for(members = inst.members->first; members; members = members.next)
4897 switch(members.type)
4899 case dataMembersInit:
4901 if(members.dataMembers)
4904 for(member = members.dataMembers->first; member; member = member.next)
4906 Identifier ident = member.identifiers ? member.identifiers->first : null;
4907 if(ident && !ident.next)
4909 if(!strcmp(ident.string, methodName) && member.initializer && member.initializer.type == expInitializer && member.initializer.exp && member.initializer.exp.type == memberExp /*ExpIdentifier*/)
4913 propLoc = member.loc;
4916 ClassDefinition classDef = object.oClass.classDefinition;
4918 if(classDef.definitions)
4920 for(def = classDef.definitions->first; def; def = def.next)
4922 if(def.type == functionClassDef)
4924 if(def.function.declarator && !strcmp(def.function.declarator.symbol.string, member.initializer.exp.identifier.string))
4926 function = def.function;
4935 // TODO: Fix memory leak
4936 function = ClassFunction
4938 declarator = Declarator { symbol = Symbol { string = CopyString(member.initializer.exp.member.member ? member.initializer.exp.member.member.string : "") } }
4950 case methodMembersInit:
4952 if(members.function.declarator && !strcmp(members.function.declarator.symbol.string, methodName))
4954 function = members.function;
4966 if(functionPtr) *functionPtr = function;
4970 void GoToMethod(char * methodName /*Method method*/)
4974 ObjectInfo object = selected;
4975 EditBoxStream f { editBox = editBox };
4976 ClassFunction function = null;
4977 bool atChar = false;
4981 Location propLoc = { {0,0,-1} };
4984 if(FindMethod(methodName, &function, &propLoc) == 1 && object != this.oClass) indent = 9;
4985 if(function && function.body)
4988 f.Seek(function.body.loc.start.pos+1, current);
4998 f.Seek(-1, current);
5003 else if(!isspace(ch))
5005 f.Seek(-1, current);
5011 else if(propLoc.start.pos > -1)
5013 f.Seek(propLoc.start.pos, current);
5016 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
5018 if(function || propLoc.start.pos > -1)
5020 editBox.SetSelPos(l1, y1, atChar ? x1 : indent, l2, y2, atChar ? x2 : indent);
5021 editBox.CenterOnCursor();
5022 SetState(normal, false, 0);
5025 if(function && function.declarator && function.declarator.symbol && !function.declarator.symbol.type)
5027 FreeClassFunction(function);
5033 void FindCompatibleMethods(Method method, OldList compatible)
5035 ClassDefinition classDef = this.oClass.classDefinition;
5036 if(classDef && classDef.definitions)
5039 Class baseClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5042 Symbol classSym { };
5043 Symbol selectedClass;
5044 if(this.selected == this.oClass)
5045 selectedClass = classSym;
5047 selectedClass = FindClass(this.selected.instance._class.name);
5049 regClass.name = classDef._class.name;
5050 regClass.base = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5051 for(def = classDef.definitions->first; def; def = def.next)
5053 if(def.type == functionClassDef && def.function.declarator)
5055 Method vMethod = eClass_FindMethod(baseClass, def.function.declarator.symbol.string, this.privateModule);
5057 vMethod = eClass_FindMethod(this.selected.instance._class, def.function.declarator.symbol.string, this.privateModule);
5060 Type type = def.function.declarator.symbol.type;
5061 if(CheckCompatibleMethod(method, type, regClass, this.selected == this.oClass, FindClass(this.selected.instance._class.name)))
5063 compatible.Add(OldLink { data = def.function });
5069 if(this.oClass && this.oClass.instance)
5071 classSym.registered = regClass;
5072 //classSym.registered = this.oClass.oClass;
5074 for(_class = regClass.base; _class; _class = _class.base)
5077 for(testMethod = (Method)_class.methods.first; testMethod; testMethod = (Method)((BTNode)testMethod).next)
5079 // TODO: Understand why these functions popup in attach list
5080 if(testMethod.type != virtualMethod /*&& testMethod.function != Window_OnGetString && testMethod.function != Window_OnGetDataFromString*/)
5082 if(!testMethod.dataType)
5083 testMethod.dataType = ProcessTypeString(testMethod.dataTypeString, false);
5085 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5086 if(CheckCompatibleMethod(method, testMethod.dataType, this.oClass.instance._class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5087 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, this.selected == this.oClass, FindClass(this.oClass.oClass.name)))
5089 // TODO: Fix memory leak, Figure out if it should be ClassFunction or FunctionDefinition
5090 // ClassFunction function { };
5091 FunctionDefinition function { };
5093 function.declarator = Declarator { };
5094 function.declarator.symbol = Symbol { string = CopyString(testMethod.name) };
5095 excludedSymbols.Add(function.declarator.symbol);
5097 compatible.Add(OldLink { data = function });
5108 void AddMethod(Method method)
5112 char methodName[1024];
5113 strcpy(methodName, method.name);
5114 if(!FindMethod(methodName, null, null))
5116 methodAction = actionAddMethod;
5117 this.method = method;
5121 GoToMethod(methodName);
5125 void DeleteMethod(ClassFunction function)
5129 methodAction = actionDeleteMethod;
5130 this.function = function;
5138 void AttachMethod(Method method, ClassFunction function)
5142 // If it's an instance we'll ask if we want to move it inside...
5143 if(!function.attached.count && function.body)
5145 // Find the function in the _class to check if it's a virtual function
5146 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5147 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5148 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5150 for(def = this.classDefinition.first; def; def = def.next)
5152 if(def.type == functionClassDef)
5154 if(def.function == function)
5159 if(!method || method.type != virtualMethod)
5162 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5163 if(MessageBox { type = yesNo, master = parent, text = title, contents = $"Method is unused. Move method inside instance?"}.Modal() == yes)
5165 moveAttached = true;
5170 methodAction = actionAttachMethod;
5171 this.method = method;
5172 this.function = function;
5179 void ReAttachMethod(Method method, ClassFunction function)
5183 // If it's an instance we'll ask if we want to move it inside...
5184 if(!function.attached.count && function.body)
5186 // Find the function in the _class to check if it's a virtual function
5187 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5188 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5189 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5191 for(def = this.classDefinition.first; def; def = def.next)
5193 if(def.type == functionClassDef)
5195 if(def.function == function)
5200 if(!method || method.type != virtualMethod)
5203 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5204 if(MessageBox { type = yesNo, master = parent, text = title,
5205 contents = $"Method is unused. Move method inside instance?" }.Modal() == yes)
5207 moveAttached = true;
5212 methodAction = actionReattachMethod;
5213 this.method = method;
5214 this.function = function;
5221 void DetachMethod(Method method, ClassFunction function, int type)
5229 hasClose = true, borderStyle = sizable, minClientSize = { 300, 55 },
5230 master = sheet, text = $"Name detached method", background = formColor
5234 dialog, anchor = { horz = 45, top = 30 }, size = { 80 }, text = $"Cancel", hotKey = escape,
5235 id = DialogResult::cancel, NotifyClicked = ButtonCloseDialog
5239 dialog, anchor = { horz = -45, top = 30 }, size = { 80 }, text = $"OK", isDefault = true,
5240 id = DialogResult::ok, NotifyClicked = ButtonCloseDialog
5244 dialog, anchor = { left = 5, right = 5, top = 5 }
5246 sprintf(methodName, "%s_%s", selected.name, method.name);
5247 nameBox.contents = methodName;
5249 result = dialog.Modal() == ok;
5250 strcpy(methodName, nameBox.contents);
5255 // If the method is not attached, move it outside
5258 // Add this class to the methodName
5259 char name[1024] = "";
5261 if(this.selected != this.oClass && !method.dataType.thisClass)
5263 strcat(name, this.selected.instance._class.name);
5265 strcat(name, this.methodName);
5266 strcpy(this.methodName, name);
5268 else if(method.dataType.thisClass && (this.selected == this.oClass || !eClass_IsDerived(this.oClass.instance._class, method.dataType.thisClass.registered)))
5270 strcat(name, method.dataType.thisClass.string);
5272 strcat(name, this.methodName);
5273 strcpy(this.methodName, name);
5276 this.moveAttached = true;
5279 this.methodAction = actionDetachMethod;
5280 this.method = method;
5281 this.function = function;
5288 void AddObject(Instance instance, ObjectInfo * object)
5292 //*object = _class.instances.Add(sizeof(ObjectInfo));
5293 *object = ObjectInfo { };
5294 oClass.instances.Insert((selected.oClass == selected) ? null : selected, *object);
5295 (*object).oClass = oClass;
5296 (*object).instance = instance;
5301 sprintf(name, "%c%s%d", tolower(instance._class.name[0]), instance._class.name+1, id);
5303 // if(strcmp(name, this.oClass.instance.name))
5306 for(check = oClass.instances.first; check; check = check.next)
5307 if(!check.deleted && check.name && !strcmp(name, check.name))
5311 (*object).name = CopyString(name);
5316 toolBox.controlClass = null;
5320 //sheet.AddObject(*object, (*object).name, TypeData, true);
5325 void EnsureUpToDate()
5327 if(sheet && codeModified)
5331 void SelectObject(ObjectInfo object)
5334 oClass = object ? object.oClass : null;
5336 designer.SelectObject(object, object ? object.instance : null);
5339 void SelectObjectFromDesigner(ObjectInfo object)
5342 sheet.SelectObject(object);
5345 void EnumerateObjects(Sheet sheet)
5349 for(oClass = classes.first; oClass; oClass = oClass.next)
5355 sheet.AddObject(oClass, oClass.name ? oClass.name : oClass.instance._class.name, typeClass, false);
5356 for(object = oClass.instances.first; object; object = object.next)
5357 sheet.AddObject(object, object.name ? object.name : object.instance._class.name, typeData, false);
5360 sheet.SelectObject(selected);
5365 designer.AddObject();
5368 void DeleteObject(ObjectInfo object)
5370 delete object.instance;
5371 object.deleted = true;
5372 object.modified = true;
5373 object.oClass.modified = true;
5375 if(selected == object)
5377 bool looped = false;
5378 ObjectInfo select = object;
5382 select = select.prev;
5386 select = object.oClass.instances.last;
5393 sheet.SelectObject(select ? select : oClass);
5396 if(!object.instCode && object.oClass != object)
5399 oClass.instances.Delete(object);
5402 if(sheet.codeEditor == this)
5403 sheet.DeleteObject(object);
5406 void RenameObject(ObjectInfo object, char * name)
5410 // Validate the name:
5411 if(object != oClass && (!name || !name[0])) valid = true; // What's this one again?
5412 else if(name[0] && (isalpha(name[0]) || name[0] == '_'))
5415 for(c = 0; name[c]; c++)
5416 if(!isalnum(name[c]) && name[c] != '_' && name[c] != '_')
5424 object.name = (name && name[0]) ? CopyString(name) : null;
5426 sheet.RenameObject(object, object.name ? object.name : object.instance._class.name);
5430 void DesignerModifiedObject()
5432 sheet.ListProperties(false);
5436 void ListSubMembers(Type member)
5440 for(subMember = member.members.first; subMember; subMember = subMember.next)
5444 DataRow row = membersList.AddString(subMember.name);
5445 row.icon = icons[typeData];
5449 ListSubMembers(subMember);
5454 void ListSubDataMembers(DataMember member, bool isPrivate)
5456 DataMember subMember;
5457 for(subMember = member.members.first; subMember; subMember = subMember.next)
5459 if((subMember.memberAccess == publicAccess && !isPrivate) || subMember._class.module == privateModule)
5463 DataRow row = membersList.AddString(subMember.name);
5464 BitmapResource bitmap = null;
5465 if(!subMember.dataType)
5466 subMember.dataType = ProcessTypeString(subMember.dataTypeString, false);
5468 if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
5470 char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
5473 bitmap = { bitmapName };
5474 membersList.AddResource(bitmap);
5477 row.icon = bitmap ? bitmap : icons[(subMember.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5481 ListSubDataMembers(subMember, isPrivate || member.memberAccess == privateAccess);
5487 void ListClassMembers(Class whatClass, bool methodsOnly)
5490 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5491 bool isPrivate = false;
5493 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5495 Method method, methodIt;
5497 DataMember memberIt;
5499 for(methodIt = (Method)_class.methods.first; methodIt; methodIt = (Method)((BTNode)methodIt).next)
5501 method = eClass_FindMethod(whatClass, methodIt.name, privateModule);
5502 if(methodIt.memberAccess == privateAccess && method && method.memberAccess == publicAccess)
5504 if(method && method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5506 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5508 DataRow row = membersList.FindString(method.name);
5511 row = membersList.AddString(method.name);
5513 if(!method.dataType)
5514 method.dataType = ProcessTypeString(method.dataTypeString, false);
5516 row.icon = icons[(method.type == virtualMethod && method.dataType && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5524 for(memberIt = _class.membersAndProperties.first; memberIt; memberIt = memberIt.next)
5528 if(memberIt.isProperty)
5530 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5532 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5536 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5538 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5541 if(memberIt.memberAccess == privateAccess && member && member.memberAccess == publicAccess)
5547 if(member && (member.memberAccess == publicAccess || member._class.module == privateModule))
5549 if(member.isProperty)
5551 Property prop = (Property) member;
5552 if(!membersList.FindString(prop.name))
5554 DataRow row = membersList.AddString(prop.name);
5555 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5558 else if(member.name && !membersList.FindString(member.name))
5560 DataRow row = membersList.AddString(member.name);
5562 BitmapResource bitmap = null;
5563 if(!member.dataType)
5564 member.dataType = ProcessTypeString(member.dataTypeString, false);
5566 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5568 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5571 bitmap = { bitmapName };
5572 membersList.AddResource(bitmap);
5575 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5578 ListSubDataMembers(member, member.memberAccess == privateAccess);
5582 if(_class.inheritanceAccess == privateAccess)
5585 if(_class.module != privateModule) break;
5590 void ListClassMembersMatch(Class whatClass, Type methodType)
5593 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5594 bool isPrivate = false;
5596 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5602 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5604 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5606 if(method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5608 if(!method.dataType)
5609 method.dataType = ProcessTypeString(method.dataTypeString, false);
5611 if(MatchTypes(method.dataType, methodType, null, whatClass, /*null, */whatClass, false, true, false, false))
5613 DataRow row = membersList.FindString(method.name);
5616 row = membersList.AddString(method.name);
5617 row.icon = icons[(method.type == virtualMethod && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5623 if(_class.inheritanceAccess == privateAccess)
5626 if(_class.module != privateModule) break;
5631 void ListClassPropertiesAndVirtual(Class whatClass)
5634 bool isPrivate = false;
5635 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5641 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5643 if(method.type == virtualMethod)
5645 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5647 DataRow row = membersList.FindString(method.name);
5650 row = membersList.AddString(method.name);
5652 if(!method.dataType)
5653 method.dataType = ProcessTypeString(method.dataTypeString, false);
5655 row.icon = icons[method.dataType.thisClass ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5661 for(member = _class.membersAndProperties.first; member; member = member.next)
5663 if(member.memberAccess == publicAccess || member._class.module == privateModule)
5665 if(member.isProperty)
5667 Property prop = (Property)member;
5669 DataRow row = membersList.AddString(prop.name);
5670 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5673 else if(member.name)
5675 DataRow row = membersList.AddString(member.name);
5677 BitmapResource bitmap = null;
5678 if(!member.dataType)
5679 member.dataType = ProcessTypeString(member.dataTypeString, false);
5681 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5683 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5686 bitmap = { bitmapName };
5687 membersList.AddResource(bitmap);
5690 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5693 ListSubDataMembers(member, member.memberAccess == privateAccess || isPrivate);
5696 if(_class.inheritanceAccess == privateAccess)
5699 if(_class.module != privateModule) break;
5704 void ListMembers(Type type)
5706 if(type && (type.kind == classType || type.kind == structType || type.kind == unionType))
5710 if(type.kind == classType)
5713 ListClassMembers(type._class.registered, false);
5718 for(member = type.members.first; member; member = member.next)
5722 DataRow row = membersList.AddString(member.name);
5723 row.icon = icons[typeData];
5725 else if(member.kind == structType || member.kind == unionType)
5726 ListSubMembers(member);
5732 void ListModule(Module mainModule, int recurse, bool listClasses)
5735 ListNameSpace(mainModule.application.systemNameSpace, 1, listClasses);
5736 ListNameSpace(mainModule.application.privateNameSpace, 1, listClasses);
5737 ListNameSpace(mainModule.application.publicNameSpace, 1, listClasses);
5738 for(module = mainModule.application.allModules.first; module; module = module.next)
5740 if(ModuleVisibility(mainModule, module))
5741 ListNameSpace(module.publicNameSpace, recurse, listClasses);
5745 void ListNameSpace(NameSpace nameSpace, int recurse, bool listClasses)
5752 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5754 Class _class = link.data;
5755 if(_class.type != systemClass)
5757 DataRow row = membersList.AddString(_class.name);
5758 row.icon = (_class.type == unitClass || _class.type == enumClass) ? icons[typeDataType] : icons[typeClass];
5763 for(link = (BTNamedLink)nameSpace.defines.first; link; link = (BTNamedLink)((BTNode)link).next )
5765 DefinedExpression definedExp = link.data;
5766 DataRow row = membersList.AddString(link /*definedExp*/.name);
5767 row.icon = icons[typeData];
5770 for(link = (BTNamedLink)nameSpace.functions.first; link; link = (BTNamedLink)((BTNode)link).next)
5772 GlobalFunction function = link.data;
5773 DataRow row = membersList.AddString(link /*function*/.name);
5774 row.icon = icons[typeMethod];
5778 for(ns = (NameSpace *)nameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
5780 if(recurse != 2 && listClasses)
5782 if(!membersList.FindString(ns->name))
5784 DataRow row = membersList.AddString(ns->name);
5785 row.icon = icons[typeNameSpace];
5790 ListNameSpace(ns, 2, listClasses);
5794 void ListEnumValues(Class _class)
5796 List<Class> classes { };
5797 for(; _class && _class.type == enumClass; _class = _class.base)
5798 classes.Insert(null, _class);
5799 for(_class : classes)
5801 EnumClassData enumeration = (EnumClassData)_class.data;
5803 for(item = enumeration.values.first; item; item = item.next)
5805 DataRow row = membersList.AddString(item.name);
5806 row.icon = icons[typeEnumValue];
5812 bool ListEnumsModule(Module mainModule, Type dest)
5814 bool result = false;
5816 result |= ListEnums(mainModule.application.systemNameSpace, dest);
5817 result |= ListEnums(mainModule.application.privateNameSpace, dest);
5818 result |= ListEnums(mainModule.application.publicNameSpace, dest);
5819 for(module = mainModule.application.allModules.first; module; module = module.next)
5821 if(ModuleVisibility(mainModule, module))
5822 result |= ListEnums(module.publicNameSpace, dest);
5827 void ListNameSpaceByString(Module mainModule, char * string)
5829 NameSpace * nameSpace;
5831 nameSpace = FindNameSpace(mainModule.application.systemNameSpace, string);
5832 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5833 nameSpace = FindNameSpace(mainModule.application.privateNameSpace, string);
5834 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5835 nameSpace = FindNameSpace(mainModule.application.publicNameSpace, string);
5836 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5837 for(module = mainModule.application.allModules.first; module; module = module.next)
5839 if(ModuleVisibility(mainModule, module))
5841 nameSpace = FindNameSpace(module.publicNameSpace, string);
5842 if(nameSpace) ListNameSpace(nameSpace, 0, true);
5847 bool ListEnums(NameSpace nameSpace, Type dest)
5850 bool result = false;
5852 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5854 Class _class = link.data;
5855 if(_class.type == enumClass && (dest.kind != classType || !dest._class || dest._class.registered != _class))
5857 OldList conversions { };
5859 type.kind = classType;
5860 type._class = FindClass(_class.name);
5861 if(MatchTypes(type, dest, &conversions, null, null, true, false, false, false))
5863 ListEnumValues(_class);
5866 conversions.Free(null);
5870 for(nameSpace = (NameSpace *)nameSpace.nameSpaces.first; nameSpace != null; nameSpace = (NameSpace *)((BTNode)nameSpace).next)
5872 result |= ListEnums(nameSpace, dest);
5877 NameSpace * FindNameSpace(NameSpace nameSpace, char * name)
5881 for(c = 0; (ch = name[c]); c++)
5883 if(ch == '.' || (ch == ':' && name[c+1] == ':'))
5885 NameSpace * newSpace;
5886 char * spaceName = new char[c - start + 1];
5887 memcpy(spaceName, name + start, c - start);
5888 spaceName[c-start] = '\0';
5889 newSpace = (NameSpace *)nameSpace.nameSpaces.FindString(spaceName);
5893 nameSpace = newSpace;
5902 return (NameSpace *)nameSpace;
5905 void ListSymbols(Expression exp, bool enumOnly, char * string, Identifier realIdentifier)
5907 bool listedEnums = false;
5908 Type destType = (exp && exp.destType && !exp.destType.truth) ? exp.destType : null;
5909 bool listClasses = true;
5911 if(exp && (exp.type == identifierExp || exp.type == memberExp))
5913 // TOCHECK: This memberExp check wasn't here... Some stuff isn't quite done
5914 Identifier id = (exp.type == memberExp) ? exp.member.member : exp.identifier;
5915 char * colons = id ? RSearchString(id.string, "::", strlen(id.string), true, false) : null;
5917 if(exp.type == identifierExp)
5918 id = realIdentifier;
5920 if(id && id._class && !id._class.name)
5922 listClasses = false;
5925 else if(id && id._class && id._class.name)
5929 Class _class = id.classSym.registered;
5930 if(_class && _class.type == enumClass)
5932 ListEnumValues(_class);
5935 ListClassMembers(id.classSym.registered, true);
5940 else if(id && colons)
5942 ListNameSpaceByString(this.privateModule, id.string);
5947 if(this.privateModule && destType && (destType.kind != pointerType || destType.type.kind != voidType) && destType.kind != ellipsisType)
5949 listedEnums = ListEnumsModule(this.privateModule, destType);
5952 if(destType && destType.kind == classType && destType._class.registered && destType._class.registered.type == enumClass)
5954 ListEnumValues(destType._class.registered);
5957 ListClassPropertiesAndVirtual(insideClass);
5961 else if(destType && destType.kind == enumType)
5965 for(value = destType.members.first; value; value = value.next)
5967 DataRow row = membersList.AddString(value.name);
5968 row.icon = icons[typeEnumValue];
5972 ListClassPropertiesAndVirtual(insideClass);
5976 else if(insideClass && !enumOnly)
5978 ListClassPropertiesAndVirtual(insideClass);
5981 if(listedEnums && string && string[0])
5983 DataRow row = membersList.FindSubString(string);
5985 listedEnums = false;
5988 if(!insideClass && exp && exp.destType && exp.destType.kind == functionType && GetThisClass())
5990 ListClassMembersMatch(GetThisClass(), exp.destType);
5992 else if(!insideClass && !enumOnly && !listedEnums)
5995 Symbol symbol = null;
5999 ListClassMembers(GetThisClass(), false);
6002 for(ctx = listClasses ? GetCurrentContext() : GetTopContext(); ctx != GetTopContext().parent && !symbol; ctx = ctx.parent)
6004 for(symbol = (Symbol)ctx.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6006 // Don't list enum values?
6007 //if(symbol.type.kind != TypeEnum)
6008 DataRow row = membersList.FindString(symbol.string);
6011 if(GetBuildingEcereComModule() && symbol.type && symbol.type.kind == functionType && eSystem_FindFunction(privateModule, symbol.string))
6013 row = membersList.AddString(symbol.string);
6014 if(symbol.type && symbol.type.kind == functionType)
6015 row.icon = icons[typeMethod];
6016 else if(symbol.type && symbol.type.kind == enumType)
6018 row.icon = icons[typeEnumValue];
6022 BitmapResource bitmap = null;
6023 if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
6025 char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
6028 bitmap = { bitmapName };
6029 membersList.AddResource(bitmap);
6032 row.icon = bitmap ? bitmap : icons[typeData];
6039 for(symbol = (Symbol)ctx.types.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6041 DataRow row = membersList.FindString(symbol.string);
6044 row = membersList.AddString(symbol.string);
6045 if(symbol.type.kind == functionType)
6046 row.icon = icons[typeMethod];
6047 else if(symbol.type.kind == classType && (!symbol.type._class.registered || (symbol.type._class.registered.type != unitClass && symbol.type._class.registered.type != enumClass)))
6049 row.icon = icons[typeClass];
6053 row.icon = icons[typeDataType];
6060 ListModule(this.privateModule, 1, listClasses);
6061 // TODO: Implement this with name space
6065 for(data = globalData.first; data; data = data.next)
6067 DataRow row = membersList.FindString(data.name);
6069 data.dataType = ProcessTypeString(data.dataTypeString, false);
6072 row = membersList.AddString(data.name);
6074 if(data.dataType && data.dataType.kind == TypeEnum)
6076 row.icon = icons[typeEnumValue];
6080 BitmapResource bitmap = null;
6081 if(data.dataType && data.dataType.kind == classType && data.dataType._class && data.dataType._class)
6083 char * bitmapName = (char *)eClass_GetProperty(data.dataType._class.registered, "icon");
6086 bitmap = { bitmapName };
6087 membersList.AddResource(bitmap);
6090 row.icon = bitmap ? bitmap : icons[typeData];
6098 DataRow row = membersList.AddString("Min");
6099 row.icon = icons[typeMethod];
6101 row = membersList.AddString("Max");
6102 row.icon = icons[typeMethod];
6104 row = membersList.AddString("Abs");
6105 row.icon = icons[typeMethod];
6107 row = membersList.AddString("Sgn");
6108 row.icon = icons[typeMethod];
6114 void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
6116 EditBoxStream f { editBox = editBox };
6121 updatingCode = true;
6123 if(!method.dataType)
6124 method.dataType = ProcessTypeString(method.dataTypeString, false);
6126 DeleteJunkBefore(f, function.loc.start.pos, &position);
6127 f.DeleteBytes(function.loc.end.pos - function.loc.start.pos - 1);
6129 // ADDING METHOD HERE
6131 Type dataType = method.dataType;
6132 Type returnType = dataType.returnType;
6134 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
6140 if(extraIndent) f.Printf(" ");
6142 OutputType(f, returnType, false);
6146 if(dataType.thisClass && !dataType.classObjectType && (!isInstance || !insideClass || !eClass_IsDerived(insideClass, dataType.thisClass.registered)))
6148 if(dataType.thisClass.shortName)
6149 f.Printf(dataType.thisClass.shortName);
6151 f.Printf(dataType.thisClass.string);
6154 f.Printf(method.name);
6156 for(param = dataType.params.first; param; param = param.next)
6158 // Decided not to write void...
6159 if(param.kind != voidType)
6161 OutputType(f, param, true);
6167 if(extraIndent) f.Printf(" ");
6168 f.Printf(" %c\n", OpenBracket);
6170 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6176 (isInstance ? _class : _class.base)._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad] ||
6177 (isInstance ? _class : _class.base)._vTbl[method.vid] == DummyMethod)) // Temp Check for DefaultFunction
6179 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
6181 if(extraIndent) f.Printf(" ");
6182 f.Printf(" return true;\n");
6184 else if(returnType && returnType.kind != voidType)
6186 if(extraIndent) f.Printf(" ");
6187 f.Printf(" return 0;\n");
6192 if(extraIndent) f.Printf(" ");
6194 if(returnType.kind != voidType)
6195 f.Printf("return ");
6196 f.Printf("%s::%s(", isInstance ? _class.name : _class.base.name, method.name);
6197 for(param = dataType.params.first; param; param = param.next)
6199 if(param.prev) f.Printf(", ");
6200 if(param.kind != voidType)
6201 f.Printf(param.name);
6207 if(extraIndent) f.Printf(" ");
6208 f.Printf(" %c", CloseBracket);
6213 if(extraIndent) { x1 += 3; x2 += 3; }
6214 editBox.SetSelPos(l1, y1, x1 + 6, l2, y2, x2 + 6);
6216 this.updatingCode = false;
6220 // Return false if we overrided a function and don't want to run params listing
6221 bool InvokeAutoComplete(bool enumOnly, int pointer, bool caretMove)
6223 bool didOverride = false;
6224 EditLine line = editBox.line;
6225 char * text = line.text;
6226 int lineNum, charPos;
6227 Expression exp = null;
6230 //Identifier id = null;
6231 Expression memberExp = null;
6232 Identifier realIdentifier = null;
6234 if(!privateModule) return !didOverride;
6236 insideFunction = null;
6238 charPos = editBox.charPos + 1;
6239 if(!membersListShown)
6244 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6246 EditBoxStream f { editBox = editBox };
6248 updatingCode = true;
6249 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6253 if(!f.Seek(-1, current))
6256 if(!isspace(ch)) break;
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 if(!membersListShown)
6269 memberExp = FindExpTree(ast, lineNum, charPos);
6270 if(memberExp && (memberExp.type == TypeKind::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6275 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6277 EditBoxStream f { editBox = editBox };
6280 updatingCode = true;
6282 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6285 if(ch == '}' || ch == ',' || ch == ')')
6287 f.Seek(-1, current);
6295 if(!f.Seek(-1, current))
6298 if(!isspace(ch)) break;
6299 f.Seek(-1, current);
6303 f.Seek(-1, current);
6305 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6307 lineNum = editBox.lineNumber + 1;
6308 charPos = editBox.charPos + 1;
6310 updatingCode = false;
6313 realIdentifier = FindCtxTree(ast, lineNum, charPos);
6318 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6319 lineNum = editBox.lineNumber + 1;
6320 charPos = editBox.charPos/* + 1*/;
6324 char tempString[1024];
6325 char * string = null;
6326 CodePosition idStart, idEnd;
6328 if(membersListShown)
6330 char * buffer = membersLine.text;
6332 bool firstChar = true;
6334 string = tempString;
6336 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
6338 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6339 if(!isSpace) firstChar = false;
6341 string[len++] = buffer[c];
6345 else //if(realIdentifier)//if(id)
6348 char * buffer = id.string;
6350 bool firstChar = true;
6352 string = tempString;
6353 for(c = 0; c<= charPos - id.loc.start.charPos; c++)
6355 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6356 if(!isSpace) firstChar = false;
6358 string[len++] = buffer[c];
6364 EditLine editLine = editBox.line;
6365 bool firstChar = true;
6368 string = tempString;
6369 for(y = lineNum-1; y >= 0; y--)
6371 char * buffer = editLine.text;
6372 int lineCount = editLine.count;
6373 for(x = (y == lineNum-1) ? (Min(charPos, lineCount) - 1 ): lineCount-1; x >= 0; x--)
6375 bool isSpace = (buffer[x] == ' ' || buffer[x] == '\t');
6380 idEnd.charPos = x + 2;
6385 // TESTING THIS CODE HERE FOR NOT CONSIDERING bool when doing ctrl-space past it
6388 idEnd.charPos = x + 2;
6395 if(!isalnum(buffer[x]) && buffer[x] != '_')
6401 memmove(string+1, string, len++);
6402 string[0] = buffer[x];
6406 //if(done || firstChar)
6407 if(done || !firstChar)
6409 editLine = editLine.prev;
6412 if(!strcmp(string, "case"))
6418 else if(!strcmp(string, "return"))
6424 else if(!strcmp(string, "delete"))
6430 else if(!strcmp(string, "new"))
6436 else if(!strcmp(string, "renew"))
6444 idStart.charPos = x + 1;
6445 idStart.line = y + 1;
6448 if(!membersListShown)
6450 membersList.Clear();
6451 if(memberExp && (memberExp.type == ExpressionType::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6453 Type type = memberExp.member.exp.expType;
6454 if(pointer == 2 && type)
6456 if(type.kind == pointerType || type.kind == arrayType)
6465 ListSymbols(exp, enumOnly, string, realIdentifier);
6467 membersList.Sort(null, 1);
6472 // Virtual function override
6473 Identifier id = GetDeclId(insideFunction.declarator);
6474 char * string = id ? id.string : null;
6476 Method method = eClass_FindMethod(GetThisClass(), string, this.privateModule);
6479 if(method.type != virtualMethod || (!insideInstance && method._class == GetThisClass()))
6480 insideFunction = null;
6483 OverrideVirtualFunction(insideFunction, method, GetThisClass(), insideInstance, insideInstance && insideClass);
6488 if(!didOverride) //insideFunction)
6490 rowCount = membersList.rowCount;
6493 DataRow row = string ? membersList.FindSubString(string) : null;
6494 if(row && !membersList.FindSubStringAfter(row, string) && !caretMove)
6496 char * newString = row.string;
6497 if(!membersListShown)
6499 membersLoc.start.line = idStart.line-1;
6500 membersLoc.start.charPos = idStart.charPos-1;
6501 //membersLoc.end = membersLoc.start;
6502 membersLoc.end.charPos = idEnd.charPos-1;
6503 membersLoc.end.line = idEnd.line-1;
6504 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6505 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6510 membersList.Destroy(0);
6511 membersListShown = false;
6514 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
6516 line, membersLoc.start.line, membersLoc.start.charPos,
6517 line, membersLoc.end.line, membersLoc.end.charPos);
6518 editBox.PutS(newString);
6524 row = membersList.FindSubStringi(string);
6526 membersList.currentRow = row;
6527 membersList.currentRow.selected = false;
6530 membersList.currentRow = row;
6532 if(!membersListShown)
6536 // TESTING THESE ADDITIONS TO THE IF SO THAT CARET ISNT MOVED IF NOT ON TOP OF A WORD
6537 if(string && string[0] && lineNum == idStart.line && charPos >= idStart.charPos-1 && charPos <= idEnd.charPos-1)
6538 editBox.SetSelPos(l1, y1, idStart.charPos-1, l2, y2, idStart.charPos-1);
6539 editBox.GetCaretPosition(caret);
6540 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6542 membersList.master = this;
6544 caret.y += editBox.GetCaretSize();
6546 membersList.Create();
6549 int x = caret.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6550 int y = caret.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6551 Window parent = membersList.parent;
6553 if(!paramsAbove && (paramsShown || y + membersList.size.h > parent.clientSize.h))
6555 y -= editBox.GetCaretSize() + membersList.size.h;
6556 membersAbove = true;
6559 membersAbove = false;
6561 membersList.position = { x, y };
6565 membersLoc.start.line = lineNum - 1;
6567 if(string && string[0])
6569 membersLoc.start.charPos = idStart.charPos-1;
6570 membersLoc.end = membersLoc.start;
6571 //membersLoc.end.charPos = id.loc.end.charPos-1;
6572 membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6576 membersLoc.start.charPos = charPos;
6577 membersLoc.end = membersLoc.start;
6578 membersLoc.end.charPos = charPos;
6580 membersListShown = true;
6582 // Hack to keep caret shown
6583 editBox.GetCaretPosition(caret);
6584 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6587 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
6593 SetCurrentContext(globalContext);
6596 return !didOverride;
6599 void InvokeParameters(bool exact, bool reposition, bool caretMove)
6601 EditLine line = editBox.line;
6602 char * text = line.text;
6603 int lineNum, charPos;
6604 Expression exp = null;
6608 charPos = editBox.charPos + 1;
6611 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6613 EditBoxStream f { editBox = editBox };
6616 updatingCode = true;
6617 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6620 if(ch == '}' || ch == ',' || ch == ')')
6622 f.Seek(-1, current);
6630 if(!f.Seek(-1, current))
6633 if(!isspace(ch)) break;
6634 f.Seek(-1, current);
6638 f.Seek(-1, current);
6640 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6642 lineNum = editBox.lineNumber + 1;
6643 charPos = editBox.charPos + 1;
6645 updatingCode = false;
6648 charPos = Min(charPos, l1.count + 1);
6650 FindParamsTree(ast, lineNum, charPos);
6652 // Not sure about this == ExpCall... paramsInsideExp doesn't seem to necessarily be a ExpCall
6653 if(exact && ((::functionType && paramsInsideExp.type == callExp && paramsInsideExp.call.exp.loc.end.charPos != charPos-1) /*|| instanceType*/))
6655 ::functionType = null;
6656 ::instanceType = null;
6659 //if((::functionType || ::instanceType) && (!paramsShown || insideExp != functionExp || ::paramsID != this.paramsID))
6660 if((::functionType || ::instanceType) && (!paramsShown || true /*paramsInsideExp.destType != functionExp.destType */|| ::paramsID != this.paramsID))
6664 Window parent = paramsList.parent;
6666 if(this.functionType != ::functionType || this.instanceType != ::instanceType)
6669 if(!this.paramsShown || reposition || paramsInsideExp != functionExp || ::instanceType) // Added instanceType here, otherwise instance popups never reposition...
6670 // ( Dummy exp: always ends up with same memory)
6672 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6673 editBox.GetCaretPosition(paramsPosition);
6674 this.paramsPosition.y += editBox.GetCaretSize();
6677 FreeType(this.functionType);
6678 FreeType(this.instanceType);
6680 this.functionType = ::functionType;
6681 this.instanceType = ::instanceType;
6683 if(this.functionType) this.functionType.refCount++;
6684 if(this.instanceType) this.instanceType.refCount++;
6686 this.paramsID = ::paramsID;
6687 functionExp = paramsInsideExp;
6689 paramsList.master = this;
6691 paramsList.Create();
6693 x = paramsPosition.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6694 y = paramsPosition.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6696 if(!this.membersAbove && ( this.membersListShown || y + paramsList.size.h > parent.clientSize.h) )
6698 y -= editBox.GetCaretSize() + paramsList.clientSize.h;
6702 paramsAbove = false;
6703 if(x + paramsList.size.w > parent.clientSize.w)
6705 x = parent.clientSize.w - paramsList.size.w;
6709 paramsList.position = { x, y };
6711 // Hack to keep caret shown
6714 editBox.GetCaretPosition(caret);
6715 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6718 this.paramsShown = true;
6720 else if((!::functionType && !::instanceType) || reposition)
6722 paramsList.Destroy(0);
6723 paramsShown = false;
6725 FreeType(this.functionType);
6726 FreeType(this.instanceType);
6727 this.functionType = null;
6728 this.instanceType = null;
6732 SetCurrentContext(globalContext);
6740 designer.visible = true;
6741 designer.Activate();
6747 CodeEditor NewCodeEditor(Window parent, WindowState state, bool modified)
6749 CodeEditor document { state = state, parent = parent, modifiedDocument = modified };