mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
* cursor.[Ch]: remove direct access to anchor
* text.C: remove findText() hack git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8382 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
39374cc4c7
commit
a73da74db2
@ -328,9 +328,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
|
||||
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.
|
||||
@ -905,7 +902,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
||||
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()) {
|
||||
|
@ -1,4 +1,10 @@
|
||||
|
||||
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...
|
||||
|
10
src/cursor.C
10
src/cursor.C
@ -474,6 +474,12 @@ void LCursor::clearTargetX()
|
||||
}
|
||||
|
||||
|
||||
LyXText * LCursor::text() const
|
||||
{
|
||||
return current_ ? current().text() : bv_->text();
|
||||
}
|
||||
|
||||
|
||||
Paragraph & LCursor::paragraph()
|
||||
{
|
||||
return current_ ? current().paragraph() : *bv_->text()->getPar(par());
|
||||
@ -723,7 +729,7 @@ std::ostream & operator<<(std::ostream & os, LCursor const & cur)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -1705,7 +1711,7 @@ CursorSlice LCursor::normalAnchor()
|
||||
}
|
||||
//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
|
||||
|
@ -201,6 +201,8 @@ public:
|
||||
///
|
||||
Paragraph const & paragraph() const;
|
||||
///
|
||||
LyXText * text() const;
|
||||
///
|
||||
InsetBase * innerInsetOfType(int code) const;
|
||||
///
|
||||
InsetTabular * innerInsetTabular() const;
|
||||
|
@ -391,10 +391,6 @@ public:
|
||||
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;
|
||||
|
||||
|
@ -136,8 +136,9 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
|
||||
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();
|
||||
|
48
src/text.C
48
src/text.C
@ -1933,46 +1933,26 @@ int LyXText::cursorY(CursorSlice const & cur) const
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ LyXText::LyXText(BufferView * bv, bool in_inset)
|
||||
{}
|
||||
|
||||
|
||||
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();
|
||||
@ -94,8 +94,7 @@ void LyXText::init(BufferView * bview)
|
||||
current_font = getFont(beg, 0);
|
||||
|
||||
redoParagraphs(beg, end);
|
||||
setCursorIntern(0, 0);
|
||||
bv()->cursor().resetAnchor();
|
||||
bv->cursor().resetAnchor();
|
||||
|
||||
updateCounters();
|
||||
}
|
||||
|
12
src/text3.C
12
src/text3.C
@ -762,9 +762,10 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
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);
|
||||
}
|
||||
@ -793,10 +794,11 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
// 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(),
|
||||
@ -805,7 +807,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
breakParagraph(bv->buffer()->paragraphs(), 0);
|
||||
}
|
||||
bv->update();
|
||||
anchor() = cur;
|
||||
// anchor() = cur;
|
||||
bv->switchKeyMap();
|
||||
bv->owner()->view_state_changed();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user