mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Implemented S_OPEN_BUFFERS scope in Advanced Find feature (keep searching and find all occurrences within all open buffers).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32680 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
605ac8e46a
commit
24e2c495fe
@ -167,6 +167,8 @@ void FindAndReplaceWidget::findAndReplace(
|
||||
scope = FindAndReplaceOptions::S_BUFFER;
|
||||
else if (MasterDocument->isChecked())
|
||||
scope = FindAndReplaceOptions::S_DOCUMENT;
|
||||
else if (OpenDocuments->isChecked())
|
||||
scope = FindAndReplaceOptions::S_OPEN_BUFFERS;
|
||||
else
|
||||
LASSERT(false, /**/);
|
||||
LYXERR(Debug::FIND, "FindAndReplaceOptions: "
|
||||
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FindAndReplaceUi</class>
|
||||
<widget class="QWidget" name="FindAndReplaceUi">
|
||||
@ -5,14 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>325</width>
|
||||
<width>327</width>
|
||||
<height>523</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -52,17 +51,15 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>303</width>
|
||||
<height>501</height>
|
||||
<width>307</width>
|
||||
<height>503</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -81,9 +78,7 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -101,9 +96,7 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QFrame" name="replace_frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -127,9 +120,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -181,14 +172,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>237</width>
|
||||
<height>84</height>
|
||||
<width>239</width>
|
||||
<height>79</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -202,9 +191,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -223,9 +210,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -244,9 +229,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -259,9 +242,7 @@
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="keepCaseCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -277,9 +258,7 @@
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="closePB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -301,9 +280,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="find_frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -321,9 +298,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -381,14 +356,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>237</width>
|
||||
<height>85</height>
|
||||
<width>239</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -399,9 +372,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="caseCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -420,9 +391,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -468,9 +437,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -492,9 +459,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -516,9 +481,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -541,9 +504,7 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -569,9 +530,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -607,9 +566,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -631,9 +588,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -655,9 +610,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -673,12 +626,10 @@
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="OpenDocuments">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -697,9 +648,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -718,9 +667,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -736,9 +683,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>1</vsizetype>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "lyxfind.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferList.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BufferView.h"
|
||||
@ -1005,6 +1006,42 @@ bool prev_document_buffer(Buffer * & p_buf) {
|
||||
}
|
||||
|
||||
|
||||
/** Switch p_buf to point to next open buffer.
|
||||
**
|
||||
** Return true if restarted from first open buffer.
|
||||
**/
|
||||
bool next_open_buffer(Buffer * & p_buf) {
|
||||
BufferList::const_iterator it = find(theBufferList().begin(), theBufferList().end(), p_buf);
|
||||
LASSERT(it != theBufferList().end(), /**/)
|
||||
++it;
|
||||
if (it == theBufferList().end()) {
|
||||
p_buf = *theBufferList().begin();
|
||||
return true;
|
||||
}
|
||||
p_buf = *it;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** Switch p_buf to point to previous open buffer.
|
||||
**
|
||||
** Return true if restarted from last open buffer.
|
||||
**/
|
||||
bool prev_open_buffer(Buffer * & p_buf) {
|
||||
BufferList::const_iterator it = find(theBufferList().begin(), theBufferList().end(), p_buf);
|
||||
LASSERT(it != theBufferList().end(), /**/)
|
||||
if (it == theBufferList().begin()) {
|
||||
it = theBufferList().end();
|
||||
--it;
|
||||
p_buf = *it;
|
||||
return true;
|
||||
}
|
||||
--it;
|
||||
p_buf = *it;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// Finds forward
|
||||
int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
{
|
||||
@ -1029,6 +1066,8 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
prompt = true;
|
||||
} else if (match.opt.scope == FindAndReplaceOptions::S_DOCUMENT) {
|
||||
prompt = next_document_buffer(match.p_buf);
|
||||
} else if (match.opt.scope == FindAndReplaceOptions::S_OPEN_BUFFERS) {
|
||||
prompt = next_open_buffer(match.p_buf);
|
||||
} else {
|
||||
/* Unimplemented scope */
|
||||
LASSERT(false, /**/);
|
||||
@ -1049,6 +1088,7 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// Find the most backward consecutive match within same paragraph while searching backwards.
|
||||
void findMostBackwards(DocIterator & cur, MatchStringAdv const & match, int & len) {
|
||||
DocIterator cur_begin = doc_iterator_begin(cur.buffer());
|
||||
@ -1141,6 +1181,8 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match) {
|
||||
prompt = true;
|
||||
} else if (match.opt.scope == FindAndReplaceOptions::S_DOCUMENT) {
|
||||
prompt = prev_document_buffer(match.p_buf);
|
||||
} else if (match.opt.scope == FindAndReplaceOptions::S_OPEN_BUFFERS) {
|
||||
prompt = prev_open_buffer(match.p_buf);
|
||||
} else {
|
||||
/* Unimplemented scope */
|
||||
LASSERT(false, /**/);
|
||||
|
Loading…
Reference in New Issue
Block a user