mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
the depm patch
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9599 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
32449e97b4
commit
8d88a0b2c9
@ -1,3 +1,44 @@
|
||||
2005-02-08 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* text3.C (cursorPrevious): return true if depm changed something
|
||||
(cursorNext): ditto
|
||||
(dispatch): rename sl to oldTopSlice, remove moving use the new
|
||||
NoUpdate func attrib instead. Make sure that needsUpdate is set
|
||||
for function that have NoUpdate, but where depm might have changed
|
||||
the buffer anyway.
|
||||
|
||||
* text2.C (cursorLeft): make us return true if depm changed
|
||||
something
|
||||
(cursorRight): ditto
|
||||
(cursorUpParagraph): ditto
|
||||
(curosrDownParagraph): ditto
|
||||
(cursorUp, cursorDown): ditto, make sure to read comments in code
|
||||
(deleteEmptyParagraphMechanism): remove an assert, also return
|
||||
true if just a single char was deleted.
|
||||
|
||||
* text.C (cursorRightOneWord, cursorLeftOneWord): use a temp
|
||||
cursor that we modify, to avoid modifying an active cursor before
|
||||
we call setCursor. This allows depm to run. Also return true if
|
||||
depm deleted something.
|
||||
|
||||
* lyxtext.h: Make cursorUp, cursorDown, cursorLeft, cursorRight,
|
||||
cursorLeftOneWord, cursorRightOneWord, cursorUpParagraph,
|
||||
cursorDownParagraph, cursorPrevious and cursorNext, return true if
|
||||
something was changed in the buffer because of them (ie. depm run)
|
||||
|
||||
* lyxfunc.C (processKeySym): add BOOST_CURRENT_FUNCTION to some
|
||||
debug messages. Make update by default be false. Make sure that
|
||||
the result of update is retained throught several calls down to
|
||||
dispatch.
|
||||
|
||||
* LyXAction.h: add a new func_attrib: NoUpdate
|
||||
|
||||
* LyXAction.C (init): add noupdate to LFUN_LEFT, LFUN_RIGHT,
|
||||
LFUN_DOWN, LFUN_HOME, LFUN_END, LFUN_DOWN_PARAGRAPH,
|
||||
LFUN_UP_PARAGRAPH, LFUN_NEXT, LFUN_PRIOR, LFUN_UP, LFUN_WORDRIGHT
|
||||
and LFUN_WORDLEFT
|
||||
(init): add missing lfuns: LFUN_FINISHED_*, LFUN_MOUSE_*
|
||||
|
||||
2005-02-07 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* BufferView_pimpl.C: replace all occurences of bv_->cursor(),
|
||||
|
@ -128,8 +128,8 @@ void LyXAction::init()
|
||||
{ LFUN_WRITEAS, "buffer-write-as", ReadOnly },
|
||||
{ LFUN_CANCEL, "cancel", NoBuffer },
|
||||
{ LFUN_INSET_CAPTION, "caption-insert", Noop },
|
||||
{ LFUN_LEFT, "char-backward", ReadOnly },
|
||||
{ LFUN_RIGHT, "char-forward", ReadOnly },
|
||||
{ LFUN_LEFT, "char-backward", ReadOnly | NoUpdate},
|
||||
{ LFUN_RIGHT, "char-forward", ReadOnly | NoUpdate},
|
||||
{ LFUN_EXEC_COMMAND, "command-execute", NoBuffer },
|
||||
{ LFUN_PREFIX, "command-prefix", NoBuffer },
|
||||
{ LFUN_SEQUENCE, "command-sequence", NoBuffer },
|
||||
@ -143,7 +143,7 @@ void LyXAction::init()
|
||||
{ LFUN_DEPTH_MIN, "depth-decrement", Noop },
|
||||
{ LFUN_DEPTH_PLUS, "depth-increment", Noop },
|
||||
{ LFUN_LDOTS, "dots-insert", Noop },
|
||||
{ LFUN_DOWN, "down", ReadOnly },
|
||||
{ LFUN_DOWN, "down", ReadOnly | NoUpdate},
|
||||
{ LFUN_DOWNSEL, "down-select", ReadOnly },
|
||||
{ LFUN_DROP_LAYOUTS_CHOICE, "drop-layouts-choice", ReadOnly },
|
||||
{ LFUN_END_OF_SENTENCE, "end-of-sentence-period-insert", Noop },
|
||||
@ -194,10 +194,10 @@ void LyXAction::init()
|
||||
{ LFUN_LAYOUT, "layout", Noop },
|
||||
{ LFUN_LAYOUT_PARAGRAPH, "layout-paragraph", ReadOnly },
|
||||
{ LFUN_LAYOUT_TABULAR, "layout-tabular", Noop },
|
||||
{ LFUN_HOME, "line-begin", ReadOnly },
|
||||
{ LFUN_HOME, "line-begin", ReadOnly | NoUpdate},
|
||||
{ LFUN_HOMESEL, "line-begin-select", ReadOnly },
|
||||
{ LFUN_DELETE_LINE_FORWARD, "line-delete-forward", Noop },
|
||||
{ LFUN_END, "line-end", ReadOnly },
|
||||
{ LFUN_END, "line-end", ReadOnly | NoUpdate},
|
||||
{ LFUN_ENDSEL, "line-end-select", ReadOnly },
|
||||
#if 0
|
||||
{ LFUN_INSET_LIST, "list-insert", Noop },
|
||||
@ -234,11 +234,11 @@ void LyXAction::init()
|
||||
{ LFUN_INSET_TOGGLE, "", ReadOnly },
|
||||
{ LFUN_NEXT_INSET_TOGGLE, "next-inset-toggle", ReadOnly },
|
||||
{ LFUN_ALL_INSETS_TOGGLE, "all-insets-toggle", ReadOnly },
|
||||
{ LFUN_DOWN_PARAGRAPH, "paragraph-down", ReadOnly },
|
||||
{ LFUN_DOWN_PARAGRAPH, "paragraph-down", ReadOnly | NoUpdate},
|
||||
{ LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select", ReadOnly },
|
||||
{ LFUN_GOTO_PARAGRAPH, "paragraph-goto", ReadOnly },
|
||||
{ LFUN_PARAGRAPH_SPACING, "paragraph-spacing", Noop },
|
||||
{ LFUN_UP_PARAGRAPH, "paragraph-up", ReadOnly },
|
||||
{ LFUN_UP_PARAGRAPH, "paragraph-up", ReadOnly | NoUpdate},
|
||||
{ LFUN_UP_PARAGRAPHSEL, "paragraph-up-select", ReadOnly },
|
||||
{ LFUN_PASTE, "paste", Noop },
|
||||
{ LFUN_SAVEPREFERENCES, "preferences-save", NoBuffer },
|
||||
@ -248,11 +248,11 @@ void LyXAction::init()
|
||||
{ LFUN_REDO, "redo", Noop },
|
||||
{ LFUN_REF_GOTO, "reference-goto", ReadOnly },
|
||||
{ LFUN_REFERENCE_GOTO, "reference-next", ReadOnly },
|
||||
{ LFUN_NEXT, "screen-down", ReadOnly },
|
||||
{ LFUN_NEXT, "screen-down", ReadOnly | NoUpdate},
|
||||
{ LFUN_NEXTSEL, "screen-down-select", ReadOnly },
|
||||
{ LFUN_SCREEN_FONT_UPDATE, "screen-font-update", NoBuffer },
|
||||
{ LFUN_CENTER, "screen-recenter", ReadOnly },
|
||||
{ LFUN_PRIOR, "screen-up", ReadOnly },
|
||||
{ LFUN_PRIOR, "screen-up", ReadOnly | NoUpdate},
|
||||
{ LFUN_PRIORSEL, "screen-up-select", ReadOnly },
|
||||
{ LFUN_SCROLL_INSET, "inset-scroll", ReadOnly },
|
||||
{ LFUN_SELFINSERT, "self-insert", Noop },
|
||||
@ -279,7 +279,7 @@ void LyXAction::init()
|
||||
{ LFUN_TOCVIEW, "toc-view", ReadOnly },
|
||||
{ LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar", ReadOnly },
|
||||
{ LFUN_UNDO, "undo", Noop },
|
||||
{ LFUN_UP, "up", ReadOnly },
|
||||
{ LFUN_UP, "up", ReadOnly | NoUpdate},
|
||||
{ LFUN_UPSEL, "up-select", ReadOnly },
|
||||
{ LFUN_URL, "url-insert", Noop },
|
||||
{ LFUN_VC_CHECKIN, "vc-check-in", ReadOnly },
|
||||
@ -287,14 +287,14 @@ void LyXAction::init()
|
||||
{ LFUN_VC_REGISTER, "vc-register", ReadOnly },
|
||||
{ LFUN_VC_REVERT, "vc-revert", ReadOnly },
|
||||
{ LFUN_VC_UNDO, "vc-undo-last", ReadOnly },
|
||||
{ LFUN_WORDLEFT, "word-backward", ReadOnly },
|
||||
{ LFUN_WORDLEFT, "word-backward", ReadOnly | NoUpdate},
|
||||
{ LFUN_WORDLEFTSEL, "word-backward-select", ReadOnly },
|
||||
{ LFUN_CAPITALIZE_WORD, "word-capitalize", Noop },
|
||||
{ LFUN_DELETE_WORD_BACKWARD, "word-delete-backward", Noop },
|
||||
{ LFUN_DELETE_WORD_FORWARD, "word-delete-forward", Noop },
|
||||
{ LFUN_WORDFINDBACKWARD, "word-find-backward", ReadOnly },
|
||||
{ LFUN_WORDFINDFORWARD, "word-find-forward", ReadOnly },
|
||||
{ LFUN_WORDRIGHT, "word-forward", ReadOnly },
|
||||
{ LFUN_WORDRIGHT, "word-forward", ReadOnly | NoUpdate},
|
||||
{ LFUN_WORDRIGHTSEL, "word-forward-select", ReadOnly },
|
||||
{ LFUN_LOWCASE_WORD, "word-lowcase", Noop },
|
||||
{ LFUN_WORDSEL, "word-select", ReadOnly },
|
||||
@ -341,6 +341,15 @@ void LyXAction::init()
|
||||
{ LFUN_NEXTBUFFER, "buffer-next", ReadOnly },
|
||||
{ LFUN_PREVIOUSBUFFER, "buffer-previous", ReadOnly },
|
||||
{ LFUN_WORDS_COUNT, "words-count", ReadOnly },
|
||||
{ LFUN_FINISHED_RIGHT, "", ReadOnly },
|
||||
{ LFUN_FINISHED_LEFT, "", ReadOnly },
|
||||
{ LFUN_FINISHED_UP, "", ReadOnly },
|
||||
{ LFUN_FINISHED_DOWN, "", ReadOnly },
|
||||
{ LFUN_MOUSE_PRESS, "", ReadOnly },
|
||||
{ LFUN_MOUSE_MOTION, "", ReadOnly },
|
||||
{ LFUN_MOUSE_RELEASE, "", ReadOnly },
|
||||
{ LFUN_MOUSE_DOUBLE, "", ReadOnly },
|
||||
{ LFUN_MOUSE_TRIPLE, "", ReadOnly },
|
||||
{ LFUN_NOACTION, "", Noop }
|
||||
};
|
||||
|
||||
|
@ -50,7 +50,8 @@ public:
|
||||
Noop = 0, //< nothing special about this func
|
||||
ReadOnly = 1, //< can be used in RO mode (perhaps this should change)
|
||||
NoBuffer = 2, //< Can be used when there is no document open
|
||||
Argument = 4 //< Requires argument
|
||||
Argument = 4, //< Requires argument
|
||||
NoUpdate = 8 //< Does not (usually) require update
|
||||
};
|
||||
|
||||
LyXAction();
|
||||
|
@ -247,7 +247,9 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
||||
cancel_meta_seq.reset();
|
||||
|
||||
FuncRequest func = cancel_meta_seq.addkey(keysym, state);
|
||||
lyxerr[Debug::KEY] << "action first set to [" << func.action << ']' << endl;
|
||||
lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
|
||||
<< " action first set to [" << func.action << ']'
|
||||
<< endl;
|
||||
|
||||
// When not cancel or meta-fake, do the normal lookup.
|
||||
// Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
|
||||
@ -255,20 +257,22 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
||||
if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_FAKE)) {
|
||||
// remove Caps Lock and Mod2 as a modifiers
|
||||
func = keyseq.addkey(keysym, (state | meta_fake_bit));
|
||||
lyxerr[Debug::KEY] << "action now set to ["
|
||||
lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
|
||||
<< "action now set to ["
|
||||
<< func.action << ']' << endl;
|
||||
}
|
||||
|
||||
// Dont remove this unless you know what you are doing.
|
||||
meta_fake_bit = key_modifier::none;
|
||||
|
||||
// can this happen now ?
|
||||
// Can this happen now ?
|
||||
if (func.action == LFUN_NOACTION) {
|
||||
func = FuncRequest(LFUN_PREFIX);
|
||||
}
|
||||
|
||||
if (lyxerr.debugging(Debug::KEY)) {
|
||||
lyxerr << "Key [action="
|
||||
lyxerr << BOOST_CURRENT_FUNCTION
|
||||
<< " Key [action="
|
||||
<< func.action << "]["
|
||||
<< keyseq.print() << ']'
|
||||
<< endl;
|
||||
@ -308,7 +312,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
|
||||
|
||||
if (func.action == LFUN_SELFINSERT) {
|
||||
if (encoded_last_key != 0) {
|
||||
string arg(1, encoded_last_key);
|
||||
string const arg(1, encoded_last_key);
|
||||
dispatch(FuncRequest(LFUN_SELFINSERT, arg));
|
||||
lyxerr[Debug::KEY]
|
||||
<< "SelfInsert arg[`" << arg << "']" << endl;
|
||||
@ -438,7 +442,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
enable = !buf->isUnnamed() && !buf->isClean();
|
||||
break;
|
||||
|
||||
|
||||
case LFUN_INSET_SETTINGS: {
|
||||
enable = false;
|
||||
if (!cur.size())
|
||||
@ -673,7 +676,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
errorstat = false;
|
||||
dispatch_buffer.erase();
|
||||
|
||||
bool update = true;
|
||||
bool update = false;
|
||||
|
||||
FuncStatus const flag = getStatus(cmd);
|
||||
if (!flag.enabled()) {
|
||||
@ -1510,12 +1513,12 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
default: {
|
||||
update = false;
|
||||
view()->cursor().dispatch(cmd);
|
||||
if (view()->cursor().result().dispatched())
|
||||
update |= view()->cursor().result().update();
|
||||
else
|
||||
if (!view()->cursor().result().dispatched()) {
|
||||
update |= view()->dispatch(cmd);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -179,30 +179,42 @@ public:
|
||||
void setCursorFromCoordinates(LCursor & cur, int x, int y);
|
||||
///
|
||||
InsetBase * editXY(LCursor & cur, int x, int y) const;
|
||||
/// Move cursor one line up.
|
||||
/**
|
||||
* Returns true if an update is needed after the move.
|
||||
*/
|
||||
bool cursorUp(LCursor & cur);
|
||||
/// Move cursor one line down.
|
||||
/**
|
||||
* Returns true if an update is needed after the move.
|
||||
*/
|
||||
bool cursorDown(LCursor & cur);
|
||||
/// Move cursor one position left
|
||||
/**
|
||||
* Returns true if an update is needed after the move.
|
||||
*/
|
||||
bool cursorLeft(LCursor & cur);
|
||||
/// Move cursor one position right
|
||||
/**
|
||||
* Returns true if an update is needed after the move.
|
||||
*/
|
||||
bool cursorRight(LCursor & cur);
|
||||
///
|
||||
void cursorUp(LCursor & cur);
|
||||
bool cursorLeftOneWord(LCursor & cur);
|
||||
///
|
||||
void cursorDown(LCursor & cur);
|
||||
bool cursorRightOneWord(LCursor & cur);
|
||||
///
|
||||
void cursorLeft(LCursor & cur);
|
||||
bool cursorUpParagraph(LCursor & cur);
|
||||
///
|
||||
void cursorRight(LCursor & cur);
|
||||
///
|
||||
void cursorLeftOneWord(LCursor & cur);
|
||||
///
|
||||
void cursorRightOneWord(LCursor & cur);
|
||||
///
|
||||
void cursorUpParagraph(LCursor & cur);
|
||||
///
|
||||
void cursorDownParagraph(LCursor & cur);
|
||||
bool cursorDownParagraph(LCursor & cur);
|
||||
///
|
||||
void cursorHome(LCursor & cur);
|
||||
///
|
||||
void cursorEnd(LCursor & cur);
|
||||
///
|
||||
void cursorPrevious(LCursor & cur);
|
||||
bool cursorPrevious(LCursor & cur);
|
||||
///
|
||||
void cursorNext(LCursor & cur);
|
||||
bool cursorNext(LCursor & cur);
|
||||
///
|
||||
void cursorTop(LCursor & cur);
|
||||
///
|
||||
|
42
src/text.C
42
src/text.C
@ -1316,41 +1316,47 @@ LyXText::computeRowMetrics(pit_type const pit, Row const & row) const
|
||||
// the cursor set functions have a special mechanism. When they
|
||||
// realize, that you left an empty paragraph, they will delete it.
|
||||
|
||||
void LyXText::cursorRightOneWord(LCursor & cur)
|
||||
bool LyXText::cursorRightOneWord(LCursor & cur)
|
||||
{
|
||||
BOOST_ASSERT(this == cur.text());
|
||||
if (cur.pos() == cur.lastpos() && cur.pit() != cur.lastpit()) {
|
||||
++cur.pit();
|
||||
cur.pos() = 0;
|
||||
|
||||
LCursor old = cur;
|
||||
|
||||
if (old.pos() == old.lastpos() && old.pit() != old.lastpit()) {
|
||||
++old.pit();
|
||||
old.pos() = 0;
|
||||
} else {
|
||||
// Skip through initial nonword stuff.
|
||||
// Treat floats and insets as words.
|
||||
while (cur.pos() != cur.lastpos() && !cur.paragraph().isLetter(cur.pos()))
|
||||
++cur.pos();
|
||||
while (old.pos() != old.lastpos() && !old.paragraph().isLetter(old.pos()))
|
||||
++old.pos();
|
||||
// Advance through word.
|
||||
while (cur.pos() != cur.lastpos() && cur.paragraph().isLetter(cur.pos()))
|
||||
++cur.pos();
|
||||
while (old.pos() != old.lastpos() && old.paragraph().isLetter(old.pos()))
|
||||
++old.pos();
|
||||
}
|
||||
setCursor(cur, cur.pit(), cur.pos());
|
||||
return setCursor(cur, old.pit(), old.pos());
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorLeftOneWord(LCursor & cur)
|
||||
bool LyXText::cursorLeftOneWord(LCursor & cur)
|
||||
{
|
||||
BOOST_ASSERT(this == cur.text());
|
||||
if (cur.pos() == 0 && cur.pit() != 0) {
|
||||
--cur.pit();
|
||||
cur.pos() = cur.lastpos();
|
||||
|
||||
LCursor old = cur;
|
||||
|
||||
if (old.pos() == 0 && old.pit() != 0) {
|
||||
--old.pit();
|
||||
old.pos() = old.lastpos();
|
||||
} else {
|
||||
// Skip through initial nonword stuff.
|
||||
// Treat floats and insets as words.
|
||||
while (cur.pos() != 0 && !cur.paragraph().isLetter(cur.pos() - 1))
|
||||
--cur.pos();
|
||||
while (old.pos() != 0 && !old.paragraph().isLetter(old.pos() - 1))
|
||||
--old.pos();
|
||||
// Advance through word.
|
||||
while (cur.pos() != 0 && cur.paragraph().isLetter(cur.pos() - 1))
|
||||
--cur.pos();
|
||||
while (old.pos() != 0 && old.paragraph().isLetter(old.pos() - 1))
|
||||
--old.pos();
|
||||
}
|
||||
setCursor(cur, cur.pit(), cur.pos());
|
||||
return setCursor(cur, old.pit(), old.pos());
|
||||
}
|
||||
|
||||
|
||||
|
116
src/text2.C
116
src/text2.C
@ -1159,6 +1159,7 @@ Row const & LyXText::getRowNearY(int y, pit_type pit) const
|
||||
return *rit;
|
||||
}
|
||||
|
||||
|
||||
// x,y are absolute screen coordinates
|
||||
// sets cursor recursively descending into nested editable insets
|
||||
InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const
|
||||
@ -1179,8 +1180,8 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const
|
||||
InsetBase * inset = checkInsetHit(x, y);
|
||||
lyxerr << "inset " << inset << " hit at x: " << x << " y: " << y << endl;
|
||||
if (!inset) {
|
||||
//either we deconst editXY or better we move current_font
|
||||
//and real_current_font to LCursor
|
||||
// Either we deconst editXY or better we move current_font
|
||||
// and real_current_font to LCursor
|
||||
const_cast<LyXText *>(this)->setCurrentFont(cur);
|
||||
return 0;
|
||||
}
|
||||
@ -1214,49 +1215,55 @@ bool LyXText::checkAndActivateInset(LCursor & cur, bool front)
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorLeft(LCursor & cur)
|
||||
bool LyXText::cursorLeft(LCursor & cur)
|
||||
{
|
||||
if (cur.pos() != 0) {
|
||||
bool boundary = cur.boundary();
|
||||
setCursor(cur, cur.pit(), cur.pos() - 1, true, false);
|
||||
bool updateNeeded = setCursor(cur, cur.pit(), cur.pos() - 1, true, false);
|
||||
if (!checkAndActivateInset(cur, false)) {
|
||||
if (false && !boundary &&
|
||||
bidi.isBoundary(cur.buffer(), cur.paragraph(), cur.pos() + 1))
|
||||
updateNeeded |=
|
||||
setCursor(cur, cur.pit(), cur.pos() + 1, true, true);
|
||||
}
|
||||
return;
|
||||
return updateNeeded;
|
||||
}
|
||||
|
||||
if (cur.pit() != 0) {
|
||||
// steps into the paragraph above
|
||||
setCursor(cur, cur.pit() - 1, getPar(cur.pit() - 1).size());
|
||||
// Steps into the paragraph above
|
||||
return setCursor(cur, cur.pit() - 1, getPar(cur.pit() - 1).size());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorRight(LCursor & cur)
|
||||
bool LyXText::cursorRight(LCursor & cur)
|
||||
{
|
||||
if (false && cur.boundary()) {
|
||||
setCursor(cur, cur.pit(), cur.pos(), true, false);
|
||||
return;
|
||||
return setCursor(cur, cur.pit(), cur.pos(), true, false);
|
||||
}
|
||||
|
||||
if (cur.pos() != cur.lastpos()) {
|
||||
bool updateNeeded = false;
|
||||
if (!checkAndActivateInset(cur, true)) {
|
||||
setCursor(cur, cur.pit(), cur.pos() + 1, true, false);
|
||||
lyxerr << BOOST_CURRENT_FUNCTION
|
||||
<< " Running setCursor" << endl;
|
||||
|
||||
updateNeeded |= setCursor(cur, cur.pit(), cur.pos() + 1, true, false);
|
||||
if (false && bidi.isBoundary(cur.buffer(), cur.paragraph(),
|
||||
cur.pos()))
|
||||
setCursor(cur, cur.pit(), cur.pos(), true, true);
|
||||
updateNeeded |= setCursor(cur, cur.pit(), cur.pos(), true, true);
|
||||
}
|
||||
return;
|
||||
return updateNeeded;
|
||||
}
|
||||
|
||||
if (cur.pit() != cur.lastpit())
|
||||
setCursor(cur, cur.pit() + 1, 0);
|
||||
return setCursor(cur, cur.pit() + 1, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorUp(LCursor & cur)
|
||||
bool LyXText::cursorUp(LCursor & cur)
|
||||
{
|
||||
Paragraph const & par = cur.paragraph();
|
||||
int const row = par.pos2row(cur.pos());
|
||||
@ -1264,23 +1271,38 @@ void LyXText::cursorUp(LCursor & cur)
|
||||
|
||||
if (!cur.selection()) {
|
||||
int const y = bv_funcs::getPos(cur).y_;
|
||||
LCursor old = cur;
|
||||
editXY(cur, x, y - par.rows()[row].ascent() - 1);
|
||||
return;
|
||||
|
||||
// This happens when you move out of an inset.
|
||||
// And to give the DEPM the possibility of doing
|
||||
// something we must provide it with two different
|
||||
// cursors. (Lgb)
|
||||
LCursor dummy = cur;
|
||||
if (dummy == old)
|
||||
++dummy.pos();
|
||||
|
||||
return deleteEmptyParagraphMechanism(dummy, old);
|
||||
}
|
||||
|
||||
bool updateNeeded = false;
|
||||
|
||||
if (row > 0) {
|
||||
setCursor(cur, cur.pit(), x2pos(cur.pit(), row - 1, x));
|
||||
updateNeeded |= setCursor(cur, cur.pit(),
|
||||
x2pos(cur.pit(), row - 1, x));
|
||||
} else if (cur.pit() > 0) {
|
||||
--cur.pit();
|
||||
setCursor(cur, cur.pit(), x2pos(cur.pit(), cur.paragraph().rows().size() - 1, x));
|
||||
|
||||
updateNeeded |= setCursor(cur, cur.pit(),
|
||||
x2pos(cur.pit(), par.rows().size() - 1, x));
|
||||
}
|
||||
|
||||
cur.x_target() = x;
|
||||
|
||||
return updateNeeded;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorDown(LCursor & cur)
|
||||
bool LyXText::cursorDown(LCursor & cur)
|
||||
{
|
||||
Paragraph const & par = cur.paragraph();
|
||||
int const row = par.pos2row(cur.pos());
|
||||
@ -1288,36 +1310,63 @@ void LyXText::cursorDown(LCursor & cur)
|
||||
|
||||
if (!cur.selection()) {
|
||||
int const y = bv_funcs::getPos(cur).y_;
|
||||
LCursor old = cur;
|
||||
editXY(cur, x, y + par.rows()[row].descent() + 1);
|
||||
return;
|
||||
|
||||
// This happens when you move out of an inset.
|
||||
// And to give the DEPM the possibility of doing
|
||||
// something we must provide it with two different
|
||||
// cursors. (Lgb)
|
||||
LCursor dummy = cur;
|
||||
if (dummy == old)
|
||||
++dummy.pos();
|
||||
|
||||
bool const changed = deleteEmptyParagraphMechanism(dummy, old);
|
||||
|
||||
// Make sure that cur gets back whatever happened to dummy(Lgb)
|
||||
if (changed)
|
||||
cur = dummy;
|
||||
|
||||
return changed;
|
||||
|
||||
}
|
||||
|
||||
bool updateNeeded = false;
|
||||
|
||||
if (row + 1 < int(par.rows().size())) {
|
||||
setCursor(cur, cur.pit(), x2pos(cur.pit(), row + 1, x));
|
||||
updateNeeded |= setCursor(cur, cur.pit(),
|
||||
x2pos(cur.pit(), row + 1, x));
|
||||
} else if (cur.pit() + 1 < int(paragraphs().size())) {
|
||||
++cur.pit();
|
||||
setCursor(cur, cur.pit(), x2pos(cur.pit(), 0, x));
|
||||
updateNeeded |= setCursor(cur, cur.pit(),
|
||||
x2pos(cur.pit(), 0, x));
|
||||
}
|
||||
|
||||
cur.x_target() = x;
|
||||
|
||||
return updateNeeded;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorUpParagraph(LCursor & cur)
|
||||
bool LyXText::cursorUpParagraph(LCursor & cur)
|
||||
{
|
||||
bool updated = false;
|
||||
if (cur.pos() > 0)
|
||||
setCursor(cur, cur.pit(), 0);
|
||||
updated = setCursor(cur, cur.pit(), 0);
|
||||
else if (cur.pit() != 0)
|
||||
setCursor(cur, cur.pit() - 1, 0);
|
||||
updated = setCursor(cur, cur.pit() - 1, 0);
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorDownParagraph(LCursor & cur)
|
||||
bool LyXText::cursorDownParagraph(LCursor & cur)
|
||||
{
|
||||
bool updated = false;
|
||||
if (cur.pit() != cur.lastpit())
|
||||
setCursor(cur, cur.pit() + 1, 0);
|
||||
updated = setCursor(cur, cur.pit() + 1, 0);
|
||||
else
|
||||
setCursor(cur, cur.pit(), cur.lastpos());
|
||||
updated = setCursor(cur, cur.pit(), cur.lastpos());
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
@ -1325,16 +1374,16 @@ void LyXText::cursorDownParagraph(LCursor & cur)
|
||||
// position. Called by deleteEmptyParagraphMechanism
|
||||
void LyXText::fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where)
|
||||
{
|
||||
// do notheing if cursor is not in the paragraph where the
|
||||
// Do nothing if cursor is not in the paragraph where the
|
||||
// deletion occured,
|
||||
if (cur.pit() != where.pit())
|
||||
return;
|
||||
|
||||
// if cursor position is after the deletion place update it
|
||||
// If cursor position is after the deletion place update it
|
||||
if (cur.pos() > where.pos())
|
||||
--cur.pos();
|
||||
|
||||
// check also if we don't want to set the cursor on a spot behind the
|
||||
// Check also if we don't want to set the cursor on a spot behind the
|
||||
// pagragraph because we erased the last character.
|
||||
if (cur.pos() > cur.lastpos())
|
||||
cur.pos() = cur.lastpos();
|
||||
@ -1343,7 +1392,6 @@ void LyXText::fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where)
|
||||
|
||||
bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor const & old)
|
||||
{
|
||||
BOOST_ASSERT(cur.size() == old.size());
|
||||
// Would be wrong to delete anything if we have a selection.
|
||||
if (cur.selection())
|
||||
return false;
|
||||
@ -1399,7 +1447,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor const & old)
|
||||
#warning DEPM, look here
|
||||
#endif
|
||||
//fixCursorAfterDelete(cur.anchor(), old.top());
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
107
src/text3.C
107
src/text3.C
@ -32,6 +32,7 @@
|
||||
#include "gettext.h"
|
||||
#include "intl.h"
|
||||
#include "language.h"
|
||||
#include "LyXAction.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "lyxlex.h"
|
||||
#include "lyxrc.h"
|
||||
@ -251,7 +252,7 @@ void LyXText::gotoInset(LCursor & cur, InsetBase_code code, bool same_content)
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorPrevious(LCursor & cur)
|
||||
bool LyXText::cursorPrevious(LCursor & cur)
|
||||
{
|
||||
pos_type cpos = cur.pos();
|
||||
lyx::pit_type cpar = cur.pit();
|
||||
@ -259,36 +260,38 @@ void LyXText::cursorPrevious(LCursor & cur)
|
||||
int x = cur.x_target();
|
||||
|
||||
setCursorFromCoordinates(cur, x, 0);
|
||||
cursorUp(cur);
|
||||
bool updated = cursorUp(cur);
|
||||
|
||||
if (cpar == cur.pit() && cpos == cur.pos()) {
|
||||
// we have a row which is taller than the workarea. The
|
||||
// simplest solution is to move to the previous row instead.
|
||||
cursorUp(cur);
|
||||
updated |= cursorUp(cur);
|
||||
}
|
||||
|
||||
cur.bv().updateScrollbar();
|
||||
finishUndo();
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorNext(LCursor & cur)
|
||||
bool LyXText::cursorNext(LCursor & cur)
|
||||
{
|
||||
pos_type cpos = cur.pos();
|
||||
lyx::pit_type cpar = cur.pit();
|
||||
|
||||
int x = cur.x_target();
|
||||
setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
|
||||
cursorDown(cur);
|
||||
bool updated = cursorDown(cur);
|
||||
|
||||
if (cpar == cur.pit() && cpos == cur.pos()) {
|
||||
// we have a row which is taller than the workarea. The
|
||||
// simplest solution is to move to the next row instead.
|
||||
cursorDown(cur);
|
||||
updated |= cursorDown(cur);
|
||||
}
|
||||
|
||||
cur.bv().updateScrollbar();
|
||||
finishUndo();
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
@ -357,9 +360,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
|
||||
BOOST_ASSERT(cur.text() == this);
|
||||
BufferView * bv = &cur.bv();
|
||||
CursorSlice sl = cur.top();
|
||||
CursorSlice oldTopSlice = cur.top();
|
||||
bool sel = cur.selection();
|
||||
bool moving = false;
|
||||
bool needsUpdate = !lyxaction.funcHasFlag(cmd.action, LyXAction::NoUpdate);
|
||||
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -403,24 +406,22 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_WORDRIGHT:
|
||||
moving = true;
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorLeftOneWord(cur);
|
||||
needsUpdate = cursorLeftOneWord(cur);
|
||||
else
|
||||
cursorRightOneWord(cur);
|
||||
needsUpdate = cursorRightOneWord(cur);
|
||||
finishChange(cur, false);
|
||||
break;
|
||||
|
||||
case LFUN_WORDLEFT:
|
||||
moving = true;
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorRightOneWord(cur);
|
||||
needsUpdate = cursorRightOneWord(cur);
|
||||
else
|
||||
cursorLeftOneWord(cur);
|
||||
needsUpdate = cursorLeftOneWord(cur);
|
||||
finishChange(cur, false);
|
||||
break;
|
||||
|
||||
@ -469,61 +470,65 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_RIGHT:
|
||||
moving = true;
|
||||
case LFUN_RIGHTSEL:
|
||||
//lyxerr << "handle LFUN_RIGHT[SEL]:\n" << cur << endl;
|
||||
lyxerr << BOOST_CURRENT_FUNCTION
|
||||
<< " LFUN_RIGHT[SEL]:\n" << cur << endl;
|
||||
cur.selHandle(cmd.action == LFUN_RIGHTSEL);
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorLeft(cur);
|
||||
needsUpdate = cursorLeft(cur);
|
||||
else
|
||||
cursorRight(cur);
|
||||
if (sl == cur.top()) {
|
||||
needsUpdate = cursorRight(cur);
|
||||
if (!needsUpdate && oldTopSlice == cur.top()) {
|
||||
cur.undispatched();
|
||||
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_LEFT:
|
||||
moving = true;
|
||||
case LFUN_LEFTSEL:
|
||||
//lyxerr << "handle LFUN_LEFT[SEL]:\n" << cur << endl;
|
||||
cur.selHandle(cmd.action == LFUN_LEFTSEL);
|
||||
if (isRTL(cur.paragraph()))
|
||||
cursorRight(cur);
|
||||
needsUpdate = cursorRight(cur);
|
||||
else
|
||||
cursorLeft(cur);
|
||||
if (sl == cur.top()) {
|
||||
needsUpdate = cursorLeft(cur);
|
||||
if (oldTopSlice == cur.top()) {
|
||||
cur.undispatched();
|
||||
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_UP:
|
||||
moving = true;
|
||||
case LFUN_UPSEL:
|
||||
update(cur);
|
||||
//lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
|
||||
cur.selHandle(cmd.action == LFUN_UPSEL);
|
||||
cursorUp(cur);
|
||||
if (sl == cur.top()) {
|
||||
needsUpdate = cursorUp(cur);
|
||||
if (oldTopSlice == cur.top()) {
|
||||
cur.undispatched();
|
||||
cmd = FuncRequest(LFUN_FINISHED_UP);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_DOWN:
|
||||
moving = true;
|
||||
case LFUN_DOWNSEL:
|
||||
update(cur);
|
||||
//lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
|
||||
cur.selHandle(cmd.action == LFUN_DOWNSEL);
|
||||
cursorDown(cur);
|
||||
if (sl == cur.top()) {
|
||||
needsUpdate = cursorDown(cur);
|
||||
if (oldTopSlice == cur.top()) {
|
||||
cur.undispatched();
|
||||
cmd = FuncRequest(LFUN_FINISHED_DOWN);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_UP_PARAGRAPH:
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
needsUpdate = cursorUpParagraph(cur);
|
||||
finishChange(cur, false);
|
||||
break;
|
||||
|
||||
case LFUN_UP_PARAGRAPHSEL:
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
@ -531,6 +536,13 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
finishChange(cur, true);
|
||||
break;
|
||||
|
||||
case LFUN_DOWN_PARAGRAPH:
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
needsUpdate = cursorDownParagraph(cur);
|
||||
finishChange(cur, false);
|
||||
break;
|
||||
|
||||
case LFUN_DOWN_PARAGRAPHSEL:
|
||||
if (!cur.selection())
|
||||
cur.resetAnchor();
|
||||
@ -596,25 +608,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_UP_PARAGRAPH:
|
||||
moving = true;
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorUpParagraph(cur);
|
||||
finishChange(cur, false);
|
||||
break;
|
||||
|
||||
case LFUN_DOWN_PARAGRAPH:
|
||||
moving = true;
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
cursorDownParagraph(cur);
|
||||
finishChange(cur, false);
|
||||
break;
|
||||
|
||||
case LFUN_PRIOR:
|
||||
update(cur);
|
||||
moving = true;
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
finishChange(cur, false);
|
||||
@ -622,13 +617,12 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
cur.undispatched();
|
||||
cmd = FuncRequest(LFUN_FINISHED_UP);
|
||||
} else {
|
||||
cursorPrevious(cur);
|
||||
needsUpdate = cursorPrevious(cur);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_NEXT:
|
||||
update(cur);
|
||||
moving = true;
|
||||
if (!cur.mark())
|
||||
cur.clearSelection();
|
||||
finishChange(cur, false);
|
||||
@ -637,7 +631,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
cur.undispatched();
|
||||
cmd = FuncRequest(LFUN_FINISHED_DOWN);
|
||||
} else {
|
||||
cursorNext(cur);
|
||||
needsUpdate = cursorNext(cur);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1598,17 +1592,20 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
default:
|
||||
lyxerr << BOOST_CURRENT_FUNCTION
|
||||
<< " Not DISPATCHED by LyXText" << endl;
|
||||
cur.undispatched();
|
||||
break;
|
||||
}
|
||||
|
||||
// avoid to update when navigating
|
||||
if (moving
|
||||
&& &sl.inset() == &cur.inset()
|
||||
&& sl.idx() == cur.idx()
|
||||
&& sel == false
|
||||
&& cur.selection() == false)
|
||||
if (!needsUpdate
|
||||
&& &oldTopSlice.inset() == &cur.inset()
|
||||
&& oldTopSlice.idx() == cur.idx()
|
||||
&& !sel
|
||||
&& !cur.selection())
|
||||
cur.noUpdate();
|
||||
else
|
||||
cur.needsUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user