#include "frontends/Alert.h"
#include "frontends/FileDialog.h"
#include "frontends/FontMetrics.h"
+#include "frontends/Selection.h"
#include "graphics/Previews.h"
cursor_.resetAnchor();
cursor_.setCursor(buffer_->getCursor().asDocIterator(&(buffer_->inset())));
cursor_.setSelection();
+ theSelection().haveSelection(cursor_.selection());
}
}
if (buffer_) {
cursor_.clearSelection();
xsel_cache_.set = false;
+ // The buffer did not really change, but this causes the
+ // redraw we need because we cleared the selection above.
+ buffer_->changed();
}
}
void BufferView::workAreaResize(int width, int height)
{
- // A resize is triggered whenever a window gets focus,
- // because of the shared rows() of a buffer in multiple
- // buffer views.
-
// Update from work area
width_ = width;
height_ = height;
+ // The complete text metrics will be redone.
text_metrics_.clear();
if (buffer_)
//
// scrollDocView(new_top_y);
//
-// // Update the scrollbar.
-// workArea_->setScrollbarParams(t->height(), top_y(), defaultRowHeight());}
}
cursor_.setSelection(cursor_, -length);
} else
cursor_.setSelection(cursor_, length);
+ theSelection().haveSelection(cursor_.selection());
}
}
}
+// FIXME: We should split-up updateMetrics() for the singlepar case.
void BufferView::updateMetrics(bool singlepar)
{
LyXText & buftext = buffer_->text();
anchor_ref_ = int(buftext.paragraphs().size() - 1);
offset_ref_ = 0;
}
+
+ // If the paragraph metrics has changed, we can not
+ // use the singlepar optimisation.
+ if (singlepar
+ // In Single Paragraph mode, rebreak only
+ // the (main text, not inset!) paragraph containing the cursor.
+ // (if this paragraph contains insets etc., rebreaking will
+ // recursively descend)
+ && tm.redoParagraph(cursor_.bottom().pit()))
+ singlepar = false;
pit_type const pit = anchor_ref_;
int pit1 = pit;
int pit2 = pit;
size_t const npit = buftext.paragraphs().size();
- // Rebreak anchor paragraph. In Single Paragraph mode, rebreak only
- // the (main text, not inset!) paragraph containing the cursor.
- // (if this paragraph contains insets etc., rebreaking will
- // recursively descend)
- if (!singlepar || pit == cursor_.bottom().pit())
- if (tm.redoParagraph(pit))
- singlepar = false;
+ // Rebreak anchor paragraph.
+ if (!singlepar)
+ tm.redoParagraph(pit);
// Clear out the position cache in case of full screen redraw.
if (!singlepar)
int y0 = tm.parMetrics(pit).ascent() - offset_ref_;
- // Redo paragraphs above anchor if necessary; again, in Single Par
- // mode, only if we encounter the (main text) one having the cursor.
+ // Redo paragraphs above anchor if necessary.
int y1 = y0;
while (y1 > 0 && pit1 > 0) {
y1 -= tm.parMetrics(pit1).ascent();
--pit1;
- if (!singlepar || pit1 == cursor_.bottom().pit())
+ if (!singlepar)
tm.redoParagraph(pit1);
y1 -= tm.parMetrics(pit1).descent();
}
anchor_ref_ = 0;
}
- // Redo paragraphs below the anchor if necessary. Single par mode:
- // only the one containing the cursor if encountered.
+ // Redo paragraphs below the anchor if necessary.
int y2 = y0;
while (y2 < height_ && pit2 < int(npit) - 1) {
y2 += tm.parMetrics(pit2).descent();
++pit2;
- if (!singlepar || pit2 == cursor_.bottom().pit())
+ if (!singlepar)
tm.redoParagraph(pit2);
y2 += tm.parMetrics(pit2).ascent();
}