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

Daniel Burrows dburrows at costa.debian.org
Fri Sep 23 02:18:38 UTC 2005


Author: dburrows
Date: Fri Sep 23 02:18:35 2005
New Revision: 4201

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/view_changelog.cc
Log:
Add backwards-searching support to the changelog viewer.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Fri Sep 23 02:18:35 2005
@@ -1,5 +1,9 @@
 2005-09-22  Daniel Burrows  <dburrows at debian.org>
 
+	* src/view_changelog.cc, src/view_changelog.h:
+
+	  Add support for either forward or backwards searching.
+
 	* src/vscreen/vs_pager.cc, src/vscreen/vs_pager.h:
 
 	  Add support for searching backwards in a file.

Modified: branches/aptitude-0.3/aptitude/src/view_changelog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/view_changelog.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/view_changelog.cc	Fri Sep 23 02:18:35 2005
@@ -26,6 +26,7 @@
 
 #include "download_bar.h"
 #include "download_manager.h"
+#include "menu_redirect.h"
 #include "ui.h"
 
 #include <generic/apt.h>
@@ -36,14 +37,16 @@
 
 using namespace std;
 
-class pkg_changelog_screen:public vs_file_pager
-// Needed to make sure the changelog is properly cleaned up.
+class pkg_changelog_screen : public vs_file_pager, public menu_redirect
 {
   pkg_changelog *cl;
+  bool last_search_forwards;
 
 
   void do_search()
   {
+    last_search_forwards = true;
+
     prompt_string(transcode(_("Search for:")),
 		  L"",
 		  arg(sigc::mem_fun(*this, &vs_pager::search_for)),
@@ -52,17 +55,34 @@
 		  NULL);
   }
 
+  void do_search_back()
+  {
+    last_search_forwards = false;
+
+    prompt_string(transcode(_("Search backwards for:")),
+		  L"",
+		  arg(sigc::mem_fun(*this, &vs_pager::search_back_for)),
+		  NULL,
+		  NULL,
+		  NULL);
+  }
+
   void do_repeat_search()
   {
-    search_for(L"");
+    if(last_search_forwards)
+      search_for(L"");
+    else
+      search_back_for(L"");
   }
 
 protected:
   pkg_changelog_screen(pkg_changelog *_cl, int x=0, int y=0, int width=0, int height=0):
-    vs_file_pager(_cl->get_filename()),cl(_cl)
+    vs_file_pager(_cl->get_filename()), cl(_cl), last_search_forwards(true)
   {
     connect_key("Search", &global_bindings,
 		sigc::mem_fun(*this, &pkg_changelog_screen::do_search));
+    connect_key("SearchBack", &global_bindings,
+		sigc::mem_fun(*this, &pkg_changelog_screen::do_search_back));
     connect_key("ReSearch", &global_bindings,
 		sigc::mem_fun(*this, &pkg_changelog_screen::do_repeat_search));
   }
@@ -78,6 +98,39 @@
     return rval;
   }
 
+  bool find_search_enabled()
+  {
+    return true;
+  }
+
+  bool find_search()
+  {
+    do_search();
+    return true;
+  }
+
+  bool find_search_back_enabled()
+  {
+    return true;
+  }
+
+  bool find_search_back()
+  {
+    do_search_back();
+    return true;
+  }
+
+  bool find_research_enabled()
+  {
+    return !get_last_search().empty();
+  }
+
+  bool find_research()
+  {
+    do_repeat_search();
+    return true;
+  }
+
   virtual ~pkg_changelog_screen() {delete cl;}
 };
 
@@ -131,6 +184,8 @@
 
       t->show_all();
 
+      create_menu_bindings(cs.unsafe_get_ref(), t);
+
       insert_main_widget(t, menulabel, "", tablabel);
     }
 }



More information about the Aptitude-svn-commit mailing list