if (!findNextInset(tmpdit, codes, contents)) {
if (dit.depth() != 1 || dit.pit() != 0 || dit.pos() != 0) {
- tmpdit = doc_iterator_begin(tmpdit.bottom().inset());
+ Inset * inset = &tmpdit.bottom().inset();
+ tmpdit = doc_iterator_begin(&inset->buffer(), inset);
if (!findNextInset(tmpdit, codes, contents))
return false;
- } else
+ } else {
return false;
+ }
}
dit = tmpdit;
BufferView::BufferView(Buffer & buf)
- : width_(0), height_(0), full_screen_(false), buffer_(buf), d(new Private(*this))
+ : width_(0), height_(0), full_screen_(false), buffer_(buf),
+ d(new Private(*this))
{
d->xsel_cache_.set = false;
d->intl_.initKeyMapper(lyxrc.use_kbmap);
+ d->cursor_.setBuffer(&buf);
d->cursor_.push(buffer_.inset());
d->cursor_.resetAnchor();
d->cursor_.setCurrentFont();
// cut off at the top
if (value <= d->scrollbarParameters_.min) {
- DocIterator dit = doc_iterator_begin(buffer_.inset());
+ DocIterator dit = doc_iterator_begin(&buffer_);
showCursor(dit);
LYXERR(Debug::SCROLLING, "scroll to top");
return;
// cut off at the bottom
if (value >= d->scrollbarParameters_.max) {
- DocIterator dit = doc_iterator_end(buffer_.inset());
+ DocIterator dit = doc_iterator_end(&buffer_);
dit.backwardPos();
showCursor(dit);
LYXERR(Debug::SCROLLING, "scroll to bottom");
return;
}
- DocIterator dit = doc_iterator_begin(buffer_.inset());
+ DocIterator dit = doc_iterator_begin(&buffer_);
dit.pit() = i;
LYXERR(Debug::SCROLLING, "value = " << value << " -> scroll to pit " << i);
showCursor(dit);
// it will be restored to the left of the outmost inset that contains
// the bookmark.
if (bottom_pit < int(buffer_.paragraphs().size())) {
- dit = doc_iterator_begin(buffer_.inset());
+ dit = doc_iterator_begin(&buffer_);
dit.pit() = bottom_pit;
dit.pos() = min(bottom_pos, dit.paragraph().size());
case LFUN_NOTE_NEXT:
case LFUN_REFERENCE_NEXT:
case LFUN_WORD_FIND:
+ case LFUN_WORD_FINDADV:
case LFUN_WORD_REPLACE:
case LFUN_MARK_OFF:
case LFUN_MARK_ON:
flag.setEnabled(true);
break;
+ // @todo Test if current WorkArea is the search WorkArea
+ case LFUN_REGEXP_MODE:
+ flag.setEnabled(! this->cursor().inRegexped());
+ break;
+
+ case LFUN_COPY_LABEL_AS_REF: {
+ // if there is an inset at cursor, see whether it
+ // handles the lfun, other start from scratch
+ Inset * inset = cur.nextInset();
+ if (!inset || !inset->getStatus(cur, cmd, flag))
+ flag = lyx::getStatus(cmd);
+ break;
+ }
+
case LFUN_NEXT_INSET_TOGGLE:
case LFUN_NEXT_INSET_MODIFY: {
// this is the real function we want to invoke
docstring label = cmd.argument();
if (label.empty()) {
InsetRef * inset =
- getInsetByCode<InsetRef>(d->cursor_,
- REF_CODE);
+ getInsetByCode<InsetRef>(d->cursor_, REF_CODE);
if (inset) {
label = inset->getParam("reference");
// persistent=false: use temp_bookmark
saveBookmark(0);
}
}
-
- if (!label.empty())
+ if (!label.empty())
gotoLabel(label);
break;
}
break;
}
+ case LFUN_WORD_FINDADV:
+ findAdv(this, cmd);
+ break;
+
case LFUN_MARK_OFF:
cur.clearSelection();
cur.resetAnchor();
from = cur.selectionBegin();
to = cur.selectionEnd();
} else {
- from = doc_iterator_begin(buffer_.inset());
- to = doc_iterator_end(buffer_.inset());
+ from = doc_iterator_begin(&buffer_);
+ to = doc_iterator_end(&buffer_);
}
int const words = countWords(from, to);
int const chars = countChars(from, to, false);
// turn compression on/off
buffer_.params().compressed = !buffer_.params().compressed;
break;
-
+ case LFUN_COPY_LABEL_AS_REF: {
+ // if there is an inset at cursor, try to copy it
+ Inset * inset = cur.nextInset();
+ if (inset) {
+ FuncRequest tmpcmd = cmd;
+ inset->dispatch(cur, tmpcmd);
+ }
+ if (!cur.result().dispatched())
+ // It did not work too; no action needed.
+ break;
+ cur.clearSelection();
+ processUpdateFlags(Update::SinglePar | Update::FitCursor);
+ break;
+ }
case LFUN_NEXT_INSET_TOGGLE: {
// create the the real function we want to invoke
FuncRequest tmpcmd = cmd;
FuncRequest fr(LFUN_INSET_TOGGLE, action);
- Inset & inset = cur.buffer().inset();
+ Inset & inset = cur.buffer()->inset();
InsetIterator it = inset_iterator_begin(inset);
InsetIterator const end = inset_iterator_end(inset);
for (; it != end; ++it) {
void BufferView::gotoLabel(docstring const & label)
{
- 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());
+ std::vector<Buffer const *> bufs = buffer().allRelatives();
+ std::vector<Buffer const *>::iterator it = bufs.begin();
+ for (; it != bufs.end(); ++it) {
+ Buffer const * buf = *it;
+
+ // find label
+ Toc & toc = buf->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());
+ return;
+ }
+ }
}
- //FIXME: We could do a bit more searching thanks to this:
- //InsetLabel const * inset = buffer_.insetLabel(label);
}
d->cursor_ = cur;
- updateLabels(buffer_);
+ buffer_.updateLabels();
updateMetrics();
buffer_.changed();
Point BufferView::getPos(DocIterator const & dit, bool boundary) const
{
+ if (!paragraphVisible(dit))
+ return Point(-1, -1);
+
CursorSlice const & bot = dit.bottom();
TextMetrics const & tm = textMetrics(bot.text());
- if (!tm.contains(bot.pit()))
- return Point(-1, -1);
Point p = coordOffset(dit, boundary); // offset from outer paragraph
p.y_ += tm.parMetrics(bot.pit()).position();
}
+bool BufferView::paragraphVisible(DocIterator const & dit) const
+{
+ CursorSlice const & bot = dit.bottom();
+ TextMetrics const & tm = textMetrics(bot.text());
+
+ return tm.contains(bot.pit());
+}
+
+
void BufferView::draw(frontend::Painter & pain)
{
if (height_ == 0 || width_ == 0)