]> git.lyx.org Git - features.git/commitdiff
KeyMap is now switched (if necessary) only just before it is actually used
authorDov Feldstern <dov@lyx.org>
Mon, 11 Jun 2007 22:05:44 +0000 (22:05 +0000)
committerDov Feldstern <dov@lyx.org>
Mon, 11 Jun 2007 22:05:44 +0000 (22:05 +0000)
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
src/BufferView.h
src/Text3.cpp
src/mathed/InsetMathGrid.cpp
src/mathed/InsetMathNest.cpp

index 59587b81303680334122b2a3af0bb62f236914b3..2d4288a0fe3c693ad5f6a566a90c97ae7e3a44ef 100644 (file)
@@ -313,7 +313,6 @@ void BufferView::resize()
        LYXERR(Debug::DEBUG) << BOOST_CURRENT_FUNCTION << endl;
 
        updateMetrics(false);
-       switchKeyMap();
 }
 
 
@@ -627,7 +626,7 @@ boost::tuple<pit_type, pos_type, int> 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(
index 7da1a08d94d54f4474118520b60d25b4b342bba5..c2b8703bc8b2f9f0e44df053f3f44df5517ec810 100644 (file)
@@ -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);
index d3a4d376e69bc3b22f63a56b7c65c83fa749916f..31537675bb940258612b5bc53bd773fbce5cfe7f 100644 (file)
@@ -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: {
index 928e452d80843bdcbfa303a929ab334e194fe465..a3b680dd34d21949e936d4009241ff5a29c3d10c 100644 (file)
@@ -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;
        }
index c4ebba132bd09f0f52047b76f1bd4e2aa9174392..f3790b192857a713a3eb610836c36061eeb8e8ed 100644 (file)
@@ -459,7 +459,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                }
                cur.niceInsert(topaste);
                cur.clearSelection(); // bug 393
-               cur.bv().switchKeyMap();
                finishUndo();
                break;
        }