bunch of changes, unfortunate lack of commits
[ede] / libede / src / FileSystemSearch.ec
index cb003f4..53b6da8 100644 (file)
@@ -37,6 +37,9 @@ public:
 
    Window owner;
    FileSystemBox fsb;
 
    Window owner;
    FileSystemBox fsb;
+   FileSystemBox tree;
+
+   FileSystemNode messageNode;
 
    FileSystemSearch()
    {
 
    FileSystemSearch()
    {
@@ -49,6 +52,15 @@ public:
    virtual bool Window::NotifySearchSortBrowser(FileSystemSearch search);
    virtual bool Window::NotifySearchTerminated(FileSystemSearch search);
 
    virtual bool Window::NotifySearchSortBrowser(FileSystemSearch search);
    virtual bool Window::NotifySearchTerminated(FileSystemSearch search);
 
+   void InitResults()
+   {
+      fsb.Clear();
+      //CreateMessageNode();
+      //messageNode.label = "No results yet!";
+   }
+
+
+
    bool SearchFileContent(String path)
    {
       bool match = false;
    bool SearchFileContent(String path)
    {
       bool match = false;
@@ -162,30 +174,51 @@ public:
       strcpy(stack[0].path, location);
       stack[0].listing = FileListing { stack[0].path };  // there should be a sorted = true/false 
 
       strcpy(stack[0].path, location);
       stack[0].listing = FileListing { stack[0].path };  // there should be a sorted = true/false 
 
-      fsb.list.Clear();
+      //fsb.list.Clear();
                                                          // Binary Search sorting...
       if(optionTree)
          stack[0].branched = false;
                                                          // Binary Search sorting...
       if(optionTree)
          stack[0].branched = false;
-      /*if(optionBrowser)
+      if(optionBrowser)
       {
          guiApp.Lock();
          {
             //stack[0].browse = searchPanel.AddBrowserRow();
       {
          guiApp.Lock();
          {
             //stack[0].browse = searchPanel.AddBrowserRow();
-            //node = MakeFileSystemNode(attribs, stack[0].path,
+            //DeleteMessageNode();
+            //node = MakeFileSystemNode(attribs, stack[0].path, true,
             //      stack[0].path, fsb.bits.previewPictures, fsb.displaySystem);
             //stack[0].browse.SetData(browserNameField, node);
             //stack[0].browse.SetData(typeField, null);
             //stack[0].browse.SetData(sizeField, null);
 
             //      stack[0].path, fsb.bits.previewPictures, fsb.displaySystem);
             //stack[0].browse.SetData(browserNameField, node);
             //stack[0].browse.SetData(typeField, null);
             //stack[0].browse.SetData(sizeField, null);
 
-            stack[0].browse = MakeFileSystemNode(stats, stack[0].path, stack[0].path,
-                  fsb.bits.previewPictures, fsb.displaySystem);
-            fsb.AddTreeNode(stack[0].browse, true, false, null); // TEMPORARY // searchPanel.AddBrowse(stack[0].browse, null);
+            //DeleteMessageNode();
+            tree.Clear();
+            stack[0].browse = MakeFileSystemNode(stats, stack[0].path, stack[0].path, false,
+                  tree.bits.previewPictures, tree.displaySystem);
+            tree.AddTreeNode(stack[0].browse, false, true, null); // TEMPORARY // searchPanel.AddBrowse(stack[0].browse, null);
          }
          guiApp.Unlock();
          }
          guiApp.Unlock();
-      }*/
+      }
       
       for(frame = 0; frame >= 0 && !terminate; )
       {
       
       for(frame = 0; frame >= 0 && !terminate; )
       {
+         guiApp.Lock();
+         {
+            double thisTime = GetTime();
+            if(thisTime - lastTime > 0.25)
+            {
+               NotifyUpdateSearchLocation(owner, this, stack[frame].listing.path); // TEMPORARY // searchPanel.SearchUpdateLabel(stack[frame].listing.path);
+               //if(!messageNode)
+               //   CreateMessageNode();
+               //delete messageNode.label;
+               //messageNode.label = PrintString("Searching '", stack[frame].listing.path, "'...");
+               //messageNode.EnsureVisible(false);
+               //fsb.Select(messageNode);
+               //fsb.Update(null);
+               //guiApp.UpdateDisplay();
+               lastTime = thisTime;
+            }
+         }
+         guiApp.Unlock();
          if(stack[frame].listing.Find())
          {
             count++;
          if(stack[frame].listing.Find())
          {
             count++;
@@ -215,15 +248,17 @@ public:
                         guiApp.Lock();
                            if(frame)
                            {
                         guiApp.Lock();
                            if(frame)
                            {
+                              DeleteMessageNode();
                               stack[frame].result = MakeFileSystemNode(stack[frame - 1].listing.stats,
                               stack[frame].result = MakeFileSystemNode(stack[frame - 1].listing.stats,
-                                    stack[frame - 1].listing.name, stack[frame - 1].path,
+                                    stack[frame - 1].listing.name, stack[frame - 1].path, true,
                                     fsb.bits.previewPictures, fsb.displaySystem);
                               fsb.AddTreeNode(stack[frame].result, true, false, stack[frame - 1].result); // TEMPORARY // searchPanel.AddResult(stack[frame].result, stack[frame - 1].result);
                               stack[frame].result.row.collapsed = false;
                            }
                            else
                            {
                                     fsb.bits.previewPictures, fsb.displaySystem);
                               fsb.AddTreeNode(stack[frame].result, true, false, stack[frame - 1].result); // TEMPORARY // searchPanel.AddResult(stack[frame].result, stack[frame - 1].result);
                               stack[frame].result.row.collapsed = false;
                            }
                            else
                            {
-                              stack[0].result = MakeFileSystemNode(stats, stack[0].path, stack[0].path,
+                              DeleteMessageNode();
+                              stack[0].result = MakeFileSystemNode(stats, stack[0].path, stack[0].path, true,
                                     fsb.bits.previewPictures, fsb.displaySystem);
                               fsb.AddTreeNode(stack[0].result, true, false, null); // TEMPORARY // searchPanel.AddResult(stack[0].result, null);
                               stack[0].result.row.collapsed = false;
                                     fsb.bits.previewPictures, fsb.displaySystem);
                               fsb.AddTreeNode(stack[0].result, true, false, null); // TEMPORARY // searchPanel.AddResult(stack[0].result, null);
                               stack[0].result.row.collapsed = false;
@@ -238,21 +273,29 @@ public:
             }
             if(optionSubdirs && stack[frame].listing.stats.attribs.isDirectory)
             {
             }
             if(optionSubdirs && stack[frame].listing.stats.attribs.isDirectory)
             {
-               guiApp.Lock();
+               /*guiApp.Lock();
                   {
                      double thisTime = GetTime();
                      if(thisTime - lastTime > 0.25)
                      {
                         NotifyUpdateSearchLocation(owner, this, stack[stackTop].listing.path); // TEMPORARY // searchPanel.SearchUpdateLabel(stack[stackTop].listing.path);
                   {
                      double thisTime = GetTime();
                      if(thisTime - lastTime > 0.25)
                      {
                         NotifyUpdateSearchLocation(owner, this, stack[stackTop].listing.path); // TEMPORARY // searchPanel.SearchUpdateLabel(stack[stackTop].listing.path);
+                        if(!messageNode)
+                           CreateMessageNode();
+                        //delete messageNode.label;
+                        messageNode.label = PrintString("Searching '", stack[stackTop].listing.path, "'...");
+                        messageNode.EnsureVisible(false);
+                        fsb.Update(null);
+                        guiApp.UpdateDisplay();
                         lastTime = thisTime;
                      }
                   }
                         lastTime = thisTime;
                      }
                   }
-                  //searchPanel.SearchUpdateLabel(stack[stackTop].listing.path);
+                  //searchPanel.SearchUpdateLabel(stack[stackTop].listing.path);*/
                   frame++;
                   frame++;
-                  /*if(optionBrowser)
+               /*   /-*if(optionBrowser)
                   {
                   {
+                     DeleteMessageNode();
                      stack[frame].browse = MakeFileSystemNode(stack[stackTop].listing.stats,
                      stack[frame].browse = MakeFileSystemNode(stack[stackTop].listing.stats,
-                           stack[stackTop].listing.name, stack[stackTop].path,
+                           stack[stackTop].listing.name, stack[stackTop].path, true,
                            fsb.bits.previewPictures, fsb.displaySystem);
                      fsb.AddTreeNode(stack[frame].browse, true, false, stack[stackTop].browse); // TEMPORARY // searchPanel.AddBrowse(stack[frame].browse, stack[stackTop].browse);
 
                            fsb.bits.previewPictures, fsb.displaySystem);
                      fsb.AddTreeNode(stack[frame].browse, true, false, stack[stackTop].browse); // TEMPORARY // searchPanel.AddBrowse(stack[frame].browse, stack[stackTop].browse);
 
@@ -262,8 +305,8 @@ public:
                         //searchPanel.SortBrowser();  // this can be very bad for performance in some situations
                                                 // there should be a way to sort the nodes as they are added
                                                 // BinarySearch sorting implementation in listBox's Sort?
                         //searchPanel.SortBrowser();  // this can be very bad for performance in some situations
                                                 // there should be a way to sort the nodes as they are added
                                                 // BinarySearch sorting implementation in listBox's Sort?
-                  }*/
-               guiApp.Unlock();
+                  }*-/
+               guiApp.Unlock();*/
                strcpy(stack[frame].path, stack[stackTop].listing.path);
                stack[frame].listing = FileListing { stack[frame].path };
                if(optionTree)
                strcpy(stack[frame].path, stack[stackTop].listing.path);
                stack[frame].listing = FileListing { stack[frame].path };
                if(optionTree)
@@ -271,8 +314,9 @@ public:
                if(match)
                {
                   guiApp.Lock();
                if(match)
                {
                   guiApp.Lock();
+                     DeleteMessageNode();
                      stack[frame].result = MakeFileSystemNode(stack[stackTop].listing.stats,
                      stack[frame].result = MakeFileSystemNode(stack[stackTop].listing.stats,
-                           stack[stackTop].listing.name, stack[stackTop].path,
+                           stack[stackTop].listing.name, stack[stackTop].path, true,
                            fsb.bits.previewPictures, fsb.displaySystem);
                      if(optionTree)
                      {
                            fsb.bits.previewPictures, fsb.displaySystem);
                      if(optionTree)
                      {
@@ -297,8 +341,9 @@ public:
                   /*if(optionBrowser)
                   {
                      FileSystemNode item;
                   /*if(optionBrowser)
                   {
                      FileSystemNode item;
+                     DeleteMessageNode();
                      item = MakeFileSystemNode(stack[frame].listing.stats,
                      item = MakeFileSystemNode(stack[frame].listing.stats,
-                           stack[frame].listing.name, stack[frame].path,
+                           stack[frame].listing.name, stack[frame].path, true,
                            fsb.bits.previewPictures, fsb.displaySystem);
                      fsb.AddTreeNode(item, true, false, stack[frame].browse); // TEMPORARY // searchPanel.AddBrowse(item, stack[frame].browse);
                      //if(frame == 1)
                            fsb.bits.previewPictures, fsb.displaySystem);
                      fsb.AddTreeNode(item, true, false, stack[frame].browse); // TEMPORARY // searchPanel.AddBrowse(item, stack[frame].browse);
                      //if(frame == 1)
@@ -309,8 +354,9 @@ public:
                   if(match)
                   {
                      FileSystemNode item;
                   if(match)
                   {
                      FileSystemNode item;
+                     DeleteMessageNode();
                      item = MakeFileSystemNode(stack[frame].listing.stats,
                      item = MakeFileSystemNode(stack[frame].listing.stats,
-                           stack[frame].listing.name, stack[frame].path,
+                           stack[frame].listing.name, stack[frame].path, true,
                            fsb.bits.previewPictures, fsb.displaySystem);
                      if(optionTree)
                      {
                            fsb.bits.previewPictures, fsb.displaySystem);
                      if(optionTree)
                      {
@@ -327,7 +373,7 @@ public:
                            sprintf(temp, "lines %d", lin.num);
                            for(lin = lin.next; lin && strlen(temp) < MAX_F_STRING; lin = lin.next)
                               strcatf(temp, ", %d", lin.num);
                            sprintf(temp, "lines %d", lin.num);
                            for(lin = lin.next; lin && strlen(temp) < MAX_F_STRING; lin = lin.next)
                               strcatf(temp, ", %d", lin.num);
-                           node = FileSystemNode { name = CopyString(temp), type = lineNumbers };
+                           node = FileSystemNode { name = temp/*CopyString(temp)*/, type = lineNumbers };
                            fsb.AddTreeNode(node, true, false, item); // TEMPORARY // searchPanel.AddResult(node, item);
                            //row.AddRow().SetData(resultsNameField, node);
                            lines.Free(null);
                            fsb.AddTreeNode(node, true, false, item); // TEMPORARY // searchPanel.AddResult(node, item);
                            //row.AddRow().SetData(resultsNameField, node);
                            lines.Free(null);
@@ -365,7 +411,25 @@ public:
 
       guiApp.Lock();
       NotifySearchTerminated(owner, this); // TEMPORARY // searchPanel.SearchTerminate();
 
       guiApp.Lock();
       NotifySearchTerminated(owner, this); // TEMPORARY // searchPanel.SearchTerminate();
+      //delete messageNode.label;
+      //messageNode.label = PrintString("Searching '", stack[stackTop].listing.path, "'...");
+      //delete the messageNode;
+      //fsb.Update(null);
       guiApp.Unlock();
       return 0;
    }
       guiApp.Unlock();
       return 0;
    }
+
+private:
+   void CreateMessageNode()
+   {
+      //messageNode = MakeFileSystemNode({ }, " ", " ", false, false, fsb.displaySystem);
+      //messageNode.type = normalFile;
+      //fsb.AddNode(messageNode);
+   }
+   void DeleteMessageNode()
+   {
+      //if(messageNode)
+      //   fsb.DeleteNode(messageNode);
+      //messageNode = null;
+   }
 }
 }