ide; added secret ctrl+shift hotkey for disabling parsing of source code when opening...
authorRejean Loyer <rejean.loyer@gmail.com>
Wed, 17 Apr 2013 03:36:31 +0000 (23:36 -0400)
committerRejean Loyer <rejean.loyer@gmail.com>
Mon, 20 May 2013 18:53:24 +0000 (14:53 -0400)
ide/src/debugger/Debugger.ec
ide/src/designer/CodeEditor.ec
ide/src/dialogs/NodeProperties.ec
ide/src/ide.ec
ide/src/panels/OutputView.ec
ide/src/project/ProjectView.ec

index e1d9811..cfd850d 100644 (file)
@@ -687,7 +687,7 @@ class Debugger
       codloc = CodeLocation::ParseCodeLocation(location);
       if(codloc)
       {
-         CodeEditor editor = (CodeEditor)ide.OpenFile(codloc.absoluteFile, normal, true, null, no, normal);
+         CodeEditor editor = (CodeEditor)ide.OpenFile(codloc.absoluteFile, normal, true, null, no, normal, false);
          if(editor)
          {
             EditBox editBox = editor.editBox;
@@ -732,7 +732,7 @@ class Debugger
                }
             }
             if(frame.absoluteFile)
-               editor = (CodeEditor)ide.OpenFile(frame.absoluteFile, normal, true, null, no, normal);
+               editor = (CodeEditor)ide.OpenFile(frame.absoluteFile, normal, true, null, no, normal, false);
             ide.Update(null);
             if(editor && frame.line)
             {
@@ -2082,14 +2082,14 @@ class Debugger
       
       strcpy(path, ide.workspace.projectDir);
       PathCat(path, tempPath);
-      codeEditor = (CodeEditor)ide.OpenFile(path, Normal, false, null, no);
+      codeEditor = (CodeEditor)ide.OpenFile(path, Normal, false, null, no, normal, false);
       if(!codeEditor)
       {
          for(srcDir : ide.workspace.sourceDirs)
          {
             strcpy(path, srcDir);
             PathCat(path, tempPath);
-            codeEditor = (CodeEditor)ide.OpenFile(path, Normal, false, null, no);
+            codeEditor = (CodeEditor)ide.OpenFile(path, Normal, false, null, no, normal, false);
             if(codeEditor) break;
          }
       }
@@ -2100,7 +2100,7 @@ class Debugger
       if(!activeFrame || !activeFrame.absoluteFile)
          codeEditor = null;
       else
-         codeEditor = (CodeEditor)ide.OpenFile(activeFrame.absoluteFile, normal, false, null, no, normal);
+         codeEditor = (CodeEditor)ide.OpenFile(activeFrame.absoluteFile, normal, false, null, no, normal, false);
       if(codeEditor)
       {
          codeEditor.inUseDebug = true;
index d4eb6a4..98077bf 100644 (file)
@@ -683,6 +683,10 @@ class CodeEditor : Window
 
    Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
 
+   bool noParsing;
+
+   property bool parsing { get { return !noParsing && !ide.noParsing; } };
+
    void ProcessCaretMove(EditBox editBox, int line, int charPos)
    {
       char temp[512];
@@ -2360,7 +2364,7 @@ class CodeEditor : Window
       if(fileName)
       {
          GetExtension(fileName, ext);
-         if(!strcmpi(ext, "ec"))
+         if(parsing && !strcmpi(ext, "ec"))
          {
             codeModified = true;
             EnsureUpToDate();
@@ -4396,6 +4400,7 @@ class CodeEditor : Window
    void UpdateFormCode()
    {
       if(!this) return;
+      if(!parsing) return;
          
       updatingCode++;
       if(codeModified)
@@ -5357,7 +5362,7 @@ class CodeEditor : Window
 
    void EnsureUpToDate()
    {
-      if(sheet && codeModified)
+      if(sheet && codeModified && parsing)
          ParseCode();
    }
 
@@ -6264,6 +6269,7 @@ class CodeEditor : Window
       Expression memberExp = null;
       Identifier realIdentifier = null;
 
+      if(!parsing) return true;
       if(!privateModule) return !didOverride;
 
       insideFunction = null;
@@ -6638,6 +6644,8 @@ class CodeEditor : Window
       EditLine l1, l2;
       int x1,y1, x2,y2;
 
+      if(!parsing) return;
+
       charPos = editBox.charPos + 1;
       EnsureUpToDate();
 
index 90bf2bd..5cd4bd6 100644 (file)
@@ -171,10 +171,10 @@ class NodeProperties : Window
 
    bool OnKeyDown(Key key, unichar ch)
    {
-      if(key == escape || (SmartKey)key == enter)
+      if(key == escape || key.code == enter || key.code == keyPadEnter)
       {
          StopEditing();
-         if((SmartKey)key == enter)
+         if(key.code == enter || key.code == keyPadEnter)
          {
             if(mode == newFile)
             {
@@ -182,7 +182,7 @@ class NodeProperties : Window
                Window document;
                node.GetFullFilePath(filePath);
                if(FileExists(filePath))
-                  ide.projectView.OpenNode(node);
+                  ide.projectView.OpenNode(node, key.ctrl && key.shift);
                else
                {
                   document = (Window)NewCodeEditor(ide, normal, false);
index b196138..ff0d84d 100644 (file)
@@ -439,9 +439,9 @@ class IDEWorkSpace : Window
    {
       parent = this;
 
-      void OnGotoError(char * line)
+      void OnGotoError(char * line, bool noParsing)
       {
-         ide.GoToError(line);
+         ide.GoToError(line, noParsing);
       }
 
       void OnCodeLocationParseAndGoTo(char * line)
@@ -706,7 +706,7 @@ class IDEWorkSpace : Window
 
                   for(c = 0; c < numSelections; c++)
                   {
-                     if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal))
+                     if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift))
                         gotWhatWeWant = true;
                   }
                   if(gotWhatWeWant ||
@@ -810,7 +810,7 @@ class IDEWorkSpace : Window
                   delete command;
                }
                else
-                  OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal);
+                  OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal, mods.ctrl && mods.shift);
                break;
             }
             id++;
@@ -832,7 +832,7 @@ class IDEWorkSpace : Window
                   delete command;
                }
                else
-                  OpenFile(file, normal, true, null, no, normal);
+                  OpenFile(file, normal, true, null, no, normal, mods.ctrl && mods.shift);
                break;
             }
             id++;
@@ -885,7 +885,7 @@ class IDEWorkSpace : Window
             ideProjectFileDialog.text = openProjectFileDialogTitle;
             if(ideProjectFileDialog.Modal() == ok)
             {
-               OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal);
+               OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift);
                //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
             }
             return true;
@@ -916,7 +916,7 @@ class IDEWorkSpace : Window
             {
                if(ideProjectFileDialog.Modal() == ok)
                {
-                  if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add))
+                  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", 
                         contents = $"Add a different project?" }.Modal() == no)
@@ -1440,6 +1440,8 @@ class IDEWorkSpace : Window
       filter = 1;
    };
 
+   bool noParsing;
+
 #ifdef GDB_DEBUG_GUI
    GDBDialog gdbDialog
    {
@@ -1620,6 +1622,7 @@ class IDEWorkSpace : Window
       if(MessageBox { type = yesNo, master = this/*.parent*/,
             text = $"Document has been modified", contents = temp }.Modal() == yes)
       {
+         bool noParsing = (this._class == class(CodeEditor) && ((CodeEditor)this).noParsing) ? true : false;
          char * fileName = CopyString(this.fileName);
          WindowState state = this.state;
          Anchor anchor = this.anchor;
@@ -1627,7 +1630,7 @@ class IDEWorkSpace : Window
 
          this.modifiedDocument = false;
          this.Destroy(0);
-         this = ide.OpenFile(fileName, normal, true, null, no, normal);
+         this = ide.OpenFile(fileName, normal, true, null, no, normal, noParsing);
          if(this)
          {
             this.anchor = anchor;
@@ -1982,7 +1985,7 @@ class IDEWorkSpace : Window
       return false;
    }
 
-   Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod)
+   Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
    {
       char extension[MAX_EXTENSION] = "";
       Window document = null;
@@ -2090,7 +2093,7 @@ class IDEWorkSpace : Window
                         {
                            if(ofi.state != closed)
                            {
-                              Window file = OpenFile(ofi.path, normal, true, null, no, normal);
+                              Window file = OpenFile(ofi.path, normal, true, null, no, normal, noParsing);
                               if(file)
                               {
                                  char fileName[MAX_LOCATION];
@@ -2225,7 +2228,7 @@ class IDEWorkSpace : Window
             !strcmp(extension, "css") || !strcmp(extension, "php") ||
             !strcmp(extension, "js"))
       {
-         CodeEditor editor { parent = this, state = state, visible = false };
+         CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
          editor.updatingCode = true;
          if(editor.LoadFile(filePath))
          {
@@ -2238,7 +2241,7 @@ class IDEWorkSpace : Window
       }
       else
       {
-         CodeEditor editor { parent = this, state = state, visible = false };
+         CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
          if(editor.LoadFile(filePath))
          {
             document = editor;
@@ -2364,10 +2367,10 @@ class IDEWorkSpace : Window
       return true;
    }
 
-   void GoToError(const char * line)
+   void GoToError(const char * line, bool noParsing)
    {
       if(projectView)
-         projectView.GoToError(line);
+         projectView.GoToError(line, noParsing);
    }
 
    void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
@@ -2441,7 +2444,7 @@ class IDEWorkSpace : Window
       fileAttribs = FileExists(completePath);
       if(fileAttribs.isFile)
       {
-         CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal);
+         CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal, false);
          if(codeEditor && line)
          {
             EditBox editBox = codeEditor.editBox;
@@ -2613,7 +2616,7 @@ class IDEWorkSpace : Window
             caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
             statusBar.AddField(caps);
 
-            ovr = { width = 30, text = $"OVR", color = editBox.overwrite ? black : Color { 128, 128, 128 } };
+            ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
             statusBar.AddField(ovr);
 
             num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
@@ -2708,6 +2711,8 @@ class IDEWorkSpace : Window
       {
          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"))
@@ -2785,10 +2790,10 @@ class IDEWorkSpace : Window
                   break;
                }
                else
-                  ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal);
+                  ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
             }
             else if(strstr(fullPath, "http://") == fullPath)
-               ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal);
+               ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
          }
       }
       if(passThrough && projectView && projectView.project && workspace)
@@ -3201,7 +3206,7 @@ class IDEApp : GuiApplication
          char fullPath[MAX_LOCATION];
          GetWorkingDir(fullPath, MAX_LOCATION);
          PathCat(fullPath, app.argv[c]);
-         ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
+         ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
       }
       */
 
index e057692..95775d8 100644 (file)
@@ -21,7 +21,7 @@ class OutputView : Window
    size.h = 240;
    background = formColor;
 
-   virtual void OnGotoError(char * line);
+   virtual void OnGotoError(char * line, bool noParsing);
    virtual void OnCodeLocationParseAndGoTo(char * line);
 
    FindDialog findDialog { master = this, editBox = buildBox, isModal = true, autoCreate = false, text = "Find" };
@@ -128,15 +128,15 @@ class OutputView : Window
       
       bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
       {
-         OnGotoError(editBox.line.text);
+         OnGotoError(editBox.line.text, mods.ctrl && mods.shift);
          return false; //true; // why not use true here? 
       }
 
       bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
       {
-         if((SmartKey)key == enter)
+         if(key.code == enter || key.code == keyPadEnter)
          {
-            OnGotoError(editBox.line.text);
+            OnGotoError(editBox.line.text, key.ctrl && key.shift);
             return false;
          }
          return true;
index 0e40ec3..77eb3bf 100755 (executable)
@@ -200,7 +200,7 @@ class ProjectView : Window
       bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
       {
          // Prevent the double click from reactivating the project view (returns false if we opened something)
-         return !OpenSelectedNodes();
+         return !OpenSelectedNodes(mods.ctrl && mods.shift);
       }
 
       bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
@@ -437,8 +437,10 @@ class ProjectView : Window
          }
          switch(key)
          {
-            case enter: case keyPadEnter:  OpenSelectedNodes();   break;
-            case del:                      RemoveSelectedNodes(); break;
+            case Key { enter, true, true }:        OpenSelectedNodes(true);   break;
+            case Key { keyPadEnter, true, true }:  OpenSelectedNodes(true);   break;
+            case enter: case keyPadEnter:          OpenSelectedNodes(false);  break;
+            case del:                              RemoveSelectedNodes();     break;
             case escape:                      
             {
                Window activeClient = ide.activeClient;
@@ -1252,7 +1254,7 @@ class ProjectView : Window
 
    bool FileOpenFile(MenuItem selection, Modifiers mods)
    {
-      OpenSelectedNodes();
+      OpenSelectedNodes(mods.ctrl && mods.shift);
       return true;
    }
 
@@ -1503,7 +1505,7 @@ class ProjectView : Window
       return result;      
    }
 
-   void GoToError(const char * line)
+   void GoToError(const char * line, const bool noParsing)
    {
       char * colon;
       
@@ -1606,12 +1608,12 @@ class ProjectView : Window
                strcpy(filePath, project.topNode.path);
                PathCatSlash(filePath, moduleName);
       
-               codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
+               codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
                if(!codeEditor && !strcmp(ext, "c"))
                {
                   char ecName[MAX_LOCATION];
                   ChangeExtension(filePath, "ec", ecName);
-                  codeEditor = (CodeEditor)ide.OpenFile(ecName, normal, true, null, no, normal);
+                  codeEditor = (CodeEditor)ide.OpenFile(ecName, normal, true, null, no, normal, noParsing);
                }
                if(!codeEditor)
                {
@@ -1629,7 +1631,7 @@ class ProjectView : Window
                            strcpy(filePath, prj.topNode.path);
                            PathCatSlash(filePath, node.path);
                            PathCatSlash(filePath, node.name);
-                           codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
+                           codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
                            if(codeEditor)
                               break;
                         }
@@ -1644,7 +1646,7 @@ class ProjectView : Window
                               strcpy(filePath, prj.topNode.path);
                               PathCatSlash(filePath, node.path);
                               PathCatSlash(filePath, node.name);
-                              codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
+                              codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
                               if(codeEditor)
                                  break;
                            }
@@ -1663,11 +1665,11 @@ class ProjectView : Window
       }
    }
 
-   bool OpenNode(ProjectNode node)
+   bool OpenNode(ProjectNode node, bool noParsing)
    {
       char filePath[MAX_LOCATION];
       node.GetFullFilePath(filePath);
-      return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
+      return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal, noParsing) ? true : false;
    }
 
    void AddNode(ProjectNode node, DataRow addTo)
@@ -2064,7 +2066,7 @@ class ProjectView : Window
             subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
             if(designerClass)
             {
-               codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
+               codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal, false);
                strcpy(name, projectNode.name);
                sprintf(name, "%s%d", upper, c);
                if(className)
@@ -2080,7 +2082,7 @@ class ProjectView : Window
          }
          else // TODO: fix no symbols generated when ommiting {} for following else
          {
-            codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
+            codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal, false);
          }
          if(codeEditor)
          {
@@ -2093,7 +2095,7 @@ class ProjectView : Window
    }
 
    // Returns true if we opened something
-   bool OpenSelectedNodes()
+   bool OpenSelectedNodes(bool noParsing)
    {
       bool result = false;
       OldList selection;
@@ -2106,7 +2108,7 @@ class ProjectView : Window
          ProjectNode node = (ProjectNode)row.tag;
          if(node.type == file)
          {
-            OpenNode(node);
+            OpenNode(node, noParsing);
             result = true;
             break;
          }