ide: add 'force single job compiling' checkbox to the toolbar.
[sdk] / ide / src / ide.ec
index e1200b8..e02a253 100755 (executable)
@@ -303,11 +303,11 @@ class IDEToolbar : ToolBar
       this, toolTip = $"Active Compiler", size = { 160 }, disabled = true;
       bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
       {
-         if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.compiler))
+         if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.activeCompiler))
          {
             bool silent = ide.projectView.buildInProgress == none ? false : true;
             CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string);
-            ide.workspace.compiler = row.string;
+            ide.workspace.activeCompiler = row.string;
             ide.projectView.ShowOutputBuildLog(!silent);
             if(!silent)
                ide.projectView.DisplayCompiler(compiler, false);
@@ -328,7 +328,7 @@ class IDEToolbar : ToolBar
          if(ide.workspace && ide.projectView && row)
          {
             bool silent = ide.projectView.buildInProgress == none ? false : true;
-            CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
+            CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler);
             ide.workspace.bitDepth = (int)row.tag;
             ide.projectView.ShowOutputBuildLog(!silent);
             if(!silent)
@@ -342,6 +342,10 @@ class IDEToolbar : ToolBar
       }
    };
 
+   Window spacer65 { this, size = { 4 } };
+
+   Button forceSingleJob { this, text = $"Force Single Job Compiling", isCheckbox = true; };
+
    Window spacer7 { this, size = { 4 } };
 
    void IDEToolbar()
@@ -439,14 +443,14 @@ class IDEWorkSpace : Window
 
       void OnGotoError(const char * line, bool noParsing)
       {
-         CompilerConfig compiler = ide.workspace ? ideSettings.GetCompilerConfig(ide.workspace.compiler) : null;
+         CompilerConfig compiler = ide.workspace ? ideSettings.GetCompilerConfig(ide.workspace.activeCompiler) : null;
          const char * objectFileExt = compiler ? compiler.objectFileExt : objectDefaultFileExt;
          ide.GoToError(line, noParsing, objectFileExt);
       }
 
       void OnCodeLocationParseAndGoTo(const char * line)
       {
-         CompilerConfig compiler = ide.workspace ? ideSettings.GetCompilerConfig(ide.workspace.compiler) : null;
+         CompilerConfig compiler = ide.workspace ? ideSettings.GetCompilerConfig(ide.workspace.activeCompiler) : null;
          const char * objectFileExt = compiler ? compiler.objectFileExt : objectDefaultFileExt;
          ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir, objectFileExt);
       }
@@ -723,8 +727,8 @@ class IDEWorkSpace : Window
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
             globalSettingsDialog.master = this;
-            if(ide.workspace && ide.workspace.compiler)
-               globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
+            if(ide.workspace && ide.workspace.activeCompiler)
+               globalSettingsDialog.workspaceActiveCompiler = ide.workspace.activeCompiler;
             else if(ideSettings.defaultCompiler)
                globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
             globalSettingsDialog.Modal();
@@ -1639,6 +1643,7 @@ class IDEWorkSpace : Window
 
    bool noParsing;
    bool debugStart;
+   bool debugHideIDE;
 
 #ifdef GDB_DEBUG_GUI
    GDBDialog gdbDialog
@@ -1857,7 +1862,7 @@ class IDEWorkSpace : Window
    {
       if(workspace)
       {
-         CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
+         CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.activeCompiler);
          for(prj : workspace.projects)
             projectView.ProjectUpdateMakefileForAllConfigs(prj);
          delete compiler;
@@ -1870,7 +1875,7 @@ class IDEWorkSpace : Window
       if(workspace)
       {
          bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
-         CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
+         CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.activeCompiler);
          if(!silent)
          {
             projectView.ShowOutputBuildLog(true);
@@ -1888,11 +1893,12 @@ class IDEWorkSpace : Window
       for(compiler : ideSettings.compilerConfigs)
       {
          DataRow row = toolBar.activeCompiler.AddString(compiler.name);
-         if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
+         if(workspace && workspace.activeCompiler && !strcmp(compiler.name, workspace.activeCompiler))
             toolBar.activeCompiler.currentRow = row;
       }
       if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
          toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
+      toolBar.activeBitDepth.SelectRow(toolBar.activeBitDepth.FindRow(workspace ? workspace.bitDepth : 0));
    }
 
    void UpdateToolBarActiveConfigs(bool selectionOnly)
@@ -2324,7 +2330,7 @@ class IDEWorkSpace : Window
 
                         ide.projectView.ShowOutputBuildLog(true);
                         {
-                           CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
+                           CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler);
                            ide.projectView.DisplayCompiler(compiler, false);
                            delete compiler;
                         }
@@ -2343,23 +2349,8 @@ class IDEWorkSpace : Window
                         // this crashes on starting ide with epj file, solution please?
                         // app.UpdateDisplay();
 
+                        workspace.OpenPreviouslyOpenedFiles(noParsing);
                         workspace.holdTracking = true;
-                        for(ofi : workspace.openedFiles)
-                        {
-                           if(ofi.state != closed)
-                           {
-                              Window file = OpenFile(ofi.path, false, true, null, no, normal, noParsing);
-                              if(file)
-                              {
-                                 char fileName[MAX_LOCATION];
-                                 ProjectNode node;
-                                 GetLastDirectory(ofi.path, fileName);
-                                 node = projectView.project.topNode.Find(fileName, true);
-                                 if(node)
-                                    node.EnsureVisible();
-                              }
-                           }
-                        }
                         ide.RepositionWindows(false);
                         workspace.holdTracking = false;
 
@@ -2442,9 +2433,9 @@ class IDEWorkSpace : Window
                   if(prj)
                   {
                      const char * activeConfigName = null;
-                     CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
+                     CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.activeCompiler);
                      prj.StartMonitoring();
-                     workspace.projects.Add(prj);
+                     workspace.AddProject(prj, null);
                      if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow &&
                            toolBar.activeConfig.currentRow.string && toolBar.activeConfig.currentRow.string[0])
                         activeConfigName = toolBar.activeConfig.currentRow.string;
@@ -2567,21 +2558,7 @@ class IDEWorkSpace : Window
       if(document)
       {
          if(projectView && document._class == class(CodeEditor) && workspace)
-         {
-            int lineNumber, position;
-            Point scroll;
-            CodeEditor editor = (CodeEditor)document;
-            editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
-            editor.openedFileInfo.holdTracking = true;
-            lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
-            position = Max(editor.openedFileInfo.position - 1, 0);
-            if(editor.editBox.GoToLineNum(lineNumber))
-               editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
-            scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
-            scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
-            editor.editBox.scroll = scroll;
-            editor.openedFileInfo.holdTracking = false;
-         }
+            workspace.RestorePreviouslyOpenedFileState((CodeEditor)document);
 
          if(needFileModified)
             document.OnFileModified = OnFileModified;
@@ -2841,7 +2818,8 @@ class IDEWorkSpace : Window
          if(binaryDocExt.Find(ext))
             ShellOpen(path);
          else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "bc") ||
-               !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
+               !strcmp(ext, "lib") || !strcmp(ext, "dll") ||
+               !strcmp(ext, "exe") || !strcmp(ext, "nexe") || !strcmp(ext, "pexe"))
          {
             char dirPath[MAX_LOCATION];
             StripLastDirectory(path, dirPath);
@@ -3142,6 +3120,8 @@ class IDEWorkSpace : Window
             ide.noParsing = true;
          else if(!strcmp(app.argv[c], "-debug-start"))
             ide.debugStart = true;
+         else if(!strcmp(app.argv[c], "-debug-hide-ide"))
+            ide.debugHideIDE = true;
          else if(!strcmp(app.argv[c], "-debug-work-dir"))
             debugWorkDir = true;
          else if(!strcmp(app.argv[c], "-@"))
@@ -3159,7 +3139,7 @@ class IDEWorkSpace : Window
             GetExtension(app.argv[c], ext);
             isProject = !openAsText && !strcmpi(ext, "epj");
 
-            if(isProject && c > 1 + (ide.debugStart ? 1 : 0)) continue;
+            if(isProject && c > 1 + (ide.debugStart ? 1 : 0) + (ide.debugHideIDE ? 1 : 0)) continue;
 
             // Create directory for projects (only)
             if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
@@ -3636,19 +3616,34 @@ bool GetInstalledFileOrFolder(const char * subDir, const char * name, char * pat
 #else
    if(!found)
    {
+      char * p = null;
       char * tokens[256];
       int c, numTokens;
 
       GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
       numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
+      if(!numTokens)
+      {
+         p = new char[MAX_LOCATION];
+         p[0] = '\0';
+         strcat(p, "/usr/share");
+         tokens[0] = p;
+         numTokens = 1;
+      }
       for(c=0; c<numTokens; c++)
       {
          strncpy(path, tokens[c], MAX_LOCATION); path[MAX_LOCATION-1] = '\0';
          PathCat(path, sdkDirName);
          PathCat(path, subDir);
-         if(name) PathCat(path, name);
-         if(FileExists(path) & attribs) found = true;
+         if(name)
+            PathCat(path, name);
+         if(FileExists(path) & attribs)
+         {
+            found = true;
+            break;
+         }
       }
+      delete p;
    }
 #endif
    delete v;
@@ -3727,6 +3722,7 @@ class IDEApp : GuiApplication
             else if(!strcmp(app.argv[c], "-t"));
             else if(!strcmp(app.argv[c], "-no-parsing"));
             else if(!strcmp(app.argv[c], "-debug-start"));
+            else if(!strcmp(app.argv[c], "-debug-hide-ide"));
             else if(!strcmp(app.argv[c], "-debug-work-dir"))
                debugWorkDir = true;
             else if(!strcmp(app.argv[c], "-@"))