2002-09-05 14:10:50 +00:00
|
|
|
/**
|
|
|
|
* \file ControlSearch.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-26 15:25:37 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
2001-03-26 15:25:37 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-26 15:25:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlSearch.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
|
2001-04-05 12:26:41 +00:00
|
|
|
#include "gettext.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
#include "lyxfind.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2001-07-29 17:39:01 +00:00
|
|
|
#include "support/lstrings.h"
|
2001-03-26 15:25:37 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2001-03-26 15:25:37 +00:00
|
|
|
ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
|
2002-01-16 14:47:58 +00:00
|
|
|
: ControlDialogBD(lv, d)
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-03-26 15:25:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ControlSearch::find(string const & search,
|
2002-08-12 20:17:41 +00:00
|
|
|
bool casesensitive, bool matchword, bool forward)
|
2001-03-26 15:25:37 +00:00
|
|
|
{
|
2002-08-12 20:17:41 +00:00
|
|
|
bool const found = lyxfind::LyXFind(bufferview(), search,
|
2002-06-18 15:44:30 +00:00
|
|
|
forward, casesensitive,
|
|
|
|
matchword);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-26 15:25:37 +00:00
|
|
|
if (!found)
|
2002-10-20 01:48:28 +00:00
|
|
|
lv_.message(_("String not found!"));
|
2001-03-26 15:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlSearch::replace(string const & search, string const & replace,
|
2002-08-12 20:17:41 +00:00
|
|
|
bool casesensitive, bool matchword, bool all)
|
2001-03-26 15:25:37 +00:00
|
|
|
{
|
2001-09-07 17:52:50 +00:00
|
|
|
// If not replacing all instances of the word, then do not
|
|
|
|
// move on to the next instance once the present instance has been
|
|
|
|
// changed
|
|
|
|
bool const once = !all;
|
2002-06-18 15:44:30 +00:00
|
|
|
int const replace_count =
|
2002-08-12 20:17:41 +00:00
|
|
|
lyxfind::LyXReplace(bufferview(),
|
2002-06-18 15:44:30 +00:00
|
|
|
search, replace, true, casesensitive,
|
|
|
|
matchword, all, once);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-26 15:25:37 +00:00
|
|
|
if (replace_count == 0) {
|
2002-10-20 01:48:28 +00:00
|
|
|
lv_.message(_("String not found!"));
|
2001-03-26 15:25:37 +00:00
|
|
|
} else {
|
|
|
|
if (replace_count == 1) {
|
2002-10-20 01:48:28 +00:00
|
|
|
lv_.message(_("String has been replaced."));
|
2001-03-26 15:25:37 +00:00
|
|
|
} else {
|
|
|
|
string str = tostr(replace_count);
|
|
|
|
str += _(" strings have been replaced.");
|
2002-10-24 12:56:44 +00:00
|
|
|
lv_.message(str);
|
2001-03-26 15:25:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|