if (bv_->text() == 0)
resizeCurrentBuffer();
- // FIXME: needed when ?
- fitCursor();
-
// Buffer-dependent dialogs should be updated or
// hidden. This should go here because some dialogs (eg ToC)
// require bv_->text.
if (inset) {
res = inset->dispatch(cur, cmd);
} else {
- res = cur.innerText()->dispatch(cur, cmd);
+ res = bv_->text()->dispatch(cur, cmd);
}
if (bv_->fitCursor() || res.update()) {
+2004-02-02 André Pönitz <poenitz@gmx.net>
+
+ * cursor.[Ch]: remove direct access to anchor
+
+ * text.C: remove findText() hack
+
2004-02-02 Alfredo Braunstein <abraunst@lyx.org>
* iterators.[Ch] (lockPath): remove in favour of...
}
+LyXText * LCursor::text() const
+{
+ return current_ ? current().text() : bv_->text();
+}
+
+
Paragraph & LCursor::paragraph()
{
return current_ ? current().paragraph() : *bv_->text()->getPar(par());
os << "\n";
for (size_t i = 0, n = cur.cursor_.size(); i != n; ++i)
os << " (" << cur.cursor_[i] << " | " << cur.anchor_[i] << "\n";
- return os;
+ return os << "current: " << cur.current_ << endl;
}
}
//lyx::BOOST_ASSERT(Anchor_.size() >= cursor.depth());
// use Anchor on the same level as Cursor
- CursorSlice normal = anchor_[depth() - 1];
+ CursorSlice normal = anchor_[current_];
#if 0
if (depth() < anchor_.size() && !(normal < xx())) {
// anchor is behind cursor -> move anchor behind the inset
///
Paragraph const & paragraph() const;
///
+ LyXText * text() const;
+ ///
InsetBase * innerInsetOfType(int code) const;
///
InsetTabular * innerInsetTabular() const;
CursorSlice & cursor();
/// the topmost cursor slice
CursorSlice const & cursor() const;
- /// access to the selection anchor
- CursorSlice & anchor();
- /// access to the selection anchor
- CursorSlice const & anchor() const;
friend class LyXScreen;
paintBackground();
// paint the selection background
- if (bv_.cursor().selection() && &text_ == bv_.cursor().innerText())
- paintSelection();
+#warning look here for selection
+ //if (bv_.cursor().selection() && &text_ == bv_.cursor().innerText())
+ // paintSelection();
// vertical lines for appendix
paintAppendix();
}
-namespace {
-
-int findText(LyXText const * text)
-{
- CursorBase & cur = text->bv()->cursor().cursor_;
- //lyxerr << "findText: text: " << text << " cursor: "
- // << text->bv()->cursor() << endl;
- for (int i = cur.size() - 1; i > 0; --i)
- if (cur[i].text() == text)
- return i;
- if (text->bv()->text() == text)
- return 0;
- lyxerr << "Trying to access text not touched by cursor" << endl;
- BOOST_ASSERT(false);
- return 0; // shut up compiler
-}
-
-}
-
-
CursorSlice & LyXText::cursor()
{
//lyxerr << "# accessing slice " << findText(this) << endl;
- return bv()->cursor().cursor_[findText(this)];
+ if (this != bv()->cursor().text()) {
+ lyxerr << "cursor: " << bv()->cursor()
+ << "\ntext: " << bv()->cursor().text()
+ << "\nthis: " << this << endl;
+ BOOST_ASSERT(false);
+ }
+ return bv()->cursor().current();
}
CursorSlice const & LyXText::cursor() const
{
- return bv()->cursor().cursor_[findText(this)];
-}
-
-
-CursorSlice & LyXText::anchor()
-{
- return bv()->cursor().anchor_[findText(this)];
-}
-
-
-CursorSlice const & LyXText::anchor() const
-{
- return bv()->cursor().anchor_[findText(this)];
+ if (this != bv()->cursor().text()) {
+ lyxerr << "cursor: " << bv()->cursor()
+ << "\ntext: " << bv()->cursor().text()
+ << "\nthis: " << this << endl;
+ BOOST_ASSERT(false);
+ }
+ return bv()->cursor().current();
}
{}
-void LyXText::init(BufferView * bview)
+void LyXText::init(BufferView * bv)
{
- bv_owner = bview;
+ bv_owner = bv;
ParagraphList::iterator const beg = paragraphs().begin();
ParagraphList::iterator const end = paragraphs().end();
current_font = getFont(beg, 0);
redoParagraphs(beg, end);
- setCursorIntern(0, 0);
- bv()->cursor().resetAnchor();
+ bv->cursor().resetAnchor();
updateCounters();
}
case LFUN_BACKSPACE_SKIP:
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
if (!cur.selection()) {
- CursorSlice cur = cursor();
+#warning look here
+ //CursorSlice cur = cursor();
backspace();
- anchor() = cur;
+ //anchor() = cur;
} else {
cutSelection(true, false);
}
// When at the beginning of a paragraph, remove
// indentation and add a "defskip" at the top.
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
- CursorSlice cur = cursor();
+#warning look here
+// CursorSlice cur = cursor();
replaceSelection(bv->getLyXText());
if (cur.pos() == 0) {
- ParagraphParameters & params = getPar(cur)->params();
+ ParagraphParameters & params = getPar(cur.current())->params();
setParagraph(
params.spacing(),
params.align(),
breakParagraph(bv->buffer()->paragraphs(), 0);
}
bv->update();
- anchor() = cur;
+// anchor() = cur;
bv->switchKeyMap();
bv->owner()->view_state_changed();
break;