mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Still addressing #6560: instead of cloning the BufferParams, which might cause
a number of unforeseen issues (like the inheritance of the default master, as pointed out in http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg168225.html), now we simply set the language into the search & replace buffers. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38647 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5791d41544
commit
c23eef3abf
@ -2087,6 +2087,18 @@ void BufferParams::readLocalLayout(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
bool BufferParams::setLanguage(string const & lang)
|
||||
{
|
||||
Language const *new_language = languages.getLanguage(lang);
|
||||
if (!new_language) {
|
||||
// Language lang was not found
|
||||
return false;
|
||||
}
|
||||
language = new_language;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BufferParams::readLanguage(Lexer & lex)
|
||||
{
|
||||
if (!lex.next()) return;
|
||||
@ -2094,8 +2106,7 @@ void BufferParams::readLanguage(Lexer & lex)
|
||||
string const tmptok = lex.getString();
|
||||
|
||||
// check if tmptok is part of tex_babel in tex-defs.h
|
||||
language = languages.getLanguage(tmptok);
|
||||
if (!language) {
|
||||
if (!setLanguage(tmptok)) {
|
||||
// Language tmptok was not found
|
||||
language = default_language;
|
||||
lyxerr << "Warning: Setting language `"
|
||||
|
@ -414,6 +414,10 @@ public:
|
||||
/// use refstyle? or prettyref?
|
||||
bool use_refstyle;
|
||||
|
||||
/// Return true if language could be set to lang,
|
||||
/// otherwise return false and do not change language
|
||||
bool setLanguage(std::string const & lang);
|
||||
|
||||
private:
|
||||
///
|
||||
void readPreamble(Lexer &);
|
||||
|
@ -45,20 +45,6 @@ namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
|
||||
/// Apply to buf the parameters supplied through bp
|
||||
static void ApplyParams(Buffer &buf, BufferParams const & bp) {
|
||||
ostringstream ss;
|
||||
ss << "\\begin_header\n";
|
||||
bp.writeFile(ss);
|
||||
ss << "\\end_header\n";
|
||||
istringstream iss(ss.str());
|
||||
Lexer lex;
|
||||
lex.setStream(iss);
|
||||
int unknown_tokens = buf.readHeader(lex);
|
||||
LASSERT(unknown_tokens == 0, /* */);
|
||||
}
|
||||
|
||||
|
||||
FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
|
||||
: QTabWidget(&view), view_(view)
|
||||
{
|
||||
@ -489,18 +475,17 @@ void FindAndReplaceWidget::showEvent(QShowEvent * /* ev */)
|
||||
if (bv) {
|
||||
Buffer & doc_buf = bv->buffer();
|
||||
BufferParams & doc_bp = doc_buf.params();
|
||||
string const & lang = doc_bp.language->lang();
|
||||
Buffer & find_buf = find_work_area_->bufferView().buffer();
|
||||
LYXERR(Debug::FIND, "Applying document params to find buffer");
|
||||
ApplyParams(find_buf, doc_bp);
|
||||
find_buf.params().setLanguage(lang);
|
||||
Buffer & replace_buf = replace_work_area_->bufferView().buffer();
|
||||
LYXERR(Debug::FIND, "Applying document params to replace buffer");
|
||||
ApplyParams(replace_buf, doc_bp);
|
||||
replace_buf.params().setLanguage(lang);
|
||||
|
||||
string lang = doc_bp.language->lang();
|
||||
LYXERR(Debug::FIND, "Setting current editing language to " << lang << endl);
|
||||
FuncRequest cmd(LFUN_LANGUAGE, lang);
|
||||
find_buf.text().dispatch(find_work_area_->bufferView().cursor(), cmd);
|
||||
replace_buf.text().dispatch(replace_work_area_->bufferView().cursor(), cmd);
|
||||
find_work_area_->bufferView().cursor().current_font.setLanguage(doc_bp.language);
|
||||
replace_work_area_->bufferView().cursor().current_font.setLanguage(doc_bp.language);
|
||||
}
|
||||
|
||||
find_work_area_->installEventFilter(this);
|
||||
|
Loading…
Reference in New Issue
Block a user