for now i would like to commit the attached

moving can be done on single pars, but also on selection that span several pars

i have tested it and found no glitches

moreover, i see no delays using the user guide in the qt2 frontend

green light?
Index: src/LyXAction.C
===================================================================
--- src/LyXAction.C     (revision 13613)
+++ src/LyXAction.C     (working copy)
@@ -353,6 +353,8 @@
                { LFUN_MOUSE_RELEASE, "", ReadOnly },
                { LFUN_MOUSE_DOUBLE, "", ReadOnly },
                { LFUN_MOUSE_TRIPLE, "", ReadOnly },
+               { LFUN_PARAGRAPH_MOVE_DOWN, "paragraph-move-down", Noop },
+               { LFUN_PARAGRAPH_MOVE_UP, "paragraph-move-up", Noop },
                { LFUN_NOACTION, "", Noop }
        };
 
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C       (revision 13613)
+++ src/lyxfunc.C       (working copy)
@@ -561,6 +561,18 @@
                flag = getStatus(func);
        }
 
+       case LFUN_PARAGRAPH_MOVE_UP: {
+               if (cur)
+                       enable = cur.pit()>0 && cur.anchor_.pit()>0;
+               break;
+       }
+
+       case LFUN_PARAGRAPH_MOVE_DOWN: {
+               if (cur)
+                       enable = cur.pit()<cur.lastpit() && 
cur.anchor_.pit()<cur.lastpit();
+               break;
+       }
+
        case LFUN_MENUNEW:
        case LFUN_MENUNEWTMPLT:
        case LFUN_WORDFINDFORWARD:
Index: src/text3.C
===================================================================
--- src/text3.C (revision 13613)
+++ src/text3.C (working copy)
@@ -321,6 +321,38 @@
 
        switch (cmd.action) {
 
+       case LFUN_PARAGRAPH_MOVE_DOWN: {
+               pit_type begpit = cur.selBegin().pit()-1;
+               for (pit_type pit = cur.selEnd().pit(); pit!=begpit; --pit)
+                       std::swap(pars_[pit], pars_[pit+1]);
+
+               if (cur.selection())
+                       ++cur.anchor_.pit();
+               ++cur.pit();
+
+               // FIXME: check whether we need to update counters?
+               updateCounters(cur.buffer());
+
+               needsUpdate = true;
+               break;
+       }
+
+       case LFUN_PARAGRAPH_MOVE_UP: {
+               pit_type endpit = cur.selEnd().pit()+1;
+               for (pit_type pit = cur.selBegin().pit(); pit!=endpit; ++pit)
+                       std::swap(pars_[pit], pars_[pit-1]);
+
+               if (cur.selection())
+                       --cur.anchor_.pit();
+               --cur.pit();
+
+               // FIXME: check whether we need to update counters?
+               updateCounters(cur.buffer());
+
+               needsUpdate = true;
+               break;
+       }
+
        case LFUN_APPENDIX: {
                Paragraph & par = cur.paragraph();
                bool start = !par.params().startOfAppendix();
Index: src/lfuns.h
===================================================================
--- src/lfuns.h (revision 13613)
+++ src/lfuns.h (working copy)
@@ -358,6 +358,9 @@
        LFUN_BIBDB_DEL,
        LFUN_INSERT_CITATION,
        LFUN_OUTLINE,                   // Vermeer 20060323
+       // 275
+       LFUN_PARAGRAPH_MOVE_DOWN,                // Edwin 20060408
+       LFUN_PARAGRAPH_MOVE_UP,                  // Edwin 20060408
 
        LFUN_LASTACTION                  // end of the table
 };
Index: lib/bind/cua.bind
===================================================================
--- lib/bind/cua.bind   (revision 13613)
+++ lib/bind/cua.bind   (working copy)
@@ -102,6 +102,8 @@
 # Motion group
 #
 
+\bind "M-Up"                   "paragraph-move-up"
+\bind "M-Down"                 "paragraph-move-down"
 \bind "C-Right"                        "word-forward"
 \bind "C-Left"                 "word-backward"
 \bind "C-Up"                   "paragraph-up"
Index: lib/bind/emacs.bind
===================================================================
--- lib/bind/emacs.bind (revision 13613)
+++ lib/bind/emacs.bind (working copy)
@@ -139,6 +139,8 @@
 # Motion group
 #
 
+\bind "M-Up"                   "paragraph-move-up"
+\bind "M-Down"                 "paragraph-move-down"
 \bind "C-Right"                        "word-forward"
 \bind "C-Left"                 "word-backward"
 \bind "C-Up"                   "paragraph-up"

Reply via email to