ide; (#1037) fix f7/ctrlF7 compilation selecting wrong file/project when file exclusi...
[sdk] / ide / src / ide.ec
index 518179c..ff94368 100644 (file)
@@ -211,7 +211,7 @@ class IDEToolbar : ToolBar
 
    /* Edit options */
    // Cut
-   // Copy 
+   // Copy
    // Paste
    // Undo
    // Redo
@@ -420,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;
@@ -443,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:
             {
@@ -482,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);
@@ -591,7 +565,7 @@ class IDEWorkSpace : Window
          }
       }
    };
-   
+
    WatchesView watchesView { parent = this };
    ThreadsView threadsView
    {
@@ -674,7 +648,7 @@ 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)
@@ -809,7 +783,7 @@ class IDEWorkSpace : Window
       }
 
    MenuPlacement editMenu { menu, $"Edit", e };
-   
+
    Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
       MenuItem projectNewItem
       {
@@ -886,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;
@@ -1221,6 +1195,7 @@ class IDEWorkSpace : Window
       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);
@@ -1603,7 +1578,7 @@ class IDEWorkSpace : Window
       }
    };
 #endif
-   
+
    bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
    {
       //app.driver = app.drivers[selection.id];
@@ -1651,12 +1626,12 @@ class IDEWorkSpace : Window
       {
          this;
          fileName = fileName;
-         
+
          void NotifyDestroyed(Window window, DialogResult result)
          {
             projectView = null;
             text = titleECEREIDE;
-            
+
             AdjustMenus();
          }
       };
@@ -1716,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;
@@ -1734,7 +1709,7 @@ class IDEWorkSpace : Window
             }
             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;
             }
@@ -1749,7 +1724,7 @@ class IDEWorkSpace : Window
       if(activeClient)
          activeClient.Activate();
       else if(projectView)
-      { 
+      {
          projectView.visible = true;
          projectView.Activate();
       }
@@ -2169,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)
          {
@@ -2239,7 +2214,7 @@ class IDEWorkSpace : Window
                   {
                      Project project;
                      Workspace workspace = null;
-                     
+
                      if(FileExists(filePath))
                      {
                         if(!strcmp(extension, ProjectExtension))
@@ -2332,21 +2307,16 @@ class IDEWorkSpace : Window
 
                         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)
                         {
@@ -2382,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
@@ -2438,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)
@@ -2449,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*/
                                     };
 
@@ -2499,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)
@@ -2531,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
@@ -2543,7 +2513,7 @@ class IDEWorkSpace : Window
          ide.UpdateRecentMenus();
          ide.AdjustFileMenus();
          settingsContainer.Save();
-         
+
          return document;
       }
       else
@@ -2848,12 +2818,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;
 
@@ -2950,8 +2920,8 @@ class IDEWorkSpace : Window
             if(projectView && projectView.project)
             {
                bool isCObject = false;
-               ProjectNode node = projectView.GetNodeFromWindow(client, null, false, false);
-               if(!node && (node = projectView.GetNodeFromWindow(client, null, false, true)))
+               ProjectNode node = projectView.GetNodeFromWindow(client, null, true, false, null);
+               if(!node && (node = projectView.GetNodeFromWindow(client, null, true, true, null)))
                   isCObject = true;
                if(node)
                {
@@ -2960,7 +2930,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;
 
@@ -2968,26 +2938,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, true, false);
-                              if(node) break;
-                           }
-                           if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true, 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;
                      }
@@ -3364,29 +3329,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;