]> git.lyx.org Git - features.git/commitdiff
move LFUN_BUFFER_PARAMS_APPLY to BufferView. I needed to make LyXFunc::updateLayout...
authorAbdelrazak Younes <younes@lyx.org>
Sat, 19 Sep 2009 17:56:53 +0000 (17:56 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 19 Sep 2009 17:56:53 +0000 (17:56 +0000)
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

src/BufferView.cpp
src/LyXFunc.cpp
src/LyXFunc.h

index b5a4ebc25ce7d2c4b06934e48c96ac057119b1fd..4fae0d8131864781a311cb0119760d8a45546d67 100644 (file)
@@ -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();
index 46929f83cb5d2fb1d048826e1e379c6b29350a7f..f681b90ddac9378e0a4d627b0039d099f02cda2d 100644 (file)
@@ -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();
index 20c3da9477bf69e4ba406ff27d55d5d533c962e8..d186a13ed7b4f49248285b2e02287691be51a13f 100644 (file)
@@ -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