]> git.lyx.org Git - features.git/commitdiff
implement buffer-next/previous (bug 515)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Oct 2004 10:24:55 +0000 (10:24 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Oct 2004 10:24:55 +0000 (10:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9103 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/bind/cua.bind
lib/bind/emacs.bind
lib/bind/mac.bind
lib/bind/xemacs.bind
src/ChangeLog
src/LyXAction.C
src/bufferlist.C
src/bufferlist.h
src/lfuns.h
src/lyxfunc.C

index 9bb8786b38a11a4917acde4cc0393024294ff592..fcc5c36a87f2dc727abcc86cc445e9cc80e8b95f 100644 (file)
@@ -1,3 +1,10 @@
+2004-10-19  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * bind/xemacs.bind: 
+       * bind/emacs.bind: 
+       * bind/mac.bind: 
+       * bind/cua.bind: add bindings for buffer-previous/next
+
 2004-10-18  Andreas Vox  <vox@isp.uni-luebeck.de>
 
        * layouts/db_stdstarsections.inc: fix definition, no title.
index dfe14041c191c54395a25ad68556422431b6b76f..28ba65aade49ce89abdabee2b04e14cb3e9cc0d8 100644 (file)
@@ -49,6 +49,8 @@
 \bind "C-S-D"                  "buffer-update dvi"     # 'd' for dvi
 \bind "C-S-T"                  "buffer-update ps"
 \bind "C-q"                    "lyx-quit"
+\bind "C-Next"                 "buffer-next"
+\bind "C-Prior"                        "buffer-previous"
 
 \bind "C-b"                    "font-bold"
 \bind "C-e"                    "font-emph"
 \bind "F2"                     "buffer-write"
 \bind "F3"                     "file-open"
 \bind "C-F4"                   "buffer-close"
-\bind "F5"                     "screen-recenter"
 \bind "M-F4"                   "lyx-quit"
+\bind "F5"                     "screen-recenter"
+\bind "C-F6"                   "buffer-next"
+\bind "C-S-F6"                 "buffer-previous"
 \bind "F7"                     "dialog-show spellchecker"
 \bind "S-F7"                   "thesaurus-entry"
 
index 7e4ce76efc42d3bd97c0e379133debcb995e4ea5..353290d75ac89be08bbf0557da2720a689c4c553 100644 (file)
 #\bind "C-x C-r"                "buffer-update dvi"
 \bind "C-x C-s"                "buffer-write"
 \bind "C-x C-t"                "buffer-update dvi"
+\bind "C-Next"                "buffer-next"
+\bind "C-Prior"                       "buffer-previous"
 
 
 # this is "upcase-region" in emacs
index 00fec4c516a4c566970264bc2b1de6c649a662ef..10215903069f57d4debcb598a8ebac529dac34e9 100644 (file)
@@ -40,6 +40,8 @@
 \bind "C-S-D"                  "buffer-update dvi"     # 'd' for dvi
 \bind "C-S-T"                  "buffer-update pdf"    # (pdflatex; was "ps")
 \bind "C-q"                    "lyx-quit"
+\bind "C-grave"                "buffer-next"
+\bind "C-asciitilde"           "buffer-previous"
 
 \bind "C-b"                    "font-bold"
 \bind "C-e"                    "font-emph"
index 6b9e74ca8c29e99c1c4901f24d9efb986f1c3d4c..b99482352ce1655b60a2dd29de4d8180ae4f345b 100644 (file)
 \bind "C-x C-t"                "buffer-update dvi"
 \bind "C-x C-u"                        "word-upcase"           # upcase-region!
 \bind "C-x C-w"                "buffer-write-as"
+\bind "C-Next"                "buffer-next"
+\bind "C-Prior"                       "buffer-previous"
 
 #bind "C-1"                    "------"
 #bind "C-2"                    "------"
index caa962d769445640ec5623606f7e36760c8b9f86..4e06c64112889bf5f7f011fd1233983e00c13c61 100644 (file)
@@ -1,3 +1,12 @@
+2004-10-18  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * lyxfunc.C (getStatus,dispatch): handle LFUN_(PREVIOUS|NEXT)BUFFER
+
+       * bufferlist.C (previous, next): new methods
+
+       * lfuns.h: 
+       * LyXAction.C (init): add LFUN_NEXTBUFFER and LFUN_PREVIOUSBUFFER
+
 2004-10-18  Andreas Vox  <vox@isp.uni-luebeck.de>
 
        * buffer.C (makeDocBookFile): add dsssl stylesheet control
index a1be389b6cae9c602a69d8768e6e0c5c06170a53..e4b582b128c13d89cd6efc7bd77ce707cc7c1e6f 100644 (file)
@@ -337,6 +337,8 @@ void LyXAction::init()
                { LFUN_BUFFERPARAMS_APPLY, "buffer-params-apply", Noop },
                { LFUN_LYXRC_APPLY, "lyxrc-apply", NoBuffer },
                { LFUN_INSET_REFRESH, "", Noop },
+               { LFUN_NEXTBUFFER, "buffer-next", ReadOnly },
+               { LFUN_PREVIOUSBUFFER, "buffer-previous", ReadOnly },
                { LFUN_NOACTION, "", Noop }
        };
 
index 29fabe9d84753de981221b0a90ce7bc0ca59c88e..109d25f9e71e36790c79763d3d86ab53393cc79d 100644 (file)
@@ -217,6 +217,35 @@ Buffer * BufferList::getBuffer(unsigned int choice)
 }
 
 
+Buffer * BufferList::next(Buffer const * buf) const 
+{
+       if (bstore.empty())
+               return 0;
+       BufferStorage::const_iterator it = find(bstore.begin(), 
+                                               bstore.end(), buf);
+       BOOST_ASSERT(it != bstore.end());
+       ++it;
+       if (it == bstore.end())
+               return bstore.front();
+       else
+               return *it;
+}
+
+
+Buffer * BufferList::previous(Buffer const * buf) const 
+{
+       if (bstore.empty())
+               return 0;
+       BufferStorage::const_iterator it = find(bstore.begin(), 
+                                               bstore.end(), buf);
+       BOOST_ASSERT(it != bstore.end());
+       if (it == bstore.begin())
+               return bstore.back();
+       else
+               return *(it - 1);
+}
+
+
 void BufferList::updateIncludedTeXfiles(string const & mastertmpdir,
                                        OutputParams const & runparams)
 {
index 5d8ddab2e4828699f08ef89c65430ba60ff68571..0b480edc03de4731b134351dd9369a0f697aa07d 100644 (file)
@@ -71,6 +71,18 @@ public:
        /// returns a pointer to the buffer whose temppath matches the string
        Buffer * BufferList::getBufferFromTmp(std::string const &);
 
+       /** returns a pointer to the buffer that follows argument in
+        * buffer list. The buffer following the last in list is the
+        * first one.
+        */
+       Buffer * next(Buffer const *) const;
+
+       /** returns a pointer to the buffer that precedes argument in
+        * buffer list. The buffer preceding the first in list is the
+        * last one.
+        */
+       Buffer * previous(Buffer const *) const;
+
        /// reset current author for all buffers
        void setCurrentAuthor(std::string const & name, std::string const & email);
 
index 9cbaf7d7eeff48d122237127aff5302ec2d5f8f5..c37368e40b8b2c77a8beeeffaf31bb2322252b42 100644 (file)
@@ -350,6 +350,8 @@ enum kb_action {
        LFUN_LYXRC_APPLY,
        LFUN_GRAPHICS_EDIT,
        LFUN_INSET_REFRESH,
+       LFUN_NEXTBUFFER,
+       LFUN_PREVIOUSBUFFER,
 
        LFUN_LASTACTION                  // end of the table
 };
index a2dadf5f933fb7ab3d7cc7e420bd87291b8fe6ec..bbff9e1f5ae0b54fb67c2c8e0c893b4a8a7627b0 100644 (file)
@@ -503,6 +503,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_SAVE_AS_DEFAULT:
        case LFUN_BUFFERPARAMS_APPLY:
        case LFUN_LYXRC_APPLY:
+       case LFUN_NEXTBUFFER:
+       case LFUN_PREVIOUSBUFFER:
                // these are handled in our dispatch()
                break;
 
@@ -958,6 +960,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
                        view()->setBuffer(bufferlist.getBuffer(argument));
                        break;
 
+               case LFUN_NEXTBUFFER:
+                       view()->setBuffer(bufferlist.next(view()->buffer()));
+                       break;
+
+               case LFUN_PREVIOUSBUFFER:
+                       view()->setBuffer(bufferlist.previous(view()->buffer()));
+                       break;
+
                case LFUN_FILE_NEW:
                        NewFile(view(), argument);
                        break;