[Aptitude-svn-commit] r4365 - branches/aptitude-0.3/aptitude/src

Daniel Burrows dburrows at costa.debian.org
Fri Sep 30 16:06:49 UTC 2005


Author: dburrows
Date: Fri Sep 30 16:06:49 2005
New Revision: 4365

Added:
   branches/aptitude-0.3/aptitude/src/menu_text_layout.cc
   branches/aptitude-0.3/aptitude/src/menu_text_layout.h
Log:
Add files I forgot to.

Added: branches/aptitude-0.3/aptitude/src/menu_text_layout.cc
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/menu_text_layout.cc	Fri Sep 30 16:06:49 2005
@@ -0,0 +1,104 @@
+// menu_text_layout.cc
+//
+//   Copyright (C) 2005 Daniel Burrows
+//
+//   This program is free software; you can redistribute it and/or
+//   modify it under the terms of the GNU General Public License as
+//   published by the Free Software Foundation; either version 2 of
+//   the License, or (at your option) any later version.
+//
+//   This program is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//   General Public License for more details.
+//
+//   You should have received a copy of the GNU General Public License
+//   along with this program; see the file COPYING.  If not, write to
+//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+//   Boston, MA 02111-1307, USA.
+
+#include "menu_text_layout.h"
+
+#include "aptitude.h"
+#include "ui.h"
+
+#include <generic/util/slotarg.h>
+
+bool menu_text_layout::find_search_enabled()
+{
+  return true;
+}
+
+bool menu_text_layout::find_search()
+{
+  prompt_string(_("Search for:"),
+		"",
+		arg(sigc::mem_fun(this, &menu_text_layout::do_find_search)),
+		NULL,
+		NULL,
+		&search_history);
+
+  return true;
+}
+
+void menu_text_layout::do_find_search(const std::wstring &s)
+{
+  last_search_forward = true;
+
+  if(!s.empty())
+    {
+      last_search = s;
+      search_for(s, true);
+    }
+  else if(!last_search.empty())
+    search_for(last_search, true);
+  else
+    beep();
+}
+
+bool menu_text_layout::find_search_back_enabled()
+{
+  return true;
+}
+
+bool menu_text_layout::find_search_back()
+{
+  prompt_string(_("Search backwards for:"),
+		"",
+		arg(sigc::mem_fun(this, &menu_text_layout::do_find_search_back)),
+		NULL,
+		NULL,
+		&search_history);
+
+  return true;
+}
+
+void menu_text_layout::do_find_search_back(const std::wstring &s)
+{
+  last_search_forward = false;
+
+  if(!s.empty())
+    {
+      last_search = s;
+      search_for(s, false);
+    }
+  else if(!last_search.empty())
+    search_for(last_search, false);
+  else
+    beep();
+}
+
+bool menu_text_layout::find_research_enabled()
+{
+  return !last_search.empty();
+}
+
+bool menu_text_layout::find_research()
+{
+  if(last_search.empty())
+    beep();
+  else
+    search_for(last_search, last_search_forward);
+
+  return true;
+}

Added: branches/aptitude-0.3/aptitude/src/menu_text_layout.h
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/menu_text_layout.h	Fri Sep 30 16:06:49 2005
@@ -0,0 +1,81 @@
+// menu_text_layout.h                             -*-c++-*-
+//
+//   Copyright (C) 2005 Daniel Burrows
+//
+//   This program is free software; you can redistribute it and/or
+//   modify it under the terms of the GNU General Public License as
+//   published by the Free Software Foundation; either version 2 of
+//   the License, or (at your option) any later version.
+//
+//   This program is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//   General Public License for more details.
+//
+//   You should have received a copy of the GNU General Public License
+//   along with this program; see the file COPYING.  If not, write to
+//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+//   Boston, MA 02111-1307, USA.
+
+#ifndef MENU_TEXT_LAYOUT_H
+#define MENU_TEXT_LAYOUT_H
+
+#include "menu_redirect.h"
+
+#include <vscreen/vs_editline.h>
+#include <vscreen/vs_text_layout.h>
+
+class menu_text_layout : public vs_text_layout, public menu_redirect
+{
+  std::wstring last_search;
+  bool last_search_forward;
+  vs_editline::history_list search_history;
+
+  menu_text_layout(const menu_text_layout &other);
+
+  /** Search forward for the given string (or the last search if s is
+   *  empty); set last_search_forward to true and last_search to s if
+   *  nonempty.
+   */
+  void do_find_search(const std::wstring &s);
+
+  /** Search backward for the given string (or the last search if s is
+   *  empty); set last_search_forward to false and last_search to s if
+   *  nonempty.
+   */
+  void do_find_search_back(const std::wstring &s);
+protected:
+  menu_text_layout()
+    : last_search_forward(true)
+  {
+  }
+
+  menu_text_layout(fragment *f)
+    : vs_text_layout(f), last_search_forward(true)
+  {
+  }
+public:
+  static ref_ptr<menu_text_layout> create()
+  {
+    ref_ptr<menu_text_layout> rval = new menu_text_layout;
+    rval->decref();
+    return rval;
+  }
+
+  static ref_ptr<menu_text_layout> create(fragment *f)
+  {
+    ref_ptr<menu_text_layout> rval = new menu_text_layout(f);
+    rval->decref();
+    return rval;
+  }
+
+  bool find_search_enabled();
+  bool find_search();
+  bool find_search_back_enabled();
+  bool find_search_back();
+  bool find_research_enabled();
+  bool find_research();
+};
+typedef ref_ptr<menu_text_layout> menu_text_layout_ref;
+
+#endif



More information about the Aptitude-svn-commit mailing list