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 const 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;
123 bool ignoreBreakpoints:1;
125 bool oldImplementation:1;
128 class EditFileDialog : FileDialog
132 if(!ide.projectView && ideSettings.ideFileDialogLocation)
133 currentDirectory = ideSettings.ideFileDialogLocation;
134 return FileDialog::OnCreate();
138 EditFileDialog codeEditorFileDialog
140 type = multiOpen, text = $"Open",
141 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType);
142 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
145 EditFileDialog codeEditorFormFileDialog
147 type = open, text = $"Open Project",
148 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType),
149 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
152 define OpenBracket = '{';
153 define CloseBracket = '}';
158 actionDeleteMethod = 2,
159 actionDetachMethod = 3,
160 actionAttachMethod = 4,
161 actionReattachMethod = 5
164 //extern StatusField pos, ovr, caps, num;
165 //extern Class thisClass;
174 Expression ctxInsideExp;
175 Expression paramsInsideExp;
176 ClassFunction insideFunction;
179 const char * instanceName;
184 /****************************************************************************
186 ****************************************************************************/
188 static void OutputString(File f, const char * string)
191 for(c = 0; string[c]; c++)
193 if(string[c] == '\"')
195 else if(string[c] == '\\')
197 else if(string[c] == '\n')
208 // Consider merging with PrintType ?
209 void OutputType(File f, Type type, bool outputName)
213 if(type.kind != pointerType && type.constant)
221 if(!type.isSigned) f.Printf("unsigned ");
225 if(!type.isSigned) f.Printf("unsigned ");
229 if(!type.isSigned) f.Printf("unsigned ");
233 if(!type.isSigned) f.Printf("unsigned ");
237 if(!type.isSigned) f.Printf("unsigned ");
248 if(type._class && !strcmp(type._class.string, "class"))
250 switch(type.classObjectType)
253 f.Printf("any_object");
256 f.Printf("typed_object");
263 // ADD CODE TO DECIDE WHETHER TO OUTPUT FULLY QUAlIFIED OR NOT:
264 f.Printf(type._class.shortName ? type._class.shortName : type._class.string);
274 OutputType(f, type.type, false);
277 OutputType(f, type.type, false);
298 if(type.kind == arrayType)
301 f.Printf("%d", type.arraySize);
307 void DeleteJunkBefore(EditBoxStream f, int pos, int * position)
313 f.Seek(pos - *position, current);
315 // Try to delete spaces and \n before...
321 /*else if(ch == '\n')
323 // Look for // comments on the line before
324 EditBox editBox = f.editBox;
325 EditLine line = editBox.line;
332 for(c = 0; text[c]; c++)
341 if(text[c] == '/' && last == '/')
353 f.DeleteBytes(before);
358 void GetLocText(EditBox editBox, File f, int position, Location loc, char ** text, int * size, int pad, int linePad)
363 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
365 // Cut & Paste function
371 f.Seek(loc.start.pos - position, current);
373 x1 = editBox.charPos;
374 y1 = editBox.lineNumber;
375 f.Seek(loc.end.pos - loc.start.pos, current);
377 x2 = editBox.charPos;
378 y2 = editBox.lineNumber;
379 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
381 *size = editBox.SelSize();
382 *text = new char[*size+1 + (y2-y1+1) * linePad + pad]; // Add pad for tabs and new name
383 editBox.GetSel(*text, false);
386 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
387 f.Printf(""); // Make the stream point to where the editbox is
390 void Code_FixProperty(Property prop, Instance object)
392 Designer::FixProperty(prop, object);
395 bool Code_IsPropertyModified(Instance test, ObjectInfo selected, Property prop)
398 if(prop.dataTypeString && (!prop.IsSet || prop.IsSet(selected.instance)))
400 Class dataType = prop.dataTypeClass;
403 dataType = prop.dataTypeClass = eSystem_FindClass(test._class.module, prop.dataTypeString);
405 if(dataType && dataType._vTbl && dataType.type == structClass)
407 void * dataForm = new0 byte[dataType.structSize];
408 void * dataTest = new0 byte[dataType.structSize];
410 ((void (*)(void *, void *))(void *)prop.Get)(selected.instance, dataForm);
411 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
413 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
415 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
421 else if(dataType && dataType._vTbl && (dataType.type == normalClass || dataType.type == noHeadClass))
423 void * dataForm, * dataTest;
424 bool isEditBoxContents = false;
425 bool freeDataForm = false, freeDataTest = false;
427 // Because contents property is broken for mutiline EditBox at the moment
428 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
429 isEditBoxContents = true;
431 if(isEditBoxContents && ((EditBox)selected.instance).multiLine)
433 dataForm = ((EditBox)selected.instance).multiLineContents;
437 dataForm = ((void *(*)(void *))(void *)prop.Get)(selected.instance);
438 if(isEditBoxContents && ((EditBox)test).multiLine)
440 dataTest = ((EditBox)test).multiLineContents;
444 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
446 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
448 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
452 // Temporary work around until we standardize how properties should manage memory
453 if(!strcmp(prop.name, "strings") && !strcmp(prop._class.name, "DirectoriesBox"))
454 freeDataForm = freeDataTest = true;
455 if(dataType.type == normalClass && dataType.structSize)
457 if(freeDataForm) eInstance_Delete(dataForm);
458 if(freeDataTest) eInstance_Delete(dataTest);
462 if(freeDataForm) delete dataForm;
463 if(freeDataTest) delete dataTest;
466 else if(dataType && dataType._vTbl)
468 DataValue dataForm, dataTest;
470 GetProperty(prop, selected.instance, &dataForm);
471 GetProperty(prop, test, &dataTest);
473 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
475 SetProperty(prop, test, dataForm);
477 // In case setting on test unset on real instance (e.g. isDefault)
478 if(strcmp(prop.name, "name"))
480 GetProperty(prop, selected.instance, &dataTest);
481 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
482 SetProperty(prop, selected.instance, dataForm);
491 bool Code_IsPropertyDisabled(ObjectInfo selected, const char * name)
493 bool disabled = false;
494 if(selected.oClass == selected)
497 if(selected.classDefinition)
499 for(def = selected.classDefinition.definitions->first; def; def = def.next)
501 if(def.type == defaultPropertiesClassDef)
504 for(prop = def.defProperties->first; prop; prop = prop.next)
506 if(prop.identifiers && prop.identifiers->first)
508 Identifier id = prop.identifiers->first;
509 if(prop.variable && !strcmp(id.string, name))
521 else if(selected.instCode)
524 if(selected.instCode.members)
526 for(members = selected.instCode.members->first; members; members = members.next)
528 if(members.type == dataMembersInit && members.dataMembers)
531 for(prop = members.dataMembers->first; prop; prop = prop.next)
533 if(prop.identifiers && prop.identifiers->first)
535 Identifier id = prop.identifiers->first;
536 if(prop.variable && !strcmp(id.string, name))
551 static bool CheckCompatibleMethod(Method method, Type type, Class regClass, bool isForm, Symbol selectedClass)
556 method.dataType = ProcessTypeString(method.dataTypeString, false);
557 if(!method.dataType.thisClass && !isForm)
560 method.dataType.thisClass = selectedClass;
562 //result = MatchTypes(method.dataType, type, null, regClass, regClass, false);
563 result = MatchTypes(type, method.dataType, null, regClass, regClass, false, true, true, false, true);
565 method.dataType.thisClass = null;
569 bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo object)
571 bool confirmation = true;
572 Statement body = function.body;
573 // Check if it contains any code
574 if((!body.compound.declarations || !body.compound.declarations->count) && (!body.compound.statements || body.compound.statements->count <= 1))
576 Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
577 Statement stmt = body.compound.statements ? body.compound.statements->first : null;
578 Type dataType = method.dataType;
579 Type returnType = dataType.returnType;
580 Expression exp = null;
583 method.dataType = ProcessTypeString(method.dataTypeString, false);
585 confirmation = false;
587 // Check if default function should be calling base class:
588 if(object.instance._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
590 if(returnType.kind != voidType)
592 if(!stmt || stmt.type != returnStmt || !stmt.expressions || stmt.expressions->count != 1)
596 exp = stmt.expressions->first;
597 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
599 if( (exp.type != identifierExp || strcmp(exp.identifier.string, "true")) &&
600 (exp.type != constantExp || strcmp(exp.constant, "1")))
605 if(exp.type != constantExp || strcmp(exp.constant, "0"))
620 if(returnType.kind != voidType)
622 if(stmt.type == returnStmt && stmt.expressions && stmt.expressions->count == 1)
623 exp = stmt.expressions->first;
625 else if(stmt.type == expressionStmt && stmt.expressions && stmt.expressions->count == 1)
626 exp = stmt.expressions->first;
629 if(!exp || exp.type != callExp || exp.call.exp.type != identifierExp)
633 Identifier id = exp.call.exp.identifier;
634 Class base = object.instance._class;
635 if(!id._class || (id._class.name && !strcmp(id._class.name, base.name)) || strcmp(id.string, method.name))
639 Expression arg = exp.call.arguments ? exp.call.arguments->first : null;
640 if(!arg || arg.type != identifierExp || strcmp("this", arg.identifier.string))
646 for(param = dataType.params.first; param; param = param.next)
648 if(!arg || arg.type != identifierExp || strcmp(param.name, arg.identifier.string))
653 arg = arg ?arg.next : null;
660 return !confirmation;
663 class CodeEditor : Window
665 background = marginColor;
666 borderStyle = sizableDeep;
671 isActiveClient = true;
672 anchor = Anchor { left = 300, right = 150, top = 0, bottom = 0 };
675 // eWindow_SetX(A_CASCADE); eWindow_SetY(A_CASCADE);
676 // eWindow_SetWidth(A_RELATIVE|80); eWindow_SetHeight(A_RELATIVE|80);
678 SheetType sheetSelected;
683 Context globalContext { };
684 OldList excludedSymbols { offset = (uint)(uintptr)&((Symbol)0).left };
697 MethodAction methodAction;
699 ClassFunction function;
701 char methodName[1024];
706 bool membersListShown;
709 EditLine membersLine;
711 Type functionType, instanceType;
715 Point paramsPosition;
716 Expression functionExp;
719 BitmapResource icons[CodeObjectType];
721 FontResource boldFont { $"Tahoma", 8.25f, bold = true, window = this };
722 FontResource normalFont { $"Tahoma", 8.25f, window = this };
724 Module privateModule;
725 NameSpace globalData;
728 OpenedFileInfo openedFileInfo;
730 FontResource font { codeFont.faceName, codeFont.size };
731 saveDialog = codeEditorFileDialog;
733 Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
736 int maxLineNumberLength;
738 property bool parsing { get { return editBox.syntaxHighlighting && !noParsing && !ide.noParsing; } };
740 void ProcessCaretMove(EditBox editBox, int line, int charPos)
743 ObjectInfo classItem;
745 // OnActivateClient is called after OnActivate
748 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
751 if(sheet.codeEditor != this) return;
755 for(classItem = classes.first; classItem; classItem = classItem.next)
757 ClassDefinition classDef = classItem.classDefinition;
758 if(classDef && classDef.loc.Inside(line, charPos))
765 for(object = classItem.instances.first; object; object = object.next)
769 if(object.instCode.loc.Inside(line, charPos))
774 sheet.SelectObject(object);
776 sheet.SelectObject(classItem);
781 //sheet.SelectObject(null);
785 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
789 expectingMove = false;
795 if(line-1 != membersLoc.start.line)
801 if(charPos - 1 < membersLoc.start.charPos)
803 else if(charPos - 1 > membersLoc.end.charPos)
805 const char * buffer = membersLine.text;
806 //if(membersList.currentRow)
810 for(c = membersLoc.start.charPos; c<=charPos && buffer[c]; c++)
811 if(buffer[c] != ' ' && buffer[c] != '\t')
813 if(c < charPos && buffer[c])
820 membersList.Destroy(0);
821 membersListShown = false;
825 bool back = codeModified;
826 codeModified = false;
828 InvokeParameters(false, false, false);
829 /*if(membersListShown)
830 InvokeAutoComplete(false, 0, true);*/
837 watch(modifiedDocument)
839 ProjectView projectView = ide.projectView;
842 char buffer[MAX_LOCATION];
843 char * fullPath = GetSlashPathBuffer(buffer, fileName);
844 Array<ProjectNode> nodes = ide.workspace.GetAllProjectNodes(fullPath, false);
848 node.modified = modifiedDocument;
849 projectView.Update(null);
858 textVertScroll = true, multiLine = true, /*lineNumbers = ideSettings.showLineNumbers,*/
859 freeCaret = ideSettings.useFreeCaret, caretFollowsScrolling = ideSettings.caretFollowsScrolling,
860 tabKey = true, smartHome = true;
861 tabSelection = true, /*maxLineSize = 65536, */parent = this, hasHorzScroll = true, hasVertScroll = true;
862 selectionColor = selectionColor, selectionText = selectionText,
863 background = codeEditorBG, foreground = codeEditorFG, syntaxColorScheme = colorScheme,
864 font = font, borderStyle = none;
865 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
867 bool OnMouseOver(int x, int y, Modifiers mods)
869 CodeEditor editor = (CodeEditor)master;
870 if(editor.designer && editor.designer.isDragging && !mods.isSideEffect)
875 void NotifyCaretMove(EditBox editBox, int line, int charPos)
877 // Update Line Numbers
879 int oldLine = lastLine;
880 display.FontExtent(font.font, " ", 1, null, &spaceH);
882 Box box { 0, (Min(oldLine,oldLine)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(oldLine, oldLine))*spaceH-1 - editBox.scroll.y };
886 Box box { 0, (Min(line,line)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(line, line))*spaceH-1 - editBox.scroll.y };
891 if(ide.activeClient == this)
892 ProcessCaretMove(editBox, line, charPos);
894 openedFileInfo.CaretMove(line, charPos);
897 void NotifyOvrToggle(EditBox editBox, bool overwrite)
899 ide.UpdateStateLight(ide.ovr, overwrite);
902 void NotifyUpdate(EditBox editBox)
909 designer.modifiedDocument = true;
912 modifiedDocument = true;
915 bool NotifyUnsetModified(EditBox editBox)
917 modifiedDocument = false;
921 bool NotifyCharsAdded(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
923 if(!loadingFile && after.y != before.y)
925 ProjectView projectView = ide.projectView;
926 if(projectView && fileName)
929 // HOW WE MIGHT WANT TO DO IT:
930 const char * text = before.line.text;
931 for(c = Min(before.line.count, before.x-1); c>= 0; c--)
932 if(!isspace(text[c]))
934 ide.debugger.MoveIcons(fileName, before.y + (((!pasteOperation && c > -1) || !after.line.count) ? 1 : 0), after.y - before.y, false);
936 // HOW VISUAL STUDIO DOES IT:
938 char * text = after.line.text;
939 for(c = after.line.count-1; c>= 0; c--)
940 if(!isspace(text[c]))
942 ide.debugger.MoveIcons(fileName, before.y + ((c < 0) ? 1 : 0), after.y - before.y, false);
945 Update({ 0, 0, editBox.position.x, clientSize.h });
953 for(oClass = classes.first; oClass; oClass = oClass.next)
956 for(object = oClass.instances.first; object; object = object.next)
960 object.instCode.loc.start.AdjustAdd(before, after);
961 object.instCode.loc.end.AdjustAdd(before, after);
966 oClass.classDefinition.loc.start.AdjustAdd(before, after);
967 oClass.classDefinition.loc.end.AdjustAdd(before, after);
973 expectingMove = true;
977 if(before.y != after.y)
981 const char * buffer = membersLine.text;
983 bool firstChar = true;
984 bool addedChar = false;
990 membersLoc.end.charPos += after.x - Max(membersLoc.start.charPos, before.x);
992 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
994 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
995 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar)) //|| membersList.currentRow
1004 membersLoc.start.charPos++;
1009 string[len++] = buffer[c];
1013 row = membersList.currentRow;
1014 if(row && row.selected)
1018 membersLoc.start.charPos--;
1026 row = membersList.FindSubString(string);
1028 membersList.currentRow = row;
1031 row = membersList.FindSubStringi(string);
1033 membersList.currentRow = row;
1034 membersList.currentRow.selected = false;
1037 membersList.SetScrollPosition(0, (row.index) * membersList.rowHeight);
1041 row = membersList.currentRow;
1044 // Accept current string if hiding typing char
1045 if(hide && row && row.selected)
1047 const char * string = row.string;
1048 int len = strlen(string);
1049 membersLoc.end.charPos -= after.x - before.x;
1050 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1051 editBox.Delete(membersLine, membersLoc.start.line, membersLoc.start.charPos,
1052 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1053 editBox.PutS(string);
1054 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos + len + 1 /*after.x - before.x*/);
1056 after.x += membersLoc.start.charPos + len - before.x;
1057 before.x = membersLoc.start.charPos + len;
1062 membersList.Destroy(0);
1063 membersListShown = false;
1066 if(/*after.x - before.x == 1 && */after.y == before.y && !membersListShown)
1068 EditLine line = editBox.line;
1069 const char * text = line.text;
1070 char ch = text[after.x-1];
1071 if(ch == '.' || (ch == '>' && after.x-1 > 0 && text[after.x-1-1] == '-') || (ch == ':' && after.x-1 > 0 && text[after.x-1-1] == ':'))
1075 // Can we call invoke auto complete here instead?
1085 // Force caret update already...
1086 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1087 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1089 editBox.GetCaretPosition(&caret);
1093 // Go back in the buffer until no space before
1095 codeModified = true;
1099 EditBoxStream f { editBox = editBox };
1103 if(text[after.x-1] == '>')
1109 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1113 if(!f.Seek(-1, current))
1116 if(!isspace(ch)) break;
1117 f.Seek(-1, current);
1119 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1121 line = editBox.lineNumber + 1;
1122 charPos = editBox.charPos + 1;
1126 exp = FindExpTree(ast, line, charPos);
1130 Type type = exp.expType;
1132 if(type && text[after.x-1] != '.')
1134 if(type.kind == TypePointer || type.kind == TypeArray)
1140 membersList.Clear();
1143 if(membersList.rowCount)
1145 membersList.Sort(null, 1);
1146 membersList.master = this;
1148 caret.y += editBox.GetCaretSize();
1151 membersList.Create();
1154 int x = caret.x + editBox.GetAbsX() - app.desktop.GetAbsX() - editBox.GetScrollX();
1155 int y = caret.y + editBox.GetAbsY() - app.desktop.GetAbsY() - editBox.GetScrollY();
1156 Window parent = membersList.parent;
1158 if(!paramsAbove && (paramsShown || y + membersList.GetHeight() > parent.GetClientHeight()))
1160 y -= editBox.GetCaretSize() + membersList.GetHeight();
1161 membersAbove = true;
1164 membersAbove = false;
1166 membersList.position = { x, y };
1170 membersLoc.start.line = line - 1;
1171 membersLoc.start.charPos = oldCharPos;
1172 membersLoc.end = membersLoc.start;
1173 membersListShown = true;
1178 SetCurrentContext(globalContext);
1180 codeModified = true;
1181 skipModified = true;
1182 if(text[after.x-1] == ':')
1183 InvokeAutoComplete(false, 0, false);
1184 else if(text[after.x-1] == '.')
1185 InvokeAutoComplete(false, 1, false);
1186 else if(text[after.x-1] == '>')
1187 InvokeAutoComplete(false, 2, false);
1188 skipModified = false;
1190 else if(ch == '(' || ch == OpenBracket || ch == ',' || ch == '=' || ch == '?' || ch == ':')
1192 codeModified = true;
1193 skipModified = true;
1195 if(InvokeAutoComplete(true, 0, false))
1197 if(ch == '(' || ch == OpenBracket)
1198 InvokeParameters(true, true, false);
1200 InvokeParameters(this.functionType ? false : true, false, false);
1203 // InvokeAutoComplete(true, 0, false);
1204 skipModified = false;
1206 else if(ch == ')' || ch == '}' || ch == ';')
1208 codeModified = true;
1209 skipModified = true;
1211 InvokeParameters(false, true, false);
1212 skipModified = false;
1216 bool back = codeModified;
1217 codeModified = false;
1219 InvokeParameters(false, false, true);
1220 if(membersListShown)
1221 InvokeAutoComplete(false, 0, true);
1222 codeModified = back;
1227 bool back = codeModified;
1228 codeModified = false;
1231 InvokeParameters(false, false, true);
1232 /*if(membersListShown)
1233 InvokeAutoComplete(false, 0, true);*/
1235 codeModified = back;
1242 bool NotifyCharsDeleted(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
1244 if(!loadingFile && after.y != before.y)
1246 ProjectView projectView = ide.projectView;
1247 if(projectView && fileName)
1248 ide.debugger.MoveIcons(fileName, before.y + 1, before.y - after.y, before.x == 0);
1249 Update({ 0, 0, editBox.position.x, clientSize.h });
1257 for(oClass = classes.first; oClass; oClass = oClass.next)
1261 for(object = oClass.instances.first; object; object = object.next)
1265 loc = &object.instCode.loc;
1267 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1268 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1270 object.instCode = null;
1274 loc->start.AdjustDelete(before, after);
1275 loc->end.AdjustDelete(before, after);
1279 if(oClass.classDefinition)
1281 loc = &oClass.classDefinition.loc;
1282 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1283 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1285 oClass.classDefinition = null;
1289 loc->start.AdjustDelete(before, after);
1290 loc->end.AdjustDelete(before, after);
1295 if(membersListShown)
1298 if(pasteOperation || before.y != after.y)
1302 const char * buffer = membersLine.text;
1304 bool firstChar = true;
1308 if(before.x >= membersLoc.start.charPos)
1310 for(c = membersLoc.start.charPos; c<before.x && len < sizeof(string)-1; c++)
1312 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1313 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1318 if(!isSpace) firstChar = false;
1321 string[len++] = buffer[c];
1326 // If deleting spaces before...
1327 for(c = before.x; c<membersLoc.start.charPos; c++)
1329 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1337 membersLoc.start.charPos = before.x;
1340 if(membersLoc.end.charPos >= after.x)
1342 for(c = after.x; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
1344 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1345 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1350 if(!isSpace) firstChar = false;
1353 string[len++] = buffer[c];
1361 membersLoc.end.charPos -= after.x - before.x;
1365 row = membersList.FindSubString(string);
1368 row = membersList.FindSubStringi(string);
1370 membersList.currentRow = row;
1371 membersList.currentRow.selected = false;
1374 membersList.currentRow = row;
1376 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
1381 membersList.Destroy(0);
1382 membersListShown = false;
1388 InvokeParameters(false, false);
1396 bool NotifyDropped(EditBox editBox, int x, int y)
1398 char * controlClass = toolBox.controlClass;
1399 if(controlClass && controlClass[0])
1403 ObjectInfo classObject;
1405 editBox.GoToLineNum(y);
1406 x = Min(x, editBox.line.count);
1407 editBox.GoToPosition(editBox.line, y, x);
1408 // Note: Uncommented this to drag objects after the member instance on which they are dropped
1409 editBox.NotifyCaretMove(this, editBox, y+1, x+1);
1411 classObject = selected ? selected.oClass : null;
1413 if((!selected || selected == classObject) && classObject && classObject.instances.first)
1414 selected = classObject.instances.last;
1417 control = eInstance_New(eSystem_FindClass(privateModule, controlClass));
1420 AddObject(control, &object);
1422 designer.CreateObject(control, object, false, classObject.instance);
1423 // designer.PostCreateObject(control, object, false, classObject.instance);
1424 designer.DroppedObject(control, object, false, classObject.instance);
1426 sheet.AddObject(object, object.name, typeData /* className*/, true);
1429 //codeModified = true;
1436 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
1438 if(key == ctrlSpace)
1440 membersList.Destroy(0);
1441 membersListShown = false;
1442 InvokeAutoComplete(false, 0, false);
1445 else if(key == Key { space, ctrl = true, shift = true })
1446 InvokeParameters(false, true, false);
1447 else if(key == escape)
1448 ide.RepositionWindows(true);
1449 else if(key == ctrlF7)
1453 ProjectNode node = ide.projectView.GetNodeForCompilationFromWindow(this, false, null, null);
1457 s = PrintString($"The ", fileName, $" file is not part of any project.\n",
1458 $"It can't be compiled.");
1459 MessageBox { type = ok, /*parent = ide, */master = ide, text = $"File not in project error", contents = s }.Modal();
1468 bool OnKeyDown(Key key, unichar ch)
1470 CodeEditor editor = (CodeEditor)master;
1471 if(key == escape /*|| key == leftAlt || key == rightAlt || (key.ctrl && key.code != left && key.code != right && key.code != leftShift && key.code != rightShift && key.code != space)*/)
1473 if(editor.membersListShown)
1475 editor.membersList.Destroy(0);
1476 editor.membersListShown = false;
1479 if(editor.paramsShown)
1481 editor.paramsList.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;
1492 return EditBox::OnKeyDown(key, ch);
1495 void OnVScroll(ScrollBarAction action, int position, Key key)
1497 if(anchor.left.distance)
1499 Box box { 0, 0, anchor.left.distance-1, parent.clientSize.h - 1 };
1502 EditBox::OnVScroll(action, position, key);
1504 CodeEditor ce = (CodeEditor)parent;
1505 if(ce.openedFileInfo)
1506 ce.openedFileInfo.ScrollChange({ scroll.x, position });
1510 void OnHScroll(ScrollBarAction action, int position, Key key)
1512 EditBox::OnHScroll(action, position, key);
1514 CodeEditor ce = (CodeEditor)parent;
1515 if(ce.openedFileInfo)
1516 ce.openedFileInfo.ScrollChange({ position, scroll.y });
1523 fullRowSelect = false,
1526 borderStyle = bevel;
1527 // size = { 200, 400 };
1529 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
1531 DataRow row = listBox.currentRow;
1534 const char * string = row.string;
1536 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1538 membersLine, membersLoc.start.line, membersLoc.start.charPos,
1539 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1540 editBox.PutS(string);
1543 membersListShown = false;
1548 bool OnKeyDown(Key key, unichar ch)
1550 CodeEditor editor = (CodeEditor) master;
1551 if(key == escape || key == leftAlt || key == rightAlt ||
1552 (key.ctrl && key.code != left && key.code != right &&
1553 key.code != leftShift && key.code != rightShift && key.code != space))
1556 if(editor.paramsShown)
1560 editor.paramsList.Destroy(0);
1561 editor.paramsShown = false;
1563 if(editor.membersListShown)
1567 editor.membersList.Destroy(0);
1568 editor.membersListShown = false;
1571 FreeType(editor.functionType);
1572 editor.functionType = null;
1574 FreeType(editor.instanceType);
1575 editor.instanceType = null;
1577 editor.paramsID = -1;
1582 return editor.editBox.OnKeyDown(key, ch);
1586 /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1588 CodeEditor editor = (CodeEditor)master;
1589 Window rw = previous ? previous.rootWindow : null;
1590 if(!active && rw != editor.paramsList)
1593 editor.membersListShown = false;
1595 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1598 bool OnKeyHit(Key key, unichar ch)
1600 CodeEditor editor = (CodeEditor) master;
1604 case enter: case tab:
1606 DataRow row = currentRow;
1607 if(row && row.selected)
1609 const char * string = row.string;
1611 editor.editBox.GoToPosition(editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos);
1612 editor.editBox.Delete(
1613 editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos,
1614 editor.membersLine, editor.membersLoc.end.line, editor.membersLoc.end.charPos);
1615 editor.editBox.PutS(string);
1618 editor.membersListShown = false;
1621 editor.editBox.OnKeyHit(key, ch);
1631 return ListBox::OnKeyHit(key, ch);
1637 // If before . or after
1638 //listBox.Destroy(true);
1639 result = editor.editBox.OnKeyHit(key, ch);
1654 clickThrough = true,
1656 borderStyle = contour,
1658 background = { 255,255,225 },
1660 OnKeyDown = membersList.OnKeyDown;
1662 /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1664 CodeEditor editor = (CodeEditor)master;
1665 Window rw = previous ? previous.rootWindow : null;
1666 if(!active && previous != editor.editBox && rw != editor.membersList)
1669 editor.paramsShown = false;
1671 return Window::OnActivate(active, previous, goOnWithActivation, direct);
1674 bool OnKeyHit(Key key, unichar ch)
1676 CodeEditor editor = (CodeEditor)master;
1678 if(!editor.membersListShown || editor.membersList.OnKeyHit(key, ch))
1681 bool result = true; editor.editBox.OnKeyHit(key, ch);
1682 return (!created) ? false : result;
1689 void OnRedraw(Surface surface)
1691 CodeEditor editor = (CodeEditor) master;
1692 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1694 Type methodType = null;
1698 int functionW, nameW = 0;
1700 int spaceW, spaceH, commaW, commaWB, parW;
1702 int maxW = 0, lineW = 0;
1708 Font font = editor.normalFont.font;
1709 Font boldFont = editor.boldFont.font;
1710 Display display = this.display;
1712 if(!type) { return; };
1714 if(type.kind == TypeKind::methodType) { methodType = type; type = type.method.dataType; }
1716 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1717 display.FontExtent(font, ", ", 2, &commaW, null);
1718 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1719 display.FontExtent(font, ")", 1, &parW, null);
1722 if(editor.functionType)
1724 PrintType(type.returnType, string, true, true);
1725 display.FontExtent(font, string, strlen(string), &functionW, null);
1727 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1728 totalW = nameW + functionW + 2 * parW;
1732 PrintType(type, string, (type.kind == functionType) ? true : false, true); // true);
1733 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1734 if(instanceName && type.kind != functionType)
1735 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1736 totalW = functionW + nameW;
1737 surface.TextFont(boldFont);
1740 surface.WriteText(x, y, string, strlen(string));
1741 x += functionW + spaceW;
1743 if(editor.functionType)
1746 surface.WriteText(x, y, type.name, strlen(type.name));
1748 surface.WriteText(x, y, "(", 1);
1751 if(methodType && !methodType.staticMethod && methodType.methodClass)
1755 if(id == editor.paramsID)
1756 surface.TextFont(boldFont);
1758 if(methodType.methodClass)
1759 surface.TextExtent(methodType.methodClass.name, strlen(methodType.methodClass.name), &tw, null);
1763 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1764 width += ((id == editor.paramsID) ? commaWB : commaW);
1769 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1774 x = 2 + nameW + spaceW + functionW + parW;
1778 if(methodType.methodClass)
1779 surface.WriteText(x, y, methodType.methodClass.name, strlen(methodType.methodClass.name));
1782 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1784 surface.WriteText(x, y, ",", 1);
1785 x += ((id == editor.paramsID) ? commaWB : commaW);
1793 if(id == editor.paramsID)
1794 surface.TextFont(font);
1798 if(!methodType || (methodType.staticMethod || !methodType.methodClass) || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1800 for(param = type.params.first; param; param = param.next)
1802 char paramString[1024];
1805 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1806 surface.TextFont(boldFont);
1809 PrintType(param, paramString, true, true);
1810 surface.TextExtent(paramString, strlen(paramString), &tw, null);
1812 if(param.next) width += ((id == editor.paramsID) ? commaWB : commaW);
1817 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1822 x = 2 + nameW + spaceW + functionW + parW;
1826 surface.WriteText(x, y, paramString, strlen(paramString));
1830 surface.WriteText(x, y, ",", 1);
1831 x += ((id == editor.paramsID) ? commaWB : commaW);
1839 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1840 surface.TextFont(font);
1845 surface.WriteText(x, y, ")", 1);
1847 else if(instanceName && type.kind != functionType)
1849 surface.WriteText(x, y, instanceName, strlen(instanceName));
1853 bool OnResizing(int * w, int * h)
1855 CodeEditor editor = (CodeEditor) master;
1856 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1858 Type methodType = null;
1862 int functionW = 0, nameW = 0;
1864 int spaceW, spaceH, commaW, commaWB, parW;
1866 int maxW = 0, lineW = 0;
1871 Font font = editor.normalFont.font;
1872 Font boldFont = editor.boldFont.font;
1873 Display display = this.display;
1875 if(type.kind == TypeKind::methodType)
1878 ProcessMethodType(type.method);
1879 type = type.method.dataType;
1882 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1883 display.FontExtent(font, ", ", 2, &commaW, null);
1884 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1885 display.FontExtent(font, ")", 1, &parW, null);
1888 if(editor.functionType && type)
1890 PrintType(type.returnType, string, true, true);
1891 display.FontExtent(font, string, strlen(string), &functionW, null);
1893 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1894 totalW = nameW + spaceW + functionW + 2 * parW;
1898 PrintType(type, string, false, true); // /*true);
1899 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1900 if(instanceName && type.kind != functionType)
1901 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1902 totalW = functionW + nameW + spaceW;
1905 if(editor.functionType)
1911 if(methodType.methodClass)
1912 display.FontExtent((id == editor.paramsID) ? boldFont : font, methodType.methodClass.name, strlen(methodType.methodClass.name), &width, null);
1913 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1914 width += ((id == editor.paramsID) ? commaWB : commaW);
1919 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1932 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1934 for(param = type.params.first; param; param = param.next)
1936 char paramString[1024];
1940 PrintType(param, paramString, true, true);
1941 display.FontExtent((id == editor.paramsID || param.kind == ellipsisType) ? boldFont : font, paramString, strlen(paramString), &width, null);
1943 width += ((id == editor.paramsID) ? commaWB : commaW);
1948 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1965 *w = realW + totalW + 4;
1971 Menu fileMenu { menu, $"File", f };
1972 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
1973 MenuItem { fileMenu, $"Save As...", a, NotifySelect = MenuFileSaveAs };
1975 Menu editMenu { menu, $"Edit", e };
1976 MenuDivider { editMenu };
1977 MenuItem clearTrailingSpacesItem
1979 editMenu, $"Clear trailing spaces", t, Key { t, ctrl = true, shift = true };
1981 bool NotifySelect(MenuItem selection, Modifiers mods)
1983 // Nuke trailing spaces
1986 editBox.recordUndoEvent = true;
1987 for(line = editBox.firstLine; line; line = line.next, y++)
1989 const String buffer = line.text;
1990 int count = line.count, i = count-1;
1991 while(i >= 0 && isspace(buffer[i])) i--;
1993 editBox.Delete(line, y, i + 1, line, y, count);
1995 editBox.recordUndoEvent = false;
2000 Menu debugMenu { menu, $"Debug", d };
2001 MenuItem debugRunToCursor { debugMenu, $"Run To Cursor", c, ctrlF10, id = RTCMenuBits { false, false, false }, NotifySelect = RTCMenu_NotifySelect; };
2002 MenuItem debugSkipRunToCursor { debugMenu, $"Run To Cursor Skipping Breakpoints", u, Key { f10, ctrl = true, shift = true }, id = RTCMenuBits { true, false, false }, NotifySelect = RTCMenu_NotifySelect; };
2003 MenuItem debugRunToCursorAtSameLevel { debugMenu, $"Run To Cursor At Same Level", l, altF10, id = RTCMenuBits { false, true, false }, NotifySelect = RTCMenu_NotifySelect; };
2004 MenuItem debugSkipRunToCursorAtSameLevel { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", g, Key { f10, shift = true, alt = true }, id = RTCMenuBits { true, true, false }, NotifySelect = RTCMenu_NotifySelect; };
2006 MenuItem debugBpRunToCursor { debugMenu, $"BP Run To Cursor"/*, c, ctrlF10*/, id = RTCMenuBits { false, false, true }, NotifySelect = RTCMenu_NotifySelect; };
2007 MenuItem debugBpSkipRunToCursor { debugMenu, $"BP Run To Cursor Skipping Breakpoints"/*, u, Key { f10, ctrl = true, shift = true }*/, id = RTCMenuBits { true, false, true }, NotifySelect = RTCMenu_NotifySelect; };
2008 MenuItem debugBpRunToCursorAtSameLevel { debugMenu, $"BP Run To Cursor At Same Level"/*, l, altF10*/, id = RTCMenuBits { false, true, true }, NotifySelect = RTCMenu_NotifySelect; };
2009 MenuItem debugBpSkipRunToCursorAtSameLevel { debugMenu, $"BP Run To Cursor At Same Level Skipping Breakpoints"/*, g, Key { f10, shift = true, alt = true }*/, id = RTCMenuBits { true, true, true }, NotifySelect = RTCMenu_NotifySelect; };
2011 bool RTCMenu_NotifySelect(MenuItem selection, Modifiers mods)
2013 ProjectView projectView = ide.projectView;
2014 if(!projectView.buildInProgress)
2016 RTCMenuBits bits = (RTCMenuBits)selection.id;
2017 int line = editBox.lineNumber + 1;
2020 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2021 ProjectConfig config = projectView.project.config;
2022 int bitDepth = ide.workspace.bitDepth;
2023 bool useValgrind = ide.workspace.useValgrind;
2024 ide.debugger.RunToCursor(compiler, config, bitDepth, useValgrind, fileName, line, bits.ignoreBreakpoints, bits.atSameLevel, bits.oldImplementation);
2030 MenuDivider { debugMenu };
2031 MenuItem debugToggleBreakpoint
2033 debugMenu, $"Toggle Breakpoint", t, f9;
2034 bool NotifySelect(MenuItem selection, Modifiers mods)
2036 ProjectView projectView = ide.projectView;
2037 if(projectView && fileName)
2039 int line = editBox.lineNumber + 1;
2040 ide.debugger.ToggleBreakpoint(fileName, line);
2050 //MenuItem viewDesignerItem, viewProperties, viewMethods;
2054 designer.parent = parent;
2057 toolBox = ((IDEWorkSpace)master).toolBox;
2059 // Debugger bug here: value of toolBox appears as 0
2061 sheet = ((IDEWorkSpace)master).sheet;
2066 bool OnClose(bool parentClosing)
2070 if(ide.workspace && fileName)
2071 ide.workspace.UpdateOpenedFileInfo(fileName, closed);
2072 if(inUseDebug && !debugClosing)
2074 debugClosing = true;
2076 if(CloseConfirmation(false))
2079 if(modifiedDocument)
2080 OnFileModified({ modified = true }, null);
2082 debugClosing = false;
2085 if(designer && !designer.closing)
2087 if(designer.visible)
2094 //Window formEditor = designer;
2095 //formEditor.Destroy(0);
2098 ide.AdjustFileMenus();
2103 void OnDestroy(void)
2105 ObjectInfo oClass, next;
2106 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2108 FreeType(this.functionType);
2109 FreeType(this.instanceType);
2114 designer.codeEditor = null;
2115 designer.Destroy(0);
2119 for(oClass = (classes).first, next = oClass ? oClass.next : null; oClass; oClass = next, next = next ? (next.next) : null)
2121 ObjectInfo object, next;
2123 for(object = oClass.instances.first; object; object = next)
2128 Designer::DestroyObject(object.instance);
2129 delete object.instance;
2131 if(object.i18nStrings)
2133 Map<String, bool> i18nStrings = object.i18nStrings;
2136 sheet.DeleteObject(object);
2138 oClass.instances.Delete(object);
2142 Designer::DestroyObject(oClass.instance);
2143 delete oClass.instance;
2145 if(oClass.i18nStrings)
2147 Map<String, bool> i18nStrings = oClass.i18nStrings;
2150 sheet.DeleteObject(oClass);
2152 classes.Delete(oClass);
2155 if(windowClass && windowClass.data)
2156 UnapplySkin(windowClass);
2160 if(sheet.codeEditor == this)
2162 sheet.codeEditor = null;
2163 toolBox.codeEditor = null;
2169 ProjectView projectView = ide.projectView;
2172 ProjectNode node = projectView.GetNodeFromWindow(this, null, true, false, null);
2173 if(node && node.modified)
2175 node.modified = false;
2176 projectView.Update(null);
2182 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool directActivation)
2184 // 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
2186 if(directActivation)
2187 ide.RepositionWindows(false); // Moved this up before as resizing causes NotifyCaretMove to be called on all editors
2189 if(active && directActivation)
2193 openedFileInfo.Activate();
2197 Location * loc = null;
2198 UpdateFormCode(); // To ensure update when modifying properties...
2200 // Got to the right spot in code so we don't lose our form selection...
2203 if(selected.instCode)
2204 loc = &selected.instCode.loc;
2205 else if(selected.classDefinition)
2206 loc = &selected.classDefinition.loc;
2208 line = editBox.lineNumber + 1;
2209 charPos = editBox.charPos + 1;
2214 if(selected && !loc->Inside(line, charPos))
2216 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2217 line = editBox.lineNumber + 1;
2218 charPos = editBox.charPos + 1;
2220 else if(selected && selected.classDefinition)
2223 for(object = selected.instances.first; object; object = object.next)
2227 if(object.instCode.loc.Inside(line, charPos))
2233 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2234 line = editBox.lineNumber + 1;
2235 charPos = editBox.charPos + 1;
2240 ProcessCaretMove(editBox, line, charPos);
2245 if(membersListShown)
2247 membersList.Destroy(0);
2248 membersListShown = false;
2252 paramsList.Destroy(0);
2253 paramsShown = false;
2254 FreeType(functionType);
2255 FreeType(instanceType);
2257 functionType = null;
2258 instanceType = null;
2265 bool OnSaveFile(const char * fileName)
2272 f = FileOpen(fileName, write);
2275 if(!ide.projectView)
2276 ide.ChangeFileDialogsDirectory(codeEditorFileDialog.currentDirectory, true);
2280 this.fileName = fileName; // Put this here because the form designer will check for it...
2281 designer.fileName = fileName;
2282 designer.modifiedDocument = false;
2285 editBox.Save(f, false);
2286 modifiedDocument = false;
2294 bool OnFileModified(FileChange fileChange, const char * param)
2296 bool reload = false;
2297 if(visible == false && inUseDebug == true)
2298 ide.debugger.WatchesReleaseCodeEditor();
2303 sprintf(message, $"The document %s was modified by another application.\n"
2304 "Would you like to reload it and lose your changes?", fileName);
2305 if(MessageBox { type = yesNo, master = /*parent = */parent, text = $"Document has been modified",
2306 contents = message }.Modal() == yes)
2312 File f = FileOpen(fileName, read);
2315 int lineNumber, charPos, len;
2319 updatingCode = true;
2320 lineNumber = editBox.lineNumber;
2321 charPos = editBox.charPos;
2322 scroll = editBox.scroll;
2325 lineNumber = lineNumber < editBox.numLines ? lineNumber : editBox.numLines - 1;
2326 len = strlen(editBox.line.text);
2327 editBox.GoToLineNum(lineNumber);
2328 editBox.GoToPosition(editBox.line, lineNumber, charPos <= len ? charPos - 1 : (len ? len - 1 : 0));
2329 editBox.scroll = scroll;
2330 updatingCode = false;
2331 loadingFile = false;
2333 codeModified = true;
2337 designer.modifiedDocument = false;
2339 modifiedDocument = false;
2347 void OnRedraw(Surface surface)
2350 surface.SetBackground(marginColor);
2351 surface.Area(0, 0, editBox.anchor.left.distance, clientSize.h - 1);
2352 if(ideSettings.showLineNumbers)
2354 int currentLineNumber;
2356 char lineFormat[16];
2360 surface.textOpacity = false;
2361 surface.font = font.font;
2362 surface.TextExtent(" ", 1, null, &spaceH);
2363 currentLineNumber = editBox.scroll.y / spaceH + 1;
2364 sprintf(lineFormat, " %%%du", maxLineNumberLength);
2366 surface.SetForeground(lineNumbersColor);
2367 for(i = 0; i < editBox.clientSize.h - 4; i += spaceH)
2369 // Highlight current line
2370 if(editBox.lineNumber == currentLineNumber - 1)
2372 surface.SetBackground(selectedMarginColor);
2373 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2374 surface.SetBackground(marginColor);
2376 sprintf(lineText, lineFormat, currentLineNumber);
2377 if(currentLineNumber <= editBox.numLines)
2378 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,maxLineNumberLength+1);
2379 currentLineNumber++;
2383 if(editBox.syntaxHighlighting && fileName && ide.projectView)
2385 bool error, bpOnTopFrame, breakpointEnabled[128];
2386 int lineCursor, lineTopFrame, breakpointLines[128];
2387 int count, i, lineH, boxH, scrollY; //, firstLine; firstLine = editBox.firstLine;
2388 Debugger debugger = ide.debugger;
2389 BitmapResource bmpRes;
2391 boxH = clientSize.h;
2392 scrollY = editBox.scroll.y;
2393 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
2395 bpOnTopFrame = false;
2396 count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
2399 for(i = 0; i < count; i++)
2401 if(breakpointLines[i] == lineCursor || breakpointLines[i] == lineTopFrame)
2403 bmpRes = breakpointEnabled[i] ? ide.bmpBpHalf : ide.bmpBpHalfDisabled;
2404 if(breakpointLines[i] == lineTopFrame)
2405 bpOnTopFrame = true;
2408 bmpRes = breakpointEnabled[i] ? ide.bmpBp : ide.bmpBpDisabled;
2410 DrawLineMarginIcon(surface, bmpRes, breakpointLines[i], lineH, scrollY, boxH);
2413 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
2414 bmpRes = bpOnTopFrame ? (error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf) : (error ? ide.bmpTopFrameError : ide.bmpTopFrame);
2415 DrawLineMarginIcon(surface, bmpRes, lineTopFrame, lineH, scrollY, boxH);
2417 if(editBox.anchor.left.distance)
2419 if(editBox.horzScroll && editBox.horzScroll.visible)
2421 surface.SetBackground(control);
2422 surface.Area(0, editBox.clientSize.h, editBox.anchor.left.distance, clientSize.h - 1);
2427 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
2432 lineY = (line - 1) * lineH;
2433 if(lineY + lineH > scrollY && lineY /*+ lineH*/ < scrollY + boxH)
2435 Bitmap bitmap = resource.bitmap;
2437 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
2444 char ext[MAX_EXTENSION];
2445 const char * fileName = property::fileName;
2447 if(SearchString(fileName, 0, "Makefile", false, true))
2448 editBox.useTab = true;
2449 designer.fileName = fileName;
2453 GetExtension(fileName, ext);
2455 if(!strcmpi(ext, "ec") || !strcmpi(ext, "eh") || !strcmpi(ext, "c") || !strcmpi(ext, "h") || !strcmpi(ext, "cpp") ||
2456 !strcmpi(ext, "hpp") || !strcmpi(ext, "cxx") || !strcmpi(ext, "hxx") || !strcmpi(ext, "cc") || !strcmpi(ext, "hh") ||
2457 !strcmpi(ext, "m") || !strcmpi(ext, "mm") || !strcmpi(ext, "cs") || !strcmpi(ext, "java") || !strcmpi(ext, "y") || !strcmpi(ext, "l"))
2458 editBox.syntaxHighlighting = true;
2460 editBox.syntaxHighlighting = false;
2462 if(parsing && !strcmpi(ext, "ec"))
2464 codeModified = true;
2468 maxLineNumberLength = 0;
2473 bool UpdateMarginSize()
2475 if(ideSettings.showLineNumbers)
2477 int numLen = Max(4, nofdigits(editBox.numLines));
2479 maxLineNumberLength = numLen;
2480 display.FontExtent(font.font, "0", 1, &digitWidth, null);
2481 editBox.anchor = Anchor
2483 left = editBox.syntaxHighlighting * 20 + ideSettings.showLineNumbers * (maxLineNumberLength+2) * digitWidth,
2484 right = 0, top = 0, bottom = 0
2489 maxLineNumberLength = 0;
2490 editBox.anchor = Anchor
2492 left = editBox.syntaxHighlighting * 20,
2493 right = 0, top = 0, bottom = 0
2505 bool LoadFile(const char * filePath)
2507 File f = FileOpen(filePath, read);
2510 // Added this here...
2511 fileName = filePath;
2513 updatingCode = true;
2515 updatingCode = false;
2516 loadingFile = false;
2525 void AdjustDebugMenus()
2527 bool unavailable = ide.areDebugMenusUnavailable;
2528 bool isNotNotRunning = unavailable || ide.isDebuggerRunning;
2529 bool isNotStopped = unavailable || !ide.isDebuggerStopped;
2530 bool noBreakpointToggle = ide.isBreakpointTogglingUnavailable;
2532 debugRunToCursor.disabled = isNotNotRunning;
2533 debugSkipRunToCursor.disabled = isNotNotRunning;
2534 debugRunToCursorAtSameLevel.disabled = isNotStopped;
2535 debugSkipRunToCursorAtSameLevel.disabled = isNotStopped;
2537 debugBpRunToCursor.disabled = isNotNotRunning;
2538 debugBpSkipRunToCursor.disabled = isNotNotRunning;
2539 debugBpRunToCursorAtSameLevel.disabled = isNotStopped;
2540 debugBpSkipRunToCursorAtSameLevel.disabled = isNotStopped;
2542 debugToggleBreakpoint.disabled = noBreakpointToggle;
2549 globalData.classes.CompareKey = (void *)BinaryTree::CompareString;
2550 globalData.defines.CompareKey = (void *)BinaryTree::CompareString;
2551 globalData.functions.CompareKey = (void *)BinaryTree::CompareString;
2552 globalData.nameSpaces.CompareKey = (void *)BinaryTree::CompareString;
2555 designer.fileName = fileName;
2561 sprintf(title, $"Untitled %d", documentID);
2562 // designer.fileName = CopyString(title);
2563 designer.fileName = title;
2568 for(c = 0; c < CodeObjectType::enumSize; c++)
2569 icons[c] = BitmapResource { iconNames[c], window = this };
2571 codeModified = true;
2583 selected.modified = true;
2584 selected.oClass.modified = true;
2586 designer.modifiedDocument = true;
2587 modifiedDocument = true;
2588 formModified = true;
2591 /****************************************************************************
2593 ****************************************************************************/
2596 SetCurrentNameSpace(null);
2602 this.defines.Free(FreeModuleDefine);
2603 this.imports.Free(FreeModuleImport); // Moved this after FreeAST because Debug printing causes ModuleImports to be created
2605 FreeExcludedSymbols(this.excludedSymbols);
2606 FreeContext(this.globalContext);
2608 FreeGlobalData(&this.globalData);
2609 FindCtx_Terminate();
2610 FindParams_Terminate();
2612 if(GetGlobalContext() == globalContext)
2614 SetGlobalData(null);
2615 SetGlobalContext(null);
2616 SetExcludedSymbols(null);
2617 SetTopContext(null);
2618 SetCurrentContext(null);
2621 SetPrivateModule(null);
2624 if(this.privateModule)
2626 FreeTypeData(this.privateModule);
2627 delete this.privateModule;
2628 this.privateModule = null;
2634 static bool reentrant = false;
2639 char * selectedClassName = null, * selectedName = null;
2640 int selectedPos = 0;
2641 Designer backDesigner;
2642 char oldWorkDir[MAX_LOCATION];
2643 char mainModuleName[MAX_FILENAME] = "";
2644 const char * fileName;
2645 ImportedModule module;
2646 char extension[MAX_EXTENSION];
2647 PathBackup pathBackup { };
2649 Time parseCodeStart = GetTime();
2650 Time startTime, startFindClass;
2652 findClassTotalTime = 0;
2653 checkTypeTotalTime = 0;
2654 externalImportTotalTime = 0;
2655 findClassIgnoreNSTotalTime = 0;
2656 findSymbolTotalTime = 0;
2657 //ResetClassFindTime();
2661 // 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)
2662 if(reentrant) return;
2669 selectedClassName = CopyString(oClass.name);
2670 if(selected != oClass)
2672 ObjectInfo object = this.selected;
2673 selectedName = CopyString(object.name);
2677 for(check = this.oClass.instances.first; check; check = check.next)
2689 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
2691 FindCtx_Terminate();
2692 FindParams_Terminate();
2694 SetGlobalData(&globalData);
2695 SetGlobalContext(globalContext);
2696 SetExcludedSymbols(&excludedSymbols);
2697 SetTopContext(globalContext);
2698 SetCurrentContext(globalContext);
2699 SetDefines(&defines);
2700 SetImports(&imports);
2701 SetCurrentNameSpace(null);
2704 sprintf(command, "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin\\cl "
2705 "/nologo /D \"MSC\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" "
2706 "/I \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include\" "
2707 "/I T:\\ecere\\include /E %s", argv[1]);
2711 ChangeWorkingDir("e:\\ec");
2712 sprintf(command, "gcc -x c -E -");
2713 fileInput = DualPipeOpen({ output = true, input = true }, command);
2714 SetFileInput(fileInput);
2719 uint count = editFile.Read(buffer, 1, sizeof(buffer));
2721 fileInput.Write(buffer, 1, count);
2726 fileInput.CloseOutput();
2730 // TOCHECK: COULDN'T WE CALL FreeParser here?
2732 FreeType(this.functionType);
2733 FreeType(this.instanceType);
2734 this.functionType = null;
2735 this.instanceType = null;
2738 sheet.SelectObject(null);
2744 // We don't want the designer to be notified of selection when deleting rows...
2745 backDesigner = designer;
2750 ObjectInfo _class, next;
2752 for(_class = classes.first; _class; _class = next)
2758 while((object = _class.instances.first))
2762 Designer::DestroyObject(object.instance);
2763 delete object.instance;
2765 if(object.i18nStrings)
2767 Map<String, bool> i18nStrings = object.i18nStrings;
2770 sheet.DeleteObject(object);
2772 _class.instances.Delete(object);
2776 Designer::DestroyObject(_class.instance);
2777 delete _class.instance;
2779 if(_class.i18nStrings)
2781 Map<String, bool> i18nStrings = _class.i18nStrings;
2784 sheet.DeleteObject(_class);
2786 classes.Delete(_class);
2792 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2793 if(windowClass && windowClass.data)
2794 UnapplySkin(windowClass);
2797 designer = backDesigner;
2800 fileInput = editFile = EditBoxStream { editBox = editBox };
2801 SetFileInput(fileInput);
2809 defines.Free(FreeModuleDefine);
2810 imports.Free(FreeModuleImport);
2812 FreeContext(this.globalContext);
2813 FreeExcludedSymbols(this.excludedSymbols);
2816 FreeGlobalData(&this.globalData);
2818 if(this.privateModule)
2820 FreeTypeData(this.privateModule);
2821 delete this.privateModule;
2825 startTime = GetTime();
2826 printf("Cleaning up took %.3f seconds\n", startTime - parseCodeStart);
2828 printf("classes.count: %d\n", globalContext.classes.count);
2833 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2834 SetTargetBits(ide.workspace.bitDepth ? ide.workspace.bitDepth : GetHostBits());
2837 this.privateModule = __ecere_COM_Initialize(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4), 1, null);
2839 SetPrivateModule(privateModule);
2842 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint"), type = ProcessTypeString("unsigned int", false) });
2843 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint64"), type = ProcessTypeString("unsigned int64", false) });
2844 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint32"), type = ProcessTypeString("unsigned int", false) });
2845 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint16"), type = ProcessTypeString("unsigned short", false) });
2846 globalContext.types.Add((BTNode)Symbol { string = CopyString("byte"), type = ProcessTypeString("unsigned char", false) });
2849 fileName = this.fileName;
2851 if(ide.workspace && ide.workspace.projects && fileName)
2853 for(p : ide.workspace.projects)
2855 char path[MAX_LOCATION];
2857 MakePathRelative(fileName, p.topNode.path, path);
2858 MakeSlashPath(path);
2860 pn = p.topNode.FindWithPath(path, false);
2869 project = ide.project;
2871 GetWorkingDir(oldWorkDir, MAX_LOCATION);
2873 ChangeWorkingDir(project.topNode.path);
2875 SetSomeSourceFileStack(fileName ? fileName : "", 0); //strcpy(sourceFileStack[0], fileName ? fileName : "");
2877 GetLastDirectory(fileName, mainModuleName);
2878 GetExtension(mainModuleName, extension);
2880 SetBuildingEcereCom(false);
2881 SetBuildingEcereComModule(false);
2883 // TODO: Get symbolsDir from project settings instead...
2886 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2887 ProjectConfig config = project.config;
2888 int bitDepth = ide.workspace.bitDepth;
2889 DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
2890 SetSymbolsDir(objDir.dir);
2891 ide.SetPath(true, compiler, config, bitDepth);
2895 // SetIncludeDirs(ide.projectView.project.config.includeDirs);
2896 // SetSysIncludeDirs(ide.ideSettings.systemDirs[includes]);
2900 switch(GetRuntimePlatform())
2902 case win32: SetSymbolsDir("obj/debug.win32"); break;
2903 case tux: SetSymbolsDir("obj/debug.linux"); break;
2904 case apple: SetSymbolsDir("obj/debug.apple"); break;
2906 SetIncludeDirs(null);
2907 SetSysIncludeDirs(null);
2911 if(ide.projectView && ide.projectView.IsModuleInProject(this.fileName))
2913 // TODO FIX for configless project
2914 if(ide.project.config && ide.project.config.options && ide.project.config.options.preprocessorDefinitions)
2916 for(item : ide.project.config.options.preprocessorDefinitions)
2918 if(!strcmp(item, "BUILDING_ECERE_COM"))
2920 SetBuildingEcereCom(true);
2927 if(!(strcmpi(mainModuleName, "instance.ec") && strcmpi(mainModuleName, "BinaryTree.ec") &&
2928 strcmpi(mainModuleName, "dataTypes.ec") && strcmpi(mainModuleName, "OldList.ec") &&
2929 strcmpi(mainModuleName, "String.ec") && strcmpi(mainModuleName, "BTNode.ec") &&
2930 strcmpi(mainModuleName, "Array.ec") && strcmpi(mainModuleName, "AVLTree.ec") &&
2931 strcmpi(mainModuleName, "BuiltInContainer.ec") && strcmpi(mainModuleName, "Container.ec") &&
2932 strcmpi(mainModuleName, "CustomAVLTree.ec") && strcmpi(mainModuleName, "LinkList.ec") &&
2933 strcmpi(mainModuleName, "List.ec") && strcmpi(mainModuleName, "Map.ec") &&
2934 strcmpi(mainModuleName, "Mutex.ec")))
2936 SetBuildingEcereComModule(true);
2939 // Predeclare all classes
2941 char symFile[MAX_FILENAME];
2942 char symLocation[MAX_LOCATION];
2943 ImportedModule module, next;
2945 GetLastDirectory(fileName, symFile);
2946 ChangeExtension(symFile, "sym", symFile);
2948 strcpy(symLocation, GetSymbolsDir());
2949 PathCat(symLocation, symFile);
2951 // if(!GetEcereImported() && !GetBuildingEcereCom())
2952 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2955 startTime = GetTime();
2957 eModule_LoadStrict(privateModule, "ecereCOM", privateAccess);
2959 printf("Loading ecereCOM took %.3f seconds\n", GetTime() - startTime);
2964 startTime = GetTime();
2966 // LoadSymbols(symLocation, normalImport, true);
2967 LoadSymbols(symLocation, preDeclImport, false);
2969 printf("Loading symbols took %.3f seconds\n", GetTime() - startTime);
2972 for(module = defines.first; module; module = next)
2975 if(module.type == moduleDefinition && strcmpi(module.name, mainModuleName))
2978 defines.Delete(module);
2983 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2985 SetDefaultDeclMode(privateAccess);
2986 SetDeclMode(privateAccess);
2990 SetDefaultDeclMode(defaultAccess);
2991 SetDeclMode(defaultAccess);
2994 StripExtension(mainModuleName);
2995 module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };
2996 defines.AddName(module);
2999 // SetYydebug(true);
3004 startTime = GetTime();
3005 startFindClass = checkTypeTotalTime;
3009 printf("ParseEc took %.3f seconds, out of which %.3f seconds were in CheckType\n", GetTime() - startTime, checkTypeTotalTime - startFindClass);
3011 CheckDataRedefinitions();
3014 SetIncludeDirs(null);
3015 SetSysIncludeDirs(null);
3026 startTime = GetTime();
3028 PrePreProcessClassDefinitions();
3029 ComputeModuleClasses(privateModule);
3030 PreProcessClassDefinitions();
3031 ProcessClassDefinitions();
3033 printf("Initial Passes took %.3f seconds\n", GetTime() - startTime);
3034 startTime = GetTime();
3039 printf("ComputeDataTypes took %.3f seconds\n", GetTime() - startTime);
3040 startTime = GetTime();
3042 ProcessInstantiations();
3044 printf("ProcessInstantiations took %.3f seconds\n", GetTime() - startTime);
3047 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
3049 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3050 if(!windowClass || windowClass.internalDecl)
3053 startTime = GetTime();
3055 // *** COMMENTED THIS OUT DUE TO ecereCOM issues
3056 // eModule_Load(this.privateModule.application.allModules.first ? this.privateModule.application.allModules.first : this.privateModule, "ecere", privateAccess);
3057 eModule_Load(this.privateModule, "ecere", privateAccess);
3059 printf("Loading ecere.dll took %.3f seconds\n", GetTime() - startTime);
3062 windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3064 if(windowClass && windowClass.data)
3065 ApplySkin(windowClass, app.currentSkin.name, null);
3069 startTime = GetTime();
3071 for(external = ast->first; external; external = external.next)
3073 if(external.type == classExternal)
3075 ClassDefinition _class = external._class;
3076 if(_class.baseSpecs && _class.baseSpecs->first && ((Specifier)_class.baseSpecs->first).type == nameSpecifier ) // classSpecifier
3078 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)_class.baseSpecs->first).name);
3081 if(eClass_GetDesigner(regClass) && !GetBuildingEcereComModule())
3083 Instance instance = eInstance_New(regClass);
3084 ObjectInfo classObject
3086 name = CopyString(_class._class.name);
3087 instance = instance;
3088 classDefinition = _class;
3089 oClass = classObject;
3091 classes.Add(classObject);
3095 // Moved this at bottom so that the file dialog doesn't show up in eCom
3096 designer.CreateObject(instance, classObject, true, null);
3097 sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, typeClass, false);
3099 if(_class.definitions)
3103 for(def = _class.definitions->first; def; def = def.next)
3107 case defaultPropertiesClassDef:
3110 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
3112 Identifier id = propDef.identifiers->first;
3115 Property prop = eClass_FindProperty(regClass, id.string, this.privateModule);
3118 Class propertyClass = prop.dataTypeClass;
3120 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3121 if(prop.compiled && prop.Set && prop.Get && propertyClass && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp)
3123 Expression computed;
3124 bool variable = true;
3126 FreeType(propDef.initializer.exp.destType);
3127 propDef.initializer.exp.destType = MkClassType(propertyClass.name);
3128 ProcessExpressionType(propDef.initializer.exp);
3130 computed = CopyExpression(propDef.initializer.exp);
3131 ComputeExpression(computed);
3132 if(computed.isConstant)
3134 switch(computed.type)
3137 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3139 String temp = new char[strlen(computed.string)+1];
3140 ReadString(temp, computed.string);
3141 ((void (*)(void *, void *))(void *)prop.Set)(instance, temp);
3144 if(!propDef.initializer.exp.intlString)
3146 Map<String, bool> i18nStrings = classObject.i18nStrings;
3148 classObject.i18nStrings = i18nStrings = { };
3149 i18nStrings[prop.name] = false;
3155 if((propertyClass.type == structClass || propertyClass.type == noHeadClass || propertyClass.type == normalClass) && !id.next)
3159 if(computed.instance._class && computed.instance._class.symbol &&
3160 computed.instance._class.symbol.registered &&
3161 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3163 ((void (*)(void *, void *))(void *)prop.Set)(instance, computed.instance.data);
3165 // This was saved in the control and shouldn't be freed by FreeExpression...
3166 // (Not doing this anymore, incrementing refCount in pass15 instead)
3167 /*if(propertyClass.type == normalClass)
3168 computed.instance.data = null;*/
3176 Operand value = GetOperand(computed);
3177 DataValue valueData;
3178 valueData.i64 = value.i64;
3179 SetProperty(prop, instance, valueData);
3186 propDef.variable = true;
3187 FreeExpression(computed);
3192 Method method = eClass_FindMethod(regClass, id.string, this.privateModule);
3193 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer &&
3194 propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
3197 // Maintain a list in FunctionDefinition of who is attached to it
3198 for(def = _class.definitions->first; def; def = def.next)
3200 if(def.type == functionClassDef)
3202 ClassFunction function = def.function;
3203 if(!strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
3205 function.attached.Add(OldLink { data = method });
3215 case declarationClassDef:
3217 Declaration decl = def.decl;
3220 case instDeclaration:
3222 Instantiation inst = decl.inst;
3223 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3224 if(instClass && eClass_GetDesigner(instClass))
3226 Instance control = eInstance_New(instClass);
3231 oClass = classObject;
3235 classObject.instances.Add(object);
3237 // TOCHECK: Why is this needed now?
3238 object.name = CopyString((inst.exp.type == memberExp) ? inst.exp.member.member.string : inst.exp.identifier.string);
3239 def.object = object;
3241 // if(object.name) { symbol = eList_Add(&curContext.symbols, sizeof(Symbol)); symbol.string = object.name; symbol.type = MkClassType(instClass.name); }
3243 designer.CreateObject(control, object, false, classObject.instance);
3244 sheet.AddObject(object, object.name ? object.name : inst._class.name, typeData, false);
3254 // Second pass, process instantiation members
3256 for(def = _class.definitions->first; def; def = def.next)
3260 case declarationClassDef:
3262 Declaration decl = def.decl;
3265 case instDeclaration:
3267 Instantiation inst = decl.inst;
3268 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3269 if(instClass && eClass_GetDesigner(instClass))
3272 object = object ? object.next : classObject.instances.first;
3273 control = object.instance;
3277 MembersInit members;
3278 for(members = inst.members->first; members; members = members.next)
3280 switch(members.type)
3282 case dataMembersInit:
3284 if(members.dataMembers)
3287 DataMember curMember = null;
3288 Class curClass = null;
3289 DataMember subMemberStack[256];
3290 int subMemberStackPos = 0;
3292 for(member = members.dataMembers->first; member; member = member.next)
3295 Identifier ident = member.identifiers ? member.identifiers->first : null;
3298 DataMember _subMemberStack[256];
3299 int _subMemberStackPos = 0;
3300 DataMember thisMember = (DataMember)eClass_FindDataMember(instClass, ident.string, privateModule, _subMemberStack, &_subMemberStackPos);
3304 thisMember = (DataMember)eClass_FindProperty(instClass, ident.string, privateModule);
3306 if(thisMember && thisMember.memberAccess == publicAccess)
3308 curMember = thisMember;
3309 curClass = curMember._class;
3310 memcpy(subMemberStack, _subMemberStack, sizeof(DataMember) * _subMemberStackPos);
3311 subMemberStackPos = _subMemberStackPos;
3317 eClass_FindNextMember(instClass, &curClass, (DataMember *)&curMember, subMemberStack, &subMemberStackPos);
3318 if(curMember) found = true;
3320 if(found && curMember.isProperty)
3322 Property prop = (Property) curMember;
3323 Class propertyClass = prop.dataTypeClass;
3324 bool variable = false;
3326 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3328 if(prop.compiled && prop.Set && prop.Get && propertyClass && member.initializer && member.initializer.type == expInitializer && member.initializer.exp)
3330 FreeType(member.initializer.exp.destType);
3331 member.initializer.exp.destType = MkClassType(propertyClass.name);
3334 Expression computed;
3336 ProcessExpressionType(member.initializer.exp);
3338 computed = CopyExpression(member.initializer.exp);
3341 bool isClass = propertyClass.type == structClass || propertyClass.type == normalClass || propertyClass.type == noHeadClass;
3344 /*char debugExpString[4096];
3345 debugExpString[0] = '\0';
3346 PrintExpression(member.initializer.exp, debugExpString);*/
3348 ComputeExpression(computed);
3350 switch(computed.type)
3353 if(isClass && computed.isConstant && computed.instance.data)
3355 if(computed.instance._class && computed.instance._class.symbol &&
3356 computed.instance._class.symbol.registered &&
3357 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3359 ((void (*)(void *, void *))(void *)prop.Set)(control, computed.instance.data);
3361 // This was saved in the control and shouldn't be freed by FreeExpression...
3362 // (Not doing this anymore, incrementing refCount in pass15 instead)
3363 /*if(propertyClass.type == normalClass)
3364 computed.instance.data = null;*/
3370 if(isClass && eClass_GetDesigner(propertyClass))
3373 char * name = computed.identifier.string;
3374 if(!strcmp(name, "this"))
3377 ((void (*)(void *, void *))(void *)prop.Set)(control, instance);
3383 for(check = classObject.instances.first; check; check = check.next)
3384 if(check.name && !strcmp(name, check.name))
3387 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3397 if(computed.member.exp.type == identifierExp)
3399 char * name = computed.member.exp.identifier.string;
3401 if(!strcmp(name, "this"))
3403 char * name = computed.member.member.string;
3405 for(check = classObject.instances.first; check; check = check.next)
3406 if(check.name && !strcmp(name, check.name))
3409 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3416 for(check = classObject.instances.first; check; check = check.next)
3418 if(check.name && !strcmp(name, check.name))
3420 Property getProperty = eClass_FindProperty(check.instance._class, computed.member.member.string, this.privateModule);
3423 DataValue value { };
3424 GetProperty(getProperty, check.instance, &value);
3425 SetProperty(prop, control, value);
3436 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3438 String temp = new char[strlen(computed.string)+1];
3439 ReadString(temp, computed.string);
3440 ((void (*)(void *, void *))(void *)prop.Set)(control, temp);
3443 if(!member.initializer.exp.intlString)
3445 Map<String, bool> i18nStrings = object.i18nStrings;
3447 object.i18nStrings = i18nStrings = { };
3448 i18nStrings[prop.name] = false;
3455 if(!isClass && computed.isConstant)
3457 if(!strcmp(propertyClass.dataTypeString, "float"))
3458 ((void (*)(void *, float))(void *)prop.Set)(control, (float)strtod(computed.constant, null));
3459 else if(!strcmp(propertyClass.dataTypeString, "double"))
3460 ((void (*)(void *, double))(void *)prop.Set)(control, strtod(computed.constant, null));
3462 ((void (*)(void *, int))(void *)prop.Set)(control, strtol(computed.constant, null, 0));
3469 FreeExpression(computed);
3473 member.variable = true;
3475 else if(ident && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3476 member.initializer.exp.type == memberExp) // identifierExp
3478 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3479 if(method && method.type == virtualMethod)
3482 // Maintain a list in FunctionDefinition of who is attached to it
3483 for(def = _class.definitions->first; def; def = def.next)
3485 if(def.type == functionClassDef)
3487 ClassFunction function = def.function;
3488 Identifier id = (member.initializer.exp.type == memberExp) ? member.initializer.exp.member.member : member.initializer.exp.identifier;
3489 if(function.declarator && !strcmp(function.declarator.symbol.string, id.string))
3491 function.attached.Add(OldLink { data = method });
3492 // Reference this particular instance?
3507 designer.PostCreateObject(object.instance, object, false, classObject.instance);
3518 //designer.CreateObject(instance, classObject, true, null);
3519 //sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, classType, false);
3521 designer.PostCreateObject(instance, classObject, true, null);
3523 //instance.state = Hidden;
3524 //instance.Create();
3525 //instance.SetState(Normal, true, 0);
3534 printf("Class/Instance Processing took %.3f seconds\n", GetTime() - startTime);
3538 // Restore Selection
3539 if(selectedClassName)
3542 for(oClass = classes.first; oClass; oClass = oClass.next)
3544 if(!strcmp(oClass.name, selectedClassName))
3546 this.oClass = oClass;
3550 delete selectedClassName;
3558 for(check = this.oClass.instances.first; check; check = check.next)
3560 if(check.name && !strcmp(check.name, selectedName))
3562 this.selected = check;
3568 if(this.oClass.instances.first)
3569 this.selected = this.oClass.instances.first;
3571 this.selected = this.oClass;
3574 else if(selectedPos == -1 || !this.oClass.instances.count)
3575 this.selected = this.oClass;
3581 if(selectedPos > this.oClass.instances.count)
3583 for(check = this.oClass.instances.first; check; check = check.next)
3585 if(selectedPos == pos++)
3587 this.selected = check;
3595 this.oClass = classes.first;
3596 this.selected = (this.oClass && this.oClass.instances.first) ? this.oClass.instances.first : this.oClass;
3598 delete selectedName;
3599 SetSymbolsDir(null);
3601 if(sheet.codeEditor == this)
3602 sheet.SelectObject(selected);
3605 codeModified = false;
3607 // TESTING THIS TO NOT GET EMPTY PARAMETERS
3610 InvokeParameters(false, false, false);
3613 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
3619 ChangeWorkingDir(oldWorkDir);
3621 printf("Total FindClass time is %.3f seconds, out of which %.3f is in Ignore NS\n\n", findClassTotalTime, findClassIgnoreNSTotalTime);
3622 printf("Total CheckType time is %.3f seconds\n\n", checkTypeTotalTime);
3623 printf("Total MkExternalImport time is %.3f seconds\n\n", externalImportTotalTime);
3624 printf("Total FindSymbol time is %.3f seconds\n\n", findSymbolTotalTime);
3625 // printf("Total Class Members Find time is %.3f seconds\n\n", GetClassFindTime());
3627 printf("Whole ParseCode function took %.3f seconds\n\n", GetTime() - parseCodeStart);
3629 if(inUseDebug && ide.projectView)
3630 ide.debugger.EvaluateWatches();
3635 void UpdateInstanceCodeClass(Class _class, ObjectInfo object, EditBoxStream f, Instance test, bool * prev, bool * lastIsMethod, DataMember * curMember, Class * curClass)
3638 Window control = (Window)object.instance;
3639 ObjectInfo classObject = object.oClass;
3641 if(_class.base && _class.base.type != systemClass) UpdateInstanceCodeClass(_class.base, object, f, test, prev, lastIsMethod, curMember, curClass);
3643 if(!strcmp(_class.name, "DesignerBase")) return;
3645 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
3647 Property prop = eClass_FindProperty(object.instance._class, propIt.name, privateModule);
3648 if(prop && prop.isProperty && !prop.conversion && eClass_FindProperty(object.instance._class, prop.name, privateModule))
3650 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(object, prop.name) &&
3651 prop.compiled && (!prop.IsSet || prop.IsSet(control)))
3653 Class dataType = prop.dataTypeClass;
3655 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3659 if(dataType.type == structClass)
3661 void * dataForm = new0 byte[dataType.structSize];
3662 void * dataTest = new0 byte[dataType.structSize];
3664 ((void (*)(void *, void *))(void *)prop.Get)(control, dataForm);
3665 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
3667 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3669 char tempString[1024] = "";
3670 const char * string = "";
3671 bool needClass = true;
3675 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3677 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3679 eClass_FindNextMember(_class, curClass, curMember, null, null);
3680 if(*curMember != (DataMember)prop)
3681 f.Printf("%s = ", prop.name);
3683 *curMember = (DataMember)prop;
3684 *curClass = curMember->_class;
3687 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3689 f.Printf("%s", string);
3696 else if(dataType.type == normalClass || dataType.type == noHeadClass)
3698 void * dataForm, * dataTest;
3699 bool isEditBoxContents = false;
3700 bool freeDataForm = false, freeDataTest = false;
3702 // Because contents property is broken for mutiline EditBox at the moment
3703 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
3704 isEditBoxContents = true;
3706 if(isEditBoxContents && ((EditBox)control).multiLine)
3708 dataForm = ((EditBox)control).multiLineContents;
3709 freeDataForm = true;
3712 dataForm = ((void *(*)(void *))(void *)prop.Get)(control);
3713 if(isEditBoxContents && ((EditBox)test).multiLine)
3715 dataTest = ((EditBox)test).multiLineContents;
3716 freeDataTest = true;
3719 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
3721 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3723 char tempString[1024] = "";
3724 const char * string = "";
3728 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3730 eClass_FindNextMember(_class, curClass, curMember, null, null);
3731 if(*curMember != (DataMember)prop)
3732 f.Printf("%s = ", prop.name);
3733 *curMember = (DataMember)prop;
3734 *curClass = curMember->_class;
3736 if(eClass_GetDesigner(dataType))
3738 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
3739 //if(!strcmp(classObject.instance._class.name, dataType.name) && classObject.instance == dataForm)
3740 f.Printf("this", prop.name);
3743 //ObjectInfo classObject;
3744 //for(classObject = classes.first; classObject; classObject = classObject.next)
3748 for(object = classObject.instances.first; object; object = object.next)
3750 if(!object.deleted && eClass_IsDerived(object.instance._class, dataType) && object.instance == dataForm && object.name)
3752 f.Printf("%s", object.name);
3759 bool needClass = true;
3760 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3761 f.Printf("%s", string);
3768 bool needClass = true;
3769 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3771 if(!strcmp(dataType.dataTypeString, "char *"))
3773 Map<String, bool> i18nStrings = object.i18nStrings;
3775 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
3778 f.Printf("%s\"", i18n ? "$" : "");
3779 OutputString(f, string);
3783 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3785 f.Printf("%s", string);
3788 *lastIsMethod = false;
3791 if(freeDataForm) delete dataForm;
3792 if(freeDataTest) delete dataTest;
3796 DataValue dataForm, dataTest;
3798 GetProperty(prop, control, &dataForm);
3799 GetProperty(prop, test, &dataTest);
3801 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
3804 char tempString[1024] = "";
3805 SetProperty(prop, test, dataForm);
3807 if(dataType.type != bitClass)
3809 bool needClass = true;
3811 if(dataType.type == enumClass)
3814 Class enumClass = eSystem_FindClass(privateModule, "enum");
3815 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
3817 for(value = e.values.first; value; value = value.next)
3819 if((int)value.data == dataForm.i)
3821 string = value.name;
3827 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
3829 if(string && string[0])
3834 eClass_FindNextMember(_class, curClass, curMember, null, null);
3835 if(*curMember != (DataMember)prop)
3836 f.Printf("%s = ", prop.name);
3837 *curMember = (DataMember)prop;
3838 *curClass = curMember->_class;
3840 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
3841 f.Printf("%sf", string);
3843 f.Printf("%s", string);
3847 else if(dataType.type == bitClass)
3849 bool needClass = true;
3851 if(*prev) f.Printf(", ");
3853 eClass_FindNextMember(_class, curClass, curMember, null, null);
3854 if(*curMember != (DataMember)prop)
3855 f.Printf("%s = ", prop.name);
3856 *curMember = (DataMember)prop;
3857 *curClass = curMember->_class;
3859 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm.ui, tempString, null, &needClass);
3861 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3863 f.Printf("%s", string);
3865 *lastIsMethod = false;
3875 int UpdateInstanceCode(EditBoxStream f, int position, Class regClass, ObjectInfo object, bool * firstObject, char ** text, int * textSize, int movedFuncIdLen, int movedFuncIdPos)
3877 Instantiation inst = object.instCode;
3878 Window control = (Window)object.instance;
3880 bool methodPresent = false;
3881 bool lastIsMethod = true;
3887 // Instance removed, delete it
3888 DeleteJunkBefore(f, inst.loc.start.pos, &position);
3890 f.DeleteBytes(inst.loc.end.pos - inst.loc.start.pos + 1);
3891 position = inst.loc.end.pos + 1;
3895 bool multiLine = false;
3898 // Check if it's an unnamed instance
3901 f.Seek(inst.nameLoc.start.pos - position, current);
3902 f.DeleteBytes(inst.nameLoc.end.pos - inst.nameLoc.start.pos);
3903 position = inst.nameLoc.end.pos;
3905 f.Printf(object.name);
3910 if(isspace(ch) && ch != '\n')
3912 f.Seek(-1, current);
3920 int pos = inst.loc.start.pos; // + strlen(inst._class.name);
3922 f.Seek(pos - position, current);
3927 f.Seek(-1, current);
3936 f.Puts(object.name);
3941 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
3942 methodPresent = true;
3950 if(ch == OpenBracket)
3956 // TODO: Simplify this?
3965 f.Seek(-1, current);
3966 DeleteJunkBefore(f, position, &position);
3978 if(ch == '\n') { toDelete = count; count = 0; }
3979 else if(isspace(ch)) count++;
3982 f.Seek(-1, current);
3986 toDelete += count - 6;
3990 toAdd = 6 - count;*/
3996 f.Seek(-toDelete-count, current);
3997 f.DeleteBytes(toDelete);
3998 f.Seek(count, current);
4001 DeleteJunkBefore(f, position, &position);
4003 // Removed this here as it was adding trailing spaces when adding a method
4008 for(c = 0; c<toAdd; c++)
4015 methodPresent = multiLine;
4017 //if(!prev) -- always false
4018 f.Printf(methodPresent ? "\n " : " ");
4023 // Instance not there, create a brand new one
4024 DeleteJunkBefore(f, position, &position);
4025 f.Printf(*firstObject ? "\n\n" : "\n");
4026 *firstObject = false;
4028 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
4029 methodPresent = true;
4034 f.Printf(" %s %s\n %c\n ", control._class.name, object.name, OpenBracket);
4036 f.Printf(" %s\n %c\n ", control._class.name, OpenBracket);
4041 f.Printf(" %s %s %c ", control._class.name, object.name, OpenBracket);
4043 f.Printf(" %s %c ", control._class.name, OpenBracket);
4049 Instance test = eInstance_New(control._class);
4050 DataMember curMember = null;
4051 Class curClass = null;
4054 UpdateInstanceCodeClass(control._class, object, f, test, &prev, &lastIsMethod, &curMember, &curClass);
4058 // Attach Method here
4059 if((this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod) && !this.moveAttached && this.selected == object)
4061 if(prev) f.Printf(", ");
4062 f.Printf("%s = %s", this.method.name, function.declarator.symbol.string);
4067 if(inst && !object.deleted)
4069 MembersInit members;
4070 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
4072 DeleteJunkBefore(f, position, &position);
4074 // Instance already there, clear out the properties
4075 for(members = inst.members ? inst.members->first : null; members; members = members.next)
4077 if(members.type == dataMembersInit)
4081 if(members.dataMembers)
4083 bool keptMember = false;
4084 MemberInit lastKept = null;
4086 for(member = members.dataMembers->first; member; member = member.next)
4088 Identifier ident = member.identifiers ? member.identifiers->first : null;
4089 bool deleted = false;
4091 // For now delete if it's not a method
4092 if(!member.variable) // && ident)
4094 if(!ident || !ident.next)
4096 Property prop = ident ? eClass_FindProperty(instClass, ident.string, this.privateModule) : null;
4099 f.Seek(member.loc.start.pos - position, current);
4100 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4101 position = member.loc.end.pos;
4106 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
4107 if(method && method.type == virtualMethod && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
4108 member.initializer.exp.type == memberExp /*ExpIdentifier*/)
4110 if(((this.methodAction == actionDetachMethod || this.methodAction == actionReattachMethod) && this.method == method && this.selected == object) ||
4111 (this.methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, member.initializer.exp.identifier.string)))
4113 f.Seek(member.loc.start.pos - position, current);
4114 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4115 position = member.loc.end.pos;
4127 //f.Seek(member.loc.start.pos - position, current);
4128 //position = member.loc.start.pos;
4129 DeleteJunkBefore(f, member.loc.start.pos, &position);
4130 if(prev) f.Printf(", ");
4131 else if(keptMember) f.Printf(" ");
4136 if(!keptMember || !members.next)
4140 if(keptMember && lastKept != members.dataMembers->last)
4145 f.Seek(-1, current);
4151 f.Seek(-1, current);
4154 else if(!isspace(ch))
4156 f.Seek(-2, current);
4161 f.DeleteBytes(count);
4164 f.Seek(members.loc.end.pos - position, current);
4169 f.Seek(-1, current);
4171 position = members.loc.end.pos + 1;
4175 f.Seek(-1, current);
4176 position = members.loc.end.pos;
4182 lastIsMethod = false;
4187 DeleteJunkBefore(f, position, &position);
4190 if(lastKept != members.dataMembers->last)
4195 f.Seek(-1, current);
4201 f.Seek(-1, current);
4204 else if(!isspace(ch))
4206 f.Seek(-2, current);
4211 f.DeleteBytes(count);
4215 f.Seek(members.loc.end.pos - position, current);
4216 position = members.loc.end.pos;
4220 lastIsMethod = true;
4223 lastIsMethod = false;
4229 f.Seek(members.loc.end.pos - position, current);
4230 position = members.loc.end.pos;
4232 lastIsMethod = true;
4235 else if(members.type == methodMembersInit)
4237 if(this.methodAction == actionDeleteMethod && members.function == function);
4239 methodPresent = true;
4241 // Delete instance method here
4242 if((this.methodAction == actionDeleteMethod || (this.methodAction == actionDetachMethod && this.moveAttached)) &&
4243 members.function == function)
4245 if(this.moveAttached && !*text)
4246 GetLocText(editBox, f, position, &function.loc, text, textSize, Max((int)strlen(this.methodName) - movedFuncIdLen,0), 0);
4248 DeleteJunkBefore(f, members.loc.start.pos, &position);
4249 f.DeleteBytes(members.loc.end.pos - members.loc.start.pos + 1);
4250 position = members.loc.end.pos + 1;
4255 DeleteJunkBefore(f, position, &position);
4259 DeleteJunkBefore(f, members.loc.start.pos, &position);
4260 lastIsMethod = true;
4264 f.Seek(members.loc.end.pos - position, current);
4265 position = members.loc.end.pos;
4267 DeleteJunkBefore(f, position, &position);
4276 if((this.methodAction == actionAddMethod || (this.moveAttached && (this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod))) && this.selected == object)
4278 Method method = this.method;
4279 DeleteJunkBefore(f, position, &position);
4285 if(!method.dataType)
4286 method.dataType = ProcessTypeString(method.dataTypeString, false);
4289 Type dataType = method.dataType;
4290 Type returnType = dataType.returnType;
4293 if(this.moveAttached)
4295 // Move function here:
4296 int newLen = strlen(method.name);
4301 GetLocText(editBox, f, position, &function.loc, text, textSize, Max(newLen - movedFuncIdLen, 0), 3);
4303 // First change name of function
4304 memmove(*text + movedFuncIdPos + newLen, *text + movedFuncIdPos + movedFuncIdLen, *textSize - movedFuncIdPos - movedFuncIdLen + 1);
4305 *textSize += newLen - movedFuncIdLen;
4306 memcpy(*text + movedFuncIdPos, method.name, newLen);
4308 // Second, tab right
4311 for(c = 0; (*text)[c]; )
4314 for(i = c; (*text)[i] && (*text)[i] != '\n'; i++);
4317 memmove((*text)+c+3, (*text)+c, *textSize+1-c);
4318 (*text)[c] = (*text)[c+1] = (*text)[c+2] = ' ';
4322 for(; (*text)[c] && (*text)[c] != '\n'; c++);
4332 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4334 // ADDING METHOD HERE
4336 OutputType(f, returnType, false);
4339 if(dataType.thisClass)
4341 if(!eClass_IsDerived(regClass, dataType.thisClass.registered) && !dataType.classObjectType) // Just fixed this... was backwards.
4343 if(dataType.thisClass.shortName)
4344 f.Printf(dataType.thisClass.shortName);
4346 f.Printf(dataType.thisClass.string);
4350 f.Printf(method.name);
4352 for(param = dataType.params.first; param; param = param.next)
4354 OutputType(f, param, true);
4359 f.Printf(" %c\n\n", OpenBracket);
4361 if(control._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4363 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4364 f.Printf(" return true;\n");
4365 else if(returnType.kind != voidType)
4366 f.Printf(" return 0;\n");
4371 if(returnType.kind != voidType)
4372 f.Printf("return ");
4373 f.Printf("%s::%s(", control._class.name, method.name);
4374 for(param = dataType.params.first; param; param = param.next)
4376 if(param.prev) f.Printf(", ");
4377 if(param.kind != voidType)
4378 f.Printf(param.name);
4382 f.Printf(" %c\n", CloseBracket);
4388 if(!object.instCode)
4389 f.Printf(methodPresent ? " %c;" : "%c;", CloseBracket);
4390 else if(!object.deleted)
4392 // Turn this into a multiline instance when adding a method
4393 DeleteJunkBefore(f, inst.loc.end.pos-1, &position);
4395 f.Printf(methodPresent ? "\n " : " ");
4397 f.Seek(inst.loc.end.pos + 1 - position, current);
4398 position = inst.loc.end.pos + 1;
4403 void OutputClassProperties(Class _class, ObjectInfo classObject, EditBoxStream f, Instance test)
4406 Class regClass = eSystem_FindClass(privateModule, classObject.name);
4408 if(_class.base && _class.base.type != systemClass) OutputClassProperties(_class.base, classObject, f, test);
4410 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
4412 Property prop = eClass_FindProperty(selected.instance._class, propIt.name, privateModule);
4413 if(prop && prop.isProperty && !prop.conversion)
4415 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(classObject, prop.name) &&
4416 (!prop.IsSet || prop.IsSet(classObject.instance)))
4418 Class dataType = prop.dataTypeClass;
4419 char tempString[1024] = "";
4421 bool specify = false;
4424 member = eClass_FindDataMember(regClass, prop.name, privateModule, null, null);
4425 if(member && member._class == regClass)
4429 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
4431 if(dataType && dataType.type == structClass)
4433 void * dataForm = new0 byte[dataType.structSize];
4434 void * dataTest = new0 byte[dataType.structSize];
4436 ((void (*)(void *, void *))(void *)prop.Get)(classObject.instance, dataForm);
4437 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
4439 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4441 bool needClass = true;
4443 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4444 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4446 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4448 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4453 else if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
4455 void * dataForm, * dataTest;
4456 bool isEditBoxContents = false;
4457 bool freeDataForm = false, freeDataTest = false;
4459 // Because contents property is broken for mutiline EditBox at the moment
4460 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
4461 isEditBoxContents = true;
4463 if(isEditBoxContents && ((EditBox)classObject.instance).multiLine)
4465 dataForm = ((EditBox)classObject.instance).multiLineContents;
4466 freeDataForm = true;
4469 dataForm = ((void *(*)(void *))(void *)prop.Get)(classObject.instance);
4470 if(isEditBoxContents && ((EditBox)test).multiLine)
4472 dataTest = ((EditBox)test).multiLineContents;
4473 freeDataTest = true;
4476 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
4478 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4480 char tempString[1024] = "";
4482 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4484 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
4486 // Shouldn't go here ...
4487 f.Printf("\n %s%s = this;", specify ? "property::" : "", prop.name);
4491 bool needClass = true;
4493 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4495 if(!strcmp(dataType.dataTypeString, "char *"))
4497 Map<String, bool> i18nStrings = classObject.i18nStrings;
4499 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
4502 f.Printf("\n %s%s = %s\"", specify ? "property::" : "", prop.name, i18n ? "$" : "");
4503 OutputString(f, string);
4507 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4509 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4512 if(freeDataForm) delete dataForm;
4513 if(freeDataTest) delete dataTest;
4517 DataValue dataForm, dataTest;
4519 GetProperty(prop, classObject.instance, &dataForm);
4520 GetProperty(prop, test, &dataTest);
4522 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
4524 SetProperty(prop, test, dataForm);
4525 if(dataType.type == bitClass)
4527 bool needClass = true;
4528 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4530 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4532 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4536 bool needClass = true;
4537 if(dataType.type == enumClass)
4540 Class enumClass = eSystem_FindClass(privateModule, "enum");
4541 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
4543 for(value = e.values.first; value; value = value.next)
4545 if((int)value.data == dataForm.i)
4547 string = value.name;
4553 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4554 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
4555 f.Printf("\n %s%s = %sf;", specify ? "property::" : "", prop.name, string);
4557 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4566 void UpdateFormCode()
4569 if(!parsing) return;
4576 else if(formModified)
4578 EditBoxStream f { editBox = editBox };
4582 Identifier movedFuncId;
4583 int movedFuncIdLen = 0, movedFuncIdPos = 0;
4584 ObjectInfo classObject;
4588 editBox.recordUndoEvent = true;
4592 movedFuncId = GetDeclId(function.declarator);
4593 movedFuncIdLen = movedFuncId.loc.end.pos - movedFuncId.loc.start.pos;
4594 movedFuncIdPos = movedFuncId.loc.start.pos - function.loc.start.pos;
4597 for(classObject = classes.first; classObject; classObject = classObject.next)
4599 ClassDefinition classDef = classObject.classDefinition;
4600 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
4603 bool firstObject = true;
4604 ObjectInfo object = classObject.instances.first;
4605 bool lastIsDecl = false;
4607 if(!classObject.modified) continue;
4609 test = eInstance_New(regClass);
4612 // Put it in the same desktop window...
4613 designer.PrepareTestObject(test);
4615 //f.Printf("class %s : %s\n", classObject.name, classObject.oClass.name);
4616 //f.Printf("%c\n\n", OpenBracket);
4618 // Change the _class name
4619 f.Seek(classDef.nameLoc.start.pos - position, current);
4620 f.DeleteBytes(classDef.nameLoc.end.pos - classDef.nameLoc.start.pos);
4621 f.Printf(classObject.name);
4622 position = classDef.nameLoc.end.pos;
4625 // Go to block start, delete all until no white space, put \n
4629 f.Seek(classDef.blockStart.end.pos - position, current);
4630 position = classDef.blockStart.end.pos;
4632 for(; f.Getc(&ch); count++)
4636 f.Seek(-1, current);
4646 f.Seek(-count, current);
4648 f.DeleteBytes(count-back);
4650 position += count-back;
4653 // Output properties
4654 OutputClassProperties(classObject.instance._class, classObject, f, test);
4656 for(def = classDef.definitions->first; def; def = def.next)
4660 case defaultPropertiesClassDef:
4662 bool keptMember = false;
4664 MemberInit lastKept = null;
4667 DeleteJunkBefore(f, def.loc.start.pos, &position);
4669 // This was adding blank spaces between comment and properties -- What was it for?
4672 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4674 Identifier ident = propDef.identifiers->first;
4675 bool deleted = false;
4677 // For now delete if it's a prop
4678 if(!propDef.variable && ident)
4682 Property prop = eClass_FindProperty(regClass, ident.string, this.privateModule);
4685 f.Seek(propDef.loc.start.pos - position, current);
4686 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4687 position = propDef.loc.end.pos;
4692 Method method = eClass_FindMethod(regClass, ident.string, this.privateModule);
4693 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4695 if(((methodAction == actionDetachMethod || methodAction == actionReattachMethod) && method == this.method && selected == classObject) ||
4696 (methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string)))
4698 f.Seek(propDef.loc.start.pos - position, current);
4699 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4700 position = propDef.loc.end.pos;
4717 f.Seek(def.loc.end.pos - position - 1, current);
4722 f.Seek(-1, current);
4725 position = def.loc.end.pos;
4729 if(lastKept != def.defProperties->last)
4734 f.Seek(-1, current);
4740 f.Seek(-1, current);
4743 else if(!isspace(ch))
4745 f.Seek(-2, current);
4750 f.DeleteBytes(count);
4754 f.Seek(def.loc.end.pos - position, current);
4755 position = def.loc.end.pos;
4760 case declarationClassDef:
4762 Declaration decl = def.decl;
4764 if(decl.type == instDeclaration)
4766 if(def.object/* && ((ObjectInfo)def.object).modified*/)
4768 while(def.object && object != def.object)
4770 if(object /*&& ((ObjectInfo)def.object).modified*/)
4771 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4772 object = object.next;
4775 DeleteJunkBefore(f, def.loc.start.pos, &position);
4776 f.Printf(firstObject ? "\n\n " : "\n ");
4777 firstObject = false;
4779 if(def.object && ((ObjectInfo)def.object).modified)
4780 position = UpdateInstanceCode(f, position, regClass, def.object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4782 object = object ? object.next : null;
4786 DeleteJunkBefore(f, def.loc.start.pos, &position);
4787 f.Printf(firstObject ? "\n\n " : "\n ");
4788 firstObject = false;
4794 DeleteJunkBefore(f, def.loc.start.pos, &position);
4795 f.Printf(lastIsDecl ? "\n " : "\n\n ");
4800 case functionClassDef:
4802 // TESTING IF THIS IS GOOD ENOUGH FOR GENERATED FUNCTION...
4803 if(!def.function.body) continue;
4807 DeleteJunkBefore(f, def.loc.start.pos, &position);
4810 // Delete _class methods
4811 if((methodAction == actionDeleteMethod || (moveAttached && selected != classObject)) &&
4812 def.function == function)
4817 if(moveAttached && !text)
4819 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max((int)strlen(methodName) - movedFuncIdLen,0), 3);
4822 f.Seek(def.loc.end.pos - position, current);
4823 for(; f.Getc(&ch); count++)
4827 f.Seek(-1, current);
4831 f.Seek(def.loc.start.pos - def.loc.end.pos - count, current);
4833 f.DeleteBytes(def.loc.end.pos - def.loc.start.pos + count);
4834 position = def.loc.end.pos + count;
4837 // In case of detaching methods in the _class, simply rename the method
4838 if(methodAction == actionDetachMethod && moveAttached && selected == classObject && function == def.function)
4840 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4841 f.DeleteBytes(movedFuncIdLen);
4843 position = function.loc.start.pos + movedFuncIdPos + movedFuncIdLen;
4846 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && moveAttached &&
4847 function == def.function)
4849 // In case of attaching methods in the _class, simply rename the method
4850 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4851 position = function.loc.start.pos + movedFuncIdPos;
4852 f.DeleteBytes(movedFuncIdLen);
4853 if(method.dataType.thisClass)
4854 f.Printf("%s::", method.dataType.thisClass.string);
4855 f.Puts(method.name);
4856 position += movedFuncIdLen;
4861 DeleteJunkBefore(f, def.loc.start.pos, &position);
4862 if(def.type == memberAccessClassDef)
4865 firstObject = false;
4875 f.Seek(def.loc.end.pos - position, current);
4876 position = def.loc.end.pos;
4879 // Output attached methods
4880 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && !moveAttached)
4882 DeleteJunkBefore(f, position, &position);
4883 f.Printf("\n %s = %s;\n", method.name, function.declarator.symbol.string);
4886 // ********** INSTANCES ***************
4887 for(; object; object = object.next)
4889 if(!object.instCode)
4891 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4895 DeleteJunkBefore(f, position, &position);
4897 // ****************** METHODS ***********************
4898 if(methodAction == actionDetachMethod && moveAttached && classObject == oClass)
4900 // If detaching an instance method
4901 if(selected != classObject)
4903 int newLen = strlen(methodName);
4906 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max(newLen - movedFuncIdLen,0), 0);
4907 // Tab selection left
4910 for(c = 0; text[c]; )
4913 for(i = 0; i<3 && text[c] == ' '; i++, c++);
4914 memmove(text+start, text+start+i, textSize+1-start-i);
4917 for(; text[c] && text[c] != '\n'; c++);
4923 memmove(text + movedFuncIdPos + newLen, text + movedFuncIdPos + movedFuncIdLen, textSize - movedFuncIdPos - movedFuncIdLen + 1);
4924 textSize += newLen - movedFuncIdLen;
4925 memcpy(text + movedFuncIdPos, methodName, newLen);
4932 if(methodAction == actionAddMethod && selected == classObject)
4934 Method method = this.method;
4936 if(!method.dataType)
4937 method.dataType = ProcessTypeString(method.dataTypeString, false);
4939 // ADDING METHOD HERE
4941 Type dataType = method.dataType;
4942 Type returnType = dataType.returnType;
4944 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4948 OutputType(f, returnType, false);
4951 if(dataType.thisClass && !dataType.classObjectType)
4953 if(dataType.thisClass.shortName)
4954 f.Printf(dataType.thisClass.shortName);
4956 f.Printf(dataType.thisClass.string);
4959 f.Printf(method.name);
4961 for(param = dataType.params.first; param; param = param.next)
4963 OutputType(f, param, true);
4968 f.Printf(" %c\n\n", OpenBracket);
4970 if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4972 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4973 f.Printf(" return true;\n");
4974 else if(returnType && returnType.kind != voidType)
4975 f.Printf(" return 0;\n");
4980 if(returnType.kind != voidType)
4981 f.Printf("return ");
4983 char * name = ((Specifier)classDef.baseSpecs->first).name;
4984 Symbol _class = FindClass(name);
4985 f.Printf("%s::%s(", (_class && _class.registered) ? _class.registered.name : name, method.name);
4987 for(param = dataType.params.first; param; param = param.next)
4989 if(param.prev) f.Printf(", ");
4990 if(param.kind != voidType)
4991 f.Printf(param.name);
4996 f.Printf(" %c", CloseBracket);
5000 DeleteJunkBefore(f, classDef.loc.end.pos-1, &position);
5006 editBox.recordUndoEvent = false;
5014 // TOFIX: Patch for a glitch where clicking at the end of the view seems one line off. No idea what could be going on?
5015 editBox.OnVScroll(setRange, editBox.scroll.y, 0);
5019 codeModified = false;
5020 formModified = false;
5022 moveAttached = false;
5027 int FindMethod(const char * methodName /*Method method*/, ClassFunction*functionPtr, Location propLoc)
5030 ClassFunction function = null;
5033 ObjectInfo object = this.selected;
5035 if(object && object == this.oClass)
5037 ClassDefinition classDef = object.oClass.classDefinition;
5039 if(classDef && classDef.definitions)
5041 for(def = classDef.definitions->first; def; def = def.next)
5043 if(def.type == functionClassDef && def.function.declarator)
5045 if(!strcmp(def.function.declarator.symbol.string, methodName))
5047 function = def.function;
5052 else if(def.type == defaultPropertiesClassDef)
5056 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
5058 Identifier ident = propDef.identifiers ? propDef.identifiers->first : null;
5059 if(ident && !ident.next)
5061 if(!strcmp(ident.string, methodName) && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
5065 propLoc = propDef.loc;
5068 ClassDefinition classDef = object.oClass.classDefinition;
5070 if(classDef.definitions)
5072 for(def = classDef.definitions->first; def; def = def.next)
5074 if(def.type == functionClassDef)
5076 if(!strcmp(def.function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
5078 function = def.function;
5097 Instantiation inst = object.instCode;
5099 // Check here to see if the method already exists, no need to call ModifyCode in that case
5100 if(inst && inst.members)
5102 MembersInit members;
5103 for(members = inst.members->first; members; members = members.next)
5105 switch(members.type)
5107 case dataMembersInit:
5109 if(members.dataMembers)
5112 for(member = members.dataMembers->first; member; member = member.next)
5114 Identifier ident = member.identifiers ? member.identifiers->first : null;
5115 if(ident && !ident.next)
5117 if(!strcmp(ident.string, methodName) && member.initializer && member.initializer.type == expInitializer && member.initializer.exp && member.initializer.exp.type == memberExp /*ExpIdentifier*/)
5121 propLoc = member.loc;
5124 ClassDefinition classDef = object.oClass.classDefinition;
5126 if(classDef.definitions)
5128 for(def = classDef.definitions->first; def; def = def.next)
5130 if(def.type == functionClassDef)
5132 if(def.function.declarator && !strcmp(def.function.declarator.symbol.string, member.initializer.exp.identifier.string))
5134 function = def.function;
5143 // TODO: Fix memory leak
5144 function = ClassFunction
5146 declarator = Declarator { symbol = Symbol { string = CopyString(member.initializer.exp.member.member ? member.initializer.exp.member.member.string : "") } }
5158 case methodMembersInit:
5160 if(members.function.declarator && !strcmp(members.function.declarator.symbol.string, methodName))
5162 function = members.function;
5174 if(functionPtr) *functionPtr = function;
5178 void GoToMethod(const char * methodName /*Method method*/)
5182 ObjectInfo object = selected;
5183 EditBoxStream f { editBox = editBox };
5184 ClassFunction function = null;
5185 bool atChar = false;
5189 Location propLoc = { {0,0,-1} };
5192 if(FindMethod(methodName, &function, &propLoc) == 1 && object != this.oClass) indent = 9;
5193 if(function && function.body)
5196 f.Seek(function.body.loc.start.pos+1, current);
5206 f.Seek(-1, current);
5211 else if(!isspace(ch))
5213 f.Seek(-1, current);
5219 else if(propLoc.start.pos > -1)
5221 f.Seek(propLoc.start.pos, current);
5224 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
5226 if(function || propLoc.start.pos > -1)
5228 editBox.SetSelPos(l1, y1, atChar ? x1 : indent, l2, y2, atChar ? x2 : indent);
5229 editBox.CenterOnCursor();
5230 SetState(normal, false, 0);
5233 if(function && function.declarator && function.declarator.symbol && !function.declarator.symbol.type)
5235 FreeClassFunction(function);
5241 void FindCompatibleMethods(Method method, OldList compatible)
5243 ClassDefinition classDef = this.oClass.classDefinition;
5244 if(classDef && classDef.definitions)
5247 Class baseClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5250 Symbol classSym { };
5251 Symbol selectedClass;
5252 if(this.selected == this.oClass)
5253 selectedClass = classSym;
5255 selectedClass = FindClass(this.selected.instance._class.name);
5257 regClass.name = classDef._class.name;
5258 regClass.base = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5259 for(def = classDef.definitions->first; def; def = def.next)
5261 if(def.type == functionClassDef && def.function.declarator)
5263 Method vMethod = eClass_FindMethod(baseClass, def.function.declarator.symbol.string, this.privateModule);
5265 vMethod = eClass_FindMethod(this.selected.instance._class, def.function.declarator.symbol.string, this.privateModule);
5268 Type type = def.function.declarator.symbol.type;
5269 if(CheckCompatibleMethod(method, type, regClass, this.selected == this.oClass, FindClass(this.selected.instance._class.name)))
5271 compatible.Add(OldLink { data = def.function });
5277 if(this.oClass && this.oClass.instance)
5279 classSym.registered = regClass;
5280 //classSym.registered = this.oClass.oClass;
5282 for(_class = regClass.base; _class; _class = _class.base)
5285 for(testMethod = (Method)_class.methods.first; testMethod; testMethod = (Method)((BTNode)testMethod).next)
5287 // TODO: Understand why these functions popup in attach list
5288 if(testMethod.type != virtualMethod /*&& testMethod.function != Window_OnGetString && testMethod.function != Window_OnGetDataFromString*/)
5290 if(!testMethod.dataType)
5291 testMethod.dataType = ProcessTypeString(testMethod.dataTypeString, false);
5293 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5294 if(CheckCompatibleMethod(method, testMethod.dataType, this.oClass.instance._class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5295 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, this.selected == this.oClass, FindClass(this.oClass.oClass.name)))
5297 // TODO: Fix memory leak, Figure out if it should be ClassFunction or FunctionDefinition
5298 // ClassFunction function { };
5299 FunctionDefinition function { };
5301 function.declarator = Declarator { };
5302 function.declarator.symbol = Symbol { string = CopyString(testMethod.name) };
5303 excludedSymbols.Add(function.declarator.symbol);
5305 compatible.Add(OldLink { data = function });
5316 void AddMethod(Method method)
5320 char methodName[1024];
5321 strcpy(methodName, method.name);
5322 if(!FindMethod(methodName, null, null))
5324 methodAction = actionAddMethod;
5325 this.method = method;
5329 GoToMethod(methodName);
5333 void DeleteMethod(ClassFunction function)
5337 methodAction = actionDeleteMethod;
5338 this.function = function;
5346 void AttachMethod(Method method, ClassFunction function)
5350 // If it's an instance we'll ask if we want to move it inside...
5351 if(!function.attached.count && function.body)
5353 // Find the function in the _class to check if it's a virtual function
5354 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5355 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5356 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5358 for(def = this.classDefinition.first; def; def = def.next)
5360 if(def.type == functionClassDef)
5362 if(def.function == function)
5367 if(!method || method.type != virtualMethod)
5370 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5371 if(MessageBox { type = yesNo, master = parent, text = title, contents = $"Method is unused. Move method inside instance?"}.Modal() == yes)
5373 moveAttached = true;
5378 methodAction = actionAttachMethod;
5379 this.method = method;
5380 this.function = function;
5387 void ReAttachMethod(Method method, ClassFunction function)
5391 // If it's an instance we'll ask if we want to move it inside...
5392 if(!function.attached.count && function.body)
5394 // Find the function in the _class to check if it's a virtual function
5395 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5396 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5397 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5399 for(def = this.classDefinition.first; def; def = def.next)
5401 if(def.type == functionClassDef)
5403 if(def.function == function)
5408 if(!method || method.type != virtualMethod)
5411 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5412 if(MessageBox { type = yesNo, master = parent, text = title,
5413 contents = $"Method is unused. Move method inside instance?" }.Modal() == yes)
5415 moveAttached = true;
5420 methodAction = actionReattachMethod;
5421 this.method = method;
5422 this.function = function;
5429 void DetachMethod(Method method, ClassFunction function, int type)
5437 hasClose = true, borderStyle = sizable, minClientSize = { 300, 55 },
5438 master = sheet, text = $"Name detached method", background = formColor
5442 dialog, anchor = { horz = 45, top = 30 }, size = { 80 }, text = $"Cancel", hotKey = escape,
5443 id = DialogResult::cancel, NotifyClicked = ButtonCloseDialog
5447 dialog, anchor = { horz = -45, top = 30 }, size = { 80 }, text = $"OK", isDefault = true,
5448 id = DialogResult::ok, NotifyClicked = ButtonCloseDialog
5452 dialog, anchor = { left = 5, right = 5, top = 5 }
5454 sprintf(methodName, "%s_%s", selected.name, method.name);
5455 nameBox.contents = methodName;
5457 result = dialog.Modal() == ok;
5458 strcpy(methodName, nameBox.contents);
5463 // If the method is not attached, move it outside
5466 // Add this class to the methodName
5467 char name[1024] = "";
5469 if(this.selected != this.oClass && !method.dataType.thisClass)
5471 strcat(name, this.selected.instance._class.name);
5473 strcat(name, this.methodName);
5474 strcpy(this.methodName, name);
5476 else if(method.dataType.thisClass && (this.selected == this.oClass || !eClass_IsDerived(this.oClass.instance._class, method.dataType.thisClass.registered)))
5478 strcat(name, method.dataType.thisClass.string);
5480 strcat(name, this.methodName);
5481 strcpy(this.methodName, name);
5484 this.moveAttached = true;
5487 this.methodAction = actionDetachMethod;
5488 this.method = method;
5489 this.function = function;
5496 void AddObject(Instance instance, ObjectInfo * object)
5500 //*object = _class.instances.Add(sizeof(ObjectInfo));
5501 *object = ObjectInfo { };
5502 oClass.instances.Insert((selected.oClass == selected) ? null : selected, *object);
5503 (*object).oClass = oClass;
5504 (*object).instance = instance;
5509 sprintf(name, "%c%s%d", tolower(instance._class.name[0]), instance._class.name+1, id);
5511 // if(strcmp(name, this.oClass.instance.name))
5514 for(check = oClass.instances.first; check; check = check.next)
5515 if(!check.deleted && check.name && !strcmp(name, check.name))
5519 (*object).name = CopyString(name);
5524 toolBox.controlClass = null;
5528 //sheet.AddObject(*object, (*object).name, TypeData, true);
5533 void EnsureUpToDate()
5535 if(sheet && codeModified && parsing)
5539 void SelectObject(ObjectInfo object)
5542 oClass = object ? object.oClass : null;
5544 designer.SelectObject(object, object ? object.instance : null);
5547 void SelectObjectFromDesigner(ObjectInfo object)
5550 sheet.SelectObject(object);
5553 void EnumerateObjects(Sheet sheet)
5557 for(oClass = classes.first; oClass; oClass = oClass.next)
5563 sheet.AddObject(oClass, oClass.name ? oClass.name : oClass.instance._class.name, typeClass, false);
5564 for(object = oClass.instances.first; object; object = object.next)
5565 sheet.AddObject(object, object.name ? object.name : object.instance._class.name, typeData, false);
5568 sheet.SelectObject(selected);
5573 designer.AddObject();
5576 void DeleteObject(ObjectInfo object)
5578 delete object.instance;
5579 object.deleted = true;
5580 object.modified = true;
5581 object.oClass.modified = true;
5583 if(selected == object)
5585 bool looped = false;
5586 ObjectInfo select = object;
5590 select = select.prev;
5594 select = object.oClass.instances.last;
5601 sheet.SelectObject(select ? select : oClass);
5604 if(!object.instCode && object.oClass != object)
5607 oClass.instances.Delete(object);
5610 if(sheet.codeEditor == this)
5611 sheet.DeleteObject(object);
5614 void RenameObject(ObjectInfo object, const char * name)
5618 // Validate the name:
5619 if(object != oClass && (!name || !name[0])) valid = true; // What's this one again?
5620 else if(name[0] && (isalpha(name[0]) || name[0] == '_'))
5623 for(c = 0; name[c]; c++)
5624 if(!isalnum(name[c]) && name[c] != '_' && name[c] != '_')
5632 object.name = (name && name[0]) ? CopyString(name) : null;
5634 sheet.RenameObject(object, object.name ? object.name : object.instance._class.name);
5638 void DesignerModifiedObject()
5640 sheet.ListProperties(false);
5644 void ListSubMembers(Type member)
5648 for(subMember = member.members.first; subMember; subMember = subMember.next)
5652 DataRow row = membersList.AddString(subMember.name);
5653 row.icon = icons[typeData];
5657 ListSubMembers(subMember);
5662 void ListSubDataMembers(DataMember member, bool isPrivate)
5664 DataMember subMember;
5665 for(subMember = member.members.first; subMember; subMember = subMember.next)
5667 if((subMember.memberAccess == publicAccess && !isPrivate) || subMember._class.module == privateModule)
5671 DataRow row = membersList.AddString(subMember.name);
5672 BitmapResource bitmap = null;
5673 if(!subMember.dataType)
5674 subMember.dataType = ProcessTypeString(subMember.dataTypeString, false);
5676 if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
5678 char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
5681 bitmap = { bitmapName };
5682 membersList.AddResource(bitmap);
5685 row.icon = bitmap ? bitmap : icons[(subMember.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5689 ListSubDataMembers(subMember, isPrivate || member.memberAccess == privateAccess);
5695 void ListClassMembers(Class whatClass, bool methodsOnly)
5698 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5699 bool isPrivate = false;
5701 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5703 Method method, methodIt;
5705 DataMember memberIt;
5707 for(methodIt = (Method)_class.methods.first; methodIt; methodIt = (Method)((BTNode)methodIt).next)
5709 method = eClass_FindMethod(whatClass, methodIt.name, privateModule);
5710 if(methodIt.memberAccess == privateAccess && method && method.memberAccess == publicAccess)
5712 if(method && method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5714 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5716 DataRow row = membersList.FindString(method.name);
5719 row = membersList.AddString(method.name);
5721 if(!method.dataType)
5722 method.dataType = ProcessTypeString(method.dataTypeString, false);
5724 row.icon = icons[(method.type == virtualMethod && method.dataType && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5732 for(memberIt = _class.membersAndProperties.first; memberIt; memberIt = memberIt.next)
5736 if(memberIt.isProperty)
5738 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5740 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5744 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5746 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5749 if(memberIt.memberAccess == privateAccess && member && member.memberAccess == publicAccess)
5755 if(member && (member.memberAccess == publicAccess || member._class.module == privateModule))
5757 if(member.isProperty)
5759 Property prop = (Property) member;
5760 if(!membersList.FindString(prop.name))
5762 DataRow row = membersList.AddString(prop.name);
5763 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5766 else if(member.name && !membersList.FindString(member.name))
5768 DataRow row = membersList.AddString(member.name);
5770 BitmapResource bitmap = null;
5771 if(!member.dataType)
5772 member.dataType = ProcessTypeString(member.dataTypeString, false);
5774 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5776 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5779 bitmap = { bitmapName };
5780 membersList.AddResource(bitmap);
5783 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5786 ListSubDataMembers(member, member.memberAccess == privateAccess);
5790 if(_class.inheritanceAccess == privateAccess)
5793 if(_class.module != privateModule) break;
5798 void ListClassMembersMatch(Class whatClass, Type methodType)
5801 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5802 bool isPrivate = false;
5804 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5808 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5810 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5812 if(method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5814 if(!method.dataType)
5815 method.dataType = ProcessTypeString(method.dataTypeString, false);
5817 if(MatchTypes(method.dataType, methodType, null, whatClass, /*null, */whatClass, false, true, false, false, true))
5819 DataRow row = membersList.FindString(method.name);
5822 row = membersList.AddString(method.name);
5823 row.icon = icons[(method.type == virtualMethod && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5829 if(_class.inheritanceAccess == privateAccess)
5832 if(_class.module != privateModule) break;
5837 void ListClassPropertiesAndVirtual(Class whatClass, const String curString)
5840 bool isPrivate = false;
5841 for(_class = whatClass; _class /*&& _class.type != systemClass*/; _class = _class.base)
5846 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5848 if(method.type == virtualMethod)
5850 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5852 DataRow row = membersList.FindString(method.name);
5855 row = membersList.AddString(method.name);
5857 if(!method.dataType)
5858 method.dataType = ProcessTypeString(method.dataTypeString, false);
5860 row.icon = icons[method.dataType.thisClass ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5866 for(member = _class.membersAndProperties.first; member; member = member.next)
5868 if(member.memberAccess == publicAccess || member._class.module == privateModule)
5870 if(member.isProperty)
5872 Property prop = (Property)member;
5874 DataRow row = membersList.AddString(prop.name);
5875 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5878 else if(member.name && (!curString || strcmp(curString, member.name)))
5880 DataRow row = membersList.AddString(member.name);
5882 BitmapResource bitmap = null;
5883 if(!member.dataType)
5884 member.dataType = ProcessTypeString(member.dataTypeString, false);
5886 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5888 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5891 bitmap = { bitmapName };
5892 membersList.AddResource(bitmap);
5895 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5898 ListSubDataMembers(member, member.memberAccess == privateAccess || isPrivate);
5901 if(_class.inheritanceAccess == privateAccess)
5904 if(_class.module != privateModule) break;
5909 void ListMembers(Type type)
5911 if(type && (type.kind == classType || type.kind == structType || type.kind == unionType))
5913 if(type.kind == classType)
5916 ListClassMembers(type._class.registered, false);
5921 for(member = type.members.first; member; member = member.next)
5925 DataRow row = membersList.AddString(member.name);
5926 row.icon = icons[typeData];
5928 else if(member.kind == structType || member.kind == unionType)
5929 ListSubMembers(member);
5935 void ListModule(Module mainModule, int recurse, bool listClasses)
5938 ListNameSpace(mainModule.application.systemNameSpace, 1, listClasses);
5939 ListNameSpace(mainModule.application.privateNameSpace, 1, listClasses);
5940 ListNameSpace(mainModule.application.publicNameSpace, 1, listClasses);
5941 for(module = mainModule.application.allModules.first; module; module = module.next)
5943 if(ModuleVisibility(mainModule, module))
5944 ListNameSpace(module.publicNameSpace, recurse, listClasses);
5948 void ListNameSpace(NameSpace nameSpace, int recurse, bool listClasses)
5955 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5957 Class _class = link.data;
5958 if(_class.type != systemClass && !_class.templateClass) // Omit templatized classes
5960 DataRow row = membersList.AddString(_class.name);
5961 row.icon = (_class.type == unitClass || _class.type == enumClass) ? icons[typeDataType] : icons[typeClass];
5966 for(link = (BTNamedLink)nameSpace.defines.first; link; link = (BTNamedLink)((BTNode)link).next )
5968 //DefinedExpression definedExp = link.data;
5969 DataRow row = membersList.AddString(link /*definedExp*/.name);
5970 row.icon = icons[typeData];
5973 for(link = (BTNamedLink)nameSpace.functions.first; link; link = (BTNamedLink)((BTNode)link).next)
5975 //GlobalFunction function = link.data;
5976 DataRow row = membersList.AddString(link /*function*/.name);
5977 row.icon = icons[typeMethod];
5981 for(ns = (NameSpace *)nameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
5983 if(recurse != 2 && listClasses)
5985 if(!membersList.FindString(ns->name))
5987 DataRow row = membersList.AddString(ns->name);
5988 row.icon = icons[typeNameSpace];
5993 ListNameSpace(ns, 2, listClasses);
5997 void ListEnumValues(Class _class)
5999 List<Class> classes { };
6000 for(; _class && _class.type == enumClass; _class = _class.base)
6001 classes.Insert(null, _class);
6002 for(_class : classes)
6004 EnumClassData enumeration = (EnumClassData)_class.data;
6006 for(item = enumeration.values.first; item; item = item.next)
6008 DataRow row = membersList.AddString(item.name);
6009 row.icon = icons[typeEnumValue];
6015 bool ListEnumsModule(Module mainModule, Type dest)
6017 bool result = false;
6019 result |= ListEnums(mainModule.application.systemNameSpace, dest);
6020 result |= ListEnums(mainModule.application.privateNameSpace, dest);
6021 result |= ListEnums(mainModule.application.publicNameSpace, dest);
6022 for(module = mainModule.application.allModules.first; module; module = module.next)
6024 if(ModuleVisibility(mainModule, module))
6025 result |= ListEnums(module.publicNameSpace, dest);
6030 void ListNameSpaceByString(Module mainModule, const char * string)
6032 NameSpace * nameSpace;
6034 nameSpace = FindNameSpace(mainModule.application.systemNameSpace, string);
6035 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6036 nameSpace = FindNameSpace(mainModule.application.privateNameSpace, string);
6037 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6038 nameSpace = FindNameSpace(mainModule.application.publicNameSpace, string);
6039 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6040 for(module = mainModule.application.allModules.first; module; module = module.next)
6042 if(ModuleVisibility(mainModule, module))
6044 nameSpace = FindNameSpace(module.publicNameSpace, string);
6045 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6050 bool ListEnums(NameSpace nameSpace, Type dest)
6053 bool result = false;
6055 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
6057 Class _class = link.data;
6058 if(_class.type == enumClass && (dest.kind != classType || ((!dest._class || !dest._class.registered || (dest._class.registered != _class && strcmp(dest._class.registered.dataTypeString, "char *"))) && !dest.classObjectType)) &&
6059 dest.kind != pointerType && dest.kind != ellipsisType)
6061 OldList conversions { };
6063 type.kind = classType;
6064 type._class = FindClass(_class.name);
6065 if(MatchTypes(type, dest, &conversions, null, null, true, false, false, false, true))
6067 ListEnumValues(_class);
6070 conversions.Free(null);
6074 for(nameSpace = (NameSpace *)nameSpace.nameSpaces.first; nameSpace != null; nameSpace = (NameSpace *)((BTNode)nameSpace).next)
6076 result |= ListEnums(nameSpace, dest);
6081 NameSpace * FindNameSpace(NameSpace nameSpace, const char * name)
6085 for(c = 0; (ch = name[c]); c++)
6087 if(ch == '.' || (ch == ':' && name[c+1] == ':'))
6089 NameSpace * newSpace;
6090 char * spaceName = new char[c - start + 1];
6091 memcpy(spaceName, name + start, c - start);
6092 spaceName[c-start] = '\0';
6093 newSpace = (NameSpace *)nameSpace.nameSpaces.FindString(spaceName);
6097 nameSpace = newSpace;
6106 return (NameSpace *)nameSpace;
6109 void ListSymbols(Expression exp, bool enumOnly, const char * string, Identifier realIdentifier)
6111 bool listedEnums = false;
6112 Type destType = (exp && exp.destType && !exp.destType.truth) ? exp.destType : null;
6113 bool listClasses = true;
6115 if(exp && (exp.type == identifierExp || exp.type == memberExp))
6117 // TOCHECK: This memberExp check wasn't here... Some stuff isn't quite done
6118 Identifier id = (exp.type == memberExp) ? exp.member.member : exp.identifier;
6119 char * colons = id ? RSearchString(id.string, "::", strlen(id.string), true, false) : null;
6121 if(exp.type == identifierExp)
6122 id = realIdentifier;
6124 if(id && id._class && !id._class.name)
6126 listClasses = false;
6129 else if(id && id._class && id._class.name)
6133 Class _class = id.classSym.registered;
6134 if(_class && _class.type == enumClass)
6136 ListEnumValues(_class);
6139 ListClassMembers(id.classSym.registered, true);
6144 else if(id && colons)
6146 ListNameSpaceByString(this.privateModule, id.string);
6151 if(this.privateModule && destType && (destType.kind == _BoolType || destType.kind == classType || destType.kind == enumType || destType.kind == structType || destType.kind == templateType || destType.kind == thisClassType || destType.kind == unionType ||
6152 (destType.kind == pointerType && destType.type.kind != voidType)))
6153 //if(this.privateModule && destType && (destType.kind != pointerType || destType.type.kind != voidType) && destType.kind != ellipsisType)
6155 listedEnums = ListEnumsModule(this.privateModule, destType);
6158 if(destType && destType.kind == classType && destType._class.registered && destType._class.registered.type == enumClass)
6160 ListEnumValues(destType._class.registered);
6163 ListClassPropertiesAndVirtual(insideClass, null);
6167 else if(destType && destType.kind == enumType)
6171 for(value = destType.members.first; value; value = value.next)
6173 DataRow row = membersList.AddString(value.name);
6174 row.icon = icons[typeEnumValue];
6178 ListClassPropertiesAndVirtual(insideClass, null);
6182 else if(insideClass && !enumOnly)
6184 ListClassPropertiesAndVirtual(insideClass, string);
6187 if(listedEnums && string && string[0])
6189 DataRow row = membersList.FindSubString(string);
6191 listedEnums = false;
6194 if(!insideClass && exp && exp.destType && exp.destType.kind == functionType && GetThisClass())
6196 ListClassMembersMatch(GetThisClass(), exp.destType);
6198 else if(!insideClass && !enumOnly && !listedEnums)
6201 Symbol symbol = null;
6205 ListClassMembers(GetThisClass(), false);
6208 for(ctx = listClasses ? GetCurrentContext() : GetTopContext(); ctx != GetTopContext().parent && !symbol; ctx = ctx.parent)
6210 for(symbol = (Symbol)ctx.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6212 // Don't list enum values?
6213 //if(symbol.type.kind != TypeEnum)
6214 DataRow row = membersList.FindString(symbol.string);
6217 if(GetBuildingEcereComModule() && symbol.type && symbol.type.kind == functionType && eSystem_FindFunction(privateModule, symbol.string))
6219 row = membersList.AddString(symbol.string);
6220 if(symbol.type && symbol.type.kind == functionType)
6221 row.icon = icons[typeMethod];
6222 else if(symbol.type && symbol.type.kind == enumType)
6224 row.icon = icons[typeEnumValue];
6228 BitmapResource bitmap = null;
6229 if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
6231 char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
6234 bitmap = { bitmapName };
6235 membersList.AddResource(bitmap);
6238 row.icon = bitmap ? bitmap : icons[typeData];
6245 for(symbol = (Symbol)ctx.types.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6247 DataRow row = membersList.FindString(symbol.string);
6250 row = membersList.AddString(symbol.string);
6251 if(symbol.type.kind == functionType)
6252 row.icon = icons[typeMethod];
6253 else if(symbol.type.kind == classType && (!symbol.type._class.registered || (symbol.type._class.registered.type != unitClass && symbol.type._class.registered.type != enumClass)))
6255 row.icon = icons[typeClass];
6259 row.icon = icons[typeDataType];
6266 ListModule(this.privateModule, 1, listClasses);
6267 // TODO: Implement this with name space
6271 for(data = globalData.first; data; data = data.next)
6273 DataRow row = membersList.FindString(data.name);
6275 data.dataType = ProcessTypeString(data.dataTypeString, false);
6278 row = membersList.AddString(data.name);
6280 if(data.dataType && data.dataType.kind == TypeEnum)
6282 row.icon = icons[typeEnumValue];
6286 BitmapResource bitmap = null;
6287 if(data.dataType && data.dataType.kind == classType && data.dataType._class && data.dataType._class)
6289 char * bitmapName = (char *)eClass_GetProperty(data.dataType._class.registered, "icon");
6292 bitmap = { bitmapName };
6293 membersList.AddResource(bitmap);
6296 row.icon = bitmap ? bitmap : icons[typeData];
6304 DataRow row = membersList.AddString("Min");
6305 row.icon = icons[typeMethod];
6307 row = membersList.AddString("Max");
6308 row.icon = icons[typeMethod];
6310 row = membersList.AddString("Abs");
6311 row.icon = icons[typeMethod];
6313 row = membersList.AddString("Sgn");
6314 row.icon = icons[typeMethod];
6320 void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
6322 EditBoxStream f { editBox = editBox };
6327 updatingCode = true;
6329 if(!method.dataType)
6330 method.dataType = ProcessTypeString(method.dataTypeString, false);
6332 DeleteJunkBefore(f, function.loc.start.pos, &position);
6333 f.DeleteBytes(function.loc.end.pos - function.loc.start.pos - 1);
6335 // ADDING METHOD HERE
6337 Type dataType = method.dataType;
6338 Type returnType = dataType.returnType;
6340 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
6346 if(extraIndent) f.Printf(" ");
6348 OutputType(f, returnType, false);
6352 if(dataType.thisClass && !dataType.classObjectType && (!isInstance || !insideClass || !eClass_IsDerived(insideClass, dataType.thisClass.registered)))
6354 if(dataType.thisClass.shortName)
6355 f.Printf(dataType.thisClass.shortName);
6357 f.Printf(dataType.thisClass.string);
6360 f.Printf(method.name);
6362 for(param = dataType.params.first; param; param = param.next)
6364 // Decided not to write void...
6365 if(param.kind != voidType)
6367 OutputType(f, param, true);
6373 if(extraIndent) f.Printf(" ");
6374 f.Printf(" %c\n", OpenBracket);
6376 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6382 (isInstance ? _class : _class.base)._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad] ||
6383 (isInstance ? _class : _class.base)._vTbl[method.vid] == DummyMethod)) // Temp Check for DefaultFunction
6385 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
6387 if(extraIndent) f.Printf(" ");
6388 f.Printf(" return true;\n");
6390 else if(returnType && returnType.kind != voidType)
6392 if(extraIndent) f.Printf(" ");
6393 f.Printf(" return 0;\n");
6398 if(extraIndent) f.Printf(" ");
6400 if(returnType.kind != voidType)
6401 f.Printf("return ");
6402 f.Printf("%s::%s(", isInstance ? _class.name : _class.base.name, method.name);
6403 for(param = dataType.params.first; param; param = param.next)
6405 if(param.prev) f.Printf(", ");
6406 if(param.kind != voidType)
6407 f.Printf(param.name);
6413 if(extraIndent) f.Printf(" ");
6414 f.Printf(" %c", CloseBracket);
6419 if(extraIndent) { x1 += 3; x2 += 3; }
6420 editBox.SetSelPos(l1, y1, x1 + 6, l2, y2, x2 + 6);
6422 this.updatingCode = false;
6426 // Return false if we overrided a function and don't want to run params listing
6427 bool InvokeAutoComplete(bool enumOnly, int pointer, bool caretMove)
6429 bool didOverride = false;
6430 EditLine line = editBox.line;
6431 int lineNum, charPos;
6432 Expression exp = null;
6435 //Identifier id = null;
6436 Expression memberExp = null;
6437 Identifier realIdentifier = null;
6439 if(!parsing) return true;
6440 if(!privateModule) return !didOverride;
6442 insideFunction = null;
6444 charPos = editBox.charPos + 1;
6445 if(!membersListShown)
6450 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6452 EditBoxStream f { editBox = editBox };
6454 updatingCode = true;
6455 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6459 if(!f.Seek(-1, current))
6462 if(!isspace(ch)) break;
6463 f.Seek(-1, current);
6465 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6467 lineNum = editBox.lineNumber + 1;
6468 charPos = editBox.charPos + 1;
6470 updatingCode = false;
6473 if(!membersListShown)
6475 memberExp = FindExpTree(ast, lineNum, charPos);
6476 if(memberExp && (memberExp.type == TypeKind::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6481 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6483 EditBoxStream f { editBox = editBox };
6486 updatingCode = true;
6488 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6491 if(ch == '}' || ch == ',' || ch == ')')
6493 f.Seek(-1, current);
6501 if(!f.Seek(-1, current))
6504 if(!isspace(ch)) break;
6505 f.Seek(-1, current);
6509 f.Seek(-1, current);
6511 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6513 lineNum = editBox.lineNumber + 1;
6514 charPos = editBox.charPos + 1;
6516 updatingCode = false;
6519 realIdentifier = FindCtxTree(ast, lineNum, charPos);
6524 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6525 lineNum = editBox.lineNumber + 1;
6526 charPos = editBox.charPos/* + 1*/;
6530 char tempString[1024];
6531 char * string = null;
6532 CodePosition idStart, idEnd;
6534 if(membersListShown)
6536 const char * buffer = membersLine.text;
6538 bool firstChar = true;
6540 string = tempString;
6542 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
6544 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6545 if(!isSpace) firstChar = false;
6547 string[len++] = buffer[c];
6551 else //if(realIdentifier)//if(id)
6554 char * buffer = id.string;
6556 bool firstChar = true;
6558 string = tempString;
6559 for(c = 0; c<= charPos - id.loc.start.charPos; c++)
6561 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6562 if(!isSpace) firstChar = false;
6564 string[len++] = buffer[c];
6570 EditLine editLine = editBox.line;
6571 bool firstChar = true;
6574 string = tempString;
6575 for(y = lineNum-1; y >= 0; y--)
6577 const char * buffer = editLine.text;
6578 int lineCount = editLine.count;
6579 for(x = (y == lineNum-1) ? (Min(charPos, lineCount) - 1 ): lineCount-1; x >= 0; x--)
6581 bool isSpace = (buffer[x] == ' ' || buffer[x] == '\t');
6586 idEnd.charPos = x + 2;
6591 // TESTING THIS CODE HERE FOR NOT CONSIDERING bool when doing ctrl-space past it
6594 idEnd.charPos = x + 2;
6601 if(!isalnum(buffer[x]) && buffer[x] != '_')
6607 memmove(string+1, string, len++);
6608 string[0] = buffer[x];
6612 //if(done || firstChar)
6613 if(done || !firstChar)
6615 editLine = editLine.prev;
6618 if(!strcmp(string, "case"))
6624 else if(!strcmp(string, "return"))
6630 else if(!strcmp(string, "delete"))
6636 else if(!strcmp(string, "new"))
6642 else if(!strcmp(string, "renew"))
6650 idStart.charPos = x + 1;
6651 idStart.line = y + 1;
6654 if(!membersListShown)
6656 membersList.Clear();
6657 if(memberExp && (memberExp.type == ExpressionType::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6659 Type type = memberExp.member.exp.expType;
6660 if(pointer == 2 && type)
6662 if(type.kind == pointerType || type.kind == arrayType)
6671 ListSymbols(exp, enumOnly, string, realIdentifier);
6673 membersList.Sort(null, 1);
6678 // Virtual function override
6679 Identifier id = GetDeclId(insideFunction.declarator);
6680 char * string = id ? id.string : null;
6682 Method method = eClass_FindMethod(GetThisClass(), string, this.privateModule);
6685 if(method.type != virtualMethod || (!insideInstance && method._class == GetThisClass()))
6686 insideFunction = null;
6689 OverrideVirtualFunction(insideFunction, method, GetThisClass(), insideInstance, insideInstance && insideClass);
6694 if(!didOverride) //insideFunction)
6696 rowCount = membersList.rowCount;
6699 DataRow row = string ? membersList.FindSubString(string) : null;
6700 if(row && !membersList.FindSubStringAfter(row, string) && !caretMove)
6702 const char * newString = row.string;
6703 if(!membersListShown)
6705 membersLoc.start.line = idStart.line-1;
6706 membersLoc.start.charPos = idStart.charPos-1;
6707 //membersLoc.end = membersLoc.start;
6708 membersLoc.end.charPos = idEnd.charPos-1;
6709 membersLoc.end.line = idEnd.line-1;
6710 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6711 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6716 membersList.Destroy(0);
6717 membersListShown = false;
6720 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
6722 line, membersLoc.start.line, membersLoc.start.charPos,
6723 line, membersLoc.end.line, membersLoc.end.charPos);
6724 editBox.PutS(newString);
6730 row = membersList.FindSubStringi(string);
6732 membersList.currentRow = row;
6733 membersList.currentRow.selected = false;
6736 membersList.currentRow = row;
6738 if(!membersListShown)
6742 // TESTING THESE ADDITIONS TO THE IF SO THAT CARET ISNT MOVED IF NOT ON TOP OF A WORD
6743 if(string && string[0] && lineNum == idStart.line && charPos >= idStart.charPos-1 && charPos <= idEnd.charPos-1)
6744 editBox.SetSelPos(l1, y1, idStart.charPos-1, l2, y2, idStart.charPos-1);
6745 editBox.GetCaretPosition(caret);
6746 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6748 membersList.master = this;
6750 caret.y += editBox.GetCaretSize();
6752 membersList.Create();
6755 int x = caret.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6756 int y = caret.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6757 Window parent = membersList.parent;
6759 if(!paramsAbove && (paramsShown || y + membersList.size.h > parent.clientSize.h))
6761 y -= editBox.GetCaretSize() + membersList.size.h;
6762 membersAbove = true;
6765 membersAbove = false;
6767 membersList.position = { x, y };
6771 membersLoc.start.line = lineNum - 1;
6773 if(string && string[0])
6775 membersLoc.start.charPos = idStart.charPos-1;
6776 membersLoc.end = membersLoc.start;
6777 //membersLoc.end.charPos = id.loc.end.charPos-1;
6778 membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6782 membersLoc.start.charPos = charPos;
6783 membersLoc.end = membersLoc.start;
6784 membersLoc.end.charPos = charPos;
6786 membersListShown = true;
6788 // Hack to keep caret shown
6789 editBox.GetCaretPosition(caret);
6790 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6793 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
6799 SetCurrentContext(globalContext);
6802 return !didOverride;
6805 void InvokeParameters(bool exact, bool reposition, bool caretMove)
6807 int lineNum, charPos;
6811 if(!parsing) return;
6813 charPos = editBox.charPos + 1;
6816 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6818 EditBoxStream f { editBox = editBox };
6821 updatingCode = true;
6822 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6825 if(ch == '}' || ch == ',' || ch == ')')
6827 f.Seek(-1, current);
6835 if(!f.Seek(-1, current))
6838 if(!isspace(ch)) break;
6839 f.Seek(-1, current);
6843 f.Seek(-1, current);
6845 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6847 lineNum = editBox.lineNumber + 1;
6848 charPos = editBox.charPos + 1;
6850 updatingCode = false;
6853 charPos = Min(charPos, l1.count + 1);
6855 FindParamsTree(ast, lineNum, charPos);
6857 // Not sure about this == ExpCall... paramsInsideExp doesn't seem to necessarily be a ExpCall
6858 if(exact && ((::functionType && paramsInsideExp.type == callExp && paramsInsideExp.call.exp.loc.end.charPos != charPos-1) /*|| instanceType*/))
6860 ::functionType = null;
6861 ::instanceType = null;
6864 //if((::functionType || ::instanceType) && (!paramsShown || insideExp != functionExp || ::paramsID != this.paramsID))
6865 if((::functionType || ::instanceType) && (!paramsShown || true /*paramsInsideExp.destType != functionExp.destType */|| ::paramsID != this.paramsID))
6869 Window parent = paramsList.parent;
6871 if(this.functionType != ::functionType || this.instanceType != ::instanceType)
6874 if(!this.paramsShown || reposition || paramsInsideExp != functionExp || ::instanceType) // Added instanceType here, otherwise instance popups never reposition...
6875 // ( Dummy exp: always ends up with same memory)
6877 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6878 editBox.GetCaretPosition(paramsPosition);
6879 this.paramsPosition.y += editBox.GetCaretSize();
6882 FreeType(this.functionType);
6883 FreeType(this.instanceType);
6885 this.functionType = ::functionType;
6886 this.instanceType = ::instanceType;
6888 if(this.functionType) this.functionType.refCount++;
6889 if(this.instanceType) this.instanceType.refCount++;
6891 this.paramsID = ::paramsID;
6892 functionExp = paramsInsideExp;
6894 paramsList.master = this;
6896 paramsList.Create();
6898 x = paramsPosition.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6899 y = paramsPosition.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6901 if(!this.membersAbove && ( this.membersListShown || y + paramsList.size.h > parent.clientSize.h) )
6903 y -= editBox.GetCaretSize() + paramsList.clientSize.h;
6907 paramsAbove = false;
6908 if(x + paramsList.size.w > parent.clientSize.w)
6910 x = parent.clientSize.w - paramsList.size.w;
6914 paramsList.position = { x, y };
6916 // Hack to keep caret shown
6919 editBox.GetCaretPosition(caret);
6920 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6923 this.paramsShown = true;
6925 else if((!::functionType && !::instanceType) || reposition)
6927 paramsList.Destroy(0);
6928 paramsShown = false;
6930 FreeType(this.functionType);
6931 FreeType(this.instanceType);
6932 this.functionType = null;
6933 this.instanceType = null;
6937 SetCurrentContext(globalContext);
6945 designer.visible = true;
6946 designer.Activate();
6952 CodeEditor NewCodeEditor(Window parent, WindowState state, bool modified)
6954 CodeEditor document { state = state, parent = parent, modifiedDocument = modified };
6959 static int nofdigits(int v)
6961 if(v == MININT) return 10 + 1;
6962 if(v < 0) return nofdigits(-v) + 1;