mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Alfredo's patch.
Enough for today... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8073 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7803b6341b
commit
6789af0a32
@ -605,8 +605,11 @@ void BufferView::Pimpl::update()
|
||||
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();
|
||||
@ -968,7 +971,8 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -979,7 +983,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
|
||||
// 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
|
||||
@ -1341,20 +1345,3 @@ void BufferView::Pimpl::updateParagraphDialog()
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -193,8 +193,6 @@ private:
|
||||
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_;
|
||||
|
@ -61,7 +61,6 @@ std::string const currentState(BufferView *);
|
||||
void replaceSelection(LyXText * lt);
|
||||
|
||||
|
||||
|
||||
}; // namespace bv_funcs
|
||||
|
||||
#endif
|
||||
|
@ -343,9 +343,8 @@ public:
|
||||
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;
|
||||
|
@ -610,3 +610,24 @@ Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset)
|
||||
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)
|
||||
;
|
||||
}
|
||||
|
@ -75,5 +75,12 @@ ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset);
|
||||
/// 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
|
||||
|
@ -1624,11 +1624,10 @@ void LyXText::cursorUp(bool selecting)
|
||||
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: " <<
|
||||
@ -1650,11 +1649,10 @@ void LyXText::cursorDown(bool selecting)
|
||||
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(),
|
||||
|
12
src/text3.C
12
src/text3.C
@ -31,6 +31,7 @@
|
||||
#include "lyxrc.h"
|
||||
#include "lyxrow.h"
|
||||
#include "paragraph.h"
|
||||
#include "paragraph_funcs.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "text_funcs.h"
|
||||
#include "undo.h"
|
||||
@ -256,10 +257,14 @@ string const freefont2string()
|
||||
|
||||
|
||||
|
||||
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) {
|
||||
@ -279,7 +284,6 @@ InsetOld * LyXText::checkInsetHit(int & x, int & y)
|
||||
&& y <= inset->y() + inset->descent())
|
||||
{
|
||||
lyxerr << "Hit inset: " << inset << endl;
|
||||
y += bv()->top_y();
|
||||
return inset;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user