File tree 1 file changed +42
-0
lines changed
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 27
27
#include " qsettings.h"
28
28
#include < QMessageBox>
29
29
#include < QCoreApplication>
30
+ #include < QProcess>
30
31
31
32
#include " qgsapplication.h"
32
33
#include " qgsgrass.h"
@@ -180,6 +181,47 @@ void QgsGrass::init( void )
180
181
strcpy ( pathEnvChar, const_cast <char *>(path.ascii ()) );
181
182
putenv ( pathEnvChar );
182
183
184
+ // Set GRASS_PAGER if not set, it is necessary for some
185
+ // modules printing to terminal, e.g. g.list
186
+ // We use 'cat' because 'more' is not present in MSYS (Win)
187
+ // and it doesn't work well in built in shell (Unix/Mac)
188
+ // and 'less' is not user friendly (for example user must press
189
+ // 'q' to quit which is definitely difficult for normal user)
190
+ // Also scroling can be don in scrollable window in both
191
+ // MSYS terminal and built in shell.
192
+ if ( !getenv (" GRASS_PAGER" ) )
193
+ {
194
+ QString pager;
195
+ QStringList pagers;
196
+ // pagers << "more" << "less" << "cat"; // se notes above
197
+ pagers << " cat" ;
198
+
199
+ for ( int i = 0 ; i < pagers.size (); i++ )
200
+ {
201
+ int state;
202
+
203
+ QProcess p;
204
+ p.start ( pagers.at (i) );
205
+ p.waitForStarted ();
206
+ state = p.state ();
207
+ p.kill ();
208
+
209
+ if ( state == QProcess::Running )
210
+ {
211
+ pager = pagers.at (i);
212
+ break ;
213
+ }
214
+ }
215
+
216
+ if ( pager.length () > 0 )
217
+ {
218
+ pager.prepend ( " GRASS_PAGER=" );
219
+ char *pagerEnvChar = new char [pager.length ()+1 ];
220
+ strcpy ( pagerEnvChar, const_cast <char *>(pager.ascii ()) );
221
+ putenv ( pagerEnvChar );
222
+ }
223
+ }
224
+
183
225
initialized = 1 ;
184
226
}
185
227
You can’t perform that action at this time.
0 commit comments