Vincent van Ravesteijn wrote:
So, if you think about this, you'd say that it's already "wrong" that you want to have this information about a buffer in lyxfind.cpp. Maybe it's already "wrong" to do this buffer management in lyxfind.cpp.
I'm sure it is wrong, I'm only trying to proceed incrementally, given my availability constraints.
Why don't you do all this in the FindAndReplaceWidget ? If you have found the scope S_OPEN_BUFFERS, you step through all open buffers, and for each you call lyx::dispatch(LFUN_WORD_FINDADV...).
In fact, I was thinking to intercept the LFUN at a higher level (perhaps GuiView level), and move all the buffer switching logics there. However, I'm not sure about how to exactly move in this direction, i.e.:

1) currently we have in BufferView::dispatch():

   case LFUN_WORD_FINDADV:
       findAdv(this, cmd);
       break;

2) I would move the "case" into GuiView::dispatch() (and I would remove the LFUN_WORD_FINDADV interception from BufferView::dispatch() ?)

3) then I would call a GuiView::findAdv() method, which would implement the "scope" functionality and buffer switch by repeatedly calling lyx::findAdv(), as found in lyxfind.cpp.

Would it be ok ? I don't want to mess-up with the LFUNC dispatching stuff.
However, in order to implement this, I would need to call the

 GuiWorkArea * GuiView::workArea(Buffer & buffer)
on a related note, what is the "Buffer::gui_" field ? What is the purpose of those "gui delegate" ? If I call "hasGuiDelegate()", is that equivalent to checking that the buffer has an associated view (workarea and bufferview) ?

method, in order to check whether the buffer has an associated view or not, while selecting the next buffer to search within. Unfortunately, this would require me to add the above method to LyXView, in a form that is qt-unaware, smth. like

 WorkArea * LyXView::workArea(Buffer & buffer)

and let the former method to be a refinement of it (if allowed by C++), or to introduce a completely new method in LyXView

 bool GuiView::hasWorkArea(Buffer & buffer)
on a related note, what is the "Buffer::gui_" field ? What is the purpose of those "gui delegate" ? If I call "hasGuiDelegate()", is that equivalent to checking that the buffer has an associated view (workarea and bufferview) ?
To conclude, if you do the buffer management in the FindReplaceWidget, you won't have this problem (but maybe you'll have other problems that I didn't foresee).

In one of the first `findadv' patches, I used to call directly lyxfind.cpp from the F&RWidget, then I was told to use LFUNs, and now that I use LFUNs there is another issue I raised some time ago of how to retrieve "return values" from LFUNs. The interaction between the F&RWidget and the actual findAdv() logics (in lyxfind.cpp) would be two-way, not one-way.

   T.

Reply via email to