tarball: Updated for version 0.44.15
[sdk] / ide / src / designer / CodeEditor.ec
index d344e86..8656bd2 100644 (file)
@@ -606,7 +606,7 @@ bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo obje
    // Check if it contains any code
    if((!body.compound.declarations || !body.compound.declarations->count) && (!body.compound.statements || body.compound.statements->count <= 1))
    {
-      Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
+      // Class moduleClass = eSystem_FindClass(object.instance._class.module, "Module");
       Statement stmt = body.compound.statements ? body.compound.statements->first : null;
       Type dataType = method.dataType;
       Type returnType = dataType.returnType;
@@ -618,7 +618,7 @@ bool Code_IsFunctionEmpty(ClassFunction function, Method method, ObjectInfo obje
       confirmation = false;
 
       // Check if default function should be calling base class:
-      if(object.instance._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
+      if(object.instance._class._vTbl[method.vid] == null /*moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]*/) // Temp Check for DefaultFunction
       {
          if(returnType.kind != voidType)
          {
@@ -760,7 +760,7 @@ class CodeEditor : Window
    bool inUseDebug;
    OpenedFileInfo openedFileInfo;
 
-   FontResource font { codeFont.faceName, codeFont.size };
+   FontResource font { codeFont.faceName, codeFont.size, codeFont.bold, codeFont.italic };
    saveDialog = codeEditorFileDialog;
 
    Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
@@ -912,11 +912,11 @@ class CodeEditor : Window
          int oldLine = lastLine;
          display.FontExtent(font.font, " ", 1, null, &spaceH);
          {
-            Box box { 0, (Min(oldLine,oldLine)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(oldLine, oldLine))*spaceH-1 - editBox.scroll.y };
+            Box box { 0, (oldLine-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, oldLine*spaceH-1 - editBox.scroll.y };
             Update(box);
          }
          {
-            Box box { 0, (Min(line,line)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(line, line))*spaceH-1 - editBox.scroll.y };
+            Box box { 0, (line-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, line*spaceH-1 - editBox.scroll.y };
             Update(box);
          }
          lastLine = line;
@@ -1752,7 +1752,7 @@ class CodeEditor : Window
          display.FontExtent(font, ")", 1, &parW, null);
 
          string[0] = 0;
-         if(editor.functionType)
+         if(editor.functionType && type.kind == functionType)
          {
             PrintType(type.returnType, string, true, true);
             display.FontExtent(font, string, strlen(string), &functionW, null);
@@ -1918,7 +1918,7 @@ class CodeEditor : Window
          display.FontExtent(font, ")", 1, &parW, null);
 
          string[0] = 0;
-         if(editor.functionType && type)
+         if(editor.functionType && type && type.kind == functionType)
          {
             PrintType(type.returnType, string, true, true);
             display.FontExtent(font, string, strlen(string), &functionW, null);
@@ -2050,7 +2050,7 @@ class CodeEditor : Window
          int line = editBox.lineNumber + 1;
          if(projectView)
          {
-            CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
+            CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(ide.workspace.activeCompiler);
             ProjectConfig config = projectView.project.config;
             int bitDepth = ide.workspace.bitDepth;
             bool useValgrind = ide.workspace.useValgrind;
@@ -2101,7 +2101,7 @@ class CodeEditor : Window
       if(!parentClosing)
       {
          if(ide.workspace && fileName)
-            ide.workspace.UpdateOpenedFileInfo(fileName, closed);
+            ide.workspace.UpdateOpenedFileInfo(fileName, closed, false);
          if(inUseDebug && !debugClosing)
          {
             debugClosing = true;
@@ -2136,7 +2136,7 @@ class CodeEditor : Window
    void OnDestroy(void)
    {
       ObjectInfo oClass, next;
-      Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
+      // Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
 
       FreeType(this.functionType);
       FreeType(this.instanceType);
@@ -2185,9 +2185,6 @@ class CodeEditor : Window
          classes.Delete(oClass);
       }
 
-      if(windowClass && windowClass.data)
-         UnapplySkin(windowClass);
-
       FreeParser();
 
       if(sheet.codeEditor == this)
@@ -2335,7 +2332,7 @@ class CodeEditor : Window
 
          sprintf(message, $"The document %s was modified by another application.\n"
             "Would you like to reload it and lose your changes?", fileName);
-         if(MessageBox { type = yesNo, master = /*parent = */parent, text = $"Document has been modified",
+         if(MessageBox { creationActivation = flash, type = yesNo, master = /*parent = */parent, text = $"Document has been modified",
             contents = message }.Modal() == yes)
             reload = true;
       }
@@ -2613,6 +2610,7 @@ class CodeEditor : Window
 
    void ModifyCode()
    {
+      fixCaret = true;
       selected.modified = true;
       selected.oClass.modified = true;
 
@@ -2626,19 +2624,25 @@ class CodeEditor : Window
    ****************************************************************************/
    void FreeParser()
    {
+      {
+         Class windowClass = eSystem_FindClass(privateModule, "ecere::gui::Window");
+         if(windowClass && windowClass.data)
+            UnapplySkin(windowClass);
+      }
+
       SetCurrentNameSpace(null);
-      if(ast != null)
+      if(ast)
       {
          FreeASTTree(ast);
          ast = null;
       }
-      this.defines.Free(FreeModuleDefine);
-      this.imports.Free(FreeModuleImport);   // Moved this after FreeAST because Debug printing causes ModuleImports to be created
+      defines.Free(FreeModuleDefine);
+      imports.Free(FreeModuleImport);   // Moved this after FreeAST because Debug printing causes ModuleImports to be created
 
-      FreeExcludedSymbols(this.excludedSymbols);
-      FreeContext(this.globalContext);
+      FreeExcludedSymbols(excludedSymbols);
+      FreeContext(globalContext);
       FreeIncludeFiles();
-      FreeGlobalData(&this.globalData);
+      FreeGlobalData(&globalData);
       FindCtx_Terminate();
       FindParams_Terminate();
 
@@ -2654,11 +2658,26 @@ class CodeEditor : Window
          SetPrivateModule(null);
       }
 
+      // Note: This code should probably be merged with FreeParser()
+      if(ast)
+      {
+         FreeASTTree(ast);
+         ast = null;
+         //SetAST(null);
+      }
+      defines.Free(FreeModuleDefine);
+      imports.Free(FreeModuleImport);
+
+      FreeContext(this.globalContext);
+      FreeExcludedSymbols(this.excludedSymbols);
+
+      FreeIncludeFiles();
+      FreeGlobalData(&this.globalData);
+
       if(this.privateModule)
       {
          FreeTypeData(this.privateModule);
          delete this.privateModule;
-         this.privateModule = null;
       }
    }
 
@@ -2691,7 +2710,7 @@ class CodeEditor : Window
 #endif
       Project project;
 
-      // This temporarily fixes issue with 2 overrides in release mode with VC6 (only happens with both ecere.dll and ide.exe compiled in release mode)
+      // This temporarily fixes issue with 2 overrides in release mode with VC6 (only happens with both ecere.dll and ecere-ide.exe compiled in release mode)
       if(reentrant) return;
       reentrant = true;
 
@@ -2721,18 +2740,6 @@ class CodeEditor : Window
 
       editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
 
-      FindCtx_Terminate();
-      FindParams_Terminate();
-
-      SetGlobalData(&globalData);
-      SetGlobalContext(globalContext);
-      SetExcludedSymbols(&excludedSymbols);
-      SetTopContext(globalContext);
-      SetCurrentContext(globalContext);
-      SetDefines(&defines);
-      SetImports(&imports);
-      SetCurrentNameSpace(null);
-
       /*
       sprintf(command, "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin\\cl "
          "/nologo /D \"MSC\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" "
@@ -2821,38 +2828,21 @@ class CodeEditor : Window
          this.oClass = null;
       }
 
-      {
-         Class windowClass = eSystem_FindClass(this.privateModule, "ecere::gui::Window");
-         if(windowClass && windowClass.data)
-            UnapplySkin(windowClass);
-      }
-
       designer = backDesigner;
 
       SetEchoOn(true);
       fileInput = editFile = EditBoxStream { editBox = editBox };
       SetFileInput(fileInput);
 
-      if(ast)
-      {
-         FreeASTTree(ast);
-         ast = null;
-         //SetAST(null);
-      }
-      defines.Free(FreeModuleDefine);
-      imports.Free(FreeModuleImport);
-
-      FreeContext(this.globalContext);
-      FreeExcludedSymbols(this.excludedSymbols);
-
-      FreeIncludeFiles();
-      FreeGlobalData(&this.globalData);
+      FreeParser();
 
-      if(this.privateModule)
-      {
-         FreeTypeData(this.privateModule);
-         delete this.privateModule;
-      }
+      SetGlobalData(&globalData);
+      SetGlobalContext(globalContext);
+      SetExcludedSymbols(&excludedSymbols);
+      SetTopContext(globalContext);
+      SetCurrentContext(globalContext);
+      SetDefines(&defines);
+      SetImports(&imports);
 
 #ifdef _TIMINGS
       startTime = GetTime();
@@ -2863,11 +2853,11 @@ class CodeEditor : Window
 
       if(ide.workspace)
       {
-         CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
+         CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(ide.workspace.activeCompiler);
          SetTargetBits(ide.workspace.bitDepth ? ide.workspace.bitDepth : GetHostBits());
          delete compiler;
       }
-      this.privateModule = __ecere_COM_Initialize(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4), 1, null);
+      this.privateModule = __ecere_COM_Initialize((bool)(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4)), 1, null);
 
       SetPrivateModule(privateModule);
 
@@ -2916,11 +2906,12 @@ class CodeEditor : Window
       // TODO: Get symbolsDir from project settings instead...
       if(ide.projectView)
       {
-         CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
+         CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(ide.workspace.activeCompiler);
          ProjectConfig config = project.config;
          int bitDepth = ide.workspace.bitDepth;
          DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
          SetSymbolsDir(objDir.dir);
+         SetDefaultNameSpace(project.GetDefaultNameSpace(config));
          ide.SetPath(true, compiler, config, bitDepth);
 
          delete objDir;
@@ -2938,6 +2929,7 @@ class CodeEditor : Window
          }
          SetIncludeDirs(null);
          SetSysIncludeDirs(null);
+         SetDefaultNameSpace(null);
       }
 
       {
@@ -3354,7 +3346,7 @@ class CodeEditor : Window
                                                                {
                                                                   Property prop = (Property) curMember;
                                                                   Class propertyClass = prop.dataTypeClass;
-                                                                  bool variable = false;
+                                                                  bool variable = true;
                                                                   if(!propertyClass)
                                                                      propertyClass = prop.dataTypeClass = eSystem_FindClass(this.privateModule, prop.dataTypeString);
 
@@ -3433,16 +3425,19 @@ class CodeEditor : Window
                                                                                           ObjectInfo check;
                                                                                           if(!strcmp(name, "this"))
                                                                                           {
-                                                                                             char * name = computed.member.member.string;
-                                                                                             ObjectInfo check;
-                                                                                             for(check = classObject.instances.first; check; check = check.next)
-                                                                                                if(check.name && !strcmp(name, check.name))
-                                                                                                {
-                                                                                                   if(prop.Set)
-                                                                                                      ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
-                                                                                                   variable = false;
-                                                                                                   break;
-                                                                                                }
+                                                                                             if(computed.member.member)
+                                                                                             {
+                                                                                                char * name = computed.member.member.string;
+                                                                                                ObjectInfo check;
+                                                                                                for(check = classObject.instances.first; check; check = check.next)
+                                                                                                   if(check.name && !strcmp(name, check.name))
+                                                                                                   {
+                                                                                                      if(prop.Set)
+                                                                                                         ((void (*)(void *, void *))(void *)prop.Set)(control, check.instance);
+                                                                                                      variable = false;
+                                                                                                      break;
+                                                                                                   }
+                                                                                             }
                                                                                           }
                                                                                           else
                                                                                           {
@@ -3805,7 +3800,7 @@ class CodeEditor : Window
                            {
                               Map<String, bool> i18nStrings = object.i18nStrings;
                               bool i18n = true;
-                              if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
+                              if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false, null))
                                  i18n = false;
 
                               f.Printf("%s\"", i18n ? "$" : "");
@@ -3833,7 +3828,7 @@ class CodeEditor : Window
 
                      if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
                      {
-                        char * string;
+                        char * string = null;
                         char tempString[1024] = "";
                         SetProperty(prop, test, dataForm);
 
@@ -4363,7 +4358,7 @@ class CodeEditor : Window
                }
                else
                {
-                  Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
+                  // Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
 
                   // ADDING METHOD HERE
                   f.Printf("\n      ");
@@ -4392,7 +4387,7 @@ class CodeEditor : Window
                   f.Printf(")\n");
                   f.Printf("      %c\n\n", OpenBracket);
 
-                  if(control._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
+                  if(control._class._vTbl[method.vid] == null /*moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]*/) // Temp Check for DefaultFunction
                   {
                      if(returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
                         f.Printf("         return true;\n");
@@ -4451,7 +4446,7 @@ class CodeEditor : Window
             {
                Class dataType = prop.dataTypeClass;
                char tempString[1024] = "";
-               char * string;
+               char * string = null;
                bool specify = false;
                DataMember member;
 
@@ -4512,7 +4507,7 @@ class CodeEditor : Window
                   if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
                   {
                      char tempString[1024] = "";
-                     char * string;
+                     char * string = null;
                      ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
 
                      if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
@@ -4530,7 +4525,7 @@ class CodeEditor : Window
                         {
                            Map<String, bool> i18nStrings = classObject.i18nStrings;
                            bool i18n = true;
-                           if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
+                           if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false, null))
                               i18n = false;
 
                            f.Printf("\n   %s%s = %s\"", specify ? "property::" : "", prop.name, i18n ? "$" : "");
@@ -4976,7 +4971,7 @@ class CodeEditor : Window
                   Type dataType = method.dataType;
                   Type returnType = dataType.returnType;
                   Type param;
-                  Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
+                  // Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
 
                   f.Printf("\n\n");
                   f.Printf("   ");
@@ -5002,7 +4997,7 @@ class CodeEditor : Window
                   f.Printf(")\n");
                   f.Printf("   %c\n\n", OpenBracket);
 
-                  if(test._class._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]) // Temp Check for DefaultFunction
+                  if(test._class._vTbl[method.vid] == null /*moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]*/) // Temp Check for DefaultFunction
                   {
                      if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
                         f.Printf("      return true;\n");
@@ -5710,7 +5705,7 @@ class CodeEditor : Window
 
                if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
                {
-                  char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
+                  char * bitmapName = (char *)(intptr)eClass_GetProperty(subMember.dataType._class.registered, "icon");
                   if(bitmapName)
                   {
                      bitmap = { bitmapName };
@@ -5808,7 +5803,7 @@ class CodeEditor : Window
 
                      if(member.dataType && member.dataType.kind == classType && member.dataType._class)
                      {
-                        char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
+                        char * bitmapName = (char *)(intptr)eClass_GetProperty(member.dataType._class.registered, "icon");
                         if(bitmapName)
                         {
                            bitmap = { bitmapName };
@@ -5920,7 +5915,7 @@ class CodeEditor : Window
 
                   if(member.dataType && member.dataType.kind == classType && member.dataType._class)
                   {
-                     char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
+                     char * bitmapName = (char *)(intptr)eClass_GetProperty(member.dataType._class.registered, "icon");
                      if(bitmapName)
                      {
                         bitmap = { bitmapName };
@@ -6263,7 +6258,7 @@ class CodeEditor : Window
                         BitmapResource bitmap = null;
                         if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
                         {
-                           char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
+                           char * bitmapName = (char *)(intptr)eClass_GetProperty(symbol.type._class.registered, "icon");
                            if(bitmapName)
                            {
                               bitmap = { bitmapName };
@@ -6372,7 +6367,7 @@ class CodeEditor : Window
          Type dataType = method.dataType;
          Type returnType = dataType.returnType;
          Type param;
-         Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
+         // Class moduleClass = eSystem_FindClass(this.privateModule, "Module");
 
          if(insideDef.prev)
              f.Printf("\n\n");
@@ -6414,7 +6409,7 @@ class CodeEditor : Window
 
          if(!_class ||
             (
-               (isInstance ? _class : _class.base)._vTbl[method.vid] == moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad] ||
+               (isInstance ? _class : _class.base)._vTbl[method.vid] == null /*moduleClass._vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Module_OnLoad]*/ ||
                (isInstance ? _class : _class.base)._vTbl[method.vid] == DummyMethod)) // Temp Check for DefaultFunction
          {
             if(returnType && returnType.kind == classType && !strcmp(returnType._class.string, "bool"))
@@ -6564,7 +6559,8 @@ class CodeEditor : Window
          int rowCount;
          char tempString[1024];
          char * string = null;
-         CodePosition idStart, idEnd;
+         CodePosition idStart { };
+         CodePosition idEnd { };
 
          if(membersListShown)
          {
@@ -6600,7 +6596,7 @@ class CodeEditor : Window
             }
             string[len] = 0;
             */
-            int x, y;
+            int x = 0, y;
             int len = 0;
             EditLine editLine = editBox.line;
             bool firstChar = true;