From: Abdelrazak Younes Date: Sat, 19 Sep 2009 17:56:53 +0000 (+0000) Subject: move LFUN_BUFFER_PARAMS_APPLY to BufferView. I needed to make LyXFunc::updateLayout... X-Git-Tag: 2.0.0~5481 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4d7ed2056b506b5ab5d1d3a7106010ed7fe80d64;p=features.git move LFUN_BUFFER_PARAMS_APPLY to BufferView. I needed to make LyXFunc::updateLayout() public but this method is misplaced there. LFUN_BUFFER_PARAMS_APPLY has now a status (disabled if read-only). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31411 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index b5a4ebc25c..4fae0d8131 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -34,6 +34,7 @@ #include "InsetIterator.h" #include "Language.h" #include "LaTeXFeatures.h" +#include "Lexer.h" #include "LyX.h" #include "lyxfind.h" #include "LyXFunc.h" @@ -899,6 +900,9 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag) Cursor & cur = d->cursor_; switch (cmd.action) { + case LFUN_BUFFER_PARAMS_APPLY: + flag.setEnabled(!buffer_.isReadonly()); + break; case LFUN_UNDO: flag.setEnabled(buffer_.undo().hasUndoStack()); @@ -1056,6 +1060,27 @@ bool BufferView::dispatch(FuncRequest const & cmd) switch (cmd.action) { + case LFUN_BUFFER_PARAMS_APPLY: { + DocumentClass const * const oldClass = buffer_.params().documentClassPtr(); + cur.recordUndoFullDocument(); + istringstream ss(to_utf8(cmd.argument())); + Lexer lex; + lex.setStream(ss); + int const unknown_tokens = buffer_.readHeader(lex); + if (unknown_tokens != 0) { + LYXERR0("Warning in LFUN_BUFFER_PARAMS_APPLY!\n" + << unknown_tokens << " unknown token" + << (unknown_tokens == 1 ? "" : "s")); + } + theLyXFunc().updateLayout(oldClass, &buffer_); + + // We are most certainly here because of a change in the document + // It is then better to make sure that all dialogs are in sync with + // current document settings. + processUpdateFlags(Update::Force | Update::FitCursor); + break; + } + case LFUN_UNDO: cur.message(_("Undo")); cur.clearSelection(); diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 46929f83cb..f681b90dda 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -570,7 +570,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const case LFUN_TEXTCLASS_APPLY: case LFUN_TEXTCLASS_LOAD: case LFUN_BUFFER_SAVE_AS_DEFAULT: - case LFUN_BUFFER_PARAMS_APPLY: case LFUN_LAYOUT_MODULES_CLEAR: case LFUN_LAYOUT_MODULE_ADD: case LFUN_LAYOUT_RELOAD: @@ -1066,35 +1065,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; } - case LFUN_BUFFER_PARAMS_APPLY: { - LASSERT(lyx_view_, /**/); - - DocumentClass const * const oldClass = buffer->params().documentClassPtr(); - Cursor & cur = lyx_view_->documentBufferView()->cursor(); - cur.recordUndoFullDocument(); - - istringstream ss(argument); - Lexer lex; - lex.setStream(ss); - int const unknown_tokens = buffer->readHeader(lex); - - if (unknown_tokens != 0) { - lyxerr << "Warning in LFUN_BUFFER_PARAMS_APPLY!\n" - << unknown_tokens << " unknown token" - << (unknown_tokens == 1 ? "" : "s") - << endl; - } - - updateLayout(oldClass, buffer); - - updateFlags = Update::Force | Update::FitCursor; - // We are most certainly here because of a change in the document - // It is then better to make sure that all dialogs are in sync with - // current document settings. LyXView::restartCursor() achieve this. - lyx_view_->restartCursor(); - break; - } - case LFUN_LAYOUT_MODULES_CLEAR: { LASSERT(lyx_view_ && lyx_view_->documentBufferView(), /**/); DocumentClass const * const oldClass = buffer->params().documentClassPtr(); diff --git a/src/LyXFunc.h b/src/LyXFunc.h index 20c3da9477..d186a13ed7 100644 --- a/src/LyXFunc.h +++ b/src/LyXFunc.h @@ -92,6 +92,9 @@ public: /// cursor y position before dispatch started int cursorBeforeDispatchY() const { return cursorPosBeforeDispatchY_; } + /// + void updateLayout(DocumentClass const * const oldlayout, Buffer * buffer); + private: /// frontend::LyXView * lyx_view_; @@ -121,8 +124,6 @@ private: /// send a post-dispatch status message void sendDispatchMessage(docstring const & msg, FuncRequest const & ev); - /// - void updateLayout(DocumentClass const * const oldlayout, Buffer * buffer); }; /// Implementation is in LyX.cpp