Пример #1
0
void FindAndReplaceDialog::buttonClicked (Button* buttonThatWasClicked)
{
  TextEditorWindow* win=TextEditorWindow::getFocusTextEditor();

  if (!win)  // no editor open
    {
      PlatformUtilities::beep();
      return;
    }
  TextBuffer* buf=win->getTextBuffer();
  // no find string
  String str=textEditor1->getText();
  if (str.isEmpty())
    {
      PlatformUtilities::beep();
      textEditor1->grabKeyboardFocus();
      return;
    }

  if (buttonThatWasClicked == textButton1)       // Replace All
    {
      if (!buf->replaceAll(str, textEditor2->getText()))
	PlatformUtilities::beep();
    }
  else if (buttonThatWasClicked == textButton2)  // Replace
    {
      if (!buf->replace(textEditor2->getText()))
	PlatformUtilities::beep();
    }
  else if (buttonThatWasClicked == textButton3) // Find & Replace
    {
      if (!buf->replaceAndFind(str, textEditor2->getText()))
	PlatformUtilities::beep();	
    }
  else if (buttonThatWasClicked == textButton4) // Previous
    {
      if (!buf->findPrevious(str))
	PlatformUtilities::beep();
    }
  else if (buttonThatWasClicked == textButton5) // Next
    {
      if (!buf->findNext(str))
	PlatformUtilities::beep();
    }
}