MCPcopy Index your code
hub / github.com/benfry/processing4 / replaceAll

Method replaceAll

app/src/processing/app/ui/FindReplace.java:438–474  ·  view source on GitHub ↗

Replace everything that matches by doing find and replace alternately until nothing more found.

()

Source from the content-addressed store, hash-verified

436 * alternately until nothing more found.
437 */
438 public void replaceAll() {
439 // move to the beginning
440 editor.setSelection(0, 0);
441
442 boolean foundAtLeastOne = false;
443 int startTab = -1;
444 int startIndex = -1;
445 int counter = 10000; // prevent infinite loop
446
447 editor.startCompoundEdit();
448 while (--counter > 0) {
449 if (find(false, false)) {
450 int caret = editor.getSelectionStart();
451 int stopIndex = startIndex + replaceField.getText().length();
452 if (editor.getSketch().getCurrentCodeIndex() == startTab &&
453 (caret >= startIndex && (caret <= stopIndex))) {
454 // we've reached where we started, so stop the replacement
455 Toolkit.beep();
456 editor.statusNotice("Reached beginning of search!");
457 break;
458 }
459 if (!foundAtLeastOne) {
460 foundAtLeastOne = true;
461 startTab = editor.getSketch().getCurrentCodeIndex();
462 startIndex = editor.getSelectionStart();
463 }
464 replace(false);
465 } else {
466 break;
467 }
468 }
469 editor.stopCompoundEdit();
470 if (!foundAtLeastOne) {
471 Toolkit.beep();
472 }
473 setFound(false);
474 }
475
476
477 public void setFindText(String t) {

Callers 10

FindReplaceMethod · 0.95
readMethod · 0.45
sanitizeHtmlTagsMethod · 0.45
loadMethod · 0.45
runMethod · 0.45
translateCategoryMethod · 0.45
pasteMethod · 0.45
setMenuMnemonicsMethod · 0.45
formatMessageMethod · 0.45
handlePrintMethod · 0.45

Calls 12

findMethod · 0.95
beepMethod · 0.95
replaceMethod · 0.95
setFoundMethod · 0.95
setSelectionMethod · 0.80
startCompoundEditMethod · 0.80
getSketchMethod · 0.80
stopCompoundEditMethod · 0.80
statusNoticeMethod · 0.65
getSelectionStartMethod · 0.45
getTextMethod · 0.45
getCurrentCodeIndexMethod · 0.45

Tested by

no test coverage detected