5 import "SettingsDialog"
7 static Context globalContext { };
8 static OldList defines { };
9 static OldList imports { };
10 static NameSpace globalData;
11 static OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
13 #define UTF8_NUM_BYTES(x) (__extension__({ byte b = x; (b & 0x80 && b & 0x40) ? ((b & 0x20) ? ((b & 0x10) ? 4 : 3) : 2) : 1; }))
16 /*extern */int __ecereVMethodID_class_OnGetString;
23 a.OnGetString(null, null, null);
26 static bool editing = true;
28 enum CodeObjectType { typeClass, typeData, typeMethod, typeEvent, typeProperty, typeNameSpace, typeDataType, typeEnumValue, typeDataPrivate, typeMethodPrivate, typePropertyPrivate };
30 static char * iconNames[CodeObjectType] =
32 "<:ecere>constructs/class.png",
33 "<:ecere>constructs/data.png",
34 "<:ecere>constructs/method.png",
35 "<:ecere>constructs/event.png",
36 "<:ecere>constructs/property.png",
37 "<:ecere>constructs/namespace.png",
38 "<:ecere>constructs/dataType.png",
39 "<:ecere>constructs/enumValue.png",
40 "<:ecere>constructs/dataPrivate.png",
41 "<:ecere>constructs/methodPrivate.png",
42 "<:ecere>constructs/propertyPrivate.png"
45 IDESettings settings { }; // instantiate the IDESettings class from the IDESettings.ec file. Do this at a global level so that all methods can access settings.
47 IDESettingsContainer settingsContainer
51 dataOwner = &settings;
54 // WARNING : This function expects a null terminated string since it recursively concatenate...
55 static void _PrintType(Type type, char * string, bool printName, bool printFunction, bool fullName)
62 if(type._class && type._class.string)
65 strcat(string, type._class.string);
68 if(type._class.registered)
71 sprintf(hex, "%08x", type._class.registered);
72 strcat(string, "<a href=\"api://");
74 strcat(string, "\" style=\"text-decoration: none;\">");
75 strcat(string, type._class.registered.name);
76 strcat(string, "</a>");
79 strcat(string, type._class.string);
86 for(funcType = type; funcType && (funcType.kind == pointerType || funcType.kind == arrayType); funcType = funcType.type);
87 if(funcType && funcType.kind == functionType)
90 DocPrintType(funcType.returnType, string, false, fullName);
92 if(printName || funcType.thisClass)
95 if(funcType.thisClass)
97 strcat(string, funcType.thisClass.string);
101 strcat(string, type.name);
103 strcat(string, ")(");
104 for(param = funcType.params.first; param; param = param.next)
106 DocPrintType(param, string, false, fullName);
107 if(param.next) strcat(string, ", ");
113 _PrintType(type.type, string, false /*printName*/, printFunction, fullName);
114 if(string[strlen(string)-1] == '(')
117 strcat(string, " *");
121 case voidType: strcat(string, "void"); break;
122 case intType: strcat(string, type.isSigned ? "int" : "uint"); break;
123 case int64Type: strcat(string, type.isSigned ? "int64" : "uint64"); break;
124 case charType: strcat(string, type.isSigned ? "char" : "byte"); break;
125 case shortType: strcat(string, type.isSigned ? "short" : "uint16"); break;
126 case floatType: strcat(string, "float"); break;
127 case doubleType: strcat(string, "double"); break;
131 strcat(string, "struct ");
132 strcat(string, type.enumName);
134 else if(type.typeName)
136 strcat(string, type.typeName);
141 strcat(string, "struct ");
142 strcat(string,"(unnamed)");
145 strcat(string, "struct {");
146 for(member = type.members.first; member; member = member.next)
148 DocPrintType(member, string, true, fullName);
157 strcat(string, "union ");
158 strcat(string, type.enumName);
160 else if(type.typeName)
162 strcat(string, type.typeName);
166 strcat(string, "union ");
167 strcat(string,"(unnamed)");
173 strcat(string, "enum ");
174 strcat(string, type.enumName);
176 else if(type.typeName)
178 strcat(string, type.typeName);
181 strcat(string, "enum");
188 strcat(string, "dllexport ");
189 DocPrintType(type.returnType, string, false, fullName);
193 // DANGER: Testing This
199 strcat(string, type.name);
202 char * name = RSearchString(type.name, "::", strlen(type.name), true, false);
203 if(name) name += 2; else name = type.name;
204 strcat(string, "<b>");
205 strcat(string, name);
206 strcat(string, "</b>");
219 for(param = type.params.first; param; param = param.next)
221 DocPrintType(param, string, true, fullName);
222 if(param.next) strcat(string, ", ");
231 for(funcType = type; funcType && (funcType.kind == pointerType || funcType.kind == arrayType); funcType = funcType.type);
232 if(funcType && funcType.kind == functionType)
235 DocPrintType(funcType.returnType, string, false, fullName);
236 strcat(string, "(*");
237 if(printName || funcType.thisClass)
240 if(funcType.thisClass)
242 strcat(string, funcType.thisClass.string);
243 strcat(string, "::");
246 strcat(string, type.name);
248 strcat(string, ")(");
249 for(param = funcType.params.first; param; param = param.next)
251 DocPrintType(param, string, false, fullName);
252 if(param.next) strcat(string, ", ");
258 char baseType[1024], size[256];
259 Type arrayType = type;
263 while(arrayType.kind == TypeKind::arrayType)
266 if(arrayType.enumClass)
267 strcat(size, arrayType.enumClass.string);
268 else if(arrayType.arraySizeExp)
269 PrintExpression(arrayType.arraySizeExp, size);
270 //sprintf(string, "%s[%s]", baseType, size);
273 arrayType = arrayType.arrayType;
275 _PrintType(arrayType, baseType, printName, printFunction, fullName);
276 strcat(string, baseType);
277 strcat(string, size);
281 DocPrintType(type.arrayType, baseType, printName, fullName);
283 strcpy(size, type.enumClass.string);
284 else if(type.arraySizeExp)
285 PrintExpression(type.arraySizeExp, size);
286 //sprintf(string, "%s[%s]", baseType, size);
287 strcat(string, baseType);
289 strcat(string, size);
297 strcat(string, "...");
300 _PrintType(type.method.dataType, string, false, printFunction, fullName);
303 strcat(string, "subclass(");
304 strcat(string, type._class ? type._class.string : "int");
310 if(type.name && printName && type.kind != functionType && (type.kind != pointerType || type.type.kind != functionType))
313 strcat(string, type.name);
318 void DocPrintType(Type type, char * string, bool printName, bool fullName)
321 for(funcType = type; funcType && (funcType.kind == pointerType || funcType.kind == arrayType); funcType = funcType.type);
322 if(funcType && funcType.kind == functionType && type != funcType)
324 char typeString[1024];
327 DocPrintType(funcType.returnType, string, false, fullName);
329 _PrintType(type, string, printName, false, fullName);
333 strcat(string, type.name);
340 for(param = funcType.params.first; param; param = param.next)
342 DocPrintType(param, string, true, fullName);
343 if(param.next) strcat(string, ", ");
348 _PrintType(type, string, printName, true, fullName);
351 void AddComponents(Module module, bool isDll)
356 if(module.name && (!strcmp(module.name, "ecere") || !strcmp(module.name, "ecereCOM")))
358 row = mainForm.browser.AddRow();
359 row.SetData(null, APIPageNameSpace { name = "ecereCOM", nameSpace = &module.application.systemNameSpace });
361 AddNameSpace(row, null, module.application.systemNameSpace, null, "", !isDll);
364 for(m = module.modules.first; m; m = m.next)
366 if(m.importMode == publicAccess || !isDll)
367 AddComponents(m.module, true);
370 // PUT MODULE DESCRIPTION HERE
371 if(module.name && strcmp(module.name, "ecereCOM"))
373 row = mainForm.browser.AddRow();
374 row.SetData(null, APIPageNameSpace { name = module.name, module = module, nameSpace = &module.publicNameSpace });
375 row.tag = (int)module;
376 AddNameSpace(row, module, module.publicNameSpace, null /*module.application.systemNameSpace*/, "", !isDll);
378 AddNameSpace(row, module, module.privateNameSpace, null /*module.application.systemNameSpace*/, "", !isDll);
390 char * OnGetString(char * tempString, void * fieldData, bool * needClass)
395 virtual void Generate(File f)
401 enum DocumentationType
409 enum DocumentationItem
425 static void FigureFileName(char * fileName, Module module, DocumentationType type, void * object, DocumentationItem item, void * data)
427 NameSpace * nameSpace, * ns;
429 Method method = null;
430 GlobalFunction function = null;
431 char nsName[1024], temp[1024];
437 case nameSpaceDoc: nameSpace = object; break;
438 case classDoc: cl = (Class)object; nameSpace = cl.nameSpace; break;
439 case functionDoc: function = object; nameSpace = function.nameSpace; break;
440 case methodDoc: method = object; cl = method._class; nameSpace = cl.nameSpace; break;
445 while(ns && ns->name)
447 strcpy(temp, "namespaces/");
448 strcat(temp, ns->name);
450 strcat(temp, nsName);
451 strcpy(nsName, temp);
454 sprintf(docFile, "%s.eCdoc", (!module || !module.name || !strcmp(nsName, "namespaces/ecere/namespaces/com")) ? "ecereCOM" : module.name);
456 sprintf(fileName, "<%s/%s>", settings.docDir, docFile); // Note that in the ecereIDE.ini file, there can be no quotes around the path, and there needs to be the final backslash. Otherwise this does not work.
457 strcat(fileName, nsName);
461 strcat(fileName, "classes/");
462 strcat(fileName, cl.name);
463 strcat(fileName, "/");
468 strcat(fileName, "methods/");
469 strcat(fileName, method.name);
470 strcat(fileName, "/");
474 char * name = RSearchString(function.name, "::", strlen(function.name), true, false);
475 if(name) name += 2; else name = function.name;
476 strcat(fileName, "functions/");
477 strcat(fileName, name);
478 strcat(fileName, "/");
483 case description: strcat(fileName, "description"); break;
484 case usage: strcat(fileName, "usage"); break;
485 case remarks: strcat(fileName, "remarks"); break;
486 case example: strcat(fileName, "example"); break;
487 case seeAlso: strcat(fileName, "seeAlso"); break;
488 case returnValue: strcat(fileName, "returnValue"); break;
489 case enumerationValue:
490 strcat(fileName, "enumeration values/");
491 strcat(fileName, ((NamedLink)data).name);
494 strcat(fileName, "definitions/");
495 strcat(fileName, ((Definition)data).name);
499 char * name = RSearchString(((Property)data).name, "::", strlen(((Property)data).name), true, false);
500 if(name) name += 2; else name = ((Property)data).name;
501 strcat(fileName, "conversions/");
502 strcat(fileName, name);
505 case memberDescription:
506 strcat(fileName, "data members/");
507 strcat(fileName, ((DataMember)data).name);
509 case propertyDescription:
510 strcat(fileName, "properties/");
511 strcat(fileName, ((Property)data).name);
518 strcat(fileName, "parameters/");
519 for(prev = data, count = 0; prev; prev = prev.prev, count++);
520 sprintf(name, "%s.%d", ((Type)data).name, count);
521 strcat(fileName, name);
527 static char * ReadDoc(Module module, DocumentationType type, void * object, DocumentationItem item, void * data)
529 char fileName[MAX_LOCATION];
530 String contents = null;
533 FigureFileName(fileName, module, type, object, item, data);
534 file = FileOpen(fileName, read);
538 if((len = file.GetSize()))
540 contents = new char[len+1];
541 file.Read(contents, 1, len);
542 contents[len] = '\0';
549 for(c = 0; contents[c]; c++)
550 if(!isspace(contents[c])) break;
554 if(editing && !contents)
555 contents = CopyString($"[Add Text]");
559 class APIPageNameSpace : APIPage
561 NameSpace * nameSpace;
564 void Generate(File f)
567 char nsName[1024], temp[1024];
574 while(ns && ns->name)
576 strcpy(temp, ns->name);
577 if(nsName[0]) strcat(temp, "::");
578 strcat(temp, nsName);
579 strcpy(nsName, temp);
582 // Generate Class Page
583 f.Printf($"<HTML><HEAD><TITLE>API Reference</TITLE></HEAD>\n<BODY><FONT SIZE=\"3\">\n");
586 f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", nsName );
587 tag = (uint)nameSpace;
588 f.Printf($"Module: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
592 tag = (uint)((!module || !module.name || !strcmp(nsName, "ecere::com") ? null : module));
593 f.Printf($"<FONT FACE=\"Arial\" SIZE=\"6\">Module %s</FONT><br>\n", (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
597 ns = nameSpace->parent;
598 while(ns && ns->name)
600 strcpy(temp, ns->name);
601 if(nsName[0]) strcat(temp, "::");
602 strcat(temp, nsName);
603 strcpy(nsName, temp);
607 f.Printf($"Parent namespace: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", nameSpace->parent, nsName);
611 char * desc = ReadDoc(module, nameSpaceDoc, nameSpace, description, null);
614 f.Printf($"<H3>Description</H3><br><br>\n");
617 char fileName[MAX_LOCATION];
618 FigureFileName(fileName, module, nameSpaceDoc, nameSpace, description, null);
619 f.Printf("<a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
621 f.Printf("</a><br><br>");
624 f.Printf("%s<br><br>", desc);
629 if(nameSpace->nameSpaces.first)
632 for(ns = (NameSpace *)nameSpace->nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
634 char * desc = ReadDoc(module, nameSpaceDoc, ns, description, null);
637 f.Printf($"<H3>Sub Namespaces</H3><br><br>\n");
638 f.Printf("<TABLE >\n");
642 f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a></TD>", iconNames[typeNameSpace], ns, ns->name);
647 char fileName[MAX_LOCATION];
648 FigureFileName(fileName, module, nameSpaceDoc, ns, description, null);
649 f.Printf("<TD valign=top height=22> <a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
651 f.Printf("</a></TD>");
654 f.Printf("<TD valign=top height=22> %s</TD>", desc);
657 f.Printf("</TR><br>\n");
660 f.Printf("</TABLE><br>\n");
663 if(nameSpace->classes.first)
666 for(link = (BTNamedLink)nameSpace->classes.first; link; link = (BTNamedLink)((BTNode)link).next)
668 Class cl = link.data;
669 if(!cl.templateClass)
671 char * desc = ReadDoc(module, classDoc, cl, description, null);
675 f.Printf($"<a name=Classes></a><H3>Classes</H3><br><br>\n");
676 f.Printf("<TABLE >\n");
682 f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a></TD>", (cl.type == enumClass || cl.type == unitClass || cl.type == systemClass) ? iconNames[typeDataType] : iconNames[typeClass], cl, cl.name);
687 char fileName[MAX_LOCATION];
688 FigureFileName(fileName, module, classDoc, cl, description, null);
689 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
691 f.Printf("</a></TD>");
694 f.Printf("<TD valign=top height=22>%s</TD>", desc);
701 f.Printf("</TABLE><br>\n");
704 if(nameSpace->functions.first)
707 for(link = (BTNamedLink)nameSpace->functions.first; link; link = (BTNamedLink)((BTNode)link).next)
709 GlobalFunction function = link.data;
710 char * desc = ReadDoc(module, functionDoc, function, description, null);
711 char * name = RSearchString(function.name, "::", strlen(function.name), true, false);
712 if(name) name += 2; else name = function.name;
715 f.Printf("<a name=Functions></a><H3>Functions</H3><br><br>\n");
716 f.Printf("<TABLE >\n");
720 f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a></TD>", iconNames[typeMethod], function, name);
725 char fileName[MAX_LOCATION];
726 FigureFileName(fileName, module, functionDoc, function, description, null);
727 f.Printf("<TD valign=top height=22> <a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
729 f.Printf("</a></TD>");
732 f.Printf("<TD valign=top height=22> %s</TD>", desc);
735 f.Printf("</TR><br>\n");
738 f.Printf("</TABLE><br>\n");
741 if(nameSpace->defines.first)
744 for(link = (BTNamedLink)nameSpace->defines.first; link; link = (BTNamedLink)((BTNode)link).next)
746 DefinedExpression def = link.data;
747 char * desc = ReadDoc(module, nameSpaceDoc, nameSpace, definition, def);
750 f.Printf($"<a name=Definitions></a><H3>Definitions</H3><br><br>\n");
751 f.Printf("<TABLE >\n");
755 f.Printf("<TD valign=top height=22 nowrap=1><a name=%08x></a><img valign=center src=\"%s\"> %s</TD>", def, iconNames[typeData], def.name);
756 f.Printf("<TD valign=top height=22>%s</TD>", def.value);
761 char fileName[MAX_LOCATION];
762 FigureFileName(fileName, module, nameSpaceDoc, nameSpace, definition, def);
763 f.Printf("<TD valign=top height=22> <a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
765 f.Printf("</a></TD>");
768 f.Printf("<TD valign=top height=22> %s</TD>", desc);
771 f.Printf("</TR><br>\n");
774 f.Printf("</TABLE><br>\n");
777 f.Printf("</FONT></BODY></HTML>\n");
781 class APIPageClass : APIPage
785 void Generate(File f)
791 char nsName[1024], temp[1024];
792 NameSpace * ns = cl.nameSpace;
793 Module module = cl.module;
796 while(ns && ns->name)
798 strcpy(temp, ns->name);
799 if(nsName[0]) strcat(temp, "::");
800 strcat(temp, nsName);
801 strcpy(nsName, temp);
804 // Generate Class Page
805 f.Printf($"<HTML><HEAD><TITLE>API Reference</TITLE></HEAD>\n<BODY><FONT SIZE=\"3\">\n");
806 f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", name);
808 f.Printf($"Module: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
810 f.Printf($"Namespace: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", cl.nameSpace, nsName);
813 char * classType = null;
817 classType = $"Bit Collection";
820 classType = $"Enumeration";
823 classType = $"Structure";
826 classType = $"Class";
829 classType = $"Class (No header)";
835 classType = $"Basic Data Type";
838 f.Printf($"Type: %s<br>\n", classType);
841 if(cl.type != systemClass && cl.base)
843 f.Printf($"Base Class: ");
844 if(!strcmp(cl.base.name, "struct") || !strcmp(cl.base.name, "class"))
846 f.Printf(cl.type == bitClass ? cl.dataTypeString : $"None");
848 else if(cl.type == enumClass && !strcmp(cl.base.name, "enum"))
849 f.Printf("%s", cl.dataTypeString);
851 f.Printf("<a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a>", cl.base, cl.base.name);
856 char * desc = ReadDoc(module, classDoc, cl, description, null);
859 f.Printf($"<br><H3>Description</H3><br><br>\n");
862 char fileName[MAX_LOCATION];
863 FigureFileName(fileName, module, classDoc, cl, description, null);
864 f.Printf("<a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
866 f.Printf("</a><br><br>");
869 f.Printf("%s<br><br>", desc);
874 if(cl.type == enumClass)
876 EnumClassData enumeration = (EnumClassData)cl.data;
877 if(enumeration.values.first)
881 f.Printf($"<a name=EnumerationValues></a><H3>Enumeration Values</H3><br><br>\n");
882 f.Printf("<TABLE >\n");
884 for(item = enumeration.values.first; item; item = item.next)
886 char * desc = ReadDoc(module, classDoc, cl, enumerationValue, item);
887 bool needClass = true;
890 while(base.type == enumClass) base = base.base;
892 if(base.type == systemClass ||
893 (base.type == bitClass && base.membersAndProperties.first && !strcmp(cl.fullName, ((DataMember)base.membersAndProperties.first).dataTypeString)))
896 base.dataType = ProcessTypeString(base.dataTypeString, false);
898 if(base.dataType.kind != classType)
903 PrintType(base.dataType, string, false, true);
904 classSym = FindClass(string);
905 dataClass = classSym ? classSym.registered : null;
908 dataClass = base.dataType._class ? base.dataType._class.registered : null;
914 f.Printf("<TD valign=top height=22 nowrap=1><a name=%08x></a><img valign=center src=\"%s\"> %s</TD>", item, iconNames[typeEnumValue], item.name);
915 if(dataClass.type == systemClass)
918 dataClass._vTbl[__ecereVMethodID_class_OnGetString](dataClass, &item.data, string, sizeof(string), &needClass);
921 eSystem_FindClass(componentsApp, "class")._vTbl[__ecereVMethodID_class_OnGetString](dataClass, &item.data, string, sizeof(string), &needClass);
923 f.Printf("<TD valign=top height=22 nowrap=1>%s { %s }</TD>", dataClass.name, string);
925 f.Printf("<TD valign=top height=22 nowrap=1>%s</TD>", string);
930 char fileName[MAX_LOCATION];
931 FigureFileName(fileName, module, classDoc, cl, enumerationValue, item);
932 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
934 f.Printf("</a></TD>");
937 f.Printf("<TD valign=top height=22>%s</TD>", desc);
942 f.Printf("</TABLE><BR>\n");
946 if(cl.conversions.first)
948 f.Printf($"<a name=Conversions></a><H3>Conversions</H3><br><br>\n");
949 f.Printf("<TABLE >\n");
950 for(prop = cl.conversions.first; prop; prop = prop.next)
952 if((prop.memberAccess == publicAccess || (prop.memberAccess == privateAccess && showPrivate)) && prop.name)
954 char * desc = ReadDoc(module, classDoc, cl, conversion, prop);
957 Type type = ProcessTypeString(prop.name, false);
958 name = RSearchString(prop.name, "::", strlen(prop.name), true, false);
959 if(name) name += 2; else name = prop.name;
964 DocPrintType(type, string, true, false);
966 f.Printf("<TD valign=top height=22 nowrap=1><a name=%08x></a><img valign=center src=\"%s\"> %s</TD>", prop, iconNames[typeDataType], string);
971 char fileName[MAX_LOCATION];
972 FigureFileName(fileName, module, classDoc, cl, conversion, prop);
973 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
975 f.Printf("</a></TD>");
978 f.Printf("<TD valign=top height=22>%s</TD>", desc);
987 f.Printf("</TABLE><br>\n");
990 if(cl.membersAndProperties.first)
993 for(prop = (Property)cl.membersAndProperties.first; prop; prop = prop.next)
995 if(prop.memberAccess == publicAccess || (prop.memberAccess == privateAccess && showPrivate))
999 f.Printf($"<a name=Members></a><H3>Properties and Members</H3><br><br>\n");
1000 f.Printf("<TABLE >\n");
1006 char * desc = ReadDoc(module, classDoc, cl, propertyDescription, prop);
1008 prop.dataType = ProcessTypeString(prop.dataTypeString, false);
1012 DocPrintType(prop.dataType, string, true, false);
1014 f.Printf("<TD valign=top height=22 nowrap=1><a name=%08x></a><img valign=center src=\"%s\"> %s</TD>", prop, iconNames[typeProperty], prop.name);
1015 f.Printf("<TD valign=top height=22 nowrap=1>%s</TD>", string);
1020 char fileName[MAX_LOCATION];
1021 FigureFileName(fileName, module, classDoc, cl, propertyDescription, prop);
1022 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1024 f.Printf("</a></TD>");
1027 f.Printf("<TD valign=top height=22>%s</TD>", desc);
1030 f.Printf("</TR>\n");
1034 AddDataMemberToPage(f, (DataMember)prop, 0, showPrivate);
1039 f.Printf("</TABLE><br>\n");
1042 if(cl.methods.first)
1046 for(method = (Method)cl.methods.first; method; method = (Method)((BTNode)method).next)
1048 if((method.memberAccess == publicAccess || (method.memberAccess == privateAccess && showPrivate)) && method.type == virtualMethod)
1050 char * desc = ReadDoc(module, methodDoc, method, description, null);
1053 f.Printf($"<a name=VirtualMethods></a><H3>Virtual Methods</H3><br><br>\n");
1054 f.Printf("<TABLE >\n");
1057 if(!method.dataType)
1058 ProcessMethodType(method);
1061 f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a></TD>", method.dataType.thisClass ? iconNames[typeEvent] : iconNames[typeMethod], method, method.name);
1066 char fileName[MAX_LOCATION];
1067 FigureFileName(fileName, module, methodDoc, method, description, null);
1068 f.Printf("<TD valign=top height=22> <a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1070 f.Printf("</a></TD>");
1073 f.Printf("<TD valign=top height=22> %s</TD>", desc);
1076 f.Printf("</TR><br>\n");
1080 f.Printf("</TABLE><br>\n");
1082 // Non-Virtual Methods
1084 for(method = (Method)cl.methods.first; method; method = (Method)((BTNode)method).next)
1086 if((method.memberAccess == publicAccess || (method.memberAccess == privateAccess && showPrivate)) && method.type != virtualMethod)
1088 char * desc = ReadDoc(module, methodDoc, method, description, null);
1091 f.Printf($"<a name=Methods></a><H3>Non-Virtual Methods</H3><br><br>\n");
1092 f.Printf("<TABLE >\n");
1096 if(!method.dataType)
1097 ProcessMethodType(method);
1100 f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a></TD>", iconNames[typeMethod], method, method.name);
1105 char fileName[MAX_LOCATION];
1106 FigureFileName(fileName, module, methodDoc, method, description, null);
1107 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1109 f.Printf("</a></TD>");
1112 f.Printf("<TD valign=top height=22>%s</TD>", desc);
1116 f.Printf("</TR><br>\n");
1120 f.Printf("</TABLE><br>\n");
1123 char * usageDoc = ReadDoc(module, classDoc, cl, usage, null);
1126 f.Printf($"<H3>Usage</H3><br>\n");
1129 char fileName[MAX_LOCATION];
1130 FigureFileName(fileName, module, classDoc, cl, usage, null);
1131 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1136 f.Printf("<br>%s\n", usageDoc);
1137 f.Printf("<br><br>\n");
1142 char * exampleDoc = ReadDoc(module, classDoc, cl, example, null);
1145 f.Printf($"<H3>Example</H3><br>\n");
1146 f.Printf("<FONT face=\"Courier New\">\n");
1147 f.Printf("<br><TABLE >\n");
1150 char fileName[MAX_LOCATION];
1151 FigureFileName(fileName, module, classDoc, cl, example, null);
1152 f.Printf("<TR><TD><CODE><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1154 f.Printf("</a></CODE></TD></TR>\n"); // bgcolor=#CFC9C0
1157 f.Printf("<TR><TD><CODE>%s</CODE></TD></TR>\n", exampleDoc); // bgcolor=#CFC9C0
1159 f.Printf("</TABLE></FONT>\n");
1165 char * remarksDoc = ReadDoc(module, classDoc, cl, remarks, null);
1169 f.Printf($"<H3>Remarks</H3><br>\n");
1172 char fileName[MAX_LOCATION];
1173 FigureFileName(fileName, module, classDoc, cl, remarks, null);
1174 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1179 f.Printf("<br>%s\n", remarksDoc);
1180 f.Printf("<br><br>\n");
1185 if(cl.type != systemClass)
1189 for(c = cl.derivatives.first; c; c = c.next)
1191 Class deriv = c.data;
1192 // TO VERIFY: Does this properly check public status?
1193 if(eSystem_FindClass(componentsApp, deriv.fullName))
1197 f.Printf($"<H3>Derived Classes</H3><br>\n");
1203 f.Printf("<a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a>", deriv, deriv.name);
1207 f.Printf("<br><br>\n");
1210 char * seeAlsoDoc = ReadDoc(module, classDoc, cl, seeAlso, null);
1213 f.Printf($"<H3>See Also</H3><br>\n");
1216 char fileName[MAX_LOCATION];
1217 FigureFileName(fileName, module, classDoc, cl, seeAlso, null);
1218 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1223 f.Printf("<br>%s\n", seeAlsoDoc);
1224 f.Printf("<br><br>\n");
1228 f.Printf("</FONT></BODY></HTML>\n");
1232 class APIPageMethod : APIPage
1235 void Generate(File f)
1237 Class cl = method._class;
1239 Module module = cl.module;
1241 char nsName[1024], temp[1024];
1242 NameSpace * ns = cl.nameSpace;
1245 while(ns && ns->name)
1247 strcpy(temp, ns->name);
1248 if(nsName[0]) strcat(temp, "::");
1249 strcat(temp, nsName);
1250 strcpy(nsName, temp);
1254 f.Printf($"<HTML><HEAD><TITLE>API Reference</TITLE></HEAD>\n<BODY><FONT SIZE=\"3\">\n");
1255 f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", name);
1257 f.Printf($"Module: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
1259 f.Printf($"Namespace: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", cl.nameSpace, nsName);
1260 f.Printf("Class: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", cl, cl.name);
1261 if(method.dataType.staticMethod)
1263 f.Printf($"this pointer class: None<br>\n");
1265 else if(method.dataType.thisClass && method.dataType.thisClass.registered && (method.dataType.thisClass.registered != method._class || method.type == virtualMethod))
1267 f.Printf($"this pointer class: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", method.dataType.thisClass.registered, method.dataType.thisClass.registered.name);
1270 // Generate Method Page
1272 if(!method.dataType.name)
1273 method.dataType.name = CopyString(method.name);
1274 DocPrintType(method.dataType, string, true, false);
1275 f.Printf("<br>%s", string);
1278 char * desc = ReadDoc(module, methodDoc, method, description, null);
1281 f.Printf($"<br><br><H3>Description</H3><br><br>\n");
1284 char fileName[MAX_LOCATION];
1285 FigureFileName(fileName, module, methodDoc, method, description, null);
1286 f.Printf("<a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1291 f.Printf("%s", desc);
1296 f.Printf("<br><br>\n");
1297 if(method.dataType.params.first && ((Type)method.dataType.params.first).kind != voidType)
1299 f.Printf($"<H3>Parameters</H3><br><br>\n");
1301 if((method.dataType.returnType && method.dataType.returnType.kind != voidType) ||
1302 (method.dataType.params.first && ((Type)method.dataType.params.first).kind != voidType))
1304 f.Printf("<TABLE valign=center>\n");
1307 for(param = method.dataType.params.first; param; param = param.next)
1309 // ADD DESCRIPTION HERE
1310 if(param.kind != voidType)
1312 char * desc = ReadDoc(module, methodDoc, method, parameter, param);
1315 DocPrintType(param, string, false, false);
1317 f.Printf("<TD valign=top height=22 nowrap=1>%s </TD>\n", param.name ? param.name : "");
1318 f.Printf("<TD valign=top height=22 nowrap=1>%s </TD>\n", string);
1323 char fileName[MAX_LOCATION];
1324 FigureFileName(fileName, module, methodDoc, method, parameter, param);
1325 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1327 f.Printf("s</a> </TD>\n");
1330 f.Printf("<TD valign=top height=22>%s </TD>\n", desc);
1334 f.Printf("</TR>\n");
1337 if(method.dataType.returnType && method.dataType.returnType.kind != voidType)
1339 char * desc = ReadDoc(module, methodDoc, method, returnValue, null);
1340 if(method.dataType.params.first && ((Type)method.dataType.params.first).kind != voidType)
1342 f.Printf("<TR><TD> </TD></TR>");
1345 f.Printf($"<TD valign=top height=22 nowrap=1><B>Return Value</B></TD>\n");
1347 DocPrintType(method.dataType.returnType, string, false, false);
1348 f.Printf("<TD valign=top height=22>%s </TD>\n", string);
1353 char fileName[MAX_LOCATION];
1354 FigureFileName(fileName, module, methodDoc, method, returnValue, null);
1355 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1357 f.Printf("</a> </TD>\n");
1360 f.Printf("<TD valign=top height=22>%s </TD>\n", desc);
1363 f.Printf("</TR>\n");
1364 f.Printf("</TABLE>\n");
1366 if((method.dataType.returnType && method.dataType.returnType.kind != voidType) ||
1367 (method.dataType.params.first && ((Type)method.dataType.params.first).kind != voidType))
1369 f.Printf("</TABLE><br>\n");
1372 char * usageDoc = ReadDoc(module, methodDoc, method, usage, null);
1375 f.Printf($"<H3>Usage</H3><br>\n");
1378 char fileName[MAX_LOCATION];
1379 FigureFileName(fileName, module, methodDoc, method, usage, null);
1380 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1385 f.Printf("<br>%s\n", usageDoc);
1386 f.Printf("<br><br>\n");
1391 char * exampleDoc = ReadDoc(module, methodDoc, method, example, null);
1394 f.Printf($"<H3>Example</H3><br>\n");
1395 f.Printf("<FONT face=\"Courier New\">\n");
1396 f.Printf("<br><TABLE >\n");
1399 char fileName[MAX_LOCATION];
1400 FigureFileName(fileName, module, methodDoc, method, example, null);
1401 f.Printf("<TR><TD><CODE><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1403 f.Printf("</a></CODE></TD></TR>\n"); // bgcolor=#CFC9C0
1406 f.Printf("<TR><TD><CODE>%s</CODE></TD></TR>\n", exampleDoc); // bgcolor=#CFC9C0
1407 f.Printf("</TABLE></FONT>\n");
1413 char * remarksDoc = ReadDoc(module, methodDoc, method, remarks, null);
1416 f.Printf($"<H3>Remarks</H3><br>\n");
1419 char fileName[MAX_LOCATION];
1420 FigureFileName(fileName, module, methodDoc, method, remarks, null);
1421 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1426 f.Printf("<br>%s\n", method, remarksDoc);
1427 f.Printf("<br><br>\n");
1432 char * seeAlsoDoc = ReadDoc(module, methodDoc, method, seeAlso, null);
1435 f.Printf($"<H3>See Also</H3><br>\n");
1438 char fileName[MAX_LOCATION];
1439 FigureFileName(fileName, module, methodDoc, method, seeAlso, null);
1440 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1445 f.Printf("<br>%s\n", method, seeAlsoDoc);
1447 f.Printf("<br><br>\n");
1451 f.Printf("</FONT></BODY></HTML>\n");
1455 class APIPageFunction : APIPage
1457 GlobalFunction function;
1458 void Generate(File f)
1461 Module module = function.module;
1463 char nsName[1024], temp[1024];
1464 NameSpace * ns = function.nameSpace;
1467 while(ns && ns->name)
1469 strcpy(temp, ns->name);
1470 if(nsName[0]) strcat(temp, "::");
1471 strcat(temp, nsName);
1472 strcpy(nsName, temp);
1476 f.Printf($"<HTML><HEAD><TITLE>API Reference</TITLE></HEAD>\n<BODY><FONT SIZE=\"3\">\n");
1477 f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", name);
1479 f.Printf($"Module: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
1482 f.Printf($"Namespace: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", function.nameSpace, nsName);
1484 if(!function.dataType)
1485 function.dataType = ProcessTypeString(function.dataTypeString, false);
1487 if(function.dataType.thisClass && function.dataType.thisClass.registered)
1489 f.Printf($"this pointer class: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", function.dataType.thisClass.registered, function.dataType.thisClass.registered.name);
1492 // Generate Method Page
1494 if(!function.dataType.name)
1495 function.dataType.name = CopyString(function.name);
1496 DocPrintType(function.dataType, string, true, false);
1497 f.Printf("<br>%s", string);
1500 char * desc = ReadDoc(module, functionDoc, function, description, null);
1503 f.Printf($"<br><br><H3>Description</H3><br><br>\n");
1506 char fileName[MAX_LOCATION];
1507 FigureFileName(fileName, module, functionDoc, function, description, null);
1508 f.Printf("<a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1513 f.Printf("%s", desc);
1517 f.Printf("<br><br>\n");
1518 if(function.dataType.params.first && ((Type)function.dataType.params.first).kind != voidType)
1520 f.Printf($"<H3>Parameters</H3><br><br>\n");
1522 if((function.dataType.returnType && function.dataType.returnType.kind != voidType) ||
1523 (function.dataType.params.first && ((Type)function.dataType.params.first).kind != voidType))
1525 f.Printf("<TABLE valign=center>\n");
1528 for(param = function.dataType.params.first; param; param = param.next)
1530 // ADD DESCRIPTION HERE
1531 if(param.kind != voidType)
1533 char * desc = ReadDoc(module, functionDoc, function, parameter, param);
1536 DocPrintType(param, string, false, false);
1538 f.Printf("<TD valign=top height=22 nowrap=1>%s </TD>\n", param.name ? param.name : "");
1539 f.Printf("<TD valign=top height=22 nowrap=1>%s </TD>\n", string);
1544 char fileName[MAX_LOCATION];
1545 FigureFileName(fileName, module, functionDoc, function, parameter, param);
1546 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1548 f.Printf("</a> </TD>\n");
1551 f.Printf("<TD valign=top height=22>%s </TD>\n", desc);
1554 f.Printf("</TR>\n");
1557 if(function.dataType.returnType && function.dataType.returnType.kind != voidType)
1559 char * desc = ReadDoc(module, functionDoc, function, returnValue, null);
1560 if(function.dataType.params.first && ((Type)function.dataType.params.first).kind != voidType)
1562 f.Printf("<TR><TD> </TD></TR>");
1565 f.Printf($"<TD valign=top height=22 nowrap=1><B>Return Value</B></TD>\n");
1567 DocPrintType(function.dataType.returnType, string, false, false);
1568 f.Printf("<TD valign=top height=22>%s </TD>\n", string);
1573 char fileName[MAX_LOCATION];
1574 FigureFileName(fileName, module, functionDoc, function, returnValue, null);
1575 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1577 f.Printf("</a> </TD>\n");
1580 f.Printf("<TD valign=top height=22>%s </TD>\n", function, desc);
1583 f.Printf("</TR>\n");
1584 f.Printf("</TABLE>\n");
1586 if((function.dataType.returnType && function.dataType.returnType.kind != voidType) ||
1587 (function.dataType.params.first && ((Type)function.dataType.params.first).kind != voidType))
1589 f.Printf("</TABLE><br>\n");
1592 char * usageDoc = ReadDoc(module, functionDoc, function, usage, null);
1595 f.Printf($"<H3>Usage</H3><br>\n");
1598 char fileName[MAX_LOCATION];
1599 FigureFileName(fileName, module, functionDoc, function, usage, null);
1600 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1605 f.Printf("<br>%s\n", usageDoc);
1606 f.Printf("<br><br>\n");
1611 char * exampleDoc = ReadDoc(module, functionDoc, function, example, null);
1614 f.Printf($"<H3>Example</H3><br>\n");
1615 f.Printf("<FONT face=\"Courier New\">\n");
1616 f.Printf("<br><TABLE >\n");
1619 char fileName[MAX_LOCATION];
1620 FigureFileName(fileName, module, functionDoc, function, example, null);
1621 f.Printf("<TR><TD><CODE><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1623 f.Printf("</a></CODE></TD></TR>\n"); // bgcolor=#CFC9C0
1626 f.Printf("<TR><TD><CODE>%s</CODE></TD></TR>\n", exampleDoc); // bgcolor=#CFC9C0
1627 f.Printf("</TABLE></FONT>\n");
1633 char * remarksDoc = ReadDoc(module, functionDoc, function, remarks, null);
1636 f.Printf($"<H3>Remarks</H3><br>\n");
1639 char fileName[MAX_LOCATION];
1640 FigureFileName(fileName, module, functionDoc, function, remarks, null);
1641 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1646 f.Printf("<br>%s\n", remarksDoc);
1647 f.Printf("<br><br>\n");
1652 char * seeAlsoDoc = ReadDoc(module, functionDoc, function, seeAlso, null);
1655 f.Printf($"<H3>See Also</H3><br>\n");
1658 char fileName[MAX_LOCATION];
1659 FigureFileName(fileName, module, functionDoc, function, seeAlso, null);
1660 f.Printf("<br><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1665 f.Printf("<br>%s\n", seeAlsoDoc);
1666 f.Printf("<br><br>\n");
1670 f.Printf("</FONT></BODY></HTML>\n");
1674 static void AddNameSpace(DataRow parentRow, Module module, NameSpace mainNameSpace, NameSpace comNameSpace, char * parentName, bool showPrivate)
1678 NameSpace * nameSpace = mainNameSpace;
1680 DataRow classesRow = null;
1681 DataRow functionsRow = null, definesRow = null;
1684 char fileName[MAX_LOCATION];
1686 strcpy(nsName, parentName ? parentName : "");
1690 strcat(nsName, "::");
1691 strcat(nsName, nameSpace->name);
1696 row = parentRow.AddRow();
1697 row.SetData(null, (page = APIPageNameSpace { nameSpace->name, module = module, nameSpace = nameSpace, showPrivate = showPrivate }));
1698 row.tag = (int)nameSpace;
1699 row.icon = mainForm.icons[typeNameSpace];
1703 // "Global NameSpace"
1705 page = parentRow.GetData(null);
1711 for(ns = (NameSpace *)mainNameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
1713 NameSpace * comNS = (comNameSpace != null) ? (NameSpace *)comNameSpace.nameSpaces.FindString(ns->name) : null;
1714 AddNameSpace(row, module, ns, comNS, nsName, showPrivate);
1716 if(comNameSpace != null)
1718 for(ns = (NameSpace *)comNameSpace.nameSpaces.first; ns; ns = (NameSpace *)((BTNode)ns).next)
1720 if(!mainNameSpace.nameSpaces.FindString(ns->name))
1722 AddNameSpace(row, module, ns, null, nsName, showPrivate);
1727 if(mainNameSpace.classes.first || (comNameSpace && comNameSpace.classes.first))
1729 for(nameSpace = mainNameSpace ; nameSpace; nameSpace = (nameSpace == mainNameSpace) ? comNameSpace : null)
1731 if(nameSpace->classes.first)
1735 for(link = (BTNamedLink)nameSpace->classes.first; link; link = (BTNamedLink)((BTNode)link).next)
1738 if(!cl.templateClass && (!module || cl.module == module || (!cl.module.name && !strcmp(module.name, "ecere"))))
1740 if(!classesRow) { classesRow = row.AddRow(); classesRow.SetData(null, APIPage { $"Classes", page = page }); classesRow.collapsed = true; classesRow.icon = mainForm.icons[typeClass]; classesRow.tag = 1; }
1741 AddClass(classesRow, module, cl, nsName, showPrivate);
1748 if(mainNameSpace.functions.first || (comNameSpace && comNameSpace.functions.first))
1750 for(nameSpace = mainNameSpace ; nameSpace; nameSpace = (nameSpace == mainNameSpace) ? comNameSpace : null)
1752 if(nameSpace->functions.first)
1756 for(link = (BTNamedLink)nameSpace->functions.first; link; link = (BTNamedLink)((BTNode)link).next)
1759 if(!module || fn.module == module || (!fn.module.name && !strcmp(module.name, "ecere")))
1761 char * name = ( name = RSearchString(fn.name, "::", strlen(fn.name), false, false), name ? name + 2 : fn.name);
1763 if(!functionsRow) { functionsRow = row.AddRow(); functionsRow.SetData(null, APIPage { $"Functions", page = page }); functionsRow.collapsed = true; functionsRow.icon = mainForm.icons[typeMethod]; functionsRow.tag = 2; };
1764 fnRow = functionsRow.AddRow(); fnRow.SetData(null, APIPageFunction { name, function = fn }); fnRow.icon = mainForm.icons[typeMethod]; fnRow.tag = (int)fn;
1771 if(mainNameSpace.defines.first || (comNameSpace && comNameSpace.defines.first))
1773 for(nameSpace = mainNameSpace ; nameSpace; nameSpace = (nameSpace == mainNameSpace) ? comNameSpace : null)
1775 if(nameSpace->defines.first)
1779 for(link = (BTNamedLink)nameSpace->defines.first; link; link = (BTNamedLink)((BTNode)link).next)
1782 //if(def.module == module)
1784 char * name = ( name = RSearchString(def.name, "::", strlen(def.name), false, false), name ? name + 2 : def.name);
1786 if(!definesRow) { definesRow = row.AddRow(); definesRow.SetData(null, APIPage { $"Definitions", page = page }); definesRow.collapsed = true; definesRow.icon = mainForm.icons[typeData]; definesRow.tag = 3; };
1787 defRow = definesRow.AddRow(); defRow.SetData(null, APIPage { name, page = page }); defRow.icon = mainForm.icons[typeData]; defRow.tag = (int)def;
1795 static void AddDataMemberToPage(File f, DataMember member, int indent, bool showPrivate)
1799 if(!member.dataType)
1800 member.dataType = ProcessTypeString(member.dataTypeString, false);
1804 DocPrintType(member.dataType, string, true, false);
1806 f.Printf("<TD valign=top height=22 nowrap=1><a name=%08x></a>", member);
1807 for(c = 0; c<indent; c++)
1808 f.Printf(" ");
1809 f.Printf("<img valign=center src=\"%s\"> %s</TD>", iconNames[typeData], member.name ? member.name : ((member.type == structMember) ? "(struct)" : "(union)"));
1810 f.Printf("<TD valign=top height=22 nowrap=1>%s</TD>", (member.type == normalMember) ? string : "");
1811 if(member.type == normalMember)
1813 char * desc = ReadDoc(member._class.module, classDoc, member._class, memberDescription, member);
1818 char fileName[MAX_LOCATION];
1819 FigureFileName(fileName, member._class.module, classDoc, member._class, memberDescription, member);
1820 f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
1822 f.Printf("</a></TD>");
1825 f.Printf("<TD valign=top height=22>%s</TD>", desc);
1830 f.Printf("<TD valign=top height=22></TD>");
1832 if(member.type != normalMember)
1834 DataMember subMember;
1835 for(subMember = member.members.first; subMember; subMember = subMember.next)
1837 if((subMember.memberAccess == publicAccess || (subMember.memberAccess == privateAccess && showPrivate)))
1839 AddDataMemberToPage(f, subMember, indent + 1, showPrivate);
1843 f.Printf("</TR><br>\n");
1846 static void AddDataMember(DataRow parentRow, APIPage page, DataMember member)
1849 if(member.type == normalMember)
1851 row = parentRow.AddRow(); row.SetData(null, APIPage { member.name, page = page }); row.icon = mainForm.icons[typeData];
1852 row.tag = (int)member;
1857 row = parentRow.AddRow(); row.SetData(null, APIPage { (member.type == unionMember) ? "(union)" : "(struct)", page });
1858 row.icon = mainForm.icons[typeData];
1859 row.tag = (int)member;
1861 for(m = member.members.first; m; m = m.next)
1863 if(m.memberAccess == publicAccess || (m.memberAccess == privateAccess && page.showPrivate))
1864 AddDataMember(row, page, m);
1869 static void AddClass(DataRow parentRow, Module module, Class cl, char * nsName, bool showPrivate)
1871 char fileName[MAX_LOCATION];
1878 DataRow methodsRow = null, virtualsRow = null, eventsRow = null;
1879 DataRow propertiesRow = null, membersRow = null, conversionsRow = null, enumRow = null;
1882 row = parentRow.AddRow();
1883 row.SetData(null, (page = APIPageClass { cl.name, cl = cl, showPrivate = showPrivate }));
1885 row.collapsed = true;
1886 row.icon = (cl.type == enumClass || cl.type == unitClass || cl.type == systemClass) ? mainForm.icons[typeDataType] : mainForm.icons[typeClass];
1889 if(cl.methods.first)
1891 for(method = (Method)cl.methods.first; method; method = (Method)((BTNode)method).next)
1893 if(method.memberAccess == publicAccess || (method.memberAccess == privateAccess && showPrivate))
1896 if(!method.dataType)
1897 ProcessMethodType(method);
1898 if(method.type == virtualMethod)
1900 if(method.dataType.thisClass)
1902 if(!eventsRow) { eventsRow = row.AddRow(); eventsRow.SetData(null, APIPage { $"Events", page = page }); eventsRow.collapsed = true; eventsRow.icon = mainForm.icons[typeEvent]; eventsRow.tag = 4; }
1903 mRow = eventsRow.AddRow(); mRow.SetData(null, APIPageMethod { method.name, method = method }); mRow.icon = mainForm.icons[typeEvent];
1904 mRow.tag = (int)method;
1908 if(!virtualsRow) { virtualsRow = row.AddRow(); virtualsRow.SetData(null, APIPage { $"Virtual Methods", page = page }); virtualsRow.collapsed = true; virtualsRow.icon = mainForm.icons[typeMethod]; virtualsRow.tag = 4; }
1909 mRow = virtualsRow.AddRow(); mRow.SetData(null, APIPageMethod { method.name, method = method }); mRow.icon = mainForm.icons[typeMethod];
1910 mRow.tag = (int)method;
1915 if(!methodsRow) { methodsRow = row.AddRow(); methodsRow.SetData(null, APIPage { $"Methods", page = page }); methodsRow.collapsed = true; methodsRow.icon = mainForm.icons[typeMethod]; methodsRow.tag = 5; }
1916 mRow = methodsRow.AddRow(); mRow.SetData(null, APIPageMethod { method.name, method = method }); mRow.icon = mainForm.icons[typeMethod];
1917 mRow.tag = (int)method;
1923 if(cl.membersAndProperties.first)
1925 for(prop = (Property)cl.membersAndProperties.first; prop; prop = prop.next)
1927 if(prop.memberAccess == publicAccess || (prop.memberAccess == privateAccess && showPrivate))
1930 prop.dataType = ProcessTypeString(prop.dataTypeString, false);
1934 if(!propertiesRow) { propertiesRow = row.AddRow(); propertiesRow.SetData(null, APIPage { $"Properties", page = page }); propertiesRow.collapsed = true; propertiesRow.icon = mainForm.icons[typeProperty]; propertiesRow.tag = 6; }
1935 mRow = propertiesRow.AddRow(); mRow.SetData(null, APIPage { prop.name, page }); mRow.icon = mainForm.icons[typeProperty];
1936 mRow.tag = (int)prop;
1940 if(!membersRow) { membersRow = row.AddRow(); membersRow.SetData(null, APIPage { $"Data Members", page = page }); membersRow.collapsed = true; membersRow.icon = mainForm.icons[typeData]; membersRow.tag = 6; }
1941 AddDataMember(membersRow, page, (DataMember)prop);
1947 if(cl.conversions.first)
1949 for(prop = cl.conversions.first; prop; prop = prop.next)
1953 if(!conversionsRow) { conversionsRow = row.AddRow(); conversionsRow.SetData(null, APIPage { $"Conversions", page = page }); conversionsRow.collapsed = true; conversionsRow.icon = mainForm.icons[typeDataType]; conversionsRow.tag = 7; }
1954 name = RSearchString(prop.name, "::", strlen(prop.name), true, false);
1955 if(name) name += 2; else name = prop.name;
1956 mRow = conversionsRow.AddRow(); mRow.SetData(null, APIPage { name, page = page }); mRow.icon = mainForm.icons[typeDataType];
1957 mRow.tag = (int)prop;
1960 if(cl.type == enumClass)
1962 EnumClassData enumeration = (EnumClassData)cl.data;
1964 for(item = enumeration.values.first; item; item = item.next)
1967 if(!enumRow) { enumRow = row.AddRow(); enumRow.SetData(null, APIPage { $"Enumeration Values", page = page }); enumRow.collapsed = true; enumRow.icon = mainForm.icons[typeEnumValue]; enumRow.tag = 8; }
1968 mRow = enumRow.AddRow(); mRow.SetData(null, APIPage { item.name, page = page }); mRow.icon = mainForm.icons[typeEnumValue];
1969 mRow.tag = (int)item;
1974 class MainForm : Window
1976 size = { 1000, 600 };
1978 borderStyle = sizable;
1981 nativeDecorations = true;
1982 icon = { ":documentorIcon.png" };
1983 text = $"API Documentation Browser";
1985 BitmapResource icons[CodeObjectType];
1990 for(c = 0; c < CodeObjectType::enumSize; c++)
1992 icons[c] = BitmapResource { iconNames[c], window = this, alphaBlend = true };
1994 browser.AddField(DataField { dataType = class(APIPage) });
1999 Menu fileMenu { menu, $"File", f };
2000 Array<FileFilter> fileFilters
2002 { $"eC Shared Library files (*.dll, *.so, *.dylib)", "dll, so, dylib" },
2003 { $"eC Symbol files (*.sym)", "sym" }
2006 FileDialog fileDialog
2008 filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter)
2010 MenuItem fileOpenItem
2012 fileMenu, $"Open...", o, ctrlO;
2014 bool NotifySelect(MenuItem selection, Modifiers mods)
2016 if(fileDialog.Modal() == ok)
2018 OpenModule(fileDialog.filePath);
2023 MenuItem fileSettingsItem
2025 fileMenu, $"Settings...", s, ctrlS; // set the Settings item to the file menu with shortcut keys:s and ctrl+s
2027 bool NotifySelect(MenuItem selection, Modifiers mods)
2029 SettingsDialog { master = this }.Modal(); // Open the settings dialog to allow the user to change the directory for the eCdoc files
2032 MenuDivider { fileMenu };
2033 MenuItem fileExit { fileMenu, $"Exit", x, altF4, NotifySelect = MenuFileExit };
2035 void OpenModule(char * filePath)
2037 char extension[MAX_EXTENSION];
2038 Module module = null;
2039 static char symbolsDir[MAX_LOCATION];
2041 FreeContext(globalContext);
2042 FreeExcludedSymbols(excludedSymbols);
2043 ::defines.Free(FreeModuleDefine);
2044 imports.Free(FreeModuleImport);
2046 FreeGlobalData(globalData);
2047 FreeTypeData(componentsApp);
2049 delete componentsApp;
2051 SetGlobalContext(globalContext);
2052 componentsApp = __ecere_COM_Initialize(false, 1, null);
2053 SetPrivateModule(componentsApp);
2055 StripLastDirectory(filePath, symbolsDir);
2056 SetSymbolsDir(symbolsDir);
2058 GetExtension(filePath, extension);
2060 mainForm.browser.Clear();
2062 ImportModule(filePath, normalImport, publicAccess, false);
2064 if(extension[0] && strcmpi(extension, "so") && strcmpi(extension, "dll"))
2065 componentsApp.name = CopyString(filePath);
2067 for(module = componentsApp.allModules.first; module; module = module.next)
2069 if(module.name && (!strcmp(module.name, "ecere") || !strcmp(module.name, "ecereCOM")))
2073 eModule_LoadStrict(componentsApp, "ecereCOM", publicAccess /*privateAccess*/);
2074 AddComponents(componentsApp, false);
2076 for(module = componentsApp.allModules.first; module; module = module.next)
2078 if(module.name && (!strcmp(module.name, filePath)))
2081 if(!module) module = componentsApp;
2082 mainForm.browser.SelectRow(mainForm.browser.FindSubRow((int)module));
2084 SetSymbolsDir(null);
2089 this, anchor = { left = 0, top = 0, bottom = 0 }, borderStyle = 0, background = aliceBlue;
2090 treeBranches = true; collapseControl = true; fullRowSelect = false; rootCollapseButton = true;
2093 bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
2095 APIPage page = row.GetData(null);
2096 if(view.edit) view.OnLeftButtonDown(0,0,0);
2097 if(page && page.page) page = page.page;
2099 view.PositionCaret(true);
2100 if(page != view.page)
2102 Window activeChild = this.activeChild;
2107 activeChild.Activate();
2109 else if(!view.created)
2113 page = row.GetData(null);
2114 if(page && page.page)
2118 case 1: view.GoToAnchor("Classes"); break;
2119 case 2: view.GoToAnchor("Functions"); break;
2120 case 3: view.GoToAnchor("Definitions"); break;
2121 case 4: view.GoToAnchor("VirtualMethods"); break;
2122 case 5: view.GoToAnchor("Methods"); break;
2123 case 6: view.GoToAnchor("Members"); break;
2124 case 7: view.GoToAnchor("Conversions"); break;
2125 case 8: view.GoToAnchor("EnumerationValues"); break;
2129 sprintf(hex, "%08x", row.tag);
2130 view.GoToAnchor(hex);
2136 view.SetScrollPosition(0, 0);
2144 this, anchor = { top = 0, bottom = 0, right = 0 };
2149 this, leftPane = browser, rightPane = view, split = 300 /*scaleSplit = 0.3 */
2152 bool OnClose(bool parentClosing)
2155 view.OnLeftButtonDown(0,0,0);
2161 mainForm.OpenModule((((GuiApplication)__thisModule).argc > 1) ? ((GuiApplication)__thisModule).argv[1] : "ecere");
2162 //mainForm.OpenModule("ec");
2163 //mainForm.OpenModule("c:/games/chess/debug/chess.sym");
2164 //mainForm.OpenModule("c:/ide/Objects.IDE.Win32.Debug/ide.sym");
2166 int index = mainForm.browser.currentRow.index;
2167 int rowHeight = mainForm.browser.rowHeight;
2168 int height = mainForm.browser.clientSize.h;
2170 mainForm.browser.scroll = { 0, index * rowHeight - height / 2 };
2176 class EditDialog : Window
2178 borderStyle = sizable;
2179 size = { 600, 400 };
2184 this, anchor = { left = 16, top = 16, right = 18, bottom = 61 }
2188 this, text = $"Save Changes", anchor = { horz = 184, vert = 160 }
2192 this, text = $"Cancel", anchor = { horz = 254, vert = 160 }
2196 #define UTF8_IS_FIRST(x) (__extension__({ byte b = x; (!(b) || !((b) & 0x80) || (b) & 0x40); }))
2197 #define UTF8_NUM_BYTES(x) (__extension__({ byte b = x; (b & 0x80 && b & 0x40) ? ((b & 0x20) ? ((b & 0x10) ? 4 : 3) : 2) : 1; }))
2199 class HelpView : HTMLView
2203 hasVertScroll = true;
2204 hasHorzScroll = true;
2206 char editString[MAX_LOCATION];
2211 page = mainForm.browser.currentRow.GetData(null);
2217 GoToAnchor(page.label);
2219 if(page.page) page = page.page;
2222 return HTMLView::OnCreate();
2231 char archiveFile[MAX_LOCATION];
2232 char fileName[MAX_FILENAME];
2233 char directory[MAX_LOCATION];
2236 SplitArchivePath(editString, archiveFile, &location);
2237 GetLastDirectory(location, fileName);
2238 StripLastDirectory(location, directory);
2239 archive = ArchiveOpen(archiveFile, { true } );
2243 ArchiveDir dir = archive.OpenDirectory(directory, null, replace);
2246 for(block = textBlock.parent.subBlocks.first; block; block = block.next)
2248 if(block.type == TEXT && block.textLen)
2256 for(block = textBlock.parent.subBlocks.first; block; block = block.next)
2258 if(block.type == BR)
2260 else if(block.type == TEXT)
2261 f.Write(block.text, 1, block.textLen);
2265 dir.AddFromFile(fileName, f, null, replace, 0, null, null);
2271 Block parent = textBlock.parent;
2272 while((block = parent.subBlocks.first))
2274 parent.subBlocks.Remove(block);
2277 textBlock = Block { type = TEXT, parent = parent, font = parent.font };
2278 textBlock.text = CopyString($"[Add Text]");
2279 textBlock.textLen = strlen(textBlock.text);
2280 parent.subBlocks.Add(textBlock);
2288 PositionCaret(true);
2294 bool OnLeftButtonDown(int x, int y, Modifiers mods)
2299 HTMLView::OnMouseMove(x, y, mods);
2300 if(textBlock && overLink == textBlock.parent)
2302 selPosition = curPosition = TextPosFromPoint(x, y, &textBlock);
2303 PositionCaret(true);
2308 HTMLView::OnLeftButtonDown(x, y, mods);
2312 return HTMLView::OnLeftButtonDown(x, y, mods);
2315 bool OnLeftButtonUp(int x, int y, Modifiers mods)
2317 if(!edit || !textBlock || clickedLink != textBlock.parent)
2319 HTMLView::OnLeftButtonUp(x, y, mods);
2322 selPosition = curPosition = TextPosFromPoint(x, y, &textBlock);
2323 PositionCaret(true);
2329 // Returns true if it needs scrolling
2331 bool FindMouse(int px, int py, int * tx, int * ty, EditLine * tline, bool half)
2337 bool needHScroll = false;
2344 line = this.viewLine ? (void *)this.viewLine.prev : null;
2349 line = (void *)this.lines.first;
2354 py = Min(py, clientSize.h);
2356 py = Min(py, this.lineCount);
2358 for(c = 0, line = this.viewLine; (line != (void *)this.lines.last && c<py); line = line.next, c++)
2364 if( (px >= clientSize.w || px < clientSize.w/2) && this.viewX)
2367 px = Min(px,clientSize.w+this.space.w);
2371 *tx = AdjustXPosition(line, px + viewX, half, null, MAXINT, 0);
2374 if(tline) *tline = line;
2377 // Prevent divide by 0 from non valid this.font
2379 return (y < this.viewY) || needHScroll;
2381 return (y < this.viewY || y >= this.viewY + clientSize.h / this.space.h) || needHScroll;
2386 bool OnLeftButtonDown(int mx, int my, Modifiers mods)
2391 if(style.noSelect) return true;
2393 if(!mods.isActivate)
2399 mouseX = mx - XOFFSET;
2402 FindMouse(mouseX, mouseY, &x, &y, &line, true);
2408 else if(IsMouseOnSelection() && !mods.isActivate)
2418 if(!mouseMove && !wordSelect && (!mods.isActivate || style.multiLine))
2420 if(mods.shift && !mods.isActivate)
2435 this.selLine = this.line;
2444 UpdateCaretPosition(true);
2449 bool OnLeftButtonUp(int x, int y, Modifiers mods)
2453 mouseSelect = false;
2464 FindMouse(mouseX, mouseY, &x, &y, &line, true);
2470 mouseMove = IsMouseOnSelection();
2474 int size = SelSize();
2477 char * text = new char[size+1];
2481 GetSel(text, false);
2483 if(Max(selY, this.y) == dropY)
2487 if(this.dropX > this.selX)
2488 moveX = this.x - this.selX;
2492 if(this.dropX > this.x)
2493 moveX = this.selX - this.x;
2497 this.dropX -= moveX;
2498 this.selX = this.x = this.dropX;
2499 this.selY = this.y = this.dropY;
2500 this.selLine = this.line = this.dropLine;
2502 SetViewToCursor(true);
2527 FindMouse(mouseX, mouseY, &x, &y, &line, true);
2529 NotifyDropped(master, this, x, y);
2536 bool OnMouseMove(int mx, int my, Modifiers mods)
2542 if(mods != -1 && mods.isSideEffect)
2547 if(style.noSelect) return true;
2548 if(wordSelect) return true;
2549 mouseX = mx - XOFFSET;
2552 needScroll = FindMouse(this.mouseX, this.mouseY, &x, &y, &line, true);
2554 if(this.mouseMove || this.mouseSelect)
2563 ((style.hScroll) || (style.vScroll)))
2570 DirtyLine(this.dropY);
2573 DirtyLine(this.dropY);
2574 this.dropLine = line;
2575 SetViewToCursor(true);
2577 else if(this.mouseSelect)
2579 DirtyLine(this.selY);
2586 SetViewToCursor(true);
2593 bool OnLeftDoubleClick(int mx, int my, Modifiers mods)
2600 if(style.noSelect) return true;
2601 FindMouse(mx, my, &x, &y, &line, false);
2602 if(!NotifyDoubleClick(master, this, line, mods))
2609 for(c = x; c >= 0; c--)
2612 while(c > 0 && !UTF8_IS_FIRST(line.buffer[c])) c--;
2613 ch = UTF8_GET_CHAR(line.buffer + c, numBytes);
2620 for(c = start; c<line.count; c += numBytes)
2622 unichar ch = UTF8_GET_CHAR(line.buffer + c, numBytes);
2633 this.line = this.selLine = line;
2634 this.wordSelect = (c != start);
2641 bool OnOpen(char * href)
2643 if(!strncmp(href, "api://", 6))
2645 int tag = strtoul(href + 6, null, 16);
2646 DataRow row = mainForm.browser.FindSubRow(tag);
2650 mainForm.browser.SelectRow(row);
2651 while((row = row.parent))
2652 row.collapsed = false;
2653 row = mainForm.browser.currentRow;
2654 mainForm.browser.scroll = { 0, row.index * mainForm.browser.rowHeight - mainForm.browser.clientSize.h / 2 };
2657 else if(!strncmp(href, "edit://", 7))
2660 int startX = clickedLink.startX, startY = clickedLink.startY;
2661 for(block = (Block)clickedLink.subBlocks.first; block; block = block.next)
2663 if(block.type == TEXT) startX = block.startX, startY = block.startY;
2664 if(block.type == BR && (!block.prev || !block.next || block.next.type != TEXT))
2666 Block newBlock { type = TEXT, parent = block.parent, font = block.parent.font };
2668 display.FontExtent(block.font.font, " ", 1, null, &th);
2671 block.parent.subBlocks.Insert(null, newBlock);
2676 block.parent.subBlocks.Insert(block, newBlock);
2679 newBlock.startX = startX;
2680 newBlock.startY = startY;
2681 newBlock.text = new0 char[1];
2685 textBlock = (Block)clickedLink.subBlocks.first;
2686 if(!strcmp(textBlock.text, $"[Add Text]"))
2688 textBlock.text[0] = 0;
2689 textBlock.textLen = 0;
2692 strcpy(editString, href + 7);
2693 selPosition = curPosition = 0;
2696 PositionCaret(true);
2703 int curPosition, selPosition;
2705 bool OnKeyDown(Key key, unichar ch)
2712 OnLeftButtonDown(0,0,0);
2715 selPosition = curPosition = textBlock.textLen;
2716 PositionCaret(true);
2720 selPosition = curPosition = 0;
2721 PositionCaret(true);
2725 selPosition = curPosition = 0;
2726 while(textBlock.prev)
2727 textBlock = textBlock.prev.prev;
2728 PositionCaret(true);
2732 while(textBlock.next && textBlock.next.next)
2733 textBlock = textBlock.next.next;
2734 selPosition = curPosition = textBlock.textLen;
2735 PositionCaret(true);
2741 return HTMLView::OnKeyDown(key, ch);
2744 bool OnKeyHit(Key key, unichar ch)
2752 if(caretY == textBlock.startY)
2756 textBlock = textBlock.prev.prev;
2757 selPosition = curPosition = Min(curPosition, textBlock.textLen);
2758 PositionCaret(false);
2768 int sx = textBlock.startX, sy = textBlock.startY;
2769 char * text = textBlock.text;
2771 Block block = textBlock;
2772 while(block && block.type != TD) block = block.parent;
2775 Block table = block;
2776 while(table && table.type != TABLE) table = table.parent;
2778 maxW = block.w - 2* table.cellPadding;
2780 maxW = clientSize.w - 10 - sx;
2783 maxW = clientSize.w - 10 - sx;
2784 display.FontExtent(textBlock.font.font, " ", 1, null, &th);
2788 int startPos = textPos;
2791 bool lineComplete = false;
2792 for(; textPos<textBlock.textLen && !lineComplete;)
2796 char * nextSpace = strchr(text + textPos, ' ');
2799 len = (nextSpace - (text + textPos)) + 1;
2801 len = textBlock.textLen - textPos;
2803 display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
2805 if(x + width + w > maxW && x > 0)
2807 lineComplete = true;
2817 if(textPos == textBlock.textLen || (sy == caretY - th && caretX <= x + width + sx))
2820 curPosition = textPos;
2821 while(curPosition > 0 && x + sx > caretX && textPos > startPos)
2824 while(curPosition > 0 && !UTF8_IS_FIRST(text[--curPosition]));
2825 len = curPosition - startPos;
2826 display.FontExtent(textBlock.font.font, text + startPos, len, &x, null);
2828 selPosition = curPosition;
2829 PositionCaret(false);
2833 if(sy == caretY - th || textPos == textBlock.textLen)
2835 if(textPos != textBlock.textLen)
2837 int c = textPos - 1;
2838 while(c > 0 && text[c] == ' ') c--;
2839 selPosition = curPosition = c + 1;
2842 selPosition = curPosition = textBlock.textLen;
2843 PositionCaret(false);
2847 sx = textBlock.startX;
2848 } while(textPos < textBlock.textLen);
2857 int sx = textBlock.startX, sy = textBlock.startY;
2858 char * text = textBlock.text;
2860 Block block = textBlock;
2861 while(block && block.type != TD) block = block.parent;
2864 Block table = block;
2865 while(table && table.type != TABLE) table = table.parent;
2867 maxW = block.w - 2* table.cellPadding;
2869 maxW = clientSize.w - 10 - sx;
2872 maxW = clientSize.w - 10 - sx;
2873 display.FontExtent(textBlock.font.font, " ", 1, null, &th);
2875 while(!textPos || textPos < textBlock.textLen)
2877 int startPos = textPos;
2880 bool lineComplete = false;
2881 for(; (textPos < textBlock.textLen) && !lineComplete;)
2885 char * nextSpace = strchr(text + textPos, ' ');
2888 len = (nextSpace - (text + textPos)) + 1;
2890 len = textBlock.textLen - textPos;
2892 display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
2894 if(x + width + w > maxW && x > 0)
2896 lineComplete = true;
2906 if(sy > caretY && (textPos == textBlock.textLen || caretX <= x + width + sx))
2908 curPosition = textPos;
2910 while(curPosition > 0 && x + sx > caretX && textPos > startPos)
2913 while(curPosition > 0 && !UTF8_IS_FIRST(text[--curPosition]));
2914 len = curPosition - startPos;
2915 display.FontExtent(textBlock.font.font, text + startPos, len, &x, null);
2917 selPosition = curPosition;
2918 PositionCaret(false);
2924 selPosition = curPosition = textBlock.textLen;
2925 PositionCaret(false);
2928 else if(textPos == textBlock.textLen && textBlock.next && textBlock.next.next)
2932 textBlock = textBlock.next.next;
2933 sy = textBlock.startY;
2934 sx = textBlock.startX;
2935 text = textBlock.text;
2940 sx = textBlock.startX;
2944 /*if(textBlock.next && textBlock.next.next)
2946 textBlock = textBlock.next.next;
2947 selPosition = curPosition = Min(curPosition, textBlock.textLen);
2948 PositionCaret(false);
2952 #define IS_ALUNDER(ch) ((ch) == '_' || isalnum((ch)))
2955 // SELECTION CTRL-RIGHT
2957 bool foundAlpha = false;
2959 Block line, lastLine;
2962 for(line = textBlock; (line && !found); line = line.next ? line.next.next : null)
2964 int start = (line == textBlock) ? curPosition : 0;
2966 for(c = start; c < line.textLen; c++)
2968 if(IS_ALUNDER(line.text[c]))
2980 if(!found && (c != curPosition || line != textBlock))
2984 lastC = line.textLen-1;
2990 selPosition = curPosition = lastC+1;
2991 textBlock = lastLine;
2992 PositionCaret(true);
2996 bool foundAlpha = false;
3000 for(line = textBlock; (line && !found); line = line.next ? line.next.next : null)
3002 int start = (line == textBlock) ? curPosition : 0;
3004 for(c = start; c < line.textLen; c++)
3006 if(!IS_ALUNDER(line.text[c]))
3011 selPosition = curPosition = c;
3013 PositionCaret(true);
3017 // No next word found,
3018 if(!found && (c != curPosition || line != textBlock))
3021 selPosition = curPosition = line.textLen;
3023 PositionCaret(true);
3031 bool foundAlpha = false;
3033 Block line, lastLine;
3036 for(line = textBlock; (line && !found); line = line.prev ? line.prev.prev : null)
3039 if(curPosition == 0 && line != textBlock)
3042 lastC = line.textLen;
3046 if(line == textBlock) start = curPosition-1; else start = line.textLen-1;
3047 for(c = start; c>=0; c--)
3049 if(IS_ALUNDER(line.text[c]))
3064 // No next word found,
3065 if(!found && curPosition > 0)
3075 textBlock = lastLine;
3076 selPosition = curPosition = lastC;
3077 PositionCaret(true);
3082 if(curPosition < textBlock.textLen)
3084 curPosition += UTF8_NUM_BYTES(textBlock.text[curPosition]);
3085 PositionCaret(true);
3086 selPosition = curPosition;
3088 else if(textBlock.next && textBlock.next.next)
3090 textBlock = textBlock.next.next;
3091 selPosition = curPosition = 0;
3092 PositionCaret(true);
3098 while(curPosition > 0 && !UTF8_IS_FIRST(textBlock.text[--curPosition]));
3099 PositionCaret(true);
3100 selPosition = curPosition;
3102 else if(textBlock.prev)
3104 textBlock = textBlock.prev.prev;
3105 selPosition = curPosition = textBlock.textLen;
3106 PositionCaret(true);
3112 int c = curPosition;
3114 while(c > 0 && !UTF8_IS_FIRST(textBlock.text[--c])) nb++;
3115 memmove(textBlock.text + curPosition - nb, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
3116 textBlock.textLen -= nb;
3117 textBlock.text = renew textBlock.text char[textBlock.textLen + 1];
3119 selPosition = curPosition;
3121 //Clear(html.block);
3122 //CreateForms(html.block);
3127 PositionCaret(true);
3130 else if(textBlock.prev)
3132 Block prev = textBlock.prev, prevBlock = textBlock.prev.prev;
3133 prevBlock.text = renew prevBlock.text char[prevBlock.textLen + textBlock.textLen + 1];
3134 memcpy(prevBlock.text + prevBlock.textLen, textBlock.text, textBlock.textLen + 1);
3136 selPosition = curPosition = prevBlock.textLen;
3137 prevBlock.textLen += textBlock.textLen;
3138 textBlock.parent.subBlocks.Remove(prev);
3140 textBlock.parent.subBlocks.Remove(textBlock);
3142 textBlock = prevBlock;
3145 //Clear(html.block);
3146 //CreateForms(html.block);
3151 PositionCaret(true);
3156 if(textBlock.textLen > curPosition)
3158 int nb = UTF8_NUM_BYTES(textBlock.text[curPosition]);
3159 memmove(textBlock.text + curPosition, textBlock.text + curPosition + nb, textBlock.textLen - curPosition + 1 - nb + 1);
3160 textBlock.textLen -= nb;
3161 textBlock.text = renew textBlock.text char[textBlock.textLen + 1];
3163 //Clear(html.block);
3164 //CreateForms(html.block);
3169 PositionCaret(true);
3172 else if(textBlock.next && textBlock.next.next)
3174 Block next = textBlock.next, nextBlock = textBlock.next.next;
3175 textBlock.text = renew textBlock.text char[textBlock.textLen + nextBlock.textLen + 1];
3176 memcpy(textBlock.text + textBlock.textLen, nextBlock.text, nextBlock.textLen + 1);
3178 textBlock.textLen += nextBlock.textLen;
3179 textBlock.parent.subBlocks.Remove(next);
3181 textBlock.parent.subBlocks.Remove(nextBlock);
3185 //Clear(html.block);
3186 //CreateForms(html.block);
3191 PositionCaret(true);
3197 Block block { type = BR, parent = textBlock.parent, font = textBlock.font };
3198 Block newBlock { type = TEXT, parent = textBlock.parent, font = textBlock.font };
3199 int startY = textBlock.startY, startX = textBlock.startX;
3202 display.FontExtent(textBlock.font.font, " ", 1, null, &th);
3203 textBlock.parent.subBlocks.Insert(textBlock, block);
3204 textBlock.parent.subBlocks.Insert(block, newBlock);
3208 newBlock.textLen = textBlock.textLen - curPosition;
3209 newBlock.text = new char[newBlock.textLen+1];
3210 memcpy(newBlock.text, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
3211 textBlock.textLen = curPosition;
3212 textBlock.text[curPosition] = 0;
3214 newBlock.startY = startY;
3215 newBlock.startX = startX;
3216 selPosition = curPosition = 0;
3218 //Clear(html.block);
3219 //CreateForms(html.block);
3224 textBlock = newBlock;
3225 PositionCaret(true);
3232 ClipBoard clipBoard { };
3233 if(clipBoard.Load())
3236 char * text = clipBoard.memory;
3239 Block parent = textBlock.parent;
3240 FontEntry font = textBlock.font;
3244 if(ch == '\n' || ch == '\r' || !ch)
3246 int len = c - start;
3247 textBlock.text = renew textBlock.text char[textBlock.textLen + 1 + len];
3248 memmove(textBlock.text + curPosition + len, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
3249 memcpy(textBlock.text + curPosition, text + start, len);
3250 textBlock.textLen += len;
3252 selPosition = curPosition;
3255 Block block { type = BR, parent = parent, font = font };
3256 Block newBlock { type = TEXT, parent = parent, font = font };
3257 int startY = textBlock.startY, startX = textBlock.startX;
3260 display.FontExtent(textBlock.font.font, " ", 1, null, &th);
3261 textBlock.parent.subBlocks.Insert(textBlock, block);
3262 textBlock.parent.subBlocks.Insert(block, newBlock);
3266 newBlock.textLen = textBlock.textLen - curPosition;
3267 newBlock.text = new char[newBlock.textLen+1];
3268 memcpy(newBlock.text, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
3269 textBlock.textLen = curPosition;
3270 textBlock.text[curPosition] = 0;
3272 newBlock.startY = startY;
3273 newBlock.startX = startX;
3274 selPosition = curPosition = 0;
3275 textBlock = newBlock;
3277 if(ch == '\r' && text[c+1] == '\n') c++;
3283 PositionCaret(true);
3291 // eC BUG HERE: (Should be fixed)
3292 if(key.ctrl && !key.alt && ch >= 32 && ch != 128 /*&& ch < 128*/)
3295 int len = UTF32toUTF8Len(&ch, 1, string, 5);
3298 textBlock.text = renew textBlock.text char[textBlock.textLen + len + 1];
3299 memmove(textBlock.text + curPosition + len, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
3301 for(c = 0; c<len; c++)
3303 textBlock.text[curPosition] = string[c];
3304 textBlock.textLen++;
3307 selPosition = curPosition;
3310 //Clear(html.block);
3311 //CreateForms(html.block);
3316 PositionCaret(true);
3325 void OnResize(int width, int height)
3327 HTMLView::OnResize(width, height);
3328 PositionCaret(true);
3332 void PositionCaret(bool setCaretX)
3338 int sx = textBlock.startX, sy = textBlock.startY;
3339 char * text = textBlock.text;
3341 Block block = textBlock;
3342 while(block && block.type != TD) block = block.parent;
3345 Block table = block;
3346 while(table && table.type != TABLE) table = table.parent;
3348 maxW = block.w - 2* table.cellPadding;
3350 maxW = clientSize.w - 10 - sx;
3353 maxW = clientSize.w - 10 - sx;
3355 display.FontExtent(textBlock.font.font, " ", 1, null, &th);
3357 while(textPos < textBlock.textLen)
3359 int startPos = textPos;
3362 bool lineComplete = false;
3364 for(; textPos<textBlock.textLen && !lineComplete;)
3368 char * nextSpace = strchr(text + textPos, ' ');
3371 len = (nextSpace - (text + textPos)) + 1;
3373 len = textBlock.textLen - textPos;
3375 display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
3377 if(x + width + w > maxW && x > 0)
3379 lineComplete = true;
3392 if(curPosition < textPos || textPos == textBlock.textLen)
3394 int len = curPosition - startPos;
3395 display.FontExtent(textBlock.font.font, text + startPos, len, &tw, null);
3400 sx = textBlock.startX;
3405 SetCaret(sx, sy, th);
3407 Point scrollPos = scroll;
3408 bool doScroll = false;
3409 if(sy - scroll.y + th > clientSize.h)
3411 scrollPos.y = sy + th - clientSize.h;
3414 else if(sy - scroll.y < 0)
3419 if(sx - scroll.x + 10 > clientSize.w)
3421 scrollPos.x = sx + 10 - clientSize.w;
3424 else if(sx - scroll.x < 10)
3426 scrollPos.x = sx - 10;
3437 // Returns a character offset into the TextBlock from a window coordinate
3438 int TextPosFromPoint(int px, int py, Block * block)
3440 Block parentBlock = this.textBlock.parent;
3443 *block = this.textBlock;
3448 for(textBlock = parentBlock.subBlocks.first; textBlock; textBlock = textBlock.next)
3450 int sx = textBlock.startX, sy = textBlock.startY;
3453 char * text = textBlock.text;
3455 Block b = textBlock;
3458 if(textBlock.type != TEXT) continue;
3460 while(b && b.type != TD) b = b.parent;
3464 while(table && table.type != TABLE) table = table.parent;
3466 maxW = b.w - 2* table.cellPadding;
3468 maxW = clientSize.w - 10 - sx;
3471 maxW = clientSize.w - 10 - sx;
3473 display.FontExtent(textBlock.font.font, " ", 1, &space, &th);
3474 //space = space/2+2;
3477 while(textPos < textBlock.textLen)
3479 int startPos = textPos;
3482 bool lineComplete = false;
3484 for(; textPos<textBlock.textLen && !lineComplete;)
3488 char * nextSpace = strchr(text + textPos, ' ');
3491 len = (nextSpace - (text + textPos)) + 1;
3493 len = textBlock.textLen - textPos;
3495 display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
3497 sx = x + textBlock.startX;
3498 if(/*py >= sy && */py < sy + th && /*px >= sx-space && */px < sx + w-space)
3503 for(c = textPos; (ch = text[c]); c += numBytes)
3505 numBytes = UTF8_NUM_BYTES(ch);
3506 display.FontExtent(textBlock.font.font, text + c, numBytes, &w, &th);
3507 if(/*py >= sy && */py < sy + th && /*px >= sx-w/2-space && */px < sx + w -w/2-space)
3514 if(x + width + w > maxW && x > 0)
3516 lineComplete = true;
3529 if(/*py >= sy && */py < sy + th)
3532 return textBlock.textLen;
3537 result = textBlock.textLen;
3543 Application componentsApp;
3545 class Documentor : GuiApplication
3549 Platform os = GetRuntimePlatform();
3550 componentsApp = __ecere_COM_Initialize(false, 1, null);
3551 SetPrivateModule(componentsApp);
3552 SetGlobalContext(globalContext);
3553 SetExcludedSymbols(&excludedSymbols);
3554 SetDefines(&::defines);
3555 SetImports(&imports);
3557 SetGlobalData(globalData);
3559 settingsContainer.dataOwner = &settings;
3560 settingsContainer.Load();
3561 if(!settings.docDir || !settings.docDir[0] )
3563 if(os == win32) // if Windows OS then
3565 char programFilesDir[MAX_LOCATION];
3566 char appData[MAX_LOCATION];
3567 char homeDrive[MAX_LOCATION];
3568 char winDir[MAX_LOCATION];
3569 GetEnvironment("APPDATA", appData, sizeof(appData));
3570 GetEnvironment("HOMEDRIVE", homeDrive, sizeof(homeDrive));
3571 GetEnvironment("windir", winDir, sizeof(winDir));
3572 if(GetEnvironment("ProgramFiles", programFilesDir, MAX_LOCATION))
3574 PathCat(programFilesDir, "ECERE SDK\\doc");
3575 settings.docDir = programFilesDir;
3577 else if(homeDrive && homeDrive[0])
3579 PathCat(homeDrive, "ECERE SDK\\doc");
3580 settings.docDir = homeDrive;
3582 else if(winDir && winDir[0])
3584 PathCat(winDir, "..\\ECERE SDK\\doc");
3585 settings.docDir = winDir;
3588 settings.docDir = "C:\\ECERE SDK\\doc";
3590 else // if Os is Linux, or Mac OSX or something else
3591 settings.docDir = "/usr/share/ecere/doc/";
3592 settingsContainer.Save();
3598 Module module = eModule_Load(componentsApp, "ecere" /*argv[1]*/, privateAccess);
3600 AddComponents(module, true);
3601 mainForm.browser.currentRow = row = mainForm.browser.FindSubRow((int)module);
3602 // mainForm.browser.currentRow = row = mainForm.browser.FindSubRow((int)eSystem_FindClass(componentsApp, "Window"));
3603 while((row = row.parent))
3604 row.collapsed = false;
3612 FreeContext(globalContext);
3613 FreeExcludedSymbols(excludedSymbols);
3614 ::defines.Free(FreeModuleDefine);
3615 imports.Free(FreeModuleImport);
3617 FreeGlobalData(globalData);
3618 FreeTypeData(componentsApp);
3620 delete componentsApp;
3624 MainForm mainForm { };