]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.C
* BufferParams:
[lyx.git] / src / insets / insettabular.C
index eeda178a56a286efacf6a39cf4dee5504593ff7a..eaa5a72488f83268c9d9017e097547b0388473ea 100644 (file)
@@ -50,6 +50,7 @@ namespace lyx {
 
 using cap::dirtyTabularStack;
 using cap::tabularStackDirty;
+using cap::saveSelection;
 
 using graphics::PreviewLoader;
 
@@ -501,12 +502,12 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
                }
 
                if (cmd.button() == mouse_button::button2) {
-                       if (bvcur.selection()) {
+                       if (cap::selection()) {
                                // See comment in LyXText::dispatch why we
                                // do this
                                // FIXME This does not use paste_tabular,
                                // another reason why paste_tabular should go.
-                               cap::copySelectionToStack(bvcur);
+                               cap::copySelectionToStack();
                                cmd = FuncRequest(LFUN_PASTE, "0");
                        } else {
                                cmd = FuncRequest(LFUN_PRIMARY_SELECTION_PASTE,
@@ -536,8 +537,13 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_MOUSE_RELEASE:
                //lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
                if (cmd.button() == mouse_button::button1) {
-                       if (bvcur.selection())
-                               theSelection().haveSelection(true);
+                       if (bvcur.selection()) {
+                               // Bug3238: disable persistent selection for table cells for now
+                               if (tablemode(bvcur))
+                                       theSelection().haveSelection(true);
+                               else
+                                       saveSelection(bvcur);
+                       }
                } else if (cmd.button() == mouse_button::button3)
                        InsetTabularMailer(*this).showDialog(&cur.bv());
                break;
@@ -545,11 +551,13 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_CELL_BACKWARD:
                movePrevCell(cur);
                cur.selection() = false;
+               saveSelection(cur);
                break;
 
        case LFUN_CELL_FORWARD:
                moveNextCell(cur);
                cur.selection() = false;
+               saveSelection(cur);
                break;
 
        case LFUN_CHAR_FORWARD_SELECT:
@@ -558,7 +566,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
                if (!cur.result().dispatched()) {
                        isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
                        if (cmd.action == LFUN_CHAR_FORWARD_SELECT)
-                               theSelection().haveSelection(cur.selection());
+                               saveSelection(cur);
                        if (sl == cur.top())
                                cmd = FuncRequest(LFUN_FINISHED_RIGHT);
                        else
@@ -572,7 +580,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
                if (!cur.result().dispatched()) {
                        isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
                        if (cmd.action == LFUN_CHAR_BACKWARD_SELECT)
-                               theSelection().haveSelection(cur.selection());
+                               saveSelection(cur);
                        if (sl == cur.top())
                                cmd = FuncRequest(LFUN_FINISHED_LEFT);
                        else
@@ -594,8 +602,13 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
                                TextMetrics const & tm =
                                        cur.bv().textMetrics(cell(cur.idx())->getText(0));
                                cur.pos() = tm.x2pos(cur.pit(), 0, cur.targetX());
-                               if (cmd.action == LFUN_DOWN_SELECT)
-                                       theSelection().haveSelection(cur.selection());
+                               if (cmd.action == LFUN_DOWN_SELECT) {
+                                       // Bug3238: disable persistent selection for table cells for now
+                                       if (tablemode(cur))
+                                               theSelection().haveSelection(true);
+                                       else
+                                               saveSelection(cur);
+                               }
                        }
                if (sl == cur.top()) {
                        // we trick it to go to the RIGHT after leaving the
@@ -621,8 +634,13 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
                                ParagraphMetrics const & pm =
                                        tm.parMetrics(cur.lastpit());
                                cur.pos() = tm.x2pos(cur.pit(), pm.rows().size()-1, cur.targetX());
-                               if (cmd.action == LFUN_UP_SELECT)
-                                       theSelection().haveSelection(cur.selection());
+                               if (cmd.action == LFUN_UP_SELECT) {
+                                       // Bug3238: disable persistent selection for table cells for now
+                                       if (tablemode(cur))
+                                               theSelection().haveSelection(true);
+                                       else
+                                               saveSelection(cur);
+                               }
                        }
                if (sl == cur.top()) {
                        cmd = FuncRequest(LFUN_FINISHED_UP);
@@ -746,7 +764,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_PASTE:
                if (tabularStackDirty() && theClipboard().isInternal()) {
                        recordUndoInset(cur, Undo::INSERT);
-                       pasteSelection(cur);
+                       pasteClipboard(cur);
                        break;
                }
                cell(cur.idx())->dispatch(cur, cmd);
@@ -1075,22 +1093,24 @@ bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & cmd,
 
 
 int InsetTabular::latex(Buffer const & buf, odocstream & os,
-                       OutputParams const & runparams) const
+                        OutputParams const & runparams) const
 {
        return tabular.latex(buf, os, runparams);
 }
 
 
 int InsetTabular::plaintext(Buffer const & buf, odocstream & os,
-                       OutputParams const & runparams) const
+                            OutputParams const & runparams) const
 {
-       int const dp = runparams.linelen ? runparams.depth : 0;
-       return tabular.plaintext(buf, os, runparams, dp, false, 0);
+       os << '\n'; // output table on a new line
+       int const dp = runparams.linelen > 0 ? runparams.depth : 0;
+       tabular.plaintext(buf, os, runparams, dp, false, 0);
+       return PLAINTEXT_NEWLINE;
 }
 
 
 int InsetTabular::docbook(Buffer const & buf, odocstream & os,
-                         OutputParams const & runparams) const
+                          OutputParams const & runparams) const
 {
        int ret = 0;
        InsetBase * master = 0;
@@ -1808,7 +1828,7 @@ bool InsetTabular::copySelection(LCursor & cur)
                                    true, true);
 
        odocstringstream os;
-       OutputParams const runparams;
+       OutputParams const runparams(0);
        paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
        // Needed for the "Edit->Paste recent" menu and the system clipboard.
        cap::copySelection(cur, os.str());
@@ -1823,7 +1843,7 @@ bool InsetTabular::copySelection(LCursor & cur)
 }
 
 
-bool InsetTabular::pasteSelection(LCursor & cur)
+bool InsetTabular::pasteClipboard(LCursor & cur)
 {
        if (!paste_tabular)
                return false;