From 6742e42e79ed4943816a376c8b928cf15b9f29fb Mon Sep 17 00:00:00 2001 From: Dov Feldstern Date: Mon, 11 Jun 2007 22:05:44 +0000 Subject: [PATCH] KeyMap is now switched (if necessary) only just before it is actually used for translating keystrokes. Up until now, the switching was done in advance in all kinds of situations, but not just before translating was actually done --- which resulted in the KeyMap not always being switched on time... This solves bug #3811 (http://bugzilla.lyx.org/show_bug.cgi?id=3811) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18744 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 8 +++----- src/BufferView.h | 4 ++-- src/Text3.cpp | 16 ++-------------- src/mathed/InsetMathGrid.cpp | 1 - src/mathed/InsetMathNest.cpp | 1 - 5 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 59587b8130..2d4288a0fe 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -313,7 +313,6 @@ void BufferView::resize() LYXERR(Debug::DEBUG) << BOOST_CURRENT_FUNCTION << endl; updateMetrics(false); - switchKeyMap(); } @@ -627,7 +626,7 @@ boost::tuple BufferView::moveToPosition(pit_type bottom } -void BufferView::switchKeyMap() +void BufferView::translateAndInsert(char_type c, Text * t, Cursor & cur) { if (!lyxrc.rtl_support) return; @@ -639,6 +638,8 @@ void BufferView::switchKeyMap() if (intl_->keymap == Intl::SECONDARY) intl_->keyMapPrim(); } + + intl_->getTransManager().translateAndInsert(c, t, cur); } @@ -779,7 +780,6 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd) cur.message(_("No further undo information")); updateFlags = Update::None; } - switchKeyMap(); break; case LFUN_REDO: @@ -789,7 +789,6 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd) cur.message(_("No further redo information")); updateFlags = Update::None; } - switchKeyMap(); break; case LFUN_FILE_INSERT: @@ -851,7 +850,6 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd) if (b == buffer_) { // Set the cursor setCursor(makeDocIterator(par, 0)); - switchKeyMap(); } else { // Switch to other buffer view and resend cmd theLyXFunc().dispatch(FuncRequest( diff --git a/src/BufferView.h b/src/BufferView.h index 7da1a08d94..c2b8703bc8 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -146,8 +146,8 @@ public: /// return the pixel height of the document view. int workHeight() const; - /// switch between primary and secondary keymaps for RTL entry. - void switchKeyMap(); + /// translate and insert a character, using the correct keymap. + void translateAndInsert(char_type c, Text * t, Cursor & cur); /// return true for events that will handle. FuncStatus getStatus(FuncRequest const & cmd); diff --git a/src/Text3.cpp b/src/Text3.cpp index d3a4d376e6..31537675bb 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -120,7 +120,6 @@ namespace { if (selecting || cur.mark()) cur.setSelection(); saveSelection(cur); - cur.bv().switchKeyMap(); } @@ -679,7 +678,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cutSelection(cur, true, false); singleParUpdate = false; } - bv->switchKeyMap(); break; case LFUN_DELETE_BACKWARD_SKIP: @@ -700,14 +698,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cap::replaceSelection(cur); breakParagraph(cur, 0); cur.resetAnchor(); - bv->switchKeyMap(); break; case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT: cap::replaceSelection(cur); breakParagraph(cur, 1); cur.resetAnchor(); - bv->switchKeyMap(); break; case LFUN_BREAK_PARAGRAPH_SKIP: { @@ -719,7 +715,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) else breakParagraph(cur, 0); cur.resetAnchor(); - bv->switchKeyMap(); break; } @@ -862,7 +857,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } bv->buffer()->errors("Paste"); cur.clearSelection(); // bug 393 - bv->switchKeyMap(); finishUndo(); break; @@ -953,7 +947,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) setLayout(cur, layout); // inform the GUI that the layout has changed. bv->layoutChanged(layout); - bv->switchKeyMap(); } break; } @@ -1075,7 +1068,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cap::pasteSelection(cur, bv->buffer()->errorList("Paste")); bv->buffer()->errors("Paste"); cur.clearSelection(); // bug 393 - bv->switchKeyMap(); bv->buffer()->markDirty(); finishUndo(); } else { @@ -1156,7 +1148,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.noUpdate(); } - bv->switchKeyMap(); break; } @@ -1180,8 +1171,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) docstring::const_iterator cit = cmd.argument().begin(); docstring::const_iterator end = cmd.argument().end(); for (; cit != end; ++cit) - bv->getIntl().getTransManager(). - translateAndInsert(*cit, this, cur); + bv->translateAndInsert(*cit, this, cur); cur.resetAnchor(); moveCursor(cur, false); @@ -1449,7 +1439,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) Font font(Font::ALL_IGNORE); font.setLanguage(lang); toggleAndShow(cur, this, font); - bv->switchKeyMap(); break; } @@ -1524,8 +1513,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) theLyXFunc().handleKeyFunc(cmd.action); if (!cmd.argument().empty()) // FIXME: Are all these characters encoded in one byte in utf8? - bv->getIntl().getTransManager() - .translateAndInsert(cmd.argument()[0], this, cur); + bv->translateAndInsert(cmd.argument()[0], this, cur); break; case LFUN_FLOAT_LIST: { diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index 928e452d80..a3b680dd34 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -1208,7 +1208,6 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd) cell(i).append(grid.cell(grid.index(r, c))); } cur.clearSelection(); // bug 393 - cur.bv().switchKeyMap(); finishUndo(); break; } diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index c4ebba132b..f3790b1928 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -459,7 +459,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) } cur.niceInsert(topaste); cur.clearSelection(); // bug 393 - cur.bv().switchKeyMap(); finishUndo(); break; }