#include "lyxtext.h"
#include "LString.h"
#include "paragraph.h"
-#include "insets/inseterror.h"
-#include "insets/insetbib.h"
-#include "insets/insetspecialchar.h"
-#include "insets/insettext.h"
-#include "insets/insetfloat.h"
-#include "layout.h"
+#include "lyxtextclasslist.h"
#include "LyXView.h"
-#include "support/textutils.h"
-#include "support/lstrings.h"
#include "undo_funcs.h"
#include "buffer.h"
#include "bufferparams.h"
#include "FloatList.h"
#include "language.h"
#include "ParagraphParameters.h"
+
+#include "insets/inseterror.h"
+#include "insets/insetbib.h"
+#include "insets/insetspecialchar.h"
+#include "insets/insettext.h"
+#include "insets/insetfloat.h"
+
#include "support/LAssert.h"
+#include "support/textutils.h"
+#include "support/lstrings.h"
using std::copy;
using std::find;
redoParagraphs(bview, selection.start, selection.end.par()->next());
// we have to reset the selection, because the
- // geometry could have changed
+ // geometry could have changed, but we keep
+ // it for user convenience
setCursor(bview, selection.start.par(), selection.start.pos());
selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos());
- clearSelection();
setSelection(bview);
setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
tmpcursor.boundary());
if (!tmprow->previous()) {
// a trick/hack for UNDO
- // Can somebody please tell me _why_ this solves
- // anything. (Lgb)
+ // This is needed because in an UNDO/REDO we could have changed
+ // the firstParagrah() so the paragraph inside the row is NOT
+ // my really first par anymore. Got it Lars ;) (Jug 20011206)
first_phys_par = firstParagraph();
} else {
first_phys_par = tmprow->par();
y -= tmprow->height();
}
}
-
+
// we can set the refreshing parameters now
status(bview, LyXText::NEED_MORE_REFRESH);
refresh_y = y;
tmppar = tmprow->next()->par();
else
tmppar = 0;
- while (tmppar != endpar) {
+ while (tmprow->next() && tmppar != endpar) {
removeRow(tmprow->next());
- if (tmprow->next())
+ if (tmprow->next()) {
tmppar = tmprow->next()->par();
- else
+ } else {
tmppar = 0;
- }
+ }
+ }
// remove the first one
tmprow2 = tmprow; /* this is because tmprow->previous()
string const LyXText::selectionAsString(Buffer const * buffer,
- bool label) const
+ bool label) const
{
if (!selection.set()) return string();
string result;
{
if (!cursor.par()->insetAllowed(inset->lyxCode()))
return;
- setUndo(bview, Undo::INSERT,
- cursor.par(), cursor.par()->next());
+ // I don't know if this is necessary here (Jug 20020102)
+ setUndo(bview, Undo::INSERT, cursor.par(), cursor.par()->next());
cursor.par()->insertInset(cursor.pos(), inset);
// Just to rebreak and refresh correctly.
// The character will not be inserted a second time
}
-void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
+void LyXText::setCursor(BufferView * bview, LyXCursor & cur, Paragraph * par,
pos_type pos, bool boundary) const
{
+ lyx::Assert(par);
+ lyx::Assert(bview);
+
cur.par(par);
cur.pos(pos);
cur.boundary(boundary);
float fill_hfill;
float fill_label_hfill;
prepareToPrint(bview, row, x, fill_separator, fill_hfill,
- fill_label_hfill);
+ fill_label_hfill);
pos_type cursor_vpos = 0;
pos_type last = rowLastPrintable(row);
- if (pos > last + 1) // This shouldn't happen.
+ if (pos > last + 1) {
+ // This shouldn't happen.
pos = last + 1;
- else if (pos < row->pos())
+ cur.pos(pos);
+ } else if (pos < row->pos()) {
pos = row->pos();
-
+ cur.pos(pos);
+ }
+
if (last < row->pos())
cursor_vpos = row->pos();
else if (pos > last && !boundary)
void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
- pos_type pos,
- bool setfont, bool boundary) const
+ pos_type pos, bool setfont, bool boundary) const
{
InsetText * it = static_cast<InsetText *>(par->inInset());
if (it) {
// I moved the lyxerr stuff in here so we can see if
// this is actually really needed and where!
// (Jug)
- it->getLyXText(bview)->setCursorIntern(bview, par, pos, setfont,
- boundary);
+ // it->getLyXText(bview)->setCursorIntern(bview, par, pos, setfont, boundary);
return;
}
}
void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
LyXCursor const & old_cursor) const
{
- // don't delete anything if this is the ONLY paragraph!
- if (!old_cursor.par()->next() && !old_cursor.par()->previous())
- return;
-
// Would be wrong to delete anything if we have a selection.
if (selection.set()) return;
// We allow all kinds of "mumbo-jumbo" when freespacing.
if (textclasslist.Style(bview->buffer()->params.textclass,
- old_cursor.par()->getLayout()).free_spacing ||
- old_cursor.par()->isFreeSpacing())
+ old_cursor.par()->getLayout()).free_spacing
+ || old_cursor.par()->isFreeSpacing())
{
return;
}
// MISSING
// If the pos around the old_cursor were spaces, delete one of them.
- if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
+ if (old_cursor.par() != cursor.par()
+ || old_cursor.pos() != cursor.pos()) {
// Only if the cursor has really moved
if (old_cursor.pos() > 0
}
}
+ // don't delete anything if this is the ONLY paragraph!
+ if (!old_cursor.par()->next() && !old_cursor.par()->previous())
+ return;
+
// Do not delete empty paragraphs with keepempty set.
if ((textclasslist.Style(bview->buffer()->params.textclass,
old_cursor.par()->getLayout())).keepempty)
setUndo(bview, Undo::DELETE, old_cursor.par(), endpar);
cursor = tmpcursor;
- // delete old row
+ // delete old row
removeRow(old_cursor.row());
if (ownerParagraph() == old_cursor.par()) {
ownerParagraph(ownerParagraph()->next());
if (op && op->inInset()) {
static_cast<InsetText *>(op->inInset())->paragraph(p);
} else {
- if (inset_owner) {
- inset_owner->paragraph(p);
- } else {
- bv_owner->buffer()->paragraph = p;
- }
+ ownerParagraph(p);
}
}