Author: jreidinger
Date: Fri May 30 15:37:07 2008
New Revision: 10284
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10284&view=rev
Log:
show help messages when show license in pager (bnc #394394)
Modified:
trunk/zypper/src/zypper-misc.cc
Modified: trunk/zypper/src/zypper-misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=10284&r1=10283&r2=10284&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.cc (original)
+++ trunk/zypper/src/zypper-misc.cc Fri May 30 15:37:07 2008
@@ -136,6 +136,31 @@
return true;
}
+string helpPagerExit(const string &pager)
+{
+ string endfour = pager.substr(pager.size()-4,4);
+ if (endfour == "less")
+ {
+ return _("Press 'q' to exit.");
+ }
+ return string();
+}
+
+string helpPagerNavigation(const string &pager)
+{
+ string endfour = pager.substr(pager.size()-4,4);
+ if (endfour == "less")
+ {
+ return _("Use arrows to scroll by line or pgnUp/Down to scroll by screens."
+ " Also Home/End work.");
+ }
+ else if (endfour == "more")
+ {
+ return _("Use Enter to go to next line and space for scroll whole screen.");
+ }
+ return string();
+}
+
//gets true if successfully display in pager
bool show_in_pager(const string& text)
{
@@ -146,7 +171,13 @@
filesystem::TmpFile tfile;
string tpath = tfile.path().absolutename().c_str();
ofstream os(tpath.c_str());
+ string help = helpPagerNavigation(pager);
+ if (!help.empty())
+ os << help << endl << endl;
os << text;
+ help = helpPagerExit(pager);
+ if (!help.empty())
+ os << endl << endl << help;
os.close();
ostringstream cmdline;
cmdline << pager <<" "<