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
This commit is contained in:
Dov Feldstern 2007-06-11 22:05:44 +00:00
parent 82c2fbf81a
commit 6742e42e79
5 changed files with 7 additions and 23 deletions

View 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(

View 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);

View 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: {

View 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;
}

View File

@ -459,7 +459,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
}
cur.niceInsert(topaste);
cur.clearSelection(); // bug 393
cur.bv().switchKeyMap();
finishUndo();
break;
}