Lars Gullik Bjønnes wrote:
Some more spaces around comparisons operators please '>' etc.

I also wonder how undo is taken care of with this? Does undo work?

attached patch works for me, including undo

do i see a green light looming in the dusk of april 12th?
Index: src/LyXAction.C
===================================================================
--- src/LyXAction.C     (revision 13657)
+++ 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 13657)
+++ src/lyxfunc.C       (working copy)
@@ -561,6 +561,19 @@
                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 13657)
+++ src/text3.C (working copy)
@@ -321,6 +321,44 @@
 
        switch (cmd.action) {
 
+       case LFUN_PARAGRAPH_MOVE_DOWN: {
+               pit_type begpit = cur.selBegin().pit() - 1;
+               pit_type endpit = cur.selEnd().pit();
+               recUndo(begpit + 1, endpit + 1);
+               finishUndo();
+               for (pit_type pit = endpit; 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 begpit = cur.selBegin().pit();
+               pit_type endpit = cur.selEnd().pit() + 1;
+               recUndo(begpit - 1, endpit - 1);
+               finishUndo();
+               for (pit_type pit = begpit; 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 13657)
+++ 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 13657)
+++ 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 13657)
+++ 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