2001-07-29 10:42:11 +00:00
|
|
|
/**
|
|
|
|
* \file ControlThesaurus.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlThesaurus.h"
|
2001-07-29 10:42:11 +00:00
|
|
|
#include "Liason.h"
|
|
|
|
#include "lyxfind.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
2001-07-29 10:42:11 +00:00
|
|
|
using Liason::setMinibuffer;
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2001-07-29 10:42:11 +00:00
|
|
|
ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d)
|
2002-01-16 14:47:58 +00:00
|
|
|
: ControlDialogBD(lv, d)
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-07-29 10:42:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ControlThesaurus::showEntry(string const & entry)
|
|
|
|
{
|
|
|
|
oldstr_ = entry;
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlThesaurus::replace(string const & newstr)
|
|
|
|
{
|
|
|
|
/* FIXME: this is not suitable ! We need to have a "lock"
|
|
|
|
* on a particular charpos in a paragraph that is broken on
|
|
|
|
* deletion/change !
|
|
|
|
*/
|
2002-06-18 15:44:30 +00:00
|
|
|
int const replace_count =
|
|
|
|
lyxfind::LyXReplace(lv_.view(), oldstr_, newstr,
|
|
|
|
true, true, true, false, true);
|
2001-07-29 10:42:11 +00:00
|
|
|
|
|
|
|
oldstr_ = newstr;
|
|
|
|
|
|
|
|
if (replace_count == 0)
|
|
|
|
setMinibuffer(&lv_, _("String not found!"));
|
|
|
|
else
|
|
|
|
setMinibuffer(&lv_, _("String has been replaced."));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-13 01:46:33 +00:00
|
|
|
Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
|
2001-07-29 10:42:11 +00:00
|
|
|
{
|
|
|
|
if (str != laststr_)
|
2002-01-13 01:46:33 +00:00
|
|
|
meanings_ = thesaurus.lookup(str);
|
2001-07-29 10:42:11 +00:00
|
|
|
|
2002-01-13 01:46:33 +00:00
|
|
|
return meanings_;
|
2001-07-29 10:42:11 +00:00
|
|
|
}
|