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 sheet.DeleteObject(object);
2755 _class.instances.Delete(object);
2759 Designer::DestroyObject(_class.instance);
2760 delete _class.instance;
2762 sheet.DeleteObject(_class);
2764 classes.Delete(_class);
2770 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2771 if(windowClass && windowClass.data)
2772 UnapplySkin(windowClass);
2775 designer = backDesigner;
2778 fileInput = editFile = EditBoxStream { editBox = editBox };
2779 SetFileInput(fileInput);
2787 defines.Free(FreeModuleDefine);
2788 imports.Free(FreeModuleImport);
2790 FreeContext(this.globalContext);
2791 FreeExcludedSymbols(this.excludedSymbols);
2794 FreeGlobalData(&this.globalData);
2796 if(this.privateModule)
2798 FreeTypeData(this.privateModule);
2799 delete this.privateModule;
2803 startTime = GetTime();
2804 printf("Cleaning up took %.3f seconds\n", startTime - parseCodeStart);
2806 printf("classes.count: %d\n", globalContext.classes.count);
2811 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2812 SetTargetBits(ide.workspace.bitDepth ? ide.workspace.bitDepth : GetHostBits());
2815 this.privateModule = __ecere_COM_Initialize(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4), 1, null);
2817 SetPrivateModule(privateModule);
2820 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint"), type = ProcessTypeString("unsigned int", false) });
2821 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint64"), type = ProcessTypeString("unsigned int64", false) });
2822 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint32"), type = ProcessTypeString("unsigned int", false) });
2823 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint16"), type = ProcessTypeString("unsigned short", false) });
2824 globalContext.types.Add((BTNode)Symbol { string = CopyString("byte"), type = ProcessTypeString("unsigned char", false) });
2827 fileName = this.fileName;
2829 if(ide.workspace && ide.workspace.projects && fileName)
2831 for(p : ide.workspace.projects)
2833 char path[MAX_LOCATION];
2835 MakePathRelative(fileName, p.topNode.path, path);
2836 MakeSlashPath(path);
2838 pn = p.topNode.FindWithPath(path, false);
2847 project = ide.project;
2849 GetWorkingDir(oldWorkDir, MAX_LOCATION);
2851 ChangeWorkingDir(project.topNode.path);
2853 SetSomeSourceFileStack(fileName ? fileName : "", 0); //strcpy(sourceFileStack[0], fileName ? fileName : "");
2855 GetLastDirectory(fileName, mainModuleName);
2856 GetExtension(mainModuleName, extension);
2858 SetBuildingEcereCom(false);
2859 SetBuildingEcereComModule(false);
2861 // TODO: Get symbolsDir from project settings instead...
2864 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2865 ProjectConfig config = project.config;
2866 int bitDepth = ide.workspace.bitDepth;
2867 DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
2868 SetSymbolsDir(objDir.dir);
2869 ide.SetPath(true, compiler, config, bitDepth);
2873 // SetIncludeDirs(ide.projectView.project.config.includeDirs);
2874 // SetSysIncludeDirs(ide.ideSettings.systemDirs[includes]);
2878 switch(GetRuntimePlatform())
2880 case win32: SetSymbolsDir("obj/debug.win32"); break;
2881 case tux: SetSymbolsDir("obj/debug.linux"); break;
2882 case apple: SetSymbolsDir("obj/debug.apple"); break;
2884 SetIncludeDirs(null);
2885 SetSysIncludeDirs(null);
2889 if(ide.projectView && ide.projectView.IsModuleInProject(this.fileName))
2891 // TODO FIX for configless project
2892 if(ide.project.config && ide.project.config.options && ide.project.config.options.preprocessorDefinitions)
2894 for(item : ide.project.config.options.preprocessorDefinitions)
2896 if(!strcmp(item, "BUILDING_ECERE_COM"))
2898 SetBuildingEcereCom(true);
2905 if(!(strcmpi(mainModuleName, "instance.ec") && strcmpi(mainModuleName, "BinaryTree.ec") &&
2906 strcmpi(mainModuleName, "dataTypes.ec") && strcmpi(mainModuleName, "OldList.ec") &&
2907 strcmpi(mainModuleName, "String.ec") && strcmpi(mainModuleName, "BTNode.ec") &&
2908 strcmpi(mainModuleName, "Array.ec") && strcmpi(mainModuleName, "AVLTree.ec") &&
2909 strcmpi(mainModuleName, "BuiltInContainer.ec") && strcmpi(mainModuleName, "Container.ec") &&
2910 strcmpi(mainModuleName, "CustomAVLTree.ec") && strcmpi(mainModuleName, "LinkList.ec") &&
2911 strcmpi(mainModuleName, "List.ec") && strcmpi(mainModuleName, "Map.ec") &&
2912 strcmpi(mainModuleName, "Mutex.ec")))
2914 SetBuildingEcereComModule(true);
2917 // Predeclare all classes
2919 char symFile[MAX_FILENAME];
2920 char symLocation[MAX_LOCATION];
2921 ImportedModule module, next;
2923 GetLastDirectory(fileName, symFile);
2924 ChangeExtension(symFile, "sym", symFile);
2926 strcpy(symLocation, GetSymbolsDir());
2927 PathCat(symLocation, symFile);
2929 // if(!GetEcereImported() && !GetBuildingEcereCom())
2930 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2933 startTime = GetTime();
2935 eModule_LoadStrict(privateModule, "ecereCOM", privateAccess);
2937 printf("Loading ecereCOM took %.3f seconds\n", GetTime() - startTime);
2942 startTime = GetTime();
2944 // LoadSymbols(symLocation, normalImport, true);
2945 LoadSymbols(symLocation, preDeclImport, false);
2947 printf("Loading symbols took %.3f seconds\n", GetTime() - startTime);
2950 for(module = defines.first; module; module = next)
2953 if(module.type == moduleDefinition && strcmpi(module.name, mainModuleName))
2956 defines.Delete(module);
2961 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2963 SetDefaultDeclMode(privateAccess);
2964 SetDeclMode(privateAccess);
2968 SetDefaultDeclMode(defaultAccess);
2969 SetDeclMode(defaultAccess);
2972 StripExtension(mainModuleName);
2973 module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };
2974 defines.AddName(module);
2977 // SetYydebug(true);
2982 startTime = GetTime();
2983 startFindClass = checkTypeTotalTime;
2987 printf("ParseEc took %.3f seconds, out of which %.3f seconds were in CheckType\n", GetTime() - startTime, checkTypeTotalTime - startFindClass);
2989 CheckDataRedefinitions();
2992 SetIncludeDirs(null);
2993 SetSysIncludeDirs(null);
3004 startTime = GetTime();
3006 PrePreProcessClassDefinitions();
3007 ComputeModuleClasses(privateModule);
3008 PreProcessClassDefinitions();
3009 ProcessClassDefinitions();
3011 printf("Initial Passes took %.3f seconds\n", GetTime() - startTime);
3012 startTime = GetTime();
3017 printf("ComputeDataTypes took %.3f seconds\n", GetTime() - startTime);
3018 startTime = GetTime();
3020 ProcessInstantiations();
3022 printf("ProcessInstantiations took %.3f seconds\n", GetTime() - startTime);
3025 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
3027 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3028 if(!windowClass || windowClass.internalDecl)
3031 startTime = GetTime();
3033 // *** COMMENTED THIS OUT DUE TO ecereCOM issues
3034 // eModule_Load(this.privateModule.application.allModules.first ? this.privateModule.application.allModules.first : this.privateModule, "ecere", privateAccess);
3035 eModule_Load(this.privateModule, "ecere", privateAccess);
3037 printf("Loading ecere.dll took %.3f seconds\n", GetTime() - startTime);
3040 windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3042 if(windowClass && windowClass.data)
3043 ApplySkin(windowClass, app.currentSkin.name, null);
3047 startTime = GetTime();
3049 for(external = ast->first; external; external = external.next)
3051 if(external.type == classExternal)
3053 ClassDefinition _class = external._class;
3054 if(_class.baseSpecs && _class.baseSpecs->first && ((Specifier)_class.baseSpecs->first).type == nameSpecifier ) // classSpecifier
3056 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)_class.baseSpecs->first).name);
3059 if(eClass_GetDesigner(regClass) && !GetBuildingEcereComModule())
3061 Instance instance = eInstance_New(regClass);
3062 ObjectInfo classObject
3064 name = CopyString(_class._class.name);
3065 instance = instance;
3066 classDefinition = _class;
3067 oClass = classObject;
3070 classes.Add(classObject);
3074 // Moved this at bottom so that the file dialog doesn't show up in eCom
3075 designer.CreateObject(instance, classObject, true, null);
3076 sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, typeClass, false);
3078 if(_class.definitions)
3082 for(def = _class.definitions->first; def; def = def.next)
3086 case defaultPropertiesClassDef:
3089 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
3091 Identifier id = propDef.identifiers->first;
3094 Property prop = eClass_FindProperty(regClass, id.string, this.privateModule);
3097 Class propertyClass = prop.dataTypeClass;
3099 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3100 if(prop.compiled && prop.Set && prop.Get && propertyClass && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp)
3102 Expression computed;
3103 bool variable = true;
3105 FreeType(propDef.initializer.exp.destType);
3106 propDef.initializer.exp.destType = MkClassType(propertyClass.name);
3107 ProcessExpressionType(propDef.initializer.exp);
3109 computed = CopyExpression(propDef.initializer.exp);
3110 ComputeExpression(computed);
3111 if(computed.isConstant)
3113 switch(computed.type)
3116 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3118 String temp = new char[strlen(computed.string)+1];
3119 ReadString(temp, computed.string);
3120 ((void (*)(void *, void *))(void *)prop.Set)(instance, temp);
3123 if(!propDef.initializer.exp.intlString)
3125 Map<String, bool> i18nStrings = classObject.i18nStrings;
3127 classObject.i18nStrings = i18nStrings = { };
3128 i18nStrings[prop.name] = false;
3134 if((propertyClass.type == structClass || propertyClass.type == noHeadClass || propertyClass.type == normalClass) && !id.next)
3138 if(computed.instance._class && computed.instance._class.symbol &&
3139 computed.instance._class.symbol.registered &&
3140 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3142 ((void (*)(void *, void *))(void *)prop.Set)(instance, computed.instance.data);
3144 // This was saved in the control and shouldn't be freed by FreeExpression...
3145 // (Not doing this anymore, incrementing refCount in pass15 instead)
3146 /*if(propertyClass.type == normalClass)
3147 computed.instance.data = null;*/
3155 Operand value = GetOperand(computed);
3156 DataValue valueData;
3157 valueData.i64 = value.i64;
3158 SetProperty(prop, instance, valueData);
3165 propDef.variable = true;
3166 FreeExpression(computed);
3171 Method method = eClass_FindMethod(regClass, id.string, this.privateModule);
3172 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer &&
3173 propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
3176 // Maintain a list in FunctionDefinition of who is attached to it
3177 for(def = _class.definitions->first; def; def = def.next)
3179 if(def.type == functionClassDef)
3181 ClassFunction function = def.function;
3182 if(!strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
3184 function.attached.Add(OldLink { data = method });
3194 case declarationClassDef:
3196 Declaration decl = def.decl;
3199 case instDeclaration:
3201 Instantiation inst = decl.inst;
3202 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3203 if(instClass && eClass_GetDesigner(instClass))
3205 Instance control = eInstance_New(instClass);
3210 oClass = classObject;
3214 classObject.instances.Add(object);
3216 // TOCHECK: Why is this needed now?
3217 object.name = CopyString((inst.exp.type == memberExp) ? inst.exp.member.member.string : inst.exp.identifier.string);
3218 def.object = object;
3220 // if(object.name) { symbol = eList_Add(&curContext.symbols, sizeof(Symbol)); symbol.string = object.name; symbol.type = MkClassType(instClass.name); }
3222 designer.CreateObject(control, object, false, classObject.instance);
3223 sheet.AddObject(object, object.name ? object.name : inst._class.name, typeData, false);
3233 // Second pass, process instantiation members
3235 for(def = _class.definitions->first; def; def = def.next)
3239 case declarationClassDef:
3241 Declaration decl = def.decl;
3244 case instDeclaration:
3246 Instantiation inst = decl.inst;
3247 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3248 if(instClass && eClass_GetDesigner(instClass))
3251 object = object ? object.next : classObject.instances.first;
3252 control = object.instance;
3256 MembersInit members;
3257 for(members = inst.members->first; members; members = members.next)
3259 switch(members.type)
3261 case dataMembersInit:
3263 if(members.dataMembers)
3266 DataMember curMember = null;
3267 Class curClass = null;
3268 DataMember subMemberStack[256];
3269 int subMemberStackPos = 0;
3271 for(member = members.dataMembers->first; member; member = member.next)
3274 Identifier ident = member.identifiers ? member.identifiers->first : null;
3277 DataMember _subMemberStack[256];
3278 int _subMemberStackPos = 0;
3279 DataMember thisMember = (DataMember)eClass_FindDataMember(instClass, ident.string, privateModule, _subMemberStack, &_subMemberStackPos);
3283 thisMember = (DataMember)eClass_FindProperty(instClass, ident.string, privateModule);
3285 if(thisMember && thisMember.memberAccess == publicAccess)
3287 curMember = thisMember;
3288 curClass = curMember._class;
3289 memcpy(subMemberStack, _subMemberStack, sizeof(DataMember) * _subMemberStackPos);
3290 subMemberStackPos = _subMemberStackPos;
3296 eClass_FindNextMember(instClass, &curClass, (DataMember *)&curMember, subMemberStack, &subMemberStackPos);
3297 if(curMember) found = true;
3299 if(found && curMember.isProperty)
3301 Property prop = (Property) curMember;
3302 Class propertyClass = prop.dataTypeClass;
3303 bool variable = false;
3305 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3307 if(prop.compiled && prop.Set && prop.Get && propertyClass && member.initializer && member.initializer.type == expInitializer && member.initializer.exp)
3309 FreeType(member.initializer.exp.destType);
3310 member.initializer.exp.destType = MkClassType(propertyClass.name);
3313 Expression computed;
3315 ProcessExpressionType(member.initializer.exp);
3317 computed = CopyExpression(member.initializer.exp);
3320 bool isClass = propertyClass.type == structClass || propertyClass.type == normalClass || propertyClass.type == noHeadClass;
3323 /*char debugExpString[4096];
3324 debugExpString[0] = '\0';
3325 PrintExpression(member.initializer.exp, debugExpString);*/
3327 ComputeExpression(computed);
3329 switch(computed.type)
3332 if(isClass && computed.isConstant && computed.instance.data)
3334 if(computed.instance._class && computed.instance._class.symbol &&
3335 computed.instance._class.symbol.registered &&
3336 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3338 ((void (*)(void *, void *))(void *)prop.Set)(control, computed.instance.data);
3340 // This was saved in the control and shouldn't be freed by FreeExpression...
3341 // (Not doing this anymore, incrementing refCount in pass15 instead)
3342 /*if(propertyClass.type == normalClass)
3343 computed.instance.data = null;*/
3349 if(isClass && eClass_GetDesigner(propertyClass))
3352 char * name = computed.identifier.string;
3353 if(!strcmp(name, "this"))
3356 ((void (*)(void *, void *))(void *)prop.Set)(control, instance);
3362 for(check = classObject.instances.first; check; check = check.next)
3363 if(check.name && !strcmp(name, check.name))
3366 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3376 if(computed.member.exp.type == identifierExp)
3378 char * name = computed.member.exp.identifier.string;
3380 if(!strcmp(name, "this"))
3382 char * name = computed.member.member.string;
3384 for(check = classObject.instances.first; check; check = check.next)
3385 if(check.name && !strcmp(name, check.name))
3388 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3395 for(check = classObject.instances.first; check; check = check.next)
3397 if(check.name && !strcmp(name, check.name))
3399 Property getProperty = eClass_FindProperty(check.instance._class, computed.member.member.string, this.privateModule);
3402 DataValue value { };
3403 GetProperty(getProperty, check.instance, &value);
3404 SetProperty(prop, control, value);
3415 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3417 String temp = new char[strlen(computed.string)+1];
3418 ReadString(temp, computed.string);
3419 ((void (*)(void *, void *))(void *)prop.Set)(control, temp);
3422 if(!member.initializer.exp.intlString)
3424 Map<String, bool> i18nStrings = object.i18nStrings;
3426 object.i18nStrings = i18nStrings = { };
3427 i18nStrings[prop.name] = false;
3434 if(!isClass && computed.isConstant)
3436 if(!strcmp(propertyClass.dataTypeString, "float"))
3437 ((void (*)(void *, float))(void *)prop.Set)(control, (float)strtod(computed.constant, null));
3438 else if(!strcmp(propertyClass.dataTypeString, "double"))
3439 ((void (*)(void *, double))(void *)prop.Set)(control, strtod(computed.constant, null));
3441 ((void (*)(void *, int))(void *)prop.Set)(control, strtol(computed.constant, null, 0));
3448 FreeExpression(computed);
3452 member.variable = true;
3454 else if(ident && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3455 member.initializer.exp.type == memberExp) // identifierExp
3457 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3458 if(method && method.type == virtualMethod)
3461 // Maintain a list in FunctionDefinition of who is attached to it
3462 for(def = _class.definitions->first; def; def = def.next)
3464 if(def.type == functionClassDef)
3466 ClassFunction function = def.function;
3467 Identifier id = (member.initializer.exp.type == memberExp) ? member.initializer.exp.member.member : member.initializer.exp.identifier;
3468 if(function.declarator && !strcmp(function.declarator.symbol.string, id.string))
3470 function.attached.Add(OldLink { data = method });
3471 // Reference this particular instance?
3486 designer.PostCreateObject(object.instance, object, false, classObject.instance);
3497 //designer.CreateObject(instance, classObject, true, null);
3498 //sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, classType, false);
3500 designer.PostCreateObject(instance, classObject, true, null);
3502 //instance.state = Hidden;
3503 //instance.Create();
3504 //instance.SetState(Normal, true, 0);
3513 printf("Class/Instance Processing took %.3f seconds\n", GetTime() - startTime);
3517 // Restore Selection
3518 if(selectedClassName)
3521 for(oClass = classes.first; oClass; oClass = oClass.next)
3523 if(!strcmp(oClass.name, selectedClassName))
3525 this.oClass = oClass;
3529 delete selectedClassName;
3538 for(check = this.oClass.instances.first; check; check = check.next)
3540 if(check.name && !strcmp(check.name, selectedName))
3542 this.selected = check;
3548 if(this.oClass.instances.first)
3549 this.selected = this.oClass.instances.first;
3551 this.selected = this.oClass;
3554 else if(selectedPos == -1 || !this.oClass.instances.count)
3555 this.selected = this.oClass;
3561 if(selectedPos > this.oClass.instances.count)
3563 for(check = this.oClass.instances.first; check; check = check.next)
3565 if(selectedPos == pos++)
3567 this.selected = check;
3575 this.oClass = classes.first;
3576 this.selected = (this.oClass && this.oClass.instances.first) ? this.oClass.instances.first : this.oClass;
3578 delete selectedName;
3579 SetSymbolsDir(null);
3581 if(sheet.codeEditor == this)
3582 sheet.SelectObject(selected);
3585 codeModified = false;
3587 // TESTING THIS TO NOT GET EMPTY PARAMETERS
3590 InvokeParameters(false, false, false);
3593 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
3599 ChangeWorkingDir(oldWorkDir);
3601 printf("Total FindClass time is %.3f seconds, out of which %.3f is in Ignore NS\n\n", findClassTotalTime, findClassIgnoreNSTotalTime);
3602 printf("Total CheckType time is %.3f seconds\n\n", checkTypeTotalTime);
3603 printf("Total MkExternalImport time is %.3f seconds\n\n", externalImportTotalTime);
3604 printf("Total FindSymbol time is %.3f seconds\n\n", findSymbolTotalTime);
3605 // printf("Total Class Members Find time is %.3f seconds\n\n", GetClassFindTime());
3607 printf("Whole ParseCode function took %.3f seconds\n\n", GetTime() - parseCodeStart);
3609 if(inUseDebug && ide.projectView)
3610 ide.debugger.EvaluateWatches();
3615 void UpdateInstanceCodeClass(Class _class, ObjectInfo object, EditBoxStream f, Instance test, bool * prev, bool * lastIsMethod, DataMember * curMember, Class * curClass)
3618 Window control = (Window)object.instance;
3619 ObjectInfo classObject = object.oClass;
3621 if(_class.base && _class.base.type != systemClass) UpdateInstanceCodeClass(_class.base, object, f, test, prev, lastIsMethod, curMember, curClass);
3623 if(!strcmp(_class.name, "DesignerBase")) return;
3625 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
3627 Property prop = eClass_FindProperty(object.instance._class, propIt.name, privateModule);
3628 if(prop && prop.isProperty && !prop.conversion && eClass_FindProperty(object.instance._class, prop.name, privateModule))
3630 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(object, prop.name) &&
3631 prop.compiled && (!prop.IsSet || prop.IsSet(control)))
3633 Class dataType = prop.dataTypeClass;
3635 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3639 if(dataType.type == structClass)
3641 void * dataForm = new0 byte[dataType.structSize];
3642 void * dataTest = new0 byte[dataType.structSize];
3644 ((void (*)(void *, void *))(void *)prop.Get)(control, dataForm);
3645 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
3647 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3649 char tempString[1024] = "";
3651 bool needClass = true;
3655 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3657 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3659 eClass_FindNextMember(_class, curClass, curMember, null, null);
3660 if(*curMember != (DataMember)prop)
3661 f.Printf("%s = ", prop.name);
3663 *curMember = (DataMember)prop;
3664 *curClass = curMember->_class;
3667 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3669 f.Printf("%s", string);
3676 else if(dataType.type == normalClass || dataType.type == noHeadClass)
3678 void * dataForm, * dataTest;
3679 bool isEditBoxContents = false;
3680 bool freeDataForm = false, freeDataTest = false;
3682 // Because contents property is broken for mutiline EditBox at the moment
3683 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
3684 isEditBoxContents = true;
3686 if(isEditBoxContents && ((EditBox)control).multiLine)
3688 dataForm = ((EditBox)control).multiLineContents;
3689 freeDataForm = true;
3692 dataForm = ((void *(*)(void *))(void *)prop.Get)(control);
3693 if(isEditBoxContents && ((EditBox)test).multiLine)
3695 dataTest = ((EditBox)test).multiLineContents;
3696 freeDataTest = true;
3699 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
3701 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3703 char tempString[1024] = "";
3708 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3710 eClass_FindNextMember(_class, curClass, curMember, null, null);
3711 if(*curMember != (DataMember)prop)
3712 f.Printf("%s = ", prop.name);
3713 *curMember = (DataMember)prop;
3714 *curClass = curMember->_class;
3716 if(eClass_GetDesigner(dataType))
3718 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
3719 //if(!strcmp(classObject.instance._class.name, dataType.name) && classObject.instance == dataForm)
3720 f.Printf("this", prop.name);
3723 //ObjectInfo classObject;
3724 //for(classObject = classes.first; classObject; classObject = classObject.next)
3728 for(object = classObject.instances.first; object; object = object.next)
3730 if(!object.deleted && eClass_IsDerived(object.instance._class, dataType) && object.instance == dataForm && object.name)
3732 f.Printf("%s", object.name);
3739 bool needClass = true;
3740 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3741 f.Printf("%s", string);
3748 bool needClass = true;
3749 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3751 if(!strcmp(dataType.dataTypeString, "char *"))
3753 Map<String, bool> i18nStrings = object.i18nStrings;
3755 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
3758 f.Printf("%s\"", i18n ? "$" : "");
3759 OutputString(f, string);
3763 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3765 f.Printf("%s", string);
3768 *lastIsMethod = false;
3771 if(freeDataForm) delete dataForm;
3772 if(freeDataTest) delete dataTest;
3776 DataValue dataForm, dataTest;
3778 GetProperty(prop, control, &dataForm);
3779 GetProperty(prop, test, &dataTest);
3781 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
3784 char tempString[1024] = "";
3785 SetProperty(prop, test, dataForm);
3787 if(dataType.type != bitClass)
3789 bool needClass = true;
3791 if(dataType.type == enumClass)
3794 Class enumClass = eSystem_FindClass(privateModule, "enum");
3795 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
3797 for(value = e.values.first; value; value = value.next)
3799 if((int)value.data == dataForm.i)
3801 string = value.name;
3807 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
3809 if(string && string[0])
3814 eClass_FindNextMember(_class, curClass, curMember, null, null);
3815 if(*curMember != (DataMember)prop)
3816 f.Printf("%s = ", prop.name);
3817 *curMember = (DataMember)prop;
3818 *curClass = curMember->_class;
3820 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
3821 f.Printf("%sf", string);
3823 f.Printf("%s", string);
3827 else if(dataType.type == bitClass)
3829 bool needClass = true;
3831 if(*prev) f.Printf(", ");
3833 eClass_FindNextMember(_class, curClass, curMember, null, null);
3834 if(*curMember != (DataMember)prop)
3835 f.Printf("%s = ", prop.name);
3836 *curMember = (DataMember)prop;
3837 *curClass = curMember->_class;
3839 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm.ui, tempString, null, &needClass);
3841 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3843 f.Printf("%s", string);
3845 *lastIsMethod = false;
3855 int UpdateInstanceCode(EditBoxStream f, int position, Class regClass, ObjectInfo object, bool * firstObject, char ** text, int * textSize, int movedFuncIdLen, int movedFuncIdPos)
3857 Instantiation inst = object.instCode;
3858 Window control = (Window)object.instance;
3860 bool methodPresent = false;
3862 bool lastIsMethod = true;
3863 ObjectInfo classObject = object.oClass;
3869 // Instance removed, delete it
3870 DeleteJunkBefore(f, inst.loc.start.pos, &position);
3872 f.DeleteBytes(inst.loc.end.pos - inst.loc.start.pos + 1);
3873 position = inst.loc.end.pos + 1;
3877 bool multiLine = false;
3880 // Check if it's an unnamed instance
3883 f.Seek(inst.nameLoc.start.pos - position, current);
3884 f.DeleteBytes(inst.nameLoc.end.pos - inst.nameLoc.start.pos);
3885 position = inst.nameLoc.end.pos;
3887 f.Printf(object.name);
3892 if(isspace(ch) && ch != '\n')
3894 f.Seek(-1, current);
3902 int pos = inst.loc.start.pos; // + strlen(inst._class.name);
3904 f.Seek(pos - position, current);
3909 f.Seek(-1, current);
3918 f.Puts(object.name);
3923 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
3924 methodPresent = true;
3932 if(ch == OpenBracket)
3938 // TODO: Simplify this?
3947 f.Seek(-1, current);
3948 DeleteJunkBefore(f, position, &position);
3960 if(ch == '\n') { toDelete = count; count = 0; }
3961 else if(isspace(ch)) count++;
3964 f.Seek(-1, current);
3968 toDelete += count - 6;
3978 f.Seek(-toDelete-count, current);
3979 f.DeleteBytes(toDelete);
3980 f.Seek(count, current);
3983 DeleteJunkBefore(f, position, &position);
3985 // Removed this here as it was adding trailing spaces when adding a method
3990 for(c = 0; c<toAdd; c++)
3997 methodPresent = multiLine;
3999 //if(!prev) -- always false
4000 f.Printf(methodPresent ? "\n " : " ");
4005 // Instance not there, create a brand new one
4006 DeleteJunkBefore(f, position, &position);
4007 f.Printf(*firstObject ? "\n\n" : "\n");
4008 *firstObject = false;
4010 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
4011 methodPresent = true;
4016 f.Printf(" %s %s\n %c\n ", control._class.name, object.name, OpenBracket);
4018 f.Printf(" %s\n %c\n ", control._class.name, OpenBracket);
4023 f.Printf(" %s %s %c ", control._class.name, object.name, OpenBracket);
4025 f.Printf(" %s %c ", control._class.name, OpenBracket);
4031 Instance test = eInstance_New(control._class);
4032 DataMember curMember = null;
4033 Class curClass = null;
4036 UpdateInstanceCodeClass(control._class, object, f, test, &prev, &lastIsMethod, &curMember, &curClass);
4040 // Attach Method here
4041 if((this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod) && !this.moveAttached && this.selected == object)
4043 if(prev) f.Printf(", ");
4044 f.Printf("%s = %s", this.method.name, function.declarator.symbol.string);
4049 if(inst && !object.deleted)
4051 MembersInit members;
4052 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
4054 DeleteJunkBefore(f, position, &position);
4056 // Instance already there, clear out the properties
4057 for(members = inst.members ? inst.members->first : null; members; members = members.next)
4059 if(members.type == dataMembersInit)
4063 if(members.dataMembers)
4065 bool keptMember = false;
4066 MemberInit lastKept = null;
4068 for(member = members.dataMembers->first; member; member = member.next)
4070 Identifier ident = member.identifiers ? member.identifiers->first : null;
4071 bool deleted = false;
4073 // For now delete if it's not a method
4074 if(!member.variable) // && ident)
4076 if(!ident || !ident.next)
4078 Property prop = ident ? eClass_FindProperty(instClass, ident.string, this.privateModule) : null;
4081 f.Seek(member.loc.start.pos - position, current);
4082 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4083 position = member.loc.end.pos;
4088 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
4089 if(method && method.type == virtualMethod && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
4090 member.initializer.exp.type == memberExp /*ExpIdentifier*/)
4092 if(((this.methodAction == actionDetachMethod || this.methodAction == actionReattachMethod) && this.method == method && this.selected == object) ||
4093 (this.methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, member.initializer.exp.identifier.string)))
4095 f.Seek(member.loc.start.pos - position, current);
4096 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4097 position = member.loc.end.pos;
4109 //f.Seek(member.loc.start.pos - position, current);
4110 //position = member.loc.start.pos;
4111 DeleteJunkBefore(f, member.loc.start.pos, &position);
4112 if(prev) f.Printf(", ");
4113 else if(keptMember) f.Printf(" ");
4118 if(!keptMember || !members.next)
4123 if(keptMember && lastKept != members.dataMembers->last)
4128 f.Seek(-1, current);
4134 f.Seek(-1, current);
4137 else if(!isspace(ch))
4139 f.Seek(-2, current);
4144 f.DeleteBytes(count);
4147 f.Seek(members.loc.end.pos - position, current);
4152 f.Seek(-1, current);
4154 position = members.loc.end.pos + 1;
4158 f.Seek(-1, current);
4159 position = members.loc.end.pos;
4165 lastIsMethod = false;
4170 DeleteJunkBefore(f, position, &position);
4173 if(lastKept != members.dataMembers->last)
4178 f.Seek(-1, current);
4184 f.Seek(-1, current);
4187 else if(!isspace(ch))
4189 f.Seek(-2, current);
4194 f.DeleteBytes(count);
4198 f.Seek(members.loc.end.pos - position, current);
4199 position = members.loc.end.pos;
4203 lastIsMethod = true;
4206 lastIsMethod = false;
4212 f.Seek(members.loc.end.pos - position, current);
4213 position = members.loc.end.pos;
4215 lastIsMethod = true;
4218 else if(members.type == methodMembersInit)
4220 if(this.methodAction == actionDeleteMethod && members.function == function);
4222 methodPresent = true;
4224 // Delete instance method here
4225 if((this.methodAction == actionDeleteMethod || (this.methodAction == actionDetachMethod && this.moveAttached)) &&
4226 members.function == function)
4228 if(this.moveAttached && !*text)
4229 GetLocText(editBox, f, position, &function.loc, text, textSize, Max((int)strlen(this.methodName) - movedFuncIdLen,0), 0);
4231 DeleteJunkBefore(f, members.loc.start.pos, &position);
4232 f.DeleteBytes(members.loc.end.pos - members.loc.start.pos + 1);
4233 position = members.loc.end.pos + 1;
4238 DeleteJunkBefore(f, position, &position);
4242 DeleteJunkBefore(f, members.loc.start.pos, &position);
4243 lastIsMethod = true;
4247 f.Seek(members.loc.end.pos - position, current);
4248 position = members.loc.end.pos;
4250 DeleteJunkBefore(f, position, &position);
4259 if((this.methodAction == actionAddMethod || (this.moveAttached && (this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod))) && this.selected == object)
4261 Method method = this.method;
4262 DeleteJunkBefore(f, position, &position);
4268 if(!method.dataType)
4269 method.dataType = ProcessTypeString(method.dataTypeString, false);
4272 Type dataType = method.dataType;
4273 Type returnType = dataType.returnType;
4276 if(this.moveAttached)
4278 // Move function here:
4279 int newLen = strlen(method.name);
4284 GetLocText(editBox, f, position, &function.loc, text, textSize, Max(newLen - movedFuncIdLen, 0), 3);
4286 // First change name of function
4287 memmove(*text + movedFuncIdPos + newLen, *text + movedFuncIdPos + movedFuncIdLen, *textSize - movedFuncIdPos - movedFuncIdLen + 1);
4288 *textSize += newLen - movedFuncIdLen;
4289 memcpy(*text + movedFuncIdPos, method.name, newLen);
4291 // Second, tab right
4294 for(c = 0; (*text)[c]; )
4297 for(i = c; (*text)[i] && (*text)[i] != '\n'; i++);
4300 memmove((*text)+c+3, (*text)+c, *textSize+1-c);
4301 (*text)[c] = (*text)[c+1] = (*text)[c+2] = ' ';
4305 for(; (*text)[c] && (*text)[c] != '\n'; c++);
4315 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4317 // ADDING METHOD HERE
4319 OutputType(f, returnType, false);
4322 if(dataType.thisClass)
4324 if(!eClass_IsDerived(regClass, dataType.thisClass.registered) && !dataType.classObjectType) // Just fixed this... was backwards.
4326 if(dataType.thisClass.shortName)
4327 f.Printf(dataType.thisClass.shortName);
4329 f.Printf(dataType.thisClass.string);
4333 f.Printf(method.name);
4335 for(param = dataType.params.first; param; param = param.next)
4337 OutputType(f, param, true);
4342 f.Printf(" %c\n\n", OpenBracket);
4344 if(control._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4346 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4347 f.Printf(" return true;\n");
4348 else if(returnType.kind != voidType)
4349 f.Printf(" return 0;\n");
4354 if(returnType.kind != voidType)
4355 f.Printf("return ");
4356 f.Printf("%s::%s(", control._class.name, method.name);
4357 for(param = dataType.params.first; param; param = param.next)
4359 if(param.prev) f.Printf(", ");
4360 if(param.kind != voidType)
4361 f.Printf(param.name);
4365 f.Printf(" %c\n", CloseBracket);
4371 if(!object.instCode)
4372 f.Printf(methodPresent ? " %c;" : "%c;", CloseBracket);
4373 else if(!object.deleted)
4375 // Turn this into a multiline instance when adding a method
4376 DeleteJunkBefore(f, inst.loc.end.pos-1, &position);
4378 f.Printf(methodPresent ? "\n " : " ");
4380 f.Seek(inst.loc.end.pos + 1 - position, current);
4381 position = inst.loc.end.pos + 1;
4386 void OutputClassProperties(Class _class, ObjectInfo classObject, EditBoxStream f, Instance test)
4389 Class regClass = eSystem_FindClass(privateModule, classObject.name);
4391 if(_class.base && _class.base.type != systemClass) OutputClassProperties(_class.base, classObject, f, test);
4393 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
4395 Property prop = eClass_FindProperty(selected.instance._class, propIt.name, privateModule);
4396 if(prop && prop.isProperty && !prop.conversion)
4398 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(classObject, prop.name) &&
4399 (!prop.IsSet || prop.IsSet(classObject.instance)))
4401 Class dataType = prop.dataTypeClass;
4402 char tempString[1024] = "";
4404 bool specify = false;
4407 member = eClass_FindDataMember(regClass, prop.name, privateModule, null, null);
4408 if(member && member._class == regClass)
4412 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
4414 if(dataType && dataType.type == structClass)
4416 void * dataForm = new0 byte[dataType.structSize];
4417 void * dataTest = new0 byte[dataType.structSize];
4419 ((void (*)(void *, void *))(void *)prop.Get)(classObject.instance, dataForm);
4420 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
4422 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4424 bool needClass = true;
4426 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4427 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4429 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4431 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4436 else if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
4438 void * dataForm, * dataTest;
4439 bool isEditBoxContents = false;
4440 bool freeDataForm = false, freeDataTest = false;
4442 // Because contents property is broken for mutiline EditBox at the moment
4443 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
4444 isEditBoxContents = true;
4446 if(isEditBoxContents && ((EditBox)classObject.instance).multiLine)
4448 dataForm = ((EditBox)classObject.instance).multiLineContents;
4449 freeDataForm = true;
4452 dataForm = ((void *(*)(void *))(void *)prop.Get)(classObject.instance);
4453 if(isEditBoxContents && ((EditBox)test).multiLine)
4455 dataTest = ((EditBox)test).multiLineContents;
4456 freeDataTest = true;
4459 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
4461 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4463 char tempString[1024] = "";
4465 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4467 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
4469 // Shouldn't go here ...
4470 f.Printf("\n %s%s = this;", specify ? "property::" : "", prop.name);
4474 bool needClass = true;
4476 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4478 if(!strcmp(dataType.dataTypeString, "char *"))
4480 Map<String, bool> i18nStrings = classObject.i18nStrings;
4482 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
4485 f.Printf("\n %s%s = %s\"", specify ? "property::" : "", prop.name, i18n ? "$" : "");
4486 OutputString(f, string);
4490 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4492 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4495 if(freeDataForm) delete dataForm;
4496 if(freeDataTest) delete dataTest;
4500 DataValue dataForm, dataTest;
4502 GetProperty(prop, classObject.instance, &dataForm);
4503 GetProperty(prop, test, &dataTest);
4505 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
4507 SetProperty(prop, test, dataForm);
4508 if(dataType.type == bitClass)
4510 bool needClass = true;
4511 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4513 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4515 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4519 bool needClass = true;
4520 if(dataType.type == enumClass)
4523 Class enumClass = eSystem_FindClass(privateModule, "enum");
4524 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
4526 for(value = e.values.first; value; value = value.next)
4528 if((int)value.data == dataForm.i)
4530 string = value.name;
4536 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4537 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
4538 f.Printf("\n %s%s = %sf;", specify ? "property::" : "", prop.name, string);
4540 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4549 void UpdateFormCode()
4552 if(!parsing) return;
4559 else if(formModified)
4561 EditBoxStream f { editBox = editBox };
4565 Identifier movedFuncId;
4566 int movedFuncIdLen = 0, movedFuncIdPos = 0;
4567 ObjectInfo classObject;
4571 editBox.recordUndoEvent = true;
4575 movedFuncId = GetDeclId(function.declarator);
4576 movedFuncIdLen = movedFuncId.loc.end.pos - movedFuncId.loc.start.pos;
4577 movedFuncIdPos = movedFuncId.loc.start.pos - function.loc.start.pos;
4580 for(classObject = classes.first; classObject; classObject = classObject.next)
4583 ClassDefinition classDef = classObject.classDefinition;
4584 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
4587 bool firstObject = true;
4588 ObjectInfo object = classObject.instances.first;
4589 bool lastIsDecl = false;
4591 if(!classObject.modified) continue;
4593 test = eInstance_New(regClass);
4596 // Put it in the same desktop window...
4597 designer.PrepareTestObject(test);
4599 //f.Printf("class %s : %s\n", classObject.name, classObject.oClass.name);
4600 //f.Printf("%c\n\n", OpenBracket);
4602 // Change the _class name
4603 f.Seek(classDef.nameLoc.start.pos - position, current);
4604 f.DeleteBytes(classDef.nameLoc.end.pos - classDef.nameLoc.start.pos);
4605 f.Printf(classObject.name);
4606 position = classDef.nameLoc.end.pos;
4609 // Go to block start, delete all until no white space, put \n
4613 f.Seek(classDef.blockStart.end.pos - position, current);
4614 position = classDef.blockStart.end.pos;
4616 for(; f.Getc(&ch); count++)
4620 f.Seek(-1, current);
4630 f.Seek(-count, current);
4632 f.DeleteBytes(count-back);
4634 position += count-back;
4637 // Output properties
4638 OutputClassProperties(classObject.instance._class, classObject, f, test);
4640 for(def = classDef.definitions->first; def; def = def.next)
4644 case defaultPropertiesClassDef:
4646 bool keptMember = false;
4648 MemberInit lastKept = null;
4651 DeleteJunkBefore(f, def.loc.start.pos, &position);
4653 // This was adding blank spaces between comment and properties -- What was it for?
4656 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4658 Identifier ident = propDef.identifiers->first;
4659 bool deleted = false;
4661 // For now delete if it's a prop
4662 if(!propDef.variable && ident)
4666 Property prop = eClass_FindProperty(regClass, ident.string, this.privateModule);
4669 f.Seek(propDef.loc.start.pos - position, current);
4670 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4671 position = propDef.loc.end.pos;
4676 Method method = eClass_FindMethod(regClass, ident.string, this.privateModule);
4677 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4679 if(((methodAction == actionDetachMethod || methodAction == actionReattachMethod) && method == this.method && selected == classObject) ||
4680 (methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string)))
4682 f.Seek(propDef.loc.start.pos - position, current);
4683 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4684 position = propDef.loc.end.pos;
4702 f.Seek(def.loc.end.pos - position - 1, current);
4707 f.Seek(-1, current);
4710 position = def.loc.end.pos;
4714 if(lastKept != def.defProperties->last)
4719 f.Seek(-1, current);
4725 f.Seek(-1, current);
4728 else if(!isspace(ch))
4730 f.Seek(-2, current);
4735 f.DeleteBytes(count);
4739 f.Seek(def.loc.end.pos - position, current);
4740 position = def.loc.end.pos;
4745 case declarationClassDef:
4747 Declaration decl = def.decl;
4749 if(decl.type == instDeclaration)
4751 if(def.object/* && ((ObjectInfo)def.object).modified*/)
4753 while(def.object && object != def.object)
4755 if(object /*&& ((ObjectInfo)def.object).modified*/)
4756 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4757 object = object.next;
4760 DeleteJunkBefore(f, def.loc.start.pos, &position);
4761 f.Printf(firstObject ? "\n\n " : "\n ");
4762 firstObject = false;
4764 if(def.object && ((ObjectInfo)def.object).modified)
4765 position = UpdateInstanceCode(f, position, regClass, def.object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4767 object = object ? object.next : null;
4771 DeleteJunkBefore(f, def.loc.start.pos, &position);
4772 f.Printf(firstObject ? "\n\n " : "\n ");
4773 firstObject = false;
4779 DeleteJunkBefore(f, def.loc.start.pos, &position);
4780 f.Printf(lastIsDecl ? "\n " : "\n\n ");
4785 case functionClassDef:
4787 // TESTING IF THIS IS GOOD ENOUGH FOR GENERATED FUNCTION...
4788 if(!def.function.body) continue;
4792 DeleteJunkBefore(f, def.loc.start.pos, &position);
4795 // Delete _class methods
4796 if((methodAction == actionDeleteMethod || (moveAttached && selected != classObject)) &&
4797 def.function == function)
4802 if(moveAttached && !text)
4804 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max((int)strlen(methodName) - movedFuncIdLen,0), 3);
4807 f.Seek(def.loc.end.pos - position, current);
4808 for(; f.Getc(&ch); count++)
4812 f.Seek(-1, current);
4816 f.Seek(def.loc.start.pos - def.loc.end.pos - count, current);
4818 f.DeleteBytes(def.loc.end.pos - def.loc.start.pos + count);
4819 position = def.loc.end.pos + count;
4822 // In case of detaching methods in the _class, simply rename the method
4823 if(methodAction == actionDetachMethod && moveAttached && selected == classObject && function == def.function)
4825 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4826 f.DeleteBytes(movedFuncIdLen);
4828 position = function.loc.start.pos + movedFuncIdPos + movedFuncIdLen;
4831 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && moveAttached &&
4832 function == def.function)
4834 // In case of attaching methods in the _class, simply rename the method
4835 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4836 position = function.loc.start.pos + movedFuncIdPos;
4837 f.DeleteBytes(movedFuncIdLen);
4838 if(method.dataType.thisClass)
4839 f.Printf("%s::", method.dataType.thisClass.string);
4840 f.Puts(method.name);
4841 position += movedFuncIdLen;
4846 DeleteJunkBefore(f, def.loc.start.pos, &position);
4847 if(def.type == memberAccessClassDef)
4850 firstObject = false;
4860 f.Seek(def.loc.end.pos - position, current);
4861 position = def.loc.end.pos;
4864 // Output attached methods
4865 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && !moveAttached)
4867 DeleteJunkBefore(f, position, &position);
4868 f.Printf("\n %s = %s;\n", method.name, function.declarator.symbol.string);
4871 // ********** INSTANCES ***************
4872 for(; object; object = object.next)
4874 if(!object.instCode)
4876 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4880 DeleteJunkBefore(f, position, &position);
4882 // ****************** METHODS ***********************
4883 if(methodAction == actionDetachMethod && moveAttached && classObject == oClass)
4885 // If detaching an instance method
4886 if(selected != classObject)
4888 int newLen = strlen(methodName);
4891 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max(newLen - movedFuncIdLen,0), 0);
4892 // Tab selection left
4895 for(c = 0; text[c]; )
4898 for(i = 0; i<3 && text[c] == ' '; i++, c++);
4899 memmove(text+start, text+start+i, textSize+1-start-i);
4902 for(; text[c] && text[c] != '\n'; c++);
4908 memmove(text + movedFuncIdPos + newLen, text + movedFuncIdPos + movedFuncIdLen, textSize - movedFuncIdPos - movedFuncIdLen + 1);
4909 textSize += newLen - movedFuncIdLen;
4910 memcpy(text + movedFuncIdPos, methodName, newLen);
4917 if(methodAction == actionAddMethod && selected == classObject)
4919 Method method = this.method;
4921 if(!method.dataType)
4922 method.dataType = ProcessTypeString(method.dataTypeString, false);
4924 // ADDING METHOD HERE
4926 Type dataType = method.dataType;
4927 Type returnType = dataType.returnType;
4929 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4933 OutputType(f, returnType, false);
4936 if(dataType.thisClass && !dataType.classObjectType)
4938 if(dataType.thisClass.shortName)
4939 f.Printf(dataType.thisClass.shortName);
4941 f.Printf(dataType.thisClass.string);
4944 f.Printf(method.name);
4946 for(param = dataType.params.first; param; param = param.next)
4948 OutputType(f, param, true);
4953 f.Printf(" %c\n\n", OpenBracket);
4955 if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4957 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4958 f.Printf(" return true;\n");
4959 else if(returnType && returnType.kind != voidType)
4960 f.Printf(" return 0;\n");
4965 if(returnType.kind != voidType)
4966 f.Printf("return ");
4968 char * name = ((Specifier)classDef.baseSpecs->first).name;
4969 Symbol _class = FindClass(name);
4970 f.Printf("%s::%s(", (_class && _class.registered) ? _class.registered.name : name, method.name);
4972 for(param = dataType.params.first; param; param = param.next)
4974 if(param.prev) f.Printf(", ");
4975 if(param.kind != voidType)
4976 f.Printf(param.name);
4981 f.Printf(" %c", CloseBracket);
4985 DeleteJunkBefore(f, classDef.loc.end.pos-1, &position);
4991 editBox.recordUndoEvent = false;
4999 // TOFIX: Patch for a glitch where clicking at the end of the view seems one line off. No idea what could be going on?
5000 editBox.OnVScroll(setRange, editBox.scroll.y, 0);
5004 codeModified = false;
5005 formModified = false;
5007 moveAttached = false;
5012 int FindMethod(char * methodName /*Method method*/, ClassFunction*functionPtr, Location propLoc)
5015 ClassFunction function = null;
5018 ObjectInfo object = this.selected;
5020 if(object && object == this.oClass)
5022 ClassDefinition classDef = object.oClass.classDefinition;
5024 if(classDef && classDef.definitions)
5026 for(def = classDef.definitions->first; def; def = def.next)
5028 if(def.type == functionClassDef && def.function.declarator)
5030 if(!strcmp(def.function.declarator.symbol.string, methodName))
5032 function = def.function;
5037 else if(def.type == defaultPropertiesClassDef)
5041 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
5043 Identifier ident = propDef.identifiers ? propDef.identifiers->first : null;
5044 if(ident && !ident.next)
5046 if(!strcmp(ident.string, methodName) && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
5050 propLoc = propDef.loc;
5053 ClassDefinition classDef = object.oClass.classDefinition;
5055 if(classDef.definitions)
5057 for(def = classDef.definitions->first; def; def = def.next)
5059 if(def.type == functionClassDef)
5061 if(!strcmp(def.function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
5063 function = def.function;
5082 Instantiation inst = object.instCode;
5084 // Check here to see if the method already exists, no need to call ModifyCode in that case
5085 if(inst && inst.members)
5087 MembersInit members;
5088 for(members = inst.members->first; members; members = members.next)
5090 switch(members.type)
5092 case dataMembersInit:
5094 if(members.dataMembers)
5097 for(member = members.dataMembers->first; member; member = member.next)
5099 Identifier ident = member.identifiers ? member.identifiers->first : null;
5100 if(ident && !ident.next)
5102 if(!strcmp(ident.string, methodName) && member.initializer && member.initializer.type == expInitializer && member.initializer.exp && member.initializer.exp.type == memberExp /*ExpIdentifier*/)
5106 propLoc = member.loc;
5109 ClassDefinition classDef = object.oClass.classDefinition;
5111 if(classDef.definitions)
5113 for(def = classDef.definitions->first; def; def = def.next)
5115 if(def.type == functionClassDef)
5117 if(def.function.declarator && !strcmp(def.function.declarator.symbol.string, member.initializer.exp.identifier.string))
5119 function = def.function;
5128 // TODO: Fix memory leak
5129 function = ClassFunction
5131 declarator = Declarator { symbol = Symbol { string = CopyString(member.initializer.exp.member.member ? member.initializer.exp.member.member.string : "") } }
5143 case methodMembersInit:
5145 if(members.function.declarator && !strcmp(members.function.declarator.symbol.string, methodName))
5147 function = members.function;
5159 if(functionPtr) *functionPtr = function;
5163 void GoToMethod(char * methodName /*Method method*/)
5167 ObjectInfo object = selected;
5168 EditBoxStream f { editBox = editBox };
5169 ClassFunction function = null;
5170 bool atChar = false;
5174 Location propLoc = { {0,0,-1} };
5177 if(FindMethod(methodName, &function, &propLoc) == 1 && object != this.oClass) indent = 9;
5178 if(function && function.body)
5181 f.Seek(function.body.loc.start.pos+1, current);
5191 f.Seek(-1, current);
5196 else if(!isspace(ch))
5198 f.Seek(-1, current);
5204 else if(propLoc.start.pos > -1)
5206 f.Seek(propLoc.start.pos, current);
5209 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
5211 if(function || propLoc.start.pos > -1)
5213 editBox.SetSelPos(l1, y1, atChar ? x1 : indent, l2, y2, atChar ? x2 : indent);
5214 editBox.CenterOnCursor();
5215 SetState(normal, false, 0);
5218 if(function && function.declarator && function.declarator.symbol && !function.declarator.symbol.type)
5220 FreeClassFunction(function);
5226 void FindCompatibleMethods(Method method, OldList compatible)
5228 ClassDefinition classDef = this.oClass.classDefinition;
5229 if(classDef && classDef.definitions)
5232 Class baseClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5235 Symbol classSym { };
5236 Symbol selectedClass;
5237 if(this.selected == this.oClass)
5238 selectedClass = classSym;
5240 selectedClass = FindClass(this.selected.instance._class.name);
5242 regClass.name = classDef._class.name;
5243 regClass.base = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5244 for(def = classDef.definitions->first; def; def = def.next)
5246 if(def.type == functionClassDef && def.function.declarator)
5248 Method vMethod = eClass_FindMethod(baseClass, def.function.declarator.symbol.string, this.privateModule);
5250 vMethod = eClass_FindMethod(this.selected.instance._class, def.function.declarator.symbol.string, this.privateModule);
5253 Type type = def.function.declarator.symbol.type;
5254 if(CheckCompatibleMethod(method, type, regClass, this.selected == this.oClass, FindClass(this.selected.instance._class.name)))
5256 compatible.Add(OldLink { data = def.function });
5262 if(this.oClass && this.oClass.instance)
5264 classSym.registered = regClass;
5265 //classSym.registered = this.oClass.oClass;
5267 for(_class = regClass.base; _class; _class = _class.base)
5270 for(testMethod = (Method)_class.methods.first; testMethod; testMethod = (Method)((BTNode)testMethod).next)
5272 // TODO: Understand why these functions popup in attach list
5273 if(testMethod.type != virtualMethod /*&& testMethod.function != Window_OnGetString && testMethod.function != Window_OnGetDataFromString*/)
5275 if(!testMethod.dataType)
5276 testMethod.dataType = ProcessTypeString(testMethod.dataTypeString, false);
5278 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5279 if(CheckCompatibleMethod(method, testMethod.dataType, this.oClass.instance._class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5280 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, this.selected == this.oClass, FindClass(this.oClass.oClass.name)))
5282 // TODO: Fix memory leak, Figure out if it should be ClassFunction or FunctionDefinition
5283 // ClassFunction function { };
5284 FunctionDefinition function { };
5286 function.declarator = Declarator { };
5287 function.declarator.symbol = Symbol { string = CopyString(testMethod.name) };
5288 excludedSymbols.Add(function.declarator.symbol);
5290 compatible.Add(OldLink { data = function });
5301 void AddMethod(Method method)
5305 char methodName[1024];
5306 strcpy(methodName, method.name);
5307 if(!FindMethod(methodName, null, null))
5309 methodAction = actionAddMethod;
5310 this.method = method;
5314 GoToMethod(methodName);
5318 void DeleteMethod(ClassFunction function)
5322 methodAction = actionDeleteMethod;
5323 this.function = function;
5331 void AttachMethod(Method method, ClassFunction function)
5335 // If it's an instance we'll ask if we want to move it inside...
5336 if(!function.attached.count && function.body)
5338 // Find the function in the _class to check if it's a virtual function
5339 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5340 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5341 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5343 for(def = this.classDefinition.first; def; def = def.next)
5345 if(def.type == functionClassDef)
5347 if(def.function == function)
5352 if(!method || method.type != virtualMethod)
5355 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5356 if(MessageBox { type = yesNo, master = parent, text = title, contents = $"Method is unused. Move method inside instance?"}.Modal() == yes)
5358 moveAttached = true;
5363 methodAction = actionAttachMethod;
5364 this.method = method;
5365 this.function = function;
5372 void ReAttachMethod(Method method, ClassFunction function)
5376 // If it's an instance we'll ask if we want to move it inside...
5377 if(!function.attached.count && function.body)
5379 // Find the function in the _class to check if it's a virtual function
5380 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5381 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5382 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5384 for(def = this.classDefinition.first; def; def = def.next)
5386 if(def.type == functionClassDef)
5388 if(def.function == function)
5393 if(!method || method.type != virtualMethod)
5396 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5397 if(MessageBox { type = yesNo, master = parent, text = title,
5398 contents = $"Method is unused. Move method inside instance?" }.Modal() == yes)
5400 moveAttached = true;
5405 methodAction = actionReattachMethod;
5406 this.method = method;
5407 this.function = function;
5414 void DetachMethod(Method method, ClassFunction function, int type)
5422 hasClose = true, borderStyle = sizable, minClientSize = { 300, 55 },
5423 master = sheet, text = $"Name detached method", background = formColor
5427 dialog, anchor = { horz = 45, top = 30 }, size = { 80 }, text = $"Cancel", hotKey = escape,
5428 id = DialogResult::cancel, NotifyClicked = ButtonCloseDialog
5432 dialog, anchor = { horz = -45, top = 30 }, size = { 80 }, text = $"OK", isDefault = true,
5433 id = DialogResult::ok, NotifyClicked = ButtonCloseDialog
5437 dialog, anchor = { left = 5, right = 5, top = 5 }
5439 sprintf(methodName, "%s_%s", selected.name, method.name);
5440 nameBox.contents = methodName;
5442 result = dialog.Modal() == ok;
5443 strcpy(methodName, nameBox.contents);
5448 // If the method is not attached, move it outside
5451 // Add this class to the methodName
5452 char name[1024] = "";
5454 if(this.selected != this.oClass && !method.dataType.thisClass)
5456 strcat(name, this.selected.instance._class.name);
5458 strcat(name, this.methodName);
5459 strcpy(this.methodName, name);
5461 else if(method.dataType.thisClass && (this.selected == this.oClass || !eClass_IsDerived(this.oClass.instance._class, method.dataType.thisClass.registered)))
5463 strcat(name, method.dataType.thisClass.string);
5465 strcat(name, this.methodName);
5466 strcpy(this.methodName, name);
5469 this.moveAttached = true;
5472 this.methodAction = actionDetachMethod;
5473 this.method = method;
5474 this.function = function;
5481 void AddObject(Instance instance, ObjectInfo * object)
5485 //*object = _class.instances.Add(sizeof(ObjectInfo));
5486 *object = ObjectInfo { };
5487 oClass.instances.Insert((selected.oClass == selected) ? null : selected, *object);
5488 (*object).oClass = oClass;
5489 (*object).instance = instance;
5494 sprintf(name, "%c%s%d", tolower(instance._class.name[0]), instance._class.name+1, id);
5496 // if(strcmp(name, this.oClass.instance.name))
5499 for(check = oClass.instances.first; check; check = check.next)
5500 if(!check.deleted && check.name && !strcmp(name, check.name))
5504 (*object).name = CopyString(name);
5509 toolBox.controlClass = null;
5513 //sheet.AddObject(*object, (*object).name, TypeData, true);
5518 void EnsureUpToDate()
5520 if(sheet && codeModified && parsing)
5524 void SelectObject(ObjectInfo object)
5527 oClass = object ? object.oClass : null;
5529 designer.SelectObject(object, object ? object.instance : null);
5532 void SelectObjectFromDesigner(ObjectInfo object)
5535 sheet.SelectObject(object);
5538 void EnumerateObjects(Sheet sheet)
5542 for(oClass = classes.first; oClass; oClass = oClass.next)
5548 sheet.AddObject(oClass, oClass.name ? oClass.name : oClass.instance._class.name, typeClass, false);
5549 for(object = oClass.instances.first; object; object = object.next)
5550 sheet.AddObject(object, object.name ? object.name : object.instance._class.name, typeData, false);
5553 sheet.SelectObject(selected);
5558 designer.AddObject();
5561 void DeleteObject(ObjectInfo object)
5563 delete object.instance;
5564 object.deleted = true;
5565 object.modified = true;
5566 object.oClass.modified = true;
5568 if(selected == object)
5570 bool looped = false;
5571 ObjectInfo select = object;
5575 select = select.prev;
5579 select = object.oClass.instances.last;
5586 sheet.SelectObject(select ? select : oClass);
5589 if(!object.instCode && object.oClass != object)
5592 oClass.instances.Delete(object);
5595 if(sheet.codeEditor == this)
5596 sheet.DeleteObject(object);
5599 void RenameObject(ObjectInfo object, char * name)
5603 // Validate the name:
5604 if(object != oClass && (!name || !name[0])) valid = true; // What's this one again?
5605 else if(name[0] && (isalpha(name[0]) || name[0] == '_'))
5608 for(c = 0; name[c]; c++)
5609 if(!isalnum(name[c]) && name[c] != '_' && name[c] != '_')
5617 object.name = (name && name[0]) ? CopyString(name) : null;
5619 sheet.RenameObject(object, object.name ? object.name : object.instance._class.name);
5623 void DesignerModifiedObject()
5625 sheet.ListProperties(false);
5629 void ListSubMembers(Type member)
5633 for(subMember = member.members.first; subMember; subMember = subMember.next)
5637 DataRow row = membersList.AddString(subMember.name);
5638 row.icon = icons[typeData];
5642 ListSubMembers(subMember);
5647 void ListSubDataMembers(DataMember member, bool isPrivate)
5649 DataMember subMember;
5650 for(subMember = member.members.first; subMember; subMember = subMember.next)
5652 if((subMember.memberAccess == publicAccess && !isPrivate) || subMember._class.module == privateModule)
5656 DataRow row = membersList.AddString(subMember.name);
5657 BitmapResource bitmap = null;
5658 if(!subMember.dataType)
5659 subMember.dataType = ProcessTypeString(subMember.dataTypeString, false);
5661 if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
5663 char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
5666 bitmap = { bitmapName };
5667 membersList.AddResource(bitmap);
5670 row.icon = bitmap ? bitmap : icons[(subMember.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5674 ListSubDataMembers(subMember, isPrivate || member.memberAccess == privateAccess);
5680 void ListClassMembers(Class whatClass, bool methodsOnly)
5683 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5684 bool isPrivate = false;
5686 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5688 Method method, methodIt;
5690 DataMember memberIt;
5692 for(methodIt = (Method)_class.methods.first; methodIt; methodIt = (Method)((BTNode)methodIt).next)
5694 method = eClass_FindMethod(whatClass, methodIt.name, privateModule);
5695 if(methodIt.memberAccess == privateAccess && method && method.memberAccess == publicAccess)
5697 if(method && method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5699 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5701 DataRow row = membersList.FindString(method.name);
5704 row = membersList.AddString(method.name);
5706 if(!method.dataType)
5707 method.dataType = ProcessTypeString(method.dataTypeString, false);
5709 row.icon = icons[(method.type == virtualMethod && method.dataType && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5717 for(memberIt = _class.membersAndProperties.first; memberIt; memberIt = memberIt.next)
5721 if(memberIt.isProperty)
5723 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5725 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5729 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5731 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5734 if(memberIt.memberAccess == privateAccess && member && member.memberAccess == publicAccess)
5740 if(member && (member.memberAccess == publicAccess || member._class.module == privateModule))
5742 if(member.isProperty)
5744 Property prop = (Property) member;
5745 if(!membersList.FindString(prop.name))
5747 DataRow row = membersList.AddString(prop.name);
5748 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5751 else if(member.name && !membersList.FindString(member.name))
5753 DataRow row = membersList.AddString(member.name);
5755 BitmapResource bitmap = null;
5756 if(!member.dataType)
5757 member.dataType = ProcessTypeString(member.dataTypeString, false);
5759 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5761 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5764 bitmap = { bitmapName };
5765 membersList.AddResource(bitmap);
5768 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5771 ListSubDataMembers(member, member.memberAccess == privateAccess);
5775 if(_class.inheritanceAccess == privateAccess)
5778 if(_class.module != privateModule) break;
5783 void ListClassMembersMatch(Class whatClass, Type methodType)
5786 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5787 bool isPrivate = false;
5789 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5795 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5797 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5799 if(method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5801 if(!method.dataType)
5802 method.dataType = ProcessTypeString(method.dataTypeString, false);
5804 if(MatchTypes(method.dataType, methodType, null, whatClass, /*null, */whatClass, false, true, false, false))
5806 DataRow row = membersList.FindString(method.name);
5809 row = membersList.AddString(method.name);
5810 row.icon = icons[(method.type == virtualMethod && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5816 if(_class.inheritanceAccess == privateAccess)
5819 if(_class.module != privateModule) break;
5824 void ListClassPropertiesAndVirtual(Class whatClass, String curString)
5827 bool isPrivate = false;
5828 for(_class = whatClass; _class /*&& _class.type != systemClass*/; _class = _class.base)
5834 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5836 if(method.type == virtualMethod)
5838 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5840 DataRow row = membersList.FindString(method.name);
5843 row = membersList.AddString(method.name);
5845 if(!method.dataType)
5846 method.dataType = ProcessTypeString(method.dataTypeString, false);
5848 row.icon = icons[method.dataType.thisClass ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5854 for(member = _class.membersAndProperties.first; member; member = member.next)
5856 if(member.memberAccess == publicAccess || member._class.module == privateModule)
5858 if(member.isProperty)
5860 Property prop = (Property)member;
5862 DataRow row = membersList.AddString(prop.name);
5863 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5866 else if(member.name && (!curString || strcmp(curString, member.name)))
5868 DataRow row = membersList.AddString(member.name);
5870 BitmapResource bitmap = null;
5871 if(!member.dataType)
5872 member.dataType = ProcessTypeString(member.dataTypeString, false);
5874 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5876 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5879 bitmap = { bitmapName };
5880 membersList.AddResource(bitmap);
5883 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5886 ListSubDataMembers(member, member.memberAccess == privateAccess || isPrivate);
5889 if(_class.inheritanceAccess == privateAccess)
5892 if(_class.module != privateModule) break;
5897 void ListMembers(Type type)
5899 if(type && (type.kind == classType || type.kind == structType || type.kind == unionType))
5903 if(type.kind == classType)
5906 ListClassMembers(type._class.registered, false);
5911 for(member = type.members.first; member; member = member.next)
5915 DataRow row = membersList.AddString(member.name);
5916 row.icon = icons[typeData];
5918 else if(member.kind == structType || member.kind == unionType)
5919 ListSubMembers(member);
5925 void ListModule(Module mainModule, int recurse, bool listClasses)
5928 ListNameSpace(mainModule.application.systemNameSpace, 1, listClasses);
5929 ListNameSpace(mainModule.application.privateNameSpace, 1, listClasses);
5930 ListNameSpace(mainModule.application.publicNameSpace, 1, listClasses);
5931 for(module = mainModule.application.allModules.first; module; module = module.next)
5933 if(ModuleVisibility(mainModule, module))
5934 ListNameSpace(module.publicNameSpace, recurse, listClasses);
5938 void ListNameSpace(NameSpace nameSpace, int recurse, bool listClasses)
5945 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5947 Class _class = link.data;
5948 if(_class.type != systemClass && !_class.templateClass) // Omit templatized classes
5950 DataRow row = membersList.AddString(_class.name);
5951 row.icon = (_class.type == unitClass || _class.type == enumClass) ? icons[typeDataType] : icons[typeClass];
5956 for(link = (BTNamedLink)nameSpace.defines.first; link; link = (BTNamedLink)((BTNode)link).next )
5958 DefinedExpression definedExp = link.data;
5959 DataRow row = membersList.AddString(link /*definedExp*/.name);
5960 row.icon = icons[typeData];
5963 for(link = (BTNamedLink)nameSpace.functions.first; link; link = (BTNamedLink)((BTNode)link).next)
5965 GlobalFunction function = link.data;
5966 DataRow row = membersList.AddString(link /*function*/.name);
5967 row.icon = icons[typeMethod];
5971 for(ns = (NameSpace *)nameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
5973 if(recurse != 2 && listClasses)
5975 if(!membersList.FindString(ns->name))
5977 DataRow row = membersList.AddString(ns->name);
5978 row.icon = icons[typeNameSpace];
5983 ListNameSpace(ns, 2, listClasses);
5987 void ListEnumValues(Class _class)
5989 List<Class> classes { };
5990 for(; _class && _class.type == enumClass; _class = _class.base)
5991 classes.Insert(null, _class);
5992 for(_class : classes)
5994 EnumClassData enumeration = (EnumClassData)_class.data;
5996 for(item = enumeration.values.first; item; item = item.next)
5998 DataRow row = membersList.AddString(item.name);
5999 row.icon = icons[typeEnumValue];
6005 bool ListEnumsModule(Module mainModule, Type dest)
6007 bool result = false;
6009 result |= ListEnums(mainModule.application.systemNameSpace, dest);
6010 result |= ListEnums(mainModule.application.privateNameSpace, dest);
6011 result |= ListEnums(mainModule.application.publicNameSpace, dest);
6012 for(module = mainModule.application.allModules.first; module; module = module.next)
6014 if(ModuleVisibility(mainModule, module))
6015 result |= ListEnums(module.publicNameSpace, dest);
6020 void ListNameSpaceByString(Module mainModule, char * string)
6022 NameSpace * nameSpace;
6024 nameSpace = FindNameSpace(mainModule.application.systemNameSpace, string);
6025 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6026 nameSpace = FindNameSpace(mainModule.application.privateNameSpace, string);
6027 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6028 nameSpace = FindNameSpace(mainModule.application.publicNameSpace, string);
6029 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6030 for(module = mainModule.application.allModules.first; module; module = module.next)
6032 if(ModuleVisibility(mainModule, module))
6034 nameSpace = FindNameSpace(module.publicNameSpace, string);
6035 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6040 bool ListEnums(NameSpace nameSpace, Type dest)
6043 bool result = false;
6045 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
6047 Class _class = link.data;
6048 if(_class.type == enumClass && (dest.kind != classType || ((!dest._class || !dest._class.registered || (dest._class.registered != _class && strcmp(dest._class.registered.dataTypeString, "char *"))) && !dest.classObjectType)) &&
6049 dest.kind != pointerType && dest.kind != ellipsisType)
6051 OldList conversions { };
6053 type.kind = classType;
6054 type._class = FindClass(_class.name);
6055 if(MatchTypes(type, dest, &conversions, null, null, true, false, false, false))
6057 ListEnumValues(_class);
6060 conversions.Free(null);
6064 for(nameSpace = (NameSpace *)nameSpace.nameSpaces.first; nameSpace != null; nameSpace = (NameSpace *)((BTNode)nameSpace).next)
6066 result |= ListEnums(nameSpace, dest);
6071 NameSpace * FindNameSpace(NameSpace nameSpace, char * name)
6075 for(c = 0; (ch = name[c]); c++)
6077 if(ch == '.' || (ch == ':' && name[c+1] == ':'))
6079 NameSpace * newSpace;
6080 char * spaceName = new char[c - start + 1];
6081 memcpy(spaceName, name + start, c - start);
6082 spaceName[c-start] = '\0';
6083 newSpace = (NameSpace *)nameSpace.nameSpaces.FindString(spaceName);
6087 nameSpace = newSpace;
6096 return (NameSpace *)nameSpace;
6099 void ListSymbols(Expression exp, bool enumOnly, char * string, Identifier realIdentifier)
6101 bool listedEnums = false;
6102 Type destType = (exp && exp.destType && !exp.destType.truth) ? exp.destType : null;
6103 bool listClasses = true;
6105 if(exp && (exp.type == identifierExp || exp.type == memberExp))
6107 // TOCHECK: This memberExp check wasn't here... Some stuff isn't quite done
6108 Identifier id = (exp.type == memberExp) ? exp.member.member : exp.identifier;
6109 char * colons = id ? RSearchString(id.string, "::", strlen(id.string), true, false) : null;
6111 if(exp.type == identifierExp)
6112 id = realIdentifier;
6114 if(id && id._class && !id._class.name)
6116 listClasses = false;
6119 else if(id && id._class && id._class.name)
6123 Class _class = id.classSym.registered;
6124 if(_class && _class.type == enumClass)
6126 ListEnumValues(_class);
6129 ListClassMembers(id.classSym.registered, true);
6134 else if(id && colons)
6136 ListNameSpaceByString(this.privateModule, id.string);
6141 if(this.privateModule && destType && (destType.kind != pointerType || destType.type.kind != voidType) && destType.kind != ellipsisType)
6143 listedEnums = ListEnumsModule(this.privateModule, destType);
6146 if(destType && destType.kind == classType && destType._class.registered && destType._class.registered.type == enumClass)
6148 ListEnumValues(destType._class.registered);
6151 ListClassPropertiesAndVirtual(insideClass, null);
6155 else if(destType && destType.kind == enumType)
6159 for(value = destType.members.first; value; value = value.next)
6161 DataRow row = membersList.AddString(value.name);
6162 row.icon = icons[typeEnumValue];
6166 ListClassPropertiesAndVirtual(insideClass, null);
6170 else if(insideClass && !enumOnly)
6172 ListClassPropertiesAndVirtual(insideClass, string);
6175 if(listedEnums && string && string[0])
6177 DataRow row = membersList.FindSubString(string);
6179 listedEnums = false;
6182 if(!insideClass && exp && exp.destType && exp.destType.kind == functionType && GetThisClass())
6184 ListClassMembersMatch(GetThisClass(), exp.destType);
6186 else if(!insideClass && !enumOnly && !listedEnums)
6189 Symbol symbol = null;
6193 ListClassMembers(GetThisClass(), false);
6196 for(ctx = listClasses ? GetCurrentContext() : GetTopContext(); ctx != GetTopContext().parent && !symbol; ctx = ctx.parent)
6198 for(symbol = (Symbol)ctx.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6200 // Don't list enum values?
6201 //if(symbol.type.kind != TypeEnum)
6202 DataRow row = membersList.FindString(symbol.string);
6205 if(GetBuildingEcereComModule() && symbol.type && symbol.type.kind == functionType && eSystem_FindFunction(privateModule, symbol.string))
6207 row = membersList.AddString(symbol.string);
6208 if(symbol.type && symbol.type.kind == functionType)
6209 row.icon = icons[typeMethod];
6210 else if(symbol.type && symbol.type.kind == enumType)
6212 row.icon = icons[typeEnumValue];
6216 BitmapResource bitmap = null;
6217 if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
6219 char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
6222 bitmap = { bitmapName };
6223 membersList.AddResource(bitmap);
6226 row.icon = bitmap ? bitmap : icons[typeData];
6233 for(symbol = (Symbol)ctx.types.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6235 DataRow row = membersList.FindString(symbol.string);
6238 row = membersList.AddString(symbol.string);
6239 if(symbol.type.kind == functionType)
6240 row.icon = icons[typeMethod];
6241 else if(symbol.type.kind == classType && (!symbol.type._class.registered || (symbol.type._class.registered.type != unitClass && symbol.type._class.registered.type != enumClass)))
6243 row.icon = icons[typeClass];
6247 row.icon = icons[typeDataType];
6254 ListModule(this.privateModule, 1, listClasses);
6255 // TODO: Implement this with name space
6259 for(data = globalData.first; data; data = data.next)
6261 DataRow row = membersList.FindString(data.name);
6263 data.dataType = ProcessTypeString(data.dataTypeString, false);
6266 row = membersList.AddString(data.name);
6268 if(data.dataType && data.dataType.kind == TypeEnum)
6270 row.icon = icons[typeEnumValue];
6274 BitmapResource bitmap = null;
6275 if(data.dataType && data.dataType.kind == classType && data.dataType._class && data.dataType._class)
6277 char * bitmapName = (char *)eClass_GetProperty(data.dataType._class.registered, "icon");
6280 bitmap = { bitmapName };
6281 membersList.AddResource(bitmap);
6284 row.icon = bitmap ? bitmap : icons[typeData];
6292 DataRow row = membersList.AddString("Min");
6293 row.icon = icons[typeMethod];
6295 row = membersList.AddString("Max");
6296 row.icon = icons[typeMethod];
6298 row = membersList.AddString("Abs");
6299 row.icon = icons[typeMethod];
6301 row = membersList.AddString("Sgn");
6302 row.icon = icons[typeMethod];
6308 void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
6310 EditBoxStream f { editBox = editBox };
6315 updatingCode = true;
6317 if(!method.dataType)
6318 method.dataType = ProcessTypeString(method.dataTypeString, false);
6320 DeleteJunkBefore(f, function.loc.start.pos, &position);
6321 f.DeleteBytes(function.loc.end.pos - function.loc.start.pos - 1);
6323 // ADDING METHOD HERE
6325 Type dataType = method.dataType;
6326 Type returnType = dataType.returnType;
6328 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
6334 if(extraIndent) f.Printf(" ");
6336 OutputType(f, returnType, false);
6340 if(dataType.thisClass && !dataType.classObjectType && (!isInstance || !insideClass || !eClass_IsDerived(insideClass, dataType.thisClass.registered)))
6342 if(dataType.thisClass.shortName)
6343 f.Printf(dataType.thisClass.shortName);
6345 f.Printf(dataType.thisClass.string);
6348 f.Printf(method.name);
6350 for(param = dataType.params.first; param; param = param.next)
6352 // Decided not to write void...
6353 if(param.kind != voidType)
6355 OutputType(f, param, true);
6361 if(extraIndent) f.Printf(" ");
6362 f.Printf(" %c\n", OpenBracket);
6364 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6370 (isInstance ? _class : _class.base)._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad] ||
6371 (isInstance ? _class : _class.base)._vTbl[method.vid] == DummyMethod)) // Temp Check for DefaultFunction
6373 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
6375 if(extraIndent) f.Printf(" ");
6376 f.Printf(" return true;\n");
6378 else if(returnType && returnType.kind != voidType)
6380 if(extraIndent) f.Printf(" ");
6381 f.Printf(" return 0;\n");
6386 if(extraIndent) f.Printf(" ");
6388 if(returnType.kind != voidType)
6389 f.Printf("return ");
6390 f.Printf("%s::%s(", isInstance ? _class.name : _class.base.name, method.name);
6391 for(param = dataType.params.first; param; param = param.next)
6393 if(param.prev) f.Printf(", ");
6394 if(param.kind != voidType)
6395 f.Printf(param.name);
6401 if(extraIndent) f.Printf(" ");
6402 f.Printf(" %c", CloseBracket);
6407 if(extraIndent) { x1 += 3; x2 += 3; }
6408 editBox.SetSelPos(l1, y1, x1 + 6, l2, y2, x2 + 6);
6410 this.updatingCode = false;
6414 // Return false if we overrided a function and don't want to run params listing
6415 bool InvokeAutoComplete(bool enumOnly, int pointer, bool caretMove)
6417 bool didOverride = false;
6418 EditLine line = editBox.line;
6419 char * text = line.text;
6420 int lineNum, charPos;
6421 Expression exp = null;
6424 //Identifier id = null;
6425 Expression memberExp = null;
6426 Identifier realIdentifier = null;
6428 if(!parsing) return true;
6429 if(!privateModule) return !didOverride;
6431 insideFunction = null;
6433 charPos = editBox.charPos + 1;
6434 if(!membersListShown)
6439 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6441 EditBoxStream f { editBox = editBox };
6443 updatingCode = true;
6444 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6448 if(!f.Seek(-1, current))
6451 if(!isspace(ch)) break;
6452 f.Seek(-1, current);
6454 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6456 lineNum = editBox.lineNumber + 1;
6457 charPos = editBox.charPos + 1;
6459 updatingCode = false;
6462 if(!membersListShown)
6464 memberExp = FindExpTree(ast, lineNum, charPos);
6465 if(memberExp && (memberExp.type == TypeKind::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6470 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6472 EditBoxStream f { editBox = editBox };
6475 updatingCode = true;
6477 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6480 if(ch == '}' || ch == ',' || ch == ')')
6482 f.Seek(-1, current);
6490 if(!f.Seek(-1, current))
6493 if(!isspace(ch)) break;
6494 f.Seek(-1, current);
6498 f.Seek(-1, current);
6500 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6502 lineNum = editBox.lineNumber + 1;
6503 charPos = editBox.charPos + 1;
6505 updatingCode = false;
6508 realIdentifier = FindCtxTree(ast, lineNum, charPos);
6513 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6514 lineNum = editBox.lineNumber + 1;
6515 charPos = editBox.charPos/* + 1*/;
6519 char tempString[1024];
6520 char * string = null;
6521 CodePosition idStart, idEnd;
6523 if(membersListShown)
6525 char * buffer = membersLine.text;
6527 bool firstChar = true;
6529 string = tempString;
6531 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
6533 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6534 if(!isSpace) firstChar = false;
6536 string[len++] = buffer[c];
6540 else //if(realIdentifier)//if(id)
6543 char * buffer = id.string;
6545 bool firstChar = true;
6547 string = tempString;
6548 for(c = 0; c<= charPos - id.loc.start.charPos; c++)
6550 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6551 if(!isSpace) firstChar = false;
6553 string[len++] = buffer[c];
6559 EditLine editLine = editBox.line;
6560 bool firstChar = true;
6563 string = tempString;
6564 for(y = lineNum-1; y >= 0; y--)
6566 char * buffer = editLine.text;
6567 int lineCount = editLine.count;
6568 for(x = (y == lineNum-1) ? (Min(charPos, lineCount) - 1 ): lineCount-1; x >= 0; x--)
6570 bool isSpace = (buffer[x] == ' ' || buffer[x] == '\t');
6575 idEnd.charPos = x + 2;
6580 // TESTING THIS CODE HERE FOR NOT CONSIDERING bool when doing ctrl-space past it
6583 idEnd.charPos = x + 2;
6590 if(!isalnum(buffer[x]) && buffer[x] != '_')
6596 memmove(string+1, string, len++);
6597 string[0] = buffer[x];
6601 //if(done || firstChar)
6602 if(done || !firstChar)
6604 editLine = editLine.prev;
6607 if(!strcmp(string, "case"))
6613 else if(!strcmp(string, "return"))
6619 else if(!strcmp(string, "delete"))
6625 else if(!strcmp(string, "new"))
6631 else if(!strcmp(string, "renew"))
6639 idStart.charPos = x + 1;
6640 idStart.line = y + 1;
6643 if(!membersListShown)
6645 membersList.Clear();
6646 if(memberExp && (memberExp.type == ExpressionType::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6648 Type type = memberExp.member.exp.expType;
6649 if(pointer == 2 && type)
6651 if(type.kind == pointerType || type.kind == arrayType)
6660 ListSymbols(exp, enumOnly, string, realIdentifier);
6662 membersList.Sort(null, 1);
6667 // Virtual function override
6668 Identifier id = GetDeclId(insideFunction.declarator);
6669 char * string = id ? id.string : null;
6671 Method method = eClass_FindMethod(GetThisClass(), string, this.privateModule);
6674 if(method.type != virtualMethod || (!insideInstance && method._class == GetThisClass()))
6675 insideFunction = null;
6678 OverrideVirtualFunction(insideFunction, method, GetThisClass(), insideInstance, insideInstance && insideClass);
6683 if(!didOverride) //insideFunction)
6685 rowCount = membersList.rowCount;
6688 DataRow row = string ? membersList.FindSubString(string) : null;
6689 if(row && !membersList.FindSubStringAfter(row, string) && !caretMove)
6691 char * newString = row.string;
6692 if(!membersListShown)
6694 membersLoc.start.line = idStart.line-1;
6695 membersLoc.start.charPos = idStart.charPos-1;
6696 //membersLoc.end = membersLoc.start;
6697 membersLoc.end.charPos = idEnd.charPos-1;
6698 membersLoc.end.line = idEnd.line-1;
6699 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6700 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6705 membersList.Destroy(0);
6706 membersListShown = false;
6709 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
6711 line, membersLoc.start.line, membersLoc.start.charPos,
6712 line, membersLoc.end.line, membersLoc.end.charPos);
6713 editBox.PutS(newString);
6719 row = membersList.FindSubStringi(string);
6721 membersList.currentRow = row;
6722 membersList.currentRow.selected = false;
6725 membersList.currentRow = row;
6727 if(!membersListShown)
6731 // TESTING THESE ADDITIONS TO THE IF SO THAT CARET ISNT MOVED IF NOT ON TOP OF A WORD
6732 if(string && string[0] && lineNum == idStart.line && charPos >= idStart.charPos-1 && charPos <= idEnd.charPos-1)
6733 editBox.SetSelPos(l1, y1, idStart.charPos-1, l2, y2, idStart.charPos-1);
6734 editBox.GetCaretPosition(caret);
6735 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6737 membersList.master = this;
6739 caret.y += editBox.GetCaretSize();
6741 membersList.Create();
6744 int x = caret.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6745 int y = caret.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6746 Window parent = membersList.parent;
6748 if(!paramsAbove && (paramsShown || y + membersList.size.h > parent.clientSize.h))
6750 y -= editBox.GetCaretSize() + membersList.size.h;
6751 membersAbove = true;
6754 membersAbove = false;
6756 membersList.position = { x, y };
6760 membersLoc.start.line = lineNum - 1;
6762 if(string && string[0])
6764 membersLoc.start.charPos = idStart.charPos-1;
6765 membersLoc.end = membersLoc.start;
6766 //membersLoc.end.charPos = id.loc.end.charPos-1;
6767 membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6771 membersLoc.start.charPos = charPos;
6772 membersLoc.end = membersLoc.start;
6773 membersLoc.end.charPos = charPos;
6775 membersListShown = true;
6777 // Hack to keep caret shown
6778 editBox.GetCaretPosition(caret);
6779 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6782 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
6788 SetCurrentContext(globalContext);
6791 return !didOverride;
6794 void InvokeParameters(bool exact, bool reposition, bool caretMove)
6796 EditLine line = editBox.line;
6797 char * text = line.text;
6798 int lineNum, charPos;
6799 Expression exp = null;
6803 if(!parsing) return;
6805 charPos = editBox.charPos + 1;
6808 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6810 EditBoxStream f { editBox = editBox };
6813 updatingCode = true;
6814 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6817 if(ch == '}' || ch == ',' || ch == ')')
6819 f.Seek(-1, current);
6827 if(!f.Seek(-1, current))
6830 if(!isspace(ch)) break;
6831 f.Seek(-1, current);
6835 f.Seek(-1, current);
6837 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6839 lineNum = editBox.lineNumber + 1;
6840 charPos = editBox.charPos + 1;
6842 updatingCode = false;
6845 charPos = Min(charPos, l1.count + 1);
6847 FindParamsTree(ast, lineNum, charPos);
6849 // Not sure about this == ExpCall... paramsInsideExp doesn't seem to necessarily be a ExpCall
6850 if(exact && ((::functionType && paramsInsideExp.type == callExp && paramsInsideExp.call.exp.loc.end.charPos != charPos-1) /*|| instanceType*/))
6852 ::functionType = null;
6853 ::instanceType = null;
6856 //if((::functionType || ::instanceType) && (!paramsShown || insideExp != functionExp || ::paramsID != this.paramsID))
6857 if((::functionType || ::instanceType) && (!paramsShown || true /*paramsInsideExp.destType != functionExp.destType */|| ::paramsID != this.paramsID))
6861 Window parent = paramsList.parent;
6863 if(this.functionType != ::functionType || this.instanceType != ::instanceType)
6866 if(!this.paramsShown || reposition || paramsInsideExp != functionExp || ::instanceType) // Added instanceType here, otherwise instance popups never reposition...
6867 // ( Dummy exp: always ends up with same memory)
6869 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6870 editBox.GetCaretPosition(paramsPosition);
6871 this.paramsPosition.y += editBox.GetCaretSize();
6874 FreeType(this.functionType);
6875 FreeType(this.instanceType);
6877 this.functionType = ::functionType;
6878 this.instanceType = ::instanceType;
6880 if(this.functionType) this.functionType.refCount++;
6881 if(this.instanceType) this.instanceType.refCount++;
6883 this.paramsID = ::paramsID;
6884 functionExp = paramsInsideExp;
6886 paramsList.master = this;
6888 paramsList.Create();
6890 x = paramsPosition.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6891 y = paramsPosition.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6893 if(!this.membersAbove && ( this.membersListShown || y + paramsList.size.h > parent.clientSize.h) )
6895 y -= editBox.GetCaretSize() + paramsList.clientSize.h;
6899 paramsAbove = false;
6900 if(x + paramsList.size.w > parent.clientSize.w)
6902 x = parent.clientSize.w - paramsList.size.w;
6906 paramsList.position = { x, y };
6908 // Hack to keep caret shown
6911 editBox.GetCaretPosition(caret);
6912 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6915 this.paramsShown = true;
6917 else if((!::functionType && !::instanceType) || reposition)
6919 paramsList.Destroy(0);
6920 paramsShown = false;
6922 FreeType(this.functionType);
6923 FreeType(this.instanceType);
6924 this.functionType = null;
6925 this.instanceType = null;
6929 SetCurrentContext(globalContext);
6937 designer.visible = true;
6938 designer.Activate();
6944 CodeEditor NewCodeEditor(Window parent, WindowState state, bool modified)
6946 CodeEditor document { state = state, parent = parent, modifiedDocument = modified };
6951 static int nofdigits(int v)
6953 if(v == MININT) return 10 + 1;
6954 if(v < 0) return nofdigits(-v) + 1;