Alfredo Braunstein wrote:
> - on clicks that do not hit anything, dispatch to the main text, not to
> the inner txt of the old par. Set the global cursor to that text (it was
^^^
I meant old cursor.
Here is the patch.
Alfredo
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.457
diff -u -p -u -r1.457 BufferView_pimpl.C
--- BufferView_pimpl.C 10 Nov 2003 14:29:38 -0000 1.457
+++ BufferView_pimpl.C 10 Nov 2003 17:31:05 -0000
@@ -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
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
// 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::updateParagraphD
}
-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;
-}
Index: BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.109
diff -u -p -u -r1.109 BufferView_pimpl.h
--- BufferView_pimpl.h 10 Nov 2003 13:23:09 -0000 1.109
+++ BufferView_pimpl.h 10 Nov 2003 17:31:07 -0000
@@ -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_;
Index: bufferview_funcs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.h,v
retrieving revision 1.27
diff -u -p -u -r1.27 bufferview_funcs.h
--- bufferview_funcs.h 10 Nov 2003 09:06:34 -0000 1.27
+++ bufferview_funcs.h 10 Nov 2003 17:31:08 -0000
@@ -61,7 +61,6 @@ std::string const currentState(BufferVie
void replaceSelection(LyXText * lt);
-
}; // namespace bv_funcs
#endif
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.252
diff -u -p -u -r1.252 lyxtext.h
--- lyxtext.h 10 Nov 2003 09:06:35 -0000 1.252
+++ lyxtext.h 10 Nov 2003 17:31:09 -0000
@@ -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;
Index: paragraph_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.C,v
retrieving revision 1.86
diff -u -p -u -r1.86 paragraph_funcs.C
--- paragraph_funcs.C 6 Nov 2003 10:52:15 -0000 1.86
+++ paragraph_funcs.C 10 Nov 2003 17:31:10 -0000
@@ -610,3 +610,24 @@ Paragraph const & ownerPar(Buffer 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)
+ ;
+}
Index: paragraph_funcs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.h,v
retrieving revision 1.35
diff -u -p -u -r1.35 paragraph_funcs.h
--- paragraph_funcs.h 5 Nov 2003 12:06:04 -0000 1.35
+++ paragraph_funcs.h 10 Nov 2003 17:31:10 -0000
@@ -75,5 +75,12 @@ ParagraphList::iterator outerPar(Buffer
/// 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
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.497
diff -u -p -u -r1.497 text2.C
--- text2.C 10 Nov 2003 13:23:09 -0000 1.497
+++ text2.C 10 Nov 2003 17:31:15 -0000
@@ -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(),
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.173
diff -u -p -u -r1.173 text3.C
--- text3.C 10 Nov 2003 13:23:10 -0000 1.173
+++ text3.C 10 Nov 2003 17:31:17 -0000
@@ -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,11 +257,15 @@ 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) {
InsetList::iterator iit = pit->insetlist.begin();
@@ -279,7 +284,6 @@ InsetOld * LyXText::checkInsetHit(int &
&& y <= inset->y() + inset->descent())
{
lyxerr << "Hit inset: " << inset << endl;
- y += bv()->top_y();
return inset;
}
}