ide/CodeEditor: Customizable color scheme support
[sdk] / ide / src / dialogs / GlobalSettingsDialog.ec
index 484c3f1..9302ad9 100644 (file)
@@ -16,20 +16,18 @@ class GlobalSettingsDialog : Window
    hasClose = true;
    borderStyle = sizable;
    text = $"Global Settings";
-   minClientSize = { 560, 446 };
+   minClientSize = { 560, 542 };
    nativeDecorations = true;
 
-   IDESettings ideSettings;
-   IDESettingsContainer settingsContainer;
    String workspaceActiveCompiler;
-   
+
    TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 8, right = 8, bottom = 40 } };
-   
+
    EditorTab editorTab { this, tabControl = tabControl };
    CompilersTab compilersTab { this, tabControl = tabControl };
    ProjectOptionsTab projectOptionsTab { this, tabControl = tabControl };
    WorkspaceOptionsTab workspaceOptionsTab { this, tabControl = tabControl };
-   
+
    property bool settingsModified
    {
       get
@@ -71,29 +69,54 @@ 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 ||
                      editorTab.showLineNumbers.checked != ideSettings.showLineNumbers ||
-                     editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling)
+                     editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling ||
+                     editorTab.fontPicker.fontSize != ideSettings.codeEditorFontSize ||
+                     editorTab.fontPicker.faceName.OnCompare(ideSettings.codeEditorFont) ||
+                     editorTab.dbColorSchemes.currentRow.string.OnCompare(ideSettings.activeColorScheme)
+                     )
                {
+                  DataRow csRow = editorTab.dbColorSchemes.currentRow;
                   ideSettings.useFreeCaret = editorTab.useFreeCaret.checked;
                   ideSettings.showLineNumbers = editorTab.showLineNumbers.checked;
                   ideSettings.caretFollowsScrolling = editorTab.caretFollowsScrolling.checked;
+                  ideSettings.codeEditorFont = editorTab.fontPicker.faceName;
+                  ideSettings.codeEditorFontSize = editorTab.fontPicker.fontSize;
+                  if(csRow && csRow.string)
+                  {
+                     ideSettings.activeColorScheme = csRow.string;
+                     for(cs : ideSettings.colorSchemes; cs.name && !strcmp(cs.name, csRow.string))
+                     {
+                        colorScheme = cs;
+                        ide.ApplyColorScheme(colorScheme);
+                        break;
+                     }
+                  }
+
+                  ide.ApplyFont(ideSettings.codeEditorFont, ideSettings.codeEditorFontSize);
+
                   editorSettingsChanged = true;
                }
             }
-            
+
             if(compilersTab.modifiedDocument)
             {
                if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
                   ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
-               ideSettings.compilerConfigs.Free();
-               for(compiler : compilersTab.compilerConfigs)
-                  ideSettings.compilerConfigs.Add(compiler.Copy());
-               compilerSettingsChanged = true;
+               if(compilersTab.compilerConfigs.OnCompare(ideConfig.compilers))
+               {
+                  cfgsToWrite = compilersTab.compilerConfigs.getWriteRequiredList(ideConfig.compilers);
+                  ideConfig.compilers.Free();
+                  for(compiler : compilersTab.compilerConfigs)
+                  {
+                     ideConfig.compilers.Add(compiler.Copy());
+                  }
+                  compilerSettingsChanged = true;
+               }
             }
 
             if(projectOptionsTab.modifiedDocument)
@@ -115,15 +138,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)
+            {
+               ideConfig.compilers.write(settingsContainer, cfgsToWrite);
                OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
+               cfgsToWrite.Free();
+               delete cfgsToWrite;
+            }
             if(editorSettingsChanged)
                OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
             if(projectOptionsChanged)
@@ -134,7 +162,7 @@ class GlobalSettingsDialog : Window
             projectOptionsTab.modifiedDocument = false;
             workspaceOptionsTab.modifiedDocument = false;
          }
-         
+
          Destroy(DialogResult::ok);
          return true;
       }
@@ -175,7 +203,7 @@ class GlobalSettingsDialog : Window
       // CompilersTab
       if(workspaceActiveCompiler)
       {
-         for(compiler : ideSettings.compilerConfigs)
+         for(compiler : ideConfig.compilers)
          {
             if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
                activateCompiler = compiler;
@@ -187,17 +215,17 @@ class GlobalSettingsDialog : Window
       }
       if(!activateCompiler && readonlyCompiler)
          activateCompiler = readonlyCompiler;
-      if(!activateCompiler && ideSettings.compilerConfigs.count)
-         activateCompiler = ideSettings.compilerConfigs[0];
-      
-      for(compiler : ideSettings.compilerConfigs)
+      if(!activateCompiler && ideConfig.compilers.count)
+         activateCompiler = ideConfig.compilers[0];
+
+      for(compiler : ideConfig.compilers)
          compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
       compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
 
       // ProjectOptionsTab
       projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
       projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
-      
+
       return true;
    }
 
@@ -218,26 +246,63 @@ class GlobalSettingsDialog : Window
    virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
 }
 
+import "FontPicker"
+
 class EditorTab : GlobalSettingsSubTab
 {
    background = formColor;
    text = $"Editor";
 
+   bool OnCreate()
+   {
+      dbColorSchemes.Clear();
+
+      for(s : ideSettings.colorSchemes)
+      {
+         DataRow row = dbColorSchemes.AddString(s.name);
+         if(!strcmp(s.name, ideSettings.activeColorScheme))
+            dbColorSchemes.currentRow = row;
+      }
+      return true;
+   }
+
+   Label lblColorSchemes { this, anchor = { top = 92, right = 126 }, labeledWindow = dbColorSchemes };
+   DropBox dbColorSchemes
+   {
+      this, text = $"Color Scheme: ", anchor = { top = 92, right = 16 }, size = { 100, 22 };
+
+      bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
+      {
+         if(row)
+         {
+            IDEColorScheme colorScheme = null;
+            for(cs : ideSettings.colorSchemes; cs.name && !strcmp(cs.name, row.string))
+            {
+               colorScheme = cs;
+               break;
+            }
+            fontPicker.SelectColorScheme(colorScheme);
+            modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
    Button useFreeCaret
    {
-      this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
+      this, text = $"Move code editor caret freely past end of line", position = { 16, 58 }, isCheckbox = true;
       NotifyClicked = NotifyClickedModifiedDocument;
    };
 
    Button caretFollowsScrolling
    {
-      this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
+      this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 78 }, isCheckbox = true;
       NotifyClicked = NotifyClickedModifiedDocument;
    };
 
    Button showLineNumbers
    {
-      this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
+      this, text = $"Show line numbers in code editor", position = { 16, 98 }, isCheckbox = true;
       NotifyClicked = NotifyClickedModifiedDocument;
    };
 
@@ -246,6 +311,17 @@ class EditorTab : GlobalSettingsSubTab
       modifiedDocument = true;
       return true;
    }
+
+   FontPicker fontPicker
+   {
+      this, anchor = { left = 8, right = 8, top = 120, bottom = 8 };
+
+      bool NotifyChanged()
+      {
+         modifiedDocument = true;
+         return true;
+      }
+   };
 }
 
 static void DrawStipple(Surface surface, Size clientSize)
@@ -259,7 +335,7 @@ static void DrawStipple(Surface surface, Size clientSize)
 
    surface.LineStipple(0x5555);
    surface.Rectangle(x1, y1, x2, y2);
-   surface.LineStipple(0);            
+   surface.LineStipple(0);
 }
 
 class CompilersTab : GlobalSettingsSubTab
@@ -270,7 +346,7 @@ class CompilersTab : GlobalSettingsSubTab
    Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
    PathBox compilerConfigsDir
    {
-      this, anchor = { left = 210, top = 8, right = 8 };
+      this, anchor = { left = 230, top = 8, right = 8 };
       text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
    };
 
@@ -278,7 +354,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)
       {
@@ -294,7 +373,7 @@ class CompilersTab : GlobalSettingsSubTab
          }
          return SelectorBar::OnKeyDown(key, ch);
       }
-      
+
       bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
       {
          ((CompilersTab)master).labelCompilers.Update(null);
@@ -318,13 +397,13 @@ class CompilersTab : GlobalSettingsSubTab
    };
 
    TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
-   
+
    CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
    CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
    CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
    CompilerOptionsTab optionsTab { this, tabControl = tabControl };
 
-   List<CompilerConfig> compilerConfigs { };
+   CompilerConfigs compilerConfigs { };
    CompilerConfig activeCompiler;
 
    Label labelCompilers
@@ -339,7 +418,7 @@ class CompilersTab : GlobalSettingsSubTab
       }
    };
 
-   void FindUniqueCompilerName(char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
+   void FindUniqueCompilerName(const char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
    {
       int num = 0;
       char tmp[MAX_F_STRING];
@@ -451,7 +530,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((int)compilerToDelete);
+               SelectorButton button = compilerSelector.FindButtonByID((int64)(intptr)compilerToDelete);
                if(button)
                   compilerSelector.RemoveButton(button);
                //DeleteCompiler(compilerToDelete);
@@ -476,7 +555,7 @@ class CompilersTab : GlobalSettingsSubTab
       {
          SelectorButton button
          {
-            compilerSelector, master = this, text = compiler.name, id = (int)compiler;
+            compilerSelector, master = this, text = compiler.name, id = (int64)(intptr)compiler;
             NotifyClicked = CompilerClicked;
          };
          selectButton = button;
@@ -485,7 +564,7 @@ class CompilersTab : GlobalSettingsSubTab
       {
          EditableSelectorButton button
          {
-            compilerSelector, master = this, renameable = true, text = compiler.name, id = (int)compiler;
+            compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)(intptr)compiler;
             NotifyClicked = CompilerClicked;
 
             bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
@@ -538,7 +617,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;
@@ -546,12 +625,13 @@ class CompilersTab : GlobalSettingsSubTab
 
    bool NotifyModifiedDocument(PathBox pathBox)
    {
+      BasicValidatePathBoxPath(pathBox);
       modifiedDocument = true;
       return true;
    }
 }
 
-Array<String> displayDirectoryNames
+Array<const String> displayDirectoryNames
 { [
    $"Include Files",
    $"Library Files",
@@ -578,6 +658,7 @@ class CompilerDirectoriesTab : CompilersSubTab
    CompilerDirectoriesTab()
    {
       DirTypes c;
+      int v = 8;
       for(c = 0; c < DirTypes::enumSize; c++)
       {
          dirs[c] = DirectoriesBox
@@ -609,24 +690,27 @@ class CompilerDirectoriesTab : CompilersSubTab
                }
                return true;
             }
+            bool NotifyPathBoxModified(DirectoriesBox dirsBox, PathBox pathBox)
+            {
+               BasicValidatePathBoxPath(pathBox);
+               return true;
+            }
          };
          incref dirs[c];
-         
+
          if(c)
             dirs[c].visible = false;
-         
+
          // (width) Should be 324 for text...
          //field[c] = { dataType = class(char *), editable = true };
          //dirs[c].AddField(field[c]);
 
-         {
-         int v = (int)c * 100 + 8;
          dirTypeTglBtn[c] = Button
          {
             this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
             stayOnTop = true;
             id = c;
-            size = { 99, 20 };
+            minClientSize = { 99, 20 };
             anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
 
             bool NotifyClicked(Button button, int x, int y, Modifiers mods)
@@ -638,6 +722,7 @@ class CompilerDirectoriesTab : CompilersSubTab
                return true;
             }
          };
+         v += dirTypeTglBtn[c].size.w + 1;
          incref dirTypeTglBtn[c];
 
          if(c == includes)
@@ -646,18 +731,29 @@ class CompilerDirectoriesTab : CompilersSubTab
             dirTypeTglBtn[c].hotKey = altL;
          else if(c == executables)
             dirTypeTglBtn[c].hotKey = altE;
-         }
-      }   
+      }
       currentDirs = dirs[includes];
       dirTypeTglBtn[includes].checked = true;
       return true;
    }
 
+   bool OnLoadGraphics()
+   {
+      DirTypes c;
+      int v = 8;
+      for(c = 0; c < DirTypes::enumSize; c++)
+      {
+         dirTypeTglBtn[c].anchor.left = v;
+         v += dirTypeTglBtn[c].size.w + 1;
+      }
+      return CompilersSubTab::OnLoadGraphics();
+   }
+
    void Load()
    {
-      if(loadedCompiler)
+      CompilerConfig compiler = loadedCompiler;
+      if(compiler)
       {
-         CompilerConfig compiler = loadedCompiler;
          dirs[includes].strings = compiler.includeDirs;
          dirs[libraries].strings = compiler.libraryDirs;
          dirs[executables].strings = compiler.executableDirs;
@@ -673,66 +769,106 @@ class CompilerToolchainTab : CompilersSubTab
    background = formColor;
    text = $"Toolchain";
 
+   int margin;
+   margin = 130;
+
    Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
    PathBox ecp
    {
-      this, anchor = { left = 120, top = 8, right = 8 };
+      this, anchor = { left = margin, top = 8, right = 8 };
       text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
    Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
    PathBox ecc
    {
-      this, anchor = { left = 120, top = 34, right = 8 };
+      this, anchor = { left = margin, top = 34, right = 8 };
       text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
    Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
    PathBox ecs
    {
-      this, anchor = { left = 120, top = 60, right = 8 };
+      this, anchor = { left = margin, top = 60, right = 8 };
       text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
    Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
    PathBox ear
    {
-      this, anchor = { left = 120, top = 86, right = 8 };
+      this, anchor = { left = margin, top = 86, right = 8 };
       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 = 120, top = 112, right = 8 };
-      text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+      this, anchor = { left = margin, top = 112, right = 8 };
+      //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
    {
-      this, anchor = { left = 120, top = 138, right = 8 };
+      this, anchor = { left = margin, top = 138, right = 8 };
       text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
    Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
    PathBox cxx
    {
-      this, anchor = { left = 120, top = 164, right = 8 };
+      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 };
+   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 = 120, top = 190, right = 8 };
+      this, anchor = { left = margin, top = 242, right = 8 };
       text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
-   Label execPrefixLabel { this, position = { 8, 220 }, labeledWindow = execPrefix, tabCycle = false, inactive = true };
-   PathBox execPrefix
+   Label gnuToolchainPrefixLabel { this, position = { 8, 272 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
+   PathBox gnuToolchainPrefix
+   {
+      this, anchor = { left = margin, top = 268, right = 8 };
+      text = $"GNU Toolchain Prefix", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+   };
+   Label sysrootLabel { this, position = { 8, 298 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
+   PathBox sysroot
+   {
+      this, anchor = { left = margin, top = 294, right = 8 };
+      text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+   };
+   Label executableLauncherLabel { this, position = { 8, 324 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
+   PathBox executableLauncher
    {
-      this, anchor = { left = 120, top = 216, right = 8 };
-      text = $"Execution Prefix", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
+      this, anchor = { left = margin, top = 320, right = 8 };
+      text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
    };
 
    bool NotifyModifiedDocument(PathBox pathBox)
    {
-      if(loadedCompiler)
+      CompilerConfig compiler = loadedCompiler;
+      if(compiler)
       {
-         CompilerConfig compiler = loadedCompiler;
+         BasicValidatePathBoxPath(pathBox);
          if(pathBox == ecp)
             compiler.ecpCommand = pathBox.slashPath;
          else if(pathBox == ecc)
@@ -741,16 +877,24 @@ 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 == execPrefix)
-            compiler.execPrefixCommand = pathBox.slashPath;
+         else if(pathBox == executableLauncher)
+            compiler.executableLauncher = pathBox.slashPath;
+         else if(pathBox == gnuToolchainPrefix)
+            compiler.gccPrefix = pathBox.slashPath;
+         else if(pathBox == sysroot)
+            compiler.sysroot = pathBox.slashPath;
          modifiedDocument = true;
          compilersTab.modifiedDocument = true;
       }
@@ -759,29 +903,39 @@ class CompilerToolchainTab : CompilersSubTab
 
    void Load()
    {
-      if(loadedCompiler)
+      CompilerConfig compiler = loadedCompiler;
+      if(compiler)
       {
-         CompilerConfig compiler = loadedCompiler;
          bool disabled = compiler.readOnly;
          bool isVC = compiler.type.isVC;
          ecp.path = compiler.ecpCommand;
          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;
-         execPrefix.path = compiler.execPrefixCommand;
+         executableLauncher.path = compiler.executableLauncher;
+         gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
+         sysroot.path = compiler.sysroot;
 
          ecpLabel.disabled = ecp.disabled = disabled;
          eccLabel.disabled = ecc.disabled = disabled;
          ecsLabel.disabled = ecs.disabled = disabled;
          earLabel.disabled = ear.disabled = disabled;
          cppLabel.disabled = cpp.disabled = isVC || disabled;
+         cxxLabel.disabled = cxx.disabled = isVC || disabled;
          ccLabel.disabled = cc.disabled = isVC || disabled;
+         ldLabel.disabled = ld.disabled = isVC || disabled;
+         arLabel.disabled = ar.disabled = isVC || disabled;
          makeLabel.disabled = make.disabled = disabled;
-         execPrefixLabel.disabled = execPrefix.disabled = disabled;
+         executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
+         gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
+         sysrootLabel.disabled = sysroot.disabled = disabled;
       }
       modifiedDocument = false;
    }
@@ -800,9 +954,13 @@ class CompilerEnvironmentTab : CompilersSubTab
 
       bool NotifyModified(NamedStringsBox stringsBox)
       {
-         loadedCompiler.environmentVars = stringsBox.namedStrings;
-         modifiedDocument = true;
-         compilersTab.modifiedDocument = true;
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.environmentVars = stringsBox.namedStrings;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
          return true;
       }
    };
@@ -813,9 +971,9 @@ class CompilerEnvironmentTab : CompilersSubTab
 
    void Load()
    {
-      if(loadedCompiler)
+      CompilerConfig compiler = loadedCompiler;
+      if(compiler)
       {
-         CompilerConfig compiler = loadedCompiler;
          envVars.namedStrings = compiler.environmentVars;
 
          modifiedDocument = false;
@@ -851,19 +1009,19 @@ class CompilerOptionsTab : CompilersSubTab
    DataBox numJobsBox
    {
       this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
-      position = { 184, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
+      position = { 244, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
 
       bool OnKeyDown(Key key, unichar ch)
       {
          if((SmartKey)key == enter)
-         {  
+         {
             DataBox::OnKeyDown(key, ch);
             return true;
          }
          else
             return DataBox::OnKeyDown(key, ch);
       }
-      
+
       bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
       {
          if(!active)
@@ -874,7 +1032,7 @@ class CompilerOptionsTab : CompilersSubTab
          return true;
       }
 
-      bool NotifyChanged(bool closingDropDown)
+      bool NotifyChanged(DataBox dataBox, bool closingDropDown)
       {
          CompilerConfig compiler = loadedCompiler;
          if(compiler)
@@ -907,7 +1065,7 @@ class CompilerOptionsTab : CompilersSubTab
 
    Button distccEnabled
    {
-      this, text = $"Use distcc", hotKey = altD, position = { 8, 96 };
+      this, text = $"Use distcc", position = { 158, 68 };
       isCheckbox = true;
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
@@ -915,7 +1073,7 @@ class CompilerOptionsTab : CompilersSubTab
          CompilerConfig compiler = loadedCompiler;
          if(compiler)
          {
-            distccHosts.disabled = !button.checked;
+            distccHostsLabel.disabled = distccHosts.disabled = !button.checked;
             compiler.distccEnabled = button.checked;
             modifiedDocument = true;
             compilersTab.modifiedDocument = true;
@@ -924,24 +1082,246 @@ class CompilerOptionsTab : CompilersSubTab
       }
    };
 
-   Label distccHostsLabel { this, position = { 8, 124 }, labeledWindow = distccHosts };
+   Label distccHostsLabel { this, position = { 240, 68 }, labeledWindow = distccHosts };
    EditBox distccHosts
    {
       this, text = $"distcc hosts", hotKey = altH;
-      position = { 88, 120 }, size = { 300 };
+      position = { 320, 64 }, size = { 160, 22 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.distccHosts = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Label lblPrepDefs { this, position = { 8, 96 }, labeledWindow = prepDefs };
+   StringListBox prepDefs
+   {
+      this, text = $"Preprocessor directives", hotKey = altP;
+      position = { 168, 94 }, size = { 280, 22 }, anchor = { left = 168, top = 94, right = 8 };
 
       bool NotifyModified(EditBox editBox)
       {
          if(loadedCompiler)
          {
             CompilerConfig compiler = loadedCompiler;
-            compiler.distccHosts = editBox.contents;
+            compiler.prepDirectives = ((StringListBox)editBox).strings;
             modifiedDocument = true;
             compilersTab.modifiedDocument = true;
          }
          return true;
       }
-   }
+   };
+
+   Label leCcompilerFlags { this, position = { 8, 126 }, labeledWindow = eCcompilerFlags };
+   StringListBox eCcompilerFlags
+   {
+      this, text = $"Additional eC compiler flags", hotKey = altG;
+      position = { 168, 124 }, size = { 280, 22 }, anchor = { left = 168, top = 124, right = 8 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         if(loadedCompiler)
+         {
+            CompilerConfig compiler = loadedCompiler;
+            compiler.eCcompilerFlags = ((StringListBox)editBox).strings;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Label lblCompilerFlags { this, position = { 8, 156 }, labeledWindow = compilerFlags };
+   StringListBox compilerFlags
+   {
+      this, text = $"Additional C compiler flags", hotKey = altR;
+      position = { 168, 154 }, size = { 280, 22 }, anchor = { left = 168, top = 154, right = 8 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         if(loadedCompiler)
+         {
+            CompilerConfig compiler = loadedCompiler;
+            compiler.compilerFlags = ((StringListBox)editBox).strings;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Label lblcxxFlags { this, position = { 8, 186 }, labeledWindow = cxxFlags };
+   StringListBox cxxFlags
+   {
+      this, text = $"Additional C++ compiler flags", hotKey = altD;
+      position = { 168, 184 }, size = { 280, 22 }, anchor = { left = 168, top = 184, right = 8 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         if(loadedCompiler)
+         {
+            CompilerConfig compiler = loadedCompiler;
+            compiler.cxxFlags = ((StringListBox)editBox).strings;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Label lblLinkerFlags { this, position = { 8, 216 }, labeledWindow = linkerFlags };
+   StringListBox linkerFlags
+   {
+      this, text = $"Additional linker flags", hotKey = altL;
+      position = { 168, 214 }, size = { 280, 22 }, anchor = { left = 168, top = 214, right = 8 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         if(loadedCompiler)
+         {
+            CompilerConfig compiler = loadedCompiler;
+            compiler.linkerFlags = ((StringListBox)editBox).strings;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Label lblExcludedLibraries { this, position = { 8, 246 }, labeledWindow = excludedLibraries };
+   StringListBox excludedLibraries
+   {
+      this, text = $"Libraries to exclude", hotKey = altX;
+      position = { 168, 244 }, size = { 280, 22 }, anchor = { left = 168, top = 244, right = 8 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         if(loadedCompiler)
+         {
+            CompilerConfig compiler = loadedCompiler;
+            compiler.excludeLibs = ((StringListBox)editBox).strings;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   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 staticLibFileExtLabel { this, position = { 8, 306 }, labeledWindow = staticLibFileExt };
+   EditBox staticLibFileExt
+   {
+      this, text = $"Target extensions (a, so, exe)";//, hotKey = altH;
+      position = { 168, 304 }, size = { 80, 22 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.staticLibFileExt = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+   EditBox sharedLibFileExt
+   {
+      this;
+      position = { 256, 304 }, size = { 80, 22 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.sharedLibFileExt = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+   EditBox executableFileExt
+   {
+      this;
+      position = { 344, 304 }, size = { 80, 22 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.executableFileExt = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Button stripTarget
+   {
+      this, text = $"Strip target", hotKey = altC, position = { 168, 332 };
+      isCheckbox = true;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.noStripTarget = !button.checked;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Button resourcesDotEar
+   {
+      this, text = $"Use resources.ear", position = { 308, 332 };
+      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()
    {
@@ -957,18 +1337,30 @@ class CompilerOptionsTab : CompilersSubTab
 
    void Load()
    {
-      if(loadedCompiler)
+      CompilerConfig compiler = loadedCompiler;
+      if(compiler)
       {
-         CompilerConfig compiler = loadedCompiler;
          bool disabled = compiler.readOnly;
          targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
          numJobs = compiler.numJobs;
          numJobsBox.Refresh();
          ccacheEnabled.checked = compiler.ccacheEnabled;
          distccEnabled.checked = compiler.distccEnabled;
-         distccHosts.disabled = !compiler.distccEnabled;
+         distccHostsLabel.disabled = distccHosts.disabled = !compiler.distccEnabled;
          distccHosts.contents = compiler.distccHosts;
-         
+         prepDefs.strings = compiler.prepDirectives;
+         excludedLibraries.strings = compiler.excludeLibs;
+         eCcompilerFlags.strings = compiler.eCcompilerFlags;
+         compilerFlags.strings = compiler.compilerFlags;
+         cxxFlags.strings = compiler.cxxFlags;
+         linkerFlags.strings = compiler.linkerFlags;
+         objectFileExt.contents = compiler.objectFileExt;
+         staticLibFileExt.contents = compiler.staticLibFileExt;
+         sharedLibFileExt.contents = compiler.sharedLibFileExt;
+         executableFileExt.contents = compiler.executableFileExt;
+         stripTarget.checked = !compiler.noStripTarget;
+         resourcesDotEar.checked = compiler.resourcesDotEar;
+
          labelTargetPlatform.disabled = disabled;
          targetPlatform.disabled = disabled;
 
@@ -1011,8 +1403,9 @@ class ProjectOptionsTab : GlobalSettingsSubTab
       this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
       text = $"Default Target Directory", hotKey = altT;
 
-      bool NotifyModified(PathBox editBox)
+      bool NotifyModified(PathBox pathBox)
       {
+         BasicValidatePathBoxPath(pathBox);
          modifiedDocument = true;
          return true;
       }
@@ -1024,15 +1417,16 @@ class ProjectOptionsTab : GlobalSettingsSubTab
       this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
       text = $"Default Intermediate Objects Directory", hotKey = altI;
 
-      bool NotifyModified(PathBox editBox)
+      bool NotifyModified(PathBox pathBox)
       {
+         BasicValidatePathBoxPath(pathBox);
          modifiedDocument = true;
          return true;
       }
    };
 }
 
-// COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate 
+// COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
 //                 of WorkspaceOptionsTab will *not* be called!
 class GlobalSettingsSubTab : Tab
 {
@@ -1069,14 +1463,14 @@ class WorkspaceOptionsTab : GlobalSettingsSubTab
    bool OnCreate()
    {
       GlobalSettingsDialog dialog = this.dialog;
-      if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
+      if(dialog && dialog.compilersTab.compilerConfigs && ideSettings)
       {
          DataRow row;
-         for(compiler : dialog.ideSettings.compilerConfigs)
+         for(compiler : ideConfig.compilers)
          {
             row = defaultCompilerDropBox.AddString(compiler.name);
-            if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] && 
-                  !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
+            if(ideSettings.defaultCompiler && ideSettings.defaultCompiler[0] &&
+                  !strcmp(compiler.name, ideSettings.defaultCompiler))
                defaultCompilerDropBox.currentRow = row;
          }
          if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)