]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
more guii moving around.
[lyx.git] / src / BufferView_pimpl.C
index 043a1410d29bf335f7569640f46d949d0aff18bb..aef9714b7d94a76864eb9cd760d1c50eff62271d 100644 (file)
@@ -5,12 +5,12 @@
 #endif
 
 #include "BufferView_pimpl.h"
-#include "WorkArea.h"
-#include "lyxscreen.h"
+#include "frontends/WorkArea.h"
+#include "frontends/screen.h"
 #include "lyxtext.h"
 #include "lyxrow.h"
 #include "paragraph.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
 #include "commandtags.h"
 #include "lyxfunc.h"
 #include "debug.h"
@@ -1092,20 +1092,19 @@ void BufferView::Pimpl::update()
                screen_->update(bv_->text, bv_);
                bool fitc = false;
                while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) {
-                       if (bv_->text->fullRebreak(bv_)) {
-                               st = LyXText::NEED_MORE_REFRESH;
-                               bv_->text->setCursor(bv_, bv_->text->cursor.par(),
-                                                                        bv_->text->cursor.pos());
-                               if (bv_->text->selection.set()) {
-                                       bv_->text->setCursor(bv_, bv_->text->selection.start,
-                                                                 bv_->text->selection.start.par(),
-                                                                 bv_->text->selection.start.pos());
-                                       bv_->text->setCursor(bv_, bv_->text->selection.end,
-                                                                 bv_->text->selection.end.par(),
-                                                                 bv_->text->selection.end.pos());
-                               }
-                               fitc = true;
+                       bv_->text->fullRebreak(bv_);
+                       st = LyXText::NEED_MORE_REFRESH;
+                       bv_->text->setCursor(bv_, bv_->text->cursor.par(),
+                                            bv_->text->cursor.pos());
+                       if (bv_->text->selection.set()) {
+                               bv_->text->setCursor(bv_, bv_->text->selection.start,
+                                                    bv_->text->selection.start.par(),
+                                                    bv_->text->selection.start.pos());
+                               bv_->text->setCursor(bv_, bv_->text->selection.end,
+                                                    bv_->text->selection.end.par(),
+                                                    bv_->text->selection.end.pos());
                        }
+                       fitc = true;
                        bv_->text->status(bv_, st);
                        screen_->update(bv_->text, bv_);
                }
@@ -1292,7 +1291,7 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
                // span several workarea-heights) we'll move to the top again, but this
                // is better than just jump down and only display part of the row.
                new_y = bv_->text->first_y + workarea_.height();
-       } else {                
+       } else {
                if (text->inset_owner) {
                        new_y = bv_->text->cursor.iy()
                                + bv_->theLockingInset()->insetInInsetY()
@@ -1391,7 +1390,10 @@ void BufferView::Pimpl::setState()
                return;
 
        LyXText * text = bv_->getLyXText();
-       if (text->real_current_font.isRightToLeft()) {
+       if (text->real_current_font.isRightToLeft()
+           && !(bv_->theLockingInset()
+                && bv_->theLockingInset()->lyxCode()== Inset::ERT_CODE))
+       {
                if (owner_->getIntl()->keymap == Intl::PRIMARY)
                        owner_->getIntl()->KeyMapSec();
        } else {
@@ -1528,6 +1530,7 @@ void BufferView::Pimpl::pasteClipboard(bool asPara)
        } else {
                bv_->getLyXText()->insertStringAsLines(bv_, clip);
        }
+       bv_->getLyXText()->clearSelection();
        update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
 }
 
@@ -1562,6 +1565,10 @@ void BufferView::Pimpl::moveCursorUpdate(bool selecting, bool fitcur)
                else
                        update(lt, BufferView::SELECT);
                showCursor();
+       } else if (bv_->text->status() != LyXText::UNCHANGED) {
+               bv_->theLockingInset()->hideInsetCursor(bv_);
+               update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
+               showCursor();
        }
 
        if (!lt->selection.set())
@@ -1655,6 +1662,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch: action["
                              << action <<"] arg[" << argument << "]" << endl;
 
+       LyXTextClass const & tclass = textclasslist[buffer_->params.textclass];
+
        switch (action) {
                // --- Misc -------------------------------------------
        case LFUN_APPENDIX:
@@ -1675,7 +1684,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                InsetCommandParams p;
                p.setCmdName("tableofcontents");
                Inset * inset = new InsetTOC(p);
-               if (!insertInset(inset, "Standard"))
+               if (!insertInset(inset, tclass.defaultLayoutName()))
                        delete inset;
                break;
        }
@@ -1800,17 +1809,25 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
                                    << argument << endl;
 
+               // This is not the good solution to the empty argument
+               // problem, but it will hopefully suffice for 1.2.0.
+               // The correct solution would be to augument the
+               // function list/array with information about what
+               // functions needs arguments and their type.
+               if (argument.empty()) {
+                       owner_->getLyXFunc()->setErrorMessage(
+                               _("LyX function 'layout' needs an argument."));
+                       break;
+               }
+
                // Derive layout number from given argument (string)
                // and current buffer's textclass (number). */
-               textclass_type tclass = buffer_->params.textclass;
-               bool hasLayout =
-                       textclasslist[tclass].hasLayout(argument);
+               bool hasLayout = tclass.hasLayout(argument);
                string layout = argument;
 
                // If the entry is obsolete, use the new one instead.
                if (hasLayout) {
-                       string const & obs = textclasslist[tclass][layout]
-                               .obsoleted_by();
+                       string const & obs = tclass[layout].obsoleted_by();
                        if (!obs.empty())
                                layout = obs;
                }
@@ -2480,6 +2497,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                       BufferView::SELECT
                       | BufferView::FITCUR
                       | BufferView::CHANGE);
+               lt->setCursor(bv_, lt->cursor.par(), lt->cursor.pos());
                moveCursorUpdate(false);
        }
        break;
@@ -2488,7 +2506,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                LyXText * lt = bv_->getLyXText();
 
-               LyXLayout const & style = textclasslist[buffer_->params.textclass][lt->cursor.par()->layout()];
+               LyXLayout const & style = tclass[lt->cursor.par()->layout()];
 
                if (style.free_spacing) {
                        lt->insertChar(bv_, ' ');
@@ -2928,23 +2946,17 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                break;
 
        case LFUN_INSET_WIDE_FLOAT:
-       {
                // check if the float type exist
                if (floatList.typeExist(argument)) {
                        InsetFloat * new_inset =
                                new InsetFloat(buffer_->params, argument);
                        new_inset->wide(true);
-                       if (insertInset(new_inset))
-                               new_inset->edit(bv_);
-                       else
-                               delete new_inset;
+                       insertAndEditInset(new_inset);
                } else {
                        lyxerr << "Non-existent float type: "
                               << argument << endl;
                }
-
-       }
-       break;
+               break;
 
 #if 0
        case LFUN_INSET_LIST:
@@ -3215,7 +3227,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetCommandParams p("printindex");
                Inset * inset = new InsetPrintIndex(p);
-               if (!insertInset(inset, "Standard"))
+               if (!insertInset(inset, tclass.defaultLayoutName()))
                        delete inset;
        }
        break;
@@ -3224,7 +3236,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        {
                InsetCommandParams p("lyxparent", argument);
                Inset * inset = new InsetParent(p, *buffer_);
-               if (!insertInset(inset, "Standard"))
+               if (!insertInset(inset, tclass.defaultLayoutName()))
                        delete inset;
        }
 
@@ -3247,13 +3259,15 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        break;
 
        case LFUN_FLOAT_LIST:
-       {
-               // We should check the argument for validity. (Lgb)
-               Inset * inset = new InsetFloatList(argument);
-               if (!insertInset(inset, "Standard"))
-                       delete inset;
-       }
-       break;
+               if (floatList.typeExist(argument)) {
+                       Inset * inset = new InsetFloatList(argument);
+                       if (!insertInset(inset, tclass.defaultLayoutName()))
+                               delete inset;
+               } else {
+                       lyxerr << "Non-existent float type: "
+                              << argument << endl;
+               }
+               break;
 
        case LFUN_THESAURUS_ENTRY:
        {