ide, documentor, epj2make: settings, compiler configs: move ide config to new ~/...
[sdk] / ide / src / dialogs / GlobalSettingsDialog.ec
index c7cec7f..ff8f1b8 100644 (file)
@@ -16,7 +16,7 @@ class GlobalSettingsDialog : Window
    hasClose = true;
    borderStyle = sizable;
    text = $"Global Settings";
-   minClientSize = { 560, 506 };
+   minClientSize = { 560, 542 };
    nativeDecorations = true;
 
    IDESettings ideSettings;
@@ -71,8 +71,7 @@ class GlobalSettingsDialog : Window
             bool editorSettingsChanged = false;
             bool compilerSettingsChanged = false;
             bool projectOptionsChanged = false;
-            bool workspaceOptionsChanged = false;
-
+            AVLTree<String> cfgsToWrite = null;
             if(editorTab.modifiedDocument)
             {
                if(editorTab.useFreeCaret.checked != ideSettings.useFreeCaret ||
@@ -88,16 +87,18 @@ class GlobalSettingsDialog : Window
 
             if(compilersTab.modifiedDocument)
             {
-               Workspace workspace = ide.workspace;
                if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
                   ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
-               ideSettings.compilerConfigs.Free();
-               for(compiler : compilersTab.compilerConfigs)
+               if(compilersTab.compilerConfigs.OnCompare(ideSettings.compilerConfigs))
                {
-                  ideSettings.compilerConfigs.Add(compiler.Copy());
+                  cfgsToWrite = compilersTab.compilerConfigs.getWriteRequiredList(ideSettings.compilerConfigs);
+                  ideSettings.compilerConfigs.Free();
+                  for(compiler : compilersTab.compilerConfigs)
+                  {
+                     ideSettings.compilerConfigs.Add(compiler.Copy());
+                  }
+                  compilerSettingsChanged = true;
                }
-
-               compilerSettingsChanged = true;
             }
 
             if(projectOptionsTab.modifiedDocument)
@@ -119,15 +120,20 @@ class GlobalSettingsDialog : Window
                   if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
                   {
                      ideSettings.defaultCompiler = row.string;
-                     workspaceOptionsChanged = true;
                   }
                }
             }
 
-            settingsContainer.Save();
+            if(editorSettingsChanged || projectOptionsChanged)
+               settingsContainer.Save();
 
             if(compilerSettingsChanged)
+            {
+               ideSettings.compilerConfigs.write(cfgsToWrite);
                OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
+               cfgsToWrite.Free();
+               delete cfgsToWrite;
+            }
             if(editorSettingsChanged)
                OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
             if(projectOptionsChanged)
@@ -282,7 +288,10 @@ class CompilersTab : GlobalSettingsSubTab
    {
       this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
       opacity = 0;
-      direction = horizontal, scrollable = true;
+      direction = horizontal;
+      scrollable = true;
+      endButtons = false;
+      hoverScroll = true;
 
       bool OnKeyDown(Key key, unichar ch)
       {
@@ -328,7 +337,7 @@ class CompilersTab : GlobalSettingsSubTab
    CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
    CompilerOptionsTab optionsTab { this, tabControl = tabControl };
 
-   List<CompilerConfig> compilerConfigs { };
+   CompilerConfigs compilerConfigs { };
    CompilerConfig activeCompiler;
 
    Label labelCompilers
@@ -455,7 +464,7 @@ class CompilersTab : GlobalSettingsSubTab
             String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
             if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
             {
-               SelectorButton button = compilerSelector.FindButtonByID((int64)compilerToDelete);
+               SelectorButton button = compilerSelector.FindButtonByID((int64)(intptr)compilerToDelete);
                if(button)
                   compilerSelector.RemoveButton(button);
                //DeleteCompiler(compilerToDelete);
@@ -480,7 +489,7 @@ class CompilersTab : GlobalSettingsSubTab
       {
          SelectorButton button
          {
-            compilerSelector, master = this, text = compiler.name, id = (int64)compiler;
+            compilerSelector, master = this, text = compiler.name, id = (int64)(intptr)compiler;
             NotifyClicked = CompilerClicked;
          };
          selectButton = button;
@@ -489,7 +498,7 @@ class CompilersTab : GlobalSettingsSubTab
       {
          EditableSelectorButton button
          {
-            compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)compiler;
+            compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)(intptr)compiler;
             NotifyClicked = CompilerClicked;
 
             bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
@@ -542,7 +551,7 @@ class CompilersTab : GlobalSettingsSubTab
    {
       if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
       {
-         LoadCompiler((CompilerConfig)clickedButton.id);
+         LoadCompiler((CompilerConfig)(intptr)clickedButton.id);
          selectedButton = (SelectorButton)clickedButton;
       }
       return true;
@@ -722,10 +731,22 @@ class CompilerToolchainTab : CompilersSubTab
       text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
    Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
-   PathBox cpp
+   EditBox cpp
    {
       this, anchor = { left = margin, top = 112, right = 8 };
-      text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+      //text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+      text = $"C Preprocessor";//, NotifyModified = NotifyModifiedDocument;
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.cppCommand = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
    };
    Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
    PathBox cc
@@ -739,28 +760,40 @@ class CompilerToolchainTab : CompilersSubTab
       this, anchor = { left = margin, top = 164, right = 8 };
       text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
-   Label makeLabel { this, position = { 8, 194 }, labeledWindow = make, tabCycle = false, inactive = true };
-   PathBox make
+   Label arLabel { this, position = { 8, 194 }, labeledWindow = ar, tabCycle = false, inactive = true };
+   PathBox ar
    {
       this, anchor = { left = margin, top = 190, right = 8 };
+      text = $"AR", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+   };
+   Label ldLabel { this, position = { 8, 220 }, labeledWindow = ld, tabCycle = false, inactive = true };
+   PathBox ld
+   {
+      this, anchor = { left = margin, top = 216, right = 8 };
+      text = $"Linker", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+   };
+   Label makeLabel { this, position = { 8, 246 }, labeledWindow = make, tabCycle = false, inactive = true };
+   PathBox make
+   {
+      this, anchor = { left = margin, top = 242, right = 8 };
       text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
-   Label gnuToolchainPrefixLabel { this, position = { 8, 220 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
+   Label gnuToolchainPrefixLabel { this, position = { 8, 272 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
    PathBox gnuToolchainPrefix
    {
-      this, anchor = { left = margin, top = 216, right = 8 };
-      text = $"GNU Toolchain Prefix", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+      this, anchor = { left = margin, top = 268, right = 8 };
+      text = $"GNU Toolchain Prefix", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
-   Label sysrootLabel { this, position = { 8, 246 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
+   Label sysrootLabel { this, position = { 8, 298 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
    PathBox sysroot
    {
-      this, anchor = { left = margin, top = 242, right = 8 };
-      text = $"SYSROOT", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+      this, anchor = { left = margin, top = 294, right = 8 };
+      text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
-   Label executableLauncherLabel { this, position = { 8, 272 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
+   Label executableLauncherLabel { this, position = { 8, 324 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
    PathBox executableLauncher
    {
-      this, anchor = { left = margin, top = 268, right = 8 };
+      this, anchor = { left = margin, top = 320, right = 8 };
       text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
 
@@ -778,16 +811,20 @@ class CompilerToolchainTab : CompilersSubTab
             compiler.ecsCommand = pathBox.slashPath;
          else if(pathBox == ear)
             compiler.earCommand = pathBox.slashPath;
-         else if(pathBox == cpp)
-            compiler.cppCommand = pathBox.slashPath;
+         /*else if(pathBox == cpp)
+            compiler.cppCommand = pathBox.slashPath;*/
          else if(pathBox == cc)
             compiler.ccCommand = pathBox.slashPath;
          else if(pathBox == cxx)
             compiler.cxxCommand = pathBox.slashPath;
+         else if(pathBox == ld)
+            compiler.ldCommand = pathBox.slashPath;
+         else if(pathBox == ar)
+            compiler.arCommand = pathBox.slashPath;
          else if(pathBox == make)
             compiler.makeCommand = pathBox.slashPath;
          else if(pathBox == executableLauncher)
-            compiler.execPrefixCommand = pathBox.slashPath;
+            compiler.executableLauncher = pathBox.slashPath;
          else if(pathBox == gnuToolchainPrefix)
             compiler.gccPrefix = pathBox.slashPath;
          else if(pathBox == sysroot)
@@ -809,9 +846,12 @@ class CompilerToolchainTab : CompilersSubTab
          ecc.path = compiler.eccCommand;
          ecs.path = compiler.ecsCommand;
          ear.path = compiler.earCommand;
-         cpp.path = compiler.cppCommand;
+         //cpp.path = compiler.cppCommand;
+         cpp.contents = compiler.cppCommand;
          cc.path = compiler.ccCommand;
          cxx.path = compiler.cxxCommand;
+         ld.path = compiler.ldCommand;
+         ar.path = compiler.arCommand;
          make.path = compiler.makeCommand;
          executableLauncher.path = compiler.executableLauncher;
          gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
@@ -824,6 +864,7 @@ class CompilerToolchainTab : CompilersSubTab
          cppLabel.disabled = cpp.disabled = isVC || disabled;
          cxxLabel.disabled = cxx.disabled = isVC || disabled;
          ccLabel.disabled = cc.disabled = isVC || disabled;
+         ldLabel.disabled = cxx.disabled = isVC || disabled;
          makeLabel.disabled = make.disabled = disabled;
          executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
          gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
@@ -997,7 +1038,7 @@ class CompilerOptionsTab : CompilersSubTab
    StringListBox prepDefs
    {
       this, text = $"Preprocessor directives", hotKey = altP;
-      position = { 148, 124 }, size = { 300, 22 }, anchor = { left = 148, top = 124, right = 8 };
+      position = { 168, 124 }, size = { 280, 22 }, anchor = { left = 168, top = 124, right = 8 };
 
       bool NotifyModified(EditBox editBox)
       {
@@ -1016,7 +1057,7 @@ class CompilerOptionsTab : CompilersSubTab
    StringListBox eCcompilerFlags
    {
       this, text = $"Additional eC compiler flags", hotKey = altG;
-      position = { 148, 154 }, size = { 300, 22 }, anchor = { left = 148, top = 154, right = 8 };
+      position = { 168, 154 }, size = { 280, 22 }, anchor = { left = 168, top = 154, right = 8 };
 
       bool NotifyModified(EditBox editBox)
       {
@@ -1035,7 +1076,7 @@ class CompilerOptionsTab : CompilersSubTab
    StringListBox compilerFlags
    {
       this, text = $"Additional compiler flags", hotKey = altR;
-      position = { 148, 184 }, size = { 300, 22 }, anchor = { left = 148, top = 184, right = 8 };
+      position = { 168, 184 }, size = { 280, 22 }, anchor = { left = 168, top = 184, right = 8 };
 
       bool NotifyModified(EditBox editBox)
       {
@@ -1054,7 +1095,7 @@ class CompilerOptionsTab : CompilersSubTab
    StringListBox linkerFlags
    {
       this, text = $"Additional linker flags", hotKey = altL;
-      position = { 148, 214 }, size = { 300, 22 }, anchor = { left = 148, top = 214, right = 8 };
+      position = { 168, 214 }, size = { 280, 22 }, anchor = { left = 168, top = 214, right = 8 };
 
       bool NotifyModified(EditBox editBox)
       {
@@ -1073,7 +1114,7 @@ class CompilerOptionsTab : CompilersSubTab
    StringListBox excludedLibraries
    {
       this, text = $"Libraries to exclude", hotKey = altX;
-      position = { 148, 244 }, size = { 300, 22 }, anchor = { left = 148, top = 244, right = 8 };
+      position = { 168, 244 }, size = { 280, 22 }, anchor = { left = 168, top = 244, right = 8 };
 
       bool NotifyModified(EditBox editBox)
       {
@@ -1088,6 +1129,62 @@ class CompilerOptionsTab : CompilersSubTab
       }
    };
 
+   Label objectFileExtLabel { this, position = { 8, 276 }, labeledWindow = objectFileExt };
+   EditBox objectFileExt
+   {
+      this, text = $"Object file extension";//, hotKey = altH;
+      position = { 168, 274 }, size = { 80, 22 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.objectFileExt = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Label outputFileExtLabel { this, position = { 8, 306 }, labeledWindow = outputFileExt };
+   EditBox outputFileExt
+   {
+      this, text = $"Output file extension";//, hotKey = altH;
+      position = { 168, 304 }, size = { 80, 22 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.outputFileExt = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Button resourcesDotEar
+   {
+      this, text = $"Use resources.ear", position = { 300, 308 };
+      isCheckbox = true;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.resourcesDotEar = button.checked;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
    CompilerOptionsTab()
    {
       Platform p;
@@ -1118,6 +1215,9 @@ class CompilerOptionsTab : CompilersSubTab
          eCcompilerFlags.strings = compiler.eCcompilerFlags;
          compilerFlags.strings = compiler.compilerFlags;
          linkerFlags.strings = compiler.linkerFlags;
+         objectFileExt.contents = compiler.objectFileExt;
+         outputFileExt.contents = compiler.outputFileExt;
+         resourcesDotEar.checked = compiler.resourcesDotEar;
 
          labelTargetPlatform.disabled = disabled;
          targetPlatform.disabled = disabled;