Skip to content
Permalink
Browse files
fix for ticket 104 (GRASS-PAGER not set)
git-svn-id: http://svn.osgeo.org/qgis/trunk@5680 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Aug 10, 2006
1 parent 6e48f22 commit e86319037e3b338402ac940f2f5f9d5b6f91aa4c
Showing with 42 additions and 0 deletions.
  1. +42 −0 src/providers/grass/qgsgrass.cpp
@@ -27,6 +27,7 @@
#include "qsettings.h"
#include <QMessageBox>
#include <QCoreApplication>
#include <QProcess>

#include "qgsapplication.h"
#include "qgsgrass.h"
@@ -180,6 +181,47 @@ void QgsGrass::init( void )
strcpy ( pathEnvChar, const_cast<char *>(path.ascii()) );
putenv( pathEnvChar );

// Set GRASS_PAGER if not set, it is necessary for some
// modules printing to terminal, e.g. g.list
// We use 'cat' because 'more' is not present in MSYS (Win)
// and it doesn't work well in built in shell (Unix/Mac)
// and 'less' is not user friendly (for example user must press
// 'q' to quit which is definitely difficult for normal user)
// Also scroling can be don in scrollable window in both
// MSYS terminal and built in shell.
if ( !getenv ("GRASS_PAGER") )
{
QString pager;
QStringList pagers;
//pagers << "more" << "less" << "cat"; // se notes above
pagers << "cat";

for ( int i = 0; i < pagers.size(); i++ )
{
int state;

QProcess p;
p.start ( pagers.at(i) );
p.waitForStarted();
state = p.state();
p.kill();

if ( state == QProcess::Running )
{
pager = pagers.at(i);
break;
}
}

if ( pager.length() > 0 )
{
pager.prepend ( "GRASS_PAGER=" );
char *pagerEnvChar = new char[pager.length()+1];
strcpy ( pagerEnvChar, const_cast<char *>(pager.ascii()) );
putenv( pagerEnvChar );
}
}

initialized = 1;
}

0 comments on commit e863190

Please sign in to comment.