static OldList defines { };
static OldList imports { };
static NameSpace globalData;
-static OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
+static OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
+static bool readOnly;
+
+define app = (GuiApplication)__thisModule.application;
#define UTF8_NUM_BYTES(x) (__extension__({ byte b = x; (b & 0x80 && b & 0x40) ? ((b & 0x20) ? ((b & 0x10) ? 4 : 3) : 2) : 1; }))
enum CodeObjectType { typeClass, typeData, typeMethod, typeEvent, typeProperty, typeNameSpace, typeDataType, typeEnumValue, typeDataPrivate, typeMethodPrivate, typePropertyPrivate };
-static char * iconNames[CodeObjectType] =
+static char * iconNames[CodeObjectType] =
{
"<:ecere>constructs/class.png",
"<:ecere>constructs/data.png",
{
if(type._class.registered)
{
- char hex[10];
- sprintf(hex, "%08x", type._class.registered);
+ char hex[20];
+ sprintf(hex, "%p", type._class.registered);
strcat(string, "<a href=\"api://");
strcat(string, hex);
strcat(string, "\" style=\"text-decoration: none;\">");
strcat(string, "</a>");
}
else
- strcat(string, type._class.string);
+ strcat(string, type._class.string);
}
}
break;
DocPrintType(param, string, false, fullName);
if(param.next) strcat(string, ", ");
}
- strcat(string, ")");
+ strcat(string, ")");
}
else*/
{
DocPrintType(type.returnType, string, false, fullName);
strcat(string, " ");
}
-
+
// DANGER: Testing This
if(printName)
{
DocPrintType(param, string, false, fullName);
if(param.next) strcat(string, ", ");
}
- strcat(string, ")");
+ strcat(string, ")");
}
else*/
{
strcat(size, arrayType.enumClass.string);
else if(arrayType.arraySizeExp)
PrintExpression(arrayType.arraySizeExp, size);
- //sprintf(string, "%s[%s]", baseType, size);
+ //sprintf(string, "%s[%s]", baseType, size);
strcat(size, "]");
arrayType = arrayType.arrayType;
strcpy(size, type.enumClass.string);
else if(type.arraySizeExp)
PrintExpression(type.arraySizeExp, size);
- //sprintf(string, "%s[%s]", baseType, size);
+ //sprintf(string, "%s[%s]", baseType, size);
strcat(string, baseType);
strcat(string, "[");
- strcat(string, size);
+ strcat(string, size);
strcat(string, "]");
*/
case subClassType:
strcat(string, "subclass(");
strcat(string, type._class ? type._class.string : "int");
- strcat(string, ")");
+ strcat(string, ")");
break;
default:
printf("");
{
page.Generate(f);
}
+
+ virtual Module GetModule()
+ {
+ return page ? page.GetModule() : null;
+ }
+
+ virtual NameSpace * GetNameSpace()
+ {
+ return page ? page.GetNameSpace() : null;
+ }
};
enum DocumentationType
case example: strcat(fileName, "example"); break;
case seeAlso: strcat(fileName, "seeAlso"); break;
case returnValue: strcat(fileName, "returnValue"); break;
- case enumerationValue:
+ case enumerationValue:
strcat(fileName, "enumeration values/");
strcat(fileName, ((NamedLink)data).name);
break;
{
contents = new char[len+1];
file.Read(contents, 1, len);
- contents[len] = '\0';
+ contents[len] = '\0';
}
delete file;
}
for(c = 0; contents[c]; c++)
if(!isspace(contents[c])) break;
if(!contents[c])
- delete contents;
+ delete contents;
}
- if(editing && !contents)
+ if(editing && !contents && !readOnly)
contents = CopyString($"[Add Text]");
return contents;
}
{
NameSpace * nameSpace;
Module module;
-
+
+ Module GetModule()
+ {
+ return module;
+ }
+
+ NameSpace * GetNameSpace()
+ {
+ return nameSpace;
+ }
+
void Generate(File f)
{
char string[1024];
{
f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", nsName );
tag = (uint)nameSpace;
- 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);
+ f.Printf($"Module: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
}
else
{
strcpy(nsName, temp);
ns = ns->parent;
}
- if(nsName[0])
- f.Printf($"Parent namespace: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", nameSpace->parent, nsName);
+ if(nsName[0])
+ f.Printf($"Parent namespace: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", nameSpace->parent, nsName);
f.Printf("<br>");
{
if(first)
{
f.Printf($"<H3>Sub Namespaces</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
first = false;
}
f.Printf("<TR>");
- 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);
+ f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a></TD>", iconNames[typeNameSpace], ns, ns->name);
if(desc)
{
if(editing)
if(first)
{
f.Printf($"<a name=Classes></a><H3>Classes</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
first = false;
}
f.Printf("<TR>");
- 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);
+ f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a></TD>", (cl.type == enumClass || cl.type == unitClass || cl.type == systemClass) ? iconNames[typeDataType] : iconNames[typeClass], cl, cl.name);
if(desc)
{
if(editing)
else
f.Printf("<TD valign=top height=22>%s</TD>", desc);
delete desc;
- }
+ }
f.Printf("</TR>\n");
}
}
if(first)
{
f.Printf($"<a name=Functions></a><H3>Functions</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
first = false;
}
f.Printf("<TR>");
- 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);
+ f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a></TD>", iconNames[typeMethod], function, name);
if(desc)
{
if(editing)
if(first)
{
f.Printf($"<a name=Definitions></a><H3>Definitions</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
first = false;
}
f.Printf("<TR>");
- 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);
+ f.Printf("<TD valign=top height=22 nowrap=1><a name=%p></a><img valign=center src=\"%s\"> %s</TD>", def, iconNames[typeData], def.name);
f.Printf("<TD valign=top height=22>%s</TD>", def.value);
if(desc)
{
}
f.Printf("</FONT></BODY></HTML>\n");
- }
+ }
}
class APIPageClass : APIPage
{
Class cl;
+ Module GetModule()
+ {
+ return cl.module;
+ }
+
+ NameSpace * GetNameSpace()
+ {
+ return cl.nameSpace;
+ }
+
void Generate(File f)
{
char string[1024];
f.Printf($"<HTML><HEAD><TITLE>API Reference</TITLE></HEAD>\n<BODY><FONT SIZE=\"3\">\n");
f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", name);
- 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);
- if(nsName[0])
- f.Printf($"Namespace: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", cl.nameSpace, nsName);
+ f.Printf($"Module: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
+ if(nsName[0])
+ f.Printf($"Namespace: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", cl.nameSpace, nsName);
{
char * classType = null;
}
f.Printf($"Type: %s<br>\n", classType);
}
-
+
if(cl.type != systemClass && cl.base)
{
f.Printf($"Base Class: ");
else if(cl.type == enumClass && !strcmp(cl.base.name, "enum"))
f.Printf("%s", cl.dataTypeString);
else
- f.Printf("<a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a>", cl.base, cl.base.name);
+ f.Printf("<a href=\"api://%p\" style=\"text-decoration: none;\">%s</a>", cl.base.templateClass ? cl.base.templateClass : cl.base, cl.base.name);
f.Printf("<br>\n");
}
if(enumeration.values.first)
{
NamedLink item;
-
+
f.Printf($"<a name=EnumerationValues></a><H3>Enumeration Values</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
for(item = enumeration.values.first; item; item = item.next)
{
bool needClass = true;
Class dataClass;
Class base = cl;
+ char tempString[1024];
+ String s;
while(base.type == enumClass) base = base.base;
if(base.type == systemClass ||
dataClass = base.dataType._class ? base.dataType._class.registered : null;
}
else
- dataClass = base;
-
+ dataClass = base;
+
f.Printf("<TR>");
- 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);
+ f.Printf("<TD valign=top height=22 nowrap=1><a name=%p></a><img valign=center src=\"%s\"> %s</TD>", item, iconNames[typeEnumValue], item.name);
if(dataClass.type == systemClass)
{
needClass = false;
- dataClass._vTbl[__ecereVMethodID_class_OnGetString](dataClass, &item.data, string, sizeof(string), &needClass);
+ s = ((char *(*)(void *, void *, char *, void *, bool *))(void *)dataClass._vTbl[__ecereVMethodID_class_OnGetString])(dataClass, &item.data, tempString, null, &needClass);
}
else
- eSystem_FindClass(componentsApp, "class")._vTbl[__ecereVMethodID_class_OnGetString](dataClass, &item.data, string, sizeof(string), &needClass);
+ s = ((char *(*)(void *, void *, char *, void *, bool *))(void *)eSystem_FindClass(componentsApp, "class")._vTbl[__ecereVMethodID_class_OnGetString])(dataClass, &item.data, tempString, null, &needClass);
if(needClass)
- f.Printf("<TD valign=top height=22 nowrap=1>%s { %s }</TD>", dataClass.name, string);
+ f.Printf("<TD valign=top height=22 nowrap=1>%s { %s }</TD>", dataClass.name, s);
else
- f.Printf("<TD valign=top height=22 nowrap=1>%s</TD>", string);
+ f.Printf("<TD valign=top height=22 nowrap=1>%s</TD>", s);
if(desc)
{
if(editing)
if(cl.conversions.first)
{
f.Printf($"<a name=Conversions></a><H3>Conversions</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
for(prop = cl.conversions.first; prop; prop = prop.next)
{
if((prop.memberAccess == publicAccess || (prop.memberAccess == privateAccess && showPrivate)) && prop.name)
if(name) name += 2; else name = prop.name;
f.Printf("<TR>");
-
+
string[0] = 0;
DocPrintType(type, string, true, false);
-
- f.Printf("<TD valign=top height=22 nowrap=1><a name=%08x></a><img valign=center src=\"%s\"> %s</TD>", prop, iconNames[typeDataType], string);
+
+ f.Printf("<TD valign=top height=22 nowrap=1><a name=%p></a><img valign=center src=\"%s\"> %s</TD>", prop, iconNames[typeDataType], string);
if(desc)
{
if(editing)
f.Printf("<TD valign=top height=22>%s</TD>", desc);
delete desc;
}
-
+
f.Printf("</TR>\n");
-
+
FreeType(type);
}
}
if(first)
{
f.Printf($"<a name=Members></a><H3>Properties and Members</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
first = false;
}
string[0] = 0;
DocPrintType(prop.dataType, string, true, false);
- 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);
+ f.Printf("<TD valign=top height=22 nowrap=1><a name=%p></a><img valign=center src=\"%s\"> %s</TD>", prop, iconNames[typeProperty], prop.name);
f.Printf("<TD valign=top height=22 nowrap=1>%s</TD>", string);
if(desc)
{
if(first)
{
f.Printf($"<a name=VirtualMethods></a><H3>Virtual Methods</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
first = false;
}
if(!method.dataType)
ProcessMethodType(method);
f.Printf("<TR>");
- 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);
+ f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a></TD>", method.dataType.thisClass ? iconNames[typeEvent] : iconNames[typeMethod], method, method.name);
if(desc)
{
if(editing)
if(first)
{
f.Printf($"<a name=Methods></a><H3>Non-Virtual Methods</H3><br><br>\n");
- f.Printf("<TABLE >\n");
+ f.Printf("<TABLE>\n");
first = false;
}
ProcessMethodType(method);
f.Printf("<TR>");
- 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);
+ f.Printf("<TD valign=top height=22 nowrap=1><img valign=center src=\"%s\"> <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a></TD>", iconNames[typeMethod], method, method.name);
if(desc)
{
if(editing)
f.Printf("<TD valign=top height=22>%s</TD>", desc);
delete desc;
}
-
+
f.Printf("</TR><br>\n");
}
}
{
f.Printf($"<H3>Example</H3><br>\n");
f.Printf($"<FONT face=\"Courier New\">\n");
- f.Printf("<br><TABLE >\n");
+ f.Printf("<br><TABLE>\n");
if(editing)
{
char fileName[MAX_LOCATION];
delete remarksDoc;
}
}
-
+
if(cl.type != systemClass)
{
bool first = true;
}
else
f.Printf(", ");
- f.Printf("<a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a>", deriv, deriv.name);
- }
+ f.Printf("<a href=\"api://%p\" style=\"text-decoration: none;\">%s</a>", deriv, deriv.name);
+ }
}
if(!first)
f.Printf("<br><br>\n");
}
}
f.Printf("</FONT></BODY></HTML>\n");
- }
+ }
}
class APIPageMethod : APIPage
{
Method method;
+
+ Module GetModule()
+ {
+ return method._class.module;
+ }
+
+ NameSpace * GetNameSpace()
+ {
+ return method._class.nameSpace;
+ }
+
void Generate(File f)
{
Class cl = method._class;
f.Printf($"<HTML><HEAD><TITLE>API Reference</TITLE></HEAD>\n<BODY><FONT SIZE=\"3\">\n");
f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", name);
- 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);
+ f.Printf($"Module: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
if(nsName[0])
- f.Printf($"Namespace: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", cl.nameSpace, nsName);
- f.Printf("Class: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", cl, cl.name);
+ f.Printf($"Namespace: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", cl.nameSpace, nsName);
+ f.Printf("Class: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", cl, cl.name);
if(method.dataType.staticMethod)
{
f.Printf($"this pointer class: None<br>\n");
}
else if(method.dataType.thisClass && method.dataType.thisClass.registered && (method.dataType.thisClass.registered != method._class || method.type == virtualMethod))
{
- 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);
+ f.Printf($"this pointer class: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", method.dataType.thisClass.registered, method.dataType.thisClass.registered.name);
}
// Generate Method Page
FigureFileName(fileName, module, methodDoc, method, parameter, param);
f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
f.Puts(desc);
- f.Printf("s</a> </TD>\n");
+ f.Printf("</a></TD>\n");
}
else
f.Printf("<TD valign=top height=22>%s </TD>\n", desc);
delete desc;
}
-
+
f.Printf("</TR>\n");
}
}
{
f.Printf($"<H3>Example</H3><br>\n");
f.Printf($"<FONT face=\"Courier New\">\n");
- f.Printf("<br><TABLE >\n");
+ f.Printf("<br><TABLE>\n");
if(editing)
{
char fileName[MAX_LOCATION];
}
else
f.Printf("<br>%s\n", method, seeAlsoDoc);
-
+
f.Printf("<br><br>\n");
delete seeAlsoDoc;
}
}
f.Printf("</FONT></BODY></HTML>\n");
- }
+ }
}
class APIPageFunction : APIPage
{
GlobalFunction function;
+
+ Module GetModule()
+ {
+ return function.module;
+ }
+
+ NameSpace * GetNameSpace()
+ {
+ return function.nameSpace;
+ }
+
void Generate(File f)
{
char string[1024];
f.Printf($"<HTML><HEAD><TITLE>API Reference</TITLE></HEAD>\n<BODY><FONT SIZE=\"3\">\n");
f.Printf("<FONT FACE=\"Arial\" SIZE=\"6\">%s</FONT><br><br>\n", name);
- 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);
+ f.Printf($"Module: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", (module && module.name) ? module : null, (!module || !module.name || !strcmp(nsName, "ecere::com")) ? "ecereCOM" : module.name);
if(nsName[0])
- f.Printf($"Namespace: <a href=\"api://%08x\" style=\"text-decoration: none;\">%s</a><br>\n", function.nameSpace, nsName);
+ f.Printf($"Namespace: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", function.nameSpace, nsName);
if(!function.dataType)
function.dataType = ProcessTypeString(function.dataTypeString, false);
if(function.dataType.thisClass && function.dataType.thisClass.registered)
{
- 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);
+ f.Printf($"this pointer class: <a href=\"api://%p\" style=\"text-decoration: none;\">%s</a><br>\n", function.dataType.thisClass.registered, function.dataType.thisClass.registered.name);
}
// Generate Method Page
char fileName[MAX_LOCATION];
FigureFileName(fileName, module, functionDoc, function, parameter, param);
f.Printf("<TD valign=top height=22><a style=\"text-decoration:none;\" href=\"edit://%s\">", fileName);
- f.Puts(desc);
+ if(desc)
+ f.Puts(desc);
f.Printf("</a> </TD>\n");
}
else
{
f.Printf($"<H3>Example</H3><br>\n");
f.Printf($"<FONT face=\"Courier New\">\n");
- f.Printf("<br><TABLE >\n");
+ f.Printf("<br><TABLE>\n");
if(editing)
{
char fileName[MAX_LOCATION];
}
}
f.Printf("</FONT></BODY></HTML>\n");
- }
+ }
}
static void AddNameSpace(DataRow parentRow, Module module, NameSpace mainNameSpace, NameSpace comNameSpace, char * parentName, bool showPrivate)
APIPage page;
char fileName[MAX_LOCATION];
-
+
strcpy(nsName, parentName ? parentName : "");
if(nameSpace->name)
{
{
for(nameSpace = mainNameSpace ; nameSpace; nameSpace = (nameSpace == mainNameSpace) ? comNameSpace : null)
{
- if(nameSpace->functions.first)
+ if(nameSpace->functions.first)
{
BTNamedLink link;
GlobalFunction fn;
if(!functionsRow) { functionsRow = row.AddRow(); functionsRow.SetData(null, APIPage { $"Functions", page = page }); functionsRow.collapsed = true; functionsRow.icon = mainForm.icons[typeMethod]; functionsRow.tag = 2; };
fnRow = functionsRow.AddRow(); fnRow.SetData(null, APIPageFunction { name, function = fn }); fnRow.icon = mainForm.icons[typeMethod]; fnRow.tag = (int)fn;
}
- }
+ }
}
}
}
-
+
if(mainNameSpace.defines.first || (comNameSpace && comNameSpace.defines.first))
{
for(nameSpace = mainNameSpace ; nameSpace; nameSpace = (nameSpace == mainNameSpace) ? comNameSpace : null)
if(!definesRow) { definesRow = row.AddRow(); definesRow.SetData(null, APIPage { $"Definitions", page = page }); definesRow.collapsed = true; definesRow.icon = mainForm.icons[typeData]; definesRow.tag = 3; };
defRow = definesRow.AddRow(); defRow.SetData(null, APIPage { name, page = page }); defRow.icon = mainForm.icons[typeData]; defRow.tag = (int)def;
}
- }
+ }
}
}
}
string[0] = 0;
DocPrintType(member.dataType, string, true, false);
- f.Printf("<TD valign=top height=22 nowrap=1><a name=%08x></a>", member);
+ f.Printf("<TD valign=top height=22 nowrap=1><a name=%p></a>", member);
for(c = 0; c<indent; c++)
f.Printf(" ");
f.Printf("<img valign=center src=\"%s\"> %s</TD>", iconNames[typeData], member.name ? member.name : ((member.type == structMember) ? "(struct)" : "(union)"));
}
else
f.Printf("<TD valign=top height=22></TD>");
-
+
if(member.type != normalMember)
{
DataMember subMember;
NamedLink item;
for(item = enumeration.values.first; item; item = item.next)
{
- DataRow mRow;
+ DataRow mRow;
if(!enumRow) { enumRow = row.AddRow(); enumRow.SetData(null, APIPage { $"Enumeration Values", page = page }); enumRow.collapsed = true; enumRow.icon = mainForm.icons[typeEnumValue]; enumRow.tag = 8; }
- mRow = enumRow.AddRow(); mRow.SetData(null, APIPage { item.name, page = page }); mRow.icon = mainForm.icons[typeEnumValue];
+ mRow = enumRow.AddRow(); mRow.SetData(null, APIPage { item.name, page = page }); mRow.icon = mainForm.icons[typeEnumValue];
mRow.tag = (int)item;
}
}
bool NotifySelect(MenuItem selection, Modifiers mods)
{
- SettingsDialog { master = this }.Modal(); // Open the settings dialog to allow the user to change the directory for the eCdoc files
+ if(SettingsDialog { master = this }.Modal() == ok) // Open the settings dialog to allow the user to change the directory for the eCdoc files
+ {
+ // Refresh docs
+ view.edit = false;
+ view.Destroy(0);
+ view.Create();
+ }
+ return true;
}
};
MenuDivider { fileMenu };
FreeExcludedSymbols(excludedSymbols);
::defines.Free(FreeModuleDefine);
imports.Free(FreeModuleImport);
-
+
FreeGlobalData(globalData);
FreeTypeData(componentsApp);
FreeIncludeFiles();
if(extension[0] && strcmpi(extension, "so") && strcmpi(extension, "dll"))
componentsApp.name = CopyString(filePath);
-
+
for(module = componentsApp.allModules.first; module; module = module.next)
{
if(module.name && (!strcmp(module.name, "ecere") || !strcmp(module.name, "ecereCOM")))
}
else if(!view.created)
view.Create();
-
+
{
page = row.GetData(null);
if(page && page.page)
case 8: view.GoToAnchor("EnumerationValues"); break;
default:
{
- char hex[10];
- sprintf(hex, "%08x", row.tag);
+ char hex[20];
+ sprintf(hex, "%p", row.tag);
view.GoToAnchor(hex);
}
}
bool OnCreate()
{
TempFile f { };
+
page = mainForm.browser.currentRow.GetData(null);
if(page)
{
+ // Writability test
+ {
+ char docFile[MAX_LOCATION];
+ Archive archive;
+ Module module = page ? page.GetModule() : null;
+ NameSpace * ns = page ? page.GetNameSpace() : null;
+
+ sprintf(docFile, "%s/%s.eCdoc", settings.docDir, (!module || !module.name || (ns && ns->name && !strcmp(ns->name, "namespaces/ecere/namespaces/com"))) ? "ecereCOM" : module.name);
+
+ if(FileExists(docFile))
+ {
+ archive = ArchiveOpen(docFile, { true } );
+ readOnly = archive == null;
+ delete archive;
+ }
+ else
+ {
+ readOnly = true;
+ archive = ArchiveOpen(docFile, { true } );
+ if(archive)
+ {
+ // Must create root directory on archive creation
+ ArchiveDir dir = archive.OpenDirectory("", null, replace);
+ if(dir)
+ readOnly = false;
+ delete dir;
+ }
+ delete archive;
+ }
+ }
+
page.Generate(f);
f.Seek(0, start);
OpenFile(f, null);
char fileName[MAX_FILENAME];
char directory[MAX_LOCATION];
char * location;
- Archive archive;
- SplitArchivePath(editString, archiveFile, &location);
- GetLastDirectory(location, fileName);
- StripLastDirectory(location, directory);
- archive = ArchiveOpen(archiveFile, { true } );
- if(archive)
+ Archive archive = null;
+ if(SplitArchivePath(editString, archiveFile, &location))
+ {
+ GetLastDirectory(location, fileName);
+ StripLastDirectory(location, directory);
+ archive = ArchiveOpen(archiveFile, { true } );
+ }
{
TempFile f { };
- ArchiveDir dir = archive.OpenDirectory(directory, null, replace);
+ ArchiveDir dir = archive ? archive.OpenDirectory(directory, null, replace) : null;
Block block;
bool empty = true;
for(block = textBlock.parent.subBlocks.first; block; block = block.next)
}
}
f.Seek(0, start);
- dir.AddFromFile(fileName, f, null, replace, 0, null, null);
+ if(dir)
+ dir.AddFromFile(fileName, f, null, replace, 0, null, null);
delete dir;
delete archive;
delete f;
parent.subBlocks.Add(textBlock);
}
- edit = false;
+ edit = false;
if(created)
{
ComputeMinSizes();
bool OnLeftButtonDown(int x, int y, Modifiers mods)
{
- if(edit)
+ bool result = true;
+
+ if(edit && (!textBlock || overLink != textBlock.parent))
{
- // Update overLink
- HTMLView::OnMouseMove(x, y, mods);
- if(textBlock && overLink == textBlock.parent)
- {
- selPosition = curPosition = TextPosFromPoint(x, y, &textBlock);
- PositionCaret(true);
- }
- else
- {
+ if(!readOnly)
SaveEdit();
- HTMLView::OnLeftButtonDown(x, y, mods);
- }
- return true;
+ HTMLView::OnLeftButtonDown(x, y, mods);
+ selPosition = curPosition = 0;
+ selBlock = textBlock;
+ Update(null);
}
- return HTMLView::OnLeftButtonDown(x, y, mods);
- }
+ else
+ result = HTMLView::OnLeftButtonDown(x, y, mods);
- bool OnLeftButtonUp(int x, int y, Modifiers mods)
- {
- if(!edit || !textBlock || clickedLink != textBlock.parent)
+ if(!edit && clickedLink)
{
- HTMLView::OnLeftButtonUp(x, y, mods);
- if(edit)
+ ReleaseCapture();
+ if(clickedLink == overLink && clickedLink.href)
{
- selPosition = curPosition = TextPosFromPoint(x, y, &textBlock);
- PositionCaret(true);
+ if(OnOpen(clickedLink.href))
+ Update(null);
}
}
- return true;
- }
-
- // Returns true if it needs scrolling
- /*
- bool FindMouse(int px, int py, int * tx, int * ty, EditLine * tline, bool half)
- {
- int w;
- int c;
- int x, y;
- EditLine line;
- bool needHScroll = false;
- if(py < 0)
- {
- if(this.viewY > 0)
- {
- y = this.viewY-1;
- line = this.viewLine ? (void *)this.viewLine.prev : null;
- }
- else
- {
- y = 0;
- line = (void *)this.lines.first;
- }
- }
- else
+ if(edit)
{
- py = Min(py, clientSize.h);
- py /= this.space.h;
- py = Min(py, this.lineCount);
- y = this.viewY;
- for(c = 0, line = this.viewLine; (line != (void *)this.lines.last && c<py); line = line.next, c++)
+ // Update overLink
+ if(textBlock && overLink == textBlock.parent)
{
- y++;
+ selPosition = curPosition = TextPosFromPoint(x, y, &textBlock, true);
+ selBlock = textBlock;
+ PositionCaret(true);
+ selecting = true;
+ Update(null);
}
}
-
- if( (px >= clientSize.w || px < clientSize.w/2) && this.viewX)
- needHScroll = true;
- px = Max(px,0);
- px = Min(px,clientSize.w+this.space.w);
-
- if(tx && line)
- {
- *tx = AdjustXPosition(line, px + viewX, half, null, MAXINT, 0);
- }
-
- if(tline) *tline = line;
- if(ty) *ty = y;
-
- // Prevent divide by 0 from non valid this.font
- if(!this.space.h)
- return (y < this.viewY) || needHScroll;
- else
- return (y < this.viewY || y >= this.viewY + clientSize.h / this.space.h) || needHScroll;
- return false;
+ return result;
}
-*/
-/*
- bool OnLeftButtonDown(int mx, int my, Modifiers mods)
- {
- int x,y;
- EditLine line;
-
- if(style.noSelect) return true;
-
- if(!mods.isActivate)
- {
- Capture();
- mouseSelect = true;
- }
-
- mouseX = mx - XOFFSET;
- mouseY = my;
-
- FindMouse(mouseX, mouseY, &x, &y, &line, true);
- if(!style.readOnly)
- {
- if(wordSelect)
- mouseMove = false;
- else if(IsMouseOnSelection() && !mods.isActivate)
- {
- DirtyLine(this.y);
- mouseMove = true;
- dropX = x;
- dropY = y;
- dropLine = line;
- }
- }
-
- if(!mouseMove && !wordSelect && (!mods.isActivate || style.multiLine))
- {
- if(mods.shift && !mods.isActivate)
- {
- this.x = x;
- this.y = y;
- this.line = line;
- DirtyAll();
- }
- else
- {
- SelDirty();
- DirtyLine(this.y);
- this.x = x;
- this.y = y;
- this.line = line;
- DirtyLine(this.y);
- this.selLine = this.line;
- this.selX = this.x;
- this.selY = this.y;
- //Deselect();
- }
- ComputeColumn();
- }
-
- UpdateDirty();
- UpdateCaretPosition(true);
- return true;
- }
-*/
-/*
bool OnLeftButtonUp(int x, int y, Modifiers mods)
{
- timer.Stop();
-
- mouseSelect = false;
- wordSelect = false;
-
- x -= XOFFSET;
-
- ReleaseCapture();
- if(!style.readOnly)
+ if(!edit || !textBlock || clickedLink != textBlock.parent)
{
- if(mouseMove)
- {
- EditLine line;
- FindMouse(mouseX, mouseY, &x, &y, &line, true);
-
- dropX = x;
- dropY = y;
- dropLine = line;
-
- mouseMove = IsMouseOnSelection();
-
- if(!mouseMove)
- {
- int size = SelSize();
- if(size)
- {
- char * text = new char[size+1];
- if(text)
- {
- int moveX = 0;
- GetSel(text, false);
-
- if(Max(selY, this.y) == dropY)
- {
- if(this.x > selX)
- {
- if(this.dropX > this.selX)
- moveX = this.x - this.selX;
- }
- else
- {
- if(this.dropX > this.x)
- moveX = this.selX - this.x;
- }
- }
- DelSel(null);
- this.dropX -= moveX;
- this.selX = this.x = this.dropX;
- this.selY = this.y = this.dropY;
- this.selLine = this.line = this.dropLine;
- AddS(text);
- SetViewToCursor(true);
- delete text;
- Modified();
- }
- }
- }
- else
- {
- SelDirty();
- DirtyLine(this.y);
- this.x = x;
- this.y = y;
- this.line = line;
- ComputeColumn();
- DirtyLine(this.y);
- Deselect();
- UpdateDirty();
- }
- }
- else
+ HTMLView::OnLeftButtonUp(x, y, mods);
+ if(edit)
{
- EditLine line;
- mouseX = x;
- mouseY = y;
-
- FindMouse(mouseX, mouseY, &x, &y, &line, true);
-
- NotifyDropped(master, this, x, y);
+ selPosition = curPosition = TextPosFromPoint(x, y, &textBlock, true);
+ selBlock = textBlock;
+ PositionCaret(true);
+ Update(null);
}
}
- mouseMove = false;
+ else
+ ReleaseCapture();
+ selecting = false;
return true;
}
+ bool selecting;
- bool OnMouseMove(int mx, int my, Modifiers mods)
+ bool OnMouseMove(int x, int y, Modifiers mods)
{
- int x,y;
- EditLine line;
- bool needScroll;
-
- if(mods != -1 && mods.isSideEffect)
- {
- SetSelectCursor();
- return true;
- }
- if(style.noSelect) return true;
- if(wordSelect) return true;
- mouseX = mx - XOFFSET;
- mouseY = my;
-
- needScroll = FindMouse(this.mouseX, this.mouseY, &x, &y, &line, true);
-
- if(this.mouseMove || this.mouseSelect)
- {
- if(!needScroll)
- timer.Stop();
- else
- {
- if(needScroll)
- timer.Start();
- if(mods != -1 &&
- ((style.hScroll) || (style.vScroll)))
- return true;
- }
- }
-
- if(this.mouseMove)
- {
- DirtyLine(this.dropY);
- this.dropX = x;
- this.dropY = y;
- DirtyLine(this.dropY);
- this.dropLine = line;
- SetViewToCursor(true);
- }
- else if(this.mouseSelect)
+ if(edit && selecting)
{
- DirtyLine(this.selY);
- DirtyLine(this.y);
- this.x = x;
- this.y = y;
- ComputeColumn();
- DirtyLine(this.y);
- this.line = line;
- SetViewToCursor(true);
- UpdateDirty();
+ curPosition = TextPosFromPoint(x, y, &textBlock, true);
+ PositionCaret(true);
+ Update(null);
}
- SetSelectCursor();
- return true;
+ return HTMLView::OnMouseMove(x, y, mods);
}
bool OnLeftDoubleClick(int mx, int my, Modifiers mods)
{
- int x,y;
- EditLine line;
-
- mx -= XOFFSET;
-
- if(style.noSelect) return true;
- FindMouse(mx, my, &x, &y, &line, false);
- if(!NotifyDoubleClick(master, this, line, mods))
- return false;
- if(x < line.count)
+ if(edit && textBlock)
{
int c;
int start = -1;
int numBytes;
- for(c = x; c >= 0; c--)
+
+ selPosition = curPosition = TextPosFromPoint(mx, my, &textBlock, false);
+ selBlock = textBlock;
+ for(c = curPosition; c >= 0; c--)
{
unichar ch;
- while(c > 0 && !UTF8_IS_FIRST(line.buffer[c])) c--;
- ch = UTF8_GET_CHAR(line.buffer + c, numBytes);
- if(!IS_ALUNDER(ch))
+ while(c > 0 && !UTF8_IS_FIRST(textBlock.text[c])) c--;
+ ch = UTF8GetChar(textBlock.text + c, &numBytes);
+ if(!CharMatchCategories(ch, letters|numbers|marks|connector))
break;
start = c;
}
if(start != -1)
{
- for(c = start; c<line.count; c += numBytes)
+ for(c = start; c < textBlock.textLen; c += numBytes)
{
- unichar ch = UTF8_GET_CHAR(line.buffer + c, numBytes);
- if(!IS_ALUNDER(ch))
+ unichar ch = UTF8GetChar(textBlock.text + c, &numBytes);
+ if(!CharMatchCategories(ch, letters|numbers|marks|connector))
break;
}
- SelDirty();
- DirtyLine(this.y);
- this.y = y;
- DirtyLine(this.y);
- this.selX = start;
- this.x = c;
- ComputeColumn();
- this.line = this.selLine = line;
- this.wordSelect = (c != start);
- UpdateDirty();
+ selPosition = start;
+ curPosition = c;
+
+ PositionCaret(true);
+ Update(null);
+ return false;
}
}
return true;
}
-*/
+
bool OnOpen(char * href)
{
if(!strncmp(href, "api://", 6))
{
- int tag = strtoul(href + 6, null, 16);
+ int tag = (uint)strtoul(href + 6, null, 16);
DataRow row = mainForm.browser.FindSubRow(tag);
if(row)
{
else
{
block.parent.subBlocks.Insert(block, newBlock);
- startY += th;
- }
+ startY += block.prev.height;
+ }
newBlock.startX = startX;
newBlock.startY = startY;
newBlock.text = new0 char[1];
if(!strcmp(textBlock.text, $"[Add Text]"))
{
textBlock.text[0] = 0;
- textBlock.textLen = 0;
+ textBlock.textLen = 0;
}
strcpy(editString, href + 7);
selPosition = curPosition = 0;
+ selBlock = textBlock;
// dialog.Create();
edit = true;
- PositionCaret(true);
+ // PositionCaret(true);
}
return true;
}
- Block textBlock;
char * text;
- int curPosition, selPosition;
+
+ void DeleteSelection()
+ {
+ if(textBlock != selBlock || curPosition != selPosition)
+ {
+ if(textBlock == selBlock)
+ {
+ // Within same block
+ int start = Min(curPosition, selPosition);
+ int end = Max(curPosition, selPosition);
+ memmove(textBlock.text + start, textBlock.text + end, textBlock.textLen - end);
+ textBlock.textLen -= end-start;
+ textBlock.text = renew textBlock.text char[textBlock.textLen + 1];
+ curPosition = start;
+ selPosition = start;
+ }
+ else
+ {
+ int startSel, endSel;
+ Block startSelBlock = null, endSelBlock = null, b, next;
+
+ NormalizeSelection(&startSelBlock, &startSel, &endSelBlock, &endSel);
+
+ startSelBlock.text = renew startSelBlock.text char[startSel + endSelBlock.textLen - endSel + 1];
+ memcpy(startSelBlock.text + startSel, endSelBlock.text + endSel, endSelBlock.textLen - endSel + 1);
+
+ startSelBlock.textLen = startSel + endSelBlock.textLen - endSel;
+ for(b = startSelBlock.next; b; b = next)
+ {
+ bool isEnd = b == endSelBlock;
+ next = GetNextBlock(b);
+ b.parent.subBlocks.Remove(b);
+ delete b;
+ if(isEnd)
+ break;
+ }
+ textBlock = startSelBlock;
+ selBlock = startSelBlock;
+ curPosition = startSel;
+ selPosition = startSel;
+ }
+ ComputeMinSizes();
+ ComputeSizes();
+ PositionCaret(true);
+ Update(null);
+ }
+ }
+
+ String GetSelectionString()
+ {
+ String selection = null;
+ if(textBlock == selBlock)
+ {
+ // Within same block
+ int start = Min(curPosition, selPosition);
+ int end = Max(curPosition, selPosition);
+ int len = end - start;
+ selection = new char[len + 1];
+ memcpy(selection, textBlock.text + start, len);
+ selection[len] = 0;
+ }
+ else
+ {
+ int startSel, endSel;
+ Block startSelBlock = null, endSelBlock = null, b;
+ int totalLen = 0;
+
+ NormalizeSelection(&startSelBlock, &startSel, &endSelBlock, &endSel);
+
+ // Compute length
+ for(b = startSelBlock; b; b = GetNextBlock(b))
+ {
+ int start = (b == startSelBlock) ? startSel : 0;
+ int end = (b == endSelBlock) ? endSel : b.textLen;
+ int len = end - start;
+ totalLen += len;
+ if(b == endSelBlock)
+ break;
+ else if(b.type == TEXT)
+ totalLen++;
+ }
+
+ selection = new char[totalLen + 1];
+ totalLen = 0;
+ for(b = startSelBlock; b; b = GetNextBlock(b))
+ {
+ int start = (b == startSelBlock) ? startSel : 0;
+ int end = (b == endSelBlock) ? endSel : b.textLen;
+ int len = end - start;
+ memcpy(selection + totalLen, b.text + start, len);
+ totalLen += len;
+ if(b == endSelBlock)
+ break;
+ else if(b.type == TEXT)
+ selection[totalLen++] = '\n';
+ }
+ selection[totalLen] = 0;
+ }
+ return selection;
+ }
+
+ void CopySelection()
+ {
+ String s = GetSelectionString();
+ if(s)
+ {
+ int len = strlen(s);
+ ClipBoard cb { };
+ if(cb.Allocate(len + 1))
+ {
+ memcpy(cb.text, s, len + 1);
+ cb.Save();
+ }
+ delete cb;
+ delete s;
+ }
+ }
bool OnKeyDown(Key key, unichar ch)
{
case escape:
OnLeftButtonDown(0,0,0);
return false;
+ case Key { end, shift = true }:
case end:
- selPosition = curPosition = textBlock.textLen;
+ curPosition = textBlock.textLen;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
Update(null);
break;
+ case Key { home, shift = true }:
case home:
- selPosition = curPosition = 0;
+ curPosition = 0;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
Update(null);
break;
+ case Key { home, ctrl = true, shift = true }:
case ctrlHome:
- selPosition = curPosition = 0;
+ curPosition = 0;
while(textBlock.prev)
textBlock = textBlock.prev.prev;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
Update(null);
return false;
+ case Key { end, ctrl = true, shift = true }:
case ctrlEnd:
while(textBlock.next && textBlock.next.next)
textBlock = textBlock.next.next;
- selPosition = curPosition = textBlock.textLen;
+ curPosition = textBlock.textLen;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
Update(null);
return false;
return HTMLView::OnKeyDown(key, ch);
return true;
}
+
bool OnKeyHit(Key key, unichar ch)
{
if(edit)
{
switch(key)
{
+ case Key { up, shift = true }:
case up:
{
if(caretY == textBlock.startY)
if(textBlock.prev)
{
textBlock = textBlock.prev.prev;
- selPosition = curPosition = Min(curPosition, textBlock.textLen);
+ curPosition = Min(curPosition, textBlock.textLen);
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
+ Update(null);
PositionCaret(false);
caretY = MAXINT;
}
len = (nextSpace - (text + textPos)) + 1;
else
len = textBlock.textLen - textPos;
-
+
display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
if(x + width + w > maxW && x > 0)
len = curPosition - startPos;
display.FontExtent(textBlock.font.font, text + startPos, len, &x, null);
}
- selPosition = curPosition;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
+ Update(null);
+
PositionCaret(false);
return false;
}
{
int c = textPos - 1;
while(c > 0 && text[c] == ' ') c--;
- selPosition = curPosition = c + 1;
+ curPosition = c + 1;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
+ Update(null);
}
else
- selPosition = curPosition = textBlock.textLen;
+ {
+ curPosition = textBlock.textLen;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
+ Update(null);
+ }
PositionCaret(false);
return false;
}
}
return false;
}
+ case Key { down, shift = true }:
case down:
{
int tw = 0, th = 0;
len = (nextSpace - (text + textPos)) + 1;
else
len = textBlock.textLen - textPos;
-
+
display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
if(x + width + w > maxW && x > 0)
len = curPosition - startPos;
display.FontExtent(textBlock.font.font, text + startPos, len, &x, null);
}
- selPosition = curPosition;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
+ Update(null);
PositionCaret(false);
return false;
}
}
if(sy > caretY)
{
- selPosition = curPosition = textBlock.textLen;
+ curPosition = textBlock.textLen;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
+ Update(null);
PositionCaret(false);
return false;
- }
+ }
else if(textPos == textBlock.textLen && textBlock.next && textBlock.next.next)
{
startPos = 0;
sx = textBlock.startX;
}
}
-
+
/*if(textBlock.next && textBlock.next.next)
{
textBlock = textBlock.next.next;
selPosition = curPosition = Min(curPosition, textBlock.textLen);
+ selBlock = textBlock;
PositionCaret(false);
}*/
break;
}
- #define IS_ALUNDER(ch) ((ch) == '_' || isalnum((ch)))
+ case Key { right, shift = true, ctrl = true }:
case ctrlRight:
{
- // SELECTION CTRL-RIGHT
- /*
bool foundAlpha = false;
bool found = false;
Block line, lastLine;
int c;
for(c = start; c < line.textLen; c++)
{
- if(IS_ALUNDER(line.text[c]))
+ char ch = line.text[c];
+ bool isAlUnder = CharMatchCategories(ch, letters|numbers|marks|connector);
+ if(key.shift ? isAlUnder : !isAlUnder)
{
foundAlpha = true;
lastC = c;
else if(foundAlpha)
{
found = true;
+ if(!key.shift)
+ {
+ curPosition = c;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
+ Update(null);
+ textBlock = line;
+ PositionCaret(true);
+ }
break;
}
}
+ // No next word found,
if(!found && (c != curPosition || line != textBlock))
{
found = true;
lastLine = line;
lastC = line.textLen-1;
- break;
- }
- }
- if(found)
- {
- selPosition = curPosition = lastC+1;
- textBlock = lastLine;
- PositionCaret(true);
- }
- */
-
- bool foundAlpha = false;
- bool found = false;
- Block line;
-
- for(line = textBlock; (line && !found); line = line.next ? line.next.next : null)
- {
- int start = (line == textBlock) ? curPosition : 0;
- int c;
- for(c = start; c < line.textLen; c++)
- {
- if(!IS_ALUNDER(line.text[c]))
- foundAlpha = true;
- else if(foundAlpha)
+ if(key.shift)
+ break;
+ else
{
- found = true;
- selPosition = curPosition = c;
+ curPosition = line.textLen;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
+ Update(null);
+
textBlock = line;
PositionCaret(true);
- break;
}
}
- // No next word found,
- if(!found && (c != curPosition || line != textBlock))
- {
- found = true;
- selPosition = curPosition = line.textLen;
- textBlock = line;
- PositionCaret(true);
- }
- foundAlpha = true;
+ if(!key.shift)
+ foundAlpha = true;
+ }
+ if(key.shift && found)
+ {
+ curPosition = lastC+1;
+ textBlock = lastLine;
+ PositionCaret(true);
+ Update(null);
}
break;
}
+ case Key { left, ctrl = true, shift = true }:
case ctrlLeft:
{
bool foundAlpha = false;
if(line == textBlock) start = curPosition-1; else start = line.textLen-1;
for(c = start; c>=0; c--)
{
- if(IS_ALUNDER(line.text[c]))
+ if(CharMatchCategories(line.text[c], letters|numbers|marks|connector))
{
foundAlpha = true;
lastC = c;
}
}
}
- // No next word found,
+ // No next word found,
if(!found && curPosition > 0)
{
foundAlpha = true;
if(foundAlpha)
{
textBlock = lastLine;
- selPosition = curPosition = lastC;
+ curPosition = lastC;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
+ Update(null);
}
break;
}
+ case Key { right, shift = true }:
case right:
if(curPosition < textBlock.textLen)
{
curPosition += UTF8_NUM_BYTES(textBlock.text[curPosition]);
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
- selPosition = curPosition;
+ Update(null);
}
else if(textBlock.next && textBlock.next.next)
{
textBlock = textBlock.next.next;
- selPosition = curPosition = 0;
+ curPosition = 0;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
+ Update(null);
}
break;
+ case Key { left, shift = true }:
case left:
if(curPosition > 0)
{
while(curPosition > 0 && !UTF8_IS_FIRST(textBlock.text[--curPosition]));
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
- selPosition = curPosition;
+ Update(null);
}
else if(textBlock.prev)
{
textBlock = textBlock.prev.prev;
- selPosition = curPosition = textBlock.textLen;
+ curPosition = textBlock.textLen;
+ if(!key.shift)
+ {
+ selPosition = curPosition;
+ selBlock = textBlock;
+ }
PositionCaret(true);
+ Update(null);
}
break;
case backSpace:
- if(curPosition)
+ if(readOnly) break;
+ if(textBlock == selBlock && curPosition == selPosition)
{
- int c = curPosition;
- int nb = 1;
- while(c > 0 && !UTF8_IS_FIRST(textBlock.text[--c])) nb++;
- memmove(textBlock.text + curPosition - nb, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
- textBlock.textLen -= nb;
- textBlock.text = renew textBlock.text char[textBlock.textLen + 1];
- curPosition -= nb;
- selPosition = curPosition;
+ if(curPosition)
{
- //Clear(html.block);
- //CreateForms(html.block);
+ int c = curPosition;
+ int nb = 1;
+ while(c > 0 && !UTF8_IS_FIRST(textBlock.text[--c])) nb++;
+ memmove(textBlock.text + curPosition - nb, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
+ textBlock.textLen -= nb;
+ textBlock.text = renew textBlock.text char[textBlock.textLen + 1];
+ curPosition -= nb;
+ selPosition = curPosition;
+ selBlock = textBlock;
+
ComputeMinSizes();
ComputeSizes();
- //PositionForms();
+ PositionCaret(true);
+ Update(null);
}
- PositionCaret(true);
- Update(null);
- }
- else if(textBlock.prev)
- {
- Block prev = textBlock.prev, prevBlock = textBlock.prev.prev;
- prevBlock.text = renew prevBlock.text char[prevBlock.textLen + textBlock.textLen + 1];
- memcpy(prevBlock.text + prevBlock.textLen, textBlock.text, textBlock.textLen + 1);
-
- selPosition = curPosition = prevBlock.textLen;
- prevBlock.textLen += textBlock.textLen;
- textBlock.parent.subBlocks.Remove(prev);
- delete prev;
- textBlock.parent.subBlocks.Remove(textBlock);
- delete textBlock;
- textBlock = prevBlock;
-
+ else if(textBlock.prev)
{
- //Clear(html.block);
- //CreateForms(html.block);
+ Block prev = textBlock.prev, prevBlock = textBlock.prev.prev;
+ prevBlock.text = renew prevBlock.text char[prevBlock.textLen + textBlock.textLen + 1];
+ memcpy(prevBlock.text + prevBlock.textLen, textBlock.text, textBlock.textLen + 1);
+
+ selPosition = curPosition = prevBlock.textLen;
+ selBlock = textBlock;
+ prevBlock.textLen += textBlock.textLen;
+ textBlock.parent.subBlocks.Remove(prev);
+ if(prev == selBlock)
+ {
+ selBlock = textBlock;
+ selPosition = curPosition;
+ }
+ delete prev;
+ textBlock.parent.subBlocks.Remove(textBlock);
+ if(textBlock == selBlock)
+ {
+ selBlock = prevBlock;
+ selPosition = curPosition;
+ }
+ delete textBlock;
+ textBlock = prevBlock;
+
ComputeMinSizes();
ComputeSizes();
- //PositionForms();
+ PositionCaret(true);
+ Update(null);
}
- PositionCaret(true);
- Update(null);
}
+ else
+ DeleteSelection();
break;
case del:
- if(textBlock.textLen > curPosition)
+ if(readOnly) break;
+ if(textBlock != selBlock || curPosition != selPosition)
+ DeleteSelection();
+ else if(textBlock.textLen > curPosition)
{
int nb = UTF8_NUM_BYTES(textBlock.text[curPosition]);
memmove(textBlock.text + curPosition, textBlock.text + curPosition + nb, textBlock.textLen - curPosition + 1 - nb + 1);
textBlock.textLen -= nb;
textBlock.text = renew textBlock.text char[textBlock.textLen + 1];
- {
- //Clear(html.block);
- //CreateForms(html.block);
- ComputeMinSizes();
- ComputeSizes();
- //PositionForms();
- }
+
+ ComputeMinSizes();
+ ComputeSizes();
+
PositionCaret(true);
Update(null);
}
textBlock.textLen += nextBlock.textLen;
textBlock.parent.subBlocks.Remove(next);
+ if(next == selBlock)
+ {
+ selBlock = textBlock;
+ selPosition = curPosition;
+ }
delete next;
- textBlock.parent.subBlocks.Remove(nextBlock);
- delete nextBlock;
-
+ textBlock.parent.subBlocks.Remove(nextBlock);
+ if(nextBlock == selBlock)
{
- //Clear(html.block);
- //CreateForms(html.block);
- ComputeMinSizes();
- ComputeSizes();
- //PositionForms();
+ selBlock = textBlock;
+ selPosition = curPosition;
}
+ delete nextBlock;
+
+ ComputeMinSizes();
+ ComputeSizes();
PositionCaret(true);
Update(null);
}
break;
case enter:
{
- Block block { type = BR, parent = textBlock.parent, font = textBlock.font };
- Block newBlock { type = TEXT, parent = textBlock.parent, font = textBlock.font };
- int startY = textBlock.startY, startX = textBlock.startX;
int tw = 0, th = 0;
+ Block block;
+ Block newBlock;
+ int startY, startX;
+
+ if(readOnly) break;
+ DeleteSelection();
+
+ block = { type = BR, parent = textBlock.parent, font = textBlock.font };
+ newBlock = { type = TEXT, parent = textBlock.parent, font = textBlock.font };
+ startY = textBlock.startY;
+ startX = textBlock.startX;
display.FontExtent(textBlock.font.font, " ", 1, null, &th);
textBlock.parent.subBlocks.Insert(textBlock, block);
newBlock.startY = startY;
newBlock.startX = startX;
selPosition = curPosition = 0;
- {
- //Clear(html.block);
- //CreateForms(html.block);
- ComputeMinSizes();
- ComputeSizes();
- //PositionForms();
- }
+
+ ComputeMinSizes();
+ ComputeSizes();
+
textBlock = newBlock;
+ selBlock = textBlock;
PositionCaret(true);
Update(null);
break;
}
+ case ctrlX:
+ case Key { del, shift = true }:
+ if(readOnly) break;
+ // Cut
+ CopySelection();
+ DeleteSelection();
+ break;
+ case ctrlC:
+ case ctrlInsert:
+ // Copy
+ CopySelection();
+ break;
case shiftInsert:
case ctrlV:
- {
- ClipBoard clipBoard { };
- if(clipBoard.Load())
- {
- int c;
- char * text = clipBoard.memory;
- char ch;
- int start = 0;
- Block parent = textBlock.parent;
- FontEntry font = textBlock.font;
- for(c = 0; ; c++)
+ if(!readOnly)
+ {
+ ClipBoard clipBoard { };
+ if(clipBoard.Load())
{
- ch = text[c];
- if(ch == '\n' || ch == '\r' || !ch)
+ int c;
+ char * text = clipBoard.memory;
+ char ch;
+ int start = 0;
+ Block parent;
+ FontEntry font;
+
+ DeleteSelection();
+
+ parent = textBlock.parent;
+ font = textBlock.font;
+
+ for(c = 0; ; c++)
{
- int len = c - start;
- textBlock.text = renew textBlock.text char[textBlock.textLen + 1 + len];
- memmove(textBlock.text + curPosition + len, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
- memcpy(textBlock.text + curPosition, text + start, len);
- textBlock.textLen += len;
- curPosition += len;
- selPosition = curPosition;
- if(!ch) break;
+ ch = text[c];
+ if(ch == '\n' || ch == '\r' || !ch)
{
- Block block { type = BR, parent = parent, font = font };
- Block newBlock { type = TEXT, parent = parent, font = font };
- int startY = textBlock.startY, startX = textBlock.startX;
- int tw = 0, th = 0;
-
- display.FontExtent(textBlock.font.font, " ", 1, null, &th);
- textBlock.parent.subBlocks.Insert(textBlock, block);
- textBlock.parent.subBlocks.Insert(block, newBlock);
-
- startY += th;
-
- newBlock.textLen = textBlock.textLen - curPosition;
- newBlock.text = new char[newBlock.textLen+1];
- memcpy(newBlock.text, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
- textBlock.textLen = curPosition;
- textBlock.text[curPosition] = 0;
-
- newBlock.startY = startY;
- newBlock.startX = startX;
- selPosition = curPosition = 0;
- textBlock = newBlock;
+ int len = c - start;
+ textBlock.text = renew textBlock.text char[textBlock.textLen + 1 + len];
+ memmove(textBlock.text + curPosition + len, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
+ memcpy(textBlock.text + curPosition, text + start, len);
+ textBlock.textLen += len;
+ curPosition += len;
+ selPosition = curPosition;
+ selBlock = textBlock;
+ if(!ch) break;
+ {
+ Block block { type = BR, parent = parent, font = font };
+ Block newBlock { type = TEXT, parent = parent, font = font };
+ int startY = textBlock.startY, startX = textBlock.startX;
+ int tw = 0, th = 0;
+
+ display.FontExtent(textBlock.font.font, " ", 1, null, &th);
+ textBlock.parent.subBlocks.Insert(textBlock, block);
+ textBlock.parent.subBlocks.Insert(block, newBlock);
+
+ startY += th;
+
+ newBlock.textLen = textBlock.textLen - curPosition;
+ newBlock.text = new char[newBlock.textLen+1];
+ memcpy(newBlock.text, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
+ textBlock.textLen = curPosition;
+ textBlock.text[curPosition] = 0;
+
+ newBlock.startY = startY;
+ newBlock.startX = startX;
+ selPosition = curPosition = 0;
+ selBlock = textBlock;
+ textBlock = newBlock;
+ }
+ if(ch == '\r' && text[c+1] == '\n') c++;
+ start = c + 1;
}
- if(ch == '\r' && text[c+1] == '\n') c++;
- start = c + 1;
}
+ ComputeMinSizes();
+ ComputeSizes();
+ PositionCaret(true);
+ Update(null);
}
- ComputeMinSizes();
- ComputeSizes();
- PositionCaret(true);
- Update(null);
+ delete clipBoard;
}
- delete clipBoard;
break;
- }
default:
{
// eC BUG HERE: (Should be fixed)
- if(!key.ctrl && !key.alt && ch >= 32 && ch != 128 /*&& ch < 128*/)
+ if(!readOnly && !key.ctrl && !key.alt && ch >= 32 && ch != 128 /*&& ch < 128*/)
{
char string[5];
int len = UTF32toUTF8Len(&ch, 1, string, 5);
int c;
+ DeleteSelection();
+
textBlock.text = renew textBlock.text char[textBlock.textLen + len + 1];
memmove(textBlock.text + curPosition + len, textBlock.text + curPosition, textBlock.textLen - curPosition + 1);
-
+
for(c = 0; c<len; c++)
{
textBlock.text[curPosition] = string[c];
curPosition++;
}
selPosition = curPosition;
-
+ selBlock = textBlock;
+
{
//Clear(html.block);
//CreateForms(html.block);
}
else
maxW = clientSize.w - 10 - sx;
-
+
display.FontExtent(textBlock.font.font, " ", 1, null, &th);
while(textPos < textBlock.textLen)
len = (nextSpace - (text + textPos)) + 1;
else
len = textBlock.textLen - textPos;
-
+
display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
if(x + width + w > maxW && x > 0)
int len = curPosition - startPos;
display.FontExtent(textBlock.font.font, text + startPos, len, &tw, null);
sx += tw;
- break;
+ break;
}
sy += th;
sx = textBlock.startX;
else if(sy - scroll.y < 0)
{
scrollPos.y = sy;
- doScroll = true;
+ doScroll = true;
}
if(sx - scroll.x + 10 > clientSize.w)
{
else if(sx - scroll.x < 10)
{
scrollPos.x = sx - 10;
- doScroll = true;
+ doScroll = true;
}
if(doScroll)
scroll = scrollPos;
}
// Returns a character offset into the TextBlock from a window coordinate
- int TextPosFromPoint(int px, int py, Block * block)
+ int TextPosFromPoint(int px, int py, Block * block, bool half)
{
Block parentBlock = this.textBlock.parent;
Block textBlock;
}
else
maxW = clientSize.w - 10 - sx;
-
+
display.FontExtent(textBlock.font.font, " ", 1, &space, &th);
//space = space/2+2;
space = 2;
len = (nextSpace - (text + textPos)) + 1;
else
len = textBlock.textLen - textPos;
-
+
display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
sx = x + textBlock.startX;
{
numBytes = UTF8_NUM_BYTES(ch);
display.FontExtent(textBlock.font.font, text + c, numBytes, &w, &th);
- if(/*py >= sy && */py < sy + th && /*px >= sx-w/2-space && */px < sx + w -w/2-space)
+ if(/*py >= sy && */py < sy + th && /*px >= sx-w/2-space && */px < sx + (half ? w/2 : w) -space)
break;
sx += w;
}
SetExcludedSymbols(&excludedSymbols);
SetDefines(&::defines);
SetImports(&imports);
-
+
SetGlobalData(globalData);
settingsContainer.dataOwner = &settings;
if(os == win32) // if Windows OS then
{
char programFilesDir[MAX_LOCATION];
- char appData[MAX_LOCATION];
+ char appData[MAX_LOCATION];
char homeDrive[MAX_LOCATION];
char winDir[MAX_LOCATION];
GetEnvironment("APPDATA", appData, sizeof(appData));
row.collapsed = false;
#endif
}
+
+ commandThread.Create();
+ return true;
+ }
+
+ bool Cycle(bool idle)
+ {
+ if(quit)
+ mainForm.Destroy(0);
return true;
}
void Terminate()
{
+ PrintLn("Exited");
+ console.Flush();
+ quit = true;
+ if(commandThread.created)
+ {
+ console.CloseInput();
+ console.CloseOutput();
+ app.Unlock();
+ commandThread.Wait();
+ app.Lock();
+ }
+
FreeContext(globalContext);
FreeExcludedSymbols(excludedSymbols);
::defines.Free(FreeModuleDefine);
}
}
+ConsoleFile console { };
MainForm mainForm { };
+bool quit;
+
+Thread commandThread
+{
+ unsigned int Main()
+ {
+ while(!quit)
+ {
+ char command[1024];
+ console.GetLine(command, sizeof(command));
+ if(!quit && command[0])
+ {
+ app.Lock();
+ if(!strcmpi(command, "Activate"))
+ mainForm.Activate();
+ else if(!strcmpi(command, "Quit"))
+ quit = true;
+ app.Unlock();
+ }
+ }
+ return 0;
+ }
+};