[Aptitude-svn-commit] r3890 - in branches/aptitude-0.3/aptitude: . src/vscreen

Daniel Burrows dburrows at costa.debian.org
Wed Aug 17 17:01:22 UTC 2005


Author: dburrows
Date: Wed Aug 17 17:01:19 2005
New Revision: 3890

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.cc
   branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.h
Log:
Add widget support (untested) for reverse searching.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Wed Aug 17 17:01:19 2005
@@ -1,5 +1,9 @@
 2005-08-17  Daniel Burrows  <dburrows at debian.org>
 
+	* src/vscreen/vs_tree.cc, src/vscreen/vs_tree.h:
+
+	  Add widget support (untested) for reverse searching.
+
 	* src/solution_screen.cc:
 
 	  Use the fragment subsystem to add text attributes to the story.

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.cc	Wed Aug 17 17:01:19 2005
@@ -729,9 +729,7 @@
     beep();
   else
     {
-      selected->unhighlighted(this);
       set_selection(curr);
-      selected->highlighted(this);
       while(!curr.is_root())
 	{
 	  curr=curr.get_up();
@@ -741,6 +739,85 @@
     }
 }
 
+void vs_tree::search_back_for(vs_tree_search_func &matches)
+{
+  vs_treeiterator curr((selected == vs_treeiterator(NULL))
+		       ? begin : selected, hierarchical),
+    start(curr);
+
+  // Skip the starting location, cycling to the end.
+  if(curr != begin)
+    {
+      if(hierarchical)
+	--curr;
+      else
+	curr.move_backward_level();
+    }
+  else
+    {
+      if(hierarchical)
+	{
+	  curr = end;
+	  --curr;
+	}
+      else
+	{
+	  vs_treeiterator curr2 = curr;
+	  curr2.move_forward_level();
+
+	  while(curr2 != curr)
+	    {
+	      curr = curr2;
+	      curr2.move_forward_level();
+	    }
+	}
+    }
+
+  while(curr != start && !matches(*curr))
+    {
+      // Code duplication alert
+      if(curr != begin)
+	{
+	  if(hierarchical)
+	    --curr;
+	  else
+	    curr.move_backward_level();
+	}
+      else
+	{
+	  if(hierarchical)
+	    {
+	      curr = end;
+	      --curr;
+	    }
+	  else
+	    {
+	      vs_treeiterator curr2 = curr;
+	      curr2.move_forward_level();
+
+	      while(curr2 != curr)
+		{
+		  curr = curr2;
+		  curr2.move_forward_level();
+		}
+	    }
+	}
+    }
+
+  if(curr == start)
+    beep();
+  else
+    {
+      set_selection(curr);
+      while(!curr.is_root())
+	{
+	  curr = curr.get_up();
+	  curr.expand();
+	}
+      vscreen_update();
+    }
+}
+
 void vs_tree::paint(const style &st)
 {
   int width,height;

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.h	Wed Aug 17 17:01:19 2005
@@ -156,6 +156,13 @@
     search_for(matches);
   }
 
+  void search_back_for(vs_tree_search_func &matches);
+  void search_back_for(const std::wstring &s)
+  {
+    vs_tree_search_string matches(s);
+    search_back_for(matches);
+  }
+
   void set_hierarchical(bool _hierarchical);
   bool get_hierarchical() {return hierarchical;}
 



More information about the Aptitude-svn-commit mailing list