| 1549 | |
| 1550 | template <typename Predicate> |
| 1551 | int CLogView::FindLine(Predicate pred, int direction) const |
| 1552 | { |
| 1553 | SetCursor(::LoadCursor(nullptr, IDC_ARROW)); |
| 1554 | Win32::ScopedCursor cursor(::LoadCursor(nullptr, IDC_WAIT)); |
| 1555 | |
| 1556 | int begin = std::max(GetNextItem(-1, LVNI_FOCUSED), 0); |
| 1557 | int line = begin; |
| 1558 | |
| 1559 | if (m_logLines.empty()) |
| 1560 | return -1; |
| 1561 | |
| 1562 | do |
| 1563 | { |
| 1564 | line += direction; |
| 1565 | if (line < 0) |
| 1566 | line += m_logLines.size(); |
| 1567 | if (line >= static_cast<int>(m_logLines.size())) |
| 1568 | line -= m_logLines.size(); |
| 1569 | |
| 1570 | if (pred(m_logLines[line])) |
| 1571 | return line; |
| 1572 | } |
| 1573 | while (line != begin); |
| 1574 | |
| 1575 | return -1; |
| 1576 | } |
| 1577 | |
| 1578 | bool CLogView::Find(const std::string& text, int direction) |
| 1579 | { |