Tommaso Cucinotta wrote:
Vincent van Ravesteijn - TNW wrote:
This is not only caused by the fact that you're using LFUN_BUFFER_SWITCH
instead of GuiView::setBuffer, but also by the fact that you now call
LFUN_FINDADV for each buffer, so it will be shown anyway when
dispatching this LFUN.
If you really want to search in hidden buffers (and/or non-current
workareas) we either have to change some design, we can hide the buffer
again when nothing is found, or freeze the view for a moment such that
we can switch buffer without showing the user.
As far as advanced F&R is concerned, I can try:
1) getting rid of the need for the BufferView, within lyxfind.cpp, i.e.,
ideally, I would like the LFUN to search within a buffer, and return
the DocIterator and length (in positions) of the match, if any
(and I really hate that passing of the BufferView to findAdv());
I am inline with you.
this should not pose any requirements on views that may exist on
the doc;
the buffer to search within may be provided in FindAndReplaceOptions
simply by name, instead of being the currentDocument();
the cursor where to start the search from would become one more
parameter of the FindAndReplaceOptions, provided by the LFUN caller
(F&R widget) -- any advice on how to textually (de)serialize a
DocIterator ?
You can use the paragraph id and the position in that paragraph. Else
there is the StableDocIterator IIRC.
But I am not sure this is really needed. I suggest to create a new
Buffer method:
Buffer::findAndReplace(
FindAndReplaceOptions const & option,
DocIterator const & dit);
Then some function in LyXFunc or GuiApplication or even lyxfind.cpp
could do the search on a number of Buffers:
findAndReplace(
FindAndReplaceOptions const & option,
vector<Buffer *> buffers)
{
for (size_t i = 0; i != buffers.size(); ++i)
buffers[i]->findAndReplace(option, doc_iterator_begin(buffers[i]);
}
You see the idea.
the switch of the displayed buffer and putSelectionAt(...)
operation would
be done by the LFUN caller (F&R widget);
2) intercept the LFUN_FINDADV wherever appropriate considering 1);
I'd suggest GuiApplication and I'd also suggest to find all occurences
in one go instead of searching Buffer per buffer one search at the time.
Then one could easily imagine a dockwidget similar to the outline panel
that will link to all found occurences accessble through a simple mouse
click. That would be powerful my friend! :-)
Abdel.