]> git.lyx.org Git - lyx.git/commitdiff
Implement and bind buffer-move-{next,previous}
authorScott Kostyshak <skostysh@lyx.org>
Wed, 8 Apr 2015 03:18:21 +0000 (23:18 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Wed, 8 Apr 2015 18:12:52 +0000 (14:12 -0400)
Control + Shift + PgDn now moves a tab to the right.
Control + Shift + PgUp now moves a tab to the left.

These keybindings are consistent with Chromium, Firefox,
Nautilus, and gnome-terminal.

Note that I allow for wrapping. This is consistent with
allowing wrapping for buffer-{next,previous}, but there
might be reasons to disable it in the future.

RELEASE-NOTES
lib/bind/cua.bind
lib/bind/emacs.bind
lib/bind/mac.bind
lib/bind/xemacs.bind
src/FuncCode.h
src/LyXAction.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/GuiWorkArea.h

index f859e48c4277ae93a0952ef7ba4010c0f5149590..f1999c271af19256abf64a07f4d4d0649ab3ad8d 100644 (file)
@@ -29,6 +29,12 @@ The following new LyX functions have been introduced in 2.2:
 - buffer-view-cache
   Opens the last previewed output of the buffer, if it exists.
 
+- buffer-move-next
+  Moves the current tab one spot to the right.
+
+- buffer-move-previous
+  Moves the current tab one spot to the left.
+
 
 The following LyX functions have been changed in 2.2:
 
@@ -36,6 +42,9 @@ The following LyX functions have been changed in 2.2:
 
 The following LyX key bindings have been changed in 2.2:
 
+- For bindings where Control + {PgDn, PgUp} switches to the
+  {next, previous} tab, Control + Shift + {PgDn, PgUp} moves the current
+  tab to the {next, previous} tab.
 
 
 The following LyX documents have been moved in 2.2:
index 359e1d486d4436d92cc27706aa333ab3171acefc..71b919c2c2dff72da3231ad96cfae99a6de9f20e 100644 (file)
@@ -187,8 +187,8 @@ Format 2
 \bind "S-KP_Next"              "screen-down-select"
 \bind "S-C-KP_Home"            "buffer-begin-select"
 \bind "S-C-KP_End"             "buffer-end-select"
-\bind "S-C-KP_Prior"           "buffer-begin-select"
-\bind "S-C-KP_Next"            "buffer-end-select"
+\bind "S-C-KP_Prior"           "buffer-move-previous"
+\bind "S-C-KP_Next"            "buffer-move-next"
 \bind "C-KP_Insert"            "copy"
 \bind "S-KP_Insert"            "paste"
 \bind "S-KP_Delete"            "cut"
index f0cb33e17f1ad7c1c1b60697a1be18fce249ec65..30a587c881d00dd5472e7b3b0a93c9006ac18ea3 100644 (file)
@@ -252,8 +252,8 @@ Format 2
 \bind "S-KP_Next"               "screen-down-select"
 \bind "S-C-KP_Home"             "buffer-begin-select"
 \bind "S-C-KP_End"              "buffer-end-select"
-\bind "S-C-KP_Prior"            "buffer-begin-select"
-\bind "S-C-KP_Next"             "buffer-end-select"
+\bind "S-C-KP_Prior"            "buffer-move-previous"
+\bind "S-C-KP_Next"             "buffer-move-next"
 \bind "M-h"                     "inset-select-all"
 \bind "C-KP_Insert"             "copy"
 \bind "S-KP_Insert"             "paste"
index ecdd3ad06bbf516716f4a2ab6a08eb204b2c4f83..6fcd406ec3d99cb709d62d2101ea8067121e2fd3 100644 (file)
@@ -314,8 +314,8 @@ Format 2
 \bind "S-KP_Next"                    "screen-down-select"
 \bind "S-C-KP_Home"                  "buffer-begin-select"
 \bind "S-C-KP_End"                   "buffer-end-select"
-\bind "S-C-KP_Prior"                 "buffer-begin-select"
-\bind "S-C-KP_Next"                  "buffer-end-select"
+\bind "S-C-KP_Prior"                 "buffer-move-previous"
+\bind "S-C-KP_Next"                  "buffer-move-next"
 \bind "C-KP_Insert"                  "copy"
 \bind "S-KP_Insert"                  "paste"
 \bind "S-KP_Delete"                  "cut"
index e3d69af2615d2ce0d22ac640ca53f184c9a397e0..32c67b190ddd4ea4a95041814ff97a4d5661da9c 100644 (file)
@@ -249,8 +249,8 @@ Format 2
 \bind "S-C-KP_Down"             "paragraph-down-select"
 \bind "S-KP_Home"               "line-begin-select"
 \bind "S-KP_End"                "line-end-select"
-\bind "S-KP_Prior"              "screen-up-select"
-\bind "S-KP_Next"               "screen-down-select"
+\bind "S-KP_Prior"              "buffer-move-previous"
+\bind "S-KP_Next"               "buffer-move-next"
 \bind "S-C-KP_Home"             "buffer-begin-select"
 \bind "S-C-KP_End"              "buffer-end-select"
 \bind "S-C-KP_Prior"            "buffer-begin-select"
index b590b38eaa16a792fe7e8ca4d509dca375f4023b..91526b93a5a05a5b7a5025d7dee6b99d351523a0 100644 (file)
@@ -460,6 +460,9 @@ enum FuncCode
        LFUN_SEPARATOR_INSERT,          // ef 20140502
        LFUN_SERVER_GET_STATISTICS,     // brokenclock 20141010
        LFUN_BUFFER_VIEW_CACHE,         // skostysh 20150401
+       LFUN_BUFFER_MOVE_NEXT,          // skostysh 20150408
+       // 340
+       LFUN_BUFFER_MOVE_PREVIOUS,      // skostysh 20150408
        LFUN_LASTACTION                 // end of the table
 };
 
index 1ba2ef81cf93ca29ffb140705a125e7f93734698..10d43f5ffbf682a41df5732a66390cede4b41dde 100644 (file)
@@ -3289,6 +3289,13 @@ void LyXAction::init()
  * \endvar
  */
                { LFUN_BUFFER_NEXT, "buffer-next", ReadOnly, Buffer },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_BUFFER_MOVE_NEXT
+ * \li Action: Moves the current tab one spot to the right.
+ * \li Syntax: buffer-move-next
+ * \endvar
+ */
+               { LFUN_BUFFER_MOVE_NEXT, "buffer-move-next", ReadOnly, Buffer },
 /*!
  * \var lyx::FuncCode lyx::LFUN_BUFFER_PREVIOUS
  * \li Action: Switch to the previous opened document.
@@ -3296,6 +3303,13 @@ void LyXAction::init()
  * \endvar
  */
                { LFUN_BUFFER_PREVIOUS, "buffer-previous", ReadOnly, Buffer },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_BUFFER_MOVE_PREVIOUS
+ * \li Action: Moves the current tab one spot to the left.
+ * \li Syntax: buffer-move-previous
+ * \endvar
+ */
+               { LFUN_BUFFER_MOVE_PREVIOUS, "buffer-move-previous", ReadOnly, Buffer },
 /*!
  * \var lyx::FuncCode lyx::LFUN_MASTER_BUFFER_UPDATE
  * \li Action: Update (export) the document built from the master buffer,
index 5e8893bfc87770c210a7a5763ef3e327bf09be79..a520b4eb54ae2e2524dbcc17325245d5fcd0b245 100644 (file)
@@ -1921,6 +1921,9 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                enable = doc_buffer;
                break;
 
+       case LFUN_BUFFER_MOVE_NEXT:
+       case LFUN_BUFFER_MOVE_PREVIOUS:
+               // we do not cycle when moving
        case LFUN_BUFFER_NEXT:
        case LFUN_BUFFER_PREVIOUS:
                // because we cycle, it doesn't matter whether on first or last
@@ -2917,7 +2920,7 @@ bool GuiView::inOtherView(Buffer & buf)
 }
 
 
-void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
+void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np, bool const move)
 {
        if (!documentBufferView())
                return;
@@ -2932,7 +2935,10 @@ void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
                                        next_index = (i == nwa - 1 ? 0 : i + 1);
                                else
                                        next_index = (i == 0 ? nwa - 1 : i - 1);
-                               setBuffer(&workArea(next_index)->bufferView().buffer());
+                               if (move)
+                                       twa->moveTab(i, next_index);
+                               else
+                                       setBuffer(&workArea(next_index)->bufferView().buffer());
                                break;
                        }
                }
@@ -3546,11 +3552,19 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                }
 
                case LFUN_BUFFER_NEXT:
-                       gotoNextOrPreviousBuffer(NEXTBUFFER);
+                       gotoNextOrPreviousBuffer(NEXTBUFFER, false);
+                       break;
+
+               case LFUN_BUFFER_MOVE_NEXT:
+                       gotoNextOrPreviousBuffer(NEXTBUFFER, true);
                        break;
 
                case LFUN_BUFFER_PREVIOUS:
-                       gotoNextOrPreviousBuffer(PREVBUFFER);
+                       gotoNextOrPreviousBuffer(PREVBUFFER, false);
+                       break;
+
+               case LFUN_BUFFER_MOVE_PREVIOUS:
+                       gotoNextOrPreviousBuffer(PREVBUFFER, true);
                        break;
 
                case LFUN_COMMAND_EXECUTE: {
index f7b488b713ca40a591b3374c944a8dc15ea2ff83..478e3a191724f4ff7a57143949d496bc27984613 100644 (file)
@@ -421,7 +421,7 @@ private:
                PREVBUFFER
        };
        ///
-       void gotoNextOrPreviousBuffer(NextOrPrevious np);
+       void gotoNextOrPreviousBuffer(NextOrPrevious np, bool const move);
 
        /// Is the dialog currently visible?
        bool isDialogVisible(std::string const & name) const;
index fb6341b1a0789776acbf358eb676256e9357fc87..5039e45b84a97da4f7df7d3ab7c7329b15c1f891 100644 (file)
@@ -218,6 +218,8 @@ public Q_SLOTS:
        /// close the tab given by \c index
        void closeTab(int index);
        ///
+       void moveTab(int fromIndex, int toIndex);
+       ///
        void updateTabTexts();
        
 private Q_SLOTS:
@@ -226,8 +228,6 @@ private Q_SLOTS:
        ///
        void showContextMenu(const QPoint & pos);
        ///
-       void moveTab(int fromIndex, int toIndex);
-       ///
        void mouseDoubleClickEvent(QMouseEvent * event);
 
 private: