bv_->getLyXText()->redoCursor();
// update all 'visible' paragraphs
- ParagraphList::iterator beg, end;
- getVisiblePars(beg, end);
+ ParagraphList::iterator beg;
+ ParagraphList::iterator end;
+ getParsInRange(buffer_->paragraphs(),
+ top_y(), top_y() + workarea().workHeight(),
+ beg, end);
bv_->text->redoParagraphs(beg, end);
updateScrollbar();
lyxerr << "cursor is: " << bv_->cursor() << endl;
lyxerr << "dispatching " << cmd1 << " to surrounding LyXText "
<< bv_->cursor().innerText() << endl;
- bv_->cursor().innerText()->dispatch(cmd1);
+ theTempCursor.innerText()->dispatch(cmd1);
+ cursor_ = theTempCursor;
//return DispatchResult(true, true);
}
// FIXME: we should skip these when selecting
owner_->updateLayoutChoice();
owner_->updateToolbar();
- fitCursor();
+// fitCursor();
// slight hack: this is only called currently when we
// clicked somewhere, so we force through the display
}
-void BufferView::Pimpl::getVisiblePars
- (ParagraphList::iterator & beg, ParagraphList::iterator & end)
-{
- beg = bv_->text->cursorPar();
- end = beg;
-
- for ( ; beg != bv_->text->ownerParagraphs().begin(); --beg)
- if (beg->y - top_y() < 0)
- break;
-
- if (beg != bv_->text->ownerParagraphs().begin())
- --beg;
-
- for ( ; end != bv_->text->ownerParagraphs().end(); ++end)
- if (end->y - top_y() > workarea().workHeight())
- break;
-}
void MenuInsertLyXFile(std::string const & filen);
/// our workarea
WorkArea & workarea() const;
- /// range of visible main text paragraphs
- void getVisiblePars(ParagraphList::iterator &, ParagraphList::iterator &);
///
LCursor cursor_;
void replaceSelection(LyXText * lt);
-
}; // namespace bv_funcs
#endif
void updateCounters();
/**
* Returns an inset if inset was hit, or 0 if not.
- * If hit, the coordinates are changed relative to the inset.
*/
- InsetOld * checkInsetHit(int & x, int & y);
+ InsetOld * checkInsetHit(int x, int y);
///
int singleWidth(ParagraphList::iterator pit, lyx::pos_type pos) const;
BOOST_ASSERT(false);
return buf.paragraphs().front(); // shut up compiler
}
+
+
+
+
+void getParsInRange(ParagraphList & pl,
+ int ystart, int yend,
+ ParagraphList::iterator & beg,
+ ParagraphList::iterator & end)
+{
+ ParagraphList::iterator const endpar = pl.end();
+ ParagraphList::iterator const begpar = pl.begin();
+
+ BOOST_ASSERT(begpar != endpar);
+
+ beg = endpar;
+ for (--beg; beg != begpar && beg->y > ystart; --beg)
+ ;
+
+ for (end = beg ; end != endpar && end->y < yend; ++end)
+ ;
+}
/// find owning paragraph containing an inset
Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset);
+/// stretch range beg,end to the minimum containing ystart, yend
+void getParsInRange(ParagraphList & pl,
+ int ystart, int yend,
+ ParagraphList::iterator & beg,
+ ParagraphList::iterator & end);
+
+
#endif // PARAGRAPH_FUNCS_H
if (!selecting) {
int topy = bv()->top_y();
int y1 = cursor.y() - topy;
- int y2 = y1;
y -= topy;
InsetOld * inset_hit = checkInsetHit(x, y1);
if (inset_hit && isHighlyEditableInset(inset_hit))
- inset_hit->edit(bv(), x, y - (y2 - y1));
+ inset_hit->edit(bv(), x, y);
}
#else
lyxerr << "cursorUp: y " << cursor.y() << " bl: " <<
if (!selecting) {
int topy = bv()->top_y();
int y1 = cursor.y() - topy;
- int y2 = y1;
y -= topy;
InsetOld * inset_hit = checkInsetHit(x, y1);
if (inset_hit && isHighlyEditableInset(inset_hit))
- inset_hit->edit(bv(), x, y - (y2 - y1));
+ inset_hit->edit(bv(), x, y);
}
#else
setCursorFromCoordinates(bv()->x_target(),
#include "lyxrc.h"
#include "lyxrow.h"
#include "paragraph.h"
+#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "text_funcs.h"
#include "undo.h"
-InsetOld * LyXText::checkInsetHit(int & x, int & y)
+InsetOld * LyXText::checkInsetHit(int x, int y)
{
- ParagraphList::iterator pit = ownerParagraphs().begin();
- ParagraphList::iterator end = ownerParagraphs().end();
+ ParagraphList::iterator pit;
+ ParagraphList::iterator end;
+ getParsInRange(ownerParagraphs(),
+ bv()->top_y(), bv()->top_y() + bv()->workHeight(),
+ pit, end);
+
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
for ( ; pit != end; ++pit) {
InsetList::iterator iit = pit->insetlist.begin();
&& y <= inset->y() + inset->descent())
{
lyxerr << "Hit inset: " << inset << endl;
- y += bv()->top_y();
return inset;
}
}