aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-06-23 23:39:12 +0000
committerMike Buland <eichlan@xagasoft.com>2010-06-23 23:39:12 +0000
commit280145e984283daa11fe81329246ad23b77cd8f3 (patch)
treef09393838f5362d5bb2ba300b310d063fa774d14 /src
parent5d8fad38edc321f4bda8084b24b0350c5af82a1d (diff)
downloadlibbu++-280145e984283daa11fe81329246ad23b77cd8f3.tar.gz
libbu++-280145e984283daa11fe81329246ad23b77cd8f3.tar.bz2
libbu++-280145e984283daa11fe81329246ad23b77cd8f3.tar.xz
libbu++-280145e984283daa11fe81329246ad23b77cd8f3.zip
find works.
Diffstat (limited to '')
-rw-r--r--src/tools/viewcsv.cpp78
1 files changed, 75 insertions, 3 deletions
diff --git a/src/tools/viewcsv.cpp b/src/tools/viewcsv.cpp
index 649ec9e..176f25e 100644
--- a/src/tools/viewcsv.cpp
+++ b/src/tools/viewcsv.cpp
@@ -284,10 +284,76 @@ public:
284 } 284 }
285 } 285 }
286 286
287 void resetCaret()
288 {
289 sysCaret.reset();
290 }
291
292 void findNext( const Bu::FString &sTerm )
293 {
294 int y = sysCaret.iRow;
295 if( y < 0 )
296 y = 0;
297 int x = sysCaret.iCol+1;
298 for( ; y < doc.sgData.getSize(); y++ )
299 {
300 StrArray &aRow = doc.sgData[y];
301 for( ; x < aRow.getSize(); x++ )
302 {
303 if( aRow[x].find( sTerm ) )
304 {
305 sysCaret.iRow = y;
306 sysCaret.iCol = x;
307 scrollToCaret();
308 return;
309 }
310 }
311 x = 0;
312 }
313 }
314
315 void scrollToCaret()
316 {
317 iXOff = sysCaret.iCol;
318 iYOff = sysCaret.iRow;
319 }
320
287 CsvDoc &doc; 321 CsvDoc &doc;
288 int iXOff; 322 int iXOff;
289 int iYOff; 323 int iYOff;
290 bool bHeaderRow; 324 bool bHeaderRow;
325
326 class Caret
327 {
328 public:
329 Caret() :
330 iRow( -1 ),
331 iCol( -1 )
332 {
333 }
334
335 virtual ~Caret()
336 {
337 }
338
339
340 void reset()
341 {
342 iRow = iCol = -1;
343 }
344
345 bool isSet()
346 {
347 if( iRow < 0 || iCol < 0 )
348 return false;
349 return true;
350 }
351
352 int iRow;
353 int iCol;
354 };
355
356 Caret sysCaret;
291}; 357};
292 358
293int main( int argc, char *argv[] ) 359int main( int argc, char *argv[] )
@@ -327,6 +393,8 @@ int main( int argc, char *argv[] )
327 CsvView view( doc ); 393 CsvView view( doc );
328 view.setHeaderRow( opt.bHeader ); 394 view.setHeaderRow( opt.bHeader );
329 395
396 Bu::FString sSearchTerm;
397
330 bool bRun = true; 398 bool bRun = true;
331 do 399 do
332 { 400 {
@@ -372,9 +440,13 @@ int main( int argc, char *argv[] )
372 break; 440 break;
373 441
374 case '/': 442 case '/':
375 { 443 sSearchTerm = view.prompt("find: ");
376 Bu::FString sIn = view.prompt("find: "); 444 view.resetCaret();
377 } 445 view.findNext( sSearchTerm );
446 break;
447
448 case 'n':
449 view.findNext( sSearchTerm );
378 break; 450 break;
379 451
380 case 'h': 452 case 'h':