#include "TextClass.h"
#include "TextMetrics.h"
#include "TexRow.h"
+#include "TocBackend.h"
#include "VSpace.h"
#include "WordLangTuple.h"
}
+bool BufferView::isTopScreen() const
+{
+ return d->scrollbarParameters_.position == d->scrollbarParameters_.min;
+}
+
+
+bool BufferView::isBottomScreen() const
+{
+ return d->scrollbarParameters_.position == d->scrollbarParameters_.max;
+}
+
+
Intl & BufferView::getIntl()
{
return d->intl_;
if (covering_inset)
return covering_inset->contextMenu(*this, x, y);
- // FIXME: Do something more elaborate here.
- return from_ascii("edit");
+ return buffer_.inset().contextMenu(*this, x, y);
}
else if (bot_pit == tm.last().first + 1)
tm.newParMetricsDown();
- if (tm.has(bot_pit)) {
+ if (tm.contains(bot_pit)) {
ParagraphMetrics const & pm = tm.parMetrics(bot_pit);
BOOST_ASSERT(!pm.rows().empty());
// FIXME: smooth scrolling doesn't work in mathed.
case LFUN_SCREEN_UP:
case LFUN_SCREEN_DOWN:
case LFUN_SCROLL:
- flag.enabled(true);
- break;
-
- // FIXME: LFUN_SCREEN_DOWN_SELECT should be removed from
- // everywhere else before this can enabled:
case LFUN_SCREEN_UP_SELECT:
case LFUN_SCREEN_DOWN_SELECT:
- flag.enabled(false);
+ flag.enabled(true);
break;
case LFUN_LAYOUT_TABULAR:
case LFUN_BUFFER_TOGGLE_EMBEDDING: {
// turn embedding on/off
try {
- buffer_.embeddedFiles().enable(!buffer_.params().embedded, buffer_);
+ buffer_.embeddedFiles().enable(!buffer_.params().embedded, buffer_, true);
} catch (ExceptionMessage const & message) {
Alert::error(message.title_, message.details_);
}
lfunScroll(cmd);
break;
- case LFUN_SCREEN_UP_SELECT:
- case LFUN_SCREEN_DOWN_SELECT: {
- // Those two are not ready yet for consumption.
- return false;
-
+ case LFUN_SCREEN_UP_SELECT: {
cur.selHandle(true);
- size_t initial_depth = cur.depth();
- Point const p = getPos(cur, cur.boundary());
- scroll(cmd.action == LFUN_SCREEN_UP_SELECT? - height_ : height_);
- // FIXME: We need to verify if the cursor stayed within an inset...
- //cur.reset(buffer_.inset());
- d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_);
+ if (isTopScreen()) {
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_BEGIN_SELECT));
+ cur.finishUndo();
+ break;
+ }
+ int y = getPos(cur, cur.boundary()).y_;
+ int const ymin = y - height_ + defaultRowHeight();
+ while (y > ymin && cur.up())
+ y = getPos(cur, cur.boundary()).y_;
+
cur.finishUndo();
- while (cur.depth() > initial_depth) {
- cur.forwardInset();
+ processUpdateFlags(Update::SinglePar | Update::FitCursor);
+ break;
+ }
+
+ case LFUN_SCREEN_DOWN_SELECT: {
+ cur.selHandle(true);
+ if (isBottomScreen()) {
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_END_SELECT));
+ cur.finishUndo();
+ break;
}
- // FIXME: we need to do a redraw again because of the selection
- // But no screen update is needed.
- d->update_strategy_ = NoScreenUpdate;
- buffer_.changed();
+ int y = getPos(cur, cur.boundary()).y_;
+ int const ymax = y + height_ - defaultRowHeight();
+ while (y < ymax && cur.down())
+ y = getPos(cur, cur.boundary()).y_;
+
+ cur.finishUndo();
+ processUpdateFlags(Update::SinglePar | Update::FitCursor);
break;
}
void BufferView::gotoLabel(docstring const & label)
{
- for (InsetIterator it = inset_iterator_begin(buffer_.inset()); it; ++it) {
- vector<docstring> labels;
- it->getLabelList(buffer_, labels);
- if (std::find(labels.begin(), labels.end(), label) != labels.end()) {
- setCursor(it);
- showCursor();
- return;
- }
+ Toc & toc = buffer().tocBackend().toc("label");
+ TocIterator toc_it = toc.begin();
+ TocIterator end = toc.end();
+ for (; toc_it != end; ++toc_it) {
+ if (label == toc_it->str())
+ dispatch(toc_it->action());
}
+ //FIXME: We could do a bit more searching thanks to this:
+ //InsetLabel const * inset = buffer_.insetLabel(label);
}
if (d->inlineCompletionPos.fixIfBroken())
d->inlineCompletionPos = DocIterator();
+ if (d->anchor_pit_ >= npit)
+ // The anchor pit must have been deleted...
+ d->anchor_pit_ = npit - 1;
+
// Rebreak anchor paragraph.
tm.redoParagraph(d->anchor_pit_);
ParagraphMetrics & anchor_pm = tm.par_metrics_[d->anchor_pit_];
el = buf.errorList("Parse");
buffer_.undo().recordUndo(d->cursor_);
cap::pasteParagraphList(d->cursor_, buf.paragraphs(),
- buf.params().getTextClassPtr(), el);
+ buf.params().documentClassPtr(), el);
res = _("Document %1$s inserted.");
} else {
res = _("Could not insert document %1$s");
{
CursorSlice const & bot = dit.bottom();
TextMetrics const & tm = textMetrics(bot.text());
- if (!tm.has(bot.pit()))
+ if (!tm.contains(bot.pit()))
return Point(-1, -1);
Point p = coordOffset(dit, boundary); // offset from outer paragraph
d->inlineCompletion = completion;
d->inlineCompletionUniqueChars = min(completion.size(), uniqueChars);
- lyxerr << "setInlineCompletion pos=" << pos << " completion=" << completion << " uniqueChars=" << uniqueChars << std::endl;
+ //lyxerr << "setInlineCompletion pos=" << pos << " completion=" << completion << " uniqueChars=" << uniqueChars << std::endl;
// at new position?
DocIterator const & old = d->inlineCompletionPos;
if (old != pos) {
- lyxerr << "inlineCompletionPos changed" << std::endl;
+ //lyxerr << "inlineCompletionPos changed" << std::endl;
// old or pos are in another paragraph?
if ((!samePar(cur, pos) && !pos.empty())
|| (!samePar(cur, old) && !old.empty())) {
singlePar = false;
- lyxerr << "different paragraph" << std::endl;
+ //lyxerr << "different paragraph" << std::endl;
}
d->inlineCompletionPos = pos;
}
// set update flags
if (changed) {
- lyxerr << "inlineCompletion changed" << std::endl;
-
- Update::flags flags
- = cur.disp_.update() | Update::Force;
- if (singlePar && !(flags | Update::SinglePar))
- flags = flags | Update::SinglePar;
- cur.updateFlags(flags);
+ if (singlePar && !(cur.disp_.update() & Update::Force))
+ cur.updateFlags(cur.disp_.update() | Update::SinglePar);
+ else
+ cur.updateFlags(cur.disp_.update() | Update::Force);
}
}