documentor; extras/html: Made it easier to position caret at beginning or end of...
[sdk] / documentor / src / Documentor.ec
index 46d9f3c..7dfc77e 100644 (file)
@@ -5,6 +5,14 @@ import "HTMLView"
 import "IDESettings"
 import "SettingsDialog"
 
+IDESettings ideSettings;
+
+IDESettingsContainer settingsContainer
+{
+   dataOwner = &ideSettings;
+   dataClass = class(IDESettings);
+};
+
 static Context globalContext { };
 static OldList defines { };
 static OldList imports { };
@@ -887,7 +895,7 @@ class APIPageNameSpace : APIPage
          {
             Class cl = link.data;
             Module module = cl.module ? cl.module  : this.module;
-            if(!cl.templateClass && !cl.internalDecl)
+            if(!cl.templateClass) // && !cl.internalDecl)
             {
                char * desc = ReadDoc(module, classDoc, cl, description, null);
 
@@ -1987,7 +1995,7 @@ static void AddNameSpace(DataRow parentRow, Module module, NameSpace mainNameSpa
             for(link = (BTNamedLink)nameSpace->classes.first; link; link = (BTNamedLink)((BTNode)link).next)
             {
                cl = link.data;
-               if(!cl.templateClass && !cl.internalDecl && (!module || cl.module == module || (!cl.module.name && !strcmp(module.name, "ecere"))))
+               if(!cl.templateClass /*&& !cl.internalDecl*/ && (!module || cl.module == module || (!cl.module.name && !strcmp(module.name, "ecere"))))
                {
                   if(!classesRow) { classesRow = row.AddRow(); classesRow.SetData(null, APIPage { $"Classes", page = page }); classesRow.collapsed = true; classesRow.icon = mainForm.icons[typeClass]; classesRow.tag = 1; }
                   AddClass(classesRow, module, cl, nsName, showPrivate);
@@ -2550,6 +2558,16 @@ class MainForm : Window
    bool dontRecordHistory;
    Module homeModule;
 
+   bool OnKeyHit(Key key, unichar ch)
+   {
+      switch(key)
+      {
+         case altLeft: Back(); return false;
+         case altRight: Forward(); return false;
+      }
+      return true;
+   }
+
    bool Forward()
    {
       if(historyPos < history.count-1)
@@ -3239,6 +3257,9 @@ class HelpView : HTMLView
          // dialog.Create();
          edit = true;
          // PositionCaret(true);
+
+         // TOCHECK: Adding this here seemed to fixed caret positioning bugs
+         ComputeSizes();
       }
       return true;
    }
@@ -4136,6 +4157,7 @@ class HelpView : HTMLView
          char * text = textBlock.text;
          int maxW;
          Block block = textBlock;
+         int xOffset = 0;
          while(block && block.type != TD) block = block.parent;
          if(block)
          {
@@ -4151,11 +4173,19 @@ class HelpView : HTMLView
 
          display.FontExtent(textBlock.font.font, " ", 1, null, &th);
 
+         // Work around to re-align with first line having different indentation because of &nbsp;&nbsp; before <A> of current block
+         {
+            Block parent = textBlock.parent;
+            while(parent && parent.type == ANCHOR) parent = parent.parent;
+            if(parent && parent.subBlocks.first && ((Block)parent.subBlocks.first).type == TEXT)
+               xOffset = sx - ((Block)parent.subBlocks.first).startX;
+         }
+
          while(textPos < textBlock.textLen)
          {
             int startPos = textPos;
             int width = 0;
-            int x = 0;
+            int x = xOffset;
             bool lineComplete = false;
 
             for(; textPos<textBlock.textLen && !lineComplete;)
@@ -4194,12 +4224,12 @@ class HelpView : HTMLView
                break;
             }
             sy += th;
-            sx = textBlock.startX;
+            sx = textBlock.startX - xOffset;
          }
          if(setCaretX)
             caretX = sx;
          caretY = sy;
-         SetCaret(sx, sy, th);
+         SetCaret(sx-1, sy, th);
          {
             Point scrollPos = scroll;
             bool doScroll = false;
@@ -4251,6 +4281,7 @@ class HelpView : HTMLView
          int maxW;
          Block b = textBlock;
          int space;
+         int xOffset = 0;
 
          if(textBlock.type != TEXT) continue;
 
@@ -4267,6 +4298,14 @@ class HelpView : HTMLView
          else
             maxW = clientSize.w - 10 - sx;
 
+         // Work around to re-align with first line having different indentation because of &nbsp;&nbsp; before <A> of current block
+         {
+            Block parent = textBlock.parent;
+            while(parent && parent.type == ANCHOR) parent = parent.parent;
+            if(parent && parent.subBlocks.first && ((Block)parent.subBlocks.first).type == TEXT)
+               xOffset = sx - ((Block)parent.subBlocks.first).startX;
+         }
+
          display.FontExtent(textBlock.font.font, " ", 1, &space, &th);
          //space = space/2+2;
          space = 2;
@@ -4274,7 +4313,7 @@ class HelpView : HTMLView
          while(textPos < textBlock.textLen)
          {
             int width = 0;
-            int x = 0;
+            int x = xOffset;
             bool lineComplete = false;
 
             for(; textPos<textBlock.textLen && !lineComplete;)
@@ -4290,7 +4329,7 @@ class HelpView : HTMLView
 
                display.FontExtent(textBlock.font.font, text + textPos, len, &w, &th);
 
-               sx = x + textBlock.startX;
+               sx = x + textBlock.startX - xOffset;
                if(/*py >= sy && */py < sy + th && /*px >= sx-space && */px < sx + w-space)
                {
                   int c, numBytes;