3 // *** Color Schemes ***
5 // *** The Old Color Scheme that was causing me auras and ophtalmic migraines -- Uncomment at your own risk! ***
7 FontResource panelFont { $"Courier New", 10 };
8 FontResource codeFont { $"Courier New", 10 };
9 Color selectionColor = Color { 10, 36, 106 };
10 Color selectionText = white;
11 Color viewsBackground = white;
12 Color viewsText = black;
13 Color outputBackground = white;
14 Color outputText = black;
15 Color projectViewBackground = white;
16 Color projectViewText = black;
17 Color codeEditorBG = white;
18 Color codeEditorFG = black;
19 Color marginColor = Color {230, 230, 230};
20 Color selectedMarginColor = Color {200, 200, 200};
21 Color lineNumbersColor = Color {60, 60, 60};
22 SyntaxColorScheme colorScheme
24 keywordColors = [ blue, blue ];
25 commentColor = dimGray;
26 charLiteralColor = crimson;
27 stringLiteralColor = crimson;
28 preprocessorColor = green;
33 // The new nice dark scheme -- so peaceful on my brain
35 FontResource panelFont { $"Courier New", 10 };
36 FontResource codeFont { $"Courier New", 10 };
38 FontResource panelFont { $"Consolas", 12 };
39 FontResource codeFont { $"Consolas", 12 };
41 Color selectionColor = lightYellow;
42 Color selectionText = Color { 30, 40, 50 };
43 Color viewsBackground = Color { 30, 40, 50 };
44 Color viewsText = lightGray;
45 Color outputBackground = black;
46 Color outputText = lime;
47 Color projectViewBackground = Color { 30, 40, 50 };
48 Color projectViewText = lightGray;
49 Color codeEditorBG = black;
50 Color codeEditorFG = ivory;
51 Color marginColor = Color {24, 24, 24};
52 Color selectedMarginColor = Color {64, 64, 64};
53 Color lineNumbersColor = Color {160, 160, 160};
54 SyntaxColorScheme colorScheme
56 keywordColors = [ skyBlue, skyBlue ];
57 commentColor = Color { 125, 125, 125 };
58 charLiteralColor = Color { 245, 50, 245 };
59 stringLiteralColor = Color { 245, 50, 245 };
60 preprocessorColor = { 120, 220, 140 };
61 numberColor = Color { 0, 192, 192 };
64 // *********************
70 // UNTIL IMPLEMENTED IN GRAMMAR
71 #define ACCESS_CLASSDATA(_class, baseClass) \
72 (_class ? ((void *)(((char *)_class.data) + baseClass.offsetClass)) : null)
75 extern int __attribute__((__stdcall__)) __ecereDll_Load_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
76 extern int __attribute__((__stdcall__)) __ecereDll_Unload_ecere(struct __ecereNameSpace__ecere__com__Instance * module);
79 static Array<FileFilter> fileFilters
81 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
82 { $"Header Files for C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
83 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
84 { $"Text files (*.txt)", "txt" },
85 { $"All files", null }
88 static Array<FileType> fileTypes
90 { $"eC Source Code", "ec", whenNoneGiven },
91 { $"Text Files", "txt", never }
94 static char * iconNames[] =
96 "<:ecere>constructs/class.png",
97 "<:ecere>constructs/data.png",
98 "<:ecere>constructs/method.png",
99 "<:ecere>constructs/event.png",
100 "<:ecere>constructs/property.png",
101 "<:ecere>constructs/namespace.png",
102 "<:ecere>constructs/dataType.png",
103 "<:ecere>constructs/enumValue.png",
104 "<:ecere>constructs/dataPrivate.png",
105 "<:ecere>constructs/methodPrivate.png",
106 "<:ecere>constructs/propertyPrivate.png"
109 enum SheetType { methods, properties };
111 extern int __ecereVMethodID_class_OnEdit;
112 extern int __ecereVMethodID_class_OnDisplay;
113 extern int __ecereVMethodID_class_OnGetString;
114 extern int __ecereVMethodID_class_OnFree;
115 extern int __ecereVMethodID_class_OnCompare;
116 extern int __ecereVMethodID_class_OnCopy;
117 extern int __ecereVMethodID_class_OnSaveEdit;
118 extern int __ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad;
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;
184 /****************************************************************************
186 ****************************************************************************/
188 static void OutputString(File f, char * string)
191 for(c = 0; string[c]; c++)
193 if(string[c] == '\"')
195 else if(string[c] == '\\')
197 else if(string[c] == '\n')
208 void OutputType(File f, Type type, bool outputName)
218 if(!type.isSigned) f.Printf("unsigned ");
222 if(!type.isSigned) f.Printf("unsigned ");
226 if(!type.isSigned) f.Printf("unsigned ");
230 if(!type.isSigned) f.Printf("unsigned ");
234 if(!type.isSigned) f.Printf("unsigned ");
245 if(type._class && !strcmp(type._class.string, "class"))
247 switch(type.classObjectType)
250 f.Printf("any_object");
253 f.Printf("typed_object");
260 // ADD CODE TO DECIDE WHETHER TO OUTPUT FULLY QUAlIFIED OR NOT:
261 f.Printf(type._class.shortName ? type._class.shortName : type._class.string);
271 OutputType(f, type.type, false);
274 OutputType(f, type.type, false);
293 if(type.kind == arrayType)
296 f.Printf("%d", type.arraySize);
302 void DeleteJunkBefore(EditBoxStream f, int pos, int * position)
308 f.Seek(pos - *position, current);
310 // Try to delete spaces and \n before...
316 /*else if(ch == '\n')
318 // Look for // comments on the line before
319 EditBox editBox = f.editBox;
320 EditLine line = editBox.line;
327 for(c = 0; text[c]; c++)
336 if(text[c] == '/' && last == '/')
348 f.DeleteBytes(before);
353 void GetLocText(EditBox editBox, File f, int position, Location loc, char ** text, int * size, int pad, int linePad)
358 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
360 // Cut & Paste function
366 f.Seek(loc.start.pos - position, current);
368 x1 = editBox.charPos;
369 y1 = editBox.lineNumber;
370 f.Seek(loc.end.pos - loc.start.pos, current);
372 x2 = editBox.charPos;
373 y2 = editBox.lineNumber;
374 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
376 *size = editBox.SelSize();
377 *text = new char[*size+1 + (y2-y1+1) * linePad + pad]; // Add pad for tabs and new name
378 editBox.GetSel(*text, false);
381 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
382 f.Printf(""); // Make the stream point to where the editbox is
385 void Code_FixProperty(Property prop, Instance object)
387 Designer::FixProperty(prop, object);
390 bool Code_IsPropertyModified(Instance test, ObjectInfo selected, Property prop)
393 if(prop.dataTypeString && (!prop.IsSet || prop.IsSet(selected.instance)))
395 Class dataType = prop.dataTypeClass;
398 dataType = prop.dataTypeClass = eSystem_FindClass(test._class.module, prop.dataTypeString);
400 if(dataType && dataType._vTbl && dataType.type == structClass)
402 void * dataForm = new0 byte[dataType.structSize];
403 void * dataTest = new0 byte[dataType.structSize];
405 ((void (*)(void *, void *))(void *)prop.Get)(selected.instance, dataForm);
406 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
408 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
410 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
416 else if(dataType && dataType._vTbl && (dataType.type == normalClass || dataType.type == noHeadClass))
418 void * dataForm, * dataTest;
419 bool isEditBoxContents = false;
420 bool freeDataForm = false, freeDataTest = false;
422 // Because contents property is broken for mutiline EditBox at the moment
423 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
424 isEditBoxContents = true;
426 if(isEditBoxContents && ((EditBox)selected.instance).multiLine)
428 dataForm = ((EditBox)selected.instance).multiLineContents;
432 dataForm = ((void *(*)(void *))(void *)prop.Get)(selected.instance);
433 if(isEditBoxContents && ((EditBox)test).multiLine)
435 dataTest = ((EditBox)test).multiLineContents;
439 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
441 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
443 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
447 if(freeDataForm) delete dataForm;
448 if(freeDataTest) delete dataTest;
450 else if(dataType && dataType._vTbl)
452 DataValue dataForm, dataTest;
454 GetProperty(prop, selected.instance, &dataForm);
455 GetProperty(prop, test, &dataTest);
457 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
459 SetProperty(prop, test, dataForm);
461 // In case setting on test unset on real instance (e.g. isDefault)
462 if(strcmp(prop.name, "name"))
464 GetProperty(prop, selected.instance, &dataTest);
465 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
466 SetProperty(prop, selected.instance, dataForm);
475 bool Code_IsPropertyDisabled(ObjectInfo selected, char * name)
477 bool disabled = false;
478 if(selected.oClass == selected)
481 if(selected.classDefinition)
483 for(def = selected.classDefinition.definitions->first; def; def = def.next)
485 if(def.type == defaultPropertiesClassDef)
488 for(prop = def.defProperties->first; prop; prop = prop.next)
490 if(prop.identifiers && prop.identifiers->first)
492 Identifier id = prop.identifiers->first;
493 if(prop.variable && !strcmp(id.string, name))
505 else if(selected.instCode)
508 if(selected.instCode.members)
510 for(members = selected.instCode.members->first; members; members = members.next)
512 if(members.type == dataMembersInit && members.dataMembers)
515 for(prop = members.dataMembers->first; prop; prop = prop.next)
517 if(prop.identifiers && prop.identifiers->first)
519 Identifier id = prop.identifiers->first;
520 if(prop.variable && !strcmp(id.string, name))
535 static bool CheckCompatibleMethod(Method method, Type type, Class regClass, bool isForm, Symbol selectedClass)
540 method.dataType = ProcessTypeString(method.dataTypeString, false);
541 if(!method.dataType.thisClass && !isForm)
544 method.dataType.thisClass = selectedClass;
546 //result = MatchTypes(method.dataType, type, null, regClass, regClass, false);
547 result = MatchTypes(type, method.dataType, null, regClass, regClass, false, true, true, false);
549 method.dataType.thisClass = null;
553 bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo object)
555 bool confirmation = true;
556 Statement body = function.body;
557 // Check if it contains any code
558 if((!body.compound.declarations || !body.compound.declarations->count) && (!body.compound.statements || body.compound.statements->count <= 1))
560 Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
561 Statement stmt = body.compound.statements ? body.compound.statements->first : null;
562 Type dataType = method.dataType;
563 Type returnType = dataType.returnType;
564 Expression exp = null;
567 method.dataType = ProcessTypeString(method.dataTypeString, false);
569 confirmation = false;
571 // Check if default function should be calling base class:
572 if(object.instance._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
574 if(returnType.kind != voidType)
576 if(!stmt || stmt.type != returnStmt || !stmt.expressions || stmt.expressions->count != 1)
580 exp = stmt.expressions->first;
581 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
583 if( (exp.type != identifierExp || strcmp(exp.identifier.string, "true")) &&
584 (exp.type != constantExp || strcmp(exp.constant, "1")))
589 if(exp.type != constantExp || strcmp(exp.constant, "0"))
604 if(returnType.kind != voidType)
606 if(stmt.type == returnStmt && stmt.expressions && stmt.expressions->count == 1)
607 exp = stmt.expressions->first;
609 else if(stmt.type == expressionStmt && stmt.expressions && stmt.expressions->count == 1)
610 exp = stmt.expressions->first;
613 if(!exp || exp.type != callExp || exp.call.exp.type != identifierExp)
617 Identifier id = exp.call.exp.identifier;
618 Class base = object.instance._class;
619 if(!id._class || (id._class.name && !strcmp(id._class.name, base.name)) || strcmp(id.string, method.name))
623 Expression arg = exp.call.arguments ? exp.call.arguments->first : null;
624 if(!arg || arg.type != identifierExp || strcmp("this", arg.identifier.string))
630 for(param = dataType.params.first; param; param = param.next)
632 if(!arg || arg.type != identifierExp || strcmp(param.name, arg.identifier.string))
637 arg = arg ?arg.next : null;
644 return !confirmation;
647 class CodeEditor : Window
649 background = marginColor;
650 borderStyle = sizableDeep;
655 isActiveClient = true;
656 anchor = Anchor { left = 300, right = 150, top = 0, bottom = 0 };
659 // eWindow_SetX(A_CASCADE); eWindow_SetY(A_CASCADE);
660 // eWindow_SetWidth(A_RELATIVE|80); eWindow_SetHeight(A_RELATIVE|80);
662 SheetType sheetSelected;
667 Context globalContext { };
668 OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
681 MethodAction methodAction;
683 ClassFunction function;
685 char methodName[1024];
690 bool membersListShown;
693 EditLine membersLine;
695 Type functionType, instanceType;
699 Point paramsPosition;
700 Expression functionExp;
703 BitmapResource icons[CodeObjectType];
705 FontResource boldFont { $"Tahoma", 8.25f, bold = true, window = this };
706 FontResource normalFont { $"Tahoma", 8.25f, window = this };
708 Module privateModule;
709 NameSpace globalData;
712 OpenedFileInfo openedFileInfo;
714 FontResource font { codeFont.faceName, codeFont.size };
715 saveDialog = codeEditorFileDialog;
717 Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
720 int maxLineNumberLength;
722 property bool parsing { get { return editBox.syntaxHighlighting && !noParsing && !ide.noParsing; } };
724 void ProcessCaretMove(EditBox editBox, int line, int charPos)
727 ObjectInfo classItem;
729 // OnActivateClient is called after OnActivate
732 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
735 if(sheet.codeEditor != this) return;
739 for(classItem = classes.first; classItem; classItem = classItem.next)
741 ClassDefinition classDef = classItem.classDefinition;
742 if(classDef && classDef.loc.Inside(line, charPos))
749 for(object = classItem.instances.first; object; object = object.next)
753 if(object.instCode.loc.Inside(line, charPos))
758 sheet.SelectObject(object);
760 sheet.SelectObject(classItem);
765 //sheet.SelectObject(null);
769 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
773 expectingMove = false;
779 if(line-1 != membersLoc.start.line)
783 char * buffer = membersLine.text;
786 if(charPos - 1 < membersLoc.start.charPos)
788 else if(charPos - 1 > membersLoc.end.charPos)
790 char * buffer = membersLine.text;
791 //if(membersList.currentRow)
795 for(c = membersLoc.start.charPos; c<=charPos && buffer[c]; c++)
796 if(buffer[c] != ' ' && buffer[c] != '\t')
798 if(c < charPos && buffer[c])
805 membersList.Destroy(0);
806 membersListShown = false;
810 bool back = codeModified;
811 codeModified = false;
813 InvokeParameters(false, false, false);
814 /*if(membersListShown)
815 InvokeAutoComplete(false, 0, true);*/
822 watch(modifiedDocument)
824 ProjectView projectView = ide.projectView;
827 char buffer[MAX_LOCATION];
828 char * fullPath = GetSlashPathBuffer(buffer, fileName);
829 Array<ProjectNode> nodes = ide.workspace.GetAllProjectNodes(fullPath, false);
833 node.modified = modifiedDocument;
834 projectView.Update(null);
843 textVertScroll = true, multiLine = true, /*lineNumbers = ideSettings.showLineNumbers,*/
844 freeCaret = ideSettings.useFreeCaret, caretFollowsScrolling = ideSettings.caretFollowsScrolling,
845 tabKey = true, smartHome = true;
846 tabSelection = true, /*maxLineSize = 65536, */parent = this, hasHorzScroll = true, hasVertScroll = true;
847 selectionColor = selectionColor, selectionText = selectionText,
848 background = codeEditorBG, foreground = codeEditorFG, syntaxColorScheme = colorScheme,
849 font = font, borderStyle = none;
850 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
852 bool OnMouseOver(int x, int y, Modifiers mods)
854 CodeEditor editor = (CodeEditor)master;
855 if(editor.designer && editor.designer.isDragging && !mods.isSideEffect)
860 void NotifyCaretMove(EditBox editBox, int line, int charPos)
862 // Update Line Numbers
864 int oldLine = lastLine;
865 display.FontExtent(font.font, " ", 1, null, &spaceH);
867 Box box { 0, (Min(oldLine,oldLine)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(oldLine, oldLine))*spaceH-1 - editBox.scroll.y };
871 Box box { 0, (Min(line,line)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(line, line))*spaceH-1 - editBox.scroll.y };
876 if(ide.activeClient == this)
877 ProcessCaretMove(editBox, line, charPos);
879 openedFileInfo.CaretMove(line, charPos);
882 void NotifyOvrToggle(EditBox editBox, bool overwrite)
884 ide.UpdateStateLight(ide.ovr, overwrite);
887 void NotifyUpdate(EditBox editBox)
894 designer.modifiedDocument = true;
897 modifiedDocument = true;
900 bool NotifyUnsetModified(EditBox editBox)
902 modifiedDocument = false;
906 bool NotifyCharsAdded(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
908 if(!loadingFile && after.y != before.y)
910 ProjectView projectView = ide.projectView;
911 if(projectView && fileName)
914 // HOW WE MIGHT WANT TO DO IT:
915 char * text = before.line.text;
916 for(c = Min(before.line.count, before.x-1); c>= 0; c--)
917 if(!isspace(text[c]))
919 ide.debugger.MoveIcons(fileName, before.y + (((!pasteOperation && c > -1) || !after.line.count) ? 1 : 0), after.y - before.y, false);
921 // HOW VISUAL STUDIO DOES IT:
923 char * text = after.line.text;
924 for(c = after.line.count-1; c>= 0; c--)
925 if(!isspace(text[c]))
927 ide.debugger.MoveIcons(fileName, before.y + ((c < 0) ? 1 : 0), after.y - before.y, false);
930 Update({ 0, 0, editBox.position.x, clientSize.h });
938 for(oClass = classes.first; oClass; oClass = oClass.next)
941 for(object = oClass.instances.first; object; object = object.next)
945 object.instCode.loc.start.AdjustAdd(before, after);
946 object.instCode.loc.end.AdjustAdd(before, after);
951 oClass.classDefinition.loc.start.AdjustAdd(before, after);
952 oClass.classDefinition.loc.end.AdjustAdd(before, after);
958 expectingMove = true;
962 if(before.y != after.y)
966 char * buffer = membersLine.text;
968 bool firstChar = true;
969 bool addedChar = false;
975 membersLoc.end.charPos += after.x - Max(membersLoc.start.charPos, before.x);
977 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
979 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
980 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar)) //|| membersList.currentRow
989 membersLoc.start.charPos++;
994 string[len++] = buffer[c];
998 row = membersList.currentRow;
999 if(row && row.selected)
1003 membersLoc.start.charPos--;
1011 row = membersList.FindSubString(string);
1013 membersList.currentRow = row;
1016 row = membersList.FindSubStringi(string);
1018 membersList.currentRow = row;
1019 membersList.currentRow.selected = false;
1022 membersList.SetScrollPosition(0, (row.index) * membersList.rowHeight);
1026 row = membersList.currentRow;
1029 // Accept current string if hiding typing char
1030 if(hide && row && row.selected)
1032 char * string = row.string;
1033 int len = strlen(string);
1034 membersLoc.end.charPos -= after.x - before.x;
1035 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1036 editBox.Delete(membersLine, membersLoc.start.line, membersLoc.start.charPos,
1037 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1038 editBox.PutS(string);
1039 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos + len + 1 /*after.x - before.x*/);
1041 after.x += membersLoc.start.charPos + len - before.x;
1042 before.x = membersLoc.start.charPos + len;
1047 membersList.Destroy(0);
1048 membersListShown = false;
1051 if(/*after.x - before.x == 1 && */after.y == before.y && !membersListShown)
1053 EditLine line = editBox.line;
1054 char * text = line.text;
1055 char ch = text[after.x-1];
1056 if(ch == '.' || (ch == '>' && after.x-1 > 0 && text[after.x-1-1] == '-') || (ch == ':' && after.x-1 > 0 && text[after.x-1-1] == ':'))
1060 // Can we call invoke auto complete here instead?
1070 // Force caret update already...
1071 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1072 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1074 editBox.GetCaretPosition(&caret);
1078 // Go back in the buffer until no space before
1080 codeModified = true;
1084 EditBoxStream f { editBox = editBox };
1088 if(text[after.x-1] == '>')
1094 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1098 if(!f.Seek(-1, current))
1101 if(!isspace(ch)) break;
1102 f.Seek(-1, current);
1104 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1106 line = editBox.lineNumber + 1;
1107 charPos = editBox.charPos + 1;
1111 exp = FindExpTree(ast, line, charPos);
1115 Type type = exp.expType;
1117 if(type && text[after.x-1] != '.')
1119 if(type.kind == TypePointer || type.kind == TypeArray)
1125 membersList.Clear();
1128 if(membersList.rowCount)
1130 membersList.Sort(null, 1);
1131 membersList.master = this;
1133 caret.y += editBox.GetCaretSize();
1136 membersList.Create();
1139 int x = caret.x + editBox.GetAbsX() - app.desktop.GetAbsX() - editBox.GetScrollX();
1140 int y = caret.y + editBox.GetAbsY() - app.desktop.GetAbsY() - editBox.GetScrollY();
1141 Window parent = membersList.parent;
1143 if(!paramsAbove && (paramsShown || y + membersList.GetHeight() > parent.GetClientHeight()))
1145 y -= editBox.GetCaretSize() + membersList.GetHeight();
1146 membersAbove = true;
1149 membersAbove = false;
1151 membersList.position = { x, y };
1155 membersLoc.start.line = line - 1;
1156 membersLoc.start.charPos = oldCharPos;
1157 membersLoc.end = membersLoc.start;
1158 membersListShown = true;
1163 SetCurrentContext(globalContext);
1165 codeModified = true;
1166 skipModified = true;
1167 if(text[after.x-1] == ':')
1168 InvokeAutoComplete(false, 0, false);
1169 else if(text[after.x-1] == '.')
1170 InvokeAutoComplete(false, 1, false);
1171 else if(text[after.x-1] == '>')
1172 InvokeAutoComplete(false, 2, false);
1173 skipModified = false;
1175 else if(ch == '(' || ch == OpenBracket || ch == ',' || ch == '=' || ch == '?' || ch == ':')
1177 codeModified = true;
1178 skipModified = true;
1180 if(InvokeAutoComplete(true, 0, false))
1182 if(ch == '(' || ch == OpenBracket)
1183 InvokeParameters(true, true, false);
1185 InvokeParameters(this.functionType ? false : true, false, false);
1188 // InvokeAutoComplete(true, 0, false);
1189 skipModified = false;
1191 else if(ch == ')' || ch == '}' || ch == ';')
1193 codeModified = true;
1194 skipModified = true;
1196 InvokeParameters(false, true, false);
1197 skipModified = false;
1201 bool back = codeModified;
1202 codeModified = false;
1204 InvokeParameters(false, false, true);
1205 if(membersListShown)
1206 InvokeAutoComplete(false, 0, true);
1207 codeModified = back;
1212 bool back = codeModified;
1213 codeModified = false;
1216 InvokeParameters(false, false, true);
1217 /*if(membersListShown)
1218 InvokeAutoComplete(false, 0, true);*/
1220 codeModified = back;
1227 bool NotifyCharsDeleted(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
1229 if(!loadingFile && after.y != before.y)
1231 ProjectView projectView = ide.projectView;
1232 if(projectView && fileName)
1233 ide.debugger.MoveIcons(fileName, before.y + 1, before.y - after.y, before.x == 0);
1234 Update({ 0, 0, editBox.position.x, clientSize.h });
1242 for(oClass = classes.first; oClass; oClass = oClass.next)
1246 for(object = oClass.instances.first; object; object = object.next)
1250 loc = &object.instCode.loc;
1252 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1253 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1255 object.instCode = null;
1259 loc->start.AdjustDelete(before, after);
1260 loc->end.AdjustDelete(before, after);
1264 if(oClass.classDefinition)
1266 loc = &oClass.classDefinition.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 oClass.classDefinition = null;
1274 loc->start.AdjustDelete(before, after);
1275 loc->end.AdjustDelete(before, after);
1280 if(membersListShown)
1283 if(pasteOperation || before.y != after.y)
1287 char * buffer = membersLine.text;
1289 bool firstChar = true;
1293 if(before.x >= membersLoc.start.charPos)
1295 for(c = membersLoc.start.charPos; c<before.x && len < sizeof(string)-1; c++)
1297 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1298 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1303 if(!isSpace) firstChar = false;
1306 string[len++] = buffer[c];
1311 // If deleting spaces before...
1312 for(c = before.x; c<membersLoc.start.charPos; c++)
1314 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1322 membersLoc.start.charPos = before.x;
1325 if(membersLoc.end.charPos >= after.x)
1327 for(c = after.x; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
1329 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1330 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1335 if(!isSpace) firstChar = false;
1338 string[len++] = buffer[c];
1346 membersLoc.end.charPos -= after.x - before.x;
1350 row = membersList.FindSubString(string);
1353 row = membersList.FindSubStringi(string);
1355 membersList.currentRow = row;
1356 membersList.currentRow.selected = false;
1359 membersList.currentRow = row;
1361 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
1366 membersList.Destroy(0);
1367 membersListShown = false;
1373 InvokeParameters(false, false);
1381 bool NotifyDropped(EditBox editBox, int x, int y)
1383 char * controlClass = toolBox.controlClass;
1384 if(controlClass && controlClass[0])
1388 ObjectInfo classObject;
1390 editBox.GoToLineNum(y);
1391 x = Min(x, editBox.line.count);
1392 editBox.GoToPosition(editBox.line, y, x);
1393 // Note: Uncommented this to drag objects after the member instance on which they are dropped
1394 editBox.NotifyCaretMove(this, editBox, y+1, x+1);
1396 classObject = selected ? selected.oClass : null;
1398 if((!selected || selected == classObject) && classObject && classObject.instances.first)
1399 selected = classObject.instances.last;
1402 control = eInstance_New(eSystem_FindClass(privateModule, controlClass));
1405 AddObject(control, &object);
1407 designer.CreateObject(control, object, false, classObject.instance);
1408 // designer.PostCreateObject(control, object, false, classObject.instance);
1409 designer.DroppedObject(control, object, false, classObject.instance);
1411 sheet.AddObject(object, object.name, typeData /* className*/, true);
1414 //codeModified = true;
1421 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
1423 if(key == ctrlSpace)
1425 membersList.Destroy(0);
1426 membersListShown = false;
1427 InvokeAutoComplete(false, 0, false);
1430 else if(key == Key { space, ctrl = true, shift = true })
1431 InvokeParameters(false, true, false);
1432 else if(key == escape)
1433 ide.RepositionWindows(true);
1434 else if(key == ctrlF7)
1438 ProjectNode node = ide.projectView.GetNodeForCompilationFromWindow(this, false, null, null);
1442 s = PrintString($"The ", fileName, $" file is not part of any project.\n",
1443 $"It can't be compiled.");
1444 MessageBox { type = ok, /*parent = ide, */master = ide, text = $"File not in project error", contents = s }.Modal();
1453 bool OnKeyDown(Key key, unichar ch)
1455 CodeEditor editor = (CodeEditor)master;
1456 if(key == escape /*|| key == leftAlt || key == rightAlt || (key.ctrl && key.code != left && key.code != right && key.code != leftShift && key.code != rightShift && key.code != space)*/)
1458 if(editor.membersListShown)
1460 editor.membersList.Destroy(0);
1461 editor.membersListShown = false;
1464 if(editor.paramsShown)
1466 editor.paramsList.Destroy(0);
1467 editor.paramsShown = false;
1468 FreeType(editor.functionType);
1469 FreeType(editor.instanceType);
1471 editor.functionType = null;
1472 editor.instanceType = null;
1473 editor.paramsID = -1;
1477 return EditBox::OnKeyDown(key, ch);
1480 void OnVScroll(ScrollBarAction action, int position, Key key)
1482 if(anchor.left.distance)
1484 Box box { 0, 0, anchor.left.distance-1, parent.clientSize.h - 1 };
1487 EditBox::OnVScroll(action, position, key);
1489 CodeEditor ce = (CodeEditor)parent;
1490 if(ce.openedFileInfo)
1491 ce.openedFileInfo.ScrollChange({ scroll.x, position });
1495 void OnHScroll(ScrollBarAction action, int position, Key key)
1497 EditBox::OnHScroll(action, position, key);
1499 CodeEditor ce = (CodeEditor)parent;
1500 if(ce.openedFileInfo)
1501 ce.openedFileInfo.ScrollChange({ position, scroll.y });
1508 fullRowSelect = false,
1511 borderStyle = bevel;
1512 // size = { 200, 400 };
1514 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
1516 DataRow row = listBox.currentRow;
1519 char * string = row.string;
1521 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1523 membersLine, membersLoc.start.line, membersLoc.start.charPos,
1524 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1525 editBox.PutS(string);
1528 membersListShown = false;
1533 bool OnKeyDown(Key key, unichar ch)
1535 CodeEditor editor = (CodeEditor) master;
1536 if(key == escape || key == leftAlt || key == rightAlt ||
1537 (key.ctrl && key.code != left && key.code != right &&
1538 key.code != leftShift && key.code != rightShift && key.code != space))
1541 if(editor.paramsShown)
1545 editor.paramsList.Destroy(0);
1546 editor.paramsShown = false;
1548 if(editor.membersListShown)
1552 editor.membersList.Destroy(0);
1553 editor.membersListShown = false;
1556 FreeType(editor.functionType);
1557 editor.functionType = null;
1559 FreeType(editor.instanceType);
1560 editor.instanceType = null;
1562 editor.paramsID = -1;
1567 return editor.editBox.OnKeyDown(key, ch);
1571 /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1573 CodeEditor editor = (CodeEditor)master;
1574 Window rw = previous ? previous.rootWindow : null;
1575 if(!active && rw != editor.paramsList)
1578 editor.membersListShown = false;
1580 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1583 bool OnKeyHit(Key key, unichar ch)
1585 CodeEditor editor = (CodeEditor) master;
1589 case enter: case tab:
1591 DataRow row = currentRow;
1592 if(row && row.selected)
1594 char * string = row.string;
1596 editor.editBox.GoToPosition(editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos);
1597 editor.editBox.Delete(
1598 editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos,
1599 editor.membersLine, editor.membersLoc.end.line, editor.membersLoc.end.charPos);
1600 editor.editBox.PutS(string);
1603 editor.membersListShown = false;
1606 editor.editBox.OnKeyHit(key, ch);
1616 return ListBox::OnKeyHit(key, ch);
1622 // If before . or after
1623 //listBox.Destroy(true);
1624 result = editor.editBox.OnKeyHit(key, ch);
1639 clickThrough = true,
1641 borderStyle = contour,
1643 background = { 255,255,225 },
1645 OnKeyDown = membersList.OnKeyDown;
1647 /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1649 CodeEditor editor = (CodeEditor)master;
1650 Window rw = previous ? previous.rootWindow : null;
1651 if(!active && previous != editor.editBox && rw != editor.membersList)
1654 editor.paramsShown = false;
1656 return Window::OnActivate(active, previous, goOnWithActivation, direct);
1659 bool OnKeyHit(Key key, unichar ch)
1661 CodeEditor editor = (CodeEditor)master;
1663 if(!editor.membersListShown || editor.membersList.OnKeyHit(key, ch))
1666 bool result = true; editor.editBox.OnKeyHit(key, ch);
1667 return (!created) ? false : result;
1674 void OnRedraw(Surface surface)
1676 CodeEditor editor = (CodeEditor) master;
1677 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1679 Type methodType = null;
1683 int functionW, nameW = 0;
1685 int spaceW, spaceH, commaW, commaWB, parW;
1687 int maxW = 0, lineW = 0;
1693 Font font = editor.normalFont.font;
1694 Font boldFont = editor.boldFont.font;
1695 Display display = this.display;
1697 if(!type) { return; };
1699 if(type.kind == TypeKind::methodType) { methodType = type; type = type.method.dataType; }
1701 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1702 display.FontExtent(font, ", ", 2, &commaW, null);
1703 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1704 display.FontExtent(font, ")", 1, &parW, null);
1707 if(editor.functionType)
1709 PrintType(type.returnType, string, true, true);
1710 display.FontExtent(font, string, strlen(string), &functionW, null);
1712 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1713 totalW = nameW + functionW + 2 * parW;
1717 PrintType(type, string, (type.kind == functionType) ? true : false, true); // true);
1718 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1719 if(instanceName && type.kind != functionType)
1720 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1721 totalW = functionW + nameW;
1722 surface.TextFont(boldFont);
1725 surface.WriteText(x, y, string, strlen(string));
1726 x += functionW + spaceW;
1728 if(editor.functionType)
1731 surface.WriteText(x, y, type.name, strlen(type.name));
1733 surface.WriteText(x, y, "(", 1);
1736 if(methodType && !methodType.staticMethod && methodType.methodClass)
1740 if(id == editor.paramsID)
1741 surface.TextFont(boldFont);
1743 if(methodType.methodClass)
1744 surface.TextExtent(methodType.methodClass.name, strlen(methodType.methodClass.name), &tw, null);
1748 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1749 width += ((id == editor.paramsID) ? commaWB : commaW);
1754 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1759 x = 2 + nameW + spaceW + functionW + parW;
1763 if(methodType.methodClass)
1764 surface.WriteText(x, y, methodType.methodClass.name, strlen(methodType.methodClass.name));
1767 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1769 surface.WriteText(x, y, ",", 1);
1770 x += ((id == editor.paramsID) ? commaWB : commaW);
1778 if(id == editor.paramsID)
1779 surface.TextFont(font);
1783 if(!methodType || (methodType.staticMethod || !methodType.methodClass) || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1785 for(param = type.params.first; param; param = param.next)
1787 char paramString[1024];
1790 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1791 surface.TextFont(boldFont);
1794 PrintType(param, paramString, true, true);
1795 surface.TextExtent(paramString, strlen(paramString), &tw, null);
1797 if(param.next) width += ((id == editor.paramsID) ? commaWB : commaW);
1802 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1807 x = 2 + nameW + spaceW + functionW + parW;
1811 surface.WriteText(x, y, paramString, strlen(paramString));
1815 surface.WriteText(x, y, ",", 1);
1816 x += ((id == editor.paramsID) ? commaWB : commaW);
1824 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1825 surface.TextFont(font);
1830 surface.WriteText(x, y, ")", 1);
1832 else if(instanceName && type.kind != functionType)
1834 surface.WriteText(x, y, instanceName, strlen(instanceName));
1838 bool OnResizing(int * w, int * h)
1840 CodeEditor editor = (CodeEditor) master;
1841 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1843 Type methodType = null;
1847 int functionW = 0, nameW = 0;
1849 int spaceW, spaceH, commaW, commaWB, parW;
1851 int maxW = 0, lineW = 0;
1856 Font font = editor.normalFont.font;
1857 Font boldFont = editor.boldFont.font;
1858 Display display = this.display;
1860 if(type.kind == TypeKind::methodType)
1863 ProcessMethodType(type.method);
1864 type = type.method.dataType;
1867 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1868 display.FontExtent(font, ", ", 2, &commaW, null);
1869 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1870 display.FontExtent(font, ")", 1, &parW, null);
1873 if(editor.functionType && type)
1875 PrintType(type.returnType, string, true, true);
1876 display.FontExtent(font, string, strlen(string), &functionW, null);
1878 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1879 totalW = nameW + spaceW + functionW + 2 * parW;
1883 PrintType(type, string, false, true); // /*true);
1884 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1885 if(instanceName && type.kind != functionType)
1886 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1887 totalW = functionW + nameW + spaceW;
1890 if(editor.functionType)
1896 if(methodType.methodClass)
1897 display.FontExtent((id == editor.paramsID) ? boldFont : font, methodType.methodClass.name, strlen(methodType.methodClass.name), &width, null);
1898 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1899 width += ((id == editor.paramsID) ? commaWB : commaW);
1904 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1917 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1919 for(param = type.params.first; param; param = param.next)
1921 char paramString[1024];
1925 PrintType(param, paramString, true, true);
1926 display.FontExtent((id == editor.paramsID || param.kind == ellipsisType) ? boldFont : font, paramString, strlen(paramString), &width, null);
1928 width += ((id == editor.paramsID) ? commaWB : commaW);
1933 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1950 *w = realW + totalW + 4;
1956 Menu fileMenu { menu, $"File", f };
1957 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
1958 MenuItem { fileMenu, $"Save As...", a, NotifySelect = MenuFileSaveAs };
1960 Menu editMenu { menu, $"Edit", e };
1961 MenuDivider { editMenu };
1962 MenuItem clearTrailingSpacesItem
1964 editMenu, $"Clear trailing spaces", t, Key { t, ctrl = true, shift = true };
1966 bool NotifySelect(MenuItem selection, Modifiers mods)
1968 // Nuke trailing spaces
1971 editBox.recordUndoEvent = true;
1972 for(line = editBox.firstLine; line; line = line.next, y++)
1974 String buffer = line.text;
1975 int count = line.count, i = count-1;
1976 while(i >= 0 && isspace(buffer[i])) i--;
1978 editBox.Delete(line, y, i + 1, line, y, count);
1980 editBox.recordUndoEvent = false;
1985 Menu debugMenu { menu, $"Debug", d };
1986 MenuItem debugRunToCursor { debugMenu, $"Run To Cursor", c, ctrlF10, id = RTCMenuBits { false, false, false }, NotifySelect = RTCMenu_NotifySelect; };
1987 MenuItem debugSkipRunToCursor { debugMenu, $"Run To Cursor Skipping Breakpoints", u, Key { f10, ctrl = true, shift = true }, id = RTCMenuBits { true, false, false }, NotifySelect = RTCMenu_NotifySelect; };
1988 MenuItem debugRunToCursorAtSameLevel { debugMenu, $"Run To Cursor At Same Level", l, altF10, id = RTCMenuBits { false, true, false }, NotifySelect = RTCMenu_NotifySelect; };
1989 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; };
1991 MenuItem debugBpRunToCursor { debugMenu, $"BP Run To Cursor"/*, c, ctrlF10*/, id = RTCMenuBits { false, false, true }, NotifySelect = RTCMenu_NotifySelect; };
1992 MenuItem debugBpSkipRunToCursor { debugMenu, $"BP Run To Cursor Skipping Breakpoints"/*, u, Key { f10, ctrl = true, shift = true }*/, id = RTCMenuBits { true, false, true }, NotifySelect = RTCMenu_NotifySelect; };
1993 MenuItem debugBpRunToCursorAtSameLevel { debugMenu, $"BP Run To Cursor At Same Level"/*, l, altF10*/, id = RTCMenuBits { false, true, true }, NotifySelect = RTCMenu_NotifySelect; };
1994 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; };
1996 bool RTCMenu_NotifySelect(MenuItem selection, Modifiers mods)
1998 ProjectView projectView = ide.projectView;
1999 if(!projectView.buildInProgress)
2001 RTCMenuBits bits = (RTCMenuBits)selection.id;
2002 int line = editBox.lineNumber + 1;
2005 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2006 ProjectConfig config = projectView.project.config;
2007 int bitDepth = ide.workspace.bitDepth;
2008 bool useValgrind = ide.workspace.useValgrind;
2009 ide.debugger.RunToCursor(compiler, config, bitDepth, useValgrind, fileName, line, bits.ignoreBreakpoints, bits.atSameLevel, bits.oldImplementation);
2015 MenuDivider { debugMenu };
2016 MenuItem debugToggleBreakpoint
2018 debugMenu, $"Toggle Breakpoint", t, f9;
2019 bool NotifySelect(MenuItem selection, Modifiers mods)
2021 ProjectView projectView = ide.projectView;
2022 if(projectView && fileName)
2024 int line = editBox.lineNumber + 1;
2025 ide.debugger.ToggleBreakpoint(fileName, line);
2035 //MenuItem viewDesignerItem, viewProperties, viewMethods;
2039 designer.parent = parent;
2042 toolBox = ((IDEWorkSpace)master).toolBox;
2044 // Debugger bug here: value of toolBox appears as 0
2046 sheet = ((IDEWorkSpace)master).sheet;
2051 bool OnClose(bool parentClosing)
2055 if(ide.workspace && fileName)
2056 ide.workspace.UpdateOpenedFileInfo(fileName, closed);
2057 if(inUseDebug && !debugClosing)
2059 debugClosing = true;
2061 if(CloseConfirmation(false))
2064 if(modifiedDocument)
2065 OnFileModified({ modified = true }, null);
2067 debugClosing = false;
2070 if(designer && !designer.closing)
2072 if(designer.visible)
2079 //Window formEditor = designer;
2080 //formEditor.Destroy(0);
2083 ide.AdjustFileMenus();
2088 void OnDestroy(void)
2090 ObjectInfo oClass, next;
2091 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2093 FreeType(this.functionType);
2094 FreeType(this.instanceType);
2099 designer.codeEditor = null;
2100 designer.Destroy(0);
2104 for(oClass = (classes).first, next = oClass ? oClass.next : null; oClass; oClass = next, next = next ? (next.next) : null)
2106 ObjectInfo object, next;
2108 for(object = oClass.instances.first; object; object = next)
2113 Designer::DestroyObject(object.instance);
2114 delete object.instance;
2116 if(object.i18nStrings)
2118 Map<String, bool> i18nStrings = object.i18nStrings;
2121 sheet.DeleteObject(object);
2123 oClass.instances.Delete(object);
2127 Designer::DestroyObject(oClass.instance);
2128 delete oClass.instance;
2130 if(oClass.i18nStrings)
2132 Map<String, bool> i18nStrings = oClass.i18nStrings;
2135 sheet.DeleteObject(oClass);
2137 classes.Delete(oClass);
2140 if(windowClass && windowClass.data)
2141 UnapplySkin(windowClass);
2145 if(sheet.codeEditor == this)
2147 sheet.codeEditor = null;
2148 toolBox.codeEditor = null;
2154 ProjectView projectView = ide.projectView;
2157 ProjectNode node = projectView.GetNodeFromWindow(this, null, true, false, null);
2158 if(node && node.modified)
2160 node.modified = false;
2161 projectView.Update(null);
2167 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool directActivation)
2169 // 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
2171 if(directActivation)
2172 ide.RepositionWindows(false); // Moved this up before as resizing causes NotifyCaretMove to be called on all editors
2174 if(active && directActivation)
2178 openedFileInfo.Activate();
2182 Location * loc = null;
2183 UpdateFormCode(); // To ensure update when modifying properties...
2185 // Got to the right spot in code so we don't lose our form selection...
2188 if(selected.instCode)
2189 loc = &selected.instCode.loc;
2190 else if(selected.classDefinition)
2191 loc = &selected.classDefinition.loc;
2193 line = editBox.lineNumber + 1;
2194 charPos = editBox.charPos + 1;
2199 if(selected && !loc->Inside(line, charPos))
2201 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2202 line = editBox.lineNumber + 1;
2203 charPos = editBox.charPos + 1;
2205 else if(selected && selected.classDefinition)
2208 for(object = selected.instances.first; object; object = object.next)
2212 if(object.instCode.loc.Inside(line, charPos))
2218 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2219 line = editBox.lineNumber + 1;
2220 charPos = editBox.charPos + 1;
2225 ProcessCaretMove(editBox, line, charPos);
2230 if(membersListShown)
2232 membersList.Destroy(0);
2233 membersListShown = false;
2237 paramsList.Destroy(0);
2238 paramsShown = false;
2239 FreeType(functionType);
2240 FreeType(instanceType);
2242 functionType = null;
2243 instanceType = null;
2250 bool OnSaveFile(char * fileName)
2257 f = FileOpen(fileName, write);
2260 if(!ide.projectView)
2261 ide.ChangeFileDialogsDirectory(codeEditorFileDialog.currentDirectory, true);
2265 this.fileName = fileName; // Put this here because the form designer will check for it...
2266 designer.fileName = fileName;
2267 designer.modifiedDocument = false;
2270 editBox.Save(f, false);
2271 modifiedDocument = false;
2279 bool OnFileModified(FileChange fileChange, char * param)
2281 bool reload = false;
2282 if(visible == false && inUseDebug == true)
2283 ide.debugger.WatchesReleaseCodeEditor();
2288 sprintf(message, $"The document %s was modified by another application.\n"
2289 "Would you like to reload it and lose your changes?", fileName);
2290 if(MessageBox { type = yesNo, master = /*parent = */parent, text = $"Document has been modified",
2291 contents = message }.Modal() == yes)
2297 File f = FileOpen(fileName, read);
2300 int lineNumber, charPos, len;
2304 updatingCode = true;
2305 lineNumber = editBox.lineNumber;
2306 charPos = editBox.charPos;
2307 scroll = editBox.scroll;
2310 lineNumber = lineNumber < editBox.numLines ? lineNumber : editBox.numLines - 1;
2311 len = strlen(editBox.line.text);
2312 editBox.GoToLineNum(lineNumber);
2313 editBox.GoToPosition(editBox.line, lineNumber, charPos <= len ? charPos - 1 : (len ? len - 1 : 0));
2314 editBox.scroll = scroll;
2315 updatingCode = false;
2316 loadingFile = false;
2318 codeModified = true;
2322 designer.modifiedDocument = false;
2324 modifiedDocument = false;
2332 void OnRedraw(Surface surface)
2335 surface.SetBackground(marginColor);
2336 surface.Area(0, 0, editBox.anchor.left.distance, clientSize.h - 1);
2337 if(ideSettings.showLineNumbers)
2339 int currentLineNumber;
2341 char lineFormat[16];
2345 surface.textOpacity = false;
2346 surface.font = font.font;
2347 surface.TextExtent(" ", 1, null, &spaceH);
2348 currentLineNumber = editBox.scroll.y / spaceH + 1;
2349 sprintf(lineFormat, " %%%du", maxLineNumberLength);
2351 surface.SetForeground(lineNumbersColor);
2352 for(i = 0; i < editBox.clientSize.h - 4; i += spaceH)
2354 // Highlight current line
2355 if(editBox.lineNumber == currentLineNumber - 1)
2357 surface.SetBackground(selectedMarginColor);
2358 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2359 surface.SetBackground(marginColor);
2361 sprintf(lineText, lineFormat, currentLineNumber);
2362 if(currentLineNumber <= editBox.numLines)
2363 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,maxLineNumberLength+1);
2364 currentLineNumber++;
2368 if(editBox.syntaxHighlighting && fileName && ide.projectView)
2370 bool error, bpOnCursor, bpOnTopFrame, breakpointEnabled[128];
2371 int lineCursor, lineTopFrame, breakpointLines[128];
2372 int count, i, lineH, boxH, scrollY; //, firstLine; firstLine = editBox.firstLine;
2373 Debugger debugger = ide.debugger;
2374 BitmapResource bmpRes;
2376 boxH = clientSize.h;
2377 scrollY = editBox.scroll.y;
2378 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
2380 bpOnCursor = bpOnTopFrame = false;
2381 count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
2384 for(i = 0; i < count; i++)
2386 if(breakpointLines[i] == lineCursor || breakpointLines[i] == lineTopFrame)
2388 bmpRes = breakpointEnabled[i] ? ide.bmpBpHalf : ide.bmpBpHalfDisabled;
2389 if(breakpointLines[i] == lineCursor)
2391 if(breakpointLines[i] == lineTopFrame)
2392 bpOnTopFrame = true;
2395 bmpRes = breakpointEnabled[i] ? ide.bmpBp : ide.bmpBpDisabled;
2397 DrawLineMarginIcon(surface, bmpRes, breakpointLines[i], lineH, scrollY, boxH);
2400 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
2401 bmpRes = bpOnTopFrame ? (error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf) : (error ? ide.bmpTopFrameError : ide.bmpTopFrame);
2402 DrawLineMarginIcon(surface, bmpRes, lineTopFrame, lineH, scrollY, boxH);
2404 if(editBox.anchor.left.distance)
2406 if(editBox.horzScroll && editBox.horzScroll.visible)
2408 surface.SetBackground(control);
2409 surface.Area(0, editBox.clientSize.h, editBox.anchor.left.distance, clientSize.h - 1);
2414 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
2419 lineY = (line - 1) * lineH;
2420 if(lineY + lineH > scrollY && lineY /*+ lineH*/ < scrollY + boxH)
2422 Bitmap bitmap = resource.bitmap;
2424 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
2431 char ext[MAX_EXTENSION];
2432 char * fileName = property::fileName;
2434 if(SearchString(fileName, 0, "Makefile", false, true))
2435 editBox.useTab = true;
2436 designer.fileName = fileName;
2440 GetExtension(fileName, ext);
2442 if(!strcmpi(ext, "ec") || !strcmpi(ext, "eh") || !strcmpi(ext, "c") || !strcmpi(ext, "h") || !strcmpi(ext, "cpp") ||
2443 !strcmpi(ext, "hpp") || !strcmpi(ext, "cxx") || !strcmpi(ext, "hxx") || !strcmpi(ext, "cc") || !strcmpi(ext, "hh") ||
2444 !strcmpi(ext, "m") || !strcmpi(ext, "mm") || !strcmpi(ext, "cs") || !strcmpi(ext, "java") || !strcmpi(ext, "y") || !strcmpi(ext, "l"))
2445 editBox.syntaxHighlighting = true;
2447 editBox.syntaxHighlighting = false;
2449 if(parsing && !strcmpi(ext, "ec"))
2451 codeModified = true;
2455 maxLineNumberLength = 0;
2460 bool UpdateMarginSize()
2462 if(ideSettings.showLineNumbers)
2464 int numLen = Max(4, nofdigits(editBox.numLines));
2466 maxLineNumberLength = numLen;
2467 display.FontExtent(font.font, "0", 1, &digitWidth, null);
2468 editBox.anchor = Anchor
2470 left = editBox.syntaxHighlighting * 20 + ideSettings.showLineNumbers * (maxLineNumberLength+2) * digitWidth,
2471 right = 0, top = 0, bottom = 0
2476 maxLineNumberLength = 0;
2477 editBox.anchor = Anchor
2479 left = editBox.syntaxHighlighting * 20,
2480 right = 0, top = 0, bottom = 0
2492 bool LoadFile(char * filePath)
2494 File f = FileOpen(filePath, read);
2497 // Added this here...
2498 fileName = filePath;
2500 updatingCode = true;
2502 updatingCode = false;
2503 loadingFile = false;
2512 void AdjustDebugMenus()
2514 bool unavailable = ide.areDebugMenusUnavailable;
2515 bool isNotNotRunning = unavailable || ide.isDebuggerRunning;
2516 bool isNotStopped = unavailable || !ide.isDebuggerStopped;
2517 bool noBreakpointToggle = ide.isBreakpointTogglingUnavailable;
2519 debugRunToCursor.disabled = isNotNotRunning;
2520 debugSkipRunToCursor.disabled = isNotNotRunning;
2521 debugRunToCursorAtSameLevel.disabled = isNotStopped;
2522 debugSkipRunToCursorAtSameLevel.disabled = isNotStopped;
2524 debugBpRunToCursor.disabled = isNotNotRunning;
2525 debugBpSkipRunToCursor.disabled = isNotNotRunning;
2526 debugBpRunToCursorAtSameLevel.disabled = isNotStopped;
2527 debugBpSkipRunToCursorAtSameLevel.disabled = isNotStopped;
2529 debugToggleBreakpoint.disabled = noBreakpointToggle;
2535 ProjectView projectView = ide.projectView;
2537 globalData.classes.CompareKey = (void *)BinaryTree::CompareString;
2538 globalData.defines.CompareKey = (void *)BinaryTree::CompareString;
2539 globalData.functions.CompareKey = (void *)BinaryTree::CompareString;
2540 globalData.nameSpaces.CompareKey = (void *)BinaryTree::CompareString;
2543 designer.fileName = fileName;
2549 sprintf(title, $"Untitled %d", documentID);
2550 // designer.fileName = CopyString(title);
2551 designer.fileName = title;
2556 for(c = 0; c < CodeObjectType::enumSize; c++)
2557 icons[c] = BitmapResource { iconNames[c], window = this };
2559 codeModified = true;
2571 selected.modified = true;
2572 selected.oClass.modified = true;
2574 designer.modifiedDocument = true;
2575 modifiedDocument = true;
2576 formModified = true;
2579 /****************************************************************************
2581 ****************************************************************************/
2584 SetCurrentNameSpace(null);
2590 this.defines.Free(FreeModuleDefine);
2591 this.imports.Free(FreeModuleImport); // Moved this after FreeAST because Debug printing causes ModuleImports to be created
2593 FreeExcludedSymbols(this.excludedSymbols);
2594 FreeContext(this.globalContext);
2596 FreeGlobalData(&this.globalData);
2597 FindCtx_Terminate();
2598 FindParams_Terminate();
2600 if(GetGlobalContext() == globalContext)
2602 SetGlobalData(null);
2603 SetGlobalContext(null);
2604 SetExcludedSymbols(null);
2605 SetTopContext(null);
2606 SetCurrentContext(null);
2609 SetPrivateModule(null);
2612 if(this.privateModule)
2614 FreeTypeData(this.privateModule);
2615 delete this.privateModule;
2616 this.privateModule = null;
2622 static bool reentrant = false;
2627 char * selectedClassName = null, * selectedName = null;
2628 int selectedPos = 0;
2629 Designer backDesigner;
2630 char oldWorkDir[MAX_LOCATION];
2631 char mainModuleName[MAX_FILENAME] = "";
2633 ImportedModule module;
2634 char extension[MAX_EXTENSION];
2635 PathBackup pathBackup { };
2637 Time parseCodeStart = GetTime();
2638 Time startTime, startFindClass;
2640 findClassTotalTime = 0;
2641 checkTypeTotalTime = 0;
2642 externalImportTotalTime = 0;
2643 findClassIgnoreNSTotalTime = 0;
2644 findSymbolTotalTime = 0;
2645 //ResetClassFindTime();
2649 // 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)
2650 if(reentrant) return;
2657 selectedClassName = CopyString(oClass.name);
2658 if(selected != oClass)
2660 ObjectInfo object = this.selected;
2661 selectedName = CopyString(object.name);
2665 for(check = this.oClass.instances.first; check; check = check.next)
2677 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
2679 FindCtx_Terminate();
2680 FindParams_Terminate();
2682 SetGlobalData(&globalData);
2683 SetGlobalContext(globalContext);
2684 SetExcludedSymbols(&excludedSymbols);
2685 SetTopContext(globalContext);
2686 SetCurrentContext(globalContext);
2687 SetDefines(&defines);
2688 SetImports(&imports);
2689 SetCurrentNameSpace(null);
2692 sprintf(command, "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin\\cl "
2693 "/nologo /D \"MSC\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" "
2694 "/I \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include\" "
2695 "/I T:\\ecere\\include /E %s", argv[1]);
2699 ChangeWorkingDir("e:\\ec");
2700 sprintf(command, "gcc -x c -E -");
2701 fileInput = DualPipeOpen({ output = true, input = true }, command);
2702 SetFileInput(fileInput);
2707 uint count = editFile.Read(buffer, 1, sizeof(buffer));
2709 fileInput.Write(buffer, 1, count);
2714 fileInput.CloseOutput();
2718 // TOCHECK: COULDN'T WE CALL FreeParser here?
2720 FreeType(this.functionType);
2721 FreeType(this.instanceType);
2722 this.functionType = null;
2723 this.instanceType = null;
2726 sheet.SelectObject(null);
2732 // We don't want the designer to be notified of selection when deleting rows...
2733 backDesigner = designer;
2738 ObjectInfo _class, next;
2740 for(_class = classes.first; _class; _class = next)
2746 for(;object = _class.instances.first;)
2750 Designer::DestroyObject(object.instance);
2751 delete object.instance;
2753 if(object.i18nStrings)
2755 Map<String, bool> i18nStrings = object.i18nStrings;
2758 sheet.DeleteObject(object);
2760 _class.instances.Delete(object);
2764 Designer::DestroyObject(_class.instance);
2765 delete _class.instance;
2767 if(_class.i18nStrings)
2769 Map<String, bool> i18nStrings = _class.i18nStrings;
2772 sheet.DeleteObject(_class);
2774 classes.Delete(_class);
2780 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2781 if(windowClass && windowClass.data)
2782 UnapplySkin(windowClass);
2785 designer = backDesigner;
2788 fileInput = editFile = EditBoxStream { editBox = editBox };
2789 SetFileInput(fileInput);
2797 defines.Free(FreeModuleDefine);
2798 imports.Free(FreeModuleImport);
2800 FreeContext(this.globalContext);
2801 FreeExcludedSymbols(this.excludedSymbols);
2804 FreeGlobalData(&this.globalData);
2806 if(this.privateModule)
2808 FreeTypeData(this.privateModule);
2809 delete this.privateModule;
2813 startTime = GetTime();
2814 printf("Cleaning up took %.3f seconds\n", startTime - parseCodeStart);
2816 printf("classes.count: %d\n", globalContext.classes.count);
2821 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2822 SetTargetBits(ide.workspace.bitDepth ? ide.workspace.bitDepth : GetHostBits());
2825 this.privateModule = __ecere_COM_Initialize(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4), 1, null);
2827 SetPrivateModule(privateModule);
2830 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint"), type = ProcessTypeString("unsigned int", false) });
2831 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint64"), type = ProcessTypeString("unsigned int64", false) });
2832 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint32"), type = ProcessTypeString("unsigned int", false) });
2833 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint16"), type = ProcessTypeString("unsigned short", false) });
2834 globalContext.types.Add((BTNode)Symbol { string = CopyString("byte"), type = ProcessTypeString("unsigned char", false) });
2837 fileName = this.fileName;
2839 if(ide.workspace && ide.workspace.projects && fileName)
2841 for(p : ide.workspace.projects)
2843 char path[MAX_LOCATION];
2845 MakePathRelative(fileName, p.topNode.path, path);
2846 MakeSlashPath(path);
2848 pn = p.topNode.FindWithPath(path, false);
2857 project = ide.project;
2859 GetWorkingDir(oldWorkDir, MAX_LOCATION);
2861 ChangeWorkingDir(project.topNode.path);
2863 SetSomeSourceFileStack(fileName ? fileName : "", 0); //strcpy(sourceFileStack[0], fileName ? fileName : "");
2865 GetLastDirectory(fileName, mainModuleName);
2866 GetExtension(mainModuleName, extension);
2868 SetBuildingEcereCom(false);
2869 SetBuildingEcereComModule(false);
2871 // TODO: Get symbolsDir from project settings instead...
2874 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2875 ProjectConfig config = project.config;
2876 int bitDepth = ide.workspace.bitDepth;
2877 DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
2878 SetSymbolsDir(objDir.dir);
2879 ide.SetPath(true, compiler, config, bitDepth);
2883 // SetIncludeDirs(ide.projectView.project.config.includeDirs);
2884 // SetSysIncludeDirs(ide.ideSettings.systemDirs[includes]);
2888 switch(GetRuntimePlatform())
2890 case win32: SetSymbolsDir("obj/debug.win32"); break;
2891 case tux: SetSymbolsDir("obj/debug.linux"); break;
2892 case apple: SetSymbolsDir("obj/debug.apple"); break;
2894 SetIncludeDirs(null);
2895 SetSysIncludeDirs(null);
2899 if(ide.projectView && ide.projectView.IsModuleInProject(this.fileName))
2901 // TODO FIX for configless project
2902 if(ide.project.config && ide.project.config.options && ide.project.config.options.preprocessorDefinitions)
2904 for(item : ide.project.config.options.preprocessorDefinitions)
2906 if(!strcmp(item, "BUILDING_ECERE_COM"))
2908 SetBuildingEcereCom(true);
2915 if(!(strcmpi(mainModuleName, "instance.ec") && strcmpi(mainModuleName, "BinaryTree.ec") &&
2916 strcmpi(mainModuleName, "dataTypes.ec") && strcmpi(mainModuleName, "OldList.ec") &&
2917 strcmpi(mainModuleName, "String.ec") && strcmpi(mainModuleName, "BTNode.ec") &&
2918 strcmpi(mainModuleName, "Array.ec") && strcmpi(mainModuleName, "AVLTree.ec") &&
2919 strcmpi(mainModuleName, "BuiltInContainer.ec") && strcmpi(mainModuleName, "Container.ec") &&
2920 strcmpi(mainModuleName, "CustomAVLTree.ec") && strcmpi(mainModuleName, "LinkList.ec") &&
2921 strcmpi(mainModuleName, "List.ec") && strcmpi(mainModuleName, "Map.ec") &&
2922 strcmpi(mainModuleName, "Mutex.ec")))
2924 SetBuildingEcereComModule(true);
2927 // Predeclare all classes
2929 char symFile[MAX_FILENAME];
2930 char symLocation[MAX_LOCATION];
2931 ImportedModule module, next;
2933 GetLastDirectory(fileName, symFile);
2934 ChangeExtension(symFile, "sym", symFile);
2936 strcpy(symLocation, GetSymbolsDir());
2937 PathCat(symLocation, symFile);
2939 // if(!GetEcereImported() && !GetBuildingEcereCom())
2940 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2943 startTime = GetTime();
2945 eModule_LoadStrict(privateModule, "ecereCOM", privateAccess);
2947 printf("Loading ecereCOM took %.3f seconds\n", GetTime() - startTime);
2952 startTime = GetTime();
2954 // LoadSymbols(symLocation, normalImport, true);
2955 LoadSymbols(symLocation, preDeclImport, false);
2957 printf("Loading symbols took %.3f seconds\n", GetTime() - startTime);
2960 for(module = defines.first; module; module = next)
2963 if(module.type == moduleDefinition && strcmpi(module.name, mainModuleName))
2966 defines.Delete(module);
2971 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2973 SetDefaultDeclMode(privateAccess);
2974 SetDeclMode(privateAccess);
2978 SetDefaultDeclMode(defaultAccess);
2979 SetDeclMode(defaultAccess);
2982 StripExtension(mainModuleName);
2983 module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };
2984 defines.AddName(module);
2987 // SetYydebug(true);
2992 startTime = GetTime();
2993 startFindClass = checkTypeTotalTime;
2997 printf("ParseEc took %.3f seconds, out of which %.3f seconds were in CheckType\n", GetTime() - startTime, checkTypeTotalTime - startFindClass);
2999 CheckDataRedefinitions();
3002 SetIncludeDirs(null);
3003 SetSysIncludeDirs(null);
3014 startTime = GetTime();
3016 PrePreProcessClassDefinitions();
3017 ComputeModuleClasses(privateModule);
3018 PreProcessClassDefinitions();
3019 ProcessClassDefinitions();
3021 printf("Initial Passes took %.3f seconds\n", GetTime() - startTime);
3022 startTime = GetTime();
3027 printf("ComputeDataTypes took %.3f seconds\n", GetTime() - startTime);
3028 startTime = GetTime();
3030 ProcessInstantiations();
3032 printf("ProcessInstantiations took %.3f seconds\n", GetTime() - startTime);
3035 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
3037 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3038 if(!windowClass || windowClass.internalDecl)
3041 startTime = GetTime();
3043 // *** COMMENTED THIS OUT DUE TO ecereCOM issues
3044 // eModule_Load(this.privateModule.application.allModules.first ? this.privateModule.application.allModules.first : this.privateModule, "ecere", privateAccess);
3045 eModule_Load(this.privateModule, "ecere", privateAccess);
3047 printf("Loading ecere.dll took %.3f seconds\n", GetTime() - startTime);
3050 windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3052 if(windowClass && windowClass.data)
3053 ApplySkin(windowClass, app.currentSkin.name, null);
3057 startTime = GetTime();
3059 for(external = ast->first; external; external = external.next)
3061 if(external.type == classExternal)
3063 ClassDefinition _class = external._class;
3064 if(_class.baseSpecs && _class.baseSpecs->first && ((Specifier)_class.baseSpecs->first).type == nameSpecifier ) // classSpecifier
3066 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)_class.baseSpecs->first).name);
3069 if(eClass_GetDesigner(regClass) && !GetBuildingEcereComModule())
3071 Instance instance = eInstance_New(regClass);
3072 ObjectInfo classObject
3074 name = CopyString(_class._class.name);
3075 instance = instance;
3076 classDefinition = _class;
3077 oClass = classObject;
3080 classes.Add(classObject);
3084 // Moved this at bottom so that the file dialog doesn't show up in eCom
3085 designer.CreateObject(instance, classObject, true, null);
3086 sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, typeClass, false);
3088 if(_class.definitions)
3092 for(def = _class.definitions->first; def; def = def.next)
3096 case defaultPropertiesClassDef:
3099 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
3101 Identifier id = propDef.identifiers->first;
3104 Property prop = eClass_FindProperty(regClass, id.string, this.privateModule);
3107 Class propertyClass = prop.dataTypeClass;
3109 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3110 if(prop.compiled && prop.Set && prop.Get && propertyClass && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp)
3112 Expression computed;
3113 bool variable = true;
3115 FreeType(propDef.initializer.exp.destType);
3116 propDef.initializer.exp.destType = MkClassType(propertyClass.name);
3117 ProcessExpressionType(propDef.initializer.exp);
3119 computed = CopyExpression(propDef.initializer.exp);
3120 ComputeExpression(computed);
3121 if(computed.isConstant)
3123 switch(computed.type)
3126 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3128 String temp = new char[strlen(computed.string)+1];
3129 ReadString(temp, computed.string);
3130 ((void (*)(void *, void *))(void *)prop.Set)(instance, temp);
3133 if(!propDef.initializer.exp.intlString)
3135 Map<String, bool> i18nStrings = classObject.i18nStrings;
3137 classObject.i18nStrings = i18nStrings = { };
3138 i18nStrings[prop.name] = false;
3144 if((propertyClass.type == structClass || propertyClass.type == noHeadClass || propertyClass.type == normalClass) && !id.next)
3148 if(computed.instance._class && computed.instance._class.symbol &&
3149 computed.instance._class.symbol.registered &&
3150 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3152 ((void (*)(void *, void *))(void *)prop.Set)(instance, computed.instance.data);
3154 // This was saved in the control and shouldn't be freed by FreeExpression...
3155 // (Not doing this anymore, incrementing refCount in pass15 instead)
3156 /*if(propertyClass.type == normalClass)
3157 computed.instance.data = null;*/
3165 Operand value = GetOperand(computed);
3166 DataValue valueData;
3167 valueData.i64 = value.i64;
3168 SetProperty(prop, instance, valueData);
3175 propDef.variable = true;
3176 FreeExpression(computed);
3181 Method method = eClass_FindMethod(regClass, id.string, this.privateModule);
3182 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer &&
3183 propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
3186 // Maintain a list in FunctionDefinition of who is attached to it
3187 for(def = _class.definitions->first; def; def = def.next)
3189 if(def.type == functionClassDef)
3191 ClassFunction function = def.function;
3192 if(!strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
3194 function.attached.Add(OldLink { data = method });
3204 case declarationClassDef:
3206 Declaration decl = def.decl;
3209 case instDeclaration:
3211 Instantiation inst = decl.inst;
3212 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3213 if(instClass && eClass_GetDesigner(instClass))
3215 Instance control = eInstance_New(instClass);
3220 oClass = classObject;
3224 classObject.instances.Add(object);
3226 // TOCHECK: Why is this needed now?
3227 object.name = CopyString((inst.exp.type == memberExp) ? inst.exp.member.member.string : inst.exp.identifier.string);
3228 def.object = object;
3230 // if(object.name) { symbol = eList_Add(&curContext.symbols, sizeof(Symbol)); symbol.string = object.name; symbol.type = MkClassType(instClass.name); }
3232 designer.CreateObject(control, object, false, classObject.instance);
3233 sheet.AddObject(object, object.name ? object.name : inst._class.name, typeData, false);
3243 // Second pass, process instantiation members
3245 for(def = _class.definitions->first; def; def = def.next)
3249 case declarationClassDef:
3251 Declaration decl = def.decl;
3254 case instDeclaration:
3256 Instantiation inst = decl.inst;
3257 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3258 if(instClass && eClass_GetDesigner(instClass))
3261 object = object ? object.next : classObject.instances.first;
3262 control = object.instance;
3266 MembersInit members;
3267 for(members = inst.members->first; members; members = members.next)
3269 switch(members.type)
3271 case dataMembersInit:
3273 if(members.dataMembers)
3276 DataMember curMember = null;
3277 Class curClass = null;
3278 DataMember subMemberStack[256];
3279 int subMemberStackPos = 0;
3281 for(member = members.dataMembers->first; member; member = member.next)
3284 Identifier ident = member.identifiers ? member.identifiers->first : null;
3287 DataMember _subMemberStack[256];
3288 int _subMemberStackPos = 0;
3289 DataMember thisMember = (DataMember)eClass_FindDataMember(instClass, ident.string, privateModule, _subMemberStack, &_subMemberStackPos);
3293 thisMember = (DataMember)eClass_FindProperty(instClass, ident.string, privateModule);
3295 if(thisMember && thisMember.memberAccess == publicAccess)
3297 curMember = thisMember;
3298 curClass = curMember._class;
3299 memcpy(subMemberStack, _subMemberStack, sizeof(DataMember) * _subMemberStackPos);
3300 subMemberStackPos = _subMemberStackPos;
3306 eClass_FindNextMember(instClass, &curClass, (DataMember *)&curMember, subMemberStack, &subMemberStackPos);
3307 if(curMember) found = true;
3309 if(found && curMember.isProperty)
3311 Property prop = (Property) curMember;
3312 Class propertyClass = prop.dataTypeClass;
3313 bool variable = false;
3315 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3317 if(prop.compiled && prop.Set && prop.Get && propertyClass && member.initializer && member.initializer.type == expInitializer && member.initializer.exp)
3319 FreeType(member.initializer.exp.destType);
3320 member.initializer.exp.destType = MkClassType(propertyClass.name);
3323 Expression computed;
3325 ProcessExpressionType(member.initializer.exp);
3327 computed = CopyExpression(member.initializer.exp);
3330 bool isClass = propertyClass.type == structClass || propertyClass.type == normalClass || propertyClass.type == noHeadClass;
3333 /*char debugExpString[4096];
3334 debugExpString[0] = '\0';
3335 PrintExpression(member.initializer.exp, debugExpString);*/
3337 ComputeExpression(computed);
3339 switch(computed.type)
3342 if(isClass && computed.isConstant && computed.instance.data)
3344 if(computed.instance._class && computed.instance._class.symbol &&
3345 computed.instance._class.symbol.registered &&
3346 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3348 ((void (*)(void *, void *))(void *)prop.Set)(control, computed.instance.data);
3350 // This was saved in the control and shouldn't be freed by FreeExpression...
3351 // (Not doing this anymore, incrementing refCount in pass15 instead)
3352 /*if(propertyClass.type == normalClass)
3353 computed.instance.data = null;*/
3359 if(isClass && eClass_GetDesigner(propertyClass))
3362 char * name = computed.identifier.string;
3363 if(!strcmp(name, "this"))
3366 ((void (*)(void *, void *))(void *)prop.Set)(control, instance);
3372 for(check = classObject.instances.first; check; check = check.next)
3373 if(check.name && !strcmp(name, check.name))
3376 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3386 if(computed.member.exp.type == identifierExp)
3388 char * name = computed.member.exp.identifier.string;
3390 if(!strcmp(name, "this"))
3392 char * name = computed.member.member.string;
3394 for(check = classObject.instances.first; check; check = check.next)
3395 if(check.name && !strcmp(name, check.name))
3398 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3405 for(check = classObject.instances.first; check; check = check.next)
3407 if(check.name && !strcmp(name, check.name))
3409 Property getProperty = eClass_FindProperty(check.instance._class, computed.member.member.string, this.privateModule);
3412 DataValue value { };
3413 GetProperty(getProperty, check.instance, &value);
3414 SetProperty(prop, control, value);
3425 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3427 String temp = new char[strlen(computed.string)+1];
3428 ReadString(temp, computed.string);
3429 ((void (*)(void *, void *))(void *)prop.Set)(control, temp);
3432 if(!member.initializer.exp.intlString)
3434 Map<String, bool> i18nStrings = object.i18nStrings;
3436 object.i18nStrings = i18nStrings = { };
3437 i18nStrings[prop.name] = false;
3444 if(!isClass && computed.isConstant)
3446 if(!strcmp(propertyClass.dataTypeString, "float"))
3447 ((void (*)(void *, float))(void *)prop.Set)(control, (float)strtod(computed.constant, null));
3448 else if(!strcmp(propertyClass.dataTypeString, "double"))
3449 ((void (*)(void *, double))(void *)prop.Set)(control, strtod(computed.constant, null));
3451 ((void (*)(void *, int))(void *)prop.Set)(control, strtol(computed.constant, null, 0));
3458 FreeExpression(computed);
3462 member.variable = true;
3464 else if(ident && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3465 member.initializer.exp.type == memberExp) // identifierExp
3467 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3468 if(method && method.type == virtualMethod)
3471 // Maintain a list in FunctionDefinition of who is attached to it
3472 for(def = _class.definitions->first; def; def = def.next)
3474 if(def.type == functionClassDef)
3476 ClassFunction function = def.function;
3477 Identifier id = (member.initializer.exp.type == memberExp) ? member.initializer.exp.member.member : member.initializer.exp.identifier;
3478 if(function.declarator && !strcmp(function.declarator.symbol.string, id.string))
3480 function.attached.Add(OldLink { data = method });
3481 // Reference this particular instance?
3496 designer.PostCreateObject(object.instance, object, false, classObject.instance);
3507 //designer.CreateObject(instance, classObject, true, null);
3508 //sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, classType, false);
3510 designer.PostCreateObject(instance, classObject, true, null);
3512 //instance.state = Hidden;
3513 //instance.Create();
3514 //instance.SetState(Normal, true, 0);
3523 printf("Class/Instance Processing took %.3f seconds\n", GetTime() - startTime);
3527 // Restore Selection
3528 if(selectedClassName)
3531 for(oClass = classes.first; oClass; oClass = oClass.next)
3533 if(!strcmp(oClass.name, selectedClassName))
3535 this.oClass = oClass;
3539 delete selectedClassName;
3548 for(check = this.oClass.instances.first; check; check = check.next)
3550 if(check.name && !strcmp(check.name, selectedName))
3552 this.selected = check;
3558 if(this.oClass.instances.first)
3559 this.selected = this.oClass.instances.first;
3561 this.selected = this.oClass;
3564 else if(selectedPos == -1 || !this.oClass.instances.count)
3565 this.selected = this.oClass;
3571 if(selectedPos > this.oClass.instances.count)
3573 for(check = this.oClass.instances.first; check; check = check.next)
3575 if(selectedPos == pos++)
3577 this.selected = check;
3585 this.oClass = classes.first;
3586 this.selected = (this.oClass && this.oClass.instances.first) ? this.oClass.instances.first : this.oClass;
3588 delete selectedName;
3589 SetSymbolsDir(null);
3591 if(sheet.codeEditor == this)
3592 sheet.SelectObject(selected);
3595 codeModified = false;
3597 // TESTING THIS TO NOT GET EMPTY PARAMETERS
3600 InvokeParameters(false, false, false);
3603 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
3609 ChangeWorkingDir(oldWorkDir);
3611 printf("Total FindClass time is %.3f seconds, out of which %.3f is in Ignore NS\n\n", findClassTotalTime, findClassIgnoreNSTotalTime);
3612 printf("Total CheckType time is %.3f seconds\n\n", checkTypeTotalTime);
3613 printf("Total MkExternalImport time is %.3f seconds\n\n", externalImportTotalTime);
3614 printf("Total FindSymbol time is %.3f seconds\n\n", findSymbolTotalTime);
3615 // printf("Total Class Members Find time is %.3f seconds\n\n", GetClassFindTime());
3617 printf("Whole ParseCode function took %.3f seconds\n\n", GetTime() - parseCodeStart);
3619 if(inUseDebug && ide.projectView)
3620 ide.debugger.EvaluateWatches();
3625 void UpdateInstanceCodeClass(Class _class, ObjectInfo object, EditBoxStream f, Instance test, bool * prev, bool * lastIsMethod, DataMember * curMember, Class * curClass)
3628 Window control = (Window)object.instance;
3629 ObjectInfo classObject = object.oClass;
3631 if(_class.base && _class.base.type != systemClass) UpdateInstanceCodeClass(_class.base, object, f, test, prev, lastIsMethod, curMember, curClass);
3633 if(!strcmp(_class.name, "DesignerBase")) return;
3635 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
3637 Property prop = eClass_FindProperty(object.instance._class, propIt.name, privateModule);
3638 if(prop && prop.isProperty && !prop.conversion && eClass_FindProperty(object.instance._class, prop.name, privateModule))
3640 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(object, prop.name) &&
3641 prop.compiled && (!prop.IsSet || prop.IsSet(control)))
3643 Class dataType = prop.dataTypeClass;
3645 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3649 if(dataType.type == structClass)
3651 void * dataForm = new0 byte[dataType.structSize];
3652 void * dataTest = new0 byte[dataType.structSize];
3654 ((void (*)(void *, void *))(void *)prop.Get)(control, dataForm);
3655 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
3657 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3659 char tempString[1024] = "";
3661 bool needClass = true;
3665 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3667 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3669 eClass_FindNextMember(_class, curClass, curMember, null, null);
3670 if(*curMember != (DataMember)prop)
3671 f.Printf("%s = ", prop.name);
3673 *curMember = (DataMember)prop;
3674 *curClass = curMember->_class;
3677 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3679 f.Printf("%s", string);
3686 else if(dataType.type == normalClass || dataType.type == noHeadClass)
3688 void * dataForm, * dataTest;
3689 bool isEditBoxContents = false;
3690 bool freeDataForm = false, freeDataTest = false;
3692 // Because contents property is broken for mutiline EditBox at the moment
3693 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
3694 isEditBoxContents = true;
3696 if(isEditBoxContents && ((EditBox)control).multiLine)
3698 dataForm = ((EditBox)control).multiLineContents;
3699 freeDataForm = true;
3702 dataForm = ((void *(*)(void *))(void *)prop.Get)(control);
3703 if(isEditBoxContents && ((EditBox)test).multiLine)
3705 dataTest = ((EditBox)test).multiLineContents;
3706 freeDataTest = true;
3709 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
3711 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3713 char tempString[1024] = "";
3718 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3720 eClass_FindNextMember(_class, curClass, curMember, null, null);
3721 if(*curMember != (DataMember)prop)
3722 f.Printf("%s = ", prop.name);
3723 *curMember = (DataMember)prop;
3724 *curClass = curMember->_class;
3726 if(eClass_GetDesigner(dataType))
3728 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
3729 //if(!strcmp(classObject.instance._class.name, dataType.name) && classObject.instance == dataForm)
3730 f.Printf("this", prop.name);
3733 //ObjectInfo classObject;
3734 //for(classObject = classes.first; classObject; classObject = classObject.next)
3738 for(object = classObject.instances.first; object; object = object.next)
3740 if(!object.deleted && eClass_IsDerived(object.instance._class, dataType) && object.instance == dataForm && object.name)
3742 f.Printf("%s", object.name);
3749 bool needClass = true;
3750 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3751 f.Printf("%s", string);
3758 bool needClass = true;
3759 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3761 if(!strcmp(dataType.dataTypeString, "char *"))
3763 Map<String, bool> i18nStrings = object.i18nStrings;
3765 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
3768 f.Printf("%s\"", i18n ? "$" : "");
3769 OutputString(f, string);
3773 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3775 f.Printf("%s", string);
3778 *lastIsMethod = false;
3781 if(freeDataForm) delete dataForm;
3782 if(freeDataTest) delete dataTest;
3786 DataValue dataForm, dataTest;
3788 GetProperty(prop, control, &dataForm);
3789 GetProperty(prop, test, &dataTest);
3791 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
3794 char tempString[1024] = "";
3795 SetProperty(prop, test, dataForm);
3797 if(dataType.type != bitClass)
3799 bool needClass = true;
3801 if(dataType.type == enumClass)
3804 Class enumClass = eSystem_FindClass(privateModule, "enum");
3805 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
3807 for(value = e.values.first; value; value = value.next)
3809 if((int)value.data == dataForm.i)
3811 string = value.name;
3817 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
3819 if(string && string[0])
3824 eClass_FindNextMember(_class, curClass, curMember, null, null);
3825 if(*curMember != (DataMember)prop)
3826 f.Printf("%s = ", prop.name);
3827 *curMember = (DataMember)prop;
3828 *curClass = curMember->_class;
3830 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
3831 f.Printf("%sf", string);
3833 f.Printf("%s", string);
3837 else if(dataType.type == bitClass)
3839 bool needClass = true;
3841 if(*prev) f.Printf(", ");
3843 eClass_FindNextMember(_class, curClass, curMember, null, null);
3844 if(*curMember != (DataMember)prop)
3845 f.Printf("%s = ", prop.name);
3846 *curMember = (DataMember)prop;
3847 *curClass = curMember->_class;
3849 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm.ui, tempString, null, &needClass);
3851 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3853 f.Printf("%s", string);
3855 *lastIsMethod = false;
3865 int UpdateInstanceCode(EditBoxStream f, int position, Class regClass, ObjectInfo object, bool * firstObject, char ** text, int * textSize, int movedFuncIdLen, int movedFuncIdPos)
3867 Instantiation inst = object.instCode;
3868 Window control = (Window)object.instance;
3870 bool methodPresent = false;
3872 bool lastIsMethod = true;
3873 ObjectInfo classObject = object.oClass;
3879 // Instance removed, delete it
3880 DeleteJunkBefore(f, inst.loc.start.pos, &position);
3882 f.DeleteBytes(inst.loc.end.pos - inst.loc.start.pos + 1);
3883 position = inst.loc.end.pos + 1;
3887 bool multiLine = false;
3890 // Check if it's an unnamed instance
3893 f.Seek(inst.nameLoc.start.pos - position, current);
3894 f.DeleteBytes(inst.nameLoc.end.pos - inst.nameLoc.start.pos);
3895 position = inst.nameLoc.end.pos;
3897 f.Printf(object.name);
3902 if(isspace(ch) && ch != '\n')
3904 f.Seek(-1, current);
3912 int pos = inst.loc.start.pos; // + strlen(inst._class.name);
3914 f.Seek(pos - position, current);
3919 f.Seek(-1, current);
3928 f.Puts(object.name);
3933 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
3934 methodPresent = true;
3942 if(ch == OpenBracket)
3948 // TODO: Simplify this?
3957 f.Seek(-1, current);
3958 DeleteJunkBefore(f, position, &position);
3970 if(ch == '\n') { toDelete = count; count = 0; }
3971 else if(isspace(ch)) count++;
3974 f.Seek(-1, current);
3978 toDelete += count - 6;
3988 f.Seek(-toDelete-count, current);
3989 f.DeleteBytes(toDelete);
3990 f.Seek(count, current);
3993 DeleteJunkBefore(f, position, &position);
3995 // Removed this here as it was adding trailing spaces when adding a method
4000 for(c = 0; c<toAdd; c++)
4007 methodPresent = multiLine;
4009 //if(!prev) -- always false
4010 f.Printf(methodPresent ? "\n " : " ");
4015 // Instance not there, create a brand new one
4016 DeleteJunkBefore(f, position, &position);
4017 f.Printf(*firstObject ? "\n\n" : "\n");
4018 *firstObject = false;
4020 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
4021 methodPresent = true;
4026 f.Printf(" %s %s\n %c\n ", control._class.name, object.name, OpenBracket);
4028 f.Printf(" %s\n %c\n ", control._class.name, OpenBracket);
4033 f.Printf(" %s %s %c ", control._class.name, object.name, OpenBracket);
4035 f.Printf(" %s %c ", control._class.name, OpenBracket);
4041 Instance test = eInstance_New(control._class);
4042 DataMember curMember = null;
4043 Class curClass = null;
4046 UpdateInstanceCodeClass(control._class, object, f, test, &prev, &lastIsMethod, &curMember, &curClass);
4050 // Attach Method here
4051 if((this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod) && !this.moveAttached && this.selected == object)
4053 if(prev) f.Printf(", ");
4054 f.Printf("%s = %s", this.method.name, function.declarator.symbol.string);
4059 if(inst && !object.deleted)
4061 MembersInit members;
4062 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
4064 DeleteJunkBefore(f, position, &position);
4066 // Instance already there, clear out the properties
4067 for(members = inst.members ? inst.members->first : null; members; members = members.next)
4069 if(members.type == dataMembersInit)
4073 if(members.dataMembers)
4075 bool keptMember = false;
4076 MemberInit lastKept = null;
4078 for(member = members.dataMembers->first; member; member = member.next)
4080 Identifier ident = member.identifiers ? member.identifiers->first : null;
4081 bool deleted = false;
4083 // For now delete if it's not a method
4084 if(!member.variable) // && ident)
4086 if(!ident || !ident.next)
4088 Property prop = ident ? eClass_FindProperty(instClass, ident.string, this.privateModule) : null;
4091 f.Seek(member.loc.start.pos - position, current);
4092 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4093 position = member.loc.end.pos;
4098 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
4099 if(method && method.type == virtualMethod && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
4100 member.initializer.exp.type == memberExp /*ExpIdentifier*/)
4102 if(((this.methodAction == actionDetachMethod || this.methodAction == actionReattachMethod) && this.method == method && this.selected == object) ||
4103 (this.methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, member.initializer.exp.identifier.string)))
4105 f.Seek(member.loc.start.pos - position, current);
4106 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4107 position = member.loc.end.pos;
4119 //f.Seek(member.loc.start.pos - position, current);
4120 //position = member.loc.start.pos;
4121 DeleteJunkBefore(f, member.loc.start.pos, &position);
4122 if(prev) f.Printf(", ");
4123 else if(keptMember) f.Printf(" ");
4128 if(!keptMember || !members.next)
4133 if(keptMember && lastKept != members.dataMembers->last)
4138 f.Seek(-1, current);
4144 f.Seek(-1, current);
4147 else if(!isspace(ch))
4149 f.Seek(-2, current);
4154 f.DeleteBytes(count);
4157 f.Seek(members.loc.end.pos - position, current);
4162 f.Seek(-1, current);
4164 position = members.loc.end.pos + 1;
4168 f.Seek(-1, current);
4169 position = members.loc.end.pos;
4175 lastIsMethod = false;
4180 DeleteJunkBefore(f, position, &position);
4183 if(lastKept != members.dataMembers->last)
4188 f.Seek(-1, current);
4194 f.Seek(-1, current);
4197 else if(!isspace(ch))
4199 f.Seek(-2, current);
4204 f.DeleteBytes(count);
4208 f.Seek(members.loc.end.pos - position, current);
4209 position = members.loc.end.pos;
4213 lastIsMethod = true;
4216 lastIsMethod = false;
4222 f.Seek(members.loc.end.pos - position, current);
4223 position = members.loc.end.pos;
4225 lastIsMethod = true;
4228 else if(members.type == methodMembersInit)
4230 if(this.methodAction == actionDeleteMethod && members.function == function);
4232 methodPresent = true;
4234 // Delete instance method here
4235 if((this.methodAction == actionDeleteMethod || (this.methodAction == actionDetachMethod && this.moveAttached)) &&
4236 members.function == function)
4238 if(this.moveAttached && !*text)
4239 GetLocText(editBox, f, position, &function.loc, text, textSize, Max((int)strlen(this.methodName) - movedFuncIdLen,0), 0);
4241 DeleteJunkBefore(f, members.loc.start.pos, &position);
4242 f.DeleteBytes(members.loc.end.pos - members.loc.start.pos + 1);
4243 position = members.loc.end.pos + 1;
4248 DeleteJunkBefore(f, position, &position);
4252 DeleteJunkBefore(f, members.loc.start.pos, &position);
4253 lastIsMethod = true;
4257 f.Seek(members.loc.end.pos - position, current);
4258 position = members.loc.end.pos;
4260 DeleteJunkBefore(f, position, &position);
4269 if((this.methodAction == actionAddMethod || (this.moveAttached && (this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod))) && this.selected == object)
4271 Method method = this.method;
4272 DeleteJunkBefore(f, position, &position);
4278 if(!method.dataType)
4279 method.dataType = ProcessTypeString(method.dataTypeString, false);
4282 Type dataType = method.dataType;
4283 Type returnType = dataType.returnType;
4286 if(this.moveAttached)
4288 // Move function here:
4289 int newLen = strlen(method.name);
4294 GetLocText(editBox, f, position, &function.loc, text, textSize, Max(newLen - movedFuncIdLen, 0), 3);
4296 // First change name of function
4297 memmove(*text + movedFuncIdPos + newLen, *text + movedFuncIdPos + movedFuncIdLen, *textSize - movedFuncIdPos - movedFuncIdLen + 1);
4298 *textSize += newLen - movedFuncIdLen;
4299 memcpy(*text + movedFuncIdPos, method.name, newLen);
4301 // Second, tab right
4304 for(c = 0; (*text)[c]; )
4307 for(i = c; (*text)[i] && (*text)[i] != '\n'; i++);
4310 memmove((*text)+c+3, (*text)+c, *textSize+1-c);
4311 (*text)[c] = (*text)[c+1] = (*text)[c+2] = ' ';
4315 for(; (*text)[c] && (*text)[c] != '\n'; c++);
4325 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4327 // ADDING METHOD HERE
4329 OutputType(f, returnType, false);
4332 if(dataType.thisClass)
4334 if(!eClass_IsDerived(regClass, dataType.thisClass.registered) && !dataType.classObjectType) // Just fixed this... was backwards.
4336 if(dataType.thisClass.shortName)
4337 f.Printf(dataType.thisClass.shortName);
4339 f.Printf(dataType.thisClass.string);
4343 f.Printf(method.name);
4345 for(param = dataType.params.first; param; param = param.next)
4347 OutputType(f, param, true);
4352 f.Printf(" %c\n\n", OpenBracket);
4354 if(control._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4356 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4357 f.Printf(" return true;\n");
4358 else if(returnType.kind != voidType)
4359 f.Printf(" return 0;\n");
4364 if(returnType.kind != voidType)
4365 f.Printf("return ");
4366 f.Printf("%s::%s(", control._class.name, method.name);
4367 for(param = dataType.params.first; param; param = param.next)
4369 if(param.prev) f.Printf(", ");
4370 if(param.kind != voidType)
4371 f.Printf(param.name);
4375 f.Printf(" %c\n", CloseBracket);
4381 if(!object.instCode)
4382 f.Printf(methodPresent ? " %c;" : "%c;", CloseBracket);
4383 else if(!object.deleted)
4385 // Turn this into a multiline instance when adding a method
4386 DeleteJunkBefore(f, inst.loc.end.pos-1, &position);
4388 f.Printf(methodPresent ? "\n " : " ");
4390 f.Seek(inst.loc.end.pos + 1 - position, current);
4391 position = inst.loc.end.pos + 1;
4396 void OutputClassProperties(Class _class, ObjectInfo classObject, EditBoxStream f, Instance test)
4399 Class regClass = eSystem_FindClass(privateModule, classObject.name);
4401 if(_class.base && _class.base.type != systemClass) OutputClassProperties(_class.base, classObject, f, test);
4403 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
4405 Property prop = eClass_FindProperty(selected.instance._class, propIt.name, privateModule);
4406 if(prop && prop.isProperty && !prop.conversion)
4408 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(classObject, prop.name) &&
4409 (!prop.IsSet || prop.IsSet(classObject.instance)))
4411 Class dataType = prop.dataTypeClass;
4412 char tempString[1024] = "";
4414 bool specify = false;
4417 member = eClass_FindDataMember(regClass, prop.name, privateModule, null, null);
4418 if(member && member._class == regClass)
4422 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
4424 if(dataType && dataType.type == structClass)
4426 void * dataForm = new0 byte[dataType.structSize];
4427 void * dataTest = new0 byte[dataType.structSize];
4429 ((void (*)(void *, void *))(void *)prop.Get)(classObject.instance, dataForm);
4430 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
4432 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4434 bool needClass = true;
4436 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4437 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4439 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4441 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4446 else if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
4448 void * dataForm, * dataTest;
4449 bool isEditBoxContents = false;
4450 bool freeDataForm = false, freeDataTest = false;
4452 // Because contents property is broken for mutiline EditBox at the moment
4453 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
4454 isEditBoxContents = true;
4456 if(isEditBoxContents && ((EditBox)classObject.instance).multiLine)
4458 dataForm = ((EditBox)classObject.instance).multiLineContents;
4459 freeDataForm = true;
4462 dataForm = ((void *(*)(void *))(void *)prop.Get)(classObject.instance);
4463 if(isEditBoxContents && ((EditBox)test).multiLine)
4465 dataTest = ((EditBox)test).multiLineContents;
4466 freeDataTest = true;
4469 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
4471 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4473 char tempString[1024] = "";
4475 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4477 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
4479 // Shouldn't go here ...
4480 f.Printf("\n %s%s = this;", specify ? "property::" : "", prop.name);
4484 bool needClass = true;
4486 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4488 if(!strcmp(dataType.dataTypeString, "char *"))
4490 Map<String, bool> i18nStrings = classObject.i18nStrings;
4492 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
4495 f.Printf("\n %s%s = %s\"", specify ? "property::" : "", prop.name, i18n ? "$" : "");
4496 OutputString(f, string);
4500 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4502 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4505 if(freeDataForm) delete dataForm;
4506 if(freeDataTest) delete dataTest;
4510 DataValue dataForm, dataTest;
4512 GetProperty(prop, classObject.instance, &dataForm);
4513 GetProperty(prop, test, &dataTest);
4515 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
4517 SetProperty(prop, test, dataForm);
4518 if(dataType.type == bitClass)
4520 bool needClass = true;
4521 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4523 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4525 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4529 bool needClass = true;
4530 if(dataType.type == enumClass)
4533 Class enumClass = eSystem_FindClass(privateModule, "enum");
4534 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
4536 for(value = e.values.first; value; value = value.next)
4538 if((int)value.data == dataForm.i)
4540 string = value.name;
4546 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4547 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
4548 f.Printf("\n %s%s = %sf;", specify ? "property::" : "", prop.name, string);
4550 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4559 void UpdateFormCode()
4562 if(!parsing) return;
4569 else if(formModified)
4571 EditBoxStream f { editBox = editBox };
4575 Identifier movedFuncId;
4576 int movedFuncIdLen = 0, movedFuncIdPos = 0;
4577 ObjectInfo classObject;
4581 editBox.recordUndoEvent = true;
4585 movedFuncId = GetDeclId(function.declarator);
4586 movedFuncIdLen = movedFuncId.loc.end.pos - movedFuncId.loc.start.pos;
4587 movedFuncIdPos = movedFuncId.loc.start.pos - function.loc.start.pos;
4590 for(classObject = classes.first; classObject; classObject = classObject.next)
4593 ClassDefinition classDef = classObject.classDefinition;
4594 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
4597 bool firstObject = true;
4598 ObjectInfo object = classObject.instances.first;
4599 bool lastIsDecl = false;
4601 if(!classObject.modified) continue;
4603 test = eInstance_New(regClass);
4606 // Put it in the same desktop window...
4607 designer.PrepareTestObject(test);
4609 //f.Printf("class %s : %s\n", classObject.name, classObject.oClass.name);
4610 //f.Printf("%c\n\n", OpenBracket);
4612 // Change the _class name
4613 f.Seek(classDef.nameLoc.start.pos - position, current);
4614 f.DeleteBytes(classDef.nameLoc.end.pos - classDef.nameLoc.start.pos);
4615 f.Printf(classObject.name);
4616 position = classDef.nameLoc.end.pos;
4619 // Go to block start, delete all until no white space, put \n
4623 f.Seek(classDef.blockStart.end.pos - position, current);
4624 position = classDef.blockStart.end.pos;
4626 for(; f.Getc(&ch); count++)
4630 f.Seek(-1, current);
4640 f.Seek(-count, current);
4642 f.DeleteBytes(count-back);
4644 position += count-back;
4647 // Output properties
4648 OutputClassProperties(classObject.instance._class, classObject, f, test);
4650 for(def = classDef.definitions->first; def; def = def.next)
4654 case defaultPropertiesClassDef:
4656 bool keptMember = false;
4658 MemberInit lastKept = null;
4661 DeleteJunkBefore(f, def.loc.start.pos, &position);
4663 // This was adding blank spaces between comment and properties -- What was it for?
4666 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4668 Identifier ident = propDef.identifiers->first;
4669 bool deleted = false;
4671 // For now delete if it's a prop
4672 if(!propDef.variable && ident)
4676 Property prop = eClass_FindProperty(regClass, ident.string, this.privateModule);
4679 f.Seek(propDef.loc.start.pos - position, current);
4680 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4681 position = propDef.loc.end.pos;
4686 Method method = eClass_FindMethod(regClass, ident.string, this.privateModule);
4687 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4689 if(((methodAction == actionDetachMethod || methodAction == actionReattachMethod) && method == this.method && selected == classObject) ||
4690 (methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string)))
4692 f.Seek(propDef.loc.start.pos - position, current);
4693 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4694 position = propDef.loc.end.pos;
4712 f.Seek(def.loc.end.pos - position - 1, current);
4717 f.Seek(-1, current);
4720 position = def.loc.end.pos;
4724 if(lastKept != def.defProperties->last)
4729 f.Seek(-1, current);
4735 f.Seek(-1, current);
4738 else if(!isspace(ch))
4740 f.Seek(-2, current);
4745 f.DeleteBytes(count);
4749 f.Seek(def.loc.end.pos - position, current);
4750 position = def.loc.end.pos;
4755 case declarationClassDef:
4757 Declaration decl = def.decl;
4759 if(decl.type == instDeclaration)
4761 if(def.object/* && ((ObjectInfo)def.object).modified*/)
4763 while(def.object && object != def.object)
4765 if(object /*&& ((ObjectInfo)def.object).modified*/)
4766 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4767 object = object.next;
4770 DeleteJunkBefore(f, def.loc.start.pos, &position);
4771 f.Printf(firstObject ? "\n\n " : "\n ");
4772 firstObject = false;
4774 if(def.object && ((ObjectInfo)def.object).modified)
4775 position = UpdateInstanceCode(f, position, regClass, def.object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4777 object = object ? object.next : null;
4781 DeleteJunkBefore(f, def.loc.start.pos, &position);
4782 f.Printf(firstObject ? "\n\n " : "\n ");
4783 firstObject = false;
4789 DeleteJunkBefore(f, def.loc.start.pos, &position);
4790 f.Printf(lastIsDecl ? "\n " : "\n\n ");
4795 case functionClassDef:
4797 // TESTING IF THIS IS GOOD ENOUGH FOR GENERATED FUNCTION...
4798 if(!def.function.body) continue;
4802 DeleteJunkBefore(f, def.loc.start.pos, &position);
4805 // Delete _class methods
4806 if((methodAction == actionDeleteMethod || (moveAttached && selected != classObject)) &&
4807 def.function == function)
4812 if(moveAttached && !text)
4814 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max((int)strlen(methodName) - movedFuncIdLen,0), 3);
4817 f.Seek(def.loc.end.pos - position, current);
4818 for(; f.Getc(&ch); count++)
4822 f.Seek(-1, current);
4826 f.Seek(def.loc.start.pos - def.loc.end.pos - count, current);
4828 f.DeleteBytes(def.loc.end.pos - def.loc.start.pos + count);
4829 position = def.loc.end.pos + count;
4832 // In case of detaching methods in the _class, simply rename the method
4833 if(methodAction == actionDetachMethod && moveAttached && selected == classObject && function == def.function)
4835 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4836 f.DeleteBytes(movedFuncIdLen);
4838 position = function.loc.start.pos + movedFuncIdPos + movedFuncIdLen;
4841 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && moveAttached &&
4842 function == def.function)
4844 // In case of attaching methods in the _class, simply rename the method
4845 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4846 position = function.loc.start.pos + movedFuncIdPos;
4847 f.DeleteBytes(movedFuncIdLen);
4848 if(method.dataType.thisClass)
4849 f.Printf("%s::", method.dataType.thisClass.string);
4850 f.Puts(method.name);
4851 position += movedFuncIdLen;
4856 DeleteJunkBefore(f, def.loc.start.pos, &position);
4857 if(def.type == memberAccessClassDef)
4860 firstObject = false;
4870 f.Seek(def.loc.end.pos - position, current);
4871 position = def.loc.end.pos;
4874 // Output attached methods
4875 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && !moveAttached)
4877 DeleteJunkBefore(f, position, &position);
4878 f.Printf("\n %s = %s;\n", method.name, function.declarator.symbol.string);
4881 // ********** INSTANCES ***************
4882 for(; object; object = object.next)
4884 if(!object.instCode)
4886 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4890 DeleteJunkBefore(f, position, &position);
4892 // ****************** METHODS ***********************
4893 if(methodAction == actionDetachMethod && moveAttached && classObject == oClass)
4895 // If detaching an instance method
4896 if(selected != classObject)
4898 int newLen = strlen(methodName);
4901 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max(newLen - movedFuncIdLen,0), 0);
4902 // Tab selection left
4905 for(c = 0; text[c]; )
4908 for(i = 0; i<3 && text[c] == ' '; i++, c++);
4909 memmove(text+start, text+start+i, textSize+1-start-i);
4912 for(; text[c] && text[c] != '\n'; c++);
4918 memmove(text + movedFuncIdPos + newLen, text + movedFuncIdPos + movedFuncIdLen, textSize - movedFuncIdPos - movedFuncIdLen + 1);
4919 textSize += newLen - movedFuncIdLen;
4920 memcpy(text + movedFuncIdPos, methodName, newLen);
4927 if(methodAction == actionAddMethod && selected == classObject)
4929 Method method = this.method;
4931 if(!method.dataType)
4932 method.dataType = ProcessTypeString(method.dataTypeString, false);
4934 // ADDING METHOD HERE
4936 Type dataType = method.dataType;
4937 Type returnType = dataType.returnType;
4939 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4943 OutputType(f, returnType, false);
4946 if(dataType.thisClass && !dataType.classObjectType)
4948 if(dataType.thisClass.shortName)
4949 f.Printf(dataType.thisClass.shortName);
4951 f.Printf(dataType.thisClass.string);
4954 f.Printf(method.name);
4956 for(param = dataType.params.first; param; param = param.next)
4958 OutputType(f, param, true);
4963 f.Printf(" %c\n\n", OpenBracket);
4965 if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4967 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4968 f.Printf(" return true;\n");
4969 else if(returnType && returnType.kind != voidType)
4970 f.Printf(" return 0;\n");
4975 if(returnType.kind != voidType)
4976 f.Printf("return ");
4978 char * name = ((Specifier)classDef.baseSpecs->first).name;
4979 Symbol _class = FindClass(name);
4980 f.Printf("%s::%s(", (_class && _class.registered) ? _class.registered.name : name, method.name);
4982 for(param = dataType.params.first; param; param = param.next)
4984 if(param.prev) f.Printf(", ");
4985 if(param.kind != voidType)
4986 f.Printf(param.name);
4991 f.Printf(" %c", CloseBracket);
4995 DeleteJunkBefore(f, classDef.loc.end.pos-1, &position);
5001 editBox.recordUndoEvent = false;
5009 // TOFIX: Patch for a glitch where clicking at the end of the view seems one line off. No idea what could be going on?
5010 editBox.OnVScroll(setRange, editBox.scroll.y, 0);
5014 codeModified = false;
5015 formModified = false;
5017 moveAttached = false;
5022 int FindMethod(char * methodName /*Method method*/, ClassFunction*functionPtr, Location propLoc)
5025 ClassFunction function = null;
5028 ObjectInfo object = this.selected;
5030 if(object && object == this.oClass)
5032 ClassDefinition classDef = object.oClass.classDefinition;
5034 if(classDef && classDef.definitions)
5036 for(def = classDef.definitions->first; def; def = def.next)
5038 if(def.type == functionClassDef && def.function.declarator)
5040 if(!strcmp(def.function.declarator.symbol.string, methodName))
5042 function = def.function;
5047 else if(def.type == defaultPropertiesClassDef)
5051 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
5053 Identifier ident = propDef.identifiers ? propDef.identifiers->first : null;
5054 if(ident && !ident.next)
5056 if(!strcmp(ident.string, methodName) && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
5060 propLoc = propDef.loc;
5063 ClassDefinition classDef = object.oClass.classDefinition;
5065 if(classDef.definitions)
5067 for(def = classDef.definitions->first; def; def = def.next)
5069 if(def.type == functionClassDef)
5071 if(!strcmp(def.function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
5073 function = def.function;
5092 Instantiation inst = object.instCode;
5094 // Check here to see if the method already exists, no need to call ModifyCode in that case
5095 if(inst && inst.members)
5097 MembersInit members;
5098 for(members = inst.members->first; members; members = members.next)
5100 switch(members.type)
5102 case dataMembersInit:
5104 if(members.dataMembers)
5107 for(member = members.dataMembers->first; member; member = member.next)
5109 Identifier ident = member.identifiers ? member.identifiers->first : null;
5110 if(ident && !ident.next)
5112 if(!strcmp(ident.string, methodName) && member.initializer && member.initializer.type == expInitializer && member.initializer.exp && member.initializer.exp.type == memberExp /*ExpIdentifier*/)
5116 propLoc = member.loc;
5119 ClassDefinition classDef = object.oClass.classDefinition;
5121 if(classDef.definitions)
5123 for(def = classDef.definitions->first; def; def = def.next)
5125 if(def.type == functionClassDef)
5127 if(def.function.declarator && !strcmp(def.function.declarator.symbol.string, member.initializer.exp.identifier.string))
5129 function = def.function;
5138 // TODO: Fix memory leak
5139 function = ClassFunction
5141 declarator = Declarator { symbol = Symbol { string = CopyString(member.initializer.exp.member.member ? member.initializer.exp.member.member.string : "") } }
5153 case methodMembersInit:
5155 if(members.function.declarator && !strcmp(members.function.declarator.symbol.string, methodName))
5157 function = members.function;
5169 if(functionPtr) *functionPtr = function;
5173 void GoToMethod(char * methodName /*Method method*/)
5177 ObjectInfo object = selected;
5178 EditBoxStream f { editBox = editBox };
5179 ClassFunction function = null;
5180 bool atChar = false;
5184 Location propLoc = { {0,0,-1} };
5187 if(FindMethod(methodName, &function, &propLoc) == 1 && object != this.oClass) indent = 9;
5188 if(function && function.body)
5191 f.Seek(function.body.loc.start.pos+1, current);
5201 f.Seek(-1, current);
5206 else if(!isspace(ch))
5208 f.Seek(-1, current);
5214 else if(propLoc.start.pos > -1)
5216 f.Seek(propLoc.start.pos, current);
5219 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
5221 if(function || propLoc.start.pos > -1)
5223 editBox.SetSelPos(l1, y1, atChar ? x1 : indent, l2, y2, atChar ? x2 : indent);
5224 editBox.CenterOnCursor();
5225 SetState(normal, false, 0);
5228 if(function && function.declarator && function.declarator.symbol && !function.declarator.symbol.type)
5230 FreeClassFunction(function);
5236 void FindCompatibleMethods(Method method, OldList compatible)
5238 ClassDefinition classDef = this.oClass.classDefinition;
5239 if(classDef && classDef.definitions)
5242 Class baseClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5245 Symbol classSym { };
5246 Symbol selectedClass;
5247 if(this.selected == this.oClass)
5248 selectedClass = classSym;
5250 selectedClass = FindClass(this.selected.instance._class.name);
5252 regClass.name = classDef._class.name;
5253 regClass.base = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5254 for(def = classDef.definitions->first; def; def = def.next)
5256 if(def.type == functionClassDef && def.function.declarator)
5258 Method vMethod = eClass_FindMethod(baseClass, def.function.declarator.symbol.string, this.privateModule);
5260 vMethod = eClass_FindMethod(this.selected.instance._class, def.function.declarator.symbol.string, this.privateModule);
5263 Type type = def.function.declarator.symbol.type;
5264 if(CheckCompatibleMethod(method, type, regClass, this.selected == this.oClass, FindClass(this.selected.instance._class.name)))
5266 compatible.Add(OldLink { data = def.function });
5272 if(this.oClass && this.oClass.instance)
5274 classSym.registered = regClass;
5275 //classSym.registered = this.oClass.oClass;
5277 for(_class = regClass.base; _class; _class = _class.base)
5280 for(testMethod = (Method)_class.methods.first; testMethod; testMethod = (Method)((BTNode)testMethod).next)
5282 // TODO: Understand why these functions popup in attach list
5283 if(testMethod.type != virtualMethod /*&& testMethod.function != Window_OnGetString && testMethod.function != Window_OnGetDataFromString*/)
5285 if(!testMethod.dataType)
5286 testMethod.dataType = ProcessTypeString(testMethod.dataTypeString, false);
5288 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5289 if(CheckCompatibleMethod(method, testMethod.dataType, this.oClass.instance._class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5290 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, this.selected == this.oClass, FindClass(this.oClass.oClass.name)))
5292 // TODO: Fix memory leak, Figure out if it should be ClassFunction or FunctionDefinition
5293 // ClassFunction function { };
5294 FunctionDefinition function { };
5296 function.declarator = Declarator { };
5297 function.declarator.symbol = Symbol { string = CopyString(testMethod.name) };
5298 excludedSymbols.Add(function.declarator.symbol);
5300 compatible.Add(OldLink { data = function });
5311 void AddMethod(Method method)
5315 char methodName[1024];
5316 strcpy(methodName, method.name);
5317 if(!FindMethod(methodName, null, null))
5319 methodAction = actionAddMethod;
5320 this.method = method;
5324 GoToMethod(methodName);
5328 void DeleteMethod(ClassFunction function)
5332 methodAction = actionDeleteMethod;
5333 this.function = function;
5341 void AttachMethod(Method method, ClassFunction function)
5345 // If it's an instance we'll ask if we want to move it inside...
5346 if(!function.attached.count && function.body)
5348 // Find the function in the _class to check if it's a virtual function
5349 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5350 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5351 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5353 for(def = this.classDefinition.first; def; def = def.next)
5355 if(def.type == functionClassDef)
5357 if(def.function == function)
5362 if(!method || method.type != virtualMethod)
5365 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5366 if(MessageBox { type = yesNo, master = parent, text = title, contents = $"Method is unused. Move method inside instance?"}.Modal() == yes)
5368 moveAttached = true;
5373 methodAction = actionAttachMethod;
5374 this.method = method;
5375 this.function = function;
5382 void ReAttachMethod(Method method, ClassFunction function)
5386 // If it's an instance we'll ask if we want to move it inside...
5387 if(!function.attached.count && function.body)
5389 // Find the function in the _class to check if it's a virtual function
5390 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5391 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5392 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5394 for(def = this.classDefinition.first; def; def = def.next)
5396 if(def.type == functionClassDef)
5398 if(def.function == function)
5403 if(!method || method.type != virtualMethod)
5406 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5407 if(MessageBox { type = yesNo, master = parent, text = title,
5408 contents = $"Method is unused. Move method inside instance?" }.Modal() == yes)
5410 moveAttached = true;
5415 methodAction = actionReattachMethod;
5416 this.method = method;
5417 this.function = function;
5424 void DetachMethod(Method method, ClassFunction function, int type)
5432 hasClose = true, borderStyle = sizable, minClientSize = { 300, 55 },
5433 master = sheet, text = $"Name detached method", background = formColor
5437 dialog, anchor = { horz = 45, top = 30 }, size = { 80 }, text = $"Cancel", hotKey = escape,
5438 id = DialogResult::cancel, NotifyClicked = ButtonCloseDialog
5442 dialog, anchor = { horz = -45, top = 30 }, size = { 80 }, text = $"OK", isDefault = true,
5443 id = DialogResult::ok, NotifyClicked = ButtonCloseDialog
5447 dialog, anchor = { left = 5, right = 5, top = 5 }
5449 sprintf(methodName, "%s_%s", selected.name, method.name);
5450 nameBox.contents = methodName;
5452 result = dialog.Modal() == ok;
5453 strcpy(methodName, nameBox.contents);
5458 // If the method is not attached, move it outside
5461 // Add this class to the methodName
5462 char name[1024] = "";
5464 if(this.selected != this.oClass && !method.dataType.thisClass)
5466 strcat(name, this.selected.instance._class.name);
5468 strcat(name, this.methodName);
5469 strcpy(this.methodName, name);
5471 else if(method.dataType.thisClass && (this.selected == this.oClass || !eClass_IsDerived(this.oClass.instance._class, method.dataType.thisClass.registered)))
5473 strcat(name, method.dataType.thisClass.string);
5475 strcat(name, this.methodName);
5476 strcpy(this.methodName, name);
5479 this.moveAttached = true;
5482 this.methodAction = actionDetachMethod;
5483 this.method = method;
5484 this.function = function;
5491 void AddObject(Instance instance, ObjectInfo * object)
5495 //*object = _class.instances.Add(sizeof(ObjectInfo));
5496 *object = ObjectInfo { };
5497 oClass.instances.Insert((selected.oClass == selected) ? null : selected, *object);
5498 (*object).oClass = oClass;
5499 (*object).instance = instance;
5504 sprintf(name, "%c%s%d", tolower(instance._class.name[0]), instance._class.name+1, id);
5506 // if(strcmp(name, this.oClass.instance.name))
5509 for(check = oClass.instances.first; check; check = check.next)
5510 if(!check.deleted && check.name && !strcmp(name, check.name))
5514 (*object).name = CopyString(name);
5519 toolBox.controlClass = null;
5523 //sheet.AddObject(*object, (*object).name, TypeData, true);
5528 void EnsureUpToDate()
5530 if(sheet && codeModified && parsing)
5534 void SelectObject(ObjectInfo object)
5537 oClass = object ? object.oClass : null;
5539 designer.SelectObject(object, object ? object.instance : null);
5542 void SelectObjectFromDesigner(ObjectInfo object)
5545 sheet.SelectObject(object);
5548 void EnumerateObjects(Sheet sheet)
5552 for(oClass = classes.first; oClass; oClass = oClass.next)
5558 sheet.AddObject(oClass, oClass.name ? oClass.name : oClass.instance._class.name, typeClass, false);
5559 for(object = oClass.instances.first; object; object = object.next)
5560 sheet.AddObject(object, object.name ? object.name : object.instance._class.name, typeData, false);
5563 sheet.SelectObject(selected);
5568 designer.AddObject();
5571 void DeleteObject(ObjectInfo object)
5573 delete object.instance;
5574 object.deleted = true;
5575 object.modified = true;
5576 object.oClass.modified = true;
5578 if(selected == object)
5580 bool looped = false;
5581 ObjectInfo select = object;
5585 select = select.prev;
5589 select = object.oClass.instances.last;
5596 sheet.SelectObject(select ? select : oClass);
5599 if(!object.instCode && object.oClass != object)
5602 oClass.instances.Delete(object);
5605 if(sheet.codeEditor == this)
5606 sheet.DeleteObject(object);
5609 void RenameObject(ObjectInfo object, char * name)
5613 // Validate the name:
5614 if(object != oClass && (!name || !name[0])) valid = true; // What's this one again?
5615 else if(name[0] && (isalpha(name[0]) || name[0] == '_'))
5618 for(c = 0; name[c]; c++)
5619 if(!isalnum(name[c]) && name[c] != '_' && name[c] != '_')
5627 object.name = (name && name[0]) ? CopyString(name) : null;
5629 sheet.RenameObject(object, object.name ? object.name : object.instance._class.name);
5633 void DesignerModifiedObject()
5635 sheet.ListProperties(false);
5639 void ListSubMembers(Type member)
5643 for(subMember = member.members.first; subMember; subMember = subMember.next)
5647 DataRow row = membersList.AddString(subMember.name);
5648 row.icon = icons[typeData];
5652 ListSubMembers(subMember);
5657 void ListSubDataMembers(DataMember member, bool isPrivate)
5659 DataMember subMember;
5660 for(subMember = member.members.first; subMember; subMember = subMember.next)
5662 if((subMember.memberAccess == publicAccess && !isPrivate) || subMember._class.module == privateModule)
5666 DataRow row = membersList.AddString(subMember.name);
5667 BitmapResource bitmap = null;
5668 if(!subMember.dataType)
5669 subMember.dataType = ProcessTypeString(subMember.dataTypeString, false);
5671 if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
5673 char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
5676 bitmap = { bitmapName };
5677 membersList.AddResource(bitmap);
5680 row.icon = bitmap ? bitmap : icons[(subMember.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5684 ListSubDataMembers(subMember, isPrivate || member.memberAccess == privateAccess);
5690 void ListClassMembers(Class whatClass, bool methodsOnly)
5693 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5694 bool isPrivate = false;
5696 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5698 Method method, methodIt;
5700 DataMember memberIt;
5702 for(methodIt = (Method)_class.methods.first; methodIt; methodIt = (Method)((BTNode)methodIt).next)
5704 method = eClass_FindMethod(whatClass, methodIt.name, privateModule);
5705 if(methodIt.memberAccess == privateAccess && method && method.memberAccess == publicAccess)
5707 if(method && method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5709 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5711 DataRow row = membersList.FindString(method.name);
5714 row = membersList.AddString(method.name);
5716 if(!method.dataType)
5717 method.dataType = ProcessTypeString(method.dataTypeString, false);
5719 row.icon = icons[(method.type == virtualMethod && method.dataType && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5727 for(memberIt = _class.membersAndProperties.first; memberIt; memberIt = memberIt.next)
5731 if(memberIt.isProperty)
5733 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5735 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5739 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5741 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5744 if(memberIt.memberAccess == privateAccess && member && member.memberAccess == publicAccess)
5750 if(member && (member.memberAccess == publicAccess || member._class.module == privateModule))
5752 if(member.isProperty)
5754 Property prop = (Property) member;
5755 if(!membersList.FindString(prop.name))
5757 DataRow row = membersList.AddString(prop.name);
5758 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5761 else if(member.name && !membersList.FindString(member.name))
5763 DataRow row = membersList.AddString(member.name);
5765 BitmapResource bitmap = null;
5766 if(!member.dataType)
5767 member.dataType = ProcessTypeString(member.dataTypeString, false);
5769 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5771 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5774 bitmap = { bitmapName };
5775 membersList.AddResource(bitmap);
5778 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5781 ListSubDataMembers(member, member.memberAccess == privateAccess);
5785 if(_class.inheritanceAccess == privateAccess)
5788 if(_class.module != privateModule) break;
5793 void ListClassMembersMatch(Class whatClass, Type methodType)
5796 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5797 bool isPrivate = false;
5799 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5805 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5807 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5809 if(method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5811 if(!method.dataType)
5812 method.dataType = ProcessTypeString(method.dataTypeString, false);
5814 if(MatchTypes(method.dataType, methodType, null, whatClass, /*null, */whatClass, false, true, false, false))
5816 DataRow row = membersList.FindString(method.name);
5819 row = membersList.AddString(method.name);
5820 row.icon = icons[(method.type == virtualMethod && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5826 if(_class.inheritanceAccess == privateAccess)
5829 if(_class.module != privateModule) break;
5834 void ListClassPropertiesAndVirtual(Class whatClass, String curString)
5837 bool isPrivate = false;
5838 for(_class = whatClass; _class /*&& _class.type != systemClass*/; _class = _class.base)
5844 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5846 if(method.type == virtualMethod)
5848 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5850 DataRow row = membersList.FindString(method.name);
5853 row = membersList.AddString(method.name);
5855 if(!method.dataType)
5856 method.dataType = ProcessTypeString(method.dataTypeString, false);
5858 row.icon = icons[method.dataType.thisClass ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5864 for(member = _class.membersAndProperties.first; member; member = member.next)
5866 if(member.memberAccess == publicAccess || member._class.module == privateModule)
5868 if(member.isProperty)
5870 Property prop = (Property)member;
5872 DataRow row = membersList.AddString(prop.name);
5873 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5876 else if(member.name && (!curString || strcmp(curString, member.name)))
5878 DataRow row = membersList.AddString(member.name);
5880 BitmapResource bitmap = null;
5881 if(!member.dataType)
5882 member.dataType = ProcessTypeString(member.dataTypeString, false);
5884 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5886 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5889 bitmap = { bitmapName };
5890 membersList.AddResource(bitmap);
5893 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5896 ListSubDataMembers(member, member.memberAccess == privateAccess || isPrivate);
5899 if(_class.inheritanceAccess == privateAccess)
5902 if(_class.module != privateModule) break;
5907 void ListMembers(Type type)
5909 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, 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))
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, 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, 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 != pointerType || destType.type.kind != voidType) && destType.kind != ellipsisType)
6153 listedEnums = ListEnumsModule(this.privateModule, destType);
6156 if(destType && destType.kind == classType && destType._class.registered && destType._class.registered.type == enumClass)
6158 ListEnumValues(destType._class.registered);
6161 ListClassPropertiesAndVirtual(insideClass, null);
6165 else if(destType && destType.kind == enumType)
6169 for(value = destType.members.first; value; value = value.next)
6171 DataRow row = membersList.AddString(value.name);
6172 row.icon = icons[typeEnumValue];
6176 ListClassPropertiesAndVirtual(insideClass, null);
6180 else if(insideClass && !enumOnly)
6182 ListClassPropertiesAndVirtual(insideClass, string);
6185 if(listedEnums && string && string[0])
6187 DataRow row = membersList.FindSubString(string);
6189 listedEnums = false;
6192 if(!insideClass && exp && exp.destType && exp.destType.kind == functionType && GetThisClass())
6194 ListClassMembersMatch(GetThisClass(), exp.destType);
6196 else if(!insideClass && !enumOnly && !listedEnums)
6199 Symbol symbol = null;
6203 ListClassMembers(GetThisClass(), false);
6206 for(ctx = listClasses ? GetCurrentContext() : GetTopContext(); ctx != GetTopContext().parent && !symbol; ctx = ctx.parent)
6208 for(symbol = (Symbol)ctx.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6210 // Don't list enum values?
6211 //if(symbol.type.kind != TypeEnum)
6212 DataRow row = membersList.FindString(symbol.string);
6215 if(GetBuildingEcereComModule() && symbol.type && symbol.type.kind == functionType && eSystem_FindFunction(privateModule, symbol.string))
6217 row = membersList.AddString(symbol.string);
6218 if(symbol.type && symbol.type.kind == functionType)
6219 row.icon = icons[typeMethod];
6220 else if(symbol.type && symbol.type.kind == enumType)
6222 row.icon = icons[typeEnumValue];
6226 BitmapResource bitmap = null;
6227 if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
6229 char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
6232 bitmap = { bitmapName };
6233 membersList.AddResource(bitmap);
6236 row.icon = bitmap ? bitmap : icons[typeData];
6243 for(symbol = (Symbol)ctx.types.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6245 DataRow row = membersList.FindString(symbol.string);
6248 row = membersList.AddString(symbol.string);
6249 if(symbol.type.kind == functionType)
6250 row.icon = icons[typeMethod];
6251 else if(symbol.type.kind == classType && (!symbol.type._class.registered || (symbol.type._class.registered.type != unitClass && symbol.type._class.registered.type != enumClass)))
6253 row.icon = icons[typeClass];
6257 row.icon = icons[typeDataType];
6264 ListModule(this.privateModule, 1, listClasses);
6265 // TODO: Implement this with name space
6269 for(data = globalData.first; data; data = data.next)
6271 DataRow row = membersList.FindString(data.name);
6273 data.dataType = ProcessTypeString(data.dataTypeString, false);
6276 row = membersList.AddString(data.name);
6278 if(data.dataType && data.dataType.kind == TypeEnum)
6280 row.icon = icons[typeEnumValue];
6284 BitmapResource bitmap = null;
6285 if(data.dataType && data.dataType.kind == classType && data.dataType._class && data.dataType._class)
6287 char * bitmapName = (char *)eClass_GetProperty(data.dataType._class.registered, "icon");
6290 bitmap = { bitmapName };
6291 membersList.AddResource(bitmap);
6294 row.icon = bitmap ? bitmap : icons[typeData];
6302 DataRow row = membersList.AddString("Min");
6303 row.icon = icons[typeMethod];
6305 row = membersList.AddString("Max");
6306 row.icon = icons[typeMethod];
6308 row = membersList.AddString("Abs");
6309 row.icon = icons[typeMethod];
6311 row = membersList.AddString("Sgn");
6312 row.icon = icons[typeMethod];
6318 void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
6320 EditBoxStream f { editBox = editBox };
6325 updatingCode = true;
6327 if(!method.dataType)
6328 method.dataType = ProcessTypeString(method.dataTypeString, false);
6330 DeleteJunkBefore(f, function.loc.start.pos, &position);
6331 f.DeleteBytes(function.loc.end.pos - function.loc.start.pos - 1);
6333 // ADDING METHOD HERE
6335 Type dataType = method.dataType;
6336 Type returnType = dataType.returnType;
6338 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
6344 if(extraIndent) f.Printf(" ");
6346 OutputType(f, returnType, false);
6350 if(dataType.thisClass && !dataType.classObjectType && (!isInstance || !insideClass || !eClass_IsDerived(insideClass, dataType.thisClass.registered)))
6352 if(dataType.thisClass.shortName)
6353 f.Printf(dataType.thisClass.shortName);
6355 f.Printf(dataType.thisClass.string);
6358 f.Printf(method.name);
6360 for(param = dataType.params.first; param; param = param.next)
6362 // Decided not to write void...
6363 if(param.kind != voidType)
6365 OutputType(f, param, true);
6371 if(extraIndent) f.Printf(" ");
6372 f.Printf(" %c\n", OpenBracket);
6374 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6380 (isInstance ? _class : _class.base)._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad] ||
6381 (isInstance ? _class : _class.base)._vTbl[method.vid] == DummyMethod)) // Temp Check for DefaultFunction
6383 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
6385 if(extraIndent) f.Printf(" ");
6386 f.Printf(" return true;\n");
6388 else if(returnType && returnType.kind != voidType)
6390 if(extraIndent) f.Printf(" ");
6391 f.Printf(" return 0;\n");
6396 if(extraIndent) f.Printf(" ");
6398 if(returnType.kind != voidType)
6399 f.Printf("return ");
6400 f.Printf("%s::%s(", isInstance ? _class.name : _class.base.name, method.name);
6401 for(param = dataType.params.first; param; param = param.next)
6403 if(param.prev) f.Printf(", ");
6404 if(param.kind != voidType)
6405 f.Printf(param.name);
6411 if(extraIndent) f.Printf(" ");
6412 f.Printf(" %c", CloseBracket);
6417 if(extraIndent) { x1 += 3; x2 += 3; }
6418 editBox.SetSelPos(l1, y1, x1 + 6, l2, y2, x2 + 6);
6420 this.updatingCode = false;
6424 // Return false if we overrided a function and don't want to run params listing
6425 bool InvokeAutoComplete(bool enumOnly, int pointer, bool caretMove)
6427 bool didOverride = false;
6428 EditLine line = editBox.line;
6429 char * text = line.text;
6430 int lineNum, charPos;
6431 Expression exp = null;
6434 //Identifier id = null;
6435 Expression memberExp = null;
6436 Identifier realIdentifier = null;
6438 if(!parsing) return true;
6439 if(!privateModule) return !didOverride;
6441 insideFunction = null;
6443 charPos = editBox.charPos + 1;
6444 if(!membersListShown)
6449 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6451 EditBoxStream f { editBox = editBox };
6453 updatingCode = true;
6454 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6458 if(!f.Seek(-1, current))
6461 if(!isspace(ch)) break;
6462 f.Seek(-1, current);
6464 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6466 lineNum = editBox.lineNumber + 1;
6467 charPos = editBox.charPos + 1;
6469 updatingCode = false;
6472 if(!membersListShown)
6474 memberExp = FindExpTree(ast, lineNum, charPos);
6475 if(memberExp && (memberExp.type == TypeKind::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6480 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6482 EditBoxStream f { editBox = editBox };
6485 updatingCode = true;
6487 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6490 if(ch == '}' || ch == ',' || ch == ')')
6492 f.Seek(-1, current);
6500 if(!f.Seek(-1, current))
6503 if(!isspace(ch)) break;
6504 f.Seek(-1, current);
6508 f.Seek(-1, current);
6510 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6512 lineNum = editBox.lineNumber + 1;
6513 charPos = editBox.charPos + 1;
6515 updatingCode = false;
6518 realIdentifier = FindCtxTree(ast, lineNum, charPos);
6523 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6524 lineNum = editBox.lineNumber + 1;
6525 charPos = editBox.charPos/* + 1*/;
6529 char tempString[1024];
6530 char * string = null;
6531 CodePosition idStart, idEnd;
6533 if(membersListShown)
6535 char * buffer = membersLine.text;
6537 bool firstChar = true;
6539 string = tempString;
6541 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
6543 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6544 if(!isSpace) firstChar = false;
6546 string[len++] = buffer[c];
6550 else //if(realIdentifier)//if(id)
6553 char * buffer = id.string;
6555 bool firstChar = true;
6557 string = tempString;
6558 for(c = 0; c<= charPos - id.loc.start.charPos; c++)
6560 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6561 if(!isSpace) firstChar = false;
6563 string[len++] = buffer[c];
6569 EditLine editLine = editBox.line;
6570 bool firstChar = true;
6573 string = tempString;
6574 for(y = lineNum-1; y >= 0; y--)
6576 char * buffer = editLine.text;
6577 int lineCount = editLine.count;
6578 for(x = (y == lineNum-1) ? (Min(charPos, lineCount) - 1 ): lineCount-1; x >= 0; x--)
6580 bool isSpace = (buffer[x] == ' ' || buffer[x] == '\t');
6585 idEnd.charPos = x + 2;
6590 // TESTING THIS CODE HERE FOR NOT CONSIDERING bool when doing ctrl-space past it
6593 idEnd.charPos = x + 2;
6600 if(!isalnum(buffer[x]) && buffer[x] != '_')
6606 memmove(string+1, string, len++);
6607 string[0] = buffer[x];
6611 //if(done || firstChar)
6612 if(done || !firstChar)
6614 editLine = editLine.prev;
6617 if(!strcmp(string, "case"))
6623 else if(!strcmp(string, "return"))
6629 else if(!strcmp(string, "delete"))
6635 else if(!strcmp(string, "new"))
6641 else if(!strcmp(string, "renew"))
6649 idStart.charPos = x + 1;
6650 idStart.line = y + 1;
6653 if(!membersListShown)
6655 membersList.Clear();
6656 if(memberExp && (memberExp.type == ExpressionType::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6658 Type type = memberExp.member.exp.expType;
6659 if(pointer == 2 && type)
6661 if(type.kind == pointerType || type.kind == arrayType)
6670 ListSymbols(exp, enumOnly, string, realIdentifier);
6672 membersList.Sort(null, 1);
6677 // Virtual function override
6678 Identifier id = GetDeclId(insideFunction.declarator);
6679 char * string = id ? id.string : null;
6681 Method method = eClass_FindMethod(GetThisClass(), string, this.privateModule);
6684 if(method.type != virtualMethod || (!insideInstance && method._class == GetThisClass()))
6685 insideFunction = null;
6688 OverrideVirtualFunction(insideFunction, method, GetThisClass(), insideInstance, insideInstance && insideClass);
6693 if(!didOverride) //insideFunction)
6695 rowCount = membersList.rowCount;
6698 DataRow row = string ? membersList.FindSubString(string) : null;
6699 if(row && !membersList.FindSubStringAfter(row, string) && !caretMove)
6701 char * newString = row.string;
6702 if(!membersListShown)
6704 membersLoc.start.line = idStart.line-1;
6705 membersLoc.start.charPos = idStart.charPos-1;
6706 //membersLoc.end = membersLoc.start;
6707 membersLoc.end.charPos = idEnd.charPos-1;
6708 membersLoc.end.line = idEnd.line-1;
6709 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6710 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6715 membersList.Destroy(0);
6716 membersListShown = false;
6719 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
6721 line, membersLoc.start.line, membersLoc.start.charPos,
6722 line, membersLoc.end.line, membersLoc.end.charPos);
6723 editBox.PutS(newString);
6729 row = membersList.FindSubStringi(string);
6731 membersList.currentRow = row;
6732 membersList.currentRow.selected = false;
6735 membersList.currentRow = row;
6737 if(!membersListShown)
6741 // TESTING THESE ADDITIONS TO THE IF SO THAT CARET ISNT MOVED IF NOT ON TOP OF A WORD
6742 if(string && string[0] && lineNum == idStart.line && charPos >= idStart.charPos-1 && charPos <= idEnd.charPos-1)
6743 editBox.SetSelPos(l1, y1, idStart.charPos-1, l2, y2, idStart.charPos-1);
6744 editBox.GetCaretPosition(caret);
6745 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6747 membersList.master = this;
6749 caret.y += editBox.GetCaretSize();
6751 membersList.Create();
6754 int x = caret.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6755 int y = caret.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6756 Window parent = membersList.parent;
6758 if(!paramsAbove && (paramsShown || y + membersList.size.h > parent.clientSize.h))
6760 y -= editBox.GetCaretSize() + membersList.size.h;
6761 membersAbove = true;
6764 membersAbove = false;
6766 membersList.position = { x, y };
6770 membersLoc.start.line = lineNum - 1;
6772 if(string && string[0])
6774 membersLoc.start.charPos = idStart.charPos-1;
6775 membersLoc.end = membersLoc.start;
6776 //membersLoc.end.charPos = id.loc.end.charPos-1;
6777 membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6781 membersLoc.start.charPos = charPos;
6782 membersLoc.end = membersLoc.start;
6783 membersLoc.end.charPos = charPos;
6785 membersListShown = true;
6787 // Hack to keep caret shown
6788 editBox.GetCaretPosition(caret);
6789 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6792 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
6798 SetCurrentContext(globalContext);
6801 return !didOverride;
6804 void InvokeParameters(bool exact, bool reposition, bool caretMove)
6806 EditLine line = editBox.line;
6807 char * text = line.text;
6808 int lineNum, charPos;
6809 Expression exp = null;
6813 if(!parsing) return;
6815 charPos = editBox.charPos + 1;
6818 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6820 EditBoxStream f { editBox = editBox };
6823 updatingCode = true;
6824 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6827 if(ch == '}' || ch == ',' || ch == ')')
6829 f.Seek(-1, current);
6837 if(!f.Seek(-1, current))
6840 if(!isspace(ch)) break;
6841 f.Seek(-1, current);
6845 f.Seek(-1, current);
6847 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6849 lineNum = editBox.lineNumber + 1;
6850 charPos = editBox.charPos + 1;
6852 updatingCode = false;
6855 charPos = Min(charPos, l1.count + 1);
6857 FindParamsTree(ast, lineNum, charPos);
6859 // Not sure about this == ExpCall... paramsInsideExp doesn't seem to necessarily be a ExpCall
6860 if(exact && ((::functionType && paramsInsideExp.type == callExp && paramsInsideExp.call.exp.loc.end.charPos != charPos-1) /*|| instanceType*/))
6862 ::functionType = null;
6863 ::instanceType = null;
6866 //if((::functionType || ::instanceType) && (!paramsShown || insideExp != functionExp || ::paramsID != this.paramsID))
6867 if((::functionType || ::instanceType) && (!paramsShown || true /*paramsInsideExp.destType != functionExp.destType */|| ::paramsID != this.paramsID))
6871 Window parent = paramsList.parent;
6873 if(this.functionType != ::functionType || this.instanceType != ::instanceType)
6876 if(!this.paramsShown || reposition || paramsInsideExp != functionExp || ::instanceType) // Added instanceType here, otherwise instance popups never reposition...
6877 // ( Dummy exp: always ends up with same memory)
6879 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6880 editBox.GetCaretPosition(paramsPosition);
6881 this.paramsPosition.y += editBox.GetCaretSize();
6884 FreeType(this.functionType);
6885 FreeType(this.instanceType);
6887 this.functionType = ::functionType;
6888 this.instanceType = ::instanceType;
6890 if(this.functionType) this.functionType.refCount++;
6891 if(this.instanceType) this.instanceType.refCount++;
6893 this.paramsID = ::paramsID;
6894 functionExp = paramsInsideExp;
6896 paramsList.master = this;
6898 paramsList.Create();
6900 x = paramsPosition.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6901 y = paramsPosition.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6903 if(!this.membersAbove && ( this.membersListShown || y + paramsList.size.h > parent.clientSize.h) )
6905 y -= editBox.GetCaretSize() + paramsList.clientSize.h;
6909 paramsAbove = false;
6910 if(x + paramsList.size.w > parent.clientSize.w)
6912 x = parent.clientSize.w - paramsList.size.w;
6916 paramsList.position = { x, y };
6918 // Hack to keep caret shown
6921 editBox.GetCaretPosition(caret);
6922 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6925 this.paramsShown = true;
6927 else if((!::functionType && !::instanceType) || reposition)
6929 paramsList.Destroy(0);
6930 paramsShown = false;
6932 FreeType(this.functionType);
6933 FreeType(this.instanceType);
6934 this.functionType = null;
6935 this.instanceType = null;
6939 SetCurrentContext(globalContext);
6947 designer.visible = true;
6948 designer.Activate();
6954 CodeEditor NewCodeEditor(Window parent, WindowState state, bool modified)
6956 CodeEditor document { state = state, parent = parent, modifiedDocument = modified };
6961 static int nofdigits(int v)
6963 if(v == MININT) return 10 + 1;
6964 if(v < 0) return nofdigits(-v) + 1;