Hello,
in an attempt to fix #6171 (weird highlighting of words language in
Find/Replace WAs), I came to the attached patch (first one, findadv-lang).
Basically, I wanted to "copy" the same language settings of the document
within which the search starts.
For example, I'm editing a foreign-language text, I type C-S-f and I
search for words in that same language. Later, I switch to an English
text (or open a manual), then I type C-S-f, and I search for English
words, etc...
The problem is that, in order to apply this language settings, I need
the LFUN_BUFFER_PARAMS_APPLY to reach the FindWA's buffer, which is
internal, thus the change in LyXAction.cpp. However, as a side effect,
now the dialog the user pops up when changing document settings may
apply changes against FindWA's buffer, not document's one (and, note
that, without the patch, it reads parameters from FindWA's buffer but it
applies to Document's one -- the second patch, guidoc.patch, is probably
needed here, or at least making the Dialog::bufferview() /
Dialog::buffer() methods virtual, and overriding them in the GuiDocument
class).
Alternatively, I may be happy (by now) with deactivating the language
embellishments at all in an internal buffer's WA, even if it might help
in detecting typos when entering the word to search -- in such case, I
would appreciate hints on where to look for.
Does anyone have any particular advice on how to deal with this issue ?
T.
Index: src/LyXAction.cpp
===================================================================
--- src/LyXAction.cpp (revisione 33002)
+++ src/LyXAction.cpp (copia locale)
@@ -3127,7 +3127,7 @@
* \li Origin: leeming, 30 Mar 2004
* \endvar
*/
- { LFUN_BUFFER_PARAMS_APPLY, "buffer-params-apply", NoInternal, Buffer },
+ { LFUN_BUFFER_PARAMS_APPLY, "buffer-params-apply", /*NoInternal*/Noop, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_FILE_INSERT
Index: src/frontends/qt4/FindAndReplace.cpp
===================================================================
--- src/frontends/qt4/FindAndReplace.cpp (revisione 33002)
+++ src/frontends/qt4/FindAndReplace.cpp (copia locale)
@@ -26,6 +26,7 @@
#include "output_latex.h"
#include "OutputParams.h"
#include "TexRow.h"
+#include "Language.h"
#include "frontends/alert.h"
@@ -511,6 +512,19 @@
void FindAndReplaceWidget::showEvent(QShowEvent * /* ev */)
{
view_.setCurrentWorkArea(find_work_area_);
+ if (view_.currentMainWorkArea()) {
+ BufferView & doc_bv = view_.currentMainWorkArea()->bufferView();
+/* string const & lang_name = doc_bv.buffer().language()->lang(); */
+/* dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name)); */
+ Buffer & find_buf = find_work_area_->bufferView().buffer();
+ find_buf.changeLanguage(find_buf.language(), doc_bv.buffer().language()); //cursor().getFont().language());
+ BufferParams bp = doc_bv.buffer().params();
+ ostringstream ss;
+ ss << "\\begin_header\n";
+ bp.writeFile(ss);
+ ss << "\\end_header\n";
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_PARAMS_APPLY, ss.str()));
+ }
LYXERR(Debug::FIND, "Selecting entire find buffer");
dispatch(FuncRequest(LFUN_BUFFER_BEGIN));
dispatch(FuncRequest(LFUN_BUFFER_END_SELECT));
Index: src/frontends/qt4/GuiDocument.cpp
===================================================================
--- src/frontends/qt4/GuiDocument.cpp (revisione 33002)
+++ src/frontends/qt4/GuiDocument.cpp (copia locale)
@@ -17,6 +17,7 @@
#include "GuiBranches.h"
#include "GuiIndices.h"
#include "GuiSelectionManager.h"
+#include "GuiView.h"
#include "LaTeXHighlighter.h"
#include "LengthCombo.h"
#include "PanelStack.h"
@@ -2840,7 +2841,7 @@
bool GuiDocument::initialiseParams(string const &)
{
- BufferView const * view = bufferview();
+ BufferView const * view = lyxview().documentBufferView();
if (!view) {
bp_ = BufferParams();
paramsToDialog();
@@ -2866,7 +2867,7 @@
BufferId GuiDocument::id() const
{
- BufferView const * const view = bufferview();
+ BufferView const * const view = lyxview().documentBufferView();
return view? &view->buffer() : 0;
}
@@ -2995,7 +2996,7 @@
}
}
// FIXME: If we used an LFUN, we would not need those two lines:
- BufferView * bv = const_cast<BufferView *>(bufferview());
+ BufferView * bv = const_cast<BufferView *>(lyxview().documentBufferView());
bv->processUpdateFlags(Update::Force | Update::FitCursor);
}