2001-06-14 08:20:41 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
/**
|
|
|
|
* \file lyxfind.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author John Levon
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
2003-11-04 12:01:15 +00:00
|
|
|
* \author Alfredo Braunstein
|
2008-11-15 23:30:27 +00:00
|
|
|
* \author Tommaso Cucinotta
|
2003-08-23 00:17:00 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2001-03-06 10:20:33 +00:00
|
|
|
#ifndef LYXFIND_H
|
|
|
|
#define LYXFIND_H
|
|
|
|
|
2007-10-31 22:40:34 +00:00
|
|
|
#include "support/strfwd.h"
|
2003-10-07 06:45:25 +00:00
|
|
|
|
2008-11-15 23:30:27 +00:00
|
|
|
// FIXME
|
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2008-11-15 23:30:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Buffer;
|
2001-03-06 10:20:33 +00:00
|
|
|
class BufferView;
|
2008-11-15 23:30:27 +00:00
|
|
|
class DocIterator;
|
2004-01-07 17:00:03 +00:00
|
|
|
class FuncRequest;
|
2007-04-29 23:33:02 +00:00
|
|
|
class Text;
|
2001-03-06 10:20:33 +00:00
|
|
|
|
2004-01-07 17:00:03 +00:00
|
|
|
/** Encode the parameters needed to find \c search as a string
|
|
|
|
* that can be dispatched to the LyX core in a FuncRequest wrapper.
|
2003-11-04 12:01:15 +00:00
|
|
|
*/
|
2006-12-10 11:52:46 +00:00
|
|
|
docstring const find2string(docstring const & search,
|
2004-01-07 17:00:03 +00:00
|
|
|
bool casesensitive,
|
|
|
|
bool matchword,
|
|
|
|
bool forward);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2004-01-07 17:00:03 +00:00
|
|
|
/** Encode the parameters needed to replace \c search with \c replace
|
|
|
|
* as a string that can be dispatched to the LyX core in a FuncRequest
|
|
|
|
* wrapper.
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
2009-07-04 23:02:27 +00:00
|
|
|
docstring const replace2string(docstring const & replace,
|
|
|
|
docstring const & search,
|
2004-01-07 17:00:03 +00:00
|
|
|
bool casesensitive,
|
|
|
|
bool matchword,
|
|
|
|
bool all,
|
2011-05-18 20:33:57 +00:00
|
|
|
bool forward,
|
|
|
|
bool findnext = true);
|
2003-11-04 12:01:15 +00:00
|
|
|
|
2004-01-07 17:00:03 +00:00
|
|
|
/** Parse the string encoding of the find request that is found in
|
|
|
|
* \c ev.argument and act on it.
|
|
|
|
* The string is encoded by \c find2string.
|
2008-02-10 18:52:32 +00:00
|
|
|
* \return true if the string was found.
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
2010-10-13 18:53:41 +00:00
|
|
|
bool lyxfind(BufferView * bv, FuncRequest const & ev);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2004-01-07 17:00:03 +00:00
|
|
|
/** Parse the string encoding of the replace request that is found in
|
|
|
|
* \c ev.argument and act on it.
|
|
|
|
* The string is encoded by \c replace2string.
|
2010-10-13 18:53:41 +00:00
|
|
|
* \return whether we did anything
|
2004-01-07 17:00:03 +00:00
|
|
|
*/
|
2010-10-14 14:32:58 +00:00
|
|
|
bool lyxreplace(BufferView * bv,
|
|
|
|
FuncRequest const &, bool has_deleted = false);
|
2001-03-06 10:20:33 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
/// find the next change in the buffer
|
|
|
|
bool findNextChange(BufferView * bv);
|
2003-03-04 09:27:27 +00:00
|
|
|
|
2009-04-05 19:11:25 +00:00
|
|
|
/// find the previous change in the buffer
|
|
|
|
bool findPreviousChange(BufferView * bv);
|
|
|
|
|
2009-01-14 15:34:56 +00:00
|
|
|
class FindAndReplaceOptions {
|
2008-11-15 23:30:27 +00:00
|
|
|
public:
|
2009-12-30 18:40:18 +00:00
|
|
|
typedef enum {
|
|
|
|
S_BUFFER,
|
|
|
|
S_DOCUMENT,
|
|
|
|
S_OPEN_BUFFERS,
|
2010-01-09 22:49:35 +00:00
|
|
|
S_ALL_MANUALS
|
2009-12-30 18:40:18 +00:00
|
|
|
} SearchScope;
|
2009-01-14 15:34:56 +00:00
|
|
|
FindAndReplaceOptions(
|
2011-02-07 23:55:02 +00:00
|
|
|
docstring const & find_buf_name,
|
2008-12-20 16:00:47 +00:00
|
|
|
bool casesensitive,
|
|
|
|
bool matchword,
|
|
|
|
bool forward,
|
|
|
|
bool expandmacros,
|
|
|
|
bool ignoreformat,
|
2011-02-07 23:55:02 +00:00
|
|
|
docstring const & repl_buf_name,
|
2009-12-30 18:40:18 +00:00
|
|
|
bool keep_case,
|
|
|
|
SearchScope scope = S_BUFFER
|
2008-12-20 16:00:47 +00:00
|
|
|
);
|
2009-01-14 15:34:56 +00:00
|
|
|
FindAndReplaceOptions() { }
|
2011-02-07 23:55:02 +00:00
|
|
|
docstring find_buf_name;
|
2008-12-20 16:00:47 +00:00
|
|
|
bool casesensitive;
|
|
|
|
bool matchword;
|
|
|
|
bool forward;
|
|
|
|
bool expandmacros;
|
|
|
|
bool ignoreformat;
|
2011-02-07 23:55:02 +00:00
|
|
|
/// This is docstring() if no replace was requested
|
|
|
|
docstring repl_buf_name;
|
2009-08-20 00:28:34 +00:00
|
|
|
bool keep_case;
|
2009-12-30 18:40:18 +00:00
|
|
|
SearchScope scope;
|
2008-11-15 23:30:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Write a FindAdvOptions instance to a stringstream
|
2009-01-14 15:34:56 +00:00
|
|
|
std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
|
2008-11-15 23:30:27 +00:00
|
|
|
|
|
|
|
/// Read a FindAdvOptions instance from a stringstream
|
2009-01-14 15:34:56 +00:00
|
|
|
std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
|
2008-11-15 23:30:27 +00:00
|
|
|
|
|
|
|
/// Perform a FindAdv operation.
|
2009-01-14 15:34:56 +00:00
|
|
|
bool findAdv(BufferView * bv, FindAndReplaceOptions const & opt);
|
2008-11-15 23:30:27 +00:00
|
|
|
|
|
|
|
/** Computes the simple-text or LaTeX export (depending on opt) of buf starting
|
|
|
|
** from cur and ending len positions after cur, if len is positive, or at the
|
|
|
|
** paragraph or innermost inset end if len is -1.
|
|
|
|
**
|
|
|
|
** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
|
|
|
|
** Ideally, this should not be needed, and the opt.search field should become a Text const &.
|
|
|
|
**/
|
2008-12-20 16:00:47 +00:00
|
|
|
docstring stringifyFromForSearch(
|
2009-01-14 15:34:56 +00:00
|
|
|
FindAndReplaceOptions const & opt,
|
2008-12-20 16:00:47 +00:00
|
|
|
DocIterator const & cur,
|
|
|
|
int len = -1);
|
2008-11-15 23:30:27 +00:00
|
|
|
|
2003-07-27 12:02:58 +00:00
|
|
|
} // namespace lyx
|
2003-03-04 09:27:27 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
#endif // LYXFIND_H
|