Skip to content

Commit

Permalink
fix for ticket 104 (GRASS-PAGER not set)
Browse files Browse the repository at this point in the history
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 e863190
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -27,6 +27,7 @@
#include "qsettings.h"
#include <QMessageBox>
#include <QCoreApplication>
#include <QProcess>

#include "qgsapplication.h"
#include "qgsgrass.h"
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit e863190

Please sign in to comment.