diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp
index 3ac8541..37fa6ac 100644
a
|
b
|
StyledEditWindow::_RevertToSaved()
|
1408 | 1408 | |
1409 | 1409 | bool |
1410 | 1410 | StyledEditWindow::_Search(BString string, bool caseSensitive, bool wrap, |
1411 | | bool backSearch) |
| 1411 | bool backSearch, bool scrollToOccurence) |
1412 | 1412 | { |
1413 | 1413 | int32 start; |
1414 | 1414 | int32 finish; |
… |
… |
StyledEditWindow::_Search(BString string, bool caseSensitive, bool wrap,
|
1450 | 1450 | if (start != B_ERROR) { |
1451 | 1451 | finish = start + length; |
1452 | 1452 | fTextView->Select(start, finish); |
1453 | | fTextView->ScrollToSelection(); |
| 1453 | |
| 1454 | if (scrollToOccurence) |
| 1455 | fTextView->ScrollToSelection(); |
1454 | 1456 | return true; |
1455 | 1457 | } |
1456 | 1458 | |
… |
… |
StyledEditWindow::_ReplaceAll(BString findThis, BString replaceWith,
|
1501 | 1503 | { |
1502 | 1504 | bool first = true; |
1503 | 1505 | fTextView->SetSuppressChanges(true); |
1504 | | while (_Search(findThis, caseSensitive, true, false)) { |
| 1506 | |
| 1507 | // start from the beginning of text |
| 1508 | fTextView->Select(0,0); |
| 1509 | |
| 1510 | int32 start, finish; |
| 1511 | |
| 1512 | // iterate occurences of findThis without wrapping around |
| 1513 | while (_Search(findThis, caseSensitive, false, false, false)) { |
1505 | 1514 | if (first) { |
1506 | 1515 | _UpdateCleanUndoRedoSaveRevert(); |
1507 | 1516 | first = false; |
1508 | 1517 | } |
1509 | | int32 start, finish; |
| 1518 | |
1510 | 1519 | fTextView->GetSelection(&start, &finish); |
1511 | | |
1512 | 1520 | fTextView->Delete(start, start + findThis.Length()); |
1513 | 1521 | fTextView->Insert(start, replaceWith.String(), replaceWith.Length()); |
| 1522 | |
| 1523 | // advance the caret behind the inserted text |
| 1524 | start += replaceWith.Length(); |
| 1525 | fTextView->Select(start, start); |
1514 | 1526 | } |
| 1527 | fTextView->ScrollToSelection(); |
1515 | 1528 | fTextView->SetSuppressChanges(false); |
1516 | 1529 | } |
1517 | 1530 | |
diff --git a/src/apps/stylededit/StyledEditWindow.h b/src/apps/stylededit/StyledEditWindow.h
index 241de30..d107917 100644
a
|
b
|
private:
|
57 | 57 | status_t _LoadFile(entry_ref* ref); |
58 | 58 | void _RevertToSaved(); |
59 | 59 | bool _Search(BString searchFor, bool caseSensitive, |
60 | | bool wrap, bool backSearch); |
| 60 | bool wrap, bool backSearch, |
| 61 | bool scrollToOccurence = true); |
61 | 62 | void _FindSelection(); |
62 | 63 | bool _Replace(BString findThis, BString replaceWith, |
63 | 64 | bool caseSensitive, bool wrap, |