]> git.lyx.org Git - features.git/commitdiff
73 lines moved, 15 killed... spoils the average ;-}
authorAndré Pönitz <poenitz@gmx.net>
Tue, 27 Aug 2002 13:17:22 +0000 (13:17 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 27 Aug 2002 13:17:22 +0000 (13:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5118 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/text3.C

index c034bf7f3aeba8704c4ef79634a9a2558bbb027b..146699307e29734f4946453350092b9d2c014fa1 100644 (file)
@@ -134,12 +134,6 @@ void BufferView::beforeChange(LyXText * text)
 }
 
 
-void BufferView::finishChange(bool fitcur)
-{
-       pimpl_->finishChange(fitcur);
-}
-
-
 void BufferView::savePosition(unsigned int i)
 {
        pimpl_->savePosition(i);
index df17dc0e1bcdf4d75e280e8ef5b608efc6a83cb8..149ef1b641c4ea3568fdf2bfc9a4f13794966613 100644 (file)
@@ -88,8 +88,6 @@ public:
        ///
        void beforeChange(LyXText *);
        ///
-       void finishChange(bool fitcur = false);
-       ///
        void savePosition(unsigned int i);
        ///
        void restorePosition(unsigned int i);
index e4c12469b12294334e67790fc18c114720c25501..b0bac3161019d4a7eefc5c2bd5a99d70768e13f0 100644 (file)
@@ -40,7 +40,6 @@
 #include "ParagraphParameters.h"
 #include "undo_funcs.h"
 #include "funcrequest.h"
-#include "language.h"
 #include "factory.h"
 
 #include "insets/insetbib.h"
@@ -1089,14 +1088,6 @@ void BufferView::Pimpl::beforeChange(LyXText * text)
 }
 
 
-void BufferView::Pimpl::finishChange(bool fitcur)
-{
-       finishUndo();
-       moveCursorUpdate(fitcur);
-       bv_->owner()->view_state_changed();
-}
-
-
 void BufferView::Pimpl::savePosition(unsigned int i)
 {
        if (i >= saved_positions_num)
@@ -1570,10 +1561,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
        }
        break;
 
-       case LFUN_QUOTE:
-               smartQuote();
-               break;
-
        case LFUN_HTMLURL:
        case LFUN_URL:
        {
@@ -1915,32 +1902,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
 }
 
 
-void BufferView::Pimpl::smartQuote()
-{
-       LyXText const * lt = bv_->getLyXText();
-       Paragraph const * par = lt->cursor.par();
-       pos_type pos = lt->cursor.pos();
-       char c;
-
-       if (!pos
-           || (par->isInset(pos - 1)
-               && par->getInset(pos - 1)->isSpace()))
-               c = ' ';
-       else
-               c = par->getChar(pos - 1);
-
-       hideCursor();
-
-       LyXLayout_ptr const & style = par->layout();
-
-       if (style->pass_thru ||
-           par->getFontSettings(buffer_->params,
-                                pos).language()->lang() == "hebrew" ||
-               (!insertInset(new InsetQuotes(c, buffer_->params))))
-               bv_->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
-}
-
-
 // Open and lock an updatable inset
 bool BufferView::Pimpl::open_new_inset(UpdatableInset * new_inset, bool behind)
 {
index 5fd64aecf9ccc0877f5a0237d5f6d014d333c7ab..e7cc824406954b02ed213c5d6618f24eecaac550 100644 (file)
@@ -96,8 +96,6 @@ struct BufferView::Pimpl : public boost::signals::trackable {
        ///
        void beforeChange(LyXText *);
        ///
-       void finishChange(bool fitcur);
-       ///
        void savePosition(unsigned int i);
        ///
        void restorePosition(unsigned int i);
@@ -142,8 +140,6 @@ private:
        bool open_new_inset(UpdatableInset * new_inset, bool behind = false);
        ///
        void hfill();
-       ///
-       void smartQuote();
 
        ///
        BufferView * bv_;
index ed93cc2abe78d8c1c552a8b033802407e3ab2011..42f9ca54d61356cd819769795a5d07a17c9d63ac 100644 (file)
 #include "ParagraphParameters.h"
 #include "gettext.h"
 #include "intl.h"
+#include "language.h"
 #include "support/lstrings.h"
 #include "frontends/LyXView.h"
 #include "frontends/screen.h"
 #include "frontends/WorkArea.h"
 #include "insets/insetspecialchar.h"
 #include "insets/insettext.h"
+#include "insets/insetquotes.h"
 #include "insets/insetcommand.h"
 #include "undo_funcs.h"
 
@@ -35,6 +37,17 @@ using std::endl;
 
 extern string current_layout;
 
+namespace {
+
+       void finishChange(BufferView * bv, bool fitcur = false)
+       {
+               finishUndo();
+               bv->moveCursorUpdate(fitcur);
+               bv->owner()->view_state_changed();
+       }
+
+}
+
 
 bool LyXText::gotoNextInset(BufferView * bv,
        vector<Inset::Code> const & codes, string const & contents) const
@@ -271,7 +284,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                update(bv, false);
                deleteWordForward(bv);
                update(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_DELETE_WORD_BACKWARD:
@@ -279,7 +292,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                update(bv, false);
                deleteWordBackward(bv);
                update(bv, true);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_DELETE_LINE_FORWARD:
@@ -287,7 +300,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                update(bv, false);
                deleteLineForward(bv);
                update(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_SHIFT_TAB:
@@ -296,7 +309,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                update(bv, false);
                cursorTab(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_WORDRIGHT:
@@ -307,7 +320,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        cursorLeftOneWord(bv);
                else
                        cursorRightOneWord(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_WORDLEFT:
@@ -318,7 +331,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        cursorRightOneWord(bv);
                else
                        cursorLeftOneWord(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_BEGINNINGBUF:
@@ -326,7 +339,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                update(bv, false);
                cursorTop(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_ENDBUF:
@@ -334,7 +347,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                update(bv, false);
                cursorBottom(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_RIGHTSEL:
@@ -343,7 +356,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        cursorLeft(bv);
                else
                        cursorRight(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_LEFTSEL:
@@ -352,55 +365,55 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        cursorRight(bv);
                else
                        cursorLeft(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_UPSEL:
                update(bv, false);
                cursorUp(bv, true);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_DOWNSEL:
                update(bv, false);
                cursorDown(bv, true);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_UP_PARAGRAPHSEL:
                update(bv, false);
                cursorUpParagraph(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_DOWN_PARAGRAPHSEL:
                update(bv, false);
                cursorDownParagraph(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_PRIORSEL:
                update(bv, false);
                cursorPrevious(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_NEXTSEL:
                update(bv, false);
                cursorNext(bv);
-               bv->finishChange();
+               finishChange(bv, true);
                break;
 
        case LFUN_HOMESEL:
                update(bv, false);
                cursorHome(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_ENDSEL:
                update(bv, false);
                cursorEnd(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_WORDRIGHTSEL:
@@ -409,7 +422,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        cursorLeftOneWord(bv);
                else
                        cursorRightOneWord(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_WORDLEFTSEL:
@@ -418,7 +431,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        cursorRightOneWord(bv);
                else
                        cursorLeftOneWord(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_RIGHT: {
@@ -438,7 +451,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                }
                if (!is_rtl)
                        cursorRight(bv, false);
-               bv->finishChange(false);
+               finishChange(bv);
                break;
        }
 
@@ -463,7 +476,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                }
                if (is_rtl)
                        cursorRight(bv, false);
-               bv->finishChange(false);
+               finishChange(bv);
                break;
        }
 
@@ -472,7 +485,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                bv->update(this, BufferView::UPDATE);
                cursorUp(bv);
-               bv->finishChange(false);
+               finishChange(bv);
                break;
 
        case LFUN_DOWN:
@@ -480,7 +493,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                bv->update(this, BufferView::UPDATE);
                cursorDown(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_UP_PARAGRAPH:
@@ -488,7 +501,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                bv->update(this, BufferView::UPDATE);
                cursorUpParagraph(bv);
-               bv->finishChange();
+               finishChange(bv);
                break;
 
        case LFUN_DOWN_PARAGRAPH:
@@ -496,7 +509,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                bv->update(this, BufferView::UPDATE);
                cursorDownParagraph(bv);
-               bv->finishChange(false);
+               finishChange(bv, false);
                break;
 
        case LFUN_PRIOR:
@@ -504,7 +517,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                bv->update(this, BufferView::UPDATE);
                cursorPrevious(bv);
-               bv->finishChange(false);
+               finishChange(bv, false);
                // was:
                // finishUndo();
                // moveCursorUpdate(false, false);
@@ -516,7 +529,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                bv->update(this, BufferView::UPDATE);
                cursorNext(bv);
-               bv->finishChange(false);
+               finishChange(bv, false);
                break;
 
        case LFUN_HOME:
@@ -524,7 +537,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                update(bv);
                cursorHome(bv);
-               bv->finishChange(false);
+               finishChange(bv, false);
                break;
 
        case LFUN_END:
@@ -532,7 +545,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        bv->beforeChange(this);
                update(bv);
                cursorEnd(bv);
-               bv->finishChange(false);
+               finishChange(bv, false);
                break;
 
        case LFUN_BREAKLINE:
@@ -875,7 +888,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        return Inset::UNDISPATCHED;
                update(bv, false);
                cursorTop(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_ENDBUFSEL:
@@ -883,7 +896,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                        return Inset::UNDISPATCHED;
                update(bv, false);
                cursorBottom(bv);
-               bv->finishChange(true);
+               finishChange(bv, true);
                break;
 
        case LFUN_GETXY:
@@ -1010,6 +1023,29 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                break;
        }
 
+       case LFUN_QUOTE: {
+               Paragraph const * par = cursor.par();
+               lyx::pos_type pos = cursor.pos();
+               char c;
+
+               if (!pos)
+                       c = ' ';
+               else if (par->isInset(pos - 1) && par->getInset(pos - 1)->isSpace())
+                       c = ' ';
+               else
+                       c = par->getChar(pos - 1);
+
+               bv->hideCursor();
+               LyXLayout_ptr const & style = par->layout();
+
+               if (style->pass_thru ||
+                               par->getFontSettings(bv->buffer()->params,
+                                        pos).language()->lang() == "hebrew" ||
+                       (!bv->insertInset(new InsetQuotes(c, bv->buffer()->params))))
+                       bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
+               break;
+       }
+
        case LFUN_SELFINSERT: {
                if (cmd.argument.empty())
                        break;