| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1429,7 +1429,6 @@ public final String getSelectedText() | |||
| 1429 | 1429 | } | |
| 1430 | 1430 | } | |
| 1431 | 1431 | ||
| 1432 | - | ||
| 1433 | 1432 | /** | |
| 1434 | 1433 | * Replaces the selection with the specified text. | |
| 1435 | 1434 | * @param selectedText The replacement text for the selection | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1572,6 +1572,11 @@ public void setSelectedText(String what) { | |||
| 1572 | 1572 | } | |
| 1573 | 1573 | ||
| 1574 | 1574 | ||
| 1575 | + public void setSelectedText(String what, boolean ever) { | ||
| 1576 | + textarea.setSelectedText(what, ever); | ||
| 1577 | + } | ||
| 1578 | + | ||
| 1579 | + | ||
| 1575 | 1580 | public void setSelection(int start, int stop) { | |
| 1576 | 1581 | // make sure that a tool isn't asking for a bad location | |
| 1577 | 1582 | start = PApplet.constrain(start, 0, textarea.getDocumentLength()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -417,15 +417,27 @@ protected void setFound(boolean found) { | |||
| 417 | 417 | replaceAndFindButton.setEnabled(found); | |
| 418 | 418 | } | |
| 419 | 419 | ||
| 420 | + /** | ||
| 421 | + * Replace the current selection with whatever's in the | ||
| 422 | + * replacement text field. | ||
| 423 | + * @param isCompoundEdit True if the action is to be marked as a copmound edit | ||
| 424 | + */ | ||
| 425 | + public void replace(boolean isCompoundEdit) { | ||
| 426 | + editor.setSelectedText(replaceField.getText(), isCompoundEdit); | ||
| 427 | + | ||
| 428 | + editor.getSketch().setModified(true); // This necessary- calling replace() | ||
| 429 | + // doesn't seem to mark a sketch as modified | ||
| 430 | + | ||
| 431 | + setFound(false); | ||
| 432 | + } | ||
| 433 | + | ||
| 420 | 434 | ||
| 421 | 435 | /** | |
| 422 | 436 | * Replace the current selection with whatever's in the | |
| 423 | - * replacement text field. | ||
| 437 | + * replacement text field, marking the action as a compound edit. | ||
| 424 | 438 | */ | |
| 425 | 439 | public void replace() { | |
| 426 | - editor.setSelectedText(replaceField.getText()); | ||
| 427 | - editor.getSketch().setModified(true); // TODO is this necessary? | ||
| 428 | - setFound(false); | ||
| 440 | + replace(true); | ||
| 429 | 441 | } | |
| 430 | 442 | ||
| 431 | 443 | ||
@@ -451,6 +463,8 @@ public void replaceAll() { | |||
| 451 | 463 | int startTab = -1; | |
| 452 | 464 | int startIndex = -1; | |
| 453 | 465 | int counter = 10000; // prevent infinite loop | |
| 466 | + | ||
| 467 | + editor.startCompoundEdit(); | ||
| 454 | 468 | while (--counter > 0) { | |
| 455 | 469 | if (find(false, false)) { | |
| 456 | 470 | int caret = editor.getSelectionStart(); | |
@@ -467,11 +481,12 @@ public void replaceAll() { | |||
| 467 | 481 | startTab = editor.getSketch().getCurrentCodeIndex(); | |
| 468 | 482 | startIndex = editor.getSelectionStart(); | |
| 469 | 483 | } | |
| 470 | - replace(); | ||
| 484 | + replace(false); | ||
| 471 | 485 | } else { | |
| 472 | 486 | break; | |
| 473 | 487 | } | |
| 474 | 488 | } | |
| 489 | + editor.stopCompoundEdit(); | ||
| 475 | 490 | if (!foundAtLeastOne) { | |
| 476 | 491 | Toolkit.beep(); | |
| 477 | 492 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments