From 78356819eae5a2ffe183ea3dae974ce8dbd18622 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Tue, 24 Jun 2008 07:52:49 +0000 Subject: [PATCH] Move LFUN_ALL_INSETS_TOGGLE dispatch to BufferView. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25371 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 26 +++++++++++++++++++++++++- src/LyXFunc.cpp | 27 --------------------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 9dec257ac4..053e2932af 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -867,6 +867,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd) case LFUN_BIBTEX_DATABASE_DEL: case LFUN_GRAPHICS_GROUPS_UNIFY: case LFUN_NOTES_MUTATE: + case LFUN_ALL_INSETS_TOGGLE: case LFUN_STATISTICS: flag.setEnabled(true); break; @@ -1404,7 +1405,7 @@ bool BufferView::dispatch(FuncRequest const & cmd) processUpdateFlags(Update::Force); break; - // These Two could be rewriten using some command like forall + // These two could be rewriten using some command like forall // once the insets refactoring is done. case LFUN_GRAPHICS_GROUPS_UNIFY: { if (cmd.argument().empty()) @@ -1426,6 +1427,29 @@ bool BufferView::dispatch(FuncRequest const & cmd) break; } + case LFUN_ALL_INSETS_TOGGLE: { + string action; + string const name = split(to_utf8(cmd.argument()), action, ' '); + InsetCode const inset_code = insetCode(name); + + FuncRequest fr(LFUN_INSET_TOGGLE, action); + + Inset & inset = cur.buffer().inset(); + InsetIterator it = inset_iterator_begin(inset); + InsetIterator const end = inset_iterator_end(inset); + for (; it != end; ++it) { + if (!it->asInsetMath() + && (inset_code == NO_CODE + || inset_code == it->lyxCode())) { + Cursor tmpcur = cur; + tmpcur.pushBackward(*it); + it->dispatch(tmpcur, fr); + } + } + processUpdateFlags(Update::Force | Update::FitCursor); + break; + } + default: return false; } diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 8c352c2661..6c9d532287 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -581,7 +581,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const case LFUN_PREFERENCES_SAVE: case LFUN_MESSAGE: case LFUN_INSET_EDIT: - case LFUN_ALL_INSETS_TOGGLE: case LFUN_BUFFER_LANGUAGE: case LFUN_TEXTCLASS_APPLY: case LFUN_TEXTCLASS_LOAD: @@ -1378,32 +1377,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd) lyx_view_->message(from_utf8(argument)); break; - - case LFUN_ALL_INSETS_TOGGLE: { - LASSERT(lyx_view_, /**/); - string action; - string const name = split(argument, action, ' '); - InsetCode const inset_code = insetCode(name); - - Cursor & cur = view()->cursor(); - FuncRequest fr(LFUN_INSET_TOGGLE, action); - - Inset & inset = lyx_view_->buffer()->inset(); - InsetIterator it = inset_iterator_begin(inset); - InsetIterator const end = inset_iterator_end(inset); - for (; it != end; ++it) { - if (!it->asInsetMath() - && (inset_code == NO_CODE - || inset_code == it->lyxCode())) { - Cursor tmpcur = cur; - tmpcur.pushBackward(*it); - it->dispatch(tmpcur, fr); - } - } - updateFlags = Update::Force | Update::FitCursor; - break; - } - case LFUN_BUFFER_LANGUAGE: { LASSERT(lyx_view_, /**/); Buffer & buffer = *lyx_view_->buffer();