/* * Search backward. Get a search string from the user, and * search for it. */ int backsearch(int f, int n) { int status; hst_init('?'); status = rsearch(f, n, FALSE, FALSE); hst_flush(); return status; }
// Returns true if the given blob overlaps more than max_overlaps blobs // in the current grid. bool CCNonTextDetect::BlobOverlapsTooMuch(BLOBNBOX* blob, int max_overlaps) { // Search the grid to see what intersects it. // Setup a Rectangle search for overlapping this blob. BlobGridSearch rsearch(this); TBOX box = blob->bounding_box(); rsearch.StartRectSearch(box); rsearch.SetUniqueMode(true); BLOBNBOX* neighbour; int overlap_count = 0; while (overlap_count <= max_overlaps && (neighbour = rsearch.NextRectSearch()) != NULL) { if (box.major_overlap(neighbour->bounding_box())) { ++overlap_count; if (overlap_count > max_overlaps) return true; } } return false; }
/* extra args -- marking if called from globals, and should mark lines, and fromscreen, if the searchpattern is on the screen, so we don't need to ask for it. */ int fsearch(int f, int n, int marking, int fromscreen) { int status = TRUE; int wrapok; MARK curpos; int didmark = FALSE; int didwrap; assert(curwp != 0); if (f && n < 0) return rsearch(f, -n, FALSE, FALSE); if (n == 0) n = 1; wrapok = marking || window_b_val(curwp, MDWRAPSCAN); last_srch_direc = FORWARD; /* ask the user for a regular expression to search for. if * "marking", then we were called to do line marking for the * global command. */ if (!marking) { status = readpattern("Search: ", &searchpat, &gregexp, lastkey, fromscreen); if (status != TRUE) return status; } ignorecase = window_b_val(curwp, MDIGNCASE); if (curwp == 0) return FALSE; curpos = DOT; scanboundry(wrapok, curpos, FORWARD); didwrap = FALSE; while (marking || n--) { movenext(&(DOT), FORWARD); status = scanner(gregexp, FORWARD, wrapok, &didwrap); if (status == ABORT) { mlwarn("[Aborted]"); DOT = curpos; return status; } /* if found, mark the line */ if (status && marking) { /* if we were on a match when we started, then scanner returns TRUE, even though it's on a boundary. quit if we find ourselves marking a line twice */ if (lismarked(DOT.l)) break; lsetmarked(DOT.l); /* and, so the next movenext gets to next line */ DOT.o = llength(DOT.l); didmark = TRUE; } if (!marking && didwrap) { mlwrite("[Search wrapped past end of buffer]"); didwrap = FALSE; } if (status != TRUE) break; } if (!marking && !status) movenext(&(DOT), REVERSE); if (marking) { /* restore dot and offset */ DOT = curpos; } else if (status) { savematch(DOT, gregexp->mlen); if (samepoint(DOT, curpos)) { mlwrite(onlyonemsg); } } /* Complain if not there. */ if ((marking && didmark == FALSE) || (!marking && status == FALSE)) { not_found_msg(wrapok, FORWARD); return FALSE; } attrib_matches(); return TRUE; }
int scrbacksearch(int f, int n) { return rsearch(f, n, FALSE, TRUE); }