[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-devel
Subject:    And destruction lays around me...
From:       andre.poenitz () mathematik ! tu-chemnitz ! de
Date:       2004-08-16 21:22:08
Message-ID: 1092691328.41212580b0bd6 () mail ! tu-chemnitz ! de
[Download RAW message or body]

Just for the fun of it and for the record.
Of course it is broken, but UserGuide loads
pretty fast now...

Andre'
["t" (text/x-diff)]

? TODO
? \
? lyxtext.h.gch
? paper.h.gch
? s
? t
? t.C
? mathed/math_all.C
Index: BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.253
diff -u -p -r1.253 BufferView.C
--- BufferView.C	16 Aug 2004 00:31:58 -0000	1.253
+++ BufferView.C	16 Aug 2004 21:15:27 -0000
@@ -213,18 +213,6 @@ void BufferView::center()
 }
 
 
-int BufferView::top_y() const
-{
-	return pimpl_->top_y();
-}
-
-
-void BufferView::top_y(int y)
-{
-	pimpl_->top_y(y);
-}
-
-
 string const BufferView::getClipboard() const
 {
 	return pimpl_->workarea().getClipboard();
@@ -336,13 +324,11 @@ LyXText * BufferView::text() const
 
 void BufferView::setCursor(ParIterator const & par, lyx::pos_type pos)
 {
-	int const last = par.size();
-	for (int i = 0; i < last; ++i)
+	for (int i = 0, n = par.size(); i < n; ++i)
 		par[i].inset().edit(cursor(), true);
 
 	cursor().setCursor(makeDocIterator(par, pos));
 	cursor().selection() = false;
-	par.bottom().text()->redoParagraph(par.bottom().par());
 }
 
 
Index: BufferView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
retrieving revision 1.178
diff -u -p -r1.178 BufferView.h
--- BufferView.h	16 Aug 2004 00:31:58 -0000	1.178
+++ BufferView.h	16 Aug 2004 21:15:27 -0000
@@ -66,12 +66,6 @@ public:
 	/// return the owning main view
 	LyXView * owner() const;
 
-	/// return the visible top y
-	int top_y() const;
-
-	/// set the visible top y
-	void top_y(int);
-
 	/// resize event has happened
 	void resize();
 
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.555
diff -u -p -r1.555 BufferView_pimpl.C
--- BufferView_pimpl.C	14 Aug 2004 19:54:55 -0000	1.555
+++ BufferView_pimpl.C	16 Aug 2004 21:15:27 -0000
@@ -308,18 +308,6 @@ Painter & BufferView::Pimpl::painter() c
 }
 
 
-void BufferView::Pimpl::top_y(int y)
-{
-	top_y_ = y;
-}
-
-
-int BufferView::Pimpl::top_y() const
-{
-	return top_y_;
-}
-
-
 void BufferView::Pimpl::setBuffer(Buffer * b)
 {
 	lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
@@ -331,7 +319,6 @@ void BufferView::Pimpl::setBuffer(Buffer
 	buffer_ = b;
 
 	// reset old cursor
-	top_y_ = 0;
 	cursor_ = LCursor(*bv_);
 
 	// if we're quitting lyx, don't bother updating stuff
@@ -380,27 +367,28 @@ void BufferView::Pimpl::setBuffer(Buffer
 
 bool BufferView::Pimpl::fitCursor()
 {
-	// to get the correct y cursor info
-	lyxerr[Debug::DEBUG] << "BufferView::fitCursor" << std::endl;
-	lyx::par_type const pit = bv_->cursor().bottom().par();
-	bv_->text()->redoParagraph(pit);
-	refreshPar(*bv_, *bv_->text(), pit);
-
-	if (!screen().fitCursor(bv_))
-		return false;
+//	// to get the correct y cursor info
+//	lyxerr[Debug::DEBUG] << "BufferView::fitCursor" << std::endl;
+//	lyx::par_type const pit = bv_->cursor().bottom().par();
+//	bv_->text()->redoParagraph(pit);
+//	refreshPar(*bv_, *bv_->text(), pit);
+//
+//	if (!screen().fitCursor(bv_))
+//		return false;
 	updateScrollbar();
-	return true;
+//	return true;
+	return false;
 }
 
 
 void BufferView::Pimpl::redoCurrentBuffer()
 {
-	lyxerr[Debug::DEBUG] << "BufferView::redoCurrentBuffer" << endl;
-	if (buffer_ && bv_->text()) {
-		resizeCurrentBuffer();
-		updateScrollbar();
-		owner_->updateLayoutChoice();
-	}
+//	lyxerr[Debug::DEBUG] << "BufferView::redoCurrentBuffer" << endl;
+//	if (buffer_ && bv_->text()) {
+//		resizeCurrentBuffer();
+//		updateScrollbar();
+//		owner_->updateLayoutChoice();
+//	}
 }
 
 
@@ -439,11 +427,12 @@ void BufferView::Pimpl::updateScrollbar(
 	LyXText const & t = *bv_->text();
 
 	lyxerr[Debug::GUI]
-		<< "Updating scrollbar: height: " << t.height()
-		<< " top_y: " << top_y()
+		<< "Updating scrollbar: height: " << t.paragraphs().size()
+		<< " curr par: " << bv_->cursor().bottom().par()
 		<< " default height " << defaultRowHeight() << endl;
 
-	workarea().setScrollbarParams(t.height(), top_y(), defaultRowHeight());
+	workarea().setScrollbarParams(t.paragraphs().size(),
+		bv_->cursor().bottom().par(), defaultRowHeight());
 }
 
 
@@ -456,24 +445,24 @@ void BufferView::Pimpl::scrollDocView(in
 
 	screen().hideCursor();
 
-	top_y(value);
-	screen().redraw(*bv_);
-
-	if (!lyxrc.cursor_follows_scrollbar)
-		return;
-
-	int const height = defaultRowHeight();
-	int const first = top_y() + height;
-	int const last = top_y() + workarea().workHeight() - height;
-
-	bv_->cursor().reset(bv_->buffer()->inset());
-	LyXText * text = bv_->text();
-	int y = text->cursorY(bv_->cursor().front());
-	if (y < first)
-		y = first;
-	if (y > last)
-		y = last;
-	text->setCursorFromCoordinates(bv_->cursor(), 0, y);
+//	top_y(value);
+//	screen().redraw(*bv_);
+//
+//	if (!lyxrc.cursor_follows_scrollbar)
+//		return;
+//
+//	int const height = defaultRowHeight();
+//	int const first = top_y() + height;
+//	int const last = top_y() + workarea().workHeight() - height;
+//
+//	bv_->cursor().reset(bv_->buffer()->inset());
+//	LyXText * text = bv_->text();
+//	int y = text->cursorY(bv_->cursor().front());
+//	if (y < first)
+//		y = first;
+//	if (y > last)
+//		y = last;
+//	text->setCursorFromCoordinates(bv_->cursor(), 0, y);
 
 	owner_->updateLayoutChoice();
 }
@@ -481,23 +470,23 @@ void BufferView::Pimpl::scrollDocView(in
 
 void BufferView::Pimpl::scroll(int lines)
 {
-	if (!buffer_)
-		return;
-
-	LyXText const * t = bv_->text();
-	int const line_height = defaultRowHeight();
-
-	// The new absolute coordinate
-	int new_top_y = top_y() + lines * line_height;
-
-	// Restrict to a valid value
-	new_top_y = std::min(t->height() - 4 * line_height, new_top_y);
-	new_top_y = std::max(0, new_top_y);
-
-	scrollDocView(new_top_y);
-
-	// Update the scrollbar.
-	workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
+//	if (!buffer_)
+//		return;
+//
+//	LyXText const * t = bv_->text();
+//	int const line_height = defaultRowHeight();
+//
+//	// The new absolute coordinate
+//	int new_top_y = top_y() + lines * line_height;
+//
+//	// Restrict to a valid value
+//	new_top_y = std::min(t->height() - 4 * line_height, new_top_y);
+//	new_top_y = std::max(0, new_top_y);
+//
+//	scrollDocView(new_top_y);
+//
+//	// Update the scrollbar.
+//	workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
 }
 
 
@@ -594,12 +583,12 @@ void BufferView::Pimpl::update()
 		// update macro store
 		buffer_->buildMacros();
 
-		// update all 'visible' paragraphs
-		lyx::par_type beg, end;
-		getParsInRange(buffer_->paragraphs(),
-			       top_y(), top_y() + workarea().workHeight(),
-			       beg, end);
-		bv_->text()->redoParagraphs(beg, end);
+//		// update all 'visible' paragraphs
+//		lyx::par_type beg, end;
+//		getParsInRange(buffer_->paragraphs(),
+//			       top_y(), top_y() + workarea().workHeight(),
+//			       beg, end);
+//		bv_->text()->redoParagraphs(beg, end);
 
 		// and the scrollbar
 		updateScrollbar();
@@ -725,30 +714,13 @@ void BufferView::Pimpl::switchKeyMap()
 
 void BufferView::Pimpl::center()
 {
-	LyXText * text = bv_->text();
-
-	bv_->cursor().clearSelection();
-	int const half_height = workarea().workHeight() / 2;
-	int new_y = text->cursorY(bv_->cursor().front()) - half_height;
-	if (new_y < 0)
-		new_y = 0;
-
-	// FIXME: look at this comment again ...
-	// This updates top_y() but means the fitCursor() call
-	// from the update(FITCUR) doesn't realise that we might
-	// have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
-	// the scrollbar to be updated as it should, so we have
-	// to do it manually. Any operation that does a center()
-	// and also might have moved top_y() must make sure to call
-	// updateScrollbar() currently. Never mind that this is a
-	// pretty obfuscated way of updating text->top_y()
-	top_y(new_y);
+	bv_->cursor().yo_ = workarea().workHeight() / 2;
 }
 
 
-void BufferView::Pimpl::stuffClipboard(string const & stuff) const
+void BufferView::Pimpl::stuffClipboard(string const & content) const
 {
-	workarea().putClipboard(stuff);
+	workarea().putClipboard(content);
 }
 
 
@@ -862,7 +834,6 @@ bool BufferView::Pimpl::workAreaDispatch
 		return true;
 	}
 
-	cmd.y += bv_->top_y();
 	if (!bv_->buffer())
 		return false;
 
@@ -905,7 +876,7 @@ bool BufferView::Pimpl::workAreaDispatch
 
 	if (cur.result().dispatched()) {
 		// Redraw if requested or necessary.
-		if (fitCursor() || cur.result().update())
+		//if (fitCursor() || cur.result().update())
 			update();
 	}
 
Index: BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.124
diff -u -p -r1.124 BufferView_pimpl.h
--- BufferView_pimpl.h	14 Aug 2004 00:27:15 -0000	1.124
+++ BufferView_pimpl.h	16 Aug 2004 21:15:27 -0000
@@ -103,13 +103,7 @@ struct BufferView::Pimpl : public boost:
 	FuncStatus getStatus(FuncRequest const & cmd);
 	/// a function should be executed
 	bool dispatch(FuncRequest const & ev);
-	///
-	int top_y() const;
-	///
-	void top_y(int y);
 private:
-	/// the y coordinate of the top of the screen
-	int top_y_;
 	/// An error list (replaces the error insets)
 	ErrorList errorlist_;
 	/// add an error to the list
Index: CutAndPaste.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/CutAndPaste.C,v
retrieving revision 1.139
diff -u -p -r1.139 CutAndPaste.C
--- CutAndPaste.C	13 Aug 2004 12:05:26 -0000	1.139
+++ CutAndPaste.C	16 Aug 2004 21:15:27 -0000
@@ -466,7 +466,7 @@ void cutSelection(LCursor & cur, bool do
 		if (doclear)
 			text->paragraphs()[begpit].stripLeadingSpaces();
 
-		text->redoParagraphs(begpit, begpit + 1);
+//		text->redoParagraphs(begpit, begpit + 1);
 		// cutSelection can invalidate the cursor so we need to set
 		// it anew. (Lgb)
 		// we prefer the end for when tracking changes
@@ -563,8 +563,6 @@ void pasteSelection(LCursor & cur, size_
 								sel_index, el);
 		bufferErrors(cur.buffer(), el);
 		cur.bv().showErrorList(_("Paste"));
-
-		text->redoParagraphs(cur.par(), endpit);
 
 		cur.clearSelection();
 		cur.resetAnchor();
Index: cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.109
diff -u -p -r1.109 cursor.C
--- cursor.C	14 Aug 2004 19:54:58 -0000	1.109
+++ cursor.C	16 Aug 2004 21:15:27 -0000
@@ -119,7 +119,10 @@ namespace {
 		CursorSlice bottom = cursor[0];
 		LyXText * text = bottom.text();
 		BOOST_ASSERT(text);
-		getParsInRange(text->paragraphs(), ylow, yhigh, beg, end);
+		
+		//getParsInRange(text->paragraphs(), ylow, yhigh, beg, end);
+		beg = 0;
+		end = text->paragraphs().size();
 
 		DocIterator it = doc_iterator_begin(cursor.bv().buffer()->inset());
 		DocIterator et = doc_iterator_end(cursor.bv().buffer()->inset());
@@ -164,9 +167,13 @@ namespace {
 } // namespace anon
 
 
+// be careful: this is called from the bv's constructor, too, so 
+// bv functions are not yet available!
 LCursor::LCursor(BufferView & bv)
 	: DocIterator(), bv_(&bv), anchor_(), x_target_(-1),
-	  selection_(false), mark_(false)
+	  selection_(false), mark_(false), xo_(0),
+		//yo_(bv.workHeight() / 2)
+		yo_(200)
 {}
 
 
@@ -350,10 +357,8 @@ void LCursor::getDim(int & asc, int & de
 
 void LCursor::getPos(int & x, int & y) const
 {
-	x = 0;
-	y = 0;
-	if (!empty())
-		inset().getCursorPos(*this, x, y);
+	inset().getCursorPos(*this, x, y);
+	y = yo_;
 }
 
 
Index: dociterator.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.C,v
retrieving revision 1.17
diff -u -p -r1.17 dociterator.C
--- dociterator.C	14 Aug 2004 21:03:55 -0000	1.17
+++ dociterator.C	16 Aug 2004 21:15:27 -0000
@@ -172,7 +172,7 @@ DocIterator::row_type DocIterator::crow(
 
 DocIterator::row_type DocIterator::lastcrow() const
 {
-	return paragraph().rows.size();
+	return paragraph().rows().size();
 }
 
 
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.312
diff -u -p -r1.312 lyxtext.h
--- lyxtext.h	15 Aug 2004 21:59:29 -0000	1.312
+++ lyxtext.h	16 Aug 2004 21:15:27 -0000
@@ -17,6 +17,7 @@
 #include "bufferview_funcs.h"
 #include "Bidi.h"
 #include "dispatchresult.h"
+#include "dimension.h"
 #include "lyxfont.h"
 #include "layout.h"
 #include "lyxlayout_ptr_fwd.h"
@@ -56,8 +57,6 @@ public:
 	///
 	void init(BufferView *);
 
-	/// update y coordinate cache of all paragraphs
-	void updateParPositions();
 	///
 	LyXFont getFont(Paragraph const & par, pos_type pos) const;
 	///
@@ -93,12 +92,8 @@ public:
 	/// Set font over selection paragraphs and rebreak.
 	void setFont(LCursor & cur, LyXFont const &, bool toggleall = false);
 
-	/// rebreaks all paragaphs between the given pars.
-	void redoParagraphs(par_type begin, par_type end);
 	/// rebreaks the given par
 	void redoParagraph(par_type pit);
-	/// rebreaks the cursor par
-	void redoParagraph(LCursor & cur);
 
 	/// returns pos in given par at given x coord
 	pos_type x2pos(par_type pit, int row, int x) const;
@@ -115,8 +110,6 @@ public:
 	/// insert an inset at cursor position
 	void insertInset(LCursor & cur, InsetBase * inset);
 
-	/// a full rebreak of the whole text
-	void fullRebreak();
 	/// compute text metrics
 	void metrics(MetricsInfo & mi, Dimension & dim);
 	/// draw text (only used for insets)
@@ -339,11 +332,9 @@ public:
 
 public:
 	///
-	unsigned int width_;
+	Dimension dim_;
 	///
 	int maxwidth_;
-	///
-	int height_;
 	/// the current font settings
 	LyXFont current_font;
 	/// the current font
@@ -373,8 +364,6 @@ private:
 	/// change on pit
 	par_type undoSpan(par_type pit);
 
-	/// rebreaks the given par
-	void redoParagraphInternal(par_type pit);
 	/// used in setlayout
 	void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
 
Index: paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.377
diff -u -p -r1.377 paragraph.C
--- paragraph.C	15 Aug 2004 16:52:40 -0000	1.377
+++ paragraph.C	16 Aug 2004 21:15:27 -0000
@@ -70,10 +70,8 @@ ParagraphList::ParagraphList()
 
 
 Paragraph::Paragraph()
-	: y(0), height(0), begin_of_body_(0),
-	  pimpl_(new Paragraph::Pimpl(this))
+	: height_(0), begin_of_body_(0), pimpl_(new Paragraph::Pimpl(this))
 {
-	//lyxerr << "sizeof Paragraph::Pimpl: " << sizeof(Paragraph::Pimpl) << endl;
 	itemdepth = 0;
 	params().clear();
 }
@@ -81,8 +79,8 @@ Paragraph::Paragraph()
 
 Paragraph::Paragraph(Paragraph const & par)
 	:	itemdepth(par.itemdepth), insetlist(par.insetlist),
-		rows(par.rows), y(par.y), height(par.height),
-		width(par.width), layout_(par.layout_),
+		height_(par.height_), width_(par.width_),
+		rows_(par.rows_), layout_(par.layout_),
 		text_(par.text_), begin_of_body_(par.begin_of_body_),
 	  pimpl_(new Paragraph::Pimpl(*par.pimpl_, this))
 {
@@ -106,10 +104,9 @@ Paragraph & Paragraph::operator=(Paragra
 		for (; it != end; ++it)
 			it->inset = it->inset->clone().release();
 
-		rows = par.rows;
-		y = par.y;
-		height = par.height;
-		width = par.width;
+		rows_ = par.rows_;
+		height_ = par.height_;
+		width_ = par.width_;
 		layout_ = par.layout();
 		text_ = par.text_;
 		begin_of_body_ = par.begin_of_body_;
@@ -408,8 +405,8 @@ LyXFont const Paragraph::getFont(BufferP
 }
 
 
-LyXFont const Paragraph::getLabelFont(BufferParams const & bparams,
-				      LyXFont const & outerfont) const
+LyXFont const Paragraph::getLabelFont
+	(BufferParams const & bparams, LyXFont const & outerfont) const
 {
 	LyXFont tmpfont = layout()->labelfont;
 	tmpfont.setLanguage(getParLanguage(bparams));
@@ -419,8 +416,8 @@ LyXFont const Paragraph::getLabelFont(Bu
 }
 
 
-LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams,
-				       LyXFont const & outerfont) const
+LyXFont const Paragraph::getLayoutFont
+	(BufferParams const & bparams, LyXFont const & outerfont) const
 {
 	LyXFont tmpfont = layout()->font;
 	tmpfont.setLanguage(getParLanguage(bparams));
@@ -431,9 +428,8 @@ LyXFont const Paragraph::getLayoutFont(B
 
 
 /// Returns the height of the highest font in range
-LyXFont_size
-Paragraph::highestFontInRange(pos_type startpos, pos_type endpos,
-			      LyXFont_size def_size) const
+LyXFont_size Paragraph::highestFontInRange
+	(pos_type startpos, pos_type endpos, LyXFont_size def_size) const
 {
 	if (pimpl_->fontlist.empty())
 		return def_size;
@@ -1812,8 +1808,8 @@ bool Paragraph::allowEmpty() const
 
 RowList::iterator Paragraph::getRow(pos_type pos)
 {
-	RowList::iterator rit = rows.end();
-	RowList::iterator const begin = rows.begin();
+	RowList::iterator rit = rows_.end();
+	RowList::iterator const begin = rows_.begin();
 
 	for (--rit; rit != begin && rit->pos() > pos; --rit)
 		;
@@ -1824,8 +1820,8 @@ RowList::iterator Paragraph::getRow(pos_
 
 RowList::const_iterator Paragraph::getRow(pos_type pos) const
 {
-	RowList::const_iterator rit = rows.end();
-	RowList::const_iterator const begin = rows.begin();
+	RowList::const_iterator rit = rows_.end();
+	RowList::const_iterator const begin = rows_.begin();
 
 	for (--rit; rit != begin && rit->pos() > pos; --rit)
 		;
@@ -1836,8 +1832,8 @@ RowList::const_iterator Paragraph::getRo
 
 size_t Paragraph::row(pos_type pos) const
 {
-	RowList::const_iterator rit = rows.end();
-	RowList::const_iterator const begin = rows.begin();
+	RowList::const_iterator rit = rows_.end();
+	RowList::const_iterator const begin = rows_.begin();
 
 	for (--rit; rit != begin && rit->pos() > pos; --rit)
 		;
Index: paragraph.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v
retrieving revision 1.135
diff -u -p -r1.135 paragraph.h
--- paragraph.h	14 Aug 2004 19:54:58 -0000	1.135
+++ paragraph.h	16 Aug 2004 21:15:27 -0000
@@ -34,6 +34,8 @@ class BufferParams;
 class BufferView;
 class Counters;
 class InsetBase;
+class MetricsInfo;
+class PainterInfo;
 class InsetBibitem;
 class InsetOld_code;
 class Language;
@@ -76,6 +78,10 @@ public:
 	///
 	int id() const;
 
+	// drawing
+	void metrics(MetricsInfo & mi, Dimension & dim);
+	void draw(PainterInfo & pi, int x, int y) const;
+
 	///
 	Language const * getParLanguage(BufferParams const &) const;
 	///
@@ -357,16 +363,24 @@ public:
 	///
 	InsetList insetlist;
 
+	/// total height of paragraph
+	unsigned int height() const { return height_; }
+	/// total width of paragraph, may differ from workwidth
+	unsigned int width() const { return width_; }
+	///
+	RowList & rows() { return rows_; }
 	///
-	mutable RowList rows;
-	/// last draw y position (baseline of top row)
-	int y;
+	RowList const & rows() const { return rows_; }
+
+public:
 	/// total height of paragraph
-	unsigned int height;
+	unsigned int height_;
 	/// total width of paragraph, may differ from workwidth
-	unsigned int width;
+	unsigned int width_;
 
 private:
+	///
+	mutable RowList rows_;
 	///
 	LyXLayout_ptr layout_;
 	/// keeping this here instead of in the pimpl makes LyX >10% faster
Index: paragraph_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.C,v
retrieving revision 1.107
diff -u -p -r1.107 paragraph_funcs.C
--- paragraph_funcs.C	16 Aug 2004 00:32:00 -0000	1.107
+++ paragraph_funcs.C	16 Aug 2004 21:15:27 -0000
@@ -316,41 +316,17 @@ LyXFont const outerFont(par_type par_off
 	return tmpfont;
 }
 
-
-par_type outerPar(Buffer const & buf, InsetBase const * inset)
-{
-	ParIterator pit = const_cast<Buffer &>(buf).par_iterator_begin();
-	ParIterator end = const_cast<Buffer &>(buf).par_iterator_end();
-	for ( ; pit != end; ++pit) {
-		LyXText * text;
-		// the second '=' below is intentional
-		for (int i = 0; (text = inset->getText(i)); ++i)
-			if (&text->paragraphs() == &pit.plist())
-				return pit.outerPar();
-
-		InsetList::const_iterator ii = pit->insetlist.begin();
-		InsetList::const_iterator iend = pit->insetlist.end();
-		for ( ; ii != iend; ++ii)
-			if (ii->inset == inset)
-				return pit.outerPar();
-	}
-	lyxerr << "outerPar: should not happen" << endl;
-	BOOST_ASSERT(false);
-	return buf.paragraphs().size(); // shut up compiler
-}
-
-
-/// return the range of pars [beg, end[ owning the range of y [ystart, yend]
-void getParsInRange(ParagraphList & pars, int ystart, int yend,
-	par_type & beg, par_type & end)
-{
-	BOOST_ASSERT(!pars.empty());
-	par_type const endpar = pars.size();
-	par_type const begpar = 0;
-
-	for (beg = endpar - 1; beg != begpar && pars[beg].y > ystart; --beg)
-		;
-
-	for (end = beg ; end != endpar && pars[end].y <= yend; ++end)
-		;
-}
+//// return the range of pars [beg, end[ owning the range of y [ystart, yend]
+//void getParsInRange(ParagraphList & pars, int ystart, int yend,
+//	par_type & beg, par_type & end)
+//{
+//	BOOST_ASSERT(!pars.empty());
+//	par_type const endpar = pars.size();
+//	par_type const begpar = 0;
+//
+//	for (beg = endpar - 1; beg != begpar && pars[beg].y > ystart; --beg)
+//		;
+//
+//	for (end = beg ; end != endpar && pars[end].y <= yend; ++end)
+//		;
+//}
Index: paragraph_funcs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.h,v
retrieving revision 1.43
diff -u -p -r1.43 paragraph_funcs.h
--- paragraph_funcs.h	16 Aug 2004 00:32:00 -0000	1.43
+++ paragraph_funcs.h	16 Aug 2004 21:15:27 -0000
@@ -56,10 +56,7 @@ bool isFirstInSequence(lyx::par_type par
     proof environment */
 int getEndLabel(lyx::par_type par, ParagraphList const & plist);
 
-LyXFont const outerFont(lyx::par_type par, ParagraphList const & plist);
-
-/// find outermost paragraph containing an inset
-lyx::par_type outerPar(Buffer const & buf, InsetBase const * inset);
+LyXFont const outerFont(lyx::par_type par_offset, ParagraphList const & pars);
 
 /// return the range of pars [beg, end[ owning the range of y [ystart, yend]
 void getParsInRange(ParagraphList & plist,
Index: rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.135
diff -u -p -r1.135 rowpainter.C
--- rowpainter.C	15 Aug 2004 16:52:40 -0000	1.135
+++ rowpainter.C	16 Aug 2004 21:15:28 -0000
@@ -61,7 +61,6 @@ public:
 private:
 	// paint various parts
 	void paintBackground();
-	void paintSelection();
 	void paintAppendix();
 	void paintDepthBar();
 	void paintChangeBar();
@@ -135,14 +134,10 @@ RowPainter::RowPainter(BufferView const 
 	hfill_ = m.hfill;
 	label_hfill_ = m.label_hfill;
 
-	// background has already been cleared.
+	// background has to be cleared for top level text
 	if (&text_ == bv_.text())
 		paintBackground();
 
-	// paint the selection background
-	if (bv_.cursor().selection() && &text_ == bv_.cursor().text())
-		paintSelection();
-
 	// vertical lines for appendix
 	paintAppendix();
 
@@ -395,101 +390,6 @@ void RowPainter::paintBackground()
 }
 
 
-void RowPainter::paintSelection()
-{
-	bool const is_rtl = text_.isRTL(par_);
-
-	// the current selection
-	LCursor const & cur = bv_.cursor();
-	int const starty = text_.cursorY(cur.selBegin());
-	int const endy = text_.cursorY(cur.selEnd());
-	par_type startpit = cur.selBegin().par();
-	par_type endpit = cur.selEnd().par();
-	RowList::iterator startrow = pars_[startpit].getRow(cur.selBegin().pos());
-	RowList::iterator endrow = pars_[endpit].getRow(cur.selEnd().pos());
-	int const h = row_.height();
-
-	int const row_y = text_.yo_ + par_.y + row_.y_offset();
-
-	bool const sel_starts_here = startpit == pit_ && startrow == rit_;
-	bool const sel_ends_here   = endpit == pit_ && endrow == rit_;
-	bool const sel_on_one_row  = sel_starts_here && sel_ends_here;
-
-	if (text_.bidi.same_direction()) {
-		if (sel_on_one_row) {
-			int const startx = text_.cursorX(cur.selBegin());
-			int const endx = text_.cursorX(cur.selEnd());
-			int const x1 = is_rtl ? endx : startx;
-			int const x2 = is_rtl ? startx : endx;
-			pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
-		} else if (sel_starts_here) {
-			int const startx = text_.cursorX(cur.selBegin());
-			int const x1 = is_rtl ? int(xo_) : startx;
-			int const x2 = is_rtl ? startx : int(xo_) + width_;
-			pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
-		} else if (sel_ends_here) {
-			int const endx = text_.cursorX(cur.selEnd());
-			int const x1 = is_rtl ? endx : int(xo_);
-			int const x2 = is_rtl ? int(xo_) + width_ : endx;
-			pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
-		} else if (row_y > starty && row_y < endy) {
-			pain_.fillRectangle(int(xo_), yo_, width_, h, LColor::selection);
-		}
-		return;
-	}
-
-	if ((startpit != pit_ && startrow != rit_ && !is_rtl)
-		|| (endpit != pit_ && endrow != rit_ && is_rtl))
-		pain_.fillRectangle(int(xo_), yo_,
-			int(x_), h, LColor::selection);
-
-	pos_type const body_pos = par_.beginOfBody();
-	pos_type const end = row_.endpos();
-	double tmpx = x_;
-
-	for (pos_type vpos = row_.pos(); vpos < end; ++vpos)  {
-		pos_type pos = text_.bidi.vis2log(vpos);
-		double const old_tmpx = tmpx;
-		if (body_pos > 0 && pos == body_pos - 1) {
-			LyXLayout_ptr const & layout = par_.layout();
-			LyXFont const lfont = getLabelFont();
-
-			tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
-
-			if (par_.isLineSeparator(body_pos - 1))
-				tmpx -= singleWidth(body_pos - 1);
-		}
-
-		tmpx += singleWidth(pos);
-
-		if (hfillExpansion(par_, row_, pos)) {
-			if (pos >= body_pos)
-				tmpx += hfill_;
-			else
-				tmpx += label_hfill_;
-		} else {
-			if (par_.isSeparator(pos) && pos >= body_pos)
-				tmpx += separator_;
-		}
-
-		if (((startpit != pit_ && startrow != rit_)
-				|| cur.selBegin().pos() <= pos) &&
-			((endpit != pit_ && endrow != rit_)
-				|| pos < cur.selEnd().pos())) {
-			// Here we do not use x_ as xo_ was added to x_.
-			pain_.fillRectangle(int(old_tmpx), yo_,
-				int(tmpx - old_tmpx + 1), h, LColor::selection);
-		}
-	}
-
-	if ((startpit != pit_ && startrow != rit_ && is_rtl) ||
-	    (endpit != pit_ && endrow != rit_ && !is_rtl)) {
-		pain_.fillRectangle(int(xo_ + tmpx),
-			yo_, int(width_ - tmpx), h, LColor::selection);
-	}
-}
-
-
 void RowPainter::paintChangeBar()
 {
 	pos_type const start = row_.pos();
@@ -853,53 +753,106 @@ void RowPainter::paintText()
 }
 
 
-int paintPars(BufferView const & bv, Painter & pain,
-	      LyXText const & text, par_type pit, par_type end)
+int paintPar(BufferView const & bv, Painter & pain,
+	LyXText const & text, par_type pit, int y)
 {
-	//lyxerr << "  paintRows: pit: " << &*pit << endl;
+	lyxerr << "  paintPar: pit: " << pit << " at y: " << y << endl;
 	ParagraphList & pars = text.paragraphs();
 
-	int y = pars[pit].y + text.yo_ - bv.top_y();
-
-	for (; pit != end; ++pit) {
-		RowList::iterator row = pars[pit].rows.begin();
-		RowList::iterator rend = pars[pit].rows.end();
-
-		// We draw full paragraphs to get the (xo, yo) cache of all
-		// contained insets right. This is needed for properly working
-		// editXY. And maybe not even sufficient.
-		// FIXME: Alfredo, please have a look at the coordinate business
-		// again.
-		for ( ; row != rend; ++row) {
-			RowPainter(bv, pain, text, pit, row, y);
-			y += row->height();
-		}
+	RowList::iterator row = pars[pit].rows().begin();
+	RowList::iterator rend = pars[pit].rows().end();
 
+	for ( ; row != rend; ++row) {
+		RowPainter(bv, pain, text, pit, row, y);
+		y += row->height();
 	}
+
 	return y;
 }
 
 } // namespace anon
 
 
-void refreshPar(BufferView const & bv, LyXText const & text, par_type pit)
+//void refreshPar(BufferView const & bv, LyXText const & text, par_type pit)
+void refreshPar(BufferView const &, LyXText const &, par_type)
 {
+	// removing this leads to linker errors ?!
 	static NullPainter nop;
-	paintPars(bv, nop, text, pit, pit + 1);
+	//paintPar(bv, nop, text, pit);
 }
 
 
-int paintText(BufferView const & bv)
+void paintText(BufferView const & bv)
 {
-	par_type pit, end;
-	getParsInRange(bv.text()->paragraphs(), bv.top_y(),
-		       bv.top_y() + bv.workHeight(), pit, end);
-	//lyxerr << "top_y: " << bv.top_y() << " y: " << pit->y << endl;
-	return paintPars(bv, bv.painter(), *bv.text(), pit, end);
+	LyXText * const text = bv.text();
+	LCursor const & cur = bv.cursor();
+	CursorSlice const & sl = cur.bottom();
+	par_type const pit = sl.par();
+
+	int pit1 = pit;
+	int pit2 = pit;
+
+	//
+	// rebreak cursor par	
+	//
+	text->redoParagraph(pit);
+
+	Paragraph const & par = sl.paragraph();
+	int const row = par.row(sl.pos());
+	
+	// find y begin of paragraph containing cursor
+	int xo, yo;
+	cur.getPos(xo, yo);
+	int const y = yo - par.rows()[row].y_offset() - par.rows()[row].baseline();
+
+	//
+	// draw paragraphs above cursor if necessary
+	//
+	int y1 = y;
+	while (y1 >= 0 && pit1 > 0) {
+		--pit1;
+		text->redoParagraph(pit1);
+		y1 -= text->getPar(pit1).height();
+	}
+
+	//
+	// draw paragraphs below cursor if necessary
+	//
+	int y2 = y + par.height();
+	while (y2 < bv.workHeight() && pit2 < int(text->paragraphs().size()) - 1) {
+		++pit2;
+		text->redoParagraph(pit2);
+		y2 += text->getPar(pit2).height();
+	}
+
+	// draw selection
+	PainterInfo pi(const_cast<BufferView *>(&bv), bv.painter());
+	text->drawSelection(pi, 0, 0);
+
+	// draw content
+	int yy = y1;
+	for (par_type pit = pit1; pit <= pit2; ++pit) {
+		paintPar(bv, bv.painter(), *bv.text(), pit, yy);
+		yy += text->getPar(pit).height();
+	}
+
+	// and grey out (should not happen later)
+	if (y1 > 0)
+		bv.painter().fillRectangle(0, 0, bv.workWidth(), y1, LColor::bottomarea);
+
+	// and possibly grey out
+	if (y2 < bv.workHeight())
+		bv.painter().fillRectangle(0, y2, bv.workWidth(), bv.workHeight(),
+			LColor::bottomarea);
+
 }
 
 
-void paintTextInset(LyXText const & text, PainterInfo & pi)
+void paintTextInset(LyXText const & text, PainterInfo & pi, int y)
 {
-	paintPars(*pi.base.bv, pi.pain, text, 0, text.paragraphs().size());
+	for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
+		const_cast<LyXText&>(text).redoParagraph(pit);
+		paintPar(*pi.base.bv, pi.pain, text, pit, y);
+		y += text.getPar(pit).height();
+	}
 }
Index: rowpainter.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.h,v
retrieving revision 1.20
diff -u -p -r1.20 rowpainter.h
--- rowpainter.h	14 Aug 2004 15:55:17 -0000	1.20
+++ rowpainter.h	16 Aug 2004 21:15:28 -0000
@@ -19,15 +19,15 @@ class LyXText;
 class BufferView;
 class PainterInfo;
 
-/// paint the rows of the main text, return last drawn y value
-int paintText(BufferView const & bv);
+/// paint visible paragraph of main text
+void paintText(BufferView const & bv);
 
 /// refresh a par of the main text
 void refreshPar(BufferView const & bv, LyXText const & text,
 		lyx::par_type pit);
 
 /// paint the rows of a text inset
-void paintTextInset(LyXText const & text, PainterInfo & pi);
+void paintTextInset(LyXText const & text, PainterInfo & pi, int y);
 
 /// some space for drawing the 'nested' markers (in pixel)
 inline int nestMargin()
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.580
diff -u -p -r1.580 text.C
--- text.C	16 Aug 2004 00:49:11 -0000	1.580
+++ text.C	16 Aug 2004 21:15:28 -0000
@@ -50,6 +50,7 @@
 
 #include "frontends/font_metrics.h"
 #include "frontends/LyXView.h"
+#include "frontends/Painter.h"
 
 #include "insets/insettext.h"
 #include "insets/insetbibitem.h"
@@ -105,17 +106,6 @@ int numberOfSeparators(Paragraph const &
 }
 
 
-unsigned int maxParagraphWidth(ParagraphList const & plist)
-{
-	unsigned int width = 0;
-	ParagraphList::const_iterator pit = plist.begin();
-	ParagraphList::const_iterator end = plist.end();
-		for (; pit != end; ++pit)
-			width = std::max(width, pit->width);
-	return width;
-}
-
-
 int numberOfLabelHfills(Paragraph const & par, Row const & row)
 {
 	pos_type last = row.endpos() - 1;
@@ -407,26 +397,15 @@ double LyXText::spacing(Paragraph const 
 }
 
 
-void LyXText::updateParPositions()
-{
-	par_type pit = 0;
-	par_type end = pars_.size();
-	for (height_ = 0; pit != end; ++pit) {
-		pars_[pit].y = height_;
-		height_ += pars_[pit].height;
-	}
-}
-
-
 int LyXText::width() const
 {
-	return width_;
+	return dim_.wid;
 }
 
 
 int LyXText::height() const
 {
-	return height_;
+	return dim_.height();
 }
 
 
@@ -449,8 +428,7 @@ int LyXText::singleWidth(Paragraph const
 			    && font.language()->lang() == "arabic") {
 				if (Encodings::IsComposeChar_arabic(c))
 					return 0;
-				else
-					c = par.transformChar(c, pos);
+				c = par.transformChar(c, pos);
 			} else if (font.language()->lang() == "hebrew" &&
 				   Encodings::IsComposeChar_hebrew(c))
 				return 0;
@@ -570,8 +548,8 @@ int LyXText::leftMargin(par_type const p
 #if 0
 		// ok, a terrible hack. The left margin depends on the widest
 		// row in this paragraph.
-		RowList::iterator rit = par.rows.begin();
-		RowList::iterator end = par.rows.end();
+		RowList::iterator rit = par.rows().begin();
+		RowList::iterator end = par.rows().end();
 #ifdef WITH_WARNINGS
 #warning This is wrong.
 #endif
@@ -1094,8 +1072,8 @@ void LyXText::breakParagraph(LCursor & c
 		pars_[next_par].erase(0);
 
 	updateCounters();
-	redoParagraph(cpit);
-	redoParagraph(next_par);
+//	redoParagraph(cpit);
+//	redoParagraph(next_par);
 
 	// This check is necessary. Otherwise the new empty paragraph will
 	// be deleted automatically. And it is more friendly for the user!
@@ -1106,16 +1084,6 @@ void LyXText::breakParagraph(LCursor & c
 }
 
 
-// convenience function
-void LyXText::redoParagraph(LCursor & cur)
-{
-	BOOST_ASSERT(this == cur.text());
-	cur.clearSelection();
-	redoParagraph(cur.par());
-	setCursorIntern(cur, cur.par(), cur.pos());
-}
-
-
 // insert a character, moves all the following breaks in the
 // same Paragraph one to the right and make a rebreak
 void LyXText::insertChar(LCursor & cur, char c)
@@ -1212,7 +1180,6 @@ void LyXText::insertChar(LCursor & cur, 
 
 	current_font = rawtmpfont;
 	real_current_font = realtmpfont;
-	redoParagraph(cur);
 	setCursor(cur, cur.par(), cur.pos() + 1, false, cur.boundary());
 	charInserted();
 }
@@ -1237,7 +1204,7 @@ RowMetrics LyXText::computeRowMetrics(pa
 	RowMetrics result;
 	Paragraph const & par = pars_[pit];
 
-	double w = width_ - row.width();
+	double w = dim_.wid - row.width();
 
 	bool const is_rtl = isRTL(par);
 	if (is_rtl)
@@ -1598,8 +1565,6 @@ void LyXText::backspace(LCursor & cur)
 
 			if (cur.par() != 0) {
 				cursorLeft(cur);
-				// the layout things can change the height of a row !
-				redoParagraph(cur);
 				return;
 			}
 		}
@@ -1657,7 +1622,6 @@ void LyXText::backspace(LCursor & cur)
 	if (cur.pos() == cur.lastpos())
 		setCurrentFont(cur);
 
-	redoParagraph(cur);
 	setCursor(cur, cur.par(), cur.pos(), false, cur.boundary());
 }
 
@@ -1673,20 +1637,19 @@ Paragraph & LyXText::getPar(par_type par
 
 Row const & LyXText::firstRow() const
 {
-	return *paragraphs().front().rows.begin();
+	return *paragraphs().front().rows().begin();
 }
 
 
-void LyXText::redoParagraphInternal(par_type const pit)
+void LyXText::redoParagraph(par_type const pit)
 {
 	// remove rows of paragraph, keep track of height changes
 	Paragraph & par = pars_[pit];
-	height_ -= par.height;
 
 	// clear old data
-	par.rows.clear();
-	par.height = 0;
-	par.width = 0;
+	par.rows().clear();
+	par.height_ = 0;
+	par.width_ = 0;
 
 	// redo insets
 	InsetList::iterator ii = par.insetlist.begin();
@@ -1706,38 +1669,13 @@ void LyXText::redoParagraphInternal(par_
 		rowBreakPoint(pit, row);
 		setRowWidth(pit, row);
 		setHeightOfRow(pit, row);
-		row.y_offset(par.height);
-		par.rows.push_back(row);
-		par.width = std::max(par.width, row.width());
-		par.height += row.height();
+		row.y_offset(par.height_);
+		par.rows().push_back(row);
+		par.width_ = std::max(par.width(), row.width());
+		par.height_ += row.height();
 		z = row.endpos();
 	} while (z < par.size());
-
-	height_ += par.height;
-	//lyxerr << "redoParagraph: " << par.rows.size() << " rows\n";
-}
-
-
-void LyXText::redoParagraphs(par_type pit, par_type end)
-{
-	for (; pit != end; ++pit)
-		redoParagraphInternal(pit);
-	updateParPositions();
-	updateCounters();
-}
-
-
-void LyXText::redoParagraph(par_type pit)
-{
-	redoParagraphInternal(pit);
-	updateParPositions();
-}
-
-
-void LyXText::fullRebreak()
-{
-	redoParagraphs(0, paragraphs().size());
-	bv()->cursor().resetAnchor();
+	//lyxerr << "redoParagraph: " << par.rows().size() << " rows\n";
 }
 
 
@@ -1747,18 +1685,23 @@ void LyXText::metrics(MetricsInfo & mi, 
 	if (mi.base.textwidth)
 		maxwidth_ = mi.base.textwidth;
 	//lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
-	//<< " maxWidth: " << maxwidth << "\nfont: " << mi.base.font
-	//<< endl;
+	//	<< " maxWidth: " << maxwidth_ << "\nfont: " << mi.base.font << endl;
 
-	// Rebuild row cache. This recomputes height as well.
-	redoParagraphs(0, paragraphs().size());
-
-	width_ = maxParagraphWidth(paragraphs());
+	unsigned int h = 0;
+	unsigned int w = 0;
+	for (int pit = 0, n = paragraphs().size(); pit != n; ++pit) {
+		redoParagraph(pit);
+		Paragraph & par = paragraphs()[pit];
+		h += par.height();
+		if (w < par.width())
+			w = par.width();
+	}
 
-	// final dimension
+	dim.wid = w;
 	dim.asc = firstRow().ascent_of_text();
-	dim.des = height_ - dim.asc;
-	dim.wid = width_;
+	dim.des = h - dim.asc;
+
+	dim_ = dim;
 }
 
 
@@ -1767,14 +1710,72 @@ void LyXText::draw(PainterInfo & pi, int
 {
 	xo_ = x;
 	yo_ = y;
-	paintTextInset(*this, pi);
+	paintTextInset(*this, pi, y);
 }
 
 
 // only used for inset right now. should also be used for main text
-void LyXText::drawSelection(PainterInfo &, int, int) const
+void LyXText::drawSelection(PainterInfo & pi, int x, int y) const
 {
-	//lyxerr << "LyXText::drawSelection at " << x << " " << y << endl;
+	// FIXME: hack to get position cache warm
+	//draw(pi, x, y);
+	xo_ = x;
+	yo_ = y;
+
+	// this should use the x/y values given, not the cached values
+	LCursor & cur = pi.base.bv->cursor();
+	if (!cur.selection())
+		return;
+	if (!ptr_cmp(cur.text(), this))
+		return;
+
+	lyxerr << "draw selection at " << x << ' ' << y << endl;
+
+	CursorSlice s1 = cur.selBegin();
+	CursorSlice s2 = cur.selEnd();
+
+	int yy = yo_;
+	par_type pit = 0;
+	for (; pit != s1.par(); ++pit)
+		yy += pars_[pit].height();
+
+	int y1 = yy;
+	Paragraph const & par1 = pars_[pit];
+	int rit1 = 0;
+	for (int const n = par1.row(s1.pos()); rit1 != n; ++rit1)
+		y1 += par1.rows()[rit1].height();
+	Row row1 = par1.rows()[rit1];
+	y1 -= row1.ascent_of_text();
+
+	for (; pit != s2.par(); ++pit)
+		yy += pars_[pit].height();
+
+	int y2 = yy;
+	Paragraph const & par2 = pars_[pit];
+	int rit2 = 0;
+	for (int const n = par2.row(s2.pos()); rit2 != n; ++rit2)
+		y2 += par2.rows()[rit2].height();
+	Row row2 = par2.rows()[rit2];
+	y2 += row2.height() - row2.ascent_of_text();
+
+	lyxerr << "y1: " << y1 << " y2: " << y2 << " rit1: " << rit1 
+		<< " rit2: " << rit2 << endl;
+
+	// paint big rectangle in one go
+	pi.pain.fillRectangle(int(xo_), y1, dim_.wid, y2 - y1, LColor::selection);
+
+	// reset background at begin of first selected line
+	int const startx = cursorX(s1);
+	int const x1 = isRTL(par1) ? startx : int(xo_);
+	int const x2 = isRTL(par1) ? int(xo_) + dim_.wid : startx;
+	pi.pain.fillRectangle(x1, y1, x2 - x1, row1.height(), LColor::background);
+
+	// reset background at end of last selected line
+	int const endx = cursorX(s2);
+	int const X1 = isRTL(par2) ? int(xo_) : endx;
+	int const X2 = isRTL(par2) ? endx : int(xo_) + dim_.wid;
+	pi.pain.fillRectangle(X1, y2  - row2.height(), X2 - X1, y2 - row2.height(),
+		 LColor::background);
 }
 
 
@@ -1903,13 +1904,13 @@ bool LyXText::read(Buffer const & buf, L
 
 int LyXText::ascent() const
 {
-	return firstRow().ascent_of_text();
+	return dim_.asc;
 }
 
 
 int LyXText::descent() const
 {
-	return height_ - firstRow().ascent_of_text();
+	return dim_.des;
 }
 
 
@@ -1917,7 +1918,7 @@ int LyXText::cursorX(CursorSlice const &
 {
 	par_type const pit = cur.par();
 	Paragraph const & par = pars_[pit];
-	if (par.rows.empty())
+	if (par.rows().empty())
 		return xo_;
 
 	Row const & row = *par.getRow(cur.pos());
@@ -1980,7 +1981,10 @@ int LyXText::cursorY(CursorSlice const &
 {
 	Paragraph const & par = getPar(cur.par());
 	Row const & row = *par.getRow(cur.pos());
-	return yo_ + par.y + row.y_offset() + row.baseline();
+	int h = yo_ + row.y_offset() + row.baseline();
+	for (par_type pit = 0; pit < cur.par(); ++pit)
+		h += pars_[pit].height();
+	return h;
 }
 
 
@@ -2105,8 +2109,8 @@ int LyXText::dist(int x, int y) const
 
 	if (x < xo_)
 		xx = xo_ - x;
-	else if (x > xo_ + int(width_))
-		xx = x - xo_ - width_;
+	else if (x > xo_ + width())
+		xx = x - xo_ - width();
 
 	if (y < yo_ - ascent())
 		yy = yo_ - ascent() - y;
@@ -2114,8 +2118,66 @@ int LyXText::dist(int x, int y) const
 		yy = y - yo_ - descent();
 
 	lyxerr << " xo_=" << xo_ << "  yo_=" << yo_ 
-	       << " width_=" << width_ << " ascent=" << ascent()
+	       << " width_=" << width() << " ascent=" << ascent()
 	       << " descent=" << descent() 
-	       << " dist=" << xx+yy <<endl;
+	       << " dist=" << xx + yy <<endl;
 	return xx + yy;
+}
+
+
+pos_type LyXText::x2pos(par_type pit, int row, int x) const
+{
+	int lastx = 0;
+	int currx = 0;
+	Paragraph const & par = pars_[pit];
+	Row const & r = par.rows()[row];
+	int pos = r.pos();
+	for (; currx < x && pos < r.endpos(); ++pos) {
+		lastx = currx;
+		currx += singleWidth(par, pos);
+	}
+	if (abs(lastx - x) < abs(currx - x) && pos != r.pos())
+		--pos;
+	return pos;
+}
+
+//int LyXText::pos2x(par_type pit, pos_type pos) const
+//{
+//	Paragraph const & par = pars_[pit];
+//	Row const & r = par.rows()[row];
+//	int x = 0;
+//	pos -= r.pos();	
+//}
+
+
+// x,y are absolute coordinates
+// sets cursor only within this LyXText
+void LyXText::setCursorFromCoordinates(LCursor & cur, int x, int y)
+{
+	int yy = yo_;
+	par_type pit = 0;
+	par_type n = pars_.size();
+	for (; pit != n; ++pit) {
+		Paragraph const & par = pars_[pit];
+		if (yy + par.height() > y)
+			break;
+		yy += par.height();
+	}
+
+	Paragraph const & par = pars_[pit];
+	int r = 0;
+	for (; r < par.rows().size(); ++r) {
+		Row const & row = par.rows()[r];
+		if (yy + row.height() > y)
+			break;
+		yy += row.height();
+	}
+
+	Row const & row = par.rows()[r];
+ 
+	lyxerr << "setCursorFromCoordinates:: hit row at: " << row.pos() << endl;
+	bool bound = false;
+	int xx = x + xo_; // getRowNearX get absolute x coords
+	pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
+	setCursor(cur, pit, pos, true, bound);
 }
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.585
diff -u -p -r1.585 text2.C
--- text2.C	16 Aug 2004 00:32:00 -0000	1.585
+++ text2.C	16 Aug 2004 21:15:28 -0000
@@ -72,7 +72,7 @@ using std::string;
 
 
 LyXText::LyXText(BufferView * bv)
-	: width_(0), maxwidth_(bv ? bv->workWidth() : 100), height_(0),
+	: maxwidth_(bv ? bv->workWidth() : 100),
 	  background_color_(LColor::background),
 	  bv_owner(bv), xo_(0), yo_(0)
 {}
@@ -83,15 +83,15 @@ void LyXText::init(BufferView * bv)
 	BOOST_ASSERT(bv);
 	bv_owner = bv;
 	maxwidth_ = bv->workWidth();
-	width_ = maxwidth_;
-	height_ = 0;
+	dim_.wid = maxwidth_;
+	dim_.asc = 10;
+	dim_.des = 10;
 
 	par_type const end = paragraphs().size();
 	for (par_type pit = 0; pit != end; ++pit)
-		pars_[pit].rows.clear();
+		pars_[pit].rows().clear();
 
 	current_font = getFont(pars_[0], 0);
-	redoParagraphs(0, end);
 	updateCounters();
 }
 
@@ -102,43 +102,42 @@ bool LyXText::isMainText() const
 }
 
 
-// takes absolute x,y coordinates
+// takes screen x,y coordinates
 InsetBase * LyXText::checkInsetHit(int x, int y) const 
 {
-	par_type pit;
-	par_type end;
-
-	getParsInRange(paragraphs(),
-		       bv()->top_y() - yo_,
-		       bv()->top_y() - yo_ + bv()->workHeight(),
-		       pit, end);
-
-	// convert to screen-absolute y coordinate
-	y -= bv()->top_y();
-	lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
-	lyxerr << "  pit: " << pit << " end: " << end << endl;
-	for (; pit != end; ++pit) {
-		InsetList::const_iterator iit = pars_[pit].insetlist.begin();
-		InsetList::const_iterator iend = pars_[pit].insetlist.end();
-		for (; iit != iend; ++iit) {
-			InsetBase * inset = iit->inset;
-#if 1
-			lyxerr << "examining inset " << inset << endl;
-			if (theCoords.insets_.has(inset))
-				lyxerr
-					<< " xo: " << inset->xo() << "..." << inset->xo() + inset->width()
-					<< " yo: " << inset->yo() - inset->ascent() << "..."
-					<< inset->yo() + inset->descent() << endl;
-			else
-				lyxerr << " inset has no cached position";
-#endif
-			if (inset->covers(x, y)) {
-				lyxerr << "Hit inset: " << inset << endl;
-				return inset;
-			}
-		}
-	}
-	lyxerr << "No inset hit. " << endl;
+//	par_type pit;
+//	par_type end;
+//
+//	getParsInRange(paragraphs(),
+//		       - yo_,
+//		       - yo_ + bv()->workHeight(),
+//		       pit, end);
+//
+//	// convert to screen-absolute y coordinate
+//	lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
+//	lyxerr << "  pit: " << pit << " end: " << end << endl;
+//	for (; pit != end; ++pit) {
+//		InsetList::const_iterator iit = pars_[pit].insetlist.begin();
+//		InsetList::const_iterator iend = pars_[pit].insetlist.end();
+//		for (; iit != iend; ++iit) {
+//			InsetBase * inset = iit->inset;
+//#if 1
+//			lyxerr << "examining inset " << inset << endl;
+//			if (theCoords.insets_.has(inset))
+//				lyxerr
+//					<< " xo: " << inset->xo() << "..." << inset->xo() + inset->width()
+//					<< " yo: " << inset->yo() - inset->ascent() << "..."
+//					<< inset->yo() + inset->descent() << endl;
+//			else
+//				lyxerr << " inset has no cached position";
+//#endif
+//			if (inset->covers(x, y)) {
+//				lyxerr << "Hit inset: " << inset << endl;
+//				return inset;
+//			}
+//		}
+//	}
+//	lyxerr << "No inset hit. " << endl;
 	return 0;
 }
 
@@ -335,14 +334,7 @@ void LyXText::setLayout(LCursor & cur, s
 		insertInset(cur, inset);
 		//inset->edit(cur, true);
 		//bv.owner()->dispatch(FuncRequest(LFUN_PASTE));
-		return;
 	}
-
-	par_type start = cur.selBegin().par();
-	par_type end = cur.selEnd().par() + 1;
-	par_type endpit = setLayout(start, end, layout);
-	redoParagraphs(start, endpit);
-	updateCounters();
 }
 
 
@@ -454,9 +446,6 @@ void LyXText::setFont(LCursor & cur, LyX
 	// Ok, we have a selection.
 	recordUndoSelection(cur);
 
-	par_type const beg = cur.selBegin().par();
-	par_type const end = cur.selEnd().par();
-
 	DocIterator dit = cur.selectionBegin();
 	DocIterator ditend = cur.selectionEnd();
 
@@ -471,8 +460,6 @@ void LyXText::setFont(LCursor & cur, LyX
 			setCharFont(dit.par(), dit.pos(), f);
 		}
 	}
-
-	redoParagraphs(beg, end + 1);
 }
 
 
@@ -602,8 +589,6 @@ void LyXText::setParagraph(LCursor & cur
 		par.setLabelWidthString(labelwidthstring);
 		params.noindent(noindent);
 	}
-
-	redoParagraphs(cur.selBegin().par(), undopit);
 }
 
 
@@ -895,12 +880,9 @@ void LyXText::updateCounters()
 		if (oldLabel != newLabel) {
 			//lyxerr[Debug::DEBUG] << "changing labels: old: " << oldLabel << " new: "
 			//	<< newLabel << endl;
-			redoParagraphInternal(pit);
 			update_pos = true;
 		}
 	}
-	if (update_pos)
-		updateParPositions();
 }
 
 
@@ -910,7 +892,6 @@ void LyXText::insertInset(LCursor & cur,
 	BOOST_ASSERT(this == cur.text());
 	BOOST_ASSERT(inset);
 	cur.paragraph().insertInset(cur.pos(), inset);
-	redoParagraph(cur);
 }
 
 
@@ -918,7 +899,6 @@ void LyXText::insertInset(LCursor & cur,
 void LyXText::insertStringAsLines(LCursor & cur, string const & str)
 {
 	par_type pit = cur.par();
-	par_type endpit = cur.par() + 1;
 	pos_type pos = cur.pos();
 	recordUndo(cur);
 
@@ -926,7 +906,6 @@ void LyXText::insertStringAsLines(LCurso
 	cur.clearSelection();
 	cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str);
 
-	redoParagraphs(cur.par(), endpit);
 	cur.resetAnchor();
 	setCursor(cur, cur.par(), pos);
 	cur.setSelection();
@@ -973,19 +952,12 @@ void LyXText::setCursor(CursorSlice & cu
 	pos_type pos, bool boundary)
 {
 	BOOST_ASSERT(par != int(paragraphs().size()));
-
 	cur.par() = par;
 	cur.pos() = pos;
 	cur.boundary() = boundary;
 
-	// no rows, no fun...
-	if (paragraphs().begin()->rows.empty())
-		return;
-
 	// now some strict checking
 	Paragraph & para = getPar(par);
-	Row const & row = *para.getRow(pos);
-	pos_type const end = row.endpos();
 
 	// None of these should happen, but we're scaredy-cats
 	if (pos < 0) {
@@ -996,24 +968,6 @@ void LyXText::setCursor(CursorSlice & cu
 	if (pos > para.size()) {
 		lyxerr << "dont like 1, pos: " << pos
 		       << " size: " << para.size()
-		       << " row.pos():" << row.pos()
-		       << " par: " << par << endl;
-		BOOST_ASSERT(false);
-	}
-
-	if (pos > end) {
-		lyxerr << "dont like 2, pos: " << pos
-		       << " size: " << para.size()
-		       << " row.pos():" << row.pos()
-		       << " par: " << par << endl;
-		// This shouldn't happen.
-		BOOST_ASSERT(false);
-	}
-
-	if (pos < row.pos()) {
-		lyxerr << "dont like 3 please report pos:" << pos
-		       << " size: " << para.size()
-		       << " row.pos():" << row.pos()
 		       << " par: " << par << endl;
 		BOOST_ASSERT(false);
 	}
@@ -1176,40 +1130,23 @@ pos_type LyXText::getColumnNearX(par_typ
 // this is only used in the two functions below
 Row const & LyXText::getRowNearY(int y, par_type & pit) const
 {
-	BOOST_ASSERT(!paragraphs().empty());
-	BOOST_ASSERT(!paragraphs().begin()->rows.empty());
-	par_type const pend = paragraphs().size() - 1;
-	pit = 0;
-	while (int(pars_[pit].y + pars_[pit].height) < y && pit != pend)
-		++pit;
-
-	RowList::iterator rit = pars_[pit].rows.end();
-	RowList::iterator const rbegin = pars_[pit].rows.begin();
-	do {
-		--rit;
-	} while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y);
-
-	return *rit;
+//	BOOST_ASSERT(!paragraphs().empty());
+//	BOOST_ASSERT(!paragraphs().begin()->rows().empty());
+//	par_type const pend = paragraphs().size() - 1;
+//	pit = 0;
+//	while (int(pars_[pit].y + pars_[pit].height) < y && pit != pend)
+//		++pit;
+//
+//	RowList::iterator rit = pars_[pit].rows().end();
+//	RowList::iterator const rbegin = pars_[pit].rows().begin();
+//	do {
+//		--rit;
+//	} while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y);
+//
+//	return *rit;
+	return paragraphs()[0].rows().front();
 }
 
-
-// x,y are absolute coordinates
-// sets cursor only within this LyXText
-void LyXText::setCursorFromCoordinates(LCursor & cur, int x, int y)
-{
-	x -= xo_;
-	y -= yo_;
-	par_type pit;
-	Row const & row = getRowNearY(y, pit);
-	lyxerr[Debug::DEBUG] << "setCursorFromCoordinates:: hit row at: "
-			     << row.pos() << endl;
-	bool bound = false;
-	int xx = x + xo_; // getRowNearX get absolute x coords
-	pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
-	setCursor(cur, pit, pos, true, bound);
-}
-
-
 // x,y are absolute screen coordinates
 // sets cursor recursively descending into nested editable insets
 InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const
@@ -1300,31 +1237,48 @@ void LyXText::cursorRight(LCursor & cur)
 
 void LyXText::cursorUp(LCursor & cur)
 {
-	Row const & row = cur.textRow();
-	int x = cur.x_target();
-	int y = cursorY(cur.top()) - row.baseline() - 1;
-	setCursorFromCoordinates(cur, x, y);
+	Paragraph const & par = cur.paragraph();
+	int const row = par.row(cur.pos());
 
-	if (!cur.selection()) {
-		InsetBase * inset_hit = checkInsetHit(cur.x_target(), y);
-		if (inset_hit && isHighlyEditableInset(inset_hit))
-			inset_hit->editXY(cur, cur.x_target(), y);
-	}
+	if (row > 0) {
+		cur.pos() = x2pos(cur.par(), row - 1, cur.x_target());
+	} else if (cur.par() > 0) {
+		--cur.par();
+		cur.idx() = 0;
+		cur.pos() = 0;
+		redoParagraph(cur.par());
+		cur.pos() = x2pos(cur.par(), cur.paragraph().rows().size() - 1, cur.x_target());
+	}
+
+//
+//	if (!cur.selection()) {
+//		InsetBase * inset_hit = checkInsetHit(cur.x_target(), y);
+//		if (inset_hit && isHighlyEditableInset(inset_hit))
+//			inset_hit->editXY(cur, cur.x_target(), y);
+//	}
 }
 
 
 void LyXText::cursorDown(LCursor & cur)
 {
-	Row const & row = cur.textRow();
-	int x = cur.x_target();
-	int y = cursorY(cur.top()) - row.baseline() + row.height() + 1;
-	setCursorFromCoordinates(cur, x, y);
+	Paragraph const & par = cur.paragraph();
+	int const row = par.row(cur.pos());
 
-	if (!cur.selection()) {
-		InsetBase * inset_hit = checkInsetHit(cur.x_target(), y);
-		if (inset_hit && isHighlyEditableInset(inset_hit))
-			inset_hit->editXY(cur, cur.x_target(), y);
-	}
+	if (row + 1 < int(par.rows().size())) {
+		cur.pos() = x2pos(cur.par(), row + 1, cur.x_target());
+	} else if (cur.par() + 1 < int(paragraphs().size())) {
+		++cur.par();
+		cur.idx() = 0;
+		cur.pos() = 0;
+		redoParagraph(cur.par());
+		cur.pos() = x2pos(cur.par(), 0, cur.x_target());
+	}
+
+//	if (!cur.selection()) {
+//		InsetBase * inset_hit = checkInsetHit(cur.x_target(), y);
+//		if (inset_hit && isHighlyEditableInset(inset_hit))
+//			inset_hit->editXY(cur, cur.x_target(), y);
+//	}
 }
 
 
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.267
diff -u -p -r1.267 text3.C
--- text3.C	14 Aug 2004 21:56:40 -0000	1.267
+++ text3.C	16 Aug 2004 21:15:28 -0000
@@ -261,7 +261,8 @@ void LyXText::cursorPrevious(LCursor & c
 	lyx::par_type cpar = cur.par();
 
 	int x = cur.x_target();
-	int y = cur.bv().top_y();
+	int y = cur.yo_ - cur.bv().workHeight() / 2 + 20;
+
 	setCursorFromCoordinates(cur, x, y);
 
 	if (cpar == cur.par() && cpos == cur.pos()) {
@@ -281,8 +282,7 @@ void LyXText::cursorNext(LCursor & cur)
 	lyx::par_type cpar = cur.par();
 
 	int x = cur.x_target();
-	int y = cur.bv().top_y() + cur.bv().workHeight();
-	setCursorFromCoordinates(cur, x, y);
+	int y = cur.yo_ + cur.bv().workHeight() / 2 - 20;
 
 	if (cpar == cur.par() && cpos == cur.pos()) {
 		// we have a row which is taller than the workarea. The
@@ -351,7 +351,7 @@ void LyXText::dispatch(LCursor & cur, Fu
 	BOOST_ASSERT(cur.text() == this);
 	BufferView * bv = &cur.bv();
 	CursorSlice sl = cur.top();
-	bool sel = cur.selection();
+//	bool sel = cur.selection();
 	bool moving = false;
 
 	switch (cmd.action) {
@@ -365,7 +365,6 @@ void LyXText::dispatch(LCursor & cur, Fu
 			if (pars_[tmp].params().startOfAppendix()) {
 				recUndo(tmp);
 				pars_[tmp].params().startOfAppendix(false);
-				redoParagraph(tmp);
 				break;
 			}
 		}
@@ -375,7 +374,6 @@ void LyXText::dispatch(LCursor & cur, Fu
 
 		// we can set the refreshing parameters now
 		updateCounters();
-		redoParagraph(cur);
 		break;
 	}
 
@@ -746,10 +744,8 @@ void LyXText::dispatch(LCursor & cur, Fu
 			lyxerr << _("Unknown spacing argument: ")
 			       << cmd.argument << endl;
 		}
-		if (cur_spacing != new_spacing || cur_value != new_value) {
+		if (cur_spacing != new_spacing || cur_value != new_value) 
 			par.params().spacing(Spacing(new_spacing, new_value));
-			redoParagraph(cur);
-		}
 		break;
 	}
 
@@ -839,7 +835,6 @@ void LyXText::dispatch(LCursor & cur, Fu
 
 	case LFUN_TRANSPOSE_CHARS:
 		recordUndo(cur);
-		redoParagraph(cur);
 		break;
 
 	case LFUN_PASTE:
@@ -1136,9 +1131,9 @@ void LyXText::dispatch(LCursor & cur, Fu
 			// This is to allow jumping over large insets
 			// FIXME: shouldn't be top-text-specific
 			if (isMainText() && cur.top() == old) {
-				if (cmd.y - bv->top_y() >= bv->workHeight())
+				if (cmd.y >= bv->workHeight())
 					cursorDown(cur);
-				else if (cmd.y - bv->top_y() < 0)
+				else if (cmd.y < 0)
 					cursorUp(cur);
 			}
 
@@ -1562,12 +1557,12 @@ void LyXText::dispatch(LCursor & cur, Fu
 	}
 
 	// avoid to update when navigating
-	if (moving
-	    && &sl.inset() == &cur.inset()
-	    && sl.idx() == cur.idx()
-	    && sel == false
-	    && cur.selection() == false)
-		cur.noUpdate();
+//	if (moving
+//	    && &sl.inset() == &cur.inset()
+//	    && sl.idx() == cur.idx()
+//	    && sel == false
+//	    && cur.selection() == false)
+//		cur.noUpdate();
 }
 
 
Index: frontends/Painter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Painter.C,v
retrieving revision 1.16
diff -u -p -r1.16 Painter.C
--- frontends/Painter.C	7 Apr 2004 20:20:13 -0000	1.16
+++ frontends/Painter.C	16 Aug 2004 21:15:28 -0000
@@ -41,20 +41,20 @@ void Painter::buttonFrame(int x, int y, 
 	int x1[4], y1[4];
 
 	x1[0] = x + d;   y1[0] = y + d;
-	x1[1] = x + d;   y1[1] = (y + h - d);
-	x1[2] = x;     y1[2] = y + h;
-	x1[3] = x;     y1[3] = y;
+	x1[1] = x + d;   y1[1] = y + h - d;
+	x1[2] = x;       y1[2] = y + h;
+	x1[3] = x;       y1[3] = y;
 	fillPolygon(x1, y1, 4, LColor::left);
 
-	x1[0] = (x + w - d); y1[0] = y + d;
-	x1[1] = (x + w - d); y1[1] = (y + h - d);
-	x1[2] = x + w; y1[2] = (y + h - d);
-	x1[3] = x + w; y1[3] = y;
+	x1[0] = x + w - d;  y1[0] = y + d;
+	x1[1] = x + w - d;  y1[1] = y + h - d;
+	x1[2] = x + w;      y1[2] = y + h - d;
+	x1[3] = x + w;      y1[3] = y;
 	fillPolygon(x1, y1, 4, LColor::right);
 }
 
 
-void Painter::rectText(int x, int baseline,
+void Painter::rectText(int x, int y,
 	string const & str,
 	LyXFont const & font,
 	LColor_color back,
@@ -66,22 +66,18 @@ void Painter::rectText(int x, int baseli
 
 	font_metrics::rectText(str, font, width, ascent, descent);
 
-	if (back != LColor::none) {
-		fillRectangle(x + 1, baseline - ascent + 1, width - 1,
+	if (back != LColor::none)
+		fillRectangle(x + 1, y - ascent + 1, width - 1,
 			      ascent + descent - 1, back);
-	}
 
-	if (frame != LColor::none) {
-		rectangle(x, baseline - ascent, width, ascent + descent, frame);
-	}
+	if (frame != LColor::none)
+		rectangle(x, y - ascent, width, ascent + descent, frame);
 
-	text(x + 3, baseline, str, font);
+	text(x + 3, y, str, font);
 }
 
 
-void Painter::buttonText(int x, int baseline,
-	string const & str,
-	LyXFont const & font)
+void Painter::buttonText(int x, int y, string const & str, LyXFont const & font)
 {
 	int width;
 	int ascent;
@@ -89,8 +85,8 @@ void Painter::buttonText(int x, int base
 
 	font_metrics::buttonText(str, font, width, ascent, descent);
 
-	button(x, baseline - ascent, width, descent + ascent);
-	text(x + 4, baseline, str, font);
+	button(x, y - ascent, width, descent + ascent);
+	text(x + 4, y, str, font);
 }
 
 
@@ -99,10 +95,8 @@ void Painter::underline(LyXFont const & 
 	int const below = max(font_metrics::maxDescent(f) / 2, 2);
 	int const height = max((font_metrics::maxDescent(f) / 4) - 1, 1);
 
-	if (height < 2) {
+	if (height < 2)
 		line(x, y + below, x + width, y + below, f.color());
-	} else {
-		fillRectangle(x, y + below, width, below + height,
-			      f.color());
-	}
+	else
+		fillRectangle(x, y + below, width, below + height, f.color());
 }
Index: frontends/screen.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/screen.C,v
retrieving revision 1.96
diff -u -p -r1.96 screen.C
--- frontends/screen.C	18 Jun 2004 13:31:54 -0000	1.96
+++ frontends/screen.C	16 Aug 2004 21:15:28 -0000
@@ -173,7 +173,7 @@ void LyXScreen::showCursor(BufferView & 
 	int x = 0;
 	int y = 0;
 	bv.cursor().getPos(x, y);
-	y -= ascent + bv.top_y();
+	y -= ascent;
 	//lyxerr << "LyXScreen::showCursor x: " << x << " y: " << y << endl;
 
 	// if it doesn't fit entirely on the screen, don't try to show it
@@ -206,41 +206,42 @@ void LyXScreen::toggleCursor(BufferView 
 
 bool LyXScreen::fitCursor(BufferView * bv)
 {
-	int const top_y = bv->top_y();
-	int const h = workarea().workHeight();
-	int newtop = top_y;
-	int x, y, asc, desc;
-
-	bv->cursor().getPos(x, y);
-	bv->cursor().getDim(asc, desc);
-	lyxerr[Debug::DEBUG] << "LyXScreen::fitCursor: x: " << x
-			     << " y: " << y
-			     << "  top_y: " << top_y
-			     << endl;
-
-	bool const big_row = h / 4 < asc + desc && asc + desc < h;
-
-	if (y + desc - top_y >= h) {
-		if (big_row)
-			newtop = y + desc - h;
-		else
-			newtop = y - h / 2;
-
-	} else if (top_y > max(y - asc, 0)) {
-		if (big_row)
-			newtop = y - asc;
-		else {
-			newtop = y - h / 2;
-			newtop = min(newtop, top_y);
-		}
-	}
-
-	newtop = max(newtop, 0);
-	if (newtop == top_y)
+//	int const top_y = bv->top_y();
+//	int const h = workarea().workHeight();
+//	int newtop = top_y;
+//	int x, y, asc, desc;
+//
+//	bv->cursor().getPos(x, y);
+//	bv->cursor().getDim(asc, desc);
+//	lyxerr[Debug::DEBUG] << "LyXScreen::fitCursor: x: " << x
+//			     << " y: " << y
+//			     << "  top_y: " << top_y
+//			     << endl;
+//
+//	bool const big_row = h / 4 < asc + desc && asc + desc < h;
+//
+//	if (y + desc - top_y >= h) {
+//		if (big_row)
+//			newtop = y + desc - h;
+//		else
+//			newtop = y - h / 2;
+//
+//	} else if (top_y > max(y - asc, 0)) {
+//		if (big_row)
+//			newtop = y - asc;
+//		else {
+//			newtop = y - h / 2;
+//			newtop = min(newtop, top_y);
+//		}
+//	}
+//
+//	newtop = max(newtop, 0);
+//	if (newtop == top_y)
+//		return false;
+//
+//	bv->top_y(newtop);
+//	return true;
 		return false;
-
-	bv->top_y(newtop);
-	return true;
 }
 
 
@@ -250,30 +251,15 @@ void LyXScreen::redraw(BufferView & bv)
 
 	if (greyed_out_) {
 		greyOut();
-		return;
-	}
-
-	workarea().getPainter().start();
-
-	hideCursor();
-
-	int const y = paintText(bv);
-
-	// maybe we have to clear the screen at the bottom
-	int const y2 = workarea().workHeight();
-	if (y < y2 && bv.text()->isMainText()) {
-		workarea().getPainter().fillRectangle(0, y,
-			workarea().workWidth(), y2 - y,
-			LColor::bottomarea);
+	} else {
+		workarea().getPainter().start();
+		hideCursor();
+		paintText(bv);
+		lyxerr[Debug::DEBUG] << "Redraw screen" << endl;
+		expose(0, 0, workarea().workWidth(), workarea().workHeight());
+		workarea().getPainter().end();
+		showCursor(bv);
 	}
-
-	lyxerr[Debug::DEBUG] << "Redraw screen" << endl;
-
-	expose(0, 0, workarea().workWidth(), workarea().workHeight());
-
-	workarea().getPainter().end();
-
-	showCursor(bv);
 }
 
 
Index: insets/insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.259
diff -u -p -r1.259 insetcollapsable.C
--- insets/insetcollapsable.C	14 Aug 2004 19:54:59 -0000	1.259
+++ insets/insetcollapsable.C	16 Aug 2004 21:15:28 -0000
@@ -50,8 +50,8 @@ void leaveInset(LCursor & cur, InsetBase
 }
 
 
-InsetCollapsable::InsetCollapsable(BufferParams const & bp,
-	CollapseStatus status)
+InsetCollapsable::InsetCollapsable
+		(BufferParams const & bp, CollapseStatus status)
 	: InsetText(bp), label("Label"), status_(status), openinlined_(false)
 {
 	setAutoBreakRows(true);
@@ -175,8 +175,8 @@ void InsetCollapsable::draw(PainterInfo 
 		int const aa  = ascent();
 		button_dim.x1 = x + 0;
 		button_dim.x2 = x + dimc.width();
-		button_dim.y1 = y - aa + pi.base.bv->top_y();
-		button_dim.y2 = y - aa + pi.base.bv->top_y() + dimc.height();
+		button_dim.y1 = y - aa;
+		button_dim.y2 = y - aa + dimc.height();
 
 		draw_collapsed(pi, x, y - aa + dimc.asc);
 		if (status_ == Open) {
@@ -192,6 +192,17 @@ void InsetCollapsable::draw(PainterInfo 
 }
 
 
+void InsetCollapsable::drawSelection(PainterInfo & pi, int x, int y) const
+{
+	if (status_ == Open && openinlined_) {
+		Dimension dimc;
+		dimension_collapsed(dimc);
+		x += dimc.width();
+	}
+	InsetText::drawSelection(pi, x, y);
+}
+
+
 InsetOld::EDITABLE InsetCollapsable::editable() const
 {
 	return status_ != Collapsed ? HIGHLY_EDITABLE : IS_EDITABLE;
@@ -367,9 +378,9 @@ void InsetCollapsable::setLabel(string c
 }
 
 
-void InsetCollapsable::setStatus(CollapseStatus st)
+void InsetCollapsable::setStatus(CollapseStatus status)
 {
-	status_ = st;
+	status_ = status;
 	setButtonLabel();
 }
 
@@ -389,10 +400,4 @@ void InsetCollapsable::scroll(BufferView
 void InsetCollapsable::scroll(BufferView & bv, int offset) const
 {
 	UpdatableInset::scroll(bv, offset);
-}
-
-
-Box const & InsetCollapsable::buttonDim() const
-{
-	return button_dim;
 }
Index: insets/insetcollapsable.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v
retrieving revision 1.177
diff -u -p -r1.177 insetcollapsable.h
--- insets/insetcollapsable.h	13 Aug 2004 19:14:14 -0000	1.177
+++ insets/insetcollapsable.h	16 Aug 2004 21:15:28 -0000
@@ -51,6 +51,8 @@ public:
 	///
 	void draw(PainterInfo & pi, int x, int y) const;
 	///
+	void drawSelection(PainterInfo & pi, int x, int y) const;
+	///
 	bool hitButton(FuncRequest &) const;
 	///
 	std::string const getNewLabel(std::string const & l) const;
Index: insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.433
diff -u -p -r1.433 insettabular.C
--- insets/insettabular.C	16 Aug 2004 00:32:03 -0000	1.433
+++ insets/insettabular.C	16 Aug 2004 21:15:28 -0000
@@ -529,42 +529,42 @@ void InsetTabular::priv_dispatch(LCursor
 		}
 		break;
 
-	case LFUN_NEXT: {
-		//if (hasSelection())
-		//	cur.selection() = false;
-		int actcell = cur.idx();
-		int actcol = tabular.column_of_cell(actcell);
-		int column = actcol;
-		if (cur.bv().top_y() + cur.bv().painter().paperHeight()
-				< yo() + tabular.getHeightOfTabular())
-		{
-			cur.bv().scrollDocView(
-				cur.bv().top_y() + cur.bv().painter().paperHeight());
-			cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
-		} else {
-			cur.idx() = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
-		}
-		resetPos(cur);
-		break;
-	}
-
-	case LFUN_PRIOR: {
-		//if (hasSelection())
-		//	cur.selection() = false;
-		int column = tabular.column_of_cell(cur.idx());
-		if (yo() < 0) {
-			cur.bv().scrollDocView(
-				cur.bv().top_y() - cur.bv().painter().paperHeight());
-			if (yo() > 0)
-				cur.idx() = column;
-			else
-				cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
-		} else {
-			cur.idx() = column;
-		}
-		resetPos(cur);
-		break;
-	}
+//	case LFUN_NEXT: {
+//		//if (hasSelection())
+//		//	cur.selection() = false;
+//		int actcell = cur.idx();
+//		int actcol = tabular.column_of_cell(actcell);
+//		int column = actcol;
+//		if (cur.bv().top_y() + cur.bv().painter().paperHeight()
+//				< yo() + tabular.getHeightOfTabular())
+//		{
+//			cur.bv().scrollDocView(
+//				cur.bv().top_y() + cur.bv().painter().paperHeight());
+//			cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
+//		} else {
+//			cur.idx() = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
+//		}
+//		resetPos(cur);
+//		break;
+//	}
+//
+//	case LFUN_PRIOR: {
+//		//if (hasSelection())
+//		//	cur.selection() = false;
+//		int column = tabular.column_of_cell(cur.idx());
+//		if (yo() < 0) {
+//			cur.bv().scrollDocView(
+//				cur.bv().top_y() - cur.bv().painter().paperHeight());
+//			if (yo() > 0)
+//				cur.idx() = column;
+//			else
+//				cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
+//		} else {
+//			cur.idx() = column;
+//		}
+//		resetPos(cur);
+//		break;
+//	}
 
 	case LFUN_LAYOUT_TABULAR:
 		InsetTabularMailer(*this).showDialog(&cur.bv());
Index: insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.597
diff -u -p -r1.597 insettext.C
--- insets/insettext.C	16 Aug 2004 00:32:04 -0000	1.597
+++ insets/insettext.C	16 Aug 2004 21:15:28 -0000
@@ -189,7 +189,7 @@ void InsetText::metrics(MetricsInfo & mi
 
 void InsetText::draw(PainterInfo & pi, int x, int y) const
 {
-	BOOST_ASSERT(!text_.paragraphs().begin()->rows.empty());
+	BOOST_ASSERT(!text_.paragraphs().front().rows().empty());
 	// update our idea of where we are
 	setPosCache(pi, x, y);
 
@@ -203,7 +203,7 @@ void InsetText::draw(PainterInfo & pi, i
 	if (backgroundColor() != LColor::background)
 		clearInset(pi.pain, x, y);
 
-	text_.draw(pi, x, y + bv->top_y());
+	text_.draw(pi, x, y);
 
 	if (drawFrame_)
 		drawFrame(pi.pain, x, y);
@@ -235,7 +235,7 @@ void InsetText::clearInset(Painter & pai
 void InsetText::updateLocal(LCursor & cur)
 {
 	if (!autoBreakRows_ && paragraphs().size() > 1) {
-		// collapseParagraphs
+		// collapse paragraphs
 		while (paragraphs().size() > 1) {
 			ParagraphList::iterator const first = paragraphs().begin();
 			ParagraphList::iterator second = first;
Index: mathed/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/Makefile.am,v
retrieving revision 1.132
diff -u -p -r1.132 Makefile.am
--- mathed/Makefile.am	15 Aug 2004 21:45:29 -0000	1.132
+++ mathed/Makefile.am	16 Aug 2004 21:15:28 -0000
@@ -11,7 +11,8 @@ AM_CXXFLAGS = $(PCH_FLAGS)
 libmathed_la_DEPENDENCIES = $(PCH_FILE)
 
 libmathed_la_SOURCES = \
-	$(PCH_FILE) textpainter.C \
+	$(PCH_FILE) \
+	textpainter.C \
 	textpainter.h \
 	math_amsarrayinset.C \
 	math_amsarrayinset.h \
Index: mathed/formulamacro.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulamacro.C,v
retrieving revision 1.156
diff -u -p -r1.156 formulamacro.C
--- mathed/formulamacro.C	24 Jul 2004 10:55:27 -0000	1.156
+++ mathed/formulamacro.C	16 Aug 2004 21:15:28 -0000
@@ -69,7 +69,7 @@ auto_ptr<InsetBase> InsetFormulaMacro::c
 
 void InsetFormulaMacro::write(Buffer const &, ostream & os) const
 {
-	os << "FormulaMacro ";
+	os << "FormulaMacro\n";
 	WriteStream wi(os, false, false);
 	tmpl()->write(wi);
 }
Index: mathed/math_binominset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_binominset.h,v
retrieving revision 1.15
diff -u -p -r1.15 math_binominset.h
--- mathed/math_binominset.h	19 Aug 2003 13:00:54 -0000	1.15
+++ mathed/math_binominset.h	16 Aug 2004 21:15:28 -0000
@@ -10,7 +10,7 @@
  */
 
 #ifndef MATH_BINOMINSET_H
-#define MATH_DINOMINSET_H
+#define MATH_BINOMINSET_H
 
 #include "math_fracbase.h"
 
Index: mathed/math_macrotemplate.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macrotemplate.C,v
retrieving revision 1.69
diff -u -p -r1.69 math_macrotemplate.C
--- mathed/math_macrotemplate.C	13 Apr 2004 13:54:58 -0000	1.69
+++ mathed/math_macrotemplate.C	16 Aug 2004 21:15:28 -0000
@@ -180,12 +180,12 @@ void MathMacroTemplate::write(Buffer con
 void MathMacroTemplate::write(WriteStream & os) const
 {
 	if (type_ == "def") {
-		os << "\n\\def\\" << name_.c_str();
+		os << "\\def\\" << name_.c_str();
 		for (int i = 1; i <= numargs_; ++i)
 			os << '#' << i;
 	} else {
 		// newcommand or renewcommand
-		os << "\n\\" << type_.c_str() << "{\\" << name_.c_str() << '}';
+		os << "\\" << type_.c_str() << "{\\" << name_.c_str() << '}';
 		if (numargs_ > 0)
 			os << '[' << numargs_ << ']';
 	}
Index: mathed/math_nestinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.C,v
retrieving revision 1.136
diff -u -p -r1.136 math_nestinset.C
--- mathed/math_nestinset.C	14 Aug 2004 21:03:55 -0000	1.136
+++ mathed/math_nestinset.C	16 Aug 2004 21:15:28 -0000
@@ -99,13 +99,15 @@ MathArray const & MathNestInset::cell(id
 
 void MathNestInset::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
-	BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
-	MathArray const & ar = cur.cell();
-	x = ar.xo() + ar.pos2x(cur.pos());
-	y = ar.yo() + cur.bv().top_y();
-	// move cursor visually into empty cells ("blue rectangles");
-	if (cur.cell().empty())
-		x += 2;
+//	BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
+//	MathArray const & ar = cur.cell();
+//	x = ar.xo() + ar.pos2x(cur.pos());
+//	y = ar.yo() + cur.bv().top_y();
+//	// move cursor visually into empty cells ("blue rectangles");
+//	if (cur.cell().empty())
+//		x += 2;
+	x = 0;
+	y = 0;
 }
 
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic