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 // Temporary work around until we standardize how properties should manage memory
448 if(!strcmp(prop.name, "strings") && !strcmp(prop._class.name, "DirectoriesBox"))
449 freeDataForm = freeDataTest = true;
450 if(dataType.type == normalClass && dataType.structSize)
452 if(freeDataForm) eInstance_Delete(dataForm);
453 if(freeDataTest) eInstance_Delete(dataTest);
457 if(freeDataForm) delete dataForm;
458 if(freeDataTest) delete dataTest;
461 else if(dataType && dataType._vTbl)
463 DataValue dataForm, dataTest;
465 GetProperty(prop, selected.instance, &dataForm);
466 GetProperty(prop, test, &dataTest);
468 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
470 SetProperty(prop, test, dataForm);
472 // In case setting on test unset on real instance (e.g. isDefault)
473 if(strcmp(prop.name, "name"))
475 GetProperty(prop, selected.instance, &dataTest);
476 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
477 SetProperty(prop, selected.instance, dataForm);
486 bool Code_IsPropertyDisabled(ObjectInfo selected, char * name)
488 bool disabled = false;
489 if(selected.oClass == selected)
492 if(selected.classDefinition)
494 for(def = selected.classDefinition.definitions->first; def; def = def.next)
496 if(def.type == defaultPropertiesClassDef)
499 for(prop = def.defProperties->first; prop; prop = prop.next)
501 if(prop.identifiers && prop.identifiers->first)
503 Identifier id = prop.identifiers->first;
504 if(prop.variable && !strcmp(id.string, name))
516 else if(selected.instCode)
519 if(selected.instCode.members)
521 for(members = selected.instCode.members->first; members; members = members.next)
523 if(members.type == dataMembersInit && members.dataMembers)
526 for(prop = members.dataMembers->first; prop; prop = prop.next)
528 if(prop.identifiers && prop.identifiers->first)
530 Identifier id = prop.identifiers->first;
531 if(prop.variable && !strcmp(id.string, name))
546 static bool CheckCompatibleMethod(Method method, Type type, Class regClass, bool isForm, Symbol selectedClass)
551 method.dataType = ProcessTypeString(method.dataTypeString, false);
552 if(!method.dataType.thisClass && !isForm)
555 method.dataType.thisClass = selectedClass;
557 //result = MatchTypes(method.dataType, type, null, regClass, regClass, false);
558 result = MatchTypes(type, method.dataType, null, regClass, regClass, false, true, true, false);
560 method.dataType.thisClass = null;
564 bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo object)
566 bool confirmation = true;
567 Statement body = function.body;
568 // Check if it contains any code
569 if((!body.compound.declarations || !body.compound.declarations->count) && (!body.compound.statements || body.compound.statements->count <= 1))
571 Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
572 Statement stmt = body.compound.statements ? body.compound.statements->first : null;
573 Type dataType = method.dataType;
574 Type returnType = dataType.returnType;
575 Expression exp = null;
578 method.dataType = ProcessTypeString(method.dataTypeString, false);
580 confirmation = false;
582 // Check if default function should be calling base class:
583 if(object.instance._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
585 if(returnType.kind != voidType)
587 if(!stmt || stmt.type != returnStmt || !stmt.expressions || stmt.expressions->count != 1)
591 exp = stmt.expressions->first;
592 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
594 if( (exp.type != identifierExp || strcmp(exp.identifier.string, "true")) &&
595 (exp.type != constantExp || strcmp(exp.constant, "1")))
600 if(exp.type != constantExp || strcmp(exp.constant, "0"))
615 if(returnType.kind != voidType)
617 if(stmt.type == returnStmt && stmt.expressions && stmt.expressions->count == 1)
618 exp = stmt.expressions->first;
620 else if(stmt.type == expressionStmt && stmt.expressions && stmt.expressions->count == 1)
621 exp = stmt.expressions->first;
624 if(!exp || exp.type != callExp || exp.call.exp.type != identifierExp)
628 Identifier id = exp.call.exp.identifier;
629 Class base = object.instance._class;
630 if(!id._class || (id._class.name && !strcmp(id._class.name, base.name)) || strcmp(id.string, method.name))
634 Expression arg = exp.call.arguments ? exp.call.arguments->first : null;
635 if(!arg || arg.type != identifierExp || strcmp("this", arg.identifier.string))
641 for(param = dataType.params.first; param; param = param.next)
643 if(!arg || arg.type != identifierExp || strcmp(param.name, arg.identifier.string))
648 arg = arg ?arg.next : null;
655 return !confirmation;
658 class CodeEditor : Window
660 background = marginColor;
661 borderStyle = sizableDeep;
666 isActiveClient = true;
667 anchor = Anchor { left = 300, right = 150, top = 0, bottom = 0 };
670 // eWindow_SetX(A_CASCADE); eWindow_SetY(A_CASCADE);
671 // eWindow_SetWidth(A_RELATIVE|80); eWindow_SetHeight(A_RELATIVE|80);
673 SheetType sheetSelected;
678 Context globalContext { };
679 OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
692 MethodAction methodAction;
694 ClassFunction function;
696 char methodName[1024];
701 bool membersListShown;
704 EditLine membersLine;
706 Type functionType, instanceType;
710 Point paramsPosition;
711 Expression functionExp;
714 BitmapResource icons[CodeObjectType];
716 FontResource boldFont { $"Tahoma", 8.25f, bold = true, window = this };
717 FontResource normalFont { $"Tahoma", 8.25f, window = this };
719 Module privateModule;
720 NameSpace globalData;
723 OpenedFileInfo openedFileInfo;
725 FontResource font { codeFont.faceName, codeFont.size };
726 saveDialog = codeEditorFileDialog;
728 Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
731 int maxLineNumberLength;
733 property bool parsing { get { return editBox.syntaxHighlighting && !noParsing && !ide.noParsing; } };
735 void ProcessCaretMove(EditBox editBox, int line, int charPos)
738 ObjectInfo classItem;
740 // OnActivateClient is called after OnActivate
743 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
746 if(sheet.codeEditor != this) return;
750 for(classItem = classes.first; classItem; classItem = classItem.next)
752 ClassDefinition classDef = classItem.classDefinition;
753 if(classDef && classDef.loc.Inside(line, charPos))
760 for(object = classItem.instances.first; object; object = object.next)
764 if(object.instCode.loc.Inside(line, charPos))
769 sheet.SelectObject(object);
771 sheet.SelectObject(classItem);
776 //sheet.SelectObject(null);
780 sprintf(temp, $"Ln %d, Col %d", line, editBox.column + 1);
784 expectingMove = false;
790 if(line-1 != membersLoc.start.line)
794 char * buffer = membersLine.text;
797 if(charPos - 1 < membersLoc.start.charPos)
799 else if(charPos - 1 > membersLoc.end.charPos)
801 char * buffer = membersLine.text;
802 //if(membersList.currentRow)
806 for(c = membersLoc.start.charPos; c<=charPos && buffer[c]; c++)
807 if(buffer[c] != ' ' && buffer[c] != '\t')
809 if(c < charPos && buffer[c])
816 membersList.Destroy(0);
817 membersListShown = false;
821 bool back = codeModified;
822 codeModified = false;
824 InvokeParameters(false, false, false);
825 /*if(membersListShown)
826 InvokeAutoComplete(false, 0, true);*/
833 watch(modifiedDocument)
835 ProjectView projectView = ide.projectView;
838 char buffer[MAX_LOCATION];
839 char * fullPath = GetSlashPathBuffer(buffer, fileName);
840 Array<ProjectNode> nodes = ide.workspace.GetAllProjectNodes(fullPath, false);
844 node.modified = modifiedDocument;
845 projectView.Update(null);
854 textVertScroll = true, multiLine = true, /*lineNumbers = ideSettings.showLineNumbers,*/
855 freeCaret = ideSettings.useFreeCaret, caretFollowsScrolling = ideSettings.caretFollowsScrolling,
856 tabKey = true, smartHome = true;
857 tabSelection = true, /*maxLineSize = 65536, */parent = this, hasHorzScroll = true, hasVertScroll = true;
858 selectionColor = selectionColor, selectionText = selectionText,
859 background = codeEditorBG, foreground = codeEditorFG, syntaxColorScheme = colorScheme,
860 font = font, borderStyle = none;
861 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
863 bool OnMouseOver(int x, int y, Modifiers mods)
865 CodeEditor editor = (CodeEditor)master;
866 if(editor.designer && editor.designer.isDragging && !mods.isSideEffect)
871 void NotifyCaretMove(EditBox editBox, int line, int charPos)
873 // Update Line Numbers
875 int oldLine = lastLine;
876 display.FontExtent(font.font, " ", 1, null, &spaceH);
878 Box box { 0, (Min(oldLine,oldLine)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(oldLine, oldLine))*spaceH-1 - editBox.scroll.y };
882 Box box { 0, (Min(line,line)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(line, line))*spaceH-1 - editBox.scroll.y };
887 if(ide.activeClient == this)
888 ProcessCaretMove(editBox, line, charPos);
890 openedFileInfo.CaretMove(line, charPos);
893 void NotifyOvrToggle(EditBox editBox, bool overwrite)
895 ide.UpdateStateLight(ide.ovr, overwrite);
898 void NotifyUpdate(EditBox editBox)
905 designer.modifiedDocument = true;
908 modifiedDocument = true;
911 bool NotifyUnsetModified(EditBox editBox)
913 modifiedDocument = false;
917 bool NotifyCharsAdded(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
919 if(!loadingFile && after.y != before.y)
921 ProjectView projectView = ide.projectView;
922 if(projectView && fileName)
925 // HOW WE MIGHT WANT TO DO IT:
926 char * text = before.line.text;
927 for(c = Min(before.line.count, before.x-1); c>= 0; c--)
928 if(!isspace(text[c]))
930 ide.debugger.MoveIcons(fileName, before.y + (((!pasteOperation && c > -1) || !after.line.count) ? 1 : 0), after.y - before.y, false);
932 // HOW VISUAL STUDIO DOES IT:
934 char * text = after.line.text;
935 for(c = after.line.count-1; c>= 0; c--)
936 if(!isspace(text[c]))
938 ide.debugger.MoveIcons(fileName, before.y + ((c < 0) ? 1 : 0), after.y - before.y, false);
941 Update({ 0, 0, editBox.position.x, clientSize.h });
949 for(oClass = classes.first; oClass; oClass = oClass.next)
952 for(object = oClass.instances.first; object; object = object.next)
956 object.instCode.loc.start.AdjustAdd(before, after);
957 object.instCode.loc.end.AdjustAdd(before, after);
962 oClass.classDefinition.loc.start.AdjustAdd(before, after);
963 oClass.classDefinition.loc.end.AdjustAdd(before, after);
969 expectingMove = true;
973 if(before.y != after.y)
977 char * buffer = membersLine.text;
979 bool firstChar = true;
980 bool addedChar = false;
986 membersLoc.end.charPos += after.x - Max(membersLoc.start.charPos, before.x);
988 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
990 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
991 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar)) //|| membersList.currentRow
1000 membersLoc.start.charPos++;
1005 string[len++] = buffer[c];
1009 row = membersList.currentRow;
1010 if(row && row.selected)
1014 membersLoc.start.charPos--;
1022 row = membersList.FindSubString(string);
1024 membersList.currentRow = row;
1027 row = membersList.FindSubStringi(string);
1029 membersList.currentRow = row;
1030 membersList.currentRow.selected = false;
1033 membersList.SetScrollPosition(0, (row.index) * membersList.rowHeight);
1037 row = membersList.currentRow;
1040 // Accept current string if hiding typing char
1041 if(hide && row && row.selected)
1043 char * string = row.string;
1044 int len = strlen(string);
1045 membersLoc.end.charPos -= after.x - before.x;
1046 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1047 editBox.Delete(membersLine, membersLoc.start.line, membersLoc.start.charPos,
1048 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1049 editBox.PutS(string);
1050 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos + len + 1 /*after.x - before.x*/);
1052 after.x += membersLoc.start.charPos + len - before.x;
1053 before.x = membersLoc.start.charPos + len;
1058 membersList.Destroy(0);
1059 membersListShown = false;
1062 if(/*after.x - before.x == 1 && */after.y == before.y && !membersListShown)
1064 EditLine line = editBox.line;
1065 char * text = line.text;
1066 char ch = text[after.x-1];
1067 if(ch == '.' || (ch == '>' && after.x-1 > 0 && text[after.x-1-1] == '-') || (ch == ':' && after.x-1 > 0 && text[after.x-1-1] == ':'))
1071 // Can we call invoke auto complete here instead?
1081 // Force caret update already...
1082 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1083 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1085 editBox.GetCaretPosition(&caret);
1089 // Go back in the buffer until no space before
1091 codeModified = true;
1095 EditBoxStream f { editBox = editBox };
1099 if(text[after.x-1] == '>')
1105 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
1109 if(!f.Seek(-1, current))
1112 if(!isspace(ch)) break;
1113 f.Seek(-1, current);
1115 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
1117 line = editBox.lineNumber + 1;
1118 charPos = editBox.charPos + 1;
1122 exp = FindExpTree(ast, line, charPos);
1126 Type type = exp.expType;
1128 if(type && text[after.x-1] != '.')
1130 if(type.kind == TypePointer || type.kind == TypeArray)
1136 membersList.Clear();
1139 if(membersList.rowCount)
1141 membersList.Sort(null, 1);
1142 membersList.master = this;
1144 caret.y += editBox.GetCaretSize();
1147 membersList.Create();
1150 int x = caret.x + editBox.GetAbsX() - app.desktop.GetAbsX() - editBox.GetScrollX();
1151 int y = caret.y + editBox.GetAbsY() - app.desktop.GetAbsY() - editBox.GetScrollY();
1152 Window parent = membersList.parent;
1154 if(!paramsAbove && (paramsShown || y + membersList.GetHeight() > parent.GetClientHeight()))
1156 y -= editBox.GetCaretSize() + membersList.GetHeight();
1157 membersAbove = true;
1160 membersAbove = false;
1162 membersList.position = { x, y };
1166 membersLoc.start.line = line - 1;
1167 membersLoc.start.charPos = oldCharPos;
1168 membersLoc.end = membersLoc.start;
1169 membersListShown = true;
1174 SetCurrentContext(globalContext);
1176 codeModified = true;
1177 skipModified = true;
1178 if(text[after.x-1] == ':')
1179 InvokeAutoComplete(false, 0, false);
1180 else if(text[after.x-1] == '.')
1181 InvokeAutoComplete(false, 1, false);
1182 else if(text[after.x-1] == '>')
1183 InvokeAutoComplete(false, 2, false);
1184 skipModified = false;
1186 else if(ch == '(' || ch == OpenBracket || ch == ',' || ch == '=' || ch == '?' || ch == ':')
1188 codeModified = true;
1189 skipModified = true;
1191 if(InvokeAutoComplete(true, 0, false))
1193 if(ch == '(' || ch == OpenBracket)
1194 InvokeParameters(true, true, false);
1196 InvokeParameters(this.functionType ? false : true, false, false);
1199 // InvokeAutoComplete(true, 0, false);
1200 skipModified = false;
1202 else if(ch == ')' || ch == '}' || ch == ';')
1204 codeModified = true;
1205 skipModified = true;
1207 InvokeParameters(false, true, false);
1208 skipModified = false;
1212 bool back = codeModified;
1213 codeModified = false;
1215 InvokeParameters(false, false, true);
1216 if(membersListShown)
1217 InvokeAutoComplete(false, 0, true);
1218 codeModified = back;
1223 bool back = codeModified;
1224 codeModified = false;
1227 InvokeParameters(false, false, true);
1228 /*if(membersListShown)
1229 InvokeAutoComplete(false, 0, true);*/
1231 codeModified = back;
1238 bool NotifyCharsDeleted(EditBox editBox, BufferLocation before, BufferLocation after, bool pasteOperation)
1240 if(!loadingFile && after.y != before.y)
1242 ProjectView projectView = ide.projectView;
1243 if(projectView && fileName)
1244 ide.debugger.MoveIcons(fileName, before.y + 1, before.y - after.y, before.x == 0);
1245 Update({ 0, 0, editBox.position.x, clientSize.h });
1253 for(oClass = classes.first; oClass; oClass = oClass.next)
1257 for(object = oClass.instances.first; object; object = object.next)
1261 loc = &object.instCode.loc;
1263 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1264 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1266 object.instCode = null;
1270 loc->start.AdjustDelete(before, after);
1271 loc->end.AdjustDelete(before, after);
1275 if(oClass.classDefinition)
1277 loc = &oClass.classDefinition.loc;
1278 if((before.y+1 < loc->start.line || (before.y+1 == loc->start.line && before.x+1 <= loc->start.charPos)) &&
1279 (after.y+1 > loc->end.line || (after.y+1 == loc->end.line && after.x+1 >= loc->end.charPos)))
1281 oClass.classDefinition = null;
1285 loc->start.AdjustDelete(before, after);
1286 loc->end.AdjustDelete(before, after);
1291 if(membersListShown)
1294 if(pasteOperation || before.y != after.y)
1298 char * buffer = membersLine.text;
1300 bool firstChar = true;
1304 if(before.x >= membersLoc.start.charPos)
1306 for(c = membersLoc.start.charPos; c<before.x && len < sizeof(string)-1; c++)
1308 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1309 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1314 if(!isSpace) firstChar = false;
1317 string[len++] = buffer[c];
1322 // If deleting spaces before...
1323 for(c = before.x; c<membersLoc.start.charPos; c++)
1325 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1333 membersLoc.start.charPos = before.x;
1336 if(membersLoc.end.charPos >= after.x)
1338 for(c = after.x; c<membersLoc.end.charPos && len < sizeof(string)-1; c++)
1340 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
1341 if(!isalnum(buffer[c]) && buffer[c] != '_' && (!isSpace || !firstChar))
1346 if(!isSpace) firstChar = false;
1349 string[len++] = buffer[c];
1357 membersLoc.end.charPos -= after.x - before.x;
1361 row = membersList.FindSubString(string);
1364 row = membersList.FindSubStringi(string);
1366 membersList.currentRow = row;
1367 membersList.currentRow.selected = false;
1370 membersList.currentRow = row;
1372 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
1377 membersList.Destroy(0);
1378 membersListShown = false;
1384 InvokeParameters(false, false);
1392 bool NotifyDropped(EditBox editBox, int x, int y)
1394 char * controlClass = toolBox.controlClass;
1395 if(controlClass && controlClass[0])
1399 ObjectInfo classObject;
1401 editBox.GoToLineNum(y);
1402 x = Min(x, editBox.line.count);
1403 editBox.GoToPosition(editBox.line, y, x);
1404 // Note: Uncommented this to drag objects after the member instance on which they are dropped
1405 editBox.NotifyCaretMove(this, editBox, y+1, x+1);
1407 classObject = selected ? selected.oClass : null;
1409 if((!selected || selected == classObject) && classObject && classObject.instances.first)
1410 selected = classObject.instances.last;
1413 control = eInstance_New(eSystem_FindClass(privateModule, controlClass));
1416 AddObject(control, &object);
1418 designer.CreateObject(control, object, false, classObject.instance);
1419 // designer.PostCreateObject(control, object, false, classObject.instance);
1420 designer.DroppedObject(control, object, false, classObject.instance);
1422 sheet.AddObject(object, object.name, typeData /* className*/, true);
1425 //codeModified = true;
1432 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
1434 if(key == ctrlSpace)
1436 membersList.Destroy(0);
1437 membersListShown = false;
1438 InvokeAutoComplete(false, 0, false);
1441 else if(key == Key { space, ctrl = true, shift = true })
1442 InvokeParameters(false, true, false);
1443 else if(key == escape)
1444 ide.RepositionWindows(true);
1445 else if(key == ctrlF7)
1449 ProjectNode node = ide.projectView.GetNodeForCompilationFromWindow(this, false, null, null);
1453 s = PrintString($"The ", fileName, $" file is not part of any project.\n",
1454 $"It can't be compiled.");
1455 MessageBox { type = ok, /*parent = ide, */master = ide, text = $"File not in project error", contents = s }.Modal();
1464 bool OnKeyDown(Key key, unichar ch)
1466 CodeEditor editor = (CodeEditor)master;
1467 if(key == escape /*|| key == leftAlt || key == rightAlt || (key.ctrl && key.code != left && key.code != right && key.code != leftShift && key.code != rightShift && key.code != space)*/)
1469 if(editor.membersListShown)
1471 editor.membersList.Destroy(0);
1472 editor.membersListShown = false;
1475 if(editor.paramsShown)
1477 editor.paramsList.Destroy(0);
1478 editor.paramsShown = false;
1479 FreeType(editor.functionType);
1480 FreeType(editor.instanceType);
1482 editor.functionType = null;
1483 editor.instanceType = null;
1484 editor.paramsID = -1;
1488 return EditBox::OnKeyDown(key, ch);
1491 void OnVScroll(ScrollBarAction action, int position, Key key)
1493 if(anchor.left.distance)
1495 Box box { 0, 0, anchor.left.distance-1, parent.clientSize.h - 1 };
1498 EditBox::OnVScroll(action, position, key);
1500 CodeEditor ce = (CodeEditor)parent;
1501 if(ce.openedFileInfo)
1502 ce.openedFileInfo.ScrollChange({ scroll.x, position });
1506 void OnHScroll(ScrollBarAction action, int position, Key key)
1508 EditBox::OnHScroll(action, position, key);
1510 CodeEditor ce = (CodeEditor)parent;
1511 if(ce.openedFileInfo)
1512 ce.openedFileInfo.ScrollChange({ position, scroll.y });
1519 fullRowSelect = false,
1522 borderStyle = bevel;
1523 // size = { 200, 400 };
1525 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
1527 DataRow row = listBox.currentRow;
1530 char * string = row.string;
1532 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
1534 membersLine, membersLoc.start.line, membersLoc.start.charPos,
1535 membersLine, membersLoc.end.line, membersLoc.end.charPos);
1536 editBox.PutS(string);
1539 membersListShown = false;
1544 bool OnKeyDown(Key key, unichar ch)
1546 CodeEditor editor = (CodeEditor) master;
1547 if(key == escape || key == leftAlt || key == rightAlt ||
1548 (key.ctrl && key.code != left && key.code != right &&
1549 key.code != leftShift && key.code != rightShift && key.code != space))
1552 if(editor.paramsShown)
1556 editor.paramsList.Destroy(0);
1557 editor.paramsShown = false;
1559 if(editor.membersListShown)
1563 editor.membersList.Destroy(0);
1564 editor.membersListShown = false;
1567 FreeType(editor.functionType);
1568 editor.functionType = null;
1570 FreeType(editor.instanceType);
1571 editor.instanceType = null;
1573 editor.paramsID = -1;
1578 return editor.editBox.OnKeyDown(key, ch);
1582 /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1584 CodeEditor editor = (CodeEditor)master;
1585 Window rw = previous ? previous.rootWindow : null;
1586 if(!active && rw != editor.paramsList)
1589 editor.membersListShown = false;
1591 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
1594 bool OnKeyHit(Key key, unichar ch)
1596 CodeEditor editor = (CodeEditor) master;
1600 case enter: case tab:
1602 DataRow row = currentRow;
1603 if(row && row.selected)
1605 char * string = row.string;
1607 editor.editBox.GoToPosition(editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos);
1608 editor.editBox.Delete(
1609 editor.membersLine, editor.membersLoc.start.line, editor.membersLoc.start.charPos,
1610 editor.membersLine, editor.membersLoc.end.line, editor.membersLoc.end.charPos);
1611 editor.editBox.PutS(string);
1614 editor.membersListShown = false;
1617 editor.editBox.OnKeyHit(key, ch);
1627 return ListBox::OnKeyHit(key, ch);
1633 // If before . or after
1634 //listBox.Destroy(true);
1635 result = editor.editBox.OnKeyHit(key, ch);
1650 clickThrough = true,
1652 borderStyle = contour,
1654 background = { 255,255,225 },
1656 OnKeyDown = membersList.OnKeyDown;
1658 /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1660 CodeEditor editor = (CodeEditor)master;
1661 Window rw = previous ? previous.rootWindow : null;
1662 if(!active && previous != editor.editBox && rw != editor.membersList)
1665 editor.paramsShown = false;
1667 return Window::OnActivate(active, previous, goOnWithActivation, direct);
1670 bool OnKeyHit(Key key, unichar ch)
1672 CodeEditor editor = (CodeEditor)master;
1674 if(!editor.membersListShown || editor.membersList.OnKeyHit(key, ch))
1677 bool result = true; editor.editBox.OnKeyHit(key, ch);
1678 return (!created) ? false : result;
1685 void OnRedraw(Surface surface)
1687 CodeEditor editor = (CodeEditor) master;
1688 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1690 Type methodType = null;
1694 int functionW, nameW = 0;
1696 int spaceW, spaceH, commaW, commaWB, parW;
1698 int maxW = 0, lineW = 0;
1704 Font font = editor.normalFont.font;
1705 Font boldFont = editor.boldFont.font;
1706 Display display = this.display;
1708 if(!type) { return; };
1710 if(type.kind == TypeKind::methodType) { methodType = type; type = type.method.dataType; }
1712 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1713 display.FontExtent(font, ", ", 2, &commaW, null);
1714 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1715 display.FontExtent(font, ")", 1, &parW, null);
1718 if(editor.functionType)
1720 PrintType(type.returnType, string, true, true);
1721 display.FontExtent(font, string, strlen(string), &functionW, null);
1723 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1724 totalW = nameW + functionW + 2 * parW;
1728 PrintType(type, string, (type.kind == functionType) ? true : false, true); // true);
1729 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1730 if(instanceName && type.kind != functionType)
1731 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1732 totalW = functionW + nameW;
1733 surface.TextFont(boldFont);
1736 surface.WriteText(x, y, string, strlen(string));
1737 x += functionW + spaceW;
1739 if(editor.functionType)
1742 surface.WriteText(x, y, type.name, strlen(type.name));
1744 surface.WriteText(x, y, "(", 1);
1747 if(methodType && !methodType.staticMethod && methodType.methodClass)
1751 if(id == editor.paramsID)
1752 surface.TextFont(boldFont);
1754 if(methodType.methodClass)
1755 surface.TextExtent(methodType.methodClass.name, strlen(methodType.methodClass.name), &tw, null);
1759 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1760 width += ((id == editor.paramsID) ? commaWB : commaW);
1765 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1770 x = 2 + nameW + spaceW + functionW + parW;
1774 if(methodType.methodClass)
1775 surface.WriteText(x, y, methodType.methodClass.name, strlen(methodType.methodClass.name));
1778 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1780 surface.WriteText(x, y, ",", 1);
1781 x += ((id == editor.paramsID) ? commaWB : commaW);
1789 if(id == editor.paramsID)
1790 surface.TextFont(font);
1794 if(!methodType || (methodType.staticMethod || !methodType.methodClass) || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1796 for(param = type.params.first; param; param = param.next)
1798 char paramString[1024];
1801 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1802 surface.TextFont(boldFont);
1805 PrintType(param, paramString, true, true);
1806 surface.TextExtent(paramString, strlen(paramString), &tw, null);
1808 if(param.next) width += ((id == editor.paramsID) ? commaWB : commaW);
1813 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1818 x = 2 + nameW + spaceW + functionW + parW;
1822 surface.WriteText(x, y, paramString, strlen(paramString));
1826 surface.WriteText(x, y, ",", 1);
1827 x += ((id == editor.paramsID) ? commaWB : commaW);
1835 if(id == editor.paramsID || (param.kind == ellipsisType && id < editor.paramsID && editor.paramsID != -1))
1836 surface.TextFont(font);
1841 surface.WriteText(x, y, ")", 1);
1843 else if(instanceName && type.kind != functionType)
1845 surface.WriteText(x, y, instanceName, strlen(instanceName));
1849 bool OnResizing(int * w, int * h)
1851 CodeEditor editor = (CodeEditor) master;
1852 Type type = editor.functionType ? editor.functionType : editor.instanceType;
1854 Type methodType = null;
1858 int functionW = 0, nameW = 0;
1860 int spaceW, spaceH, commaW, commaWB, parW;
1862 int maxW = 0, lineW = 0;
1867 Font font = editor.normalFont.font;
1868 Font boldFont = editor.boldFont.font;
1869 Display display = this.display;
1871 if(type.kind == TypeKind::methodType)
1874 ProcessMethodType(type.method);
1875 type = type.method.dataType;
1878 display.FontExtent(boldFont, " ", 1, &spaceW, &spaceH);
1879 display.FontExtent(font, ", ", 2, &commaW, null);
1880 display.FontExtent(boldFont, ", ", 2, &commaWB, null);
1881 display.FontExtent(font, ")", 1, &parW, null);
1884 if(editor.functionType && type)
1886 PrintType(type.returnType, string, true, true);
1887 display.FontExtent(font, string, strlen(string), &functionW, null);
1889 display.FontExtent(font, type.name, strlen(type.name), &nameW, null);
1890 totalW = nameW + spaceW + functionW + 2 * parW;
1894 PrintType(type, string, false, true); // /*true);
1895 display.FontExtent(boldFont, string, strlen(string), &functionW, null);
1896 if(instanceName && type.kind != functionType)
1897 display.FontExtent(boldFont, instanceName, strlen(instanceName), &nameW, null);
1898 totalW = functionW + nameW + spaceW;
1901 if(editor.functionType)
1907 if(methodType.methodClass)
1908 display.FontExtent((id == editor.paramsID) ? boldFont : font, methodType.methodClass.name, strlen(methodType.methodClass.name), &width, null);
1909 if(type.params.first && (((Type)type.params.first).kind != voidType || type.params.count > 1))
1910 width += ((id == editor.paramsID) ? commaWB : commaW);
1915 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1928 if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
1930 for(param = type.params.first; param; param = param.next)
1932 char paramString[1024];
1936 PrintType(param, paramString, true, true);
1937 display.FontExtent((id == editor.paramsID || param.kind == ellipsisType) ? boldFont : font, paramString, strlen(paramString), &width, null);
1939 width += ((id == editor.paramsID) ? commaWB : commaW);
1944 if(lineW && ((height && lineW + width > maxW) || (totalW + lineW + width + 20 > availW)))
1961 *w = realW + totalW + 4;
1967 Menu fileMenu { menu, $"File", f };
1968 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
1969 MenuItem { fileMenu, $"Save As...", a, NotifySelect = MenuFileSaveAs };
1971 Menu editMenu { menu, $"Edit", e };
1972 MenuDivider { editMenu };
1973 MenuItem clearTrailingSpacesItem
1975 editMenu, $"Clear trailing spaces", t, Key { t, ctrl = true, shift = true };
1977 bool NotifySelect(MenuItem selection, Modifiers mods)
1979 // Nuke trailing spaces
1982 editBox.recordUndoEvent = true;
1983 for(line = editBox.firstLine; line; line = line.next, y++)
1985 String buffer = line.text;
1986 int count = line.count, i = count-1;
1987 while(i >= 0 && isspace(buffer[i])) i--;
1989 editBox.Delete(line, y, i + 1, line, y, count);
1991 editBox.recordUndoEvent = false;
1996 Menu debugMenu { menu, $"Debug", d };
1997 MenuItem debugRunToCursor { debugMenu, $"Run To Cursor", c, ctrlF10, id = RTCMenuBits { false, false, false }, NotifySelect = RTCMenu_NotifySelect; };
1998 MenuItem debugSkipRunToCursor { debugMenu, $"Run To Cursor Skipping Breakpoints", u, Key { f10, ctrl = true, shift = true }, id = RTCMenuBits { true, false, false }, NotifySelect = RTCMenu_NotifySelect; };
1999 MenuItem debugRunToCursorAtSameLevel { debugMenu, $"Run To Cursor At Same Level", l, altF10, id = RTCMenuBits { false, true, false }, NotifySelect = RTCMenu_NotifySelect; };
2000 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; };
2002 MenuItem debugBpRunToCursor { debugMenu, $"BP Run To Cursor"/*, c, ctrlF10*/, id = RTCMenuBits { false, false, true }, NotifySelect = RTCMenu_NotifySelect; };
2003 MenuItem debugBpSkipRunToCursor { debugMenu, $"BP Run To Cursor Skipping Breakpoints"/*, u, Key { f10, ctrl = true, shift = true }*/, id = RTCMenuBits { true, false, true }, NotifySelect = RTCMenu_NotifySelect; };
2004 MenuItem debugBpRunToCursorAtSameLevel { debugMenu, $"BP Run To Cursor At Same Level"/*, l, altF10*/, id = RTCMenuBits { false, true, true }, NotifySelect = RTCMenu_NotifySelect; };
2005 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; };
2007 bool RTCMenu_NotifySelect(MenuItem selection, Modifiers mods)
2009 ProjectView projectView = ide.projectView;
2010 if(!projectView.buildInProgress)
2012 RTCMenuBits bits = (RTCMenuBits)selection.id;
2013 int line = editBox.lineNumber + 1;
2016 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2017 ProjectConfig config = projectView.project.config;
2018 int bitDepth = ide.workspace.bitDepth;
2019 bool useValgrind = ide.workspace.useValgrind;
2020 ide.debugger.RunToCursor(compiler, config, bitDepth, useValgrind, fileName, line, bits.ignoreBreakpoints, bits.atSameLevel, bits.oldImplementation);
2026 MenuDivider { debugMenu };
2027 MenuItem debugToggleBreakpoint
2029 debugMenu, $"Toggle Breakpoint", t, f9;
2030 bool NotifySelect(MenuItem selection, Modifiers mods)
2032 ProjectView projectView = ide.projectView;
2033 if(projectView && fileName)
2035 int line = editBox.lineNumber + 1;
2036 ide.debugger.ToggleBreakpoint(fileName, line);
2046 //MenuItem viewDesignerItem, viewProperties, viewMethods;
2050 designer.parent = parent;
2053 toolBox = ((IDEWorkSpace)master).toolBox;
2055 // Debugger bug here: value of toolBox appears as 0
2057 sheet = ((IDEWorkSpace)master).sheet;
2062 bool OnClose(bool parentClosing)
2066 if(ide.workspace && fileName)
2067 ide.workspace.UpdateOpenedFileInfo(fileName, closed);
2068 if(inUseDebug && !debugClosing)
2070 debugClosing = true;
2072 if(CloseConfirmation(false))
2075 if(modifiedDocument)
2076 OnFileModified({ modified = true }, null);
2078 debugClosing = false;
2081 if(designer && !designer.closing)
2083 if(designer.visible)
2090 //Window formEditor = designer;
2091 //formEditor.Destroy(0);
2094 ide.AdjustFileMenus();
2099 void OnDestroy(void)
2101 ObjectInfo oClass, next;
2102 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2104 FreeType(this.functionType);
2105 FreeType(this.instanceType);
2110 designer.codeEditor = null;
2111 designer.Destroy(0);
2115 for(oClass = (classes).first, next = oClass ? oClass.next : null; oClass; oClass = next, next = next ? (next.next) : null)
2117 ObjectInfo object, next;
2119 for(object = oClass.instances.first; object; object = next)
2124 Designer::DestroyObject(object.instance);
2125 delete object.instance;
2127 if(object.i18nStrings)
2129 Map<String, bool> i18nStrings = object.i18nStrings;
2132 sheet.DeleteObject(object);
2134 oClass.instances.Delete(object);
2138 Designer::DestroyObject(oClass.instance);
2139 delete oClass.instance;
2141 if(oClass.i18nStrings)
2143 Map<String, bool> i18nStrings = oClass.i18nStrings;
2146 sheet.DeleteObject(oClass);
2148 classes.Delete(oClass);
2151 if(windowClass && windowClass.data)
2152 UnapplySkin(windowClass);
2156 if(sheet.codeEditor == this)
2158 sheet.codeEditor = null;
2159 toolBox.codeEditor = null;
2165 ProjectView projectView = ide.projectView;
2168 ProjectNode node = projectView.GetNodeFromWindow(this, null, true, false, null);
2169 if(node && node.modified)
2171 node.modified = false;
2172 projectView.Update(null);
2178 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool directActivation)
2180 // 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
2182 if(directActivation)
2183 ide.RepositionWindows(false); // Moved this up before as resizing causes NotifyCaretMove to be called on all editors
2185 if(active && directActivation)
2189 openedFileInfo.Activate();
2193 Location * loc = null;
2194 UpdateFormCode(); // To ensure update when modifying properties...
2196 // Got to the right spot in code so we don't lose our form selection...
2199 if(selected.instCode)
2200 loc = &selected.instCode.loc;
2201 else if(selected.classDefinition)
2202 loc = &selected.classDefinition.loc;
2204 line = editBox.lineNumber + 1;
2205 charPos = editBox.charPos + 1;
2210 if(selected && !loc->Inside(line, charPos))
2212 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2213 line = editBox.lineNumber + 1;
2214 charPos = editBox.charPos + 1;
2216 else if(selected && selected.classDefinition)
2219 for(object = selected.instances.first; object; object = object.next)
2223 if(object.instCode.loc.Inside(line, charPos))
2229 editBox.GoToPosition(null, loc->start.line - 1, loc->start.charPos - 1);
2230 line = editBox.lineNumber + 1;
2231 charPos = editBox.charPos + 1;
2236 ProcessCaretMove(editBox, line, charPos);
2241 if(membersListShown)
2243 membersList.Destroy(0);
2244 membersListShown = false;
2248 paramsList.Destroy(0);
2249 paramsShown = false;
2250 FreeType(functionType);
2251 FreeType(instanceType);
2253 functionType = null;
2254 instanceType = null;
2261 bool OnSaveFile(char * fileName)
2268 f = FileOpen(fileName, write);
2271 if(!ide.projectView)
2272 ide.ChangeFileDialogsDirectory(codeEditorFileDialog.currentDirectory, true);
2276 this.fileName = fileName; // Put this here because the form designer will check for it...
2277 designer.fileName = fileName;
2278 designer.modifiedDocument = false;
2281 editBox.Save(f, false);
2282 modifiedDocument = false;
2290 bool OnFileModified(FileChange fileChange, char * param)
2292 bool reload = false;
2293 if(visible == false && inUseDebug == true)
2294 ide.debugger.WatchesReleaseCodeEditor();
2299 sprintf(message, $"The document %s was modified by another application.\n"
2300 "Would you like to reload it and lose your changes?", fileName);
2301 if(MessageBox { type = yesNo, master = /*parent = */parent, text = $"Document has been modified",
2302 contents = message }.Modal() == yes)
2308 File f = FileOpen(fileName, read);
2311 int lineNumber, charPos, len;
2315 updatingCode = true;
2316 lineNumber = editBox.lineNumber;
2317 charPos = editBox.charPos;
2318 scroll = editBox.scroll;
2321 lineNumber = lineNumber < editBox.numLines ? lineNumber : editBox.numLines - 1;
2322 len = strlen(editBox.line.text);
2323 editBox.GoToLineNum(lineNumber);
2324 editBox.GoToPosition(editBox.line, lineNumber, charPos <= len ? charPos - 1 : (len ? len - 1 : 0));
2325 editBox.scroll = scroll;
2326 updatingCode = false;
2327 loadingFile = false;
2329 codeModified = true;
2333 designer.modifiedDocument = false;
2335 modifiedDocument = false;
2343 void OnRedraw(Surface surface)
2346 surface.SetBackground(marginColor);
2347 surface.Area(0, 0, editBox.anchor.left.distance, clientSize.h - 1);
2348 if(ideSettings.showLineNumbers)
2350 int currentLineNumber;
2352 char lineFormat[16];
2356 surface.textOpacity = false;
2357 surface.font = font.font;
2358 surface.TextExtent(" ", 1, null, &spaceH);
2359 currentLineNumber = editBox.scroll.y / spaceH + 1;
2360 sprintf(lineFormat, " %%%du", maxLineNumberLength);
2362 surface.SetForeground(lineNumbersColor);
2363 for(i = 0; i < editBox.clientSize.h - 4; i += spaceH)
2365 // Highlight current line
2366 if(editBox.lineNumber == currentLineNumber - 1)
2368 surface.SetBackground(selectedMarginColor);
2369 surface.Area(0, i, editBox.anchor.left.distance, i+spaceH-1);
2370 surface.SetBackground(marginColor);
2372 sprintf(lineText, lineFormat, currentLineNumber);
2373 if(currentLineNumber <= editBox.numLines)
2374 surface.WriteText(editBox.syntaxHighlighting * 20, i+1,lineText,maxLineNumberLength+1);
2375 currentLineNumber++;
2379 if(editBox.syntaxHighlighting && fileName && ide.projectView)
2381 bool error, bpOnCursor, bpOnTopFrame, breakpointEnabled[128];
2382 int lineCursor, lineTopFrame, breakpointLines[128];
2383 int count, i, lineH, boxH, scrollY; //, firstLine; firstLine = editBox.firstLine;
2384 Debugger debugger = ide.debugger;
2385 BitmapResource bmpRes;
2387 boxH = clientSize.h;
2388 scrollY = editBox.scroll.y;
2389 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
2391 bpOnCursor = bpOnTopFrame = false;
2392 count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
2395 for(i = 0; i < count; i++)
2397 if(breakpointLines[i] == lineCursor || breakpointLines[i] == lineTopFrame)
2399 bmpRes = breakpointEnabled[i] ? ide.bmpBpHalf : ide.bmpBpHalfDisabled;
2400 if(breakpointLines[i] == lineCursor)
2402 if(breakpointLines[i] == lineTopFrame)
2403 bpOnTopFrame = true;
2406 bmpRes = breakpointEnabled[i] ? ide.bmpBp : ide.bmpBpDisabled;
2408 DrawLineMarginIcon(surface, bmpRes, breakpointLines[i], lineH, scrollY, boxH);
2411 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
2412 bmpRes = bpOnTopFrame ? (error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf) : (error ? ide.bmpTopFrameError : ide.bmpTopFrame);
2413 DrawLineMarginIcon(surface, bmpRes, lineTopFrame, lineH, scrollY, boxH);
2415 if(editBox.anchor.left.distance)
2417 if(editBox.horzScroll && editBox.horzScroll.visible)
2419 surface.SetBackground(control);
2420 surface.Area(0, editBox.clientSize.h, editBox.anchor.left.distance, clientSize.h - 1);
2425 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
2430 lineY = (line - 1) * lineH;
2431 if(lineY + lineH > scrollY && lineY /*+ lineH*/ < scrollY + boxH)
2433 Bitmap bitmap = resource.bitmap;
2435 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
2442 char ext[MAX_EXTENSION];
2443 char * fileName = property::fileName;
2445 if(SearchString(fileName, 0, "Makefile", false, true))
2446 editBox.useTab = true;
2447 designer.fileName = fileName;
2451 GetExtension(fileName, ext);
2453 if(!strcmpi(ext, "ec") || !strcmpi(ext, "eh") || !strcmpi(ext, "c") || !strcmpi(ext, "h") || !strcmpi(ext, "cpp") ||
2454 !strcmpi(ext, "hpp") || !strcmpi(ext, "cxx") || !strcmpi(ext, "hxx") || !strcmpi(ext, "cc") || !strcmpi(ext, "hh") ||
2455 !strcmpi(ext, "m") || !strcmpi(ext, "mm") || !strcmpi(ext, "cs") || !strcmpi(ext, "java") || !strcmpi(ext, "y") || !strcmpi(ext, "l"))
2456 editBox.syntaxHighlighting = true;
2458 editBox.syntaxHighlighting = false;
2460 if(parsing && !strcmpi(ext, "ec"))
2462 codeModified = true;
2466 maxLineNumberLength = 0;
2471 bool UpdateMarginSize()
2473 if(ideSettings.showLineNumbers)
2475 int numLen = Max(4, nofdigits(editBox.numLines));
2477 maxLineNumberLength = numLen;
2478 display.FontExtent(font.font, "0", 1, &digitWidth, null);
2479 editBox.anchor = Anchor
2481 left = editBox.syntaxHighlighting * 20 + ideSettings.showLineNumbers * (maxLineNumberLength+2) * digitWidth,
2482 right = 0, top = 0, bottom = 0
2487 maxLineNumberLength = 0;
2488 editBox.anchor = Anchor
2490 left = editBox.syntaxHighlighting * 20,
2491 right = 0, top = 0, bottom = 0
2503 bool LoadFile(char * filePath)
2505 File f = FileOpen(filePath, read);
2508 // Added this here...
2509 fileName = filePath;
2511 updatingCode = true;
2513 updatingCode = false;
2514 loadingFile = false;
2523 void AdjustDebugMenus()
2525 bool unavailable = ide.areDebugMenusUnavailable;
2526 bool isNotNotRunning = unavailable || ide.isDebuggerRunning;
2527 bool isNotStopped = unavailable || !ide.isDebuggerStopped;
2528 bool noBreakpointToggle = ide.isBreakpointTogglingUnavailable;
2530 debugRunToCursor.disabled = isNotNotRunning;
2531 debugSkipRunToCursor.disabled = isNotNotRunning;
2532 debugRunToCursorAtSameLevel.disabled = isNotStopped;
2533 debugSkipRunToCursorAtSameLevel.disabled = isNotStopped;
2535 debugBpRunToCursor.disabled = isNotNotRunning;
2536 debugBpSkipRunToCursor.disabled = isNotNotRunning;
2537 debugBpRunToCursorAtSameLevel.disabled = isNotStopped;
2538 debugBpSkipRunToCursorAtSameLevel.disabled = isNotStopped;
2540 debugToggleBreakpoint.disabled = noBreakpointToggle;
2546 ProjectView projectView = ide.projectView;
2548 globalData.classes.CompareKey = (void *)BinaryTree::CompareString;
2549 globalData.defines.CompareKey = (void *)BinaryTree::CompareString;
2550 globalData.functions.CompareKey = (void *)BinaryTree::CompareString;
2551 globalData.nameSpaces.CompareKey = (void *)BinaryTree::CompareString;
2554 designer.fileName = fileName;
2560 sprintf(title, $"Untitled %d", documentID);
2561 // designer.fileName = CopyString(title);
2562 designer.fileName = title;
2567 for(c = 0; c < CodeObjectType::enumSize; c++)
2568 icons[c] = BitmapResource { iconNames[c], window = this };
2570 codeModified = true;
2582 selected.modified = true;
2583 selected.oClass.modified = true;
2585 designer.modifiedDocument = true;
2586 modifiedDocument = true;
2587 formModified = true;
2590 /****************************************************************************
2592 ****************************************************************************/
2595 SetCurrentNameSpace(null);
2601 this.defines.Free(FreeModuleDefine);
2602 this.imports.Free(FreeModuleImport); // Moved this after FreeAST because Debug printing causes ModuleImports to be created
2604 FreeExcludedSymbols(this.excludedSymbols);
2605 FreeContext(this.globalContext);
2607 FreeGlobalData(&this.globalData);
2608 FindCtx_Terminate();
2609 FindParams_Terminate();
2611 if(GetGlobalContext() == globalContext)
2613 SetGlobalData(null);
2614 SetGlobalContext(null);
2615 SetExcludedSymbols(null);
2616 SetTopContext(null);
2617 SetCurrentContext(null);
2620 SetPrivateModule(null);
2623 if(this.privateModule)
2625 FreeTypeData(this.privateModule);
2626 delete this.privateModule;
2627 this.privateModule = null;
2633 static bool reentrant = false;
2638 char * selectedClassName = null, * selectedName = null;
2639 int selectedPos = 0;
2640 Designer backDesigner;
2641 char oldWorkDir[MAX_LOCATION];
2642 char mainModuleName[MAX_FILENAME] = "";
2644 ImportedModule module;
2645 char extension[MAX_EXTENSION];
2646 PathBackup pathBackup { };
2648 Time parseCodeStart = GetTime();
2649 Time startTime, startFindClass;
2651 findClassTotalTime = 0;
2652 checkTypeTotalTime = 0;
2653 externalImportTotalTime = 0;
2654 findClassIgnoreNSTotalTime = 0;
2655 findSymbolTotalTime = 0;
2656 //ResetClassFindTime();
2660 // 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)
2661 if(reentrant) return;
2668 selectedClassName = CopyString(oClass.name);
2669 if(selected != oClass)
2671 ObjectInfo object = this.selected;
2672 selectedName = CopyString(object.name);
2676 for(check = this.oClass.instances.first; check; check = check.next)
2688 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
2690 FindCtx_Terminate();
2691 FindParams_Terminate();
2693 SetGlobalData(&globalData);
2694 SetGlobalContext(globalContext);
2695 SetExcludedSymbols(&excludedSymbols);
2696 SetTopContext(globalContext);
2697 SetCurrentContext(globalContext);
2698 SetDefines(&defines);
2699 SetImports(&imports);
2700 SetCurrentNameSpace(null);
2703 sprintf(command, "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin\\cl "
2704 "/nologo /D \"MSC\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" "
2705 "/I \"C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include\" "
2706 "/I T:\\ecere\\include /E %s", argv[1]);
2710 ChangeWorkingDir("e:\\ec");
2711 sprintf(command, "gcc -x c -E -");
2712 fileInput = DualPipeOpen({ output = true, input = true }, command);
2713 SetFileInput(fileInput);
2718 uint count = editFile.Read(buffer, 1, sizeof(buffer));
2720 fileInput.Write(buffer, 1, count);
2725 fileInput.CloseOutput();
2729 // TOCHECK: COULDN'T WE CALL FreeParser here?
2731 FreeType(this.functionType);
2732 FreeType(this.instanceType);
2733 this.functionType = null;
2734 this.instanceType = null;
2737 sheet.SelectObject(null);
2743 // We don't want the designer to be notified of selection when deleting rows...
2744 backDesigner = designer;
2749 ObjectInfo _class, next;
2751 for(_class = classes.first; _class; _class = next)
2757 for(;object = _class.instances.first;)
2761 Designer::DestroyObject(object.instance);
2762 delete object.instance;
2764 if(object.i18nStrings)
2766 Map<String, bool> i18nStrings = object.i18nStrings;
2769 sheet.DeleteObject(object);
2771 _class.instances.Delete(object);
2775 Designer::DestroyObject(_class.instance);
2776 delete _class.instance;
2778 if(_class.i18nStrings)
2780 Map<String, bool> i18nStrings = _class.i18nStrings;
2783 sheet.DeleteObject(_class);
2785 classes.Delete(_class);
2791 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
2792 if(windowClass && windowClass.data)
2793 UnapplySkin(windowClass);
2796 designer = backDesigner;
2799 fileInput = editFile = EditBoxStream { editBox = editBox };
2800 SetFileInput(fileInput);
2808 defines.Free(FreeModuleDefine);
2809 imports.Free(FreeModuleImport);
2811 FreeContext(this.globalContext);
2812 FreeExcludedSymbols(this.excludedSymbols);
2815 FreeGlobalData(&this.globalData);
2817 if(this.privateModule)
2819 FreeTypeData(this.privateModule);
2820 delete this.privateModule;
2824 startTime = GetTime();
2825 printf("Cleaning up took %.3f seconds\n", startTime - parseCodeStart);
2827 printf("classes.count: %d\n", globalContext.classes.count);
2832 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2833 SetTargetBits(ide.workspace.bitDepth ? ide.workspace.bitDepth : GetHostBits());
2836 this.privateModule = __ecere_COM_Initialize(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4), 1, null);
2838 SetPrivateModule(privateModule);
2841 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint"), type = ProcessTypeString("unsigned int", false) });
2842 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint64"), type = ProcessTypeString("unsigned int64", false) });
2843 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint32"), type = ProcessTypeString("unsigned int", false) });
2844 globalContext.types.Add((BTNode)Symbol { string = CopyString("uint16"), type = ProcessTypeString("unsigned short", false) });
2845 globalContext.types.Add((BTNode)Symbol { string = CopyString("byte"), type = ProcessTypeString("unsigned char", false) });
2848 fileName = this.fileName;
2850 if(ide.workspace && ide.workspace.projects && fileName)
2852 for(p : ide.workspace.projects)
2854 char path[MAX_LOCATION];
2856 MakePathRelative(fileName, p.topNode.path, path);
2857 MakeSlashPath(path);
2859 pn = p.topNode.FindWithPath(path, false);
2868 project = ide.project;
2870 GetWorkingDir(oldWorkDir, MAX_LOCATION);
2872 ChangeWorkingDir(project.topNode.path);
2874 SetSomeSourceFileStack(fileName ? fileName : "", 0); //strcpy(sourceFileStack[0], fileName ? fileName : "");
2876 GetLastDirectory(fileName, mainModuleName);
2877 GetExtension(mainModuleName, extension);
2879 SetBuildingEcereCom(false);
2880 SetBuildingEcereComModule(false);
2882 // TODO: Get symbolsDir from project settings instead...
2885 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2886 ProjectConfig config = project.config;
2887 int bitDepth = ide.workspace.bitDepth;
2888 DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
2889 SetSymbolsDir(objDir.dir);
2890 ide.SetPath(true, compiler, config, bitDepth);
2894 // SetIncludeDirs(ide.projectView.project.config.includeDirs);
2895 // SetSysIncludeDirs(ide.ideSettings.systemDirs[includes]);
2899 switch(GetRuntimePlatform())
2901 case win32: SetSymbolsDir("obj/debug.win32"); break;
2902 case tux: SetSymbolsDir("obj/debug.linux"); break;
2903 case apple: SetSymbolsDir("obj/debug.apple"); break;
2905 SetIncludeDirs(null);
2906 SetSysIncludeDirs(null);
2910 if(ide.projectView && ide.projectView.IsModuleInProject(this.fileName))
2912 // TODO FIX for configless project
2913 if(ide.project.config && ide.project.config.options && ide.project.config.options.preprocessorDefinitions)
2915 for(item : ide.project.config.options.preprocessorDefinitions)
2917 if(!strcmp(item, "BUILDING_ECERE_COM"))
2919 SetBuildingEcereCom(true);
2926 if(!(strcmpi(mainModuleName, "instance.ec") && strcmpi(mainModuleName, "BinaryTree.ec") &&
2927 strcmpi(mainModuleName, "dataTypes.ec") && strcmpi(mainModuleName, "OldList.ec") &&
2928 strcmpi(mainModuleName, "String.ec") && strcmpi(mainModuleName, "BTNode.ec") &&
2929 strcmpi(mainModuleName, "Array.ec") && strcmpi(mainModuleName, "AVLTree.ec") &&
2930 strcmpi(mainModuleName, "BuiltInContainer.ec") && strcmpi(mainModuleName, "Container.ec") &&
2931 strcmpi(mainModuleName, "CustomAVLTree.ec") && strcmpi(mainModuleName, "LinkList.ec") &&
2932 strcmpi(mainModuleName, "List.ec") && strcmpi(mainModuleName, "Map.ec") &&
2933 strcmpi(mainModuleName, "Mutex.ec")))
2935 SetBuildingEcereComModule(true);
2938 // Predeclare all classes
2940 char symFile[MAX_FILENAME];
2941 char symLocation[MAX_LOCATION];
2942 ImportedModule module, next;
2944 GetLastDirectory(fileName, symFile);
2945 ChangeExtension(symFile, "sym", symFile);
2947 strcpy(symLocation, GetSymbolsDir());
2948 PathCat(symLocation, symFile);
2950 // if(!GetEcereImported() && !GetBuildingEcereCom())
2951 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2954 startTime = GetTime();
2956 eModule_LoadStrict(privateModule, "ecereCOM", privateAccess);
2958 printf("Loading ecereCOM took %.3f seconds\n", GetTime() - startTime);
2963 startTime = GetTime();
2965 // LoadSymbols(symLocation, normalImport, true);
2966 LoadSymbols(symLocation, preDeclImport, false);
2968 printf("Loading symbols took %.3f seconds\n", GetTime() - startTime);
2971 for(module = defines.first; module; module = next)
2974 if(module.type == moduleDefinition && strcmpi(module.name, mainModuleName))
2977 defines.Delete(module);
2982 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
2984 SetDefaultDeclMode(privateAccess);
2985 SetDeclMode(privateAccess);
2989 SetDefaultDeclMode(defaultAccess);
2990 SetDeclMode(defaultAccess);
2993 StripExtension(mainModuleName);
2994 module = ImportedModule { name = CopyString(mainModuleName), type = moduleDefinition };
2995 defines.AddName(module);
2998 // SetYydebug(true);
3003 startTime = GetTime();
3004 startFindClass = checkTypeTotalTime;
3008 printf("ParseEc took %.3f seconds, out of which %.3f seconds were in CheckType\n", GetTime() - startTime, checkTypeTotalTime - startFindClass);
3010 CheckDataRedefinitions();
3013 SetIncludeDirs(null);
3014 SetSysIncludeDirs(null);
3025 startTime = GetTime();
3027 PrePreProcessClassDefinitions();
3028 ComputeModuleClasses(privateModule);
3029 PreProcessClassDefinitions();
3030 ProcessClassDefinitions();
3032 printf("Initial Passes took %.3f seconds\n", GetTime() - startTime);
3033 startTime = GetTime();
3038 printf("ComputeDataTypes took %.3f seconds\n", GetTime() - startTime);
3039 startTime = GetTime();
3041 ProcessInstantiations();
3043 printf("ProcessInstantiations took %.3f seconds\n", GetTime() - startTime);
3046 if(!strcmp(extension, "ec") || !strcmp(extension, "eh"))
3048 Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3049 if(!windowClass || windowClass.internalDecl)
3052 startTime = GetTime();
3054 // *** COMMENTED THIS OUT DUE TO ecereCOM issues
3055 // eModule_Load(this.privateModule.application.allModules.first ? this.privateModule.application.allModules.first : this.privateModule, "ecere", privateAccess);
3056 eModule_Load(this.privateModule, "ecere", privateAccess);
3058 printf("Loading ecere.dll took %.3f seconds\n", GetTime() - startTime);
3061 windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
3063 if(windowClass && windowClass.data)
3064 ApplySkin(windowClass, app.currentSkin.name, null);
3068 startTime = GetTime();
3070 for(external = ast->first; external; external = external.next)
3072 if(external.type == classExternal)
3074 ClassDefinition _class = external._class;
3075 if(_class.baseSpecs && _class.baseSpecs->first && ((Specifier)_class.baseSpecs->first).type == nameSpecifier ) // classSpecifier
3077 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)_class.baseSpecs->first).name);
3080 if(eClass_GetDesigner(regClass) && !GetBuildingEcereComModule())
3082 Instance instance = eInstance_New(regClass);
3083 ObjectInfo classObject
3085 name = CopyString(_class._class.name);
3086 instance = instance;
3087 classDefinition = _class;
3088 oClass = classObject;
3091 classes.Add(classObject);
3095 // Moved this at bottom so that the file dialog doesn't show up in eCom
3096 designer.CreateObject(instance, classObject, true, null);
3097 sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, typeClass, false);
3099 if(_class.definitions)
3103 for(def = _class.definitions->first; def; def = def.next)
3107 case defaultPropertiesClassDef:
3110 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
3112 Identifier id = propDef.identifiers->first;
3115 Property prop = eClass_FindProperty(regClass, id.string, this.privateModule);
3118 Class propertyClass = prop.dataTypeClass;
3120 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3121 if(prop.compiled && prop.Set && prop.Get && propertyClass && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp)
3123 Expression computed;
3124 bool variable = true;
3126 FreeType(propDef.initializer.exp.destType);
3127 propDef.initializer.exp.destType = MkClassType(propertyClass.name);
3128 ProcessExpressionType(propDef.initializer.exp);
3130 computed = CopyExpression(propDef.initializer.exp);
3131 ComputeExpression(computed);
3132 if(computed.isConstant)
3134 switch(computed.type)
3137 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3139 String temp = new char[strlen(computed.string)+1];
3140 ReadString(temp, computed.string);
3141 ((void (*)(void *, void *))(void *)prop.Set)(instance, temp);
3144 if(!propDef.initializer.exp.intlString)
3146 Map<String, bool> i18nStrings = classObject.i18nStrings;
3148 classObject.i18nStrings = i18nStrings = { };
3149 i18nStrings[prop.name] = false;
3155 if((propertyClass.type == structClass || propertyClass.type == noHeadClass || propertyClass.type == normalClass) && !id.next)
3159 if(computed.instance._class && computed.instance._class.symbol &&
3160 computed.instance._class.symbol.registered &&
3161 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3163 ((void (*)(void *, void *))(void *)prop.Set)(instance, computed.instance.data);
3165 // This was saved in the control and shouldn't be freed by FreeExpression...
3166 // (Not doing this anymore, incrementing refCount in pass15 instead)
3167 /*if(propertyClass.type == normalClass)
3168 computed.instance.data = null;*/
3176 Operand value = GetOperand(computed);
3177 DataValue valueData;
3178 valueData.i64 = value.i64;
3179 SetProperty(prop, instance, valueData);
3186 propDef.variable = true;
3187 FreeExpression(computed);
3192 Method method = eClass_FindMethod(regClass, id.string, this.privateModule);
3193 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer &&
3194 propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
3197 // Maintain a list in FunctionDefinition of who is attached to it
3198 for(def = _class.definitions->first; def; def = def.next)
3200 if(def.type == functionClassDef)
3202 ClassFunction function = def.function;
3203 if(!strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
3205 function.attached.Add(OldLink { data = method });
3215 case declarationClassDef:
3217 Declaration decl = def.decl;
3220 case instDeclaration:
3222 Instantiation inst = decl.inst;
3223 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3224 if(instClass && eClass_GetDesigner(instClass))
3226 Instance control = eInstance_New(instClass);
3231 oClass = classObject;
3235 classObject.instances.Add(object);
3237 // TOCHECK: Why is this needed now?
3238 object.name = CopyString((inst.exp.type == memberExp) ? inst.exp.member.member.string : inst.exp.identifier.string);
3239 def.object = object;
3241 // if(object.name) { symbol = eList_Add(&curContext.symbols, sizeof(Symbol)); symbol.string = object.name; symbol.type = MkClassType(instClass.name); }
3243 designer.CreateObject(control, object, false, classObject.instance);
3244 sheet.AddObject(object, object.name ? object.name : inst._class.name, typeData, false);
3254 // Second pass, process instantiation members
3256 for(def = _class.definitions->first; def; def = def.next)
3260 case declarationClassDef:
3262 Declaration decl = def.decl;
3265 case instDeclaration:
3267 Instantiation inst = decl.inst;
3268 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
3269 if(instClass && eClass_GetDesigner(instClass))
3272 object = object ? object.next : classObject.instances.first;
3273 control = object.instance;
3277 MembersInit members;
3278 for(members = inst.members->first; members; members = members.next)
3280 switch(members.type)
3282 case dataMembersInit:
3284 if(members.dataMembers)
3287 DataMember curMember = null;
3288 Class curClass = null;
3289 DataMember subMemberStack[256];
3290 int subMemberStackPos = 0;
3292 for(member = members.dataMembers->first; member; member = member.next)
3295 Identifier ident = member.identifiers ? member.identifiers->first : null;
3298 DataMember _subMemberStack[256];
3299 int _subMemberStackPos = 0;
3300 DataMember thisMember = (DataMember)eClass_FindDataMember(instClass, ident.string, privateModule, _subMemberStack, &_subMemberStackPos);
3304 thisMember = (DataMember)eClass_FindProperty(instClass, ident.string, privateModule);
3306 if(thisMember && thisMember.memberAccess == publicAccess)
3308 curMember = thisMember;
3309 curClass = curMember._class;
3310 memcpy(subMemberStack, _subMemberStack, sizeof(DataMember) * _subMemberStackPos);
3311 subMemberStackPos = _subMemberStackPos;
3317 eClass_FindNextMember(instClass, &curClass, (DataMember *)&curMember, subMemberStack, &subMemberStackPos);
3318 if(curMember) found = true;
3320 if(found && curMember.isProperty)
3322 Property prop = (Property) curMember;
3323 Class propertyClass = prop.dataTypeClass;
3324 bool variable = false;
3326 propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3328 if(prop.compiled && prop.Set && prop.Get && propertyClass && member.initializer && member.initializer.type == expInitializer && member.initializer.exp)
3330 FreeType(member.initializer.exp.destType);
3331 member.initializer.exp.destType = MkClassType(propertyClass.name);
3334 Expression computed;
3336 ProcessExpressionType(member.initializer.exp);
3338 computed = CopyExpression(member.initializer.exp);
3341 bool isClass = propertyClass.type == structClass || propertyClass.type == normalClass || propertyClass.type == noHeadClass;
3344 /*char debugExpString[4096];
3345 debugExpString[0] = '\0';
3346 PrintExpression(member.initializer.exp, debugExpString);*/
3348 ComputeExpression(computed);
3350 switch(computed.type)
3353 if(isClass && computed.isConstant && computed.instance.data)
3355 if(computed.instance._class && computed.instance._class.symbol &&
3356 computed.instance._class.symbol.registered &&
3357 eClass_IsDerived(computed.instance._class.symbol.registered, propertyClass))
3359 ((void (*)(void *, void *))(void *)prop.Set)(control, computed.instance.data);
3361 // This was saved in the control and shouldn't be freed by FreeExpression...
3362 // (Not doing this anymore, incrementing refCount in pass15 instead)
3363 /*if(propertyClass.type == normalClass)
3364 computed.instance.data = null;*/
3370 if(isClass && eClass_GetDesigner(propertyClass))
3373 char * name = computed.identifier.string;
3374 if(!strcmp(name, "this"))
3377 ((void (*)(void *, void *))(void *)prop.Set)(control, instance);
3383 for(check = classObject.instances.first; check; check = check.next)
3384 if(check.name && !strcmp(name, check.name))
3387 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3397 if(computed.member.exp.type == identifierExp)
3399 char * name = computed.member.exp.identifier.string;
3401 if(!strcmp(name, "this"))
3403 char * name = computed.member.member.string;
3405 for(check = classObject.instances.first; check; check = check.next)
3406 if(check.name && !strcmp(name, check.name))
3409 ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
3416 for(check = classObject.instances.first; check; check = check.next)
3418 if(check.name && !strcmp(name, check.name))
3420 Property getProperty = eClass_FindProperty(check.instance._class, computed.member.member.string, this.privateModule);
3423 DataValue value { };
3424 GetProperty(getProperty, check.instance, &value);
3425 SetProperty(prop, control, value);
3436 if(propertyClass.dataTypeString && strstr(propertyClass.dataTypeString, "char *"))
3438 String temp = new char[strlen(computed.string)+1];
3439 ReadString(temp, computed.string);
3440 ((void (*)(void *, void *))(void *)prop.Set)(control, temp);
3443 if(!member.initializer.exp.intlString)
3445 Map<String, bool> i18nStrings = object.i18nStrings;
3447 object.i18nStrings = i18nStrings = { };
3448 i18nStrings[prop.name] = false;
3455 if(!isClass && computed.isConstant)
3457 if(!strcmp(propertyClass.dataTypeString, "float"))
3458 ((void (*)(void *, float))(void *)prop.Set)(control, (float)strtod(computed.constant, null));
3459 else if(!strcmp(propertyClass.dataTypeString, "double"))
3460 ((void (*)(void *, double))(void *)prop.Set)(control, strtod(computed.constant, null));
3462 ((void (*)(void *, int))(void *)prop.Set)(control, strtol(computed.constant, null, 0));
3469 FreeExpression(computed);
3473 member.variable = true;
3475 else if(ident && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
3476 member.initializer.exp.type == memberExp) // identifierExp
3478 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
3479 if(method && method.type == virtualMethod)
3482 // Maintain a list in FunctionDefinition of who is attached to it
3483 for(def = _class.definitions->first; def; def = def.next)
3485 if(def.type == functionClassDef)
3487 ClassFunction function = def.function;
3488 Identifier id = (member.initializer.exp.type == memberExp) ? member.initializer.exp.member.member : member.initializer.exp.identifier;
3489 if(function.declarator && !strcmp(function.declarator.symbol.string, id.string))
3491 function.attached.Add(OldLink { data = method });
3492 // Reference this particular instance?
3507 designer.PostCreateObject(object.instance, object, false, classObject.instance);
3518 //designer.CreateObject(instance, classObject, true, null);
3519 //sheet.AddObject(classObject, classObject.name ? classObject.name : _class._class.name, classType, false);
3521 designer.PostCreateObject(instance, classObject, true, null);
3523 //instance.state = Hidden;
3524 //instance.Create();
3525 //instance.SetState(Normal, true, 0);
3534 printf("Class/Instance Processing took %.3f seconds\n", GetTime() - startTime);
3538 // Restore Selection
3539 if(selectedClassName)
3542 for(oClass = classes.first; oClass; oClass = oClass.next)
3544 if(!strcmp(oClass.name, selectedClassName))
3546 this.oClass = oClass;
3550 delete selectedClassName;
3559 for(check = this.oClass.instances.first; check; check = check.next)
3561 if(check.name && !strcmp(check.name, selectedName))
3563 this.selected = check;
3569 if(this.oClass.instances.first)
3570 this.selected = this.oClass.instances.first;
3572 this.selected = this.oClass;
3575 else if(selectedPos == -1 || !this.oClass.instances.count)
3576 this.selected = this.oClass;
3582 if(selectedPos > this.oClass.instances.count)
3584 for(check = this.oClass.instances.first; check; check = check.next)
3586 if(selectedPos == pos++)
3588 this.selected = check;
3596 this.oClass = classes.first;
3597 this.selected = (this.oClass && this.oClass.instances.first) ? this.oClass.instances.first : this.oClass;
3599 delete selectedName;
3600 SetSymbolsDir(null);
3602 if(sheet.codeEditor == this)
3603 sheet.SelectObject(selected);
3606 codeModified = false;
3608 // TESTING THIS TO NOT GET EMPTY PARAMETERS
3611 InvokeParameters(false, false, false);
3614 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
3620 ChangeWorkingDir(oldWorkDir);
3622 printf("Total FindClass time is %.3f seconds, out of which %.3f is in Ignore NS\n\n", findClassTotalTime, findClassIgnoreNSTotalTime);
3623 printf("Total CheckType time is %.3f seconds\n\n", checkTypeTotalTime);
3624 printf("Total MkExternalImport time is %.3f seconds\n\n", externalImportTotalTime);
3625 printf("Total FindSymbol time is %.3f seconds\n\n", findSymbolTotalTime);
3626 // printf("Total Class Members Find time is %.3f seconds\n\n", GetClassFindTime());
3628 printf("Whole ParseCode function took %.3f seconds\n\n", GetTime() - parseCodeStart);
3630 if(inUseDebug && ide.projectView)
3631 ide.debugger.EvaluateWatches();
3636 void UpdateInstanceCodeClass(Class _class, ObjectInfo object, EditBoxStream f, Instance test, bool * prev, bool * lastIsMethod, DataMember * curMember, Class * curClass)
3639 Window control = (Window)object.instance;
3640 ObjectInfo classObject = object.oClass;
3642 if(_class.base && _class.base.type != systemClass) UpdateInstanceCodeClass(_class.base, object, f, test, prev, lastIsMethod, curMember, curClass);
3644 if(!strcmp(_class.name, "DesignerBase")) return;
3646 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
3648 Property prop = eClass_FindProperty(object.instance._class, propIt.name, privateModule);
3649 if(prop && prop.isProperty && !prop.conversion && eClass_FindProperty(object.instance._class, prop.name, privateModule))
3651 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(object, prop.name) &&
3652 prop.compiled && (!prop.IsSet || prop.IsSet(control)))
3654 Class dataType = prop.dataTypeClass;
3656 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
3660 if(dataType.type == structClass)
3662 void * dataForm = new0 byte[dataType.structSize];
3663 void * dataTest = new0 byte[dataType.structSize];
3665 ((void (*)(void *, void *))(void *)prop.Get)(control, dataForm);
3666 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
3668 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3670 char tempString[1024] = "";
3672 bool needClass = true;
3676 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3678 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3680 eClass_FindNextMember(_class, curClass, curMember, null, null);
3681 if(*curMember != (DataMember)prop)
3682 f.Printf("%s = ", prop.name);
3684 *curMember = (DataMember)prop;
3685 *curClass = curMember->_class;
3688 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3690 f.Printf("%s", string);
3697 else if(dataType.type == normalClass || dataType.type == noHeadClass)
3699 void * dataForm, * dataTest;
3700 bool isEditBoxContents = false;
3701 bool freeDataForm = false, freeDataTest = false;
3703 // Because contents property is broken for mutiline EditBox at the moment
3704 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
3705 isEditBoxContents = true;
3707 if(isEditBoxContents && ((EditBox)control).multiLine)
3709 dataForm = ((EditBox)control).multiLineContents;
3710 freeDataForm = true;
3713 dataForm = ((void *(*)(void *))(void *)prop.Get)(control);
3714 if(isEditBoxContents && ((EditBox)test).multiLine)
3716 dataTest = ((EditBox)test).multiLineContents;
3717 freeDataTest = true;
3720 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
3722 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
3724 char tempString[1024] = "";
3729 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
3731 eClass_FindNextMember(_class, curClass, curMember, null, null);
3732 if(*curMember != (DataMember)prop)
3733 f.Printf("%s = ", prop.name);
3734 *curMember = (DataMember)prop;
3735 *curClass = curMember->_class;
3737 if(eClass_GetDesigner(dataType))
3739 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
3740 //if(!strcmp(classObject.instance._class.name, dataType.name) && classObject.instance == dataForm)
3741 f.Printf("this", prop.name);
3744 //ObjectInfo classObject;
3745 //for(classObject = classes.first; classObject; classObject = classObject.next)
3749 for(object = classObject.instances.first; object; object = object.next)
3751 if(!object.deleted && eClass_IsDerived(object.instance._class, dataType) && object.instance == dataForm && object.name)
3753 f.Printf("%s", object.name);
3760 bool needClass = true;
3761 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3762 f.Printf("%s", string);
3769 bool needClass = true;
3770 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
3772 if(!strcmp(dataType.dataTypeString, "char *"))
3774 Map<String, bool> i18nStrings = object.i18nStrings;
3776 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
3779 f.Printf("%s\"", i18n ? "$" : "");
3780 OutputString(f, string);
3784 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3786 f.Printf("%s", string);
3789 *lastIsMethod = false;
3792 if(freeDataForm) delete dataForm;
3793 if(freeDataTest) delete dataTest;
3797 DataValue dataForm, dataTest;
3799 GetProperty(prop, control, &dataForm);
3800 GetProperty(prop, test, &dataTest);
3802 if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
3805 char tempString[1024] = "";
3806 SetProperty(prop, test, dataForm);
3808 if(dataType.type != bitClass)
3810 bool needClass = true;
3812 if(dataType.type == enumClass)
3815 Class enumClass = eSystem_FindClass(privateModule, "enum");
3816 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
3818 for(value = e.values.first; value; value = value.next)
3820 if((int)value.data == dataForm.i)
3822 string = value.name;
3828 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
3830 if(string && string[0])
3835 eClass_FindNextMember(_class, curClass, curMember, null, null);
3836 if(*curMember != (DataMember)prop)
3837 f.Printf("%s = ", prop.name);
3838 *curMember = (DataMember)prop;
3839 *curClass = curMember->_class;
3841 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
3842 f.Printf("%sf", string);
3844 f.Printf("%s", string);
3848 else if(dataType.type == bitClass)
3850 bool needClass = true;
3852 if(*prev) f.Printf(", ");
3854 eClass_FindNextMember(_class, curClass, curMember, null, null);
3855 if(*curMember != (DataMember)prop)
3856 f.Printf("%s = ", prop.name);
3857 *curMember = (DataMember)prop;
3858 *curClass = curMember->_class;
3860 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm.ui, tempString, null, &needClass);
3862 f.Printf("%c %s %c", /*dataType.name, */OpenBracket, string, CloseBracket);
3864 f.Printf("%s", string);
3866 *lastIsMethod = false;
3876 int UpdateInstanceCode(EditBoxStream f, int position, Class regClass, ObjectInfo object, bool * firstObject, char ** text, int * textSize, int movedFuncIdLen, int movedFuncIdPos)
3878 Instantiation inst = object.instCode;
3879 Window control = (Window)object.instance;
3881 bool methodPresent = false;
3883 bool lastIsMethod = true;
3884 ObjectInfo classObject = object.oClass;
3890 // Instance removed, delete it
3891 DeleteJunkBefore(f, inst.loc.start.pos, &position);
3893 f.DeleteBytes(inst.loc.end.pos - inst.loc.start.pos + 1);
3894 position = inst.loc.end.pos + 1;
3898 bool multiLine = false;
3901 // Check if it's an unnamed instance
3904 f.Seek(inst.nameLoc.start.pos - position, current);
3905 f.DeleteBytes(inst.nameLoc.end.pos - inst.nameLoc.start.pos);
3906 position = inst.nameLoc.end.pos;
3908 f.Printf(object.name);
3913 if(isspace(ch) && ch != '\n')
3915 f.Seek(-1, current);
3923 int pos = inst.loc.start.pos; // + strlen(inst._class.name);
3925 f.Seek(pos - position, current);
3930 f.Seek(-1, current);
3939 f.Puts(object.name);
3944 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
3945 methodPresent = true;
3953 if(ch == OpenBracket)
3959 // TODO: Simplify this?
3968 f.Seek(-1, current);
3969 DeleteJunkBefore(f, position, &position);
3981 if(ch == '\n') { toDelete = count; count = 0; }
3982 else if(isspace(ch)) count++;
3985 f.Seek(-1, current);
3989 toDelete += count - 6;
3999 f.Seek(-toDelete-count, current);
4000 f.DeleteBytes(toDelete);
4001 f.Seek(count, current);
4004 DeleteJunkBefore(f, position, &position);
4006 // Removed this here as it was adding trailing spaces when adding a method
4011 for(c = 0; c<toAdd; c++)
4018 methodPresent = multiLine;
4020 //if(!prev) -- always false
4021 f.Printf(methodPresent ? "\n " : " ");
4026 // Instance not there, create a brand new one
4027 DeleteJunkBefore(f, position, &position);
4028 f.Printf(*firstObject ? "\n\n" : "\n");
4029 *firstObject = false;
4031 if((this.methodAction == actionAddMethod || this.moveAttached) && this.selected == object)
4032 methodPresent = true;
4037 f.Printf(" %s %s\n %c\n ", control._class.name, object.name, OpenBracket);
4039 f.Printf(" %s\n %c\n ", control._class.name, OpenBracket);
4044 f.Printf(" %s %s %c ", control._class.name, object.name, OpenBracket);
4046 f.Printf(" %s %c ", control._class.name, OpenBracket);
4052 Instance test = eInstance_New(control._class);
4053 DataMember curMember = null;
4054 Class curClass = null;
4057 UpdateInstanceCodeClass(control._class, object, f, test, &prev, &lastIsMethod, &curMember, &curClass);
4061 // Attach Method here
4062 if((this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod) && !this.moveAttached && this.selected == object)
4064 if(prev) f.Printf(", ");
4065 f.Printf("%s = %s", this.method.name, function.declarator.symbol.string);
4070 if(inst && !object.deleted)
4072 MembersInit members;
4073 Class instClass = eSystem_FindClass(this.privateModule, inst._class.name);
4075 DeleteJunkBefore(f, position, &position);
4077 // Instance already there, clear out the properties
4078 for(members = inst.members ? inst.members->first : null; members; members = members.next)
4080 if(members.type == dataMembersInit)
4084 if(members.dataMembers)
4086 bool keptMember = false;
4087 MemberInit lastKept = null;
4089 for(member = members.dataMembers->first; member; member = member.next)
4091 Identifier ident = member.identifiers ? member.identifiers->first : null;
4092 bool deleted = false;
4094 // For now delete if it's not a method
4095 if(!member.variable) // && ident)
4097 if(!ident || !ident.next)
4099 Property prop = ident ? eClass_FindProperty(instClass, ident.string, this.privateModule) : null;
4102 f.Seek(member.loc.start.pos - position, current);
4103 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4104 position = member.loc.end.pos;
4109 Method method = eClass_FindMethod(instClass, ident.string, this.privateModule);
4110 if(method && method.type == virtualMethod && member.initializer && member.initializer.type == expInitializer && member.initializer.exp &&
4111 member.initializer.exp.type == memberExp /*ExpIdentifier*/)
4113 if(((this.methodAction == actionDetachMethod || this.methodAction == actionReattachMethod) && this.method == method && this.selected == object) ||
4114 (this.methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, member.initializer.exp.identifier.string)))
4116 f.Seek(member.loc.start.pos - position, current);
4117 f.DeleteBytes(member.loc.end.pos - member.loc.start.pos);
4118 position = member.loc.end.pos;
4130 //f.Seek(member.loc.start.pos - position, current);
4131 //position = member.loc.start.pos;
4132 DeleteJunkBefore(f, member.loc.start.pos, &position);
4133 if(prev) f.Printf(", ");
4134 else if(keptMember) f.Printf(" ");
4139 if(!keptMember || !members.next)
4144 if(keptMember && lastKept != members.dataMembers->last)
4149 f.Seek(-1, current);
4155 f.Seek(-1, current);
4158 else if(!isspace(ch))
4160 f.Seek(-2, current);
4165 f.DeleteBytes(count);
4168 f.Seek(members.loc.end.pos - position, current);
4173 f.Seek(-1, current);
4175 position = members.loc.end.pos + 1;
4179 f.Seek(-1, current);
4180 position = members.loc.end.pos;
4186 lastIsMethod = false;
4191 DeleteJunkBefore(f, position, &position);
4194 if(lastKept != members.dataMembers->last)
4199 f.Seek(-1, current);
4205 f.Seek(-1, current);
4208 else if(!isspace(ch))
4210 f.Seek(-2, current);
4215 f.DeleteBytes(count);
4219 f.Seek(members.loc.end.pos - position, current);
4220 position = members.loc.end.pos;
4224 lastIsMethod = true;
4227 lastIsMethod = false;
4233 f.Seek(members.loc.end.pos - position, current);
4234 position = members.loc.end.pos;
4236 lastIsMethod = true;
4239 else if(members.type == methodMembersInit)
4241 if(this.methodAction == actionDeleteMethod && members.function == function);
4243 methodPresent = true;
4245 // Delete instance method here
4246 if((this.methodAction == actionDeleteMethod || (this.methodAction == actionDetachMethod && this.moveAttached)) &&
4247 members.function == function)
4249 if(this.moveAttached && !*text)
4250 GetLocText(editBox, f, position, &function.loc, text, textSize, Max((int)strlen(this.methodName) - movedFuncIdLen,0), 0);
4252 DeleteJunkBefore(f, members.loc.start.pos, &position);
4253 f.DeleteBytes(members.loc.end.pos - members.loc.start.pos + 1);
4254 position = members.loc.end.pos + 1;
4259 DeleteJunkBefore(f, position, &position);
4263 DeleteJunkBefore(f, members.loc.start.pos, &position);
4264 lastIsMethod = true;
4268 f.Seek(members.loc.end.pos - position, current);
4269 position = members.loc.end.pos;
4271 DeleteJunkBefore(f, position, &position);
4280 if((this.methodAction == actionAddMethod || (this.moveAttached && (this.methodAction == actionAttachMethod || this.methodAction == actionReattachMethod))) && this.selected == object)
4282 Method method = this.method;
4283 DeleteJunkBefore(f, position, &position);
4289 if(!method.dataType)
4290 method.dataType = ProcessTypeString(method.dataTypeString, false);
4293 Type dataType = method.dataType;
4294 Type returnType = dataType.returnType;
4297 if(this.moveAttached)
4299 // Move function here:
4300 int newLen = strlen(method.name);
4305 GetLocText(editBox, f, position, &function.loc, text, textSize, Max(newLen - movedFuncIdLen, 0), 3);
4307 // First change name of function
4308 memmove(*text + movedFuncIdPos + newLen, *text + movedFuncIdPos + movedFuncIdLen, *textSize - movedFuncIdPos - movedFuncIdLen + 1);
4309 *textSize += newLen - movedFuncIdLen;
4310 memcpy(*text + movedFuncIdPos, method.name, newLen);
4312 // Second, tab right
4315 for(c = 0; (*text)[c]; )
4318 for(i = c; (*text)[i] && (*text)[i] != '\n'; i++);
4321 memmove((*text)+c+3, (*text)+c, *textSize+1-c);
4322 (*text)[c] = (*text)[c+1] = (*text)[c+2] = ' ';
4326 for(; (*text)[c] && (*text)[c] != '\n'; c++);
4336 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4338 // ADDING METHOD HERE
4340 OutputType(f, returnType, false);
4343 if(dataType.thisClass)
4345 if(!eClass_IsDerived(regClass, dataType.thisClass.registered) && !dataType.classObjectType) // Just fixed this... was backwards.
4347 if(dataType.thisClass.shortName)
4348 f.Printf(dataType.thisClass.shortName);
4350 f.Printf(dataType.thisClass.string);
4354 f.Printf(method.name);
4356 for(param = dataType.params.first; param; param = param.next)
4358 OutputType(f, param, true);
4363 f.Printf(" %c\n\n", OpenBracket);
4365 if(control._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4367 if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4368 f.Printf(" return true;\n");
4369 else if(returnType.kind != voidType)
4370 f.Printf(" return 0;\n");
4375 if(returnType.kind != voidType)
4376 f.Printf("return ");
4377 f.Printf("%s::%s(", control._class.name, method.name);
4378 for(param = dataType.params.first; param; param = param.next)
4380 if(param.prev) f.Printf(", ");
4381 if(param.kind != voidType)
4382 f.Printf(param.name);
4386 f.Printf(" %c\n", CloseBracket);
4392 if(!object.instCode)
4393 f.Printf(methodPresent ? " %c;" : "%c;", CloseBracket);
4394 else if(!object.deleted)
4396 // Turn this into a multiline instance when adding a method
4397 DeleteJunkBefore(f, inst.loc.end.pos-1, &position);
4399 f.Printf(methodPresent ? "\n " : " ");
4401 f.Seek(inst.loc.end.pos + 1 - position, current);
4402 position = inst.loc.end.pos + 1;
4407 void OutputClassProperties(Class _class, ObjectInfo classObject, EditBoxStream f, Instance test)
4410 Class regClass = eSystem_FindClass(privateModule, classObject.name);
4412 if(_class.base && _class.base.type != systemClass) OutputClassProperties(_class.base, classObject, f, test);
4414 for(propIt = _class.membersAndProperties.first; propIt; propIt = propIt.next)
4416 Property prop = eClass_FindProperty(selected.instance._class, propIt.name, privateModule);
4417 if(prop && prop.isProperty && !prop.conversion)
4419 if(prop.Set && prop.Get && prop.dataTypeString && strcmp(prop.name, "name") && !Code_IsPropertyDisabled(classObject, prop.name) &&
4420 (!prop.IsSet || prop.IsSet(classObject.instance)))
4422 Class dataType = prop.dataTypeClass;
4423 char tempString[1024] = "";
4425 bool specify = false;
4428 member = eClass_FindDataMember(regClass, prop.name, privateModule, null, null);
4429 if(member && member._class == regClass)
4433 dataType = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
4435 if(dataType && dataType.type == structClass)
4437 void * dataForm = new0 byte[dataType.structSize];
4438 void * dataTest = new0 byte[dataType.structSize];
4440 ((void (*)(void *, void *))(void *)prop.Get)(classObject.instance, dataForm);
4441 ((void (*)(void *, void *))(void *)prop.Get)(test, dataTest);
4443 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4445 bool needClass = true;
4447 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4448 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4450 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4452 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4457 else if(dataType && (dataType.type == normalClass || dataType.type == noHeadClass))
4459 void * dataForm, * dataTest;
4460 bool isEditBoxContents = false;
4461 bool freeDataForm = false, freeDataTest = false;
4463 // Because contents property is broken for mutiline EditBox at the moment
4464 if(!strcmp(prop.name, "contents") && !strcmp(prop._class.name, "EditBox"))
4465 isEditBoxContents = true;
4467 if(isEditBoxContents && ((EditBox)classObject.instance).multiLine)
4469 dataForm = ((EditBox)classObject.instance).multiLineContents;
4470 freeDataForm = true;
4473 dataForm = ((void *(*)(void *))(void *)prop.Get)(classObject.instance);
4474 if(isEditBoxContents && ((EditBox)test).multiLine)
4476 dataTest = ((EditBox)test).multiLineContents;
4477 freeDataTest = true;
4480 dataTest = ((void *(*)(void *))(void *)prop.Get)(test);
4482 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
4484 char tempString[1024] = "";
4486 ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
4488 if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
4490 // Shouldn't go here ...
4491 f.Printf("\n %s%s = this;", specify ? "property::" : "", prop.name);
4495 bool needClass = true;
4497 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, dataForm, tempString, null, &needClass);
4499 if(!strcmp(dataType.dataTypeString, "char *"))
4501 Map<String, bool> i18nStrings = classObject.i18nStrings;
4503 if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
4506 f.Printf("\n %s%s = %s\"", specify ? "property::" : "", prop.name, i18n ? "$" : "");
4507 OutputString(f, string);
4511 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4513 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4516 if(freeDataForm) delete dataForm;
4517 if(freeDataTest) delete dataTest;
4521 DataValue dataForm, dataTest;
4523 GetProperty(prop, classObject.instance, &dataForm);
4524 GetProperty(prop, test, &dataTest);
4526 if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
4528 SetProperty(prop, test, dataForm);
4529 if(dataType.type == bitClass)
4531 bool needClass = true;
4532 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4534 f.Printf("\n %s%s = %c %s %c;", specify ? "property::" : "", prop.name, /*dataType.name, */OpenBracket, string, CloseBracket);
4536 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4540 bool needClass = true;
4541 if(dataType.type == enumClass)
4544 Class enumClass = eSystem_FindClass(privateModule, "enum");
4545 EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
4547 for(value = e.values.first; value; value = value.next)
4549 if((int)value.data == dataForm.i)
4551 string = value.name;
4557 string = ((char * (*)(void *, void *, void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetString])(dataType, &dataForm, tempString, null, &needClass);
4558 if(!strcmp(dataType.dataTypeString, "float") && strchr(string, '.'))
4559 f.Printf("\n %s%s = %sf;", specify ? "property::" : "", prop.name, string);
4561 f.Printf("\n %s%s = %s;", specify ? "property::" : "", prop.name, string);
4570 void UpdateFormCode()
4573 if(!parsing) return;
4580 else if(formModified)
4582 EditBoxStream f { editBox = editBox };
4586 Identifier movedFuncId;
4587 int movedFuncIdLen = 0, movedFuncIdPos = 0;
4588 ObjectInfo classObject;
4592 editBox.recordUndoEvent = true;
4596 movedFuncId = GetDeclId(function.declarator);
4597 movedFuncIdLen = movedFuncId.loc.end.pos - movedFuncId.loc.start.pos;
4598 movedFuncIdPos = movedFuncId.loc.start.pos - function.loc.start.pos;
4601 for(classObject = classes.first; classObject; classObject = classObject.next)
4604 ClassDefinition classDef = classObject.classDefinition;
4605 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
4608 bool firstObject = true;
4609 ObjectInfo object = classObject.instances.first;
4610 bool lastIsDecl = false;
4612 if(!classObject.modified) continue;
4614 test = eInstance_New(regClass);
4617 // Put it in the same desktop window...
4618 designer.PrepareTestObject(test);
4620 //f.Printf("class %s : %s\n", classObject.name, classObject.oClass.name);
4621 //f.Printf("%c\n\n", OpenBracket);
4623 // Change the _class name
4624 f.Seek(classDef.nameLoc.start.pos - position, current);
4625 f.DeleteBytes(classDef.nameLoc.end.pos - classDef.nameLoc.start.pos);
4626 f.Printf(classObject.name);
4627 position = classDef.nameLoc.end.pos;
4630 // Go to block start, delete all until no white space, put \n
4634 f.Seek(classDef.blockStart.end.pos - position, current);
4635 position = classDef.blockStart.end.pos;
4637 for(; f.Getc(&ch); count++)
4641 f.Seek(-1, current);
4651 f.Seek(-count, current);
4653 f.DeleteBytes(count-back);
4655 position += count-back;
4658 // Output properties
4659 OutputClassProperties(classObject.instance._class, classObject, f, test);
4661 for(def = classDef.definitions->first; def; def = def.next)
4665 case defaultPropertiesClassDef:
4667 bool keptMember = false;
4669 MemberInit lastKept = null;
4672 DeleteJunkBefore(f, def.loc.start.pos, &position);
4674 // This was adding blank spaces between comment and properties -- What was it for?
4677 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
4679 Identifier ident = propDef.identifiers->first;
4680 bool deleted = false;
4682 // For now delete if it's a prop
4683 if(!propDef.variable && ident)
4687 Property prop = eClass_FindProperty(regClass, ident.string, this.privateModule);
4690 f.Seek(propDef.loc.start.pos - position, current);
4691 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4692 position = propDef.loc.end.pos;
4697 Method method = eClass_FindMethod(regClass, ident.string, this.privateModule);
4698 if(method && method.type == virtualMethod && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
4700 if(((methodAction == actionDetachMethod || methodAction == actionReattachMethod) && method == this.method && selected == classObject) ||
4701 (methodAction == actionDeleteMethod && !strcmp(function.declarator.symbol.string, propDef.initializer.exp.identifier.string)))
4703 f.Seek(propDef.loc.start.pos - position, current);
4704 f.DeleteBytes(propDef.loc.end.pos - propDef.loc.start.pos);
4705 position = propDef.loc.end.pos;
4723 f.Seek(def.loc.end.pos - position - 1, current);
4728 f.Seek(-1, current);
4731 position = def.loc.end.pos;
4735 if(lastKept != def.defProperties->last)
4740 f.Seek(-1, current);
4746 f.Seek(-1, current);
4749 else if(!isspace(ch))
4751 f.Seek(-2, current);
4756 f.DeleteBytes(count);
4760 f.Seek(def.loc.end.pos - position, current);
4761 position = def.loc.end.pos;
4766 case declarationClassDef:
4768 Declaration decl = def.decl;
4770 if(decl.type == instDeclaration)
4772 if(def.object/* && ((ObjectInfo)def.object).modified*/)
4774 while(def.object && object != def.object)
4776 if(object /*&& ((ObjectInfo)def.object).modified*/)
4777 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4778 object = object.next;
4781 DeleteJunkBefore(f, def.loc.start.pos, &position);
4782 f.Printf(firstObject ? "\n\n " : "\n ");
4783 firstObject = false;
4785 if(def.object && ((ObjectInfo)def.object).modified)
4786 position = UpdateInstanceCode(f, position, regClass, def.object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4788 object = object ? object.next : null;
4792 DeleteJunkBefore(f, def.loc.start.pos, &position);
4793 f.Printf(firstObject ? "\n\n " : "\n ");
4794 firstObject = false;
4800 DeleteJunkBefore(f, def.loc.start.pos, &position);
4801 f.Printf(lastIsDecl ? "\n " : "\n\n ");
4806 case functionClassDef:
4808 // TESTING IF THIS IS GOOD ENOUGH FOR GENERATED FUNCTION...
4809 if(!def.function.body) continue;
4813 DeleteJunkBefore(f, def.loc.start.pos, &position);
4816 // Delete _class methods
4817 if((methodAction == actionDeleteMethod || (moveAttached && selected != classObject)) &&
4818 def.function == function)
4823 if(moveAttached && !text)
4825 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max((int)strlen(methodName) - movedFuncIdLen,0), 3);
4828 f.Seek(def.loc.end.pos - position, current);
4829 for(; f.Getc(&ch); count++)
4833 f.Seek(-1, current);
4837 f.Seek(def.loc.start.pos - def.loc.end.pos - count, current);
4839 f.DeleteBytes(def.loc.end.pos - def.loc.start.pos + count);
4840 position = def.loc.end.pos + count;
4843 // In case of detaching methods in the _class, simply rename the method
4844 if(methodAction == actionDetachMethod && moveAttached && selected == classObject && function == def.function)
4846 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4847 f.DeleteBytes(movedFuncIdLen);
4849 position = function.loc.start.pos + movedFuncIdPos + movedFuncIdLen;
4852 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && moveAttached &&
4853 function == def.function)
4855 // In case of attaching methods in the _class, simply rename the method
4856 f.Seek(function.loc.start.pos + movedFuncIdPos - position, current);
4857 position = function.loc.start.pos + movedFuncIdPos;
4858 f.DeleteBytes(movedFuncIdLen);
4859 if(method.dataType.thisClass)
4860 f.Printf("%s::", method.dataType.thisClass.string);
4861 f.Puts(method.name);
4862 position += movedFuncIdLen;
4867 DeleteJunkBefore(f, def.loc.start.pos, &position);
4868 if(def.type == memberAccessClassDef)
4871 firstObject = false;
4881 f.Seek(def.loc.end.pos - position, current);
4882 position = def.loc.end.pos;
4885 // Output attached methods
4886 if((methodAction == actionAttachMethod || methodAction == actionReattachMethod) && selected == classObject && !moveAttached)
4888 DeleteJunkBefore(f, position, &position);
4889 f.Printf("\n %s = %s;\n", method.name, function.declarator.symbol.string);
4892 // ********** INSTANCES ***************
4893 for(; object; object = object.next)
4895 if(!object.instCode)
4897 position = UpdateInstanceCode(f, position, regClass, object, &firstObject, &text, &textSize, movedFuncIdLen, movedFuncIdPos);
4901 DeleteJunkBefore(f, position, &position);
4903 // ****************** METHODS ***********************
4904 if(methodAction == actionDetachMethod && moveAttached && classObject == oClass)
4906 // If detaching an instance method
4907 if(selected != classObject)
4909 int newLen = strlen(methodName);
4912 GetLocText(editBox, f, position, &function.loc, &text, &textSize, Max(newLen - movedFuncIdLen,0), 0);
4913 // Tab selection left
4916 for(c = 0; text[c]; )
4919 for(i = 0; i<3 && text[c] == ' '; i++, c++);
4920 memmove(text+start, text+start+i, textSize+1-start-i);
4923 for(; text[c] && text[c] != '\n'; c++);
4929 memmove(text + movedFuncIdPos + newLen, text + movedFuncIdPos + movedFuncIdLen, textSize - movedFuncIdPos - movedFuncIdLen + 1);
4930 textSize += newLen - movedFuncIdLen;
4931 memcpy(text + movedFuncIdPos, methodName, newLen);
4938 if(methodAction == actionAddMethod && selected == classObject)
4940 Method method = this.method;
4942 if(!method.dataType)
4943 method.dataType = ProcessTypeString(method.dataTypeString, false);
4945 // ADDING METHOD HERE
4947 Type dataType = method.dataType;
4948 Type returnType = dataType.returnType;
4950 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
4954 OutputType(f, returnType, false);
4957 if(dataType.thisClass && !dataType.classObjectType)
4959 if(dataType.thisClass.shortName)
4960 f.Printf(dataType.thisClass.shortName);
4962 f.Printf(dataType.thisClass.string);
4965 f.Printf(method.name);
4967 for(param = dataType.params.first; param; param = param.next)
4969 OutputType(f, param, true);
4974 f.Printf(" %c\n\n", OpenBracket);
4976 if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
4978 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
4979 f.Printf(" return true;\n");
4980 else if(returnType && returnType.kind != voidType)
4981 f.Printf(" return 0;\n");
4986 if(returnType.kind != voidType)
4987 f.Printf("return ");
4989 char * name = ((Specifier)classDef.baseSpecs->first).name;
4990 Symbol _class = FindClass(name);
4991 f.Printf("%s::%s(", (_class && _class.registered) ? _class.registered.name : name, method.name);
4993 for(param = dataType.params.first; param; param = param.next)
4995 if(param.prev) f.Printf(", ");
4996 if(param.kind != voidType)
4997 f.Printf(param.name);
5002 f.Printf(" %c", CloseBracket);
5006 DeleteJunkBefore(f, classDef.loc.end.pos-1, &position);
5012 editBox.recordUndoEvent = false;
5020 // TOFIX: Patch for a glitch where clicking at the end of the view seems one line off. No idea what could be going on?
5021 editBox.OnVScroll(setRange, editBox.scroll.y, 0);
5025 codeModified = false;
5026 formModified = false;
5028 moveAttached = false;
5033 int FindMethod(char * methodName /*Method method*/, ClassFunction*functionPtr, Location propLoc)
5036 ClassFunction function = null;
5039 ObjectInfo object = this.selected;
5041 if(object && object == this.oClass)
5043 ClassDefinition classDef = object.oClass.classDefinition;
5045 if(classDef && classDef.definitions)
5047 for(def = classDef.definitions->first; def; def = def.next)
5049 if(def.type == functionClassDef && def.function.declarator)
5051 if(!strcmp(def.function.declarator.symbol.string, methodName))
5053 function = def.function;
5058 else if(def.type == defaultPropertiesClassDef)
5062 for(propDef = def.defProperties->first; propDef; propDef = propDef.next)
5064 Identifier ident = propDef.identifiers ? propDef.identifiers->first : null;
5065 if(ident && !ident.next)
5067 if(!strcmp(ident.string, methodName) && propDef.initializer && propDef.initializer.type == expInitializer && propDef.initializer.exp && propDef.initializer.exp.type == identifierExp)
5071 propLoc = propDef.loc;
5074 ClassDefinition classDef = object.oClass.classDefinition;
5076 if(classDef.definitions)
5078 for(def = classDef.definitions->first; def; def = def.next)
5080 if(def.type == functionClassDef)
5082 if(!strcmp(def.function.declarator.symbol.string, propDef.initializer.exp.identifier.string))
5084 function = def.function;
5103 Instantiation inst = object.instCode;
5105 // Check here to see if the method already exists, no need to call ModifyCode in that case
5106 if(inst && inst.members)
5108 MembersInit members;
5109 for(members = inst.members->first; members; members = members.next)
5111 switch(members.type)
5113 case dataMembersInit:
5115 if(members.dataMembers)
5118 for(member = members.dataMembers->first; member; member = member.next)
5120 Identifier ident = member.identifiers ? member.identifiers->first : null;
5121 if(ident && !ident.next)
5123 if(!strcmp(ident.string, methodName) && member.initializer && member.initializer.type == expInitializer && member.initializer.exp && member.initializer.exp.type == memberExp /*ExpIdentifier*/)
5127 propLoc = member.loc;
5130 ClassDefinition classDef = object.oClass.classDefinition;
5132 if(classDef.definitions)
5134 for(def = classDef.definitions->first; def; def = def.next)
5136 if(def.type == functionClassDef)
5138 if(def.function.declarator && !strcmp(def.function.declarator.symbol.string, member.initializer.exp.identifier.string))
5140 function = def.function;
5149 // TODO: Fix memory leak
5150 function = ClassFunction
5152 declarator = Declarator { symbol = Symbol { string = CopyString(member.initializer.exp.member.member ? member.initializer.exp.member.member.string : "") } }
5164 case methodMembersInit:
5166 if(members.function.declarator && !strcmp(members.function.declarator.symbol.string, methodName))
5168 function = members.function;
5180 if(functionPtr) *functionPtr = function;
5184 void GoToMethod(char * methodName /*Method method*/)
5188 ObjectInfo object = selected;
5189 EditBoxStream f { editBox = editBox };
5190 ClassFunction function = null;
5191 bool atChar = false;
5195 Location propLoc = { {0,0,-1} };
5198 if(FindMethod(methodName, &function, &propLoc) == 1 && object != this.oClass) indent = 9;
5199 if(function && function.body)
5202 f.Seek(function.body.loc.start.pos+1, current);
5212 f.Seek(-1, current);
5217 else if(!isspace(ch))
5219 f.Seek(-1, current);
5225 else if(propLoc.start.pos > -1)
5227 f.Seek(propLoc.start.pos, current);
5230 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
5232 if(function || propLoc.start.pos > -1)
5234 editBox.SetSelPos(l1, y1, atChar ? x1 : indent, l2, y2, atChar ? x2 : indent);
5235 editBox.CenterOnCursor();
5236 SetState(normal, false, 0);
5239 if(function && function.declarator && function.declarator.symbol && !function.declarator.symbol.type)
5241 FreeClassFunction(function);
5247 void FindCompatibleMethods(Method method, OldList compatible)
5249 ClassDefinition classDef = this.oClass.classDefinition;
5250 if(classDef && classDef.definitions)
5253 Class baseClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5256 Symbol classSym { };
5257 Symbol selectedClass;
5258 if(this.selected == this.oClass)
5259 selectedClass = classSym;
5261 selectedClass = FindClass(this.selected.instance._class.name);
5263 regClass.name = classDef._class.name;
5264 regClass.base = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
5265 for(def = classDef.definitions->first; def; def = def.next)
5267 if(def.type == functionClassDef && def.function.declarator)
5269 Method vMethod = eClass_FindMethod(baseClass, def.function.declarator.symbol.string, this.privateModule);
5271 vMethod = eClass_FindMethod(this.selected.instance._class, def.function.declarator.symbol.string, this.privateModule);
5274 Type type = def.function.declarator.symbol.type;
5275 if(CheckCompatibleMethod(method, type, regClass, this.selected == this.oClass, FindClass(this.selected.instance._class.name)))
5277 compatible.Add(OldLink { data = def.function });
5283 if(this.oClass && this.oClass.instance)
5285 classSym.registered = regClass;
5286 //classSym.registered = this.oClass.oClass;
5288 for(_class = regClass.base; _class; _class = _class.base)
5291 for(testMethod = (Method)_class.methods.first; testMethod; testMethod = (Method)((BTNode)testMethod).next)
5293 // TODO: Understand why these functions popup in attach list
5294 if(testMethod.type != virtualMethod /*&& testMethod.function != Window_OnGetString && testMethod.function != Window_OnGetDataFromString*/)
5296 if(!testMethod.dataType)
5297 testMethod.dataType = ProcessTypeString(testMethod.dataTypeString, false);
5299 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5300 if(CheckCompatibleMethod(method, testMethod.dataType, this.oClass.instance._class, false, selectedClass)) // this.selected == this.oClass, selectedClass))
5301 //if(CheckCompatibleMethod(method, testMethod.dataType, ®Class, this.selected == this.oClass, FindClass(this.oClass.oClass.name)))
5303 // TODO: Fix memory leak, Figure out if it should be ClassFunction or FunctionDefinition
5304 // ClassFunction function { };
5305 FunctionDefinition function { };
5307 function.declarator = Declarator { };
5308 function.declarator.symbol = Symbol { string = CopyString(testMethod.name) };
5309 excludedSymbols.Add(function.declarator.symbol);
5311 compatible.Add(OldLink { data = function });
5322 void AddMethod(Method method)
5326 char methodName[1024];
5327 strcpy(methodName, method.name);
5328 if(!FindMethod(methodName, null, null))
5330 methodAction = actionAddMethod;
5331 this.method = method;
5335 GoToMethod(methodName);
5339 void DeleteMethod(ClassFunction function)
5343 methodAction = actionDeleteMethod;
5344 this.function = function;
5352 void AttachMethod(Method method, ClassFunction function)
5356 // If it's an instance we'll ask if we want to move it inside...
5357 if(!function.attached.count && function.body)
5359 // Find the function in the _class to check if it's a virtual function
5360 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5361 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5362 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5364 for(def = this.classDefinition.first; def; def = def.next)
5366 if(def.type == functionClassDef)
5368 if(def.function == function)
5373 if(!method || method.type != virtualMethod)
5376 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5377 if(MessageBox { type = yesNo, master = parent, text = title, contents = $"Method is unused. Move method inside instance?"}.Modal() == yes)
5379 moveAttached = true;
5384 methodAction = actionAttachMethod;
5385 this.method = method;
5386 this.function = function;
5393 void ReAttachMethod(Method method, ClassFunction function)
5397 // If it's an instance we'll ask if we want to move it inside...
5398 if(!function.attached.count && function.body)
5400 // Find the function in the _class to check if it's a virtual function
5401 Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)this.oClass.classDefinition.baseSpecs->first).name);
5402 Method method = eClass_FindMethod(regClass, function.declarator.symbol.string, this.privateModule);
5403 /* LATER we'll need to check for public/virtual properties etc, for now only checked if virtual in base _class
5405 for(def = this.classDefinition.first; def; def = def.next)
5407 if(def.type == functionClassDef)
5409 if(def.function == function)
5414 if(!method || method.type != virtualMethod)
5417 sprintf(title, $"Attach %s", function.declarator.symbol.string);
5418 if(MessageBox { type = yesNo, master = parent, text = title,
5419 contents = $"Method is unused. Move method inside instance?" }.Modal() == yes)
5421 moveAttached = true;
5426 methodAction = actionReattachMethod;
5427 this.method = method;
5428 this.function = function;
5435 void DetachMethod(Method method, ClassFunction function, int type)
5443 hasClose = true, borderStyle = sizable, minClientSize = { 300, 55 },
5444 master = sheet, text = $"Name detached method", background = formColor
5448 dialog, anchor = { horz = 45, top = 30 }, size = { 80 }, text = $"Cancel", hotKey = escape,
5449 id = DialogResult::cancel, NotifyClicked = ButtonCloseDialog
5453 dialog, anchor = { horz = -45, top = 30 }, size = { 80 }, text = $"OK", isDefault = true,
5454 id = DialogResult::ok, NotifyClicked = ButtonCloseDialog
5458 dialog, anchor = { left = 5, right = 5, top = 5 }
5460 sprintf(methodName, "%s_%s", selected.name, method.name);
5461 nameBox.contents = methodName;
5463 result = dialog.Modal() == ok;
5464 strcpy(methodName, nameBox.contents);
5469 // If the method is not attached, move it outside
5472 // Add this class to the methodName
5473 char name[1024] = "";
5475 if(this.selected != this.oClass && !method.dataType.thisClass)
5477 strcat(name, this.selected.instance._class.name);
5479 strcat(name, this.methodName);
5480 strcpy(this.methodName, name);
5482 else if(method.dataType.thisClass && (this.selected == this.oClass || !eClass_IsDerived(this.oClass.instance._class, method.dataType.thisClass.registered)))
5484 strcat(name, method.dataType.thisClass.string);
5486 strcat(name, this.methodName);
5487 strcpy(this.methodName, name);
5490 this.moveAttached = true;
5493 this.methodAction = actionDetachMethod;
5494 this.method = method;
5495 this.function = function;
5502 void AddObject(Instance instance, ObjectInfo * object)
5506 //*object = _class.instances.Add(sizeof(ObjectInfo));
5507 *object = ObjectInfo { };
5508 oClass.instances.Insert((selected.oClass == selected) ? null : selected, *object);
5509 (*object).oClass = oClass;
5510 (*object).instance = instance;
5515 sprintf(name, "%c%s%d", tolower(instance._class.name[0]), instance._class.name+1, id);
5517 // if(strcmp(name, this.oClass.instance.name))
5520 for(check = oClass.instances.first; check; check = check.next)
5521 if(!check.deleted && check.name && !strcmp(name, check.name))
5525 (*object).name = CopyString(name);
5530 toolBox.controlClass = null;
5534 //sheet.AddObject(*object, (*object).name, TypeData, true);
5539 void EnsureUpToDate()
5541 if(sheet && codeModified && parsing)
5545 void SelectObject(ObjectInfo object)
5548 oClass = object ? object.oClass : null;
5550 designer.SelectObject(object, object ? object.instance : null);
5553 void SelectObjectFromDesigner(ObjectInfo object)
5556 sheet.SelectObject(object);
5559 void EnumerateObjects(Sheet sheet)
5563 for(oClass = classes.first; oClass; oClass = oClass.next)
5569 sheet.AddObject(oClass, oClass.name ? oClass.name : oClass.instance._class.name, typeClass, false);
5570 for(object = oClass.instances.first; object; object = object.next)
5571 sheet.AddObject(object, object.name ? object.name : object.instance._class.name, typeData, false);
5574 sheet.SelectObject(selected);
5579 designer.AddObject();
5582 void DeleteObject(ObjectInfo object)
5584 delete object.instance;
5585 object.deleted = true;
5586 object.modified = true;
5587 object.oClass.modified = true;
5589 if(selected == object)
5591 bool looped = false;
5592 ObjectInfo select = object;
5596 select = select.prev;
5600 select = object.oClass.instances.last;
5607 sheet.SelectObject(select ? select : oClass);
5610 if(!object.instCode && object.oClass != object)
5613 oClass.instances.Delete(object);
5616 if(sheet.codeEditor == this)
5617 sheet.DeleteObject(object);
5620 void RenameObject(ObjectInfo object, char * name)
5624 // Validate the name:
5625 if(object != oClass && (!name || !name[0])) valid = true; // What's this one again?
5626 else if(name[0] && (isalpha(name[0]) || name[0] == '_'))
5629 for(c = 0; name[c]; c++)
5630 if(!isalnum(name[c]) && name[c] != '_' && name[c] != '_')
5638 object.name = (name && name[0]) ? CopyString(name) : null;
5640 sheet.RenameObject(object, object.name ? object.name : object.instance._class.name);
5644 void DesignerModifiedObject()
5646 sheet.ListProperties(false);
5650 void ListSubMembers(Type member)
5654 for(subMember = member.members.first; subMember; subMember = subMember.next)
5658 DataRow row = membersList.AddString(subMember.name);
5659 row.icon = icons[typeData];
5663 ListSubMembers(subMember);
5668 void ListSubDataMembers(DataMember member, bool isPrivate)
5670 DataMember subMember;
5671 for(subMember = member.members.first; subMember; subMember = subMember.next)
5673 if((subMember.memberAccess == publicAccess && !isPrivate) || subMember._class.module == privateModule)
5677 DataRow row = membersList.AddString(subMember.name);
5678 BitmapResource bitmap = null;
5679 if(!subMember.dataType)
5680 subMember.dataType = ProcessTypeString(subMember.dataTypeString, false);
5682 if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
5684 char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
5687 bitmap = { bitmapName };
5688 membersList.AddResource(bitmap);
5691 row.icon = bitmap ? bitmap : icons[(subMember.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5695 ListSubDataMembers(subMember, isPrivate || member.memberAccess == privateAccess);
5701 void ListClassMembers(Class whatClass, bool methodsOnly)
5704 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5705 bool isPrivate = false;
5707 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5709 Method method, methodIt;
5711 DataMember memberIt;
5713 for(methodIt = (Method)_class.methods.first; methodIt; methodIt = (Method)((BTNode)methodIt).next)
5715 method = eClass_FindMethod(whatClass, methodIt.name, privateModule);
5716 if(methodIt.memberAccess == privateAccess && method && method.memberAccess == publicAccess)
5718 if(method && method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5720 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5722 DataRow row = membersList.FindString(method.name);
5725 row = membersList.AddString(method.name);
5727 if(!method.dataType)
5728 method.dataType = ProcessTypeString(method.dataTypeString, false);
5730 row.icon = icons[(method.type == virtualMethod && method.dataType && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5738 for(memberIt = _class.membersAndProperties.first; memberIt; memberIt = memberIt.next)
5742 if(memberIt.isProperty)
5744 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5746 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5750 member = eClass_FindDataMember(whatClass, memberIt.name, privateModule, null, null);
5752 member = (DataMember)eClass_FindProperty(whatClass, memberIt.name, privateModule);
5755 if(memberIt.memberAccess == privateAccess && member && member.memberAccess == publicAccess)
5761 if(member && (member.memberAccess == publicAccess || member._class.module == privateModule))
5763 if(member.isProperty)
5765 Property prop = (Property) member;
5766 if(!membersList.FindString(prop.name))
5768 DataRow row = membersList.AddString(prop.name);
5769 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5772 else if(member.name && !membersList.FindString(member.name))
5774 DataRow row = membersList.AddString(member.name);
5776 BitmapResource bitmap = null;
5777 if(!member.dataType)
5778 member.dataType = ProcessTypeString(member.dataTypeString, false);
5780 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5782 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5785 bitmap = { bitmapName };
5786 membersList.AddResource(bitmap);
5789 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5792 ListSubDataMembers(member, member.memberAccess == privateAccess);
5796 if(_class.inheritanceAccess == privateAccess)
5799 if(_class.module != privateModule) break;
5804 void ListClassMembersMatch(Class whatClass, Type methodType)
5807 Class baseClass = eSystem_FindClass(this.privateModule, "class");
5808 bool isPrivate = false;
5810 for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
5816 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5818 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5820 if(method._class.type != systemClass && !eClass_FindMethod(baseClass, method.name, this.privateModule))
5822 if(!method.dataType)
5823 method.dataType = ProcessTypeString(method.dataTypeString, false);
5825 if(MatchTypes(method.dataType, methodType, null, whatClass, /*null, */whatClass, false, true, false, false))
5827 DataRow row = membersList.FindString(method.name);
5830 row = membersList.AddString(method.name);
5831 row.icon = icons[(method.type == virtualMethod && method.dataType.thisClass) ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5837 if(_class.inheritanceAccess == privateAccess)
5840 if(_class.module != privateModule) break;
5845 void ListClassPropertiesAndVirtual(Class whatClass, String curString)
5848 bool isPrivate = false;
5849 for(_class = whatClass; _class /*&& _class.type != systemClass*/; _class = _class.base)
5855 for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
5857 if(method.type == virtualMethod)
5859 if(method.memberAccess == publicAccess || method._class.module == privateModule)
5861 DataRow row = membersList.FindString(method.name);
5864 row = membersList.AddString(method.name);
5866 if(!method.dataType)
5867 method.dataType = ProcessTypeString(method.dataTypeString, false);
5869 row.icon = icons[method.dataType.thisClass ? typeEvent : ((method.memberAccess == publicAccess && !isPrivate) ? typeMethod : typeMethodPrivate)];
5875 for(member = _class.membersAndProperties.first; member; member = member.next)
5877 if(member.memberAccess == publicAccess || member._class.module == privateModule)
5879 if(member.isProperty)
5881 Property prop = (Property)member;
5883 DataRow row = membersList.AddString(prop.name);
5884 row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
5887 else if(member.name && (!curString || strcmp(curString, member.name)))
5889 DataRow row = membersList.AddString(member.name);
5891 BitmapResource bitmap = null;
5892 if(!member.dataType)
5893 member.dataType = ProcessTypeString(member.dataTypeString, false);
5895 if(member.dataType && member.dataType.kind == classType && member.dataType._class)
5897 char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
5900 bitmap = { bitmapName };
5901 membersList.AddResource(bitmap);
5904 row.icon = bitmap ? bitmap : icons[(member.memberAccess == publicAccess && !isPrivate) ? typeData : typeDataPrivate];
5907 ListSubDataMembers(member, member.memberAccess == privateAccess || isPrivate);
5910 if(_class.inheritanceAccess == privateAccess)
5913 if(_class.module != privateModule) break;
5918 void ListMembers(Type type)
5920 if(type && (type.kind == classType || type.kind == structType || type.kind == unionType))
5924 if(type.kind == classType)
5927 ListClassMembers(type._class.registered, false);
5932 for(member = type.members.first; member; member = member.next)
5936 DataRow row = membersList.AddString(member.name);
5937 row.icon = icons[typeData];
5939 else if(member.kind == structType || member.kind == unionType)
5940 ListSubMembers(member);
5946 void ListModule(Module mainModule, int recurse, bool listClasses)
5949 ListNameSpace(mainModule.application.systemNameSpace, 1, listClasses);
5950 ListNameSpace(mainModule.application.privateNameSpace, 1, listClasses);
5951 ListNameSpace(mainModule.application.publicNameSpace, 1, listClasses);
5952 for(module = mainModule.application.allModules.first; module; module = module.next)
5954 if(ModuleVisibility(mainModule, module))
5955 ListNameSpace(module.publicNameSpace, recurse, listClasses);
5959 void ListNameSpace(NameSpace nameSpace, int recurse, bool listClasses)
5966 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
5968 Class _class = link.data;
5969 if(_class.type != systemClass && !_class.templateClass) // Omit templatized classes
5971 DataRow row = membersList.AddString(_class.name);
5972 row.icon = (_class.type == unitClass || _class.type == enumClass) ? icons[typeDataType] : icons[typeClass];
5977 for(link = (BTNamedLink)nameSpace.defines.first; link; link = (BTNamedLink)((BTNode)link).next )
5979 DefinedExpression definedExp = link.data;
5980 DataRow row = membersList.AddString(link /*definedExp*/.name);
5981 row.icon = icons[typeData];
5984 for(link = (BTNamedLink)nameSpace.functions.first; link; link = (BTNamedLink)((BTNode)link).next)
5986 GlobalFunction function = link.data;
5987 DataRow row = membersList.AddString(link /*function*/.name);
5988 row.icon = icons[typeMethod];
5992 for(ns = (NameSpace *)nameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
5994 if(recurse != 2 && listClasses)
5996 if(!membersList.FindString(ns->name))
5998 DataRow row = membersList.AddString(ns->name);
5999 row.icon = icons[typeNameSpace];
6004 ListNameSpace(ns, 2, listClasses);
6008 void ListEnumValues(Class _class)
6010 List<Class> classes { };
6011 for(; _class && _class.type == enumClass; _class = _class.base)
6012 classes.Insert(null, _class);
6013 for(_class : classes)
6015 EnumClassData enumeration = (EnumClassData)_class.data;
6017 for(item = enumeration.values.first; item; item = item.next)
6019 DataRow row = membersList.AddString(item.name);
6020 row.icon = icons[typeEnumValue];
6026 bool ListEnumsModule(Module mainModule, Type dest)
6028 bool result = false;
6030 result |= ListEnums(mainModule.application.systemNameSpace, dest);
6031 result |= ListEnums(mainModule.application.privateNameSpace, dest);
6032 result |= ListEnums(mainModule.application.publicNameSpace, dest);
6033 for(module = mainModule.application.allModules.first; module; module = module.next)
6035 if(ModuleVisibility(mainModule, module))
6036 result |= ListEnums(module.publicNameSpace, dest);
6041 void ListNameSpaceByString(Module mainModule, char * string)
6043 NameSpace * nameSpace;
6045 nameSpace = FindNameSpace(mainModule.application.systemNameSpace, string);
6046 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6047 nameSpace = FindNameSpace(mainModule.application.privateNameSpace, string);
6048 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6049 nameSpace = FindNameSpace(mainModule.application.publicNameSpace, string);
6050 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6051 for(module = mainModule.application.allModules.first; module; module = module.next)
6053 if(ModuleVisibility(mainModule, module))
6055 nameSpace = FindNameSpace(module.publicNameSpace, string);
6056 if(nameSpace) ListNameSpace(nameSpace, 0, true);
6061 bool ListEnums(NameSpace nameSpace, Type dest)
6064 bool result = false;
6066 for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
6068 Class _class = link.data;
6069 if(_class.type == enumClass && (dest.kind != classType || ((!dest._class || !dest._class.registered || (dest._class.registered != _class && strcmp(dest._class.registered.dataTypeString, "char *"))) && !dest.classObjectType)) &&
6070 dest.kind != pointerType && dest.kind != ellipsisType)
6072 OldList conversions { };
6074 type.kind = classType;
6075 type._class = FindClass(_class.name);
6076 if(MatchTypes(type, dest, &conversions, null, null, true, false, false, false))
6078 ListEnumValues(_class);
6081 conversions.Free(null);
6085 for(nameSpace = (NameSpace *)nameSpace.nameSpaces.first; nameSpace != null; nameSpace = (NameSpace *)((BTNode)nameSpace).next)
6087 result |= ListEnums(nameSpace, dest);
6092 NameSpace * FindNameSpace(NameSpace nameSpace, char * name)
6096 for(c = 0; (ch = name[c]); c++)
6098 if(ch == '.' || (ch == ':' && name[c+1] == ':'))
6100 NameSpace * newSpace;
6101 char * spaceName = new char[c - start + 1];
6102 memcpy(spaceName, name + start, c - start);
6103 spaceName[c-start] = '\0';
6104 newSpace = (NameSpace *)nameSpace.nameSpaces.FindString(spaceName);
6108 nameSpace = newSpace;
6117 return (NameSpace *)nameSpace;
6120 void ListSymbols(Expression exp, bool enumOnly, char * string, Identifier realIdentifier)
6122 bool listedEnums = false;
6123 Type destType = (exp && exp.destType && !exp.destType.truth) ? exp.destType : null;
6124 bool listClasses = true;
6126 if(exp && (exp.type == identifierExp || exp.type == memberExp))
6128 // TOCHECK: This memberExp check wasn't here... Some stuff isn't quite done
6129 Identifier id = (exp.type == memberExp) ? exp.member.member : exp.identifier;
6130 char * colons = id ? RSearchString(id.string, "::", strlen(id.string), true, false) : null;
6132 if(exp.type == identifierExp)
6133 id = realIdentifier;
6135 if(id && id._class && !id._class.name)
6137 listClasses = false;
6140 else if(id && id._class && id._class.name)
6144 Class _class = id.classSym.registered;
6145 if(_class && _class.type == enumClass)
6147 ListEnumValues(_class);
6150 ListClassMembers(id.classSym.registered, true);
6155 else if(id && colons)
6157 ListNameSpaceByString(this.privateModule, id.string);
6162 if(this.privateModule && destType && (destType.kind != pointerType || destType.type.kind != voidType) && destType.kind != ellipsisType)
6164 listedEnums = ListEnumsModule(this.privateModule, destType);
6167 if(destType && destType.kind == classType && destType._class.registered && destType._class.registered.type == enumClass)
6169 ListEnumValues(destType._class.registered);
6172 ListClassPropertiesAndVirtual(insideClass, null);
6176 else if(destType && destType.kind == enumType)
6180 for(value = destType.members.first; value; value = value.next)
6182 DataRow row = membersList.AddString(value.name);
6183 row.icon = icons[typeEnumValue];
6187 ListClassPropertiesAndVirtual(insideClass, null);
6191 else if(insideClass && !enumOnly)
6193 ListClassPropertiesAndVirtual(insideClass, string);
6196 if(listedEnums && string && string[0])
6198 DataRow row = membersList.FindSubString(string);
6200 listedEnums = false;
6203 if(!insideClass && exp && exp.destType && exp.destType.kind == functionType && GetThisClass())
6205 ListClassMembersMatch(GetThisClass(), exp.destType);
6207 else if(!insideClass && !enumOnly && !listedEnums)
6210 Symbol symbol = null;
6214 ListClassMembers(GetThisClass(), false);
6217 for(ctx = listClasses ? GetCurrentContext() : GetTopContext(); ctx != GetTopContext().parent && !symbol; ctx = ctx.parent)
6219 for(symbol = (Symbol)ctx.symbols.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6221 // Don't list enum values?
6222 //if(symbol.type.kind != TypeEnum)
6223 DataRow row = membersList.FindString(symbol.string);
6226 if(GetBuildingEcereComModule() && symbol.type && symbol.type.kind == functionType && eSystem_FindFunction(privateModule, symbol.string))
6228 row = membersList.AddString(symbol.string);
6229 if(symbol.type && symbol.type.kind == functionType)
6230 row.icon = icons[typeMethod];
6231 else if(symbol.type && symbol.type.kind == enumType)
6233 row.icon = icons[typeEnumValue];
6237 BitmapResource bitmap = null;
6238 if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
6240 char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
6243 bitmap = { bitmapName };
6244 membersList.AddResource(bitmap);
6247 row.icon = bitmap ? bitmap : icons[typeData];
6254 for(symbol = (Symbol)ctx.types.first; symbol; symbol = (Symbol)((BTNode)symbol).next)
6256 DataRow row = membersList.FindString(symbol.string);
6259 row = membersList.AddString(symbol.string);
6260 if(symbol.type.kind == functionType)
6261 row.icon = icons[typeMethod];
6262 else if(symbol.type.kind == classType && (!symbol.type._class.registered || (symbol.type._class.registered.type != unitClass && symbol.type._class.registered.type != enumClass)))
6264 row.icon = icons[typeClass];
6268 row.icon = icons[typeDataType];
6275 ListModule(this.privateModule, 1, listClasses);
6276 // TODO: Implement this with name space
6280 for(data = globalData.first; data; data = data.next)
6282 DataRow row = membersList.FindString(data.name);
6284 data.dataType = ProcessTypeString(data.dataTypeString, false);
6287 row = membersList.AddString(data.name);
6289 if(data.dataType && data.dataType.kind == TypeEnum)
6291 row.icon = icons[typeEnumValue];
6295 BitmapResource bitmap = null;
6296 if(data.dataType && data.dataType.kind == classType && data.dataType._class && data.dataType._class)
6298 char * bitmapName = (char *)eClass_GetProperty(data.dataType._class.registered, "icon");
6301 bitmap = { bitmapName };
6302 membersList.AddResource(bitmap);
6305 row.icon = bitmap ? bitmap : icons[typeData];
6313 DataRow row = membersList.AddString("Min");
6314 row.icon = icons[typeMethod];
6316 row = membersList.AddString("Max");
6317 row.icon = icons[typeMethod];
6319 row = membersList.AddString("Abs");
6320 row.icon = icons[typeMethod];
6322 row = membersList.AddString("Sgn");
6323 row.icon = icons[typeMethod];
6329 void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
6331 EditBoxStream f { editBox = editBox };
6336 updatingCode = true;
6338 if(!method.dataType)
6339 method.dataType = ProcessTypeString(method.dataTypeString, false);
6341 DeleteJunkBefore(f, function.loc.start.pos, &position);
6342 f.DeleteBytes(function.loc.end.pos - function.loc.start.pos - 1);
6344 // ADDING METHOD HERE
6346 Type dataType = method.dataType;
6347 Type returnType = dataType.returnType;
6349 Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
6355 if(extraIndent) f.Printf(" ");
6357 OutputType(f, returnType, false);
6361 if(dataType.thisClass && !dataType.classObjectType && (!isInstance || !insideClass || !eClass_IsDerived(insideClass, dataType.thisClass.registered)))
6363 if(dataType.thisClass.shortName)
6364 f.Printf(dataType.thisClass.shortName);
6366 f.Printf(dataType.thisClass.string);
6369 f.Printf(method.name);
6371 for(param = dataType.params.first; param; param = param.next)
6373 // Decided not to write void...
6374 if(param.kind != voidType)
6376 OutputType(f, param, true);
6382 if(extraIndent) f.Printf(" ");
6383 f.Printf(" %c\n", OpenBracket);
6385 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6391 (isInstance ? _class : _class.base)._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad] ||
6392 (isInstance ? _class : _class.base)._vTbl[method.vid] == DummyMethod)) // Temp Check for DefaultFunction
6394 if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
6396 if(extraIndent) f.Printf(" ");
6397 f.Printf(" return true;\n");
6399 else if(returnType && returnType.kind != voidType)
6401 if(extraIndent) f.Printf(" ");
6402 f.Printf(" return 0;\n");
6407 if(extraIndent) f.Printf(" ");
6409 if(returnType.kind != voidType)
6410 f.Printf("return ");
6411 f.Printf("%s::%s(", isInstance ? _class.name : _class.base.name, method.name);
6412 for(param = dataType.params.first; param; param = param.next)
6414 if(param.prev) f.Printf(", ");
6415 if(param.kind != voidType)
6416 f.Printf(param.name);
6422 if(extraIndent) f.Printf(" ");
6423 f.Printf(" %c", CloseBracket);
6428 if(extraIndent) { x1 += 3; x2 += 3; }
6429 editBox.SetSelPos(l1, y1, x1 + 6, l2, y2, x2 + 6);
6431 this.updatingCode = false;
6435 // Return false if we overrided a function and don't want to run params listing
6436 bool InvokeAutoComplete(bool enumOnly, int pointer, bool caretMove)
6438 bool didOverride = false;
6439 EditLine line = editBox.line;
6440 char * text = line.text;
6441 int lineNum, charPos;
6442 Expression exp = null;
6445 //Identifier id = null;
6446 Expression memberExp = null;
6447 Identifier realIdentifier = null;
6449 if(!parsing) return true;
6450 if(!privateModule) return !didOverride;
6452 insideFunction = null;
6454 charPos = editBox.charPos + 1;
6455 if(!membersListShown)
6460 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6462 EditBoxStream f { editBox = editBox };
6464 updatingCode = true;
6465 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6469 if(!f.Seek(-1, current))
6472 if(!isspace(ch)) break;
6473 f.Seek(-1, current);
6475 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6477 lineNum = editBox.lineNumber + 1;
6478 charPos = editBox.charPos + 1;
6480 updatingCode = false;
6483 if(!membersListShown)
6485 memberExp = FindExpTree(ast, lineNum, charPos);
6486 if(memberExp && (memberExp.type == TypeKind::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6491 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6493 EditBoxStream f { editBox = editBox };
6496 updatingCode = true;
6498 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6501 if(ch == '}' || ch == ',' || ch == ')')
6503 f.Seek(-1, current);
6511 if(!f.Seek(-1, current))
6514 if(!isspace(ch)) break;
6515 f.Seek(-1, current);
6519 f.Seek(-1, current);
6521 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6523 lineNum = editBox.lineNumber + 1;
6524 charPos = editBox.charPos + 1;
6526 updatingCode = false;
6529 realIdentifier = FindCtxTree(ast, lineNum, charPos);
6534 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6535 lineNum = editBox.lineNumber + 1;
6536 charPos = editBox.charPos/* + 1*/;
6540 char tempString[1024];
6541 char * string = null;
6542 CodePosition idStart, idEnd;
6544 if(membersListShown)
6546 char * buffer = membersLine.text;
6548 bool firstChar = true;
6550 string = tempString;
6552 for(c = membersLoc.start.charPos; c<membersLoc.end.charPos; c++)
6554 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6555 if(!isSpace) firstChar = false;
6557 string[len++] = buffer[c];
6561 else //if(realIdentifier)//if(id)
6564 char * buffer = id.string;
6566 bool firstChar = true;
6568 string = tempString;
6569 for(c = 0; c<= charPos - id.loc.start.charPos; c++)
6571 bool isSpace = (buffer[c] == ' ' || buffer[c] == '\t');
6572 if(!isSpace) firstChar = false;
6574 string[len++] = buffer[c];
6580 EditLine editLine = editBox.line;
6581 bool firstChar = true;
6584 string = tempString;
6585 for(y = lineNum-1; y >= 0; y--)
6587 char * buffer = editLine.text;
6588 int lineCount = editLine.count;
6589 for(x = (y == lineNum-1) ? (Min(charPos, lineCount) - 1 ): lineCount-1; x >= 0; x--)
6591 bool isSpace = (buffer[x] == ' ' || buffer[x] == '\t');
6596 idEnd.charPos = x + 2;
6601 // TESTING THIS CODE HERE FOR NOT CONSIDERING bool when doing ctrl-space past it
6604 idEnd.charPos = x + 2;
6611 if(!isalnum(buffer[x]) && buffer[x] != '_')
6617 memmove(string+1, string, len++);
6618 string[0] = buffer[x];
6622 //if(done || firstChar)
6623 if(done || !firstChar)
6625 editLine = editLine.prev;
6628 if(!strcmp(string, "case"))
6634 else if(!strcmp(string, "return"))
6640 else if(!strcmp(string, "delete"))
6646 else if(!strcmp(string, "new"))
6652 else if(!strcmp(string, "renew"))
6660 idStart.charPos = x + 1;
6661 idStart.line = y + 1;
6664 if(!membersListShown)
6666 membersList.Clear();
6667 if(memberExp && (memberExp.type == ExpressionType::memberExp || memberExp.type == pointerExp) && !memberExp.addedThis)
6669 Type type = memberExp.member.exp.expType;
6670 if(pointer == 2 && type)
6672 if(type.kind == pointerType || type.kind == arrayType)
6681 ListSymbols(exp, enumOnly, string, realIdentifier);
6683 membersList.Sort(null, 1);
6688 // Virtual function override
6689 Identifier id = GetDeclId(insideFunction.declarator);
6690 char * string = id ? id.string : null;
6692 Method method = eClass_FindMethod(GetThisClass(), string, this.privateModule);
6695 if(method.type != virtualMethod || (!insideInstance && method._class == GetThisClass()))
6696 insideFunction = null;
6699 OverrideVirtualFunction(insideFunction, method, GetThisClass(), insideInstance, insideInstance && insideClass);
6704 if(!didOverride) //insideFunction)
6706 rowCount = membersList.rowCount;
6709 DataRow row = string ? membersList.FindSubString(string) : null;
6710 if(row && !membersList.FindSubStringAfter(row, string) && !caretMove)
6712 char * newString = row.string;
6713 if(!membersListShown)
6715 membersLoc.start.line = idStart.line-1;
6716 membersLoc.start.charPos = idStart.charPos-1;
6717 //membersLoc.end = membersLoc.start;
6718 membersLoc.end.charPos = idEnd.charPos-1;
6719 membersLoc.end.line = idEnd.line-1;
6720 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6721 //membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6726 membersList.Destroy(0);
6727 membersListShown = false;
6730 editBox.GoToPosition(membersLine, membersLoc.start.line, membersLoc.start.charPos);
6732 line, membersLoc.start.line, membersLoc.start.charPos,
6733 line, membersLoc.end.line, membersLoc.end.charPos);
6734 editBox.PutS(newString);
6740 row = membersList.FindSubStringi(string);
6742 membersList.currentRow = row;
6743 membersList.currentRow.selected = false;
6746 membersList.currentRow = row;
6748 if(!membersListShown)
6752 // TESTING THESE ADDITIONS TO THE IF SO THAT CARET ISNT MOVED IF NOT ON TOP OF A WORD
6753 if(string && string[0] && lineNum == idStart.line && charPos >= idStart.charPos-1 && charPos <= idEnd.charPos-1)
6754 editBox.SetSelPos(l1, y1, idStart.charPos-1, l2, y2, idStart.charPos-1);
6755 editBox.GetCaretPosition(caret);
6756 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6758 membersList.master = this;
6760 caret.y += editBox.GetCaretSize();
6762 membersList.Create();
6765 int x = caret.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6766 int y = caret.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6767 Window parent = membersList.parent;
6769 if(!paramsAbove && (paramsShown || y + membersList.size.h > parent.clientSize.h))
6771 y -= editBox.GetCaretSize() + membersList.size.h;
6772 membersAbove = true;
6775 membersAbove = false;
6777 membersList.position = { x, y };
6781 membersLoc.start.line = lineNum - 1;
6783 if(string && string[0])
6785 membersLoc.start.charPos = idStart.charPos-1;
6786 membersLoc.end = membersLoc.start;
6787 //membersLoc.end.charPos = id.loc.end.charPos-1;
6788 membersLoc.end.charPos = idStart.charPos + strlen(string)-1; //end.charPos-1;
6792 membersLoc.start.charPos = charPos;
6793 membersLoc.end = membersLoc.start;
6794 membersLoc.end.charPos = charPos;
6796 membersListShown = true;
6798 // Hack to keep caret shown
6799 editBox.GetCaretPosition(caret);
6800 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6803 membersList.SetScrollPosition(0, row.index * membersList.rowHeight);
6809 SetCurrentContext(globalContext);
6812 return !didOverride;
6815 void InvokeParameters(bool exact, bool reposition, bool caretMove)
6817 EditLine line = editBox.line;
6818 char * text = line.text;
6819 int lineNum, charPos;
6820 Expression exp = null;
6824 if(!parsing) return;
6826 charPos = editBox.charPos + 1;
6829 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6831 EditBoxStream f { editBox = editBox };
6834 updatingCode = true;
6835 editBox.SetSelPos(l1, y1, x1, l2, y2, x2);
6838 if(ch == '}' || ch == ',' || ch == ')')
6840 f.Seek(-1, current);
6848 if(!f.Seek(-1, current))
6851 if(!isspace(ch)) break;
6852 f.Seek(-1, current);
6856 f.Seek(-1, current);
6858 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6860 lineNum = editBox.lineNumber + 1;
6861 charPos = editBox.charPos + 1;
6863 updatingCode = false;
6866 charPos = Min(charPos, l1.count + 1);
6868 FindParamsTree(ast, lineNum, charPos);
6870 // Not sure about this == ExpCall... paramsInsideExp doesn't seem to necessarily be a ExpCall
6871 if(exact && ((::functionType && paramsInsideExp.type == callExp && paramsInsideExp.call.exp.loc.end.charPos != charPos-1) /*|| instanceType*/))
6873 ::functionType = null;
6874 ::instanceType = null;
6877 //if((::functionType || ::instanceType) && (!paramsShown || insideExp != functionExp || ::paramsID != this.paramsID))
6878 if((::functionType || ::instanceType) && (!paramsShown || true /*paramsInsideExp.destType != functionExp.destType */|| ::paramsID != this.paramsID))
6882 Window parent = paramsList.parent;
6884 if(this.functionType != ::functionType || this.instanceType != ::instanceType)
6887 if(!this.paramsShown || reposition || paramsInsideExp != functionExp || ::instanceType) // Added instanceType here, otherwise instance popups never reposition...
6888 // ( Dummy exp: always ends up with same memory)
6890 editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
6891 editBox.GetCaretPosition(paramsPosition);
6892 this.paramsPosition.y += editBox.GetCaretSize();
6895 FreeType(this.functionType);
6896 FreeType(this.instanceType);
6898 this.functionType = ::functionType;
6899 this.instanceType = ::instanceType;
6901 if(this.functionType) this.functionType.refCount++;
6902 if(this.instanceType) this.instanceType.refCount++;
6904 this.paramsID = ::paramsID;
6905 functionExp = paramsInsideExp;
6907 paramsList.master = this;
6909 paramsList.Create();
6911 x = paramsPosition.x + editBox.absPosition.x - app.desktop.absPosition.x - editBox.scroll.x;
6912 y = paramsPosition.y + editBox.absPosition.y - app.desktop.absPosition.y - editBox.scroll.y;
6914 if(!this.membersAbove && ( this.membersListShown || y + paramsList.size.h > parent.clientSize.h) )
6916 y -= editBox.GetCaretSize() + paramsList.clientSize.h;
6920 paramsAbove = false;
6921 if(x + paramsList.size.w > parent.clientSize.w)
6923 x = parent.clientSize.w - paramsList.size.w;
6927 paramsList.position = { x, y };
6929 // Hack to keep caret shown
6932 editBox.GetCaretPosition(caret);
6933 editBox.SetCaret(caret.x, caret.y, editBox.GetCaretSize());
6936 this.paramsShown = true;
6938 else if((!::functionType && !::instanceType) || reposition)
6940 paramsList.Destroy(0);
6941 paramsShown = false;
6943 FreeType(this.functionType);
6944 FreeType(this.instanceType);
6945 this.functionType = null;
6946 this.instanceType = null;
6950 SetCurrentContext(globalContext);
6958 designer.visible = true;
6959 designer.Activate();
6965 CodeEditor NewCodeEditor(Window parent, WindowState state, bool modified)
6967 CodeEditor document { state = state, parent = parent, modifiedDocument = modified };
6972 static int nofdigits(int v)
6974 if(v == MININT) return 10 + 1;
6975 if(v < 0) return nofdigits(-v) + 1;