MCPcopy Index your code
hub / github.com/processing/processing / find

Method find

app/src/processing/app/ui/FindReplace.java:274–413  ·  view source on GitHub ↗
(boolean wrap, boolean backwards)

Source from the content-addressed store, hash-verified

272 // look for the next instance of the find string to be found
273 // once found, select it (and go to that line)
274 private boolean find(boolean wrap, boolean backwards) {
275 String searchTerm = findField.getText();
276
277 // this will catch "find next" being called when no search yet
278 if (searchTerm.length() != 0) {
279 String text = editor.getText();
280
281 // Started work on find/replace across tabs. These two variables store
282 // the original tab and selection position so that it knew when to stop
283 // rotating through.
284 Sketch sketch = editor.getSketch();
285 int tabIndex = sketch.getCurrentCodeIndex();
286// int selIndex = backwards ?
287// editor.getSelectionStart() : editor.getSelectionStop();
288
289 if (ignoreCase) {
290 searchTerm = searchTerm.toLowerCase();
291 text = text.toLowerCase();
292 }
293
294 int nextIndex;
295 if (!backwards) {
296 //int selectionStart = editor.textarea.getSelectionStart();
297 int selectionEnd = editor.getSelectionStop();
298
299 nextIndex = text.indexOf(searchTerm, selectionEnd);
300 if (nextIndex == -1 && wrap && !allTabs) {
301 // if wrapping, a second chance is ok, start from beginning
302 nextIndex = text.indexOf(searchTerm, 0);
303
304 } else if (nextIndex == -1 && allTabs) {
305 // For searching in all tabs, wrapping always happens.
306
307 int tempIndex = tabIndex;
308 // Look for searchterm in all tabs.
309 while (tabIndex <= sketch.getCodeCount() - 1) {
310 if (tabIndex == sketch.getCodeCount() - 1) {
311 // System.out.println("wrapping.");
312 tabIndex = -1;
313 } else if (tabIndex == sketch.getCodeCount() - 1) {
314 break;
315 }
316
317 try {
318 Document doc = sketch.getCode(tabIndex + 1).getDocument();
319 if(doc != null) {
320 text = doc.getText(0, doc.getLength()); // this thing has the latest changes
321 }
322 else {
323 text = sketch.getCode(tabIndex + 1).getProgram(); // not this thing.
324 }
325 } catch (BadLocationException e) {
326 e.printStackTrace();
327 }
328 tabIndex++;
329 if (ignoreCase) {
330 text = text.toLowerCase();
331 }

Callers 15

replaceAllMethod · 0.95
findNextMethod · 0.95
findPreviousMethod · 0.95
parsePolyMethod · 0.80
matchMethod · 0.80
matchAllMethod · 0.80
toHtmlLinksMethod · 0.80
findInScopeMethod · 0.80
writeMethod · 0.80
addAllDecimalNumbersMethod · 0.80
addAllHexNumbersMethod · 0.80

Calls 13

getCurrentCodeIndexMethod · 0.95
getCodeCountMethod · 0.95
getCodeMethod · 0.95
setCurrentCodeMethod · 0.95
setFoundMethod · 0.95
getSketchMethod · 0.80
getProgramMethod · 0.80
setSelectionMethod · 0.80
getTextMethod · 0.45
getSelectionStopMethod · 0.45
getDocumentMethod · 0.45
printStackTraceMethod · 0.45

Tested by 1