+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(),
bv_->owner(), bv_->buffer() by direct references to the private
- members.
+ members.
(MenuInsertLyXFile): replace bv_->resize() with resizeCurrentBuffer.
(getStatus): isSavedPosition() is in BufferView::Pimpl.
(fitCursor): center() is in BufferView::Pimpl.
(getStatus, trackChanges, dispatch): no need for a temporary buf
- variable
+ variable
(fitCursor, workAreaDispatch): use workarea().workheight()
2005-02-07 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* CutAndPaste.C (pasteSelectionHelper): convert newline to paragraph
break if pasting into ERT
* lyxfunc.C (getStatus): suppress mathpanel and
- LFUN_DIALOG_SHOW_NEW_INSET in ERT
+ LFUN_DIALOG_SHOW_NEW_INSET in ERT
2005-02-01 Angus Leeming <leeming@lyx.org>
LyXText containing the cursor, not the top-level one.
* buffer.C (Impl): make sure the toplevel insettext has AutoBreak_
- true.
+ true.
(insertStringAsLines): rename par to pit; use temporary variable
par to hold a Paragraph; do not store par.layout() in a variable,
since the pointer may die when breaking paragraphs; pass pars to
* text.C: various obvious clean-ups. Removal of ancient cruft.
Bug fixes, even.
-
+
2005-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
* vc-backend.C (find_file): rewrite to use boost.filesystem
{ 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 },
{ 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 },
{ 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 },
{ 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 },
{ 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 },
{ 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 },
{ 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 },
{ 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 }
};
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();
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.
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 ["
- << func.action << ']' << endl;
+ 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;
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;
enable = !buf->isUnnamed() && !buf->isClean();
break;
-
case LFUN_INSET_SETTINGS: {
enable = false;
if (!cur.size())
errorstat = false;
dispatch_buffer.erase();
- bool update = true;
+ bool update = false;
FuncStatus const flag = getStatus(cmd);
if (!flag.enabled()) {
}
default: {
- update = false;
view()->cursor().dispatch(cmd);
- if (view()->cursor().result().dispatched())
- update |= view()->cursor().result().update();
- else
+ update |= view()->cursor().result().update();
+ if (!view()->cursor().result().dispatched()) {
update |= view()->dispatch(cmd);
+ }
+
break;
}
}
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);
- ///
- void cursorDown(LCursor & cur);
- ///
- void cursorLeft(LCursor & cur);
- ///
- void cursorRight(LCursor & cur);
- ///
- void cursorLeftOneWord(LCursor & cur);
+ bool cursorLeftOneWord(LCursor & cur);
///
- void cursorRightOneWord(LCursor & cur);
+ bool cursorRightOneWord(LCursor & cur);
///
- void cursorUpParagraph(LCursor & cur);
+ bool 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);
///
// 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());
}
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
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;
}
}
-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))
- setCursor(cur, cur.pit(), cur.pos() + 1, true, true);
+ 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());
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());
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;
}
// 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();
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;
#warning DEPM, look here
#endif
//fixCursorAfterDelete(cur.anchor(), old.top());
- return false;
+ return true;
}
}
#include "gettext.h"
#include "intl.h"
#include "language.h"
+#include "LyXAction.h"
#include "lyxfunc.h"
#include "lyxlex.h"
#include "lyxrc.h"
}
-void LyXText::cursorPrevious(LCursor & cur)
+bool LyXText::cursorPrevious(LCursor & cur)
{
pos_type cpos = cur.pos();
lyx::pit_type cpar = cur.pit();
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;
}
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) {
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;
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();
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();
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);
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);
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_DOWN);
} else {
- cursorNext(cur);
+ needsUpdate = cursorNext(cur);
}
break;
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();
}