From 8b7da465d898995f79e4808fb46a069451ce19ec Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 22 Oct 2004 10:24:55 +0000 Subject: [PATCH] implement buffer-next/previous (bug 515) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9103 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 7 +++++++ lib/bind/cua.bind | 6 +++++- lib/bind/emacs.bind | 2 ++ lib/bind/mac.bind | 2 ++ lib/bind/xemacs.bind | 2 ++ src/ChangeLog | 9 +++++++++ src/LyXAction.C | 2 ++ src/bufferlist.C | 29 +++++++++++++++++++++++++++++ src/bufferlist.h | 12 ++++++++++++ src/lfuns.h | 2 ++ src/lyxfunc.C | 10 ++++++++++ 11 files changed, 82 insertions(+), 1 deletion(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 9bb8786b38..fcc5c36a87 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,10 @@ +2004-10-19 Jean-Marc Lasgouttes + + * bind/xemacs.bind: + * bind/emacs.bind: + * bind/mac.bind: + * bind/cua.bind: add bindings for buffer-previous/next + 2004-10-18 Andreas Vox * layouts/db_stdstarsections.inc: fix definition, no title. diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index dfe14041c1..28ba65aade 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -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" @@ -85,8 +87,10 @@ \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" diff --git a/lib/bind/emacs.bind b/lib/bind/emacs.bind index 7e4ce76efc..353290d75a 100644 --- a/lib/bind/emacs.bind +++ b/lib/bind/emacs.bind @@ -101,6 +101,8 @@ #\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 diff --git a/lib/bind/mac.bind b/lib/bind/mac.bind index 00fec4c516..1021590306 100644 --- a/lib/bind/mac.bind +++ b/lib/bind/mac.bind @@ -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" diff --git a/lib/bind/xemacs.bind b/lib/bind/xemacs.bind index 6b9e74ca8c..b99482352c 100644 --- a/lib/bind/xemacs.bind +++ b/lib/bind/xemacs.bind @@ -111,6 +111,8 @@ \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" "------" diff --git a/src/ChangeLog b/src/ChangeLog index caa962d769..4e06c64112 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2004-10-18 Jean-Marc Lasgouttes + + * 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 * buffer.C (makeDocBookFile): add dsssl stylesheet control diff --git a/src/LyXAction.C b/src/LyXAction.C index a1be389b6c..e4b582b128 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -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 } }; diff --git a/src/bufferlist.C b/src/bufferlist.C index 29fabe9d84..109d25f9e7 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -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) { diff --git a/src/bufferlist.h b/src/bufferlist.h index 5d8ddab2e4..0b480edc03 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -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); diff --git a/src/lfuns.h b/src/lfuns.h index 9cbaf7d7ee..c37368e40b 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -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 }; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index a2dadf5f93..bbff9e1f5a 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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; -- 2.39.2