ide: Renamed selection of 32/64 bit from 'bit depth' to 'bit length'; Updated credits
[sdk] / ide / src / ide.ec
index 21fb1b2..65967b0 100644 (file)
@@ -211,7 +211,7 @@ class IDEToolbar : ToolBar
 
    /* Edit options */
    // Cut
-   // Copy 
+   // Copy
    // Paste
    // Undo
    // Redo
@@ -246,6 +246,9 @@ class IDEToolbar : ToolBar
    // Compile actual file
    // Execute
    ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem), disabled = true; };
+#ifdef IDE_SHOW_INSTALL_MENU_BUTTON
+   ToolButton buttonInstall { this, toolTip = $"Install", menuItemPtr = IDEItem(projectInstallItem), disabled = true; };
+#endif
 
    ToolSeparator separator4 { this };
 
@@ -279,21 +282,7 @@ class IDEToolbar : ToolBar
       bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
       {
          if(row)
-         {
-            for(prj : ide.workspace.projects)
-            {
-               for(cfg : prj.configurations)
-               {
-                  if(cfg.name && !strcmp(cfg.name, row.string))
-                  {
-                     prj.config = cfg;
-                     break;
-                  }
-               }
-            }
-            ide.UpdateToolBarActiveConfigs(true);
-            ide.projectView.Update(null);
-         }
+            ide.workspace.SelectActiveConfig(row.string);
          return true;
       }
    };
@@ -324,7 +313,7 @@ class IDEToolbar : ToolBar
 
    DropBox activeBitDepth
    {
-      this, toolTip = $"Active Bit Depth", size = { 60 }, disabled = true;
+      this, toolTip = $"Active Bit Length", size = { 60 }, disabled = true;
       bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
       {
          if(ide.workspace && ide.projectView && row)
@@ -418,6 +407,7 @@ class IDEWorkSpace : Window
    MenuItem * driverItems, * skinItems;
    StatusField pos { width = 150 };
    StatusField ovr, caps, num;
+   DualPipe documentor;
 
    BitmapResource back                 { ":ecereBack.jpg", window = this };
    BitmapResource bmpBp                { ":codeMarks/breakpoint.png", window = this };
@@ -430,7 +420,7 @@ class IDEWorkSpace : Window
    BitmapResource bmpTopFrameError     { ":codeMarks/topFrameError.png", window = this };
    BitmapResource bmpTopFrameHalf      { ":codeMarks/topFrameHalf.png", window = this };
    BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
-   
+
    Debugger debugger { };
 
    ProjectView projectView;
@@ -453,9 +443,9 @@ class IDEWorkSpace : Window
       {
          switch(key)
          {
-            case escape: 
+            case escape:
                if(activeBox != findBox || !ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
-                  ide.ShowCodeEditor(); 
+                  ide.ShowCodeEditor();
                break;
             default:
             {
@@ -466,13 +456,6 @@ class IDEWorkSpace : Window
          return true;
       }
 
-      bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
-      {
-         if(active)
-            ide.RepositionWindows(false);
-         return true;
-      }
-
       bool OnClose(bool parentClosing)
       {
          visible = false;
@@ -486,16 +469,11 @@ class IDEWorkSpace : Window
    {
       parent = this, font = { panelFont.faceName, panelFont.size };
 
-      void OnGotoLine(char * line)
+      void OnSelectFrame(int frameIndex)
       {
-         int stackLvl;
-         stackLvl = atoi(line);
-         ide.debugger.GoToStackFrameLine(stackLvl, true);
-      }
-
-      void OnSelectFrame(int lineNumber)
-      {
-         ide.debugger.SelectFrame(lineNumber);
+         ide.debugger.GoToStackFrameLine(frameIndex, true, true);
+         if(frameIndex >= 0)
+            ide.debugger.SelectFrame(frameIndex);
       }
 
       void OnToggleBreakpoint()
@@ -504,33 +482,7 @@ class IDEWorkSpace : Window
          if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
          {
             int line = debugger.activeFrame.line;
-            char name[MAX_LOCATION];
-            Project prj = null;
-            // TOFIX: Improve on this, don't use only filename, make a function
-            GetLastDirectory(debugger.activeFrame.absoluteFile, name);
-            if(ide && ide.workspace)
-            {
-               for(p : ide.workspace.projects)
-               {
-                  if(p.topNode.Find(name, false))
-                  {
-                     prj = p;
-                     break;
-                  }
-               }
-               if(!prj)
-               {
-                  for(p : ide.workspace.projects)
-                  {
-                     if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
-                     {
-                        prj = p;
-                        break;
-                     }
-                  }
-               }
-            }
-            debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
+            debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line);
             Update(null);
             {
                CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
@@ -548,13 +500,6 @@ class IDEWorkSpace : Window
          return true;
       }
 
-      bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
-      {
-         if(active)
-            ide.RepositionWindows(false);
-         return true;
-      }
-
       bool OnClose(bool parentClosing)
       {
          visible = false;
@@ -620,7 +565,7 @@ class IDEWorkSpace : Window
          }
       }
    };
-   
+
    WatchesView watchesView { parent = this };
    ThreadsView threadsView
    {
@@ -635,13 +580,6 @@ class IDEWorkSpace : Window
          return true;
       }
 
-      bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
-      {
-         if(active)
-            ide.RepositionWindows(false);
-         return true;
-      }
-
       bool OnClose(bool parentClosing)
       {
          visible = false;
@@ -710,11 +648,12 @@ class IDEWorkSpace : Window
                         gotWhatWeWant = true;
                   }
                   if(gotWhatWeWant ||
-                     MessageBox { type = yesNo, master = this, text = $"Error opening file", 
+                     MessageBox { type = yesNo, master = this, text = $"Error opening file",
                      contents = $"Open a different file?" }.Modal() == no)
                   {
                      if(!projectView && gotWhatWeWant)
                         ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
+                     ide.RepositionWindows(false);
                      break;
                   }
                }
@@ -783,7 +722,7 @@ class IDEWorkSpace : Window
       MenuDivider { fileMenu };
       MenuItem exitItem
       {
-         fileMenu, $"Exit", x, altF4, NotifySelect = MenuFileExit;
+         fileMenu, $"Exit", x, altF4;
 
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
@@ -810,7 +749,10 @@ class IDEWorkSpace : Window
                   delete command;
                }
                else
+               {
                   OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal, mods.ctrl && mods.shift);
+                  ide.RepositionWindows(false);
+               }
                break;
             }
             id++;
@@ -841,7 +783,7 @@ class IDEWorkSpace : Window
       }
 
    MenuPlacement editMenu { menu, $"Edit", e };
-   
+
    Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
       MenuItem projectNewItem
       {
@@ -853,6 +795,7 @@ class IDEWorkSpace : Window
             {
                DialogResult result;
                NewProjectDialog newProjectDialog { master = this };
+               incref newProjectDialog;
                result = newProjectDialog.Modal();
                if(result == ok)
                {
@@ -867,6 +810,7 @@ class IDEWorkSpace : Window
                      }
                   }
                }
+               delete newProjectDialog;
             }
             return true;
          }
@@ -916,7 +860,7 @@ class IDEWorkSpace : Window
                {
                   if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add, mods.ctrl && mods.shift))
                      break;
-                  if(MessageBox { type = yesNo, master = this, text = $"Error opening project file", 
+                  if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
                         contents = $"Add a different project?" }.Modal() == no)
                   {
                      break;
@@ -1065,6 +1009,19 @@ class IDEWorkSpace : Window
             return true;
          }
       }
+      MenuItem projectInstallItem
+      {
+#ifdef IDE_SHOW_INSTALL_MENU_BUTTON
+         projectMenu, $"Install", t, disabled = true;
+#endif
+         bitmap = { ":status/software-update-available.png" };
+         bool NotifySelect(MenuItem selection, Modifiers mods)
+         {
+            if(projectView)
+               projectView.ProjectInstall(projectView.active ? selection : null, mods);
+            return true;
+         }
+      }
       MenuItem projectCompileItem;
    Menu debugMenu { menu, $"Debug", d, hasMargin = true };
       MenuItem debugStartResumeItem
@@ -1124,6 +1081,96 @@ class IDEWorkSpace : Window
             return true;
          }
       }
+#ifndef __WIN32__
+      MenuDivider { debugMenu };
+      MenuItem debugUseValgrindItem
+      {
+         debugMenu, $"Use Valgrind", d, disabled = true, checkable = true;
+         bool NotifySelect(MenuItem selection, Modifiers mods)
+         {
+            if(ide.workspace)
+            {
+               ide.workspace.useValgrind = selection.checked;
+               ide.workspace.Save();
+            }
+            ide.AdjustValgrindMenus();
+            return true;
+         }
+      }
+      Menu debugValgrindLeakCheckItem { debugMenu, $"Valgrind Leak Check", h };
+         MenuItem debugValgrindNoLeakCheckItem      { debugValgrindLeakCheckItem, $"No"     , f, id = ValgrindLeakCheck::no     , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
+         MenuItem debugValgrindSummaryLeakCheckItem { debugValgrindLeakCheckItem, $"Summary", f, id = ValgrindLeakCheck::summary, checkable = true, disabled = true; NotifySelect = ValgrindLCSelect, checked = true; }
+         MenuItem debugValgrindYesLeakCheckItem     { debugValgrindLeakCheckItem, $"Yes"    , f, id = ValgrindLeakCheck::yes    , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
+         MenuItem debugValgrindFullLeakCheckItem    { debugValgrindLeakCheckItem, $"Full"   , f, id = ValgrindLeakCheck::full   , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
+         bool ValgrindLCSelect(MenuItem selection, Modifiers mods)
+         {
+            if(ide.workspace)
+            {
+               if(selection.checked)
+               {
+                  ValgrindLeakCheck vgLeakCheck = (ValgrindLeakCheck)selection.id;
+
+                  debugValgrindNoLeakCheckItem.checked      = debugValgrindNoLeakCheckItem.id      == vgLeakCheck;
+                  debugValgrindSummaryLeakCheckItem.checked = debugValgrindSummaryLeakCheckItem.id == vgLeakCheck;
+                  debugValgrindYesLeakCheckItem.checked     = debugValgrindYesLeakCheckItem.id     == vgLeakCheck;
+                  debugValgrindFullLeakCheckItem.checked    = debugValgrindFullLeakCheckItem.id    == vgLeakCheck;
+
+                  ide.workspace.vgLeakCheck = vgLeakCheck;
+                  ide.workspace.Save();
+               }
+               else
+                  selection.checked = true;
+            }
+            return true;
+         }
+      Menu debugValgrindRedzoneSizeItem { debugMenu, $"Valgrind Redzone Size", z };
+         MenuItem debugValgrindRSDefaultItem { debugValgrindRedzoneSizeItem, $"Default", f, id =  -1, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect, checked = true; }
+         MenuItem debugValgrindRS0Item       { debugValgrindRedzoneSizeItem, $"0"      , f, id =   0, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
+         MenuItem debugValgrindRS16Item      { debugValgrindRedzoneSizeItem, $"16"     , f, id =  16, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
+         MenuItem debugValgrindRS32Item      { debugValgrindRedzoneSizeItem, $"32"     , f, id =  32, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
+         MenuItem debugValgrindRS64Item      { debugValgrindRedzoneSizeItem, $"64"     , f, id =  64, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
+         MenuItem debugValgrindRS128Item     { debugValgrindRedzoneSizeItem, $"128"    , f, id = 128, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
+         MenuItem debugValgrindRS256Item     { debugValgrindRedzoneSizeItem, $"256"    , f, id = 256, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
+         MenuItem debugValgrindRS512Item     { debugValgrindRedzoneSizeItem, $"512"    , f, id = 512, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
+         bool ValgrindRSSelect(MenuItem selection, Modifiers mods)
+         {
+            if(ide.workspace)
+            {
+               if(selection.checked)
+               {
+                  int vgRedzoneSize = (int)selection.id;
+
+                  debugValgrindRSDefaultItem.checked = debugValgrindRSDefaultItem.id == vgRedzoneSize;
+                  debugValgrindRS0Item.checked       = debugValgrindRS0Item.id       == vgRedzoneSize;
+                  debugValgrindRS16Item.checked      = debugValgrindRS16Item.id      == vgRedzoneSize;
+                  debugValgrindRS32Item.checked      = debugValgrindRS32Item.id      == vgRedzoneSize;
+                  debugValgrindRS64Item.checked      = debugValgrindRS64Item.id      == vgRedzoneSize;
+                  debugValgrindRS128Item.checked     = debugValgrindRS128Item.id     == vgRedzoneSize;
+                  debugValgrindRS256Item.checked     = debugValgrindRS256Item.id     == vgRedzoneSize;
+                  debugValgrindRS512Item.checked     = debugValgrindRS512Item.id     == vgRedzoneSize;
+
+                  ide.workspace.vgRedzoneSize = vgRedzoneSize;
+                  ide.workspace.Save();
+               }
+               else
+                  selection.checked = true;
+            }
+            return true;
+         }
+      MenuItem debugValgrindTrackOriginsItem
+      {
+         debugMenu, $"Valgrind Track Origins", k, checkable = true, disabled = true;
+         bool NotifySelect(MenuItem selection, Modifiers mods)
+         {
+            if(ide.workspace)
+            {
+               ide.workspace.vgTrackOrigins = selection.checked;
+               ide.workspace.Save();
+            }
+            return true;
+         }
+      };
+#endif
       MenuDivider { debugMenu };
       MenuItem debugStepIntoItem
       {
@@ -1131,8 +1178,7 @@ class IDEWorkSpace : Window
          bitmap = { ":actions/stepInto.png" };
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
-            if(projectView)
-               projectView.DebugStepInto();
+            if(projectView) projectView.DebugStepInto();
             return true;
          }
       }
@@ -1142,8 +1188,17 @@ class IDEWorkSpace : Window
          bitmap = { ":actions/stepOver.png" };
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
-            if(projectView)
-               projectView.DebugStepOver(false);
+            if(projectView) projectView.DebugStepOver(false);
+            return true;
+         }
+      }
+      MenuItem debugSkipStepOverItem
+      {
+         debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
+         bitmap = { ":actions/stepOverSkipBreak.png" };
+         bool NotifySelect(MenuItem selection, Modifiers mods)
+         {
+            if(projectView) projectView.DebugStepOver(true);
             return true;
          }
       }
@@ -1153,35 +1208,50 @@ class IDEWorkSpace : Window
          bitmap = { ":actions/stepOut.png" };
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
-            if(projectView)
-               projectView.DebugStepOut(false);
+            if(projectView) projectView.DebugStepOut(false);
             return true;
          }
       }
-      MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
-      MenuItem debugSkipStepOverItem
+      MenuItem debugSkipStepOutItem
       {
-         debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
+         debugMenu, $"Step Out Skipping Breakpoints", n, Key { f11, ctrl = true, shift = true }, disabled = true;
+         bitmap = { ":actions/skipBreaks.png" };
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
-            if(projectView)
-               projectView.DebugStepOver(true);
+            if(projectView) projectView.DebugStepOut(true);
             return true;
          }
       }
-      MenuItem debugSkipStepOutItem
+#if 0
+      MenuItem debugStepUntilItem
       {
-         debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
-         bitmap = { ":actions/skipBreaks.png" };
+         debugMenu, $"Step Over Until Next Line", x, disabled = true;
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
-            if(projectView)
-               projectView.DebugStepOut(true);
+            if(projectView) projectView.DebugStepUntil(false);
             return true;
          }
       }
+      MenuItem debugSkipStepUntilItem
+      {
+         debugMenu, $"Step Over Until Next Line Skipping Breakpoints", e, Key { f10, shift = true, alt = true }, disabled = true;
+         bool NotifySelect(MenuItem selection, Modifiers mods)
+         {
+            if(projectView) projectView.DebugStepUntil(true);
+            return true;
+         }
+      }
+#endif
+      MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
       MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
-      MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", s };
+      MenuPlacement debugRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level", l };
+      MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", g };
+#if 0
+      MenuPlacement debugBpRunToCursorItem { debugMenu, $"BP Run To Cursor" };
+      MenuPlacement debugBpSkipRunToCursorItem { debugMenu, $"BP Run To Cursor Skipping Breakpoints" };
+      MenuPlacement debugBpRunToCursorAtSameLevelItem { debugMenu, $"BP Run To Cursor At Same Level" };
+      MenuPlacement debugBpSkipRunToCursorAtSameLevelItem { debugMenu, $"BP Run To Cursor At Same Level Skipping Breakpoints" };
+#endif
       //MenuDivider { debugMenu };
       //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
    MenuPlacement imageMenu { menu, $"Image", i };
@@ -1341,7 +1411,7 @@ class IDEWorkSpace : Window
       MenuDivider { viewMenu };
       MenuItem viewColorPicker
       {
-         viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
+         viewMenu, $"Color Picker...", l, Key { c, ctrl = true , shift = true };
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
             ColorPicker colorPicker { master = this };
@@ -1384,18 +1454,26 @@ class IDEWorkSpace : Window
          helpMenu, $"API Reference", r, f1;
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
-            char * p = new char[MAX_LOCATION];
-            p[0] = '\0';
-            strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
-            PathCat(p, "documentor");
-#if defined(__WIN32__)
-            ChangeExtension(p, "exe", p);
-#endif
-            if(FileExists(p).isFile)
-               Execute(p);
+            if(!documentor)
+            {
+               char * p = new char[MAX_LOCATION];
+               p[0] = '\0';
+               strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
+               PathCat(p, "documentor");
+   #if defined(__WIN32__)
+               ChangeExtension(p, "exe", p);
+   #endif
+               if(!FileExists(p).isFile)
+                  strcpy(p, "documentor");
+
+               documentor = DualPipeOpen({ input = true, output = true, showWindow = true }, p);
+               delete p;
+            }
             else
-               Execute("documentor");
-            delete p;
+            {
+               Process_ShowWindows(documentor.GetProcessID());
+               // documentor.Puts("Activate\n");
+            }
             return true;
          }
       }
@@ -1491,7 +1569,7 @@ class IDEWorkSpace : Window
    GDBDialog gdbDialog
    {
       master = this, parent = this;
-      anchor = { left = 100, top = 100, right = 100, bottom = 100 };
+      //anchor = { left = 100, top = 100, right = 100, bottom = 100 };
 
       void OnCommand(char * string)
       {
@@ -1500,7 +1578,7 @@ class IDEWorkSpace : Window
       }
    };
 #endif
-   
+
    bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
    {
       //app.driver = app.drivers[selection.id];
@@ -1548,12 +1626,12 @@ class IDEWorkSpace : Window
       {
          this;
          fileName = fileName;
-         
+
          void NotifyDestroyed(Window window, DialogResult result)
          {
             projectView = null;
             text = titleECEREIDE;
-            
+
             AdjustMenus();
          }
       };
@@ -1613,10 +1691,10 @@ class IDEWorkSpace : Window
          bool outputVisible = expand ? false : outputView.visible;
          int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
          int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
-         
+
          for(child = firstChild; child; child = child.next)
          {
-            if(child._class == class(CodeEditor) || child._class == class(Designer) || 
+            if(child._class == class(CodeEditor) || child._class == class(Designer) ||
                child._class == class(Sheet) || child._class == class(ProjectView))
             {
                Anchor anchor = child.anchor;
@@ -1624,13 +1702,14 @@ class IDEWorkSpace : Window
                anchor.bottom = bottomDistance;
                if(child._class == class(CodeEditor) || child._class == class(Designer))
                {
+                  anchor.left = 300;
                   anchor.right = toolBoxVisible ? 150 : 0;
                }
                child.anchor = anchor;
             }
             else if(expand)
             {
-               if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) || 
+               if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
                   child._class == class(BreakpointsView))
                   child.visible = false;
             }
@@ -1645,7 +1724,7 @@ class IDEWorkSpace : Window
       if(activeClient)
          activeClient.Activate();
       else if(projectView)
-      { 
+      {
          projectView.visible = true;
          projectView.Activate();
       }
@@ -1828,11 +1907,38 @@ class IDEWorkSpace : Window
       toolBar.activeCompiler.disabled     = unavailable;
       toolBar.activeBitDepth.disabled     = unavailable;
 
+#ifndef __WIN32__
+      debugUseValgrindItem.disabled       = unavailable;
+      AdjustValgrindMenus();
+#endif
+
       AdjustFileMenus();
       AdjustBuildMenus();
       AdjustDebugMenus();
    }
 
+#ifndef __WIN32__
+   void AdjustValgrindMenus()
+   {
+      bool unavailable = !project || !debugUseValgrindItem.checked;
+      debugValgrindNoLeakCheckItem.disabled        = unavailable;
+      debugValgrindSummaryLeakCheckItem.disabled   = unavailable;
+      debugValgrindYesLeakCheckItem.disabled       = unavailable;
+      debugValgrindFullLeakCheckItem.disabled      = unavailable;
+
+      debugValgrindTrackOriginsItem.disabled       = unavailable;
+
+      debugValgrindRSDefaultItem.disabled          = unavailable;
+      debugValgrindRS0Item.disabled                = unavailable;
+      debugValgrindRS16Item.disabled               = unavailable;
+      debugValgrindRS32Item.disabled               = unavailable;
+      debugValgrindRS64Item.disabled               = unavailable;
+      debugValgrindRS128Item.disabled              = unavailable;
+      debugValgrindRS256Item.disabled              = unavailable;
+      debugValgrindRS512Item.disabled              = unavailable;
+   }
+#endif
+
    property bool hasOpenedCodeEditors
    {
       get
@@ -1857,6 +1963,7 @@ class IDEWorkSpace : Window
    void AdjustBuildMenus()
    {
       bool unavailable = project && projectView.buildInProgress;
+      bool naForRun = unavailable || !project || project.GetTargetType(project.config) != executable;
 
       projectNewItem.disabled             = unavailable;
       toolBar.buttonNewProject.disabled   = unavailable;
@@ -1868,8 +1975,8 @@ class IDEWorkSpace : Window
       projectCloseItem.disabled           = unavailable;
       // toolBar.buttonCloseProject.disabled = unavailable;
 
-      projectRunItem.disabled    = unavailable || project.GetTargetType(project.config) != executable;
-      toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
+      projectRunItem.disabled    = naForRun;
+      toolBar.buttonRun.disabled = naForRun;
 
       projectBuildItem.disabled = false;
       projectBuildItem.text     = unavailable ? $"Stop Build" : $"Build";
@@ -1886,6 +1993,10 @@ class IDEWorkSpace : Window
       // toolBar.buttonRealClean.disabled          = unavailable;
       projectRegenerateItem.disabled            = unavailable;
       toolBar.buttonRegenerateMakefile.disabled = unavailable;
+#ifdef IDE_SHOW_INSTALL_MENU_BUTTON
+      projectInstallItem.disabled               = unavailable;
+      toolBar.buttonInstall.disabled            = unavailable;
+#endif
       projectCompileItem.disabled               = unavailable;
 
       AdjustPopupBuildMenus();
@@ -1912,6 +2023,7 @@ class IDEWorkSpace : Window
          menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0);             if(menu) menu.disabled = unavailable;
          menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0);         if(menu) menu.disabled = unavailable;
          menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0);        if(menu) menu.disabled = unavailable;
+         menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectInstall, 0);           if(menu) menu.disabled = unavailable;
          menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0);            if(menu) menu.disabled = unavailable;
          menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0);                if(menu) menu.disabled = unavailable;
          menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0);              if(menu) menu.disabled = unavailable;
@@ -1928,62 +2040,64 @@ class IDEWorkSpace : Window
             projectView.buildInProgress == buildingMainProject;
    } }
 
-   property bool isBreakpointTogglingUnavailable { get {
-      return !project;
-   } }
-
-   property bool isDebuggerExecuting { get {
-      if(!ide.debugger)
-         return false;
-      else
-         return ide.debugger.state == running;
-   } }
+   property bool isBreakpointTogglingUnavailable { get { return !project; } }
+   property bool isDebuggerRunning { get { if(ide.debugger) return ide.debugger.state == running; return false; } }
+   property bool isDebuggerStopped { get { if(ide.debugger) return ide.debugger.state == stopped; return false; } }
 
    void AdjustDebugMenus()
    {
       bool unavailable = areDebugMenusUnavailable;
+      bool running = isDebuggerRunning;
+      bool stopped = isDebuggerStopped;
       bool active = debugger.isActive;
-      bool bpNoToggle = isBreakpointTogglingUnavailable;
-      bool executing = isDebuggerExecuting;
-      //bool holding = debugger.state == stopped;
+      bool noBreakpointToggle = !project;
 
-      debugStartResumeItem.disabled       = unavailable || executing;
+      bool isNotRunning    = unavailable || !running;
+      bool isNotNotRunning = unavailable || running;
+      bool isNotStopped    = unavailable || !stopped;
+      bool isNotActive     = unavailable || !active;
+
+      debugStartResumeItem.disabled       = isNotNotRunning;
       debugStartResumeItem.text           = active ? $"Resume" : $"Start";
       debugStartResumeItem.NotifySelect   = active ? MenuDebugResume : MenuDebugStart;
       if(toolBar)
       {
-         toolBar.buttonDebugStartResume.disabled      = unavailable || executing;
+         toolBar.buttonDebugStartResume.disabled      = isNotNotRunning;
          toolBar.buttonDebugStartResume.toolTip       = active ? $"Resume" : $"Start";
       }
 
-      debugBreakItem.disabled             = unavailable || !executing;
-      debugStopItem.disabled              = unavailable || !active;
-      debugRestartItem.disabled           = unavailable || !active;
+      debugBreakItem.disabled             = isNotRunning;
+      debugStopItem.disabled              = isNotActive;
+      debugRestartItem.disabled           = isNotActive;
       if(toolBar)
       {
-         toolBar.buttonDebugPause.disabled            = unavailable || !executing;
-         toolBar.buttonDebugStop.disabled             = unavailable || !active;
-         toolBar.buttonDebugRestart.disabled          = unavailable || !active;
+         toolBar.buttonDebugPause.disabled            = isNotRunning;
+         toolBar.buttonDebugStop.disabled             = isNotActive;
+         toolBar.buttonDebugRestart.disabled          = isNotActive;
       }
 
-      debugStepIntoItem.disabled          = unavailable || executing;
-      debugStepOverItem.disabled          = unavailable || executing;
-      debugStepOutItem.disabled           = unavailable || executing || !active;
-      debugSkipStepOverItem.disabled      = unavailable || executing;
-      debugSkipStepOutItem.disabled       = unavailable || executing || !active;
+      debugStepIntoItem.disabled          = isNotNotRunning;
+      debugStepOverItem.disabled          = isNotNotRunning;
+      debugSkipStepOverItem.disabled      = isNotNotRunning;
+      debugStepOutItem.disabled           = isNotStopped;
+      debugSkipStepOutItem.disabled       = isNotStopped;
+#if 0
+      debugStepUntilItem.disabled         = isNotStopped;
+      debugSkipStepUntilItem.disabled     = isNotStopped;
+#endif
       if(toolBar)
       {
-         toolBar.buttonDebugStepInto.disabled         = unavailable || executing;
-         toolBar.buttonDebugStepOver.disabled         = unavailable || executing;
-         toolBar.buttonDebugStepOut.disabled          = unavailable || executing || !active;
-         toolBar.buttonDebugSkipStepOver.disabled     = unavailable || executing;
-         // toolBar.buttonDebugSkipStepOutItem.disabled  = unavailable || executing;
+         toolBar.buttonDebugStepInto.disabled         = isNotNotRunning;
+         toolBar.buttonDebugStepOver.disabled         = isNotNotRunning;
+         toolBar.buttonDebugSkipStepOver.disabled     = isNotNotRunning;
+         toolBar.buttonDebugStepOut.disabled          = isNotStopped;
+         //toolBar.buttonDebugSkipStepOutItem.disabled  = isNotNotRunning;
       }
       if((Designer)GetActiveDesigner())
       {
          CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
          if(codeEditor)
-            codeEditor.AdjustDebugMenus(unavailable, bpNoToggle, executing);
+            codeEditor.AdjustDebugMenus();
       }
    }
 
@@ -2030,13 +2144,13 @@ class IDEWorkSpace : Window
    {
       if(debugger.isActive)
       {
-         if(MessageBox { type = yesNo, master = ide, 
-                           contents = $"Do you want to terminate the debugging session in progress?", 
+         if(MessageBox { type = yesNo, master = ide,
+                           contents = $"Do you want to terminate the debugging session in progress?",
                            text = title }.Modal() == no)
             return true;
          /*
-         MessageBox msg { type = yesNo, master = ide, 
-                           contents = "Do you want to terminate the debugging session in progress?", 
+         MessageBox msg { type = yesNo, master = ide,
+                           contents = "Do you want to terminate the debugging session in progress?",
                            text = title };
          if(msg.Modal() == no)
          {
@@ -2100,7 +2214,7 @@ class IDEWorkSpace : Window
                   {
                      Project project;
                      Workspace workspace = null;
-                     
+
                      if(FileExists(filePath))
                      {
                         if(!strcmp(extension, ProjectExtension))
@@ -2116,14 +2230,15 @@ class IDEWorkSpace : Window
                            return null;
                         //project = LoadProject(filePath, null);
                      }
-                     
+
                      if(workspace)
                      {
                         char absolutePath[MAX_LOCATION];
                         CreateProjectView(workspace, filePath);
                         document = projectView;
 
-                        workspace.DropInvalidBreakpoints();
+                        workspace.ParseLoadedBreakpoints();
+                        workspace.DropInvalidBreakpoints(null);
                         workspace.Save();
 
                         ide.projectView.ShowOutputBuildLog(true);
@@ -2164,27 +2279,44 @@ class IDEWorkSpace : Window
                               }
                            }
                         }
+                        ide.RepositionWindows(false);
                         workspace.holdTracking = false;
 
                         workspace.timer.Start();
 
+#if !defined(__WIN32__)
+                        // Valgrind Debug menu updates
+                        debugUseValgrindItem.checked = workspace.useValgrind;
+
+                        debugValgrindNoLeakCheckItem.checked      = workspace.vgLeakCheck == no;
+                        debugValgrindSummaryLeakCheckItem.checked = workspace.vgLeakCheck == summary;
+                        debugValgrindYesLeakCheckItem.checked     = workspace.vgLeakCheck == yes;
+                        debugValgrindFullLeakCheckItem.checked    = workspace.vgLeakCheck == full;
+
+                        debugValgrindRSDefaultItem.checked = workspace.vgRedzoneSize == -1;
+                        debugValgrindRS0Item.checked       = workspace.vgRedzoneSize == 0;
+                        debugValgrindRS16Item.checked      = workspace.vgRedzoneSize == 16;
+                        debugValgrindRS32Item.checked      = workspace.vgRedzoneSize == 32;
+                        debugValgrindRS64Item.checked      = workspace.vgRedzoneSize == 64;
+                        debugValgrindRS128Item.checked     = workspace.vgRedzoneSize == 128;
+                        debugValgrindRS256Item.checked     = workspace.vgRedzoneSize == 256;
+                        debugValgrindRS512Item.checked     = workspace.vgRedzoneSize == 512;
+
+                        debugValgrindTrackOriginsItem.checked = workspace.vgTrackOrigins;
+#endif
+
                         findInFilesDialog.mode = FindInFilesMode::project;
                         findInFilesDialog.currentDirectory = ide.project.topNode.path;
-                        
+
                         {
                            char location[MAX_LOCATION];
                            StripLastDirectory(ide.project.topNode.path, location);
                            ChangeProjectFileDialogDirectory(location);
                         }
-                        
-                        /*
-                        if(projectView.debugger)
-                           projectView.debugger.EvaluateWatches();
-                        */
-                        
+
                         break;
                      }
-                     else 
+                     else
                      {
                         if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
                         {
@@ -2220,7 +2352,7 @@ class IDEWorkSpace : Window
                }
                if(prj)
                {
-                  MessageBox { type = ok, parent = parent, master = this, text = $"Same Project", 
+                  MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
                         contents = $"This project is already present in workspace." }.Modal();
                }
                else
@@ -2276,8 +2408,8 @@ class IDEWorkSpace : Window
             !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
       {
          if(FileExists(filePath))
-            document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable, 
-                                       hasVertScroll = true, hasHorzScroll = true, parent = this, state = state, 
+            document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
+                                       hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
                                        visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
                                     };
          if(!document)
@@ -2287,8 +2419,8 @@ class IDEWorkSpace : Window
       else if(!strcmp(extension, "3ds"))
       {
          if(FileExists(filePath))
-            document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable, 
-                                    hasVertScroll = true, hasHorzScroll = true, parent = this, state = state, 
+            document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
+                                    hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
                                     visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
                                     };
 
@@ -2337,10 +2469,10 @@ class IDEWorkSpace : Window
                workspace.UpdateOpenedFileInfo(filePath, opened);
          }
       }
-      
+
       if(!document && createIfFails != no)
       {
-         if(createIfFails != yes && !needFileModified && 
+         if(createIfFails != yes && !needFileModified &&
                MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
             createIfFails = yes;
          if(createIfFails == yes || createIfFails == whatever)
@@ -2369,11 +2501,11 @@ class IDEWorkSpace : Window
             editor.editBox.scroll = scroll;
             editor.openedFileInfo.holdTracking = false;
          }
-         
+
          if(needFileModified)
             document.OnFileModified = OnFileModified;
          document.NotifySaved = DocumentSaved;
-         
+
          if(isProject)
             ideSettings.AddRecentProject(document.fileName);
          else
@@ -2381,7 +2513,7 @@ class IDEWorkSpace : Window
          ide.UpdateRecentMenus();
          ide.AdjustFileMenus();
          settingsContainer.Save();
-         
+
          return document;
       }
       else
@@ -2417,10 +2549,17 @@ class IDEWorkSpace : Window
    }
    */
 
+   void UpdateStateLight(StatusField fld, bool on)
+   {
+      fld.color = on ? lime : Color { 128,128,128 };
+      fld.backColor = on ? dimGray : 0;
+      fld.bold = on;
+   }
+
    bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
    {
-      caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
-      num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
+      UpdateStateLight(caps, app.GetKeyState(capsState));
+      UpdateStateLight(num, app.GetKeyState(numState));
       return true;
    }
 
@@ -2428,15 +2567,19 @@ class IDEWorkSpace : Window
    {
       switch(key)
       {
-         case b:
-            projectView.Update(null);
-            break;
-         case capsLock:
-            caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
-            break;
-         case numLock:
-            num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
-            break;
+         case b: projectView.Update(null); break;
+         case capsLock: UpdateStateLight(caps, app.GetKeyState(capsState)); break;
+         case numLock:  UpdateStateLight(num, app.GetKeyState(numState)); break;
+      }
+      return true;
+   }
+
+   bool OnKeyUp(Key key, unichar ch)
+   {
+      switch(key)
+      {
+         case capsLock: UpdateStateLight(caps, app.GetKeyState(capsState)); break;
+         case numLock:  UpdateStateLight(num, app.GetKeyState(numState)); break;
       }
       return true;
    }
@@ -2449,20 +2592,55 @@ class IDEWorkSpace : Window
 
    void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
    {
+      char *s = null;
       char *path = text;
       char *colon = strchr(text, ':');
       char filePath[MAX_LOCATION] = "";
       char completePath[MAX_LOCATION];
       int line = 0, col = 0;
+      int len = strlen(text);
       Project prj = null;
       FileAttribs fileAttribs;
 
-      if(colon && (colon[1] == '/' || colon[1] == '\\'))
+      // support for valgrind output
+      if((s = strstr(text, "==")) && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
       {
-         path = (colon - 1 > path) ? colon - 1 : path;
-         colon = strstr(colon + 1, ":");
+         colon = s;
+         for(; s>text; s--)
+         {
+            if(*s == '(')
+            {
+               path = s+1;
+               break;
+            }
+         }
+         /*for(s=colon; *s; s++)
+         {
+            if(*s == ')')
+            {
+               *s = '\0';;
+               break;
+            }
+         }*/
+         //*colon = '\0';
+         //line = atoi(colon+1);
+      }
+      // support for "Found n match(es) in "file/path";
+      else if(path[len-1] == '\"' && strstr(path, $"Found %d match%s in \"%s\"%s\n\n"."Found") && strstr(path, $"match") && strstr(path, $"in") && (s = strstr(path, "\"")) && s != path+len-1)
+      {
+         path = s+1;
+      }
+      else
+      {
+         if(colon && (colon[1] == '/' || colon[1] == '\\'))
+         {
+            path = (colon - 1 > path) ? colon - 1 : path;
+            colon = strstr(colon + 1, ":");
+         }
+         if(*path == '*' && (s = strchr(path+1, '*')))
+            path = s+1;
+         while(isspace(*path)) path++;
       }
-      while(isspace(*path)) path++;
       if(*path == '(')
       {
          char * close = strchr(path, ')');
@@ -2519,18 +2697,36 @@ class IDEWorkSpace : Window
 
          if((fileAttribs = FileExists(completePath)))
             CodeLocationGoTo(completePath, fileAttribs, line, col);
-         else
+         else if(ide.workspace)
          {
+            bool done = false;
             for(p : ide.workspace.projects)
             {
                strcpy(completePath, p.topNode.path);
                PathCat(completePath, filePath);
-               if((fileAttribs = FileExists(completePath)))
+               if((fileAttribs = FileExists(completePath)).isFile)
                {
                   CodeLocationGoTo(completePath, fileAttribs, line, col);
+                  done = true;
                   break;
                }
             }
+            if(!done)
+            {
+               for(p : ide.workspace.projects)
+               {
+                  ProjectNode node = p.topNode.Find(filePath, false);
+                  if(node)
+                  {
+                     node.GetFullFilePath(completePath);
+                     if((fileAttribs = FileExists(completePath)).isFile)
+                     {
+                        CodeLocationGoTo(completePath, fileAttribs, line, col);
+                        break;
+                     }
+                  }
+               }
+            }
          }
       }
    }
@@ -2539,33 +2735,29 @@ class IDEWorkSpace : Window
    {
       if(fileAttribs.isFile)
       {
-         CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, "", no, normal, false);
-         if(codeEditor && line)
+         char ext[MAX_EXTENSION];
+         GetExtension(path, ext);
+         if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
+            ShellOpen(path);
+         else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
          {
-            char ext[MAX_EXTENSION];
-            GetExtension(path, ext);
-            if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
-               ShellOpen(path);
-            else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
-            {
-               char dirPath[MAX_LOCATION];
-               StripLastDirectory(path, dirPath);
-               ShellOpen(dirPath);
-            }
-            else
+            char dirPath[MAX_LOCATION];
+            StripLastDirectory(path, dirPath);
+            ShellOpen(dirPath);
+         }
+         else
+         {
+            CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, ext, no, normal, false);
+            if(codeEditor && line)
             {
-               CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, "", no, normal, false);
-               if(codeEditor && line)
-               {
-                  EditBox editBox = codeEditor.editBox;
-                  editBox.GoToLineNum(line - 1);
-                  editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
-               }
+               EditBox editBox = codeEditor.editBox;
+               editBox.GoToLineNum(line - 1);
+               editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
             }
          }
-         else if(fileAttribs.isDirectory)
-            ShellOpen(path);
       }
+      else if(fileAttribs.isDirectory)
+         ShellOpen(path);
    }
 
    void OnRedraw(Surface surface)
@@ -2637,12 +2829,12 @@ class IDEWorkSpace : Window
             SetCurrentContext(codeEditor.globalContext);
             SetTopContext(codeEditor.globalContext);
             SetGlobalContext(codeEditor.globalContext);
-            
+
             SetDefines(&codeEditor.defines);
             SetImports(&codeEditor.imports);
 
             SetActiveDesigner(codeEditor.designer);
-            
+
             sheet.codeEditor = codeEditor;
             toolBox.codeEditor = codeEditor;
 
@@ -2725,22 +2917,25 @@ class IDEWorkSpace : Window
 
             statusBar.AddField(pos);
 
-            caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
+            caps = { width = 40, text = $"CAPS" };
             statusBar.AddField(caps);
+            UpdateStateLight(caps, app.GetKeyState(capsState));
 
-            ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
+            ovr = { width = 36, text = $"OVR" };
             statusBar.AddField(ovr);
+            UpdateStateLight(ovr, (editBox && editBox.overwrite));
 
-            num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
+            num = { width = 36, text = $"NUM" };
             statusBar.AddField(num);
+            UpdateStateLight(num, app.GetKeyState(numState));
 
             //statusBar.text = "Ready";
 
             if(projectView && projectView.project)
             {
                bool isCObject = false;
-               ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
-               if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
+               ProjectNode node = projectView.GetNodeFromWindow(client, null, true, false, null);
+               if(!node && (node = projectView.GetNodeFromWindow(client, null, true, true, null)))
                   isCObject = true;
                if(node)
                {
@@ -2749,7 +2944,7 @@ class IDEWorkSpace : Window
                   if(isCObject)
                      ChangeExtension(node.name, "c", nodeName);
                   sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
-                  projectCompileItem = 
+                  projectCompileItem =
                   {
                      copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
 
@@ -2757,26 +2952,21 @@ class IDEWorkSpace : Window
                      {
                         if(projectView)
                         {
-                           bool result = false;
                            bool isCObject = false;
-                           ProjectNode node = null;
-                           for(p : ide.workspace.projects)
-                           {
-                              node = projectView.GetNodeFromWindow(activeClient, p, false);
-                              if(node) break;
-                           }
-                           if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
-                              isCObject = true;
+                           bool isExcluded = false;
+                           ProjectNode node = projectView.GetNodeForCompilationFromWindow(activeClient, true, &isExcluded, &isCObject);
                            if(node)
                            {
-                              List<ProjectNode> nodes { };
-                              nodes.Add(node);
-                              projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
-                              delete nodes;
-                              result = true;
+                              if(isExcluded)
+                                 ide.outputView.buildBox.Logf($"%s %s is excluded from current build configuration.\n", isCObject ? "Object file" : "File", node.name);
+                              else
+                              {
+                                 List<ProjectNode> nodes { };
+                                 nodes.Add(node);
+                                 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
+                                 delete nodes;
+                              }
                            }
-                           if(!result && node)
-                              ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
                         }
                         return true;
                      }
@@ -2823,21 +3013,15 @@ class IDEWorkSpace : Window
 
       for(c = 1; c<app.argc; c++)
       {
-         if(!strcmp(app.argv[c], "-t"))
-            openAsText = true;
-         else if(!strcmp(app.argv[c], "-no-parsing"))
-            ide.noParsing = true;
-         else if(!strcmp(app.argv[c], "-debug-start"))
-            debugStart = true;
-         else if(!strcmp(app.argv[c], "-debug-work-dir"))
-            debugWorkDir = true;
-         else if(!passThrough && !strcmp(app.argv[c], "-@"))
-            passThrough = true;
-         else if(passThrough)
+         if(passThrough)
          {
+            char * arg = app.argv[c];
+            char * buf = new char[strlen(arg)*2+1];
             if(ptArg++ > 0)
                passArgs.concat(" ");
-            passArgs.concat(app.argv[c]);
+            PassArg(buf, arg);
+            passArgs.concat(buf);
+            delete buf;
          }
          else if(debugWorkDir)
          {
@@ -2845,6 +3029,16 @@ class IDEWorkSpace : Window
             StripQuotes(passDebugWorkDir, passDebugWorkDir);
             debugWorkDir = false;
          }
+         else if(!strcmp(app.argv[c], "-t"))
+            openAsText = true;
+         else if(!strcmp(app.argv[c], "-no-parsing"))
+            ide.noParsing = true;
+         else if(!strcmp(app.argv[c], "-debug-start"))
+            debugStart = true;
+         else if(!strcmp(app.argv[c], "-debug-work-dir"))
+            debugWorkDir = true;
+         else if(!strcmp(app.argv[c], "-@"))
+            passThrough = true;
          else
          {
             char fullPath[MAX_LOCATION];
@@ -2905,49 +3099,8 @@ class IDEWorkSpace : Window
          }
       }
       if(passThrough && projectView && projectView.project && workspace)
-      {
-         char * fixSpacing = new char[Max(passArgs.size * 1.5, 32)];
-         {
-            int c, d = 0;
-            char j = 0;
-            char k = ' ';
-            char l = 0;
-            bool inQuote = false;
-            for(c=0; c<passArgs.size; c++)
-            {
-               l = passArgs[c];
-               if(inQuote && k != '\\' && l == ' ')
-               {
-                  fixSpacing[d++] = '\"';
-                  fixSpacing[d++] = ' ';
-                  inQuote = false;
-               }
-               else if(inQuote && l == '\0')
-               {
-                  fixSpacing[d++] = '\"';
-                  fixSpacing[d++] = '\0';
-                  inQuote = false;
-               }
-               else if(!inQuote && j != '\\' && k == ' ' && l != '-' && l != ' ')
-               {
-                  fixSpacing[d++] = '\"';
-                  fixSpacing[d++] = l;
-                  inQuote = true;
-               }
-               else if(k == '\\' && l == ' ')
-                  fixSpacing[d++] = ' ';
-               else if(k == '\\' && l == '\\')
-                  fixSpacing[d++] = '\\';
-               else if(l != '\\')
-                  fixSpacing[d++] = l;
-               j = k;
-               k = l;
-            }
-            fixSpacing[d] = '\0';
-         }
-         workspace.commandLineArgs = fixSpacing;
-      }
-      if(passDebugWorkDir)
+         workspace.commandLineArgs = passArgs;
+      if(passDebugWorkDir && projectView && projectView.project && workspace)
       {
          workspace.debugDir = passDebugWorkDir;
          delete passDebugWorkDir;
@@ -3107,8 +3260,9 @@ class IDEWorkSpace : Window
       {
          if(!libPathExists[item])  // fstrcmp should be used
          {
-            newLibPaths.Add(item);
-            libPathExists[item] = true;
+            String s = CopyString(item);
+            newLibPaths.Add(s);
+            libPathExists[s] = true;
          }
       }
 
@@ -3125,8 +3279,9 @@ class IDEWorkSpace : Window
       {
          if(!libPathExists[oldPaths[c]])  // fstrcmp should be used
          {
-            newLibPaths.Add(oldPaths[c]);
-            libPathExists[oldPaths[c]] = true;
+            String s = CopyString(oldPaths[c]);
+            newLibPaths.Add(s);
+            libPathExists[s] = true;
          }
       }
 
@@ -3151,6 +3306,7 @@ class IDEWorkSpace : Window
 #endif*/
       delete newList;
 
+      newLibPaths.Free();
       delete newLibPaths;
       delete libPathExists;
 #endif
@@ -3187,29 +3343,29 @@ class IDEWorkSpace : Window
       {
          driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
          driverItems[c].id = c;
-         driverItems[c].isRadio = true;         
+         driverItems[c].isRadio = true;
       }
 */
       driverItems = new MenuItem[2];
 #if defined(__unix__)
          driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
          driverItems[0].id = 0;
-         driverItems[0].isRadio = true;         
+         driverItems[0].isRadio = true;
 #else
          driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
          driverItems[0].id = 0;
-         driverItems[0].isRadio = true;         
+         driverItems[0].isRadio = true;
 #endif
          driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
          driverItems[1].id = 1;
-         driverItems[1].isRadio = true;         
+         driverItems[1].isRadio = true;
 
 /*      skinItems = new MenuItem[app.numSkins];
       for(c = 0; c < app.numSkins; c++)
       {
          skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
          skinItems[c].id = c;
-         skinItems[c].isRadio = true;         
+         skinItems[c].isRadio = true;
       }
 */
       ideFileDialog.master = this;
@@ -3261,6 +3417,12 @@ class IDEWorkSpace : Window
       delete driverItems;
       delete skinItems;
       delete ideSettings;
+      if(documentor)
+      {
+         documentor.Puts("Quit\n");
+         documentor.Wait();
+         delete documentor;
+      }
    }
 }
 
@@ -3441,16 +3603,25 @@ class IDEApp : GuiApplication
 
    bool Init()
    {
+      char ext[MAX_EXTENSION];
       SetLoggingMode(stdOut, null);
       //SetLoggingMode(debug, null);
 
       settingsContainer.Load();
+      if(argc > 1 && !strcmpi(GetExtension(argv[1], ext), "3ds"))
+      {
+         app.driver = "OpenGL";
+         ide.driverItems[1].checked = true;
+      }
+      else
+      {
 #if defined(__unix__) || defined(__APPLE__)
-      app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
+         app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
 #else
-      app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
+         app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
 #endif
-      ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
+         ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
+      }
 
       SetInIDE(true);
 
@@ -3472,6 +3643,33 @@ class IDEApp : GuiApplication
       return true;
    }
 
+   bool Cycle(bool idle)
+   {
+      if(ide.documentor)
+      {
+         if(ide.documentor.Peek())
+         {
+            char line[1024];
+            ide.documentor.GetLine(line, sizeof(line));
+            if(!strcmpi(line, "Exited"))
+            {
+               ide.documentor.CloseInput();
+               ide.documentor.CloseOutput();
+               ide.documentor.Wait();
+               delete ide.documentor;
+            }
+         }
+         if(ide.documentor && ide.documentor.eof)
+         {
+            ide.documentor.CloseInput();
+            ide.documentor.CloseOutput();
+            ide.documentor.Wait();
+            delete ide.documentor;
+         }
+      }
+      return true;
+   }
+
    bool LoadIncludeFile()
    {
       bool result = false;