mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Always remove selection after cursor left/right
Example: when a selection is set, a `Left' cursor movement would not reset selection when the cursor was at the beginning of buffer. To fix this, it is necessary, when cursor is in top-level text, to avoid the mechnanism (undispatched cursor) that sends the action to the upper level (necessary when the cursor leaves an inset). The change is mechanical and is done for : char-backward, char-forward, char-left, char-right, word-left, word-right, word-left, word-right. It might be possible to factor this code a bit, but there is no evident solution. char-up/down are *not* handled at this point. Fixes part of bug #12310.
This commit is contained in:
parent
ab5e5e41a2
commit
8d90bb9991
123
src/Text3.cpp
123
src/Text3.cpp
@ -794,24 +794,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
bool const cur_moved = cursorForward(cur);
|
bool const cur_moved = cursorForward(cur);
|
||||||
needsUpdate |= cur_moved;
|
needsUpdate |= cur_moved;
|
||||||
|
|
||||||
if (!cur_moved && oldTopSlice == cur.top()
|
if (!cur_moved && cur.depth() > 1
|
||||||
&& cur.boundary() == oldBoundary) {
|
&& oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
|
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
|
||||||
|
|
||||||
// we will probably be moving out the inset, so we should execute
|
// we will be moving out the inset, so we should execute
|
||||||
// the depm-mechanism, but only when the cursor has a place to
|
// the depm-mechanism.
|
||||||
// go outside this inset, i.e. in a slice above.
|
// The cursor hasn't changed yet. To give the DEPM the
|
||||||
if (cur.depth() > 1 && cur.pos() == cur.lastpos()
|
// possibility of doing something we must provide it with
|
||||||
&& cur.pit() == cur.lastpit()) {
|
// two different cursors.
|
||||||
// The cursor hasn't changed yet. To give the
|
Cursor dummy = cur;
|
||||||
// DEPM the possibility of doing something we must
|
dummy.pos() = dummy.pit() = 0;
|
||||||
// provide it with two different cursors.
|
if (cur.bv().checkDepm(dummy, cur))
|
||||||
Cursor dummy = cur;
|
cur.forceBufferUpdate();
|
||||||
dummy.pos() = dummy.pit() = 0;
|
|
||||||
if (cur.bv().checkDepm(dummy, cur))
|
|
||||||
cur.forceBufferUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -823,24 +819,21 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
bool const cur_moved = cursorBackward(cur);
|
bool const cur_moved = cursorBackward(cur);
|
||||||
needsUpdate |= cur_moved;
|
needsUpdate |= cur_moved;
|
||||||
|
|
||||||
if (!cur_moved && oldTopSlice == cur.top()
|
if (!cur_moved && cur.depth() > 1
|
||||||
&& cur.boundary() == oldBoundary) {
|
&& oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
|
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
|
||||||
|
|
||||||
// we will probably be moving out the inset, so we should execute
|
// we will be moving out the inset, so we should execute
|
||||||
// the depm-mechanism, but only when the cursor has a place to
|
// the depm-mechanism.
|
||||||
// go outside this inset, i.e. in a slice above.
|
// The cursor hasn't changed yet. To give the DEPM the
|
||||||
if (cur.depth() > 1 && cur.pos() == 0 && cur.pit() == 0) {
|
// possibility of doing something we must provide it with
|
||||||
// The cursor hasn't changed yet. To give the
|
// two different cursors.
|
||||||
// DEPM the possibility of doing something we must
|
Cursor dummy = cur;
|
||||||
// provide it with two different cursors.
|
dummy.pos() = cur.lastpos();
|
||||||
Cursor dummy = cur;
|
dummy.pit() = cur.lastpit();
|
||||||
dummy.pos() = cur.lastpos();
|
if (cur.bv().checkDepm(dummy, cur))
|
||||||
dummy.pit() = cur.lastpit();
|
cur.forceBufferUpdate();
|
||||||
if (cur.bv().checkDepm(dummy, cur))
|
|
||||||
cur.forceBufferUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -851,8 +844,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
needsUpdate |= cur.selHandle(act == LFUN_CHAR_LEFT_SELECT);
|
needsUpdate |= cur.selHandle(act == LFUN_CHAR_LEFT_SELECT);
|
||||||
bool const cur_moved = cursorVisLeft(cur);
|
bool const cur_moved = cursorVisLeft(cur);
|
||||||
needsUpdate |= cur_moved;
|
needsUpdate |= cur_moved;
|
||||||
if (!cur_moved && oldTopSlice == cur.top()
|
if (!cur_moved && cur.depth() > 1
|
||||||
&& cur.boundary() == oldBoundary) {
|
&& oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
||||||
}
|
}
|
||||||
@ -875,8 +868,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
needsUpdate |= cur.selHandle(cmd.action() == LFUN_CHAR_RIGHT_SELECT);
|
needsUpdate |= cur.selHandle(cmd.action() == LFUN_CHAR_RIGHT_SELECT);
|
||||||
bool const cur_moved = cursorVisRight(cur);
|
bool const cur_moved = cursorVisRight(cur);
|
||||||
needsUpdate |= cur_moved;
|
needsUpdate |= cur_moved;
|
||||||
if (!cur_moved && oldTopSlice == cur.top()
|
if (!cur_moved && cur.depth() > 1
|
||||||
&& cur.boundary() == oldBoundary) {
|
&& oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
||||||
}
|
}
|
||||||
@ -1009,8 +1002,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_RIGHT_SELECT);
|
needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_RIGHT_SELECT);
|
||||||
bool const cur_moved = cursorVisRightOneWord(cur);
|
bool const cur_moved = cursorVisRightOneWord(cur);
|
||||||
needsUpdate |= cur_moved;
|
needsUpdate |= cur_moved;
|
||||||
if (!cur_moved && oldTopSlice == cur.top()
|
if (!cur_moved && cur.depth() > 1
|
||||||
&& cur.boundary() == oldBoundary) {
|
&& oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
||||||
}
|
}
|
||||||
@ -1033,24 +1026,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
bool const cur_moved = cursorForwardOneWord(cur);
|
bool const cur_moved = cursorForwardOneWord(cur);
|
||||||
needsUpdate |= cur_moved;
|
needsUpdate |= cur_moved;
|
||||||
|
|
||||||
if (!cur_moved && oldTopSlice == cur.top()
|
if (!cur_moved && cur.depth() > 1
|
||||||
&& cur.boundary() == oldBoundary) {
|
&& oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
|
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
|
||||||
|
|
||||||
// we will probably be moving out the inset, so we should execute
|
// we will be moving out the inset, so we should execute
|
||||||
// the depm-mechanism, but only when the cursor has a place to
|
// the depm-mechanism.
|
||||||
// go outside this inset, i.e. in a slice above.
|
// The cursor hasn't changed yet. To give the DEPM the
|
||||||
if (cur.depth() > 1 && cur.pos() == cur.lastpos()
|
// possibility of doing something we must provide it with
|
||||||
&& cur.pit() == cur.lastpit()) {
|
// two different cursors.
|
||||||
// The cursor hasn't changed yet. To give the
|
Cursor dummy = cur;
|
||||||
// DEPM the possibility of doing something we must
|
dummy.pos() = dummy.pit() = 0;
|
||||||
// provide it with two different cursors.
|
if (cur.bv().checkDepm(dummy, cur))
|
||||||
Cursor dummy = cur;
|
cur.forceBufferUpdate();
|
||||||
dummy.pos() = dummy.pit() = 0;
|
|
||||||
if (cur.bv().checkDepm(dummy, cur))
|
|
||||||
cur.forceBufferUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1061,8 +1050,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_LEFT_SELECT);
|
needsUpdate |= cur.selHandle(cmd.action() == LFUN_WORD_LEFT_SELECT);
|
||||||
bool const cur_moved = cursorVisLeftOneWord(cur);
|
bool const cur_moved = cursorVisLeftOneWord(cur);
|
||||||
needsUpdate |= cur_moved;
|
needsUpdate |= cur_moved;
|
||||||
if (!cur_moved && oldTopSlice == cur.top()
|
if (!cur_moved && cur.depth() > 1
|
||||||
&& cur.boundary() == oldBoundary) {
|
&& oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
||||||
}
|
}
|
||||||
@ -1085,25 +1074,21 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
bool const cur_moved = cursorBackwardOneWord(cur);
|
bool const cur_moved = cursorBackwardOneWord(cur);
|
||||||
needsUpdate |= cur_moved;
|
needsUpdate |= cur_moved;
|
||||||
|
|
||||||
if (!cur_moved && oldTopSlice == cur.top()
|
if (!cur_moved && cur.depth() > 1
|
||||||
&& cur.boundary() == oldBoundary) {
|
&& oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
|
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
|
||||||
|
|
||||||
// we will probably be moving out the inset, so we should execute
|
// we will be moving out the inset, so we should execute
|
||||||
// the depm-mechanism, but only when the cursor has a place to
|
// the depm-mechanism.
|
||||||
// go outside this inset, i.e. in a slice above.
|
// The cursor hasn't changed yet. To give the DEPM the
|
||||||
if (cur.depth() > 1 && cur.pos() == 0
|
// possibility of doing something we must provide it with
|
||||||
&& cur.pit() == 0) {
|
// two different cursors.
|
||||||
// The cursor hasn't changed yet. To give the
|
Cursor dummy = cur;
|
||||||
// DEPM the possibility of doing something we must
|
dummy.pos() = cur.lastpos();
|
||||||
// provide it with two different cursors.
|
dummy.pit() = cur.lastpit();
|
||||||
Cursor dummy = cur;
|
if (cur.bv().checkDepm(dummy, cur))
|
||||||
dummy.pos() = cur.lastpos();
|
cur.forceBufferUpdate();
|
||||||
dummy.pit() = cur.lastpit();
|
|
||||||
if (cur.bv().checkDepm(dummy, cur))
|
|
||||||
cur.forceBufferUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user