1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich,
|
|
|
|
* Copyright 1995-1999 The LyX Team.
|
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#include <cctype>
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "LString.h"
|
|
|
|
#include "lyx_main.h"
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
#include "form1.h"
|
|
|
|
#include "lyxfr0.h"
|
|
|
|
#include "lyxfr1.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
#include "lyxscreen.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "LyXView.h" // only because of form_main
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
// I hate global variables, but the same search object must be used everywhere,
|
|
|
|
// and the form is also global, so...
|
|
|
|
LyXFindReplace1 _FR;
|
|
|
|
|
|
|
|
// This one should be a protected member of LyXFindReplace1
|
|
|
|
// Form creation/destruction must also be done in LyXFindReplace1
|
|
|
|
extern FD_form_search *fd_form_search;
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// callbacks for form form_search
|
|
|
|
void SearchCancelCB(FL_OBJECT *, long)
|
|
|
|
{
|
|
|
|
_FR.SearchCancelCB();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SearchForwardCB(FL_OBJECT *, long)
|
|
|
|
{
|
|
|
|
_FR.SearchCB(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SearchBackwardCB(FL_OBJECT *, long)
|
|
|
|
{
|
|
|
|
_FR.SearchCB(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SearchReplaceAllCB(FL_OBJECT *, long)
|
|
|
|
{
|
|
|
|
_FR.SearchReplaceAllCB();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SearchReplaceCB(FL_OBJECT *, long)
|
|
|
|
{
|
|
|
|
_FR.SearchReplaceCB();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------- LyXFindReplace0's implementation ------------
|
|
|
|
|
|
|
|
LyXFindReplace0::LyXFindReplace0()
|
|
|
|
{
|
|
|
|
fCaseSensitive = false;
|
|
|
|
fMatchWord = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXFindReplace0::StartSearch()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
FD_form_search *fd_fs = fd_form_search;
|
|
|
|
|
|
|
|
if (fd_fs->form_search->visible) {
|
|
|
|
fl_raise_form(fd_fs->form_search);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_fs->form_search,
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
|
|
|
|
_("Find & Replace")); // RVDK_PATCH_5
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_search->form_search->w;
|
|
|
|
oh = fd_form_search->form_search->h;
|
|
|
|
}
|
|
|
|
fl_set_form_minsize(fd_form_search->form_search, ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
ReInitFromForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXFindReplace0::ReInitFromForm()
|
|
|
|
{
|
|
|
|
FD_form_search *fd_fs = fd_form_search;
|
|
|
|
|
|
|
|
lsSearch = fl_get_input(fd_fs->input_search);
|
|
|
|
fCaseSensitive = fl_get_button(fd_fs->btnCaseSensitive);
|
|
|
|
fMatchWord = fl_get_button(fd_fs->btnMatchWord);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the value of the replace string in the form
|
1999-10-02 16:21:10 +00:00
|
|
|
string const LyXFindReplace0::ReplaceString()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
return string(fl_get_input(fd_form_search->input_replace));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXFindReplace0::SearchCancelCB()
|
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_search->form_search);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXFindReplace0::SetReplaceEnabled(bool fEnable)
|
|
|
|
{
|
|
|
|
FD_form_search *fd_fs = fd_form_search;
|
|
|
|
fReplaceEnabled = fEnable;
|
|
|
|
if (fEnable) {
|
|
|
|
fl_activate_object(fd_fs->replace_button);
|
|
|
|
fl_activate_object(fd_fs->replaceall_button);
|
|
|
|
fl_activate_object(fd_fs->input_replace);
|
|
|
|
fl_set_object_lcol(fd_fs->replace_button, FL_BLACK);
|
|
|
|
fl_set_object_lcol(fd_fs->replaceall_button, FL_BLACK);
|
|
|
|
fl_set_object_lcol(fd_fs->input_replace, FL_BLACK);
|
|
|
|
} else {
|
|
|
|
fl_deactivate_object(fd_fs->replace_button);
|
|
|
|
fl_deactivate_object(fd_fs->replaceall_button);
|
|
|
|
fl_deactivate_object(fd_fs->input_replace);
|
1999-11-15 12:01:38 +00:00
|
|
|
fl_set_object_lcol(fd_fs->replace_button, FL_INACTIVE);
|
|
|
|
fl_set_object_lcol(fd_fs->replaceall_button, FL_INACTIVE);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_object_lcol(fd_fs->input_replace, FL_INACTIVE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
void LyXFindReplace0::SetSearchString(string const &ls)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
lsSearch = ls;
|
|
|
|
fl_set_input(fd_form_search->input_search, ls.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
//HB??: Maybe _FR.StartSearch should be called in lyxfunc.C instead of MenuSearch() ?
|
|
|
|
|
|
|
|
void MenuSearch()
|
|
|
|
{
|
|
|
|
_FR.StartSearch();
|
|
|
|
}
|