From 513ea1058984ac112db16e0276358c2d3c0ae7e9 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Wed, 26 Apr 2006 22:43:26 +0000 Subject: [PATCH] Adding PARAGRAPH_MOVE_UP/DOWN + key bindings: * src/LyXAction.C * src/text3.C * src/lfuns.h * lib/bind/cua.bind * lib/bind/sciword.bind * lib/bind/xemacs.bind * lib/bind/emacs.bind * lib/bind/mac.bind git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13752 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/bind/cua.bind | 2 ++ lib/bind/emacs.bind | 2 ++ lib/bind/mac.bind | 2 ++ lib/bind/sciword.bind | 2 ++ lib/bind/xemacs.bind | 2 ++ src/LyXAction.C | 2 ++ src/lfuns.h | 3 +++ src/text3.C | 39 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 54 insertions(+) diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index 8cc464a13d..b92079ab3e 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -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" diff --git a/lib/bind/emacs.bind b/lib/bind/emacs.bind index b0e6fc99f9..73631396e5 100644 --- a/lib/bind/emacs.bind +++ b/lib/bind/emacs.bind @@ -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" diff --git a/lib/bind/mac.bind b/lib/bind/mac.bind index 16f015e357..9ed9041798 100644 --- a/lib/bind/mac.bind +++ b/lib/bind/mac.bind @@ -176,6 +176,8 @@ \bind "C-period" "end-of-sentence-period-insert" \bind "M-period" "dots-insert" \bind "Escape" "cancel" +\bind "C-M-Up" "paragraph-move-up" +\bind "C-M-Down" "paragraph-move-down" #\bind "F9" "meta-prefix" diff --git a/lib/bind/sciword.bind b/lib/bind/sciword.bind index 3c5bc0b37e..c094069549 100644 --- a/lib/bind/sciword.bind +++ b/lib/bind/sciword.bind @@ -216,6 +216,8 @@ \bind_file greekkeys.bind +\bind "M-Up" "paragraph-move-up" +\bind "M-Down" "paragraph-move-down" \bind "S-KP_Right" "forward-select" \bind "S-KP_Left" "backward-select" \bind "S-KP_Up" "up-select" diff --git a/lib/bind/xemacs.bind b/lib/bind/xemacs.bind index b20d1c2421..93b1d537ed 100644 --- a/lib/bind/xemacs.bind +++ b/lib/bind/xemacs.bind @@ -144,6 +144,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" diff --git a/src/LyXAction.C b/src/LyXAction.C index 33ed97d548..e9a83dc962 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -356,6 +356,8 @@ void LyXAction::init() { 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 } }; diff --git a/src/lfuns.h b/src/lfuns.h index 5f147974e4..1418e0eda2 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -362,6 +362,9 @@ enum kb_action { LFUN_OUTLINE_DOWN, LFUN_OUTLINE_IN, LFUN_OUTLINE_OUT, + // 275 + LFUN_PARAGRAPH_MOVE_DOWN, // Edwin 20060408 + LFUN_PARAGRAPH_MOVE_UP, // Edwin 20060408 LFUN_LASTACTION // end of the table }; diff --git a/src/text3.C b/src/text3.C index 0abeffd356..b1c2782e59 100644 --- a/src/text3.C +++ b/src/text3.C @@ -44,6 +44,7 @@ #include "ParagraphParameters.h" #include "undo.h" #include "vspace.h" +#include "pariterator.h" #include "frontends/Dialogs.h" #include "frontends/LyXView.h" @@ -321,6 +322,34 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) switch (cmd.action) { + case LFUN_PARAGRAPH_MOVE_DOWN: { + pit_type const pit = cur.pit(); + recUndo(pit, pit + 1); + finishUndo(); + std::swap(pars_[pit], pars_[pit + 1]); + ++cur.pit(); + + ParIterator parit(cur); + updateLabels(cur.buffer(), parit); + + needsUpdate = true; + break; + } + + case LFUN_PARAGRAPH_MOVE_UP: { + pit_type const pit = cur.pit(); + recUndo(pit - 1, pit); + finishUndo(); + std::swap(pars_[pit], pars_[pit - 1]); + --cur.pit(); + + ParIterator parit(cur); + updateLabels(cur.buffer(), parit); + + needsUpdate = true; + break; + } + case LFUN_APPENDIX: { Paragraph & par = cur.paragraph(); bool start = !par.params().startOfAppendix(); @@ -1777,6 +1806,16 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd, enable = lyx::cap::numberOfSelections() > 0; break; + case LFUN_PARAGRAPH_MOVE_UP: { + enable = cur.pit() > 0 && !cur.selection(); + break; + } + + case LFUN_PARAGRAPH_MOVE_DOWN: { + enable = cur.pit() < cur.lastpit() && !cur.selection(); + break; + } + case LFUN_DELETE_WORD_FORWARD: case LFUN_DELETE_WORD_BACKWARD: case LFUN_DELETE_LINE_FORWARD: -- 2.39.2