MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / find_substring_CB

Method find_substring_CB

src/csvapplication.cpp:1640–1692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1638}
1639
1640void CsvApplication::find_substring_CB(Fl_Widget *, long data) {
1641 int keyCode = (int) data;
1642 if( keyCode <= 0 ) {
1643 // ESC, Red Close Button == 0 / ENTER, Find Next Button == TCRUNCHER_MYFLCHOICE_MAGICAL
1644 app.searchWin->hide();
1645 return;
1646 }
1647 int row, col;
1648 int startFindRow, startFindCol;
1649 std::tuple<int, int> found;
1650 std::string query(app.searchInput->value());
1651 int winIndex = app.getTopWindow();
1652 bool caseSensitive = true;
1653 bool useRegex = false;
1654 std::vector<int> sel = windows[winIndex].grid->getSelection();
1655 if( app.ignoreCase->value() ) {
1656 caseSensitive = false;
1657 }
1658 if( app.useRegex->value() ) {
1659 useRegex = true;
1660 }
1661 app.searchWinLabel->copy_label("Start searching ...");
1662 app.searchWinLabel->redraw();
1663 Fl::check();
1664 if( std::get<0>(app.lastFound) >= 0 && std::get<1>(app.lastFound) >= 0 ) {
1665 startFindRow = std::get<0>(app.lastFound);
1666 startFindCol = std::get<1>(app.lastFound);
1667 } else {
1668 startFindRow = sel[0];
1669 startFindCol = sel[1];
1670 }
1671 if( sel[2] == sel[0] && sel[3] == sel[1] ) {
1672 sel = {0, 0, windows[winIndex].table->getNumberRows()-1, windows[winIndex].table->getNumberCols()-1};
1673 }
1674 app.showImWorkingWindow("Searching ...");
1675 found = windows[winIndex].table->findSubstring(query, startFindRow, startFindCol, sel, caseSensitive, useRegex);
1676 app.hideImWorkingWindow();
1677 row = std::get<0>(found);
1678 col = std::get<1>(found);
1679 if( row != -1 && col != -1 ) {
1680 app.lastFound = found;
1681 windows[winIndex].grid->setVisibleArea(row, col);
1682 windows[winIndex].grid->redraw();
1683 windows[winIndex].showDefaultStatus();
1684 app.searchWinLabel->copy_label("");
1685 } else {
1686 app.lastFound = {-1,-1};
1687 windows[winIndex].grid->redraw();
1688 app.searchWinLabel->copy_label("No match found.");
1689 }
1690 app.searchWin->redraw();
1691 Fl::check();
1692}
1693
1694/*
1695 * Does Replacement, is called by callback functions below

Callers

nothing calls this directly

Calls 11

checkFunction · 0.85
getTopWindowMethod · 0.80
getNumberRowsMethod · 0.80
getNumberColsMethod · 0.80
showImWorkingWindowMethod · 0.80
findSubstringMethod · 0.80
hideImWorkingWindowMethod · 0.80
setVisibleAreaMethod · 0.80
showDefaultStatusMethod · 0.80
valueMethod · 0.45
getSelectionMethod · 0.45

Tested by

no test coverage detected