mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
Getting rid of LTR bias --- part 3/4
This is a continuation of r21128, r21244 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21448 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c888185ffc
commit
ddd82f7aa4
@ -1320,7 +1320,7 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
|
||||
if (inset) {
|
||||
if (inset->isActive()) {
|
||||
Cursor tmpcur = cur;
|
||||
tmpcur.pushLeft(*inset);
|
||||
tmpcur.pushBackward(*inset);
|
||||
inset->dispatch(tmpcur, tmpcmd);
|
||||
if (tmpcur.result().dispatched()) {
|
||||
cur.dispatched();
|
||||
|
@ -370,19 +370,19 @@ void Cursor::push(Inset & p)
|
||||
}
|
||||
|
||||
|
||||
void Cursor::pushLeft(Inset & p)
|
||||
void Cursor::pushBackward(Inset & p)
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
//lyxerr << "Entering inset " << t << " left" << endl;
|
||||
//lyxerr << "Entering inset " << t << " front" << endl;
|
||||
push(p);
|
||||
p.idxFirst(*this);
|
||||
}
|
||||
|
||||
|
||||
bool Cursor::popLeft()
|
||||
bool Cursor::popBackward()
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
//lyxerr << "Leaving inset to the left" << endl;
|
||||
//lyxerr << "Leaving inset from in front" << endl;
|
||||
inset().notifyCursorLeaves(*this);
|
||||
if (depth() == 1)
|
||||
return false;
|
||||
@ -391,10 +391,10 @@ bool Cursor::popLeft()
|
||||
}
|
||||
|
||||
|
||||
bool Cursor::popRight()
|
||||
bool Cursor::popForward()
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
//lyxerr << "Leaving inset to the right" << endl;
|
||||
//lyxerr << "Leaving inset from in back" << endl;
|
||||
const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
|
||||
inset().notifyCursorLeaves(*this);
|
||||
if (depth() == 1)
|
||||
@ -440,7 +440,7 @@ void Cursor::resetAnchor()
|
||||
|
||||
|
||||
|
||||
bool Cursor::posLeft()
|
||||
bool Cursor::posBackward()
|
||||
{
|
||||
if (pos() == 0)
|
||||
return false;
|
||||
@ -449,7 +449,7 @@ bool Cursor::posLeft()
|
||||
}
|
||||
|
||||
|
||||
bool Cursor::posRight()
|
||||
bool Cursor::posForward()
|
||||
{
|
||||
if (pos() == lastpos())
|
||||
return false;
|
||||
@ -772,10 +772,10 @@ void Cursor::niceInsert(MathAtom const & t)
|
||||
plainInsert(t);
|
||||
// enter the new inset and move the contents of the selection if possible
|
||||
if (t->isActive()) {
|
||||
posLeft();
|
||||
// be careful here: don't use 'pushLeft(t)' as this we need to
|
||||
posBackward();
|
||||
// be careful here: don't use 'pushBackward(t)' as this we need to
|
||||
// push the clone, not the original
|
||||
pushLeft(*nextInset());
|
||||
pushBackward(*nextInset());
|
||||
// We may not use niceInsert here (recursion)
|
||||
MathData ar;
|
||||
asArray(safe, ar);
|
||||
@ -806,7 +806,7 @@ bool Cursor::backspace()
|
||||
if (pos() == 0) {
|
||||
// If empty cell, and not part of a big cell
|
||||
if (lastpos() == 0 && inset().nargs() == 1) {
|
||||
popLeft();
|
||||
popBackward();
|
||||
// Directly delete empty cell: [|[]] => [|]
|
||||
if (inMathed()) {
|
||||
plainErase();
|
||||
@ -819,7 +819,7 @@ bool Cursor::backspace()
|
||||
if (inMathed())
|
||||
pullArg();
|
||||
else
|
||||
popLeft();
|
||||
popBackward();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -865,7 +865,7 @@ bool Cursor::erase()
|
||||
if (pos() == lastpos()) {
|
||||
bool one_cell = inset().nargs() == 1;
|
||||
if (one_cell && lastpos() == 0) {
|
||||
popLeft();
|
||||
popBackward();
|
||||
// Directly delete empty cell: [|[]] => [|]
|
||||
if (inMathed()) {
|
||||
plainErase();
|
||||
@ -967,8 +967,8 @@ void Cursor::handleNest(MathAtom const & a, int c)
|
||||
MathAtom t = a;
|
||||
asArray(cap::grabAndEraseSelection(*this), t.nucleus()->cell(c));
|
||||
insert(t);
|
||||
posLeft();
|
||||
pushLeft(*nextInset());
|
||||
posBackward();
|
||||
pushBackward(*nextInset());
|
||||
}
|
||||
|
||||
|
||||
@ -1019,7 +1019,7 @@ void Cursor::pullArg()
|
||||
{
|
||||
// FIXME: Look here
|
||||
MathData ar = cell();
|
||||
if (popLeft() && inMathed()) {
|
||||
if (popBackward() && inMathed()) {
|
||||
plainErase();
|
||||
cell().insert(pos(), ar);
|
||||
resetAnchor();
|
||||
@ -1161,8 +1161,8 @@ bool Cursor::upDownInMath(bool up)
|
||||
}
|
||||
|
||||
// any improvement going just out of inset?
|
||||
if (popLeft() && inMathed()) {
|
||||
//lyxerr << "updown: popLeft succeeded" << endl;
|
||||
if (popBackward() && inMathed()) {
|
||||
//lyxerr << "updown: popBackward succeeded" << endl;
|
||||
int xnew;
|
||||
int ynew;
|
||||
getPos(xnew, ynew);
|
||||
@ -1303,17 +1303,17 @@ void Cursor::handleFont(string const & font)
|
||||
// something left in the cell
|
||||
if (pos() == 0) {
|
||||
// cursor in first position
|
||||
popLeft();
|
||||
popBackward();
|
||||
} else if (pos() == lastpos()) {
|
||||
// cursor in last position
|
||||
popRight();
|
||||
popForward();
|
||||
} else {
|
||||
// cursor in between. split cell
|
||||
MathData::iterator bt = cell().begin();
|
||||
MathAtom at = createInsetMath(from_utf8(font));
|
||||
at.nucleus()->cell(0) = MathData(bt, bt + pos());
|
||||
cell().erase(bt, bt + pos());
|
||||
popLeft();
|
||||
popBackward();
|
||||
plainInsert(at);
|
||||
}
|
||||
} else {
|
||||
|
20
src/Cursor.h
20
src/Cursor.h
@ -48,14 +48,14 @@ public:
|
||||
DispatchResult result() const;
|
||||
/// add a new cursor slice
|
||||
void push(Inset & inset);
|
||||
/// add a new cursor slice, place cursor on left end
|
||||
void pushLeft(Inset & inset);
|
||||
/// add a new cursor slice, place cursor at front (move backwards)
|
||||
void pushBackward(Inset & inset);
|
||||
/// pop one level off the cursor
|
||||
void pop();
|
||||
/// pop one slice off the cursor stack and go left
|
||||
bool popLeft();
|
||||
/// pop one slice off the cursor stack and go right
|
||||
bool popRight();
|
||||
/// pop one slice off the cursor stack and go backwards
|
||||
bool popBackward();
|
||||
/// pop one slice off the cursor stack and go forward
|
||||
bool popForward();
|
||||
/// make sure we are outside of given inset
|
||||
void leaveInset(Inset const & inset);
|
||||
/// sets cursor part
|
||||
@ -112,10 +112,10 @@ public:
|
||||
//
|
||||
// common part
|
||||
//
|
||||
/// move one step to the left
|
||||
bool posLeft();
|
||||
/// move one step to the right
|
||||
bool posRight();
|
||||
/// move one step backwards
|
||||
bool posBackward();
|
||||
/// move one step forward
|
||||
bool posForward();
|
||||
|
||||
/// insert an inset
|
||||
void insert(Inset *);
|
||||
|
@ -1841,7 +1841,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
&& (inset_code == NO_CODE
|
||||
|| inset_code == it->lyxCode())) {
|
||||
Cursor tmpcur = cur;
|
||||
tmpcur.pushLeft(*it);
|
||||
tmpcur.pushBackward(*it);
|
||||
it->dispatch(tmpcur, fr);
|
||||
}
|
||||
}
|
||||
|
@ -1053,7 +1053,7 @@ bool Text::dissolveInset(Cursor & cur) {
|
||||
ParagraphList plist;
|
||||
if (cur.lastpit() != 0 || cur.lastpos() != 0)
|
||||
plist = paragraphs();
|
||||
cur.popLeft();
|
||||
cur.popBackward();
|
||||
// store cursor offset
|
||||
if (spit == 0)
|
||||
spos += cur.pos();
|
||||
|
@ -179,7 +179,7 @@ static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind)
|
||||
cur.recordUndo();
|
||||
cap::replaceSelection(cur);
|
||||
cur.insert(new InsetSpecialChar(kind));
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
}
|
||||
|
||||
|
||||
@ -558,7 +558,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cur.recordUndo();
|
||||
cap::replaceSelection(cur);
|
||||
cur.insert(new InsetNewline);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
moveCursor(cur, false);
|
||||
}
|
||||
break;
|
||||
@ -714,7 +714,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
if (cur.selection())
|
||||
cutSelection(cur, true, false);
|
||||
insertInset(cur, inset);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -732,7 +732,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
insertChar(cur, ' ');
|
||||
else {
|
||||
doInsertInset(cur, this, cmd, false, false);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
}
|
||||
moveCursor(cur, false);
|
||||
break;
|
||||
@ -936,7 +936,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cur.insert(new InsetQuotes(c,
|
||||
bufparams.quotes_language,
|
||||
InsetQuotes::DoubleQ));
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
}
|
||||
else
|
||||
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
|
||||
@ -1156,7 +1156,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds));
|
||||
}
|
||||
insertInset(cur, inset);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
@ -1168,7 +1168,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
// Open the inset, and move the current selection
|
||||
// inside it.
|
||||
doInsertInset(cur, this, cmd, true, true);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
// These insets are numbered.
|
||||
updateLabels(bv->buffer());
|
||||
break;
|
||||
@ -1185,13 +1185,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
// Open the inset, and move the current selection
|
||||
// inside it.
|
||||
doInsertInset(cur, this, cmd, true, true);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
break;
|
||||
|
||||
case LFUN_TABULAR_INSERT:
|
||||
// if there were no arguments, just open the dialog
|
||||
if (doInsertInset(cur, this, cmd, false, true))
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
else
|
||||
bv->showDialog("tabularcreate");
|
||||
|
||||
@ -1203,7 +1203,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
bool content = cur.selection(); // will some text be moved into the inset?
|
||||
|
||||
doInsertInset(cur, this, cmd, true, true);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
ParagraphList & pars = cur.text()->paragraphs();
|
||||
|
||||
TextClass const & tclass = bv->buffer().params().getTextClass();
|
||||
@ -1242,7 +1242,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
case LFUN_INDEX_INSERT:
|
||||
doInsertInset(cur, this, cmd, true, true);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
break;
|
||||
|
||||
case LFUN_NOMENCL_INSERT: {
|
||||
@ -1260,7 +1260,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
// description entry still needs to be filled in.
|
||||
if (cmd.action == LFUN_NOMENCL_INSERT)
|
||||
inset->edit(cur, true);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1274,7 +1274,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
case LFUN_CLEARDOUBLEPAGE_INSERT:
|
||||
// do nothing fancy
|
||||
doInsertInset(cur, this, cmd, false, false);
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
break;
|
||||
|
||||
case LFUN_DEPTH_DECREMENT:
|
||||
@ -1516,7 +1516,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
ParagraphParameters p;
|
||||
setParagraphs(cur, p);
|
||||
insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
|
||||
cur.posRight();
|
||||
cur.posForward();
|
||||
} else {
|
||||
lyxerr << "Non-existent float type: "
|
||||
<< to_utf8(cmd.argument()) << endl;
|
||||
|
@ -369,11 +369,11 @@ bool TextMetrics::redoParagraph(pit_type const pit)
|
||||
// when layout is set; when material is pasted.
|
||||
int const moveCursor = par.checkBiblio(buffer.params().trackChanges);
|
||||
if (moveCursor > 0)
|
||||
const_cast<Cursor &>(bv_->cursor()).posRight();
|
||||
const_cast<Cursor &>(bv_->cursor()).posForward();
|
||||
else if (moveCursor < 0) {
|
||||
Cursor & cursor = const_cast<Cursor &>(bv_->cursor());
|
||||
if (cursor.pos() >= -moveCursor)
|
||||
cursor.posLeft();
|
||||
cursor.posBackward();
|
||||
}
|
||||
|
||||
// Optimisation: this is used in the next two loops
|
||||
|
@ -180,9 +180,9 @@ public:
|
||||
/// Move one physical cell down
|
||||
virtual bool idxPrev(Cursor &) const { return false; }
|
||||
|
||||
/// Target pos when we enter the inset from the left by pressing "Right"
|
||||
/// Target pos when we enter the inset while moving forward
|
||||
virtual bool idxFirst(Cursor &) const { return false; }
|
||||
/// Target pos when we enter the inset from the right by pressing "Left"
|
||||
/// Target pos when we enter the inset while moving backwards
|
||||
virtual bool idxLast(Cursor &) const { return false; }
|
||||
|
||||
/// Delete a cell and move cursor
|
||||
|
@ -1308,10 +1308,10 @@ void InsetMathHull::handleFont2(Cursor & cur, docstring const & arg)
|
||||
}
|
||||
|
||||
|
||||
void InsetMathHull::edit(Cursor & cur, bool left)
|
||||
void InsetMathHull::edit(Cursor & cur, bool front)
|
||||
{
|
||||
cur.push(*this);
|
||||
left ? idxFirst(cur) : idxLast(cur);
|
||||
front ? idxFirst(cur) : idxLast(cur);
|
||||
// The inset formula dimension is not necessarily the same as the
|
||||
// one of the instant preview image, so we have to indicate to the
|
||||
// BufferView that a metrics update is needed.
|
||||
|
@ -196,7 +196,7 @@ public:
|
||||
///
|
||||
EDITABLE editable() const { return HIGHLY_EDITABLE; }
|
||||
///
|
||||
void edit(Cursor & cur, bool left);
|
||||
void edit(Cursor & cur, bool front);
|
||||
///
|
||||
Inset * editXY(Cursor & cur, int x, int y);
|
||||
///
|
||||
|
@ -507,10 +507,10 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cur.clearTargetX();
|
||||
cur.macroModeClose();
|
||||
if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
|
||||
cur.pushLeft(*cur.nextAtom().nucleus());
|
||||
cur.pushBackward(*cur.nextAtom().nucleus());
|
||||
cur.inset().idxFirst(cur);
|
||||
} else if (cur.posRight() || idxRight(cur)
|
||||
|| cur.popRight() || cur.selection())
|
||||
} else if (cur.posForward() || idxRight(cur)
|
||||
|| cur.popForward() || cur.selection())
|
||||
;
|
||||
else {
|
||||
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
|
||||
@ -526,11 +526,11 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cur.clearTargetX();
|
||||
cur.macroModeClose();
|
||||
if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
|
||||
cur.posLeft();
|
||||
cur.posBackward();
|
||||
cur.push(*cur.nextAtom().nucleus());
|
||||
cur.inset().idxLast(cur);
|
||||
} else if (cur.posLeft() || idxLeft(cur)
|
||||
|| cur.popLeft() || cur.selection())
|
||||
} else if (cur.posBackward() || idxLeft(cur)
|
||||
|| cur.popBackward() || cur.selection())
|
||||
;
|
||||
else {
|
||||
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
|
||||
@ -729,7 +729,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
case LFUN_INSET_TOGGLE:
|
||||
cur.recordUndo();
|
||||
lock(!lock());
|
||||
cur.popRight();
|
||||
cur.popForward();
|
||||
break;
|
||||
|
||||
case LFUN_SELF_INSERT:
|
||||
@ -760,8 +760,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
&& cur.macroModeClose()) {
|
||||
MathAtom const atom = cur.prevAtom();
|
||||
if (atom->asNestInset() && atom->isActive()) {
|
||||
cur.posLeft();
|
||||
cur.pushLeft(*cur.nextInset());
|
||||
cur.posBackward();
|
||||
cur.pushBackward(*cur.nextInset());
|
||||
}
|
||||
} else if (!interpretChar(cur, cmd.argument()[0])) {
|
||||
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
|
||||
@ -881,8 +881,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
selClearOrDel(cur);
|
||||
//cur.plainInsert(MathAtom(new InsetMathMBox(cur.bv())));
|
||||
cur.plainInsert(MathAtom(new InsetMathBox(from_ascii("mbox"))));
|
||||
cur.posLeft();
|
||||
cur.pushLeft(*cur.nextInset());
|
||||
cur.posBackward();
|
||||
cur.pushBackward(*cur.nextInset());
|
||||
cur.niceInsert(save_selection);
|
||||
#else
|
||||
if (currentMode() == Inset::TEXT_MODE) {
|
||||
@ -1463,7 +1463,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type c)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cur.popRight()) {
|
||||
if (cur.popForward()) {
|
||||
// FIXME: we have to enable full redraw here because of the
|
||||
// visual box corners that define the inset. If we know for
|
||||
// sure that we stay within the same cell we can optimize for
|
||||
|
@ -62,9 +62,9 @@ public:
|
||||
/// move one physical cell down
|
||||
bool idxPrev(Cursor &) const;
|
||||
|
||||
/// target pos when we enter the inset from the left by pressing "Right"
|
||||
/// target pos when we enter the inset while moving forward
|
||||
bool idxFirst(Cursor &) const;
|
||||
/// target pos when we enter the inset from the right by pressing "Left"
|
||||
/// target pos when we enter the inset while moving backwards
|
||||
bool idxLast(Cursor &) const;
|
||||
|
||||
/// number of cells currently governed by us
|
||||
|
@ -47,9 +47,9 @@ public:
|
||||
bool idxRight(Cursor & cur) const;
|
||||
/// move cursor up or down
|
||||
bool idxUpDown(Cursor & cur, bool up) const;
|
||||
/// Target pos when we enter the inset from the left by pressing "Right"
|
||||
/// Target pos when we enter the inset while moving forward
|
||||
bool idxFirst(Cursor & cur) const;
|
||||
/// Target pos when we enter the inset from the right by pressing "Left"
|
||||
/// Target pos when we enter the inset while moving backwards
|
||||
bool idxLast(Cursor & cur) const;
|
||||
|
||||
/// write LaTeX and Lyx code
|
||||
|
@ -49,9 +49,9 @@ public:
|
||||
///
|
||||
Inset * editXY(Cursor & cur, int x, int y);
|
||||
|
||||
/// target pos when we enter the inset from the left by pressing "Right"
|
||||
/// target pos when we enter the inset while moving forward
|
||||
bool idxFirst(Cursor &) const;
|
||||
/// target pos when we enter the inset from the right by pressing "Left"
|
||||
/// target pos when we enter the inset while moving backwards
|
||||
bool idxLast(Cursor &) const;
|
||||
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user