+2001-03-05 Edwin Leuven <leuven@fee.uva.nl>
+
+ * form1.fd: search_form deleted
+
2001-02-26 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* layout_forms.fd: delete
Internal Form Definition File
(do not change)
-Number of forms: 4
+Number of forms: 3
Unit of measure: FL_COORD_PIXEL
=============== FORM ===============
--------------------
class: FL_BEGIN_GROUP
type: 0
-box: 0 10 10 0
+box: 0 0 0 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
--------------------
class: FL_BEGIN_GROUP
type: 0
-box: 0 10 10 0
+box: 0 0 0 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
--------------------
class: FL_BEGIN_GROUP
type: 0
-box: 0 10 10 0
+box: 0 0 0 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
--------------------
class: FL_BEGIN_GROUP
type: 0
-box: 0 10 10 0
+box: 0 0 0 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
callback:
argument:
-=============== FORM ===============
-Name: form_search
-Width: 440
-Height: 160
-Number of Objects: 11
-
---------------------
-class: FL_BOX
-type: UP_BOX
-box: 0 0 440 160
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label:
-shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name:
-callback:
-argument:
-
---------------------
-class: FL_FRAME
-type: ENGRAVED_FRAME
-box: 300 10 130 80
-boxtype: FL_NO_BOX
-colors: FL_BLACK FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label:
-shortcut:
-resize: FL_RESIZE_NONE
-gravity: FL_NorthEast FL_NorthEast
-name:
-callback:
-argument:
-
---------------------
-class: FL_INPUT
-type: NORMAL_INPUT
-box: 110 10 180 30
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Find|#n
-shortcut:
-resize: FL_RESIZE_X
-gravity: FL_NorthWest FL_NorthEast
-name: input_search
-callback:
-argument:
-
---------------------
-class: FL_INPUT
-type: NORMAL_INPUT
-box: 110 40 180 30
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Replace with|#W
-shortcut:
-resize: FL_RESIZE_X
-gravity: FL_NorthWest FL_NorthEast
-name: input_replace
-callback:
-argument:
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 80 90 30
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: @>|#F^s
-shortcut:
-resize: FL_RESIZE_NONE
-gravity: FL_SouthEast FL_SouthEast
-name:
-callback: SearchForwardCB
-argument: 0
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 110 80 90 30
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: @<|#B^r
-shortcut:
-resize: FL_RESIZE_NONE
-gravity: FL_SouthEast FL_SouthEast
-name:
-callback: SearchBackwardCB
-argument: 0
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 110 120 90 30
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Replace|#R#r
-shortcut:
-resize: FL_RESIZE_NONE
-gravity: FL_SouthEast FL_SouthEast
-name: replace_button
-callback: SearchReplaceCB
-argument: 0
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 350 120 80 30
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Close|^[
-shortcut:
-resize: FL_RESIZE_NONE
-gravity: FL_SouthEast FL_SouthEast
-name:
-callback: SearchCancelCB
-argument: 0
-
---------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 300 20 150 30
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Case sensitive|#s#S
-shortcut:
-resize: FL_RESIZE_NONE
-gravity: FL_NorthEast FL_NorthEast
-name: btnCaseSensitive
-callback:
-argument: 0
-
---------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 300 50 150 30
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Match word|#M#m
-shortcut:
-resize: FL_RESIZE_NONE
-gravity: FL_NorthEast FL_NorthEast
-name: btnMatchWord
-callback:
-argument: 0
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 120 90 30
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Replace All|#A#a
-shortcut:
-resize: FL_RESIZE_NONE
-gravity: FL_SouthEast FL_SouthEast
-name: replaceall_button
-callback: SearchReplaceAllCB
-argument: 0
-
==============================
--------------------
src/frontends/kde/tabcreatedlg.C
src/frontends/kde/tocdlg.C
src/frontends/kde/urldlg.C
+src/frontends/qt2/FormCharacter.C
src/frontends/qt2/FormCopyright.C
src/frontends/qt2/FormParagraph.C
src/frontends/qt2/FormPrint.C
src/frontends/qt2/paragraphdlgimpl.C
src/frontends/qt2/tabularcreatedlgimpl.C
src/frontends/xforms/FormBase.h
-src/frontends/xforms/FormBibitem.C
src/frontends/xforms/form_bibitem.C
-src/frontends/xforms/FormBibtex.C
+src/frontends/xforms/FormBibitem.C
src/frontends/xforms/form_bibtex.C
+src/frontends/xforms/FormBibtex.C
src/frontends/xforms/form_browser.C
-src/frontends/xforms/FormCharacter.C
src/frontends/xforms/form_character.C
-src/frontends/xforms/FormCitation.C
+src/frontends/xforms/FormCharacter.C
src/frontends/xforms/form_citation.C
-src/frontends/xforms/FormCopyright.C
+src/frontends/xforms/FormCitation.C
src/frontends/xforms/form_copyright.C
-src/frontends/xforms/FormDocument.C
+src/frontends/xforms/FormCopyright.C
src/frontends/xforms/form_document.C
-src/frontends/xforms/FormError.C
+src/frontends/xforms/FormDocument.C
src/frontends/xforms/form_error.C
-src/frontends/xforms/FormGraphics.C
+src/frontends/xforms/FormError.C
src/frontends/xforms/form_graphics.C
-src/frontends/xforms/FormInclude.C
+src/frontends/xforms/FormGraphics.C
src/frontends/xforms/form_include.C
-src/frontends/xforms/FormIndex.C
+src/frontends/xforms/FormInclude.C
src/frontends/xforms/form_index.C
+src/frontends/xforms/FormIndex.C
src/frontends/xforms/FormInset.h
src/frontends/xforms/FormLog.C
-src/frontends/xforms/FormParagraph.C
src/frontends/xforms/form_paragraph.C
-src/frontends/xforms/FormPreamble.C
+src/frontends/xforms/FormParagraph.C
src/frontends/xforms/form_preamble.C
-src/frontends/xforms/FormPreferences.C
+src/frontends/xforms/FormPreamble.C
src/frontends/xforms/form_preferences.C
-src/frontends/xforms/FormPrint.C
+src/frontends/xforms/FormPreferences.C
src/frontends/xforms/form_print.C
-src/frontends/xforms/FormRef.C
+src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_ref.C
+src/frontends/xforms/FormRef.C
+src/frontends/xforms/form_search.C
+src/frontends/xforms/FormSearch.C
src/frontends/xforms/FormSplash.C
-src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular.C
-src/frontends/xforms/FormTabularCreate.C
+src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular_create.C
-src/frontends/xforms/FormToc.C
+src/frontends/xforms/FormTabularCreate.C
src/frontends/xforms/form_toc.C
-src/frontends/xforms/FormUrl.C
+src/frontends/xforms/FormToc.C
src/frontends/xforms/form_url.C
+src/frontends/xforms/FormUrl.C
src/frontends/xforms/FormVCLog.C
src/frontends/xforms/input_validators.C
src/frontends/xforms/Menubar_pimpl.C
-src/frontends/xforms/xform_helpers.C
+src/frontends/xforms/xforms_helpers.C
src/gettext.h
src/importer.C
src/insets/figinset.C
src/LyXAction.C
src/lyx.C
src/lyx_cb.C
+src/lyxfind.C
src/lyxfont.C
src/lyxfr0.C
src/lyxfr1.C
+2001-03-06 Juergen Vigna <jug@sad.it>
+
+ * lyxfind.C (IsStringInText): put parentes around expressions.
+
+2001-03-05 Edwin Leuven <leuven@fee.uva.nl>
+
+ * lyxfind.[Ch]: find stuff moved out of text2.C/lyxtext.h
+
2001-02-23 John Levon <moz@compsoc.man.ac.uk>
* lyx_main.C: add ISO_Left_Tab as bind synonym for Tab
lyxcursor.h \
lyxfont.C \
lyxfont.h \
- lyxfr0.C \
- lyxfr0.h \
- lyxfr1.C \
- lyxfr1.h \
+ lyxfind.C \
+ lyxfind.h \
lyxfunc.C \
lyxfunc.h \
lyxlex.C \
}
/*---------------------------------------*/
-FD_form_search *create_form_form_search(void)
-{
- FL_OBJECT *obj;
- FD_form_search *fdui = (FD_form_search *) fl_calloc(1, sizeof(FD_form_search));
-
- fdui->form_search = fl_bgn_form(FL_NO_BOX, 440, 160);
- obj = fl_add_box(FL_UP_BOX, 0, 0, 440, 160, "");
- obj = fl_add_frame(FL_ENGRAVED_FRAME, 300, 10, 130, 80, "");
- fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
- fdui->input_search = obj = fl_add_input(FL_NORMAL_INPUT, 110, 10, 180, 30, idex(_("Find|#n")));fl_set_button_shortcut(obj, scex(_("Find|#n")), 1);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
- fl_set_object_resize(obj, FL_RESIZE_X);
- fdui->input_replace = obj = fl_add_input(FL_NORMAL_INPUT, 110, 40, 180, 30, idex(_("Replace with|#W")));fl_set_button_shortcut(obj, scex(_("Replace with|#W")), 1);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
- fl_set_object_resize(obj, FL_RESIZE_X);
- obj = fl_add_button(FL_NORMAL_BUTTON, 200, 80, 90, 30, idex(_("@>|#F^s")));fl_set_button_shortcut(obj, scex(_("@>|#F^s")), 1);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, SearchForwardCB, 0);
- obj = fl_add_button(FL_NORMAL_BUTTON, 110, 80, 90, 30, idex(_("@<|#B^r")));fl_set_button_shortcut(obj, scex(_("@<|#B^r")), 1);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, SearchBackwardCB, 0);
- fdui->replace_button = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 120, 90, 30, idex(_("Replace|#R#r")));fl_set_button_shortcut(obj, scex(_("Replace|#R#r")), 1);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, SearchReplaceCB, 0);
- obj = fl_add_button(FL_NORMAL_BUTTON, 350, 120, 80, 30, idex(_("Close|^[")));fl_set_button_shortcut(obj, scex(_("Close|^[")), 1);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, SearchCancelCB, 0);
- fdui->btnCaseSensitive = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 300, 20, 150, 30, idex(_("Case sensitive|#s#S")));fl_set_button_shortcut(obj, scex(_("Case sensitive|#s#S")), 1);
- fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
- fdui->btnMatchWord = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 300, 50, 150, 30, idex(_("Match word|#M#m")));fl_set_button_shortcut(obj, scex(_("Match word|#M#m")), 1);
- fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
- fdui->replaceall_button = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 120, 90, 30, idex(_("Replace All|#A#a")));fl_set_button_shortcut(obj, scex(_("Replace All|#A#a")), 1);
- fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
- fl_set_object_callback(obj, SearchReplaceAllCB, 0);
- fl_end_form();
-
- fdui->form_search->fdui = fdui;
-
- return fdui;
-}
-/*---------------------------------------*/
-
extern "C" void GraphicsCB(FL_OBJECT *, long);
-extern "C" void SearchForwardCB(FL_OBJECT *, long);
-extern "C" void SearchBackwardCB(FL_OBJECT *, long);
-extern "C" void SearchReplaceCB(FL_OBJECT *, long);
-extern "C" void SearchCancelCB(FL_OBJECT *, long);
-extern "C" void SearchReplaceAllCB(FL_OBJECT *, long);
-
-
/**** Forms and Objects ****/
typedef struct {
FL_FORM *KeyMap;
FL_OBJECT *replaceall_button;
} FD_form_search;
-extern FD_form_search * create_form_form_search(void);
-
#endif /* FD_KeyMap_h_ */
Signal1<void, InsetCommand *> showRef;
///
Signal1<void, string const &> createRef;
+ ///
+ Signal0<void> showSearch;
/// pop up the splash
Signal0<void> showSplash;
/// hide the splash immediately
+2001-03-05 Edwin Leuven <leuven@fee.uva.nl>
+
+ * added find/replace dialog:
+ * FormSearch.*: added
+ * form_search.*: added
+ * forms/form_search.fd: added
+
2001-03-05 Angus Leeming <a.leeming@ic.ac.uk>
* xform_helpers.[Ch]: renamed as xforms_helpers.[Ch].
#include "FormPreferences.h"
#include "FormPrint.h"
#include "FormRef.h"
+#include "FormSearch.h"
#include "FormSplash.h"
#include "FormTabular.h"
#include "FormTabularCreate.h"
dialogs_.push_back(new FormPreferences(lv, this));
dialogs_.push_back(new FormPrint(lv, this));
dialogs_.push_back(new FormRef(lv, this));
+ dialogs_.push_back(new FormSearch(lv, this));
dialogs_.push_back(new FormSplash(lv, this));
dialogs_.push_back(new FormTabular(lv, this));
dialogs_.push_back(new FormTabularCreate(lv, this));
--- /dev/null
+/**
+ * \file FormSearch.C
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Edwin Leuven
+ */
+
+#include <config.h>
+
+#include "FormSearch.h"
+#include "form_search.h"
+#include "gettext.h"
+#include "Dialogs.h"
+#include "Liason.h"
+#include "LyXView.h"
+#include "buffer.h"
+#include "gettext.h"
+#include "lyxfind.h"
+#include "debug.h"
+
+#ifdef CXX_WORKING_NAMESPACES
+using Liason::setMinibuffer;
+#endif
+
+
+FormSearch::FormSearch(LyXView * lv, Dialogs * d)
+ : FormBaseBD(lv, d, _("LyX: Find and Replace"), new NoRepeatedApplyReadOnlyPolicy),
+ dialog_(0)
+{
+ // let the popup be shown
+ // This is a permanent connection so we won't bother
+ // storing a copy because we won't be disconnecting.
+ d->showSearch.connect(slot(this, &FormSearch::show));
+ // perhaps in the future we'd like a
+ // "search again" button/keybinding
+// d->searchAgain.connect(slot(this, &FormSearch::FindNext));
+}
+
+
+FormSearch::~FormSearch()
+{
+ delete dialog_;
+}
+
+
+FL_FORM * FormSearch::form() const
+{
+ if (dialog_)
+ return dialog_->form;
+ return 0;
+}
+
+void FormSearch::build()
+{
+ dialog_ = build_search();
+ // Workaround dumb xforms sizing bug
+ minw_ = form()->w;
+ minh_ = form()->h;
+
+ // Manage the ok, apply and cancel/close buttons
+ bc_.setCancel(dialog_->button_cancel);
+ bc_.addReadOnly(dialog_->input_replace);
+ bc_.addReadOnly(dialog_->replace);
+ bc_.addReadOnly(dialog_->replaceall);
+ bc_.refresh();
+}
+
+void FormSearch::update()
+{
+ if (!dialog_)
+ return;
+
+ bc_.readOnly(lv_->buffer()->isReadonly());
+}
+
+bool FormSearch::input(FL_OBJECT * obj, long)
+{
+ if (obj == dialog_->findnext)
+ Find();
+ else if (obj == dialog_->findprev)
+ Find(false);
+ else if (obj == dialog_->replace)
+ Replace();
+ else if (obj == dialog_->replaceall)
+ Replace(true);
+
+ return 0;
+}
+
+void FormSearch::Find(bool const next = true)
+{
+ bool found = LyXFind(lv_->view(),
+ fl_get_input(dialog_->input_search),
+ fl_get_button(dialog_->casesensitive),
+ fl_get_button(dialog_->matchword),
+ next);
+
+ if (!found)
+ setMinibuffer(lv_, _("String not found!"));
+ };
+
+
+void FormSearch::Replace(bool const all = false)
+{
+ int replace_count = LyXReplace(lv_->view(),
+ fl_get_input(dialog_->input_search),
+ fl_get_input(dialog_->input_replace),
+ fl_get_button(dialog_->casesensitive),
+ fl_get_button(dialog_->matchword),
+ true,
+ all);
+
+ if (replace_count == 0) {
+ setMinibuffer(lv_, _("String not found!"));
+ } else {
+ if (replace_count == 1) {
+ setMinibuffer(lv_, _("String has been replaced."));
+ } else {
+ string str = tostr(replace_count);
+ str += _(" strings have been replaced.");
+ setMinibuffer(lv_, str.c_str());
+ }
+ }
+};
+
+
--- /dev/null
+/**
+ * \file FormSearch.h
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Edwin Leuven
+ */
+
+#ifndef FORMSEARCH_H
+#define FORMSEARCH_H
+
+#include "FormBase.h"
+
+struct FD_form_search;
+class LyXView;
+class Dialogs;
+
+/** This class provides an XForms implementation of the FormSearch Dialog.
+ */
+class FormSearch : public FormBaseBD {
+public:
+ ///
+ FormSearch(LyXView *, Dialogs *);
+ ///
+ ~FormSearch();
+
+private:
+ /** Redraw the form (on receipt of a Signal indicating, for example,
+ * that the xform colours have been re-mapped).
+ */
+
+ /// Filter the inputs
+ virtual bool input(FL_OBJECT *, long);
+
+ /// Build the popup
+ virtual void build();
+
+ /// Update the popup
+ virtual void update();
+
+ /// Searches occurance of string
+ /// if argument=true forward search otherwise backward search
+ void Find(bool const = true);
+ /// if argument=false replace once otherwise replace all
+ /// Replaces occurance of string
+ void Replace(bool const = false);
+
+ ///
+ virtual FL_FORM * form() const;
+
+ /// Typedefinitions from the fdesign produced Header file
+ FD_form_search * build_search();
+
+ /// Real GUI implementation.
+ FD_form_search * dialog_;
+};
+
+#endif
FormRef.h \
form_ref.C \
form_ref.h \
+ FormSearch.C \
+ FormSearch.h \
+ form_search.C \
+ form_search.h \
FormSplash.C \
FormSplash.h \
form_splash.C \
--- /dev/null
+// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
+#include <config.h>
+#include "lyx_gui_misc.h"
+#include "gettext.h"
+
+/* Form definition file generated with fdesign. */
+
+#include FORMS_H_LOCATION
+#include <stdlib.h>
+#include "form_search.h"
+#include "FormSearch.h"
+
+FD_form_search::~FD_form_search()
+{
+ if ( form->visible ) fl_hide_form( form );
+ fl_free_form( form );
+}
+
+
+FD_form_search * FormSearch::build_search()
+{
+ FL_OBJECT *obj;
+ FD_form_search *fdui = new FD_form_search;
+
+ fdui->form = fl_bgn_form(FL_NO_BOX, 440, 160);
+ fdui->form->u_vdata = this;
+ obj = fl_add_box(FL_UP_BOX, 0, 0, 440, 160, "");
+ obj = fl_add_frame(FL_ENGRAVED_FRAME, 300, 10, 130, 80, "");
+ fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
+ {
+ char const * const dummy = N_("Find|#n");
+ fdui->input_search = obj = fl_add_input(FL_NORMAL_INPUT, 110, 10, 180, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
+ fl_set_object_resize(obj, FL_RESIZE_X);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ {
+ char const * const dummy = N_("Replace with|#W");
+ fdui->input_replace = obj = fl_add_input(FL_NORMAL_INPUT, 110, 40, 180, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
+ fl_set_object_resize(obj, FL_RESIZE_X);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ {
+ char const * const dummy = N_(" >|#F^s");
+ fdui->findnext = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 80, 90, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ {
+ char const * const dummy = N_(" <|#B^r");
+ fdui->findprev = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 80, 90, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ {
+ char const * const dummy = N_("Replace|#R#r");
+ fdui->replace = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 120, 90, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ {
+ char const * const dummy = N_("Close|^[");
+ fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 350, 120, 80, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
+ fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
+ {
+ char const * const dummy = N_("Case sensitive|#s#S");
+ fdui->casesensitive = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 300, 20, 150, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ {
+ char const * const dummy = N_("Match word|#M#m");
+ fdui->matchword = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 300, 50, 150, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ {
+ char const * const dummy = N_("Replace All|#A#a");
+ fdui->replaceall = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 120, 90, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+ fl_end_form();
+
+ fdui->form->fdui = fdui;
+
+ return fdui;
+}
+/*---------------------------------------*/
+
--- /dev/null
+// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
+/** Header file generated with fdesign **/
+
+#ifndef FD_form_search_h_
+#define FD_form_search_h_
+
+/** Callbacks, globals and object handlers **/
+extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
+extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
+
+
+/**** Forms and Objects ****/
+struct FD_form_search {
+ ~FD_form_search();
+
+ FL_FORM *form;
+ FL_OBJECT *input_search;
+ FL_OBJECT *input_replace;
+ FL_OBJECT *findnext;
+ FL_OBJECT *findprev;
+ FL_OBJECT *replace;
+ FL_OBJECT *button_cancel;
+ FL_OBJECT *casesensitive;
+ FL_OBJECT *matchword;
+ FL_OBJECT *replaceall;
+};
+
+#endif /* FD_form_search_h_ */
--- /dev/null
+Magic: 13000
+
+Internal Form Definition File
+ (do not change)
+
+Number of forms: 1
+Unit of measure: FL_COORD_PIXEL
+
+=============== FORM ===============
+Name: form_search
+Width: 440
+Height: 160
+Number of Objects: 11
+
+--------------------
+class: FL_BOX
+type: UP_BOX
+box: 0 0 440 160
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label:
+shortcut:
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name:
+callback:
+argument:
+
+--------------------
+class: FL_FRAME
+type: ENGRAVED_FRAME
+box: 300 10 130 80
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label:
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_NorthEast FL_NorthEast
+name:
+callback:
+argument:
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 110 10 180 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Find|#n
+shortcut:
+resize: FL_RESIZE_X
+gravity: FL_NorthWest FL_NorthEast
+name: input_search
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 110 40 180 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Replace with|#W
+shortcut:
+resize: FL_RESIZE_X
+gravity: FL_NorthWest FL_NorthEast
+name: input_replace
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 80 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: >|#F^s
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: findnext
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 110 80 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: <|#B^r
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: findprev
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 110 120 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Replace|#R#r
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: replace
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 350 120 80 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Close|^[
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: button_cancel
+callback: C_FormBaseCancelCB
+argument: 0
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 300 20 150 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Case sensitive|#s#S
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_NorthEast FL_NorthEast
+name: casesensitive
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 300 50 150 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Match word|#M#m
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_NorthEast FL_NorthEast
+name: matchword
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 200 120 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Replace All|#A#a
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: replaceall
+callback: C_FormBaseInputCB
+argument: 0
+
+==============================
+--------------------
form_preferences.fd \
form_print.fd \
form_ref.fd \
+ form_search.fd \
form_splash.fd \
form_tabular.fd \
form_tabular_create.fd \
--- /dev/null
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "lyxtext.h"
+#include "lyxfind.h"
+#include "LyXView.h"
+#include "minibuffer.h"
+#include "lyx_gui_misc.h"
+#include "support/textutils.h"
+#include "support/lstrings.h"
+#include "BufferView.h"
+#include "buffer.h"
+
+int LyXReplace(BufferView * bv,
+ string const & searchstr,
+ string const & replacestr,
+ bool const & casesens,
+ bool const & matchwrd,
+ bool const & forward,
+ bool const & replaceall=false)
+{
+ int replace_count = 0;
+
+ if (!bv->available() || bv->buffer()->isReadonly())
+ return replace_count;
+
+ // CutSelection cannot cut a single space, so we have to stop
+ // in order to avoid endless loop :-(
+ if (searchstr.length() == 0
+ || (searchstr.length() == 1 && searchstr[0] == ' ')) {
+ WriteAlert(_("Sorry!"), _("You cannot replace a single space, "
+ "nor an empty character."));
+ return replace_count;
+ }
+ // now we can start searching for the first
+ // start at top if replaceall
+ bool fw = forward;
+ if (replaceall) {
+ bv->text->ClearSelection(bv);
+ bv->text->CursorTop(bv);
+ // override search direction because we search top to bottom
+ fw = true;
+ }
+
+ // if nothing selected or selection does not equal search string
+ // search and select next occurance and return if no replaceall
+ if (searchstr!=bv->text->selectionAsString(bv->buffer())) {
+ LyXFind(bv, searchstr, casesens, matchwrd, fw);
+ if (!replaceall)
+ return replace_count;
+ }
+
+ bool found;
+ do {
+ bv->hideCursor();
+ bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
+ bv->toggleSelection(false);
+ bv->text->ReplaceSelectionWithString(bv, replacestr);
+ bv->text->SetSelectionOverString(bv, replacestr);
+ bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ ++replace_count;
+ found = LyXFind(bv, searchstr, casesens, matchwrd, fw);
+ } while (replaceall && found);
+
+ if (bv->focus())
+ bv->showCursor();
+
+ return replace_count;
+}
+
+bool LyXFind(BufferView * bv,
+ string const & searchstr,
+ bool const & casesens,
+ bool const & matchwrd,
+ bool const & forward)
+{
+ bool found = false;
+
+ if (!bv->available() || searchstr.empty())
+ return found;
+
+ bv->hideCursor();
+ bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
+
+ LyXText * ltCur = bv->text;
+ if (ltCur->selection)
+ ltCur->cursor = forward ? ltCur->sel_end_cursor
+ : ltCur->sel_start_cursor;
+
+ if (forward
+ ? SearchForward(bv, searchstr, casesens, matchwrd)
+ : SearchBackward(bv, searchstr, casesens, matchwrd)) {
+ bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
+ bv->toggleSelection();
+ bv->text->ClearSelection(bv);
+ bv->text->SetSelectionOverString(bv, searchstr);
+ bv->toggleSelection(false);
+ found = true;
+ };
+
+ if (bv->focus())
+ bv->showCursor();
+
+ return found;
+}
+
+
+// returns true if the specified string is at the specified position
+bool IsStringInText(LyXParagraph * par, LyXParagraph::size_type pos,
+ string const & str, bool const & cs = true,
+ bool const & mw = false)
+{
+ if (!par)
+ return false;
+
+ string::size_type size = str.length();
+ LyXParagraph::size_type i = 0;
+ while (((pos + i) < par->Last())
+ && (string::size_type(i) < size)
+ && (cs ? (str[i] == par->GetChar(pos + i))
+ : (toupper(str[i]) == toupper(par->GetChar(pos + i)))))
+ {
+ ++i;
+ }
+ if (size == string::size_type(i)) {
+ // if necessary, check whether string matches word
+ if (!mw ||
+ (mw && ((pos <= 0 || !IsLetterCharOrDigit(par->GetChar(pos - 1)))
+ && (pos + size >= par->Last()
+ || !IsLetterCharOrDigit(par->GetChar(pos + size))))
+ )
+ )
+ return true;
+ }
+ return false;
+}
+
+// forward search:
+// if the string can be found: return true and set the cursor to
+// the new position, cs = casesensitive, mw = matchword
+bool SearchForward(BufferView * bv, string const & str,
+ bool const & cs = true, bool const & mw = false)
+{
+ LyXParagraph * par = bv->text->cursor.par();
+ LyXParagraph::size_type pos = bv->text->cursor.pos();
+
+ while (par && !IsStringInText(par, pos, str, cs, mw)) {
+ if (pos < par->Last() - 1)
+ ++pos;
+ else {
+ pos = 0;
+ par = par->Next();
+ }
+ }
+ if (par) {
+ bv->text->SetCursor(bv, par, pos);
+ return true;
+ }
+ else
+ return false;
+}
+
+
+// backward search:
+// if the string can be found: return true and set the cursor to
+// the new position, cs = casesensitive, mw = matchword
+bool SearchBackward(BufferView * bv, string const & str,
+ bool const & cs = true, bool const & mw = false)
+{
+ LyXParagraph * par = bv->text->cursor.par();
+ LyXParagraph::size_type pos = bv->text->cursor.pos();
+
+ do {
+ if (pos > 0)
+ --pos;
+ else {
+ // We skip empty paragraphs (Asger)
+ do {
+ par = par->Previous();
+ if (par)
+ pos = par->Last() - 1;
+ } while (par && pos < 0);
+ }
+ } while (par && !IsStringInText(par, pos, str, cs, mw));
+
+ if (par) {
+ bv->text->SetCursor(bv, par, pos);
+ return true;
+ } else
+ return false;
+}
+
--- /dev/null
+#ifndef LYXFIND_H
+#define LYXFIND_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+#include "lyxparagraph.h"
+
+class BufferView;
+
+int LyXReplace(BufferView * bv, string const &, string const &,
+ bool const &, bool const &, bool const &, bool const & = false);
+
+bool LyXFind(BufferView * bv, string const &, bool const &, bool const &,
+ bool const &);
+
+/// returns true if the specified string is at the specified position
+bool IsStringInText(LyXParagraph * par, LyXParagraph::size_type pos,
+ string const & str, bool const & = true,
+ bool const & = false);
+
+/// if the string is found: return true and set the cursor to the new position
+bool SearchForward(BufferView *, string const & str, bool const & = true,
+ bool const & = false);
+///
+bool SearchBackward(BufferView *, string const & str, bool const & = true,
+ bool const & = false);
+
+
+#endif
+++ /dev/null
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich,
- * Copyright 1995-2000 The LyX Team.
- *
- * ====================================================== */
-
-#include <config.h>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "lyxfr0.h"
-#include "lyxfr1.h"
-#include "lyx_gui_misc.h"
-#include "frontends/Dialogs.h" // redrawGUI
-
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::slot;
-#endif
-
-// callbacks for form form_search
-void SearchCancelCB(FL_OBJECT * ob, long)
-{
- fl_hide_form(ob->form);
-}
-
-
-void SearchForwardCB(FL_OBJECT * ob, long)
-{
- LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
- lfr->SearchCB(true);
-}
-
-
-void SearchBackwardCB(FL_OBJECT * ob, long)
-{
- LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
- lfr->SearchCB(false);
-}
-
-
-void SearchReplaceAllCB(FL_OBJECT * ob, long)
-{
- LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
- lfr->SearchReplaceAllCB();
-}
-
-
-void SearchReplaceCB(FL_OBJECT * ob, long)
-{
- LyXFindReplace * lfr = static_cast<LyXFindReplace*>(ob->form->u_vdata);
- lfr->SearchReplaceCB();
-}
-
-
-
-SearchForm::SearchForm()
- : search_form(0)
-{
- r_ = Dialogs::redrawGUI.connect(slot(this, &SearchForm::redraw));
-}
-
-
-SearchForm::~SearchForm()
-{
- // The search_form should be closed and freed when SearchForm
- // is destructed.
- r_.disconnect();
-}
-
-
-void SearchForm::redraw()
-{
- if (search_form && search_form->form_search->visible)
- fl_redraw_form(search_form->form_search);
-}
-
-
-void SearchForm::SearchCancelCB()
-{
- fl_hide_form(search_form->form_search);
-}
-
-
-void SearchForm::StartSearch(LyXFindReplace * lfr)
-{
- static int ow = -1, oh;
-
- if (!search_form) {
- search_form = create_form_form_search();
- fl_set_form_atclose(search_form->form_search,
- CancelCloseBoxCB, 0);
- }
- // Set the u_vdata
- search_form->form_search->u_vdata = lfr;
-
-
- if (search_form->form_search->visible) {
- fl_raise_form(search_form->form_search);
- } else {
- fl_show_form(search_form->form_search,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
- _("Find & Replace")); // RVDK_PATCH_5
- if (ow < 0) {
- ow = search_form->form_search->w;
- oh = search_form->form_search->h;
- }
- fl_set_form_minsize(search_form->form_search, ow, oh);
- }
-}
-
-
-// Returns the value of the replace string in the form
-string const SearchForm::ReplaceString() const
-{
- return fl_get_input(search_form->input_replace);
-}
-
-
-void SearchForm::replaceEnabled(bool fEnable)
-{
- fReplaceEnabled = fEnable;
- if (fEnable) {
- fl_activate_object(search_form->replace_button);
- fl_activate_object(search_form->replaceall_button);
- fl_activate_object(search_form->input_replace);
- fl_set_object_lcol(search_form->replace_button, FL_BLACK);
- fl_set_object_lcol(search_form->replaceall_button, FL_BLACK);
- fl_set_object_lcol(search_form->input_replace, FL_BLACK);
- } else {
- fl_deactivate_object(search_form->replace_button);
- fl_deactivate_object(search_form->replaceall_button);
- fl_deactivate_object(search_form->input_replace);
- fl_set_object_lcol(search_form->replace_button, FL_INACTIVE);
- fl_set_object_lcol(search_form->replaceall_button, FL_INACTIVE);
- fl_set_object_lcol(search_form->input_replace, FL_INACTIVE);
- }
-}
-
-
-void SearchForm::SetSearchString(string const & ls)
-{
- fl_set_input(search_form->input_search, ls.c_str());
-}
+++ /dev/null
-// -*- C++ -*-
-#ifndef LYXFR0_H
-#define LYXFR0_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "LString.h"
-#include FORMS_H_LOCATION
-#include "form1.h"
-#include <sigc++/signal_system.h>
-
-class LyXFindReplace;
-
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::Object;
-using SigC::Connection;
-#endif
-
-/**
- The comments below are most likely not valied anymore since
- the rewrite of LyXFindReplace0 and LyXFindReplace1. (Lgb)
-
- LyXFindReplace0
-
- This is a virtual base class. It does not handle text specific
- items. It only manages the Find & Replace form and the variables.
-
- To be added:
-
- - Confirm replace lightbutton (checkbox)
-
- - A history list for search and replace strings.
- These 2 stringlists should match, so that you can replay previous replaces.
- If you select another search string, then the first choice should be the
- replace string you have typed before.
-
- - regex searches (I'm working on that -- dnaber, 1999-02-24)
-
-*/
-class SearchForm : public Object {
-public:
- ///
- SearchForm();
- ///
- ~SearchForm();
-
- ///
- bool CaseSensitive() const {
- return fl_get_button(search_form->btnCaseSensitive);
- }
-
- ///
- bool MatchWord() const {
- return fl_get_button(search_form->btnMatchWord);
- }
-
- ///
- string const SearchString() const {
- return fl_get_input(search_form->input_search);
- }
-
- /// Initialize internal variables and dialog
- void StartSearch(LyXFindReplace *);
-
- ///
- void replaceEnabled(bool fEnabled);
- ///
- bool replaceEnabled() const { return fReplaceEnabled; }
-
- // Callbacks from form
- ///
- void SearchCancelCB();
-
- // Return values
- ///
- void SetSearchString(string const & ls);
- ///
- string const ReplaceString() const;
-
- ///
- bool ValidSearchData() const { return !(SearchString().empty()); }
-private:
- /** Redraw the form (on receipt of a Signal indicating, for example,
- that the xform colors have been re-mapped).
- */
- void redraw();
- ///
- FD_form_search * search_form;
- /// replace buttons enabled?
- bool fReplaceEnabled;
- /// Redraw connection.
- Connection r_;
-};
-
-#endif
+++ /dev/null
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich,
- * Copyright 1995-2000 The LyX Team.
- *
- * ====================================================== */
-
-#include <config.h>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "lyxfr1.h"
-
-#include "lyxtext.h"
-#include "LyXView.h"
-#include "minibuffer.h"
-#include "lyx_gui_misc.h"
-#include "support/textutils.h"
-#include "support/lstrings.h"
-#include "BufferView.h"
-#include "buffer.h"
-
-// Returns the current selection. If nothing is selected or if the selection
-// spans 2 paragraphs, an empty string is returned.
-static
-string GetCurrentSelectionAsString(LyXText * lt)
-{
- string sz;
-
- LyXParagraph * par = lt->cursor.par();
- if (lt->selection && lt->sel_cursor.par() == par) {
- // (selected) and (begin/end in same paragraph)
- LyXParagraph::size_type pos =
- lt->sel_start_cursor.pos();
- LyXParagraph::size_type endpos =
- lt->sel_end_cursor.pos();
- bool fPrevIsSpace = false;
- char ch;
- while (pos < par->Last() && pos < endpos) {
- ch = par->GetChar(pos);
-
- //HB??: Maybe (ch <= ' ')
- if ((ch == ' ') || (ch <= LyXParagraph::META_INSET)) {
- // consecutive spaces --> 1 space char
- if (fPrevIsSpace) {
- ++pos; // Next text pos
- continue; // same search pos
- }
- sz += ' ';
- fPrevIsSpace = true;
- } else {
- sz += ch;
- fPrevIsSpace = false;
- }
- ++pos;
- }
- }
- return sz;
-}
-
-
-// If nothing selected, select the word at the cursor.
-// Returns the current selection
-static inline
-string GetSelectionOrWordAtCursor(BufferView * bv)
-{
- bv->text->SelectWordWhenUnderCursor(bv);
- return GetCurrentSelectionAsString(bv->text);
-}
-
-
-// This is a copy of SetSelectionOverString from text.C
-// It does the same, but uses only the length as a parameter
-static inline
-void SetSelectionOverLenChars(BufferView * bv, int len)
-{
- bv->text->sel_cursor = bv->text->cursor;
- for (int i = 0; i < len; ++i)
- bv->text->CursorRight(bv);
- bv->text->SetSelection(bv);
-}
-
-
-//------------------------------
-
-
-LyXFindReplace::LyXFindReplace()
- : bv(0)
-{}
-
-
-LyXFindReplace::~LyXFindReplace()
-{}
-
-
-void LyXFindReplace::StartSearch(BufferView * b)
-{
- bv = b;
- SF.StartSearch(this);
- SF.replaceEnabled(!bv->buffer()->isReadonly());
- searchForward = true;
- if (SF.SearchString().empty())
- SF.SetSearchString(GetSelectionOrWordAtCursor(bv));
-}
-
-
-// TODO?: the user can insert multiple spaces with this
-// routine (1999-01-11, dnaber)
-void LyXFindReplace::SearchReplaceCB()
-{
- if (!bv->available()) return;
- if (bv->buffer()->isReadonly()) return;
-
- // CutSelection cannot cut a single space, so we have to stop
- // in order to avoid endless loop :-(
- if (SF.SearchString().length() == 0
- || (SF.SearchString().length() == 1
- && SF.SearchString()[0] == ' ')) {
- WriteAlert(_("Sorry!"), _("You cannot replace a single space, "
- "nor an empty character."));
- return;
- }
-
- string const replacestring = SF.ReplaceString();
-
- bv->hideCursor();
- bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
-
- LyXText * ltCur = bv->text;
- if (ltCur->selection) {
- // clear the selection (if there is any)
- bv->toggleSelection(false);
- bv->text->
- ReplaceSelectionWithString(bv, replacestring);
- bv->text->
- SetSelectionOverString(bv, replacestring);
- bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- }
-
- // jump to next match:
- SearchCB(searchForward);
-}
-
-
-// replaces all occurences of a string (1999-01-15, dnaber@mini.gt.owl.de)
-void LyXFindReplace::SearchReplaceAllCB()
-{
- if (!bv->available()) return;
- if (bv->buffer()->isReadonly()) return;
-
- // CutSelection cannot cut a single space, so we have to stop
- // in order to avoid endless loop :-(
- if (SF.SearchString().length() == 0
- || (SF.SearchString().length() == 1
- && SF.SearchString()[0] == ' ')) {
- WriteAlert(_("Sorry!"), _("You cannot replace a single space, "
- "nor an empty character."));
- return;
- }
-
- string const replacestring = SF.ReplaceString();
-
- bv->hideCursor();
-
- // start at top
- bv->text->ClearSelection(bv);
- bv->text->CursorTop(bv);
-
- int replace_count = 0;
- LyXText * ltCur;
- do {
- ltCur = bv->text;
- if (ltCur->selection) {
- bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
- bv->toggleSelection(false);
- bv->text->
- ReplaceSelectionWithString(bv, replacestring);
- bv->text->
- SetSelectionOverString(bv, replacestring);
- bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- ++replace_count;
- }
- } while (SearchCB(true));
- if (replace_count == 0) {
- bv->owner()->getMiniBuffer()->Set(
- _("String not found!"));
- } else {
- if (replace_count == 1) {
- bv->owner()->getMiniBuffer()->Set(
- _("1 string has been replaced."));
- } else {
- string str = tostr(replace_count);
- str += _(" strings have been replaced.");
- bv->owner()->getMiniBuffer()->Set(str);
- }
- }
-}
-
-
-bool LyXFindReplace::SearchCB(bool fForward)
-{
- // store search direction
- searchForward = fForward;
-
- if (!bv->available())
- return false;
-
- bv->hideCursor();
- bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
- LyXText * ltCur = bv->text;
- if (ltCur->selection)
- ltCur->cursor = fForward ? ltCur->sel_end_cursor :
- ltCur->sel_start_cursor;
-
- iLenSelected = SF.SearchString().length();
- bool result;
-
- if (!SF.ValidSearchData() ||
- (fForward ? SearchForward(bv):SearchBackward(bv))) {
- bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
-
- // clear the selection (if there is any)
- bv->toggleSelection();
- bv->text->ClearSelection(bv);
-
- // set the new selection
- SetSelectionOverLenChars(bv, iLenSelected);
- bv->toggleSelection(false);
- bv->owner()->getMiniBuffer()->Set(_("Found."));
- result = true;
- } else {
- bv->owner()->getMiniBuffer()->Set(_("String not found!"));
- result = false;
- }
-
- if (bv->focus())
- bv->showCursor();
-
- return result;
-}
-
-
-// if the string can be found: return true and set the cursor to
-// the new position
-// (was: LyXText::SearchForward(char const* string) in text2.C )
-bool LyXFindReplace::SearchForward(BufferView * bv)
-{
- LyXParagraph * par = bv->text->cursor.par();
- LyXParagraph::size_type pos = bv->text->cursor.pos();
-
- while (par && !IsSearchStringInText(par, pos)) {
- if (pos < par->Last() - 1)
- ++pos;
- else {
- pos = 0;
- par = par->Next();
- }
- }
- if (par) {
- bv->text->SetCursor(bv, par, pos);
- return true;
- } else
- return false;
-}
-
-
-// if the string can be found: return true and set the cursor to
-// the new position
-// (was: LyXText::SearchBackward(char const* string) in text2.C )
-bool LyXFindReplace::SearchBackward(BufferView * bv)
-{
- LyXParagraph * par = bv->text->cursor.par();
- int pos = bv->text->cursor.pos();
-
- do {
- if (pos > 0)
- --pos;
- else {
- // We skip empty paragraphs (Asger)
- do {
- par = par->Previous();
- if (par)
- pos = par->Last() - 1;
- } while (par && pos < 0);
- }
- } while (par && !IsSearchStringInText(par, pos));
-
- if (par) {
- bv->text->SetCursor(bv, par, pos);
- return true;
- } else
- return false;
-}
-
-
-/* Compares 2 char values.
-return value is
- > 0 if chSearch > ch2
- = 0 if chSearch == ch2
- < 0 if chSearch < ch2
-*/
-int LyXFindReplace::CompareChars(char chSearch, char chText) const
-{
- if (SF.CaseSensitive())
- return (chSearch - chText);
- return (toupper(chSearch) - toupper(chText));
-}
-
-
-// returns true if the search string is at the specified position
-// (Copied from the original "LyXText::IsStringInText" in text2.C )
-bool LyXFindReplace::IsSearchStringInText(LyXParagraph * par,
- LyXParagraph::size_type pos) const
-{
- if (!par) return false;
-
- char chSrch = 0;
- char chText;
- bool fPrevIsSpace = false;
- int iText = 0;
- string::size_type iSrch = 0;
- while (pos + iText < par->Last() &&
- iSrch < SF.SearchString().length()) {
- chSrch = SF.SearchString()[iSrch];
- chText = par->GetChar(pos+iText);
- if (chText == ' ') {
- if (fPrevIsSpace) {
- ++iText; // next Text pos
- continue; // same search pos
- }
- fPrevIsSpace = true;
- } else
- fPrevIsSpace = false;
- if (CompareChars(chSrch, chText) != 0)
- break;
-
- ++iSrch;
- ++iText;
- }
-
- if (iSrch < SF.SearchString().length())
- return false;
-
- if (!SF.MatchWord()
- || ((pos <= 0 || !IsLetterCharOrDigit(par->GetChar(pos - 1)))
- && (pos + iText >= par->Last()
- || !IsLetterCharOrDigit(par->GetChar(pos + iText))))) {
- iLenSelected = iText;
- return true;
- }
-
- return false;
-}
+++ /dev/null
-// -*- C++ -*-
-#ifndef LYXFR1_H
-#define LYXFR1_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "lyxparagraph.h"
-#include "lyxfr0.h"
-
-class LyXText;
-
-/** Find and replace in LyXText texts.
-
- This class implements Find & Replace in LyXText texts. It is based on
- LyXFindReplace0, which implements the form related stuff. (see lyxfr0.h)
-*/
-class LyXFindReplace {
-public:
- ///
- LyXFindReplace();
- ///
- ~LyXFindReplace();
-
- /// Initialize internal variables and search form
- void StartSearch(BufferView *);
-
- ///
- bool SearchCB(bool fForward);
- ///
- void SearchReplaceCB();
- ///
- void SearchReplaceAllCB();
-private:
- /// Set by IsSearchStringInText:
- mutable int iLenSelected;
-
- /// Direction we are searching:
- bool searchForward;
-
- ///
- bool SearchForward(BufferView *);
- ///
- bool SearchBackward(BufferView *);
-
- /** Compares 2 char values.
- return value is
- \begin{itemize}
- \item > 0 if ch1 > ch2
- \item = 0 if ch1 == ch2
- \item < 0 if ch1 < ch2
- \end{itemize}
- */
- int CompareChars(char chSearch, char chText) const;
- /// returns true if the specified string is at the specified position
- bool IsSearchStringInText(LyXParagraph * par,
- LyXParagraph::size_type pos) const;
- ///
- SearchForm SF;
- ///
- BufferView * bv;
-};
-#endif
#include "trans_mgr.h"
#include "layout.h"
#include "WorkArea.h"
-#include "lyxfr1.h"
#include "bufferview_funcs.h"
#include "frontends/Dialogs.h"
#include "frontends/Toolbar.h"
#include "importer.h"
#include "FontLoader.h"
#include "TextCache.h"
+#include "lyxfind.h"
using std::pair;
using std::endl;
if (!searched_string.empty() &&
((action == LFUN_WORDFINDBACKWARD) ?
- TEXT()->SearchBackward(owner->view(), searched_string) :
- TEXT()->SearchForward(owner->view(), searched_string))) {
+ SearchBackward(owner->view(), searched_string) :
+ SearchForward(owner->view(), searched_string))) {
// ??? What is that ???
owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
case LFUN_MENUSEARCH:
{
- // Ok this is one _very_ bad solution, but I think that some
- // of this will be rewritten as part of GUI indep anyway.
- // Lgb
- static LyXFindReplace FR_;
- FR_.StartSearch(owner->view());
+ owner->getDialogs()->showSearch();
+ break;
}
break;
/* these things are for search and replace */
- /** returns true if the specified string is at the specified
- position
- */
- bool IsStringInText(LyXParagraph * par,
- LyXParagraph::size_type pos,
- string const & str) const;
/** sets the selection over the number of characters of string,
no check!!
*/
*/
void ReplaceSelectionWithString(BufferView *, string const & str);
- /** if the string can be found: return true and set the cursor to
- the new position */
- bool SearchForward(BufferView *, string const & str) const;
- ///
- bool SearchBackward(BufferView *, string const & str) const;
-
/// needed to insert the selection
void InsertStringA(BufferView *, string const & str);
/// needed to insert the selection
}
-// returns true if the specified string is at the specified position
-bool LyXText::IsStringInText(LyXParagraph * par,
- LyXParagraph::size_type pos,
- string const & str) const
-{
- if (!par)
- return false;
-
- LyXParagraph::size_type i = 0;
- while (pos + i < par->Last()
- && string::size_type(i) < str.length()
- && str[i] == par->GetChar(pos + i)) {
- ++i;
- }
- if (str.length() == string::size_type(i))
- return true;
- return false;
-}
-
-
// sets the selection over the number of characters of string, no check!!
void LyXText::SetSelectionOverString(BufferView * bview, string const & str)
{
}
-// if the string can be found: return true and set the cursor to
-// the new position
-bool LyXText::SearchForward(BufferView * bview, string const & str) const
-{
- LyXParagraph * par = cursor.par();
- LyXParagraph::size_type pos = cursor.pos();
- while (par && !IsStringInText(par, pos, str)) {
- if (pos < par->Last() - 1)
- ++pos;
- else {
- pos = 0;
- par = par->Next();
- }
- }
- if (par) {
- SetCursor(bview, par, pos);
- return true;
- }
- else
- return false;
-}
-
-
-bool LyXText::SearchBackward(BufferView * bview, string const & str) const
-{
- LyXParagraph * par = cursor.par();
- int pos = cursor.pos();
-
- do {
- if (pos > 0)
- --pos;
- else {
- // We skip empty paragraphs (Asger)
- do {
- par = par->Previous();
- if (par)
- pos = par->Last() - 1;
- } while (par && pos < 0);
- }
- } while (par && !IsStringInText(par, pos, str));
-
- if (par) {
- SetCursor(bview, par, pos);
- return true;
- } else
- return false;
-}
-
-
// needed to insert the selection
void LyXText::InsertStringA(BufferView * bview, string const & str)
{