Re: [patch] linking source view with text

2007-06-27 Thread Mael Hilléreau

Le 27 juin 07 à 12:24, Alfredo Braunstein a écrit :


Mael Hilléreau wrote:


Thanks for the suggestion. How do you think would it help error
handling? Right now we don't show latex errors line numbers at all.


In fact, I was thinking of non blocking errors or warnings, which are
indicated into the LaTeX log and often come with a line number.


Good point. In fact IMHO it would be very useful to cope with non- 
blocking
errors and warnings in the same way than normal errors. I think the  
only

thing we need to code would be to access the error dialog even after
compilation. I think it would be best if we can solve the problem  
without

resorting to line numbers.


Indeed! ;)

Mael.


Re: [patch] linking source view with text

2007-06-27 Thread Alfredo Braunstein
Mael Hilléreau wrote:

>> Thanks for the suggestion. How do you think would it help error
>> handling? Right now we don't show latex errors line numbers at all.
> 
> In fact, I was thinking of non blocking errors or warnings, which are
> indicated into the LaTeX log and often come with a line number.

Good point. In fact IMHO it would be very useful to cope with non-blocking
errors and warnings in the same way than normal errors. I think the only
thing we need to code would be to access the error dialog even after
compilation. I think it would be best if we can solve the problem without
resorting to line numbers.

A/




Re: [patch] linking source view with text

2007-06-27 Thread Mael Hilléreau

Le 27 juin 07 à 11:51, Alfredo Braunstein a écrit :


On 6/27/07, Mael Hilléreau <[EMAIL PROTECTED]> wrote:

What about displaying line numbers in the source view? This may not
be hard to do and could help error handling as well... But it would

Thanks for the suggestion. How do you think would it help error  
handling? Right now we don't show latex errors line numbers at all.


In fact, I was thinking of non blocking errors or warnings, which are  
indicated into the LaTeX log and often come with a line number.


On latex errors, ideally we could just select the offending line in  
the view source window, which is better than the


latex source line -> top buffer pit/pos -> view source line(s)


Yes, this is clearly more convenient when LyX handles the problem  
itself.


Mael.



Re: [patch] linking source view with text

2007-06-27 Thread Alfredo Braunstein

On 6/27/07, Mael Hilléreau <[EMAIL PROTECTED]> wrote:

What about displaying line numbers in the source view? This may not

be hard to do and could help error handling as well... But it would
be needed to consider child documents separately (offset due to
preamble skipping).



Thanks for the suggestion. How do you think would it help error handling?
Right now we don't show latex errors line numbers at all.

On latex errors, ideally we could just select the offending line in the view
source window, which is better than the

latex source line -> top buffer pit/pos -> view source line(s)

trip we have with the patch

A/


Re: [patch] linking source view with text

2007-06-27 Thread Mael Hilléreau

Le 20 juin 07 à 17:06, Alfredo Braunstein a écrit :

The following short patch is a links the source view window with  
the work

area: now when navigating with the cursor the line of the latex source
which should contain the corresponding position of the cursor  
position is

selected.

The patch includes an orthogonal simplification to rowlist (for the  
same

price).

This is probably 1.5.x stuff at minimum, but I'd appreciate  
comments very

much nevertheless...


What about displaying line numbers in the source view? This may not  
be hard to do and could help error handling as well... But it would  
be needed to consider child documents separately (offset due to  
preamble skipping).


Mael.


Re: [patch] linking source view with text

2007-06-26 Thread Bo Peng

I'm not sure I'll be able to follow closely in the next days, so unless
someone else wants to take care of it I prefer to leave it for 1.5.x (soon
I hope ;-))


I agree. Let us just push 1.5.0 out...

Bo


Re: [patch] linking source view with text

2007-06-26 Thread Alfredo Braunstein
José Matos wrote:

> On Monday 25 June 2007 19:50:41 Bo Peng wrote:
>>
>> Then you have a combined OK from Abdel and me, you need to wait for
>> Jose's.
>>
>> Jose: This looks like 1.5.x stuff but showing where the cursor is in
>> the view source window is a nice thing to have.
> 
>   I was tempted to say yes, but then I saw Alfredo's message. ;-)
> 
>   OK with the single condition that if any related problems appears after
>   RC2
> we revert the patch. Is this OK?

I'm not sure I'll be able to follow closely in the next days, so unless
someone else wants to take care of it I prefer to leave it for 1.5.x (soon
I hope ;-))

A/




Re: [patch] linking source view with text

2007-06-26 Thread José Matos
On Monday 25 June 2007 19:50:41 Bo Peng wrote:
>
> Then you have a combined OK from Abdel and me, you need to wait for Jose's.
>
> Jose: This looks like 1.5.x stuff but showing where the cursor is in
> the view source window is a nice thing to have.

  I was tempted to say yes, but then I saw Alfredo's message. ;-)

  OK with the single condition that if any related problems appears after RC2 
we revert the patch. Is this OK?

> Bo

-- 
José Abílio


Re: [patch] linking source view with text

2007-06-25 Thread Alfredo Braunstein
Bo Peng wrote:

>> I cannot judge the ViewSource part but the TexRow simplification is good
>> by itself IMHO.
> 
> Then you have a combined OK from Abdel and me, you need to wait for
> Jose's.
> 
> Jose: This looks like 1.5.x stuff but showing where the cursor is in
> the view source window is a nice thing to have.

There's really no rush, I prefer to wait for 1.5.x than have to fix last
minute bugs.

The thing that bothers me the most is that a blue selection is too
distracting, it would be much better to have some lighter color (e.g.
grey). Another thing that would be nice to have is the reverse linking:
implementing it is trivial, but then the combination of the two would
interfere with the selection of text in the source view window, and that's
very bad. So the best would be to have an independent selection, but I
don't know how to do that (at least with qt 4.1). 

qt expertise needed here ;-)

A/




Re: [patch] linking source view with text

2007-06-25 Thread Bo Peng

I cannot judge the ViewSource part but the TexRow simplification is good
by itself IMHO.


Then you have a combined OK from Abdel and me, you need to wait for Jose's.

Jose: This looks like 1.5.x stuff but showing where the cursor is in
the view source window is a nice thing to have.

Bo


Re: [patch] linking source view with text

2007-06-25 Thread Abdelrazak Younes

Alfredo Braunstein wrote:

Bo Peng wrote:


Err... what doesn't work exactly? This texrow stuff work at the outer
paragraphs level, so there should be no particular problem with tables.

I meant, if you click on texts inside table, your gray bar does not go
there. It always stays at the first line (\begin{table}?)


Update: better behavior in this case (i.e. a top level par position spanning
multiple latex rows) + handling of selection.


I cannot judge the ViewSource part but the TexRow simplification is good 
by itself IMHO.


Abdel.



Re: [patch] linking source view with text

2007-06-25 Thread Alfredo Braunstein
Bo Peng wrote:

>> Err... what doesn't work exactly? This texrow stuff work at the outer
>> paragraphs level, so there should be no particular problem with tables.
> 
> I meant, if you click on texts inside table, your gray bar does not go
> there. It always stays at the first line (\begin{table}?)

Update: better behavior in this case (i.e. a top level par position spanning
multiple latex rows) + handling of selection.

A/

Index: TexRow.h
===
--- TexRow.h	(revision 18883)
+++ TexRow.h	(working copy)
@@ -14,7 +14,7 @@
 #ifndef TEXROW_H
 #define TEXROW_H
 
-#include 
+#include 
 
 
 namespace lyx {
@@ -24,10 +24,8 @@
 class TexRow {
 public:
 	///
-	TexRow() : count(0), lastid(-1), lastpos(-1) {}
+	TexRow() : lastid(-1), lastpos(-1) {}
 
-	TexRow & operator+= (TexRow const &);
-
 	/// Clears structure
 	void reset();
 
@@ -49,14 +47,22 @@
 	 */
 	bool getIdFromRow(int row, int & id, int & pos) const;
 
+	/**
+	 * getIdFromRow - find row containing a given id and pos
+	 * @param id of the paragraph
+	 * @param pos a given position in that paragraph
+	 * @return the row number within the rowlist
+	 */
+	int getRowFromIdPos(int id, int pos) const;
+	
 	/// Returns the number of rows contained
-	int rows() const { return count; }
+	int rows() const { return rowlist.size(); }
 
 	/// an individual id/pos <=> row mapping
 	class RowItem {
 	public:
-		RowItem(int id, int pos, int row)
-			: id_(id), pos_(pos), rownumber_(row)
+		RowItem(int id, int pos)
+			: id_(id), pos_(pos)
 		{}
 
 		/// paragraph id
@@ -74,21 +80,14 @@
 			return pos_;
 		}
 
-		/// row number
-		int rownumber() const {
-			return rownumber_;
-		}
 	private:
 		RowItem();
 		int id_;
 		int pos_;
-		int rownumber_;
 	};
 	///
-	typedef std::list RowList;
+	typedef std::vector RowList;
 private:
-	/// number of lines
-	unsigned int count;
 	/// container of id/pos <=> row mapping
 	RowList rowlist;
 	/// Last paragraph
Index: frontends/qt4/QViewSource.cpp
===
--- frontends/qt4/QViewSource.cpp	(revision 18883)
+++ frontends/qt4/QViewSource.cpp	(working copy)
@@ -61,6 +61,13 @@
 	if (autoUpdateCB->isChecked())
 		form_->update(viewFullSourceCB->isChecked());
 
+	int beg, end;
+	boost::tie(beg, end) = form_->getRows();
+	QTextCursor c = QTextCursor(viewSourceTV->document());
+	c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, beg);
+	c.select(QTextCursor::BlockUnderCursor);
+	c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, end - beg + 1);
+	viewSourceTV->setTextCursor(c);
 	QWidget::update();
 }
 
Index: frontends/controllers/ControlViewSource.cpp
===
--- frontends/controllers/ControlViewSource.cpp	(revision 18883)
+++ frontends/controllers/ControlViewSource.cpp	(working copy)
@@ -18,6 +18,7 @@
 #include "BufferView.h"
 #include "Buffer.h"
 #include "Cursor.h"
+#include "TexRow.h"
 #include 
 
 using std::string;
@@ -58,6 +59,20 @@
 }
 
 
+std::pair ControlViewSource::getRows() const
+{
+	BufferView const * view = kernel().bufferview();
+	CursorSlice beg = view->cursor().selectionBegin().bottom();
+	CursorSlice end = view->cursor().selectionEnd().bottom();
+
+	int begrow = view->buffer()->texrow().
+		getRowFromIdPos(beg.paragraph().id(), beg.pos());
+	int endrow = view->buffer()->texrow().
+		getRowFromIdPos(end.paragraph().id(), end.pos() + 1);
+	return std::make_pair(begrow, endrow);
+}
+
+
 void ControlViewSource::clearParams()
 {
 }
Index: frontends/controllers/ControlViewSource.h
===
--- frontends/controllers/ControlViewSource.h	(revision 18883)
+++ frontends/controllers/ControlViewSource.h	(working copy)
@@ -45,6 +45,9 @@
 		\param fullSource get full source code
 	 */
 	docstring const updateContent(bool fullSource);
+	/** get the cursor position in the source code
+	 */
+	std::pair getRows() const;
 };
 
 } // namespace frontend
Index: TexRow.cpp
===
--- TexRow.cpp	(revision 18883)
+++ TexRow.cpp	(working copy)
@@ -20,30 +20,10 @@
 
 namespace lyx {
 
-using std::find_if;
 
-
-namespace {
-
-/// function object returning true when row number is found
-class same_rownumber {
-public:
-	same_rownumber(int row) : row_(row) {}
-	bool operator()(TexRow::RowList::value_type const & vt) const {
-		return vt.rownumber() == row_;
-	}
-
-private:
-	int row_;
-};
-
-} // namespace anon
-
-
 void TexRow::reset()
 {
 	rowlist.clear();
-	count = 0;
 	lastid = -1;
 	lastpos = -1;
 }
@@ -59,32 +39,41 @@
 void TexRow::newline()
 {
 	int const id = lastid;
-	RowList::value_type tmp(id, lastpos, ++count);
+	RowList::value_type tmp(id, lastpos);
 	rowlist.push_back(tmp);
 }
 
 
 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
 {
-	RowList::const_iterator cit =
-		find_if(rowlist.begin(), rowlist.e

Re: [patch] linking source view with text

2007-06-20 Thread Bo Peng

PS2: I'm ok if one or both of them get applied after 1.5.0 is out.


This is a new feature so it has to wait after 1.5.0 is out.

Bo


Re: [patch] linking source view with text

2007-06-20 Thread Alfredo Braunstein
Bo Peng wrote:

> On 6/20/07, Bo Peng <[EMAIL PROTECTED]>
> wrote:
>> > This is probably 1.5.x stuff at minimum, but I'd appreciate comments
>> > very much nevertheless...
>>
>> Looks good to me right now...
> 
> I am not familiar with textrow() stuff, I guess Abdel can comment on
> that. One thing I notice that your patch does not work for tables.
> 
> The viewsource part is fine to me.
> 
> Cheers,
> Bo

Updated patches:

- The texrow part, should be safe as is an equivalent transformation
(list -> vector) plus a new function getRowFromIdPos (difference with
previous patch: the missing include you corrected + a bug fixed (the row
index in getIdFromRow goes from 1..rowlist.size(), not 0..rowlist.size-1))

- The gui part, small and purely ui (but depends on the first) plus a small
adjustment to buffer (the texrow was out of sync because of the small
comments added to the source). 

PS: you get a grey selection on the source code? here it is blue. Do you
know how to how to change the color with only qt 4.1 libs?

PS2: I'm ok if one or both of them get applied after 1.5.0 is out.

A/

Index: Buffer.cpp
===
--- Buffer.cpp	(revision 18837)
+++ Buffer.cpp	(working copy)
@@ -1746,8 +1746,11 @@
 	// No side effect of file copying and image conversion
 	runparams.dryrun = true;
 
+	texrow().reset();
 	if (full_source) {
 		os << "% " << _("Preview source code") << "\n\n";
+		texrow().newline();
+		texrow().newline();
 		if (isLatex())
 			writeLaTeXSource(os, filePath(), runparams, true, true);
 		else {
@@ -1766,9 +1769,10 @@
 	convert(par_begin),
 	convert(par_end - 1))
 			   << "\n\n";
+		texrow().newline();
+		texrow().newline();
 		// output paragraphs
 		if (isLatex()) {
-			texrow().reset();
 			latexParagraphs(*this, paragraphs(), os, texrow(), runparams);
 		} else {
 			// DocBook
Index: frontends/controllers/ControlViewSource.h
===
--- frontends/controllers/ControlViewSource.h	(revision 18837)
+++ frontends/controllers/ControlViewSource.h	(working copy)
@@ -45,6 +45,9 @@
 		\param fullSource get full source code
 	 */
 	docstring const updateContent(bool fullSource);
+	/** get the cursor position in the source code
+	 */
+	int getRow() const;
 };
 
 } // namespace frontend
Index: frontends/controllers/ControlViewSource.cpp
===
--- frontends/controllers/ControlViewSource.cpp	(revision 18837)
+++ frontends/controllers/ControlViewSource.cpp	(working copy)
@@ -18,6 +18,7 @@
 #include "BufferView.h"
 #include "Buffer.h"
 #include "Cursor.h"
+#include "TexRow.h"
 #include 
 
 using std::string;
@@ -58,6 +59,15 @@
 }
 
 
+int ControlViewSource::getRow() const
+{
+	BufferView const * view = kernel().bufferview();
+	return view->buffer()->texrow().
+		getRowFromIdPos(view->cursor().bottom().paragraph().id(),
+view->cursor().bottom().pos());
+}
+
+
 void ControlViewSource::clearParams()
 {
 }
Index: frontends/qt4/QViewSource.cpp
===
--- frontends/qt4/QViewSource.cpp	(revision 18837)
+++ frontends/qt4/QViewSource.cpp	(working copy)
@@ -61,6 +61,11 @@
 	if (autoUpdateCB->isChecked())
 		form_->update(viewFullSourceCB->isChecked());
 
+	int row = form_->getRow();
+	QTextCursor c = QTextCursor(viewSourceTV->document());
+	c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, row);
+	c.select(QTextCursor::BlockUnderCursor);
+	viewSourceTV->setTextCursor(c);
 	QWidget::update();
 }
 

Index: TexRow.h
===
--- TexRow.h	(revision 18837)
+++ TexRow.h	(working copy)
@@ -14,7 +14,7 @@
 #ifndef TEXROW_H
 #define TEXROW_H
 
-#include 
+#include 
 
 
 namespace lyx {
@@ -24,10 +24,8 @@
 class TexRow {
 public:
 	///
-	TexRow() : count(0), lastid(-1), lastpos(-1) {}
+	TexRow() : lastid(-1), lastpos(-1) {}
 
-	TexRow & operator+= (TexRow const &);
-
 	/// Clears structure
 	void reset();
 
@@ -49,14 +47,22 @@
 	 */
 	bool getIdFromRow(int row, int & id, int & pos) const;
 
+	/**
+	 * getIdFromRow - find row containing a given id and pos
+	 * @param id of the paragraph
+	 * @param pos a given position in that paragraph
+	 * @return the row number within the rowlist
+	 */
+	int getRowFromIdPos(int id, int pos) const;
+	
 	/// Returns the number of rows contained
-	int rows() const { return count; }
+	int rows() const { return rowlist.size(); }
 
 	/// an individual id/pos <=> row mapping
 	class RowItem {
 	public:
-		RowItem(int id, int pos, int row)
-			: id_(id), pos_(pos), rownumber_(row)
+		RowItem(int id, int pos)
+			: id_(id), pos_(pos)
 		{}
 
 		/// paragraph id
@@ -74,21 +80,14 @@
 			return pos_;
 		}
 
-		/// row number
-		int rownumber() const {
-			return rownumber_;
-		}
 	private:
 		RowItem();
 		int id_;
 		int pos_;
-		int rownumber_;
 	};
 	///
-	typedef std::list RowList;
+

Re: [patch] linking source view with text

2007-06-20 Thread Alfredo Braunstein
Bo Peng wrote:

>> Right. The #include  can also go. Dunno why my compiler didn't
>> complain.
> 
> If you are using cmake, it uses pre-compiled headers which is a
> superset of header files included in this single file... This has
> caused some troubles in the past.

That would explain it, thanks.
 
> I do not know if autotools has the same problem when pch.h is used.
> scons does not support pre-compiled headers.

Seems so, I'm using autotools with pch.

A/




Re: [patch] linking source view with text

2007-06-20 Thread Bo Peng

Right. The #include  can also go. Dunno why my compiler didn't
complain.


If you are using cmake, it uses pre-compiled headers which is a
superset of header files included in this single file... This has
caused some troubles in the past.

I do not know if autotools has the same problem when pch.h is used.
scons does not support pre-compiled headers.

Bo


Re: [patch] linking source view with text

2007-06-20 Thread Alfredo Braunstein
Bo Peng wrote:

> #include 
> +#include 


Right. The #include  can also go. Dunno why my compiler didn't
complain.

A/




Re: [patch] linking source view with text

2007-06-20 Thread Alfredo Braunstein
Bo Peng wrote:

>> Err... what doesn't work exactly? This texrow stuff work at the outer
>> paragraphs level, so there should be no particular problem with tables.
> 
> I meant, if you click on texts inside table, your gray bar does not go
> there. It always stays at the first line (\begin{table}?)

Yes, same thing with mathed, etc. The TexRow mechanism is somewhat limited
(and is the same used for latex errors btw, with the exact same
limitations), only work at the outer level of paragraphs. 

A/




Re: [patch] linking source view with text

2007-06-20 Thread Bo Peng

On 6/20/07, Stefan Schimanski <[EMAIL PROTECTED]> wrote:

Did I miss anything?


The original patch needs an '#include '. Please try the
attached instead.

I think this is an artifact of cmake's 'include-everything' approach.

Cheers,
Bo
Index: src/TexRow.h
===
--- src/TexRow.h	(revision 18837)
+++ src/TexRow.h	(working copy)
@@ -15,6 +15,7 @@
 #define TEXROW_H
 
 #include 
+#include 
 
 
 namespace lyx {
@@ -24,10 +25,8 @@
 class TexRow {
 public:
 	///
-	TexRow() : count(0), lastid(-1), lastpos(-1) {}
+	TexRow() : lastid(-1), lastpos(-1) {}
 
-	TexRow & operator+= (TexRow const &);
-
 	/// Clears structure
 	void reset();
 
@@ -49,14 +48,22 @@
 	 */
 	bool getIdFromRow(int row, int & id, int & pos) const;
 
+	/**
+	 * getIdFromRow - find row containing a given id and pos
+	 * @param id of the paragraph
+	 * @param pos a given position in that paragraph
+	 * @return the row number within the rowlist
+	 */
+	int getRowFromIdPos(int id, int pos) const;
+	
 	/// Returns the number of rows contained
-	int rows() const { return count; }
+	int rows() const { return rowlist.size(); }
 
 	/// an individual id/pos <=> row mapping
 	class RowItem {
 	public:
-		RowItem(int id, int pos, int row)
-			: id_(id), pos_(pos), rownumber_(row)
+		RowItem(int id, int pos)
+			: id_(id), pos_(pos)
 		{}
 
 		/// paragraph id
@@ -74,21 +81,14 @@
 			return pos_;
 		}
 
-		/// row number
-		int rownumber() const {
-			return rownumber_;
-		}
 	private:
 		RowItem();
 		int id_;
 		int pos_;
-		int rownumber_;
 	};
 	///
-	typedef std::list RowList;
+	typedef std::vector RowList;
 private:
-	/// number of lines
-	unsigned int count;
 	/// container of id/pos <=> row mapping
 	RowList rowlist;
 	/// Last paragraph
Index: src/frontends/qt4/QViewSource.cpp
===
--- src/frontends/qt4/QViewSource.cpp	(revision 18837)
+++ src/frontends/qt4/QViewSource.cpp	(working copy)
@@ -61,6 +61,11 @@
 	if (autoUpdateCB->isChecked())
 		form_->update(viewFullSourceCB->isChecked());
 
+	int row = form_->getRow();
+	QTextCursor c = QTextCursor(viewSourceTV->document());
+	c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, row);
+	c.select(QTextCursor::BlockUnderCursor);
+	viewSourceTV->setTextCursor(c);
 	QWidget::update();
 }
 
Index: src/frontends/controllers/ControlViewSource.cpp
===
--- src/frontends/controllers/ControlViewSource.cpp	(revision 18837)
+++ src/frontends/controllers/ControlViewSource.cpp	(working copy)
@@ -18,6 +18,7 @@
 #include "BufferView.h"
 #include "Buffer.h"
 #include "Cursor.h"
+#include "TexRow.h"
 #include 
 
 using std::string;
@@ -58,6 +59,15 @@
 }
 
 
+int ControlViewSource::getRow() const
+{
+	BufferView const * view = kernel().bufferview();
+	return view->buffer()->texrow().
+		getRowFromIdPos(view->cursor().bottom().paragraph().id(),
+view->cursor().bottom().pos());
+}
+
+
 void ControlViewSource::clearParams()
 {
 }
Index: src/frontends/controllers/ControlViewSource.h
===
--- src/frontends/controllers/ControlViewSource.h	(revision 18837)
+++ src/frontends/controllers/ControlViewSource.h	(working copy)
@@ -45,6 +45,9 @@
 		\param fullSource get full source code
 	 */
 	docstring const updateContent(bool fullSource);
+	/** get the cursor position in the source code
+	 */
+	int getRow() const;
 };
 
 } // namespace frontend
Index: src/TexRow.cpp
===
--- src/TexRow.cpp	(revision 18837)
+++ src/TexRow.cpp	(working copy)
@@ -20,30 +20,10 @@
 
 namespace lyx {
 
-using std::find_if;
 
-
-namespace {
-
-/// function object returning true when row number is found
-class same_rownumber {
-public:
-	same_rownumber(int row) : row_(row) {}
-	bool operator()(TexRow::RowList::value_type const & vt) const {
-		return vt.rownumber() == row_;
-	}
-
-private:
-	int row_;
-};
-
-} // namespace anon
-
-
 void TexRow::reset()
 {
 	rowlist.clear();
-	count = 0;
 	lastid = -1;
 	lastpos = -1;
 }
@@ -59,32 +39,41 @@
 void TexRow::newline()
 {
 	int const id = lastid;
-	RowList::value_type tmp(id, lastpos, ++count);
+	RowList::value_type tmp(id, lastpos);
 	rowlist.push_back(tmp);
 }
 
 
 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
 {
-	RowList::const_iterator cit =
-		find_if(rowlist.begin(), rowlist.end(),
-			same_rownumber(row));
-
-	if (cit != rowlist.end()) {
-		id = cit->id();
-		pos = cit->pos();
-		return true;
+	if (row > rowlist.size()) {
+		id = -1;
+		pos = 0;
+		return false;
 	}
-	id = -1;
-	pos = 0;
-	return false;
+
+	id = rowlist[row].id();
+	pos = rowlist[row].pos();
+	return true;
 }
 
 
-TexRow & TexRow::operator+=(TexRow const & tr)
+int TexRow::getRowFromIdPos(int id, int pos) const
 {
-	rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());
-	return *thi

Re: [patch] linking source view with text

2007-06-20 Thread Stefan Schimanski

Did I miss anything?

/Users/sts/Quellen/mac/lyx-devel/src/TexRow.h:89: error: ISO C++  
forbids declaration of 'vector' with no type
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.h:89: error: typedef name  
may not be a nested-name-specifier
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.h:89: error: expected ';'  
before '<' token
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.h:92: error: 'RowList'  
does not name a type
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.h: In member function  
'int lyx::TexRow::rows() const':
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.h:59: error: 'rowlist'  
was not declared in this scope
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp: In member function  
'void lyx::TexRow::reset()':
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:26: error: 'rowlist'  
was not declared in this scope
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp: In member function  
'void lyx::TexRow::newline()':
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:42: error: 'RowList'  
has not been declared
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:42: error:  
'value_type' was not declared in this scope
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:42: error: expected  
`;' before 'tmp'
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:43: error: 'rowlist'  
was not declared in this scope
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:43: error: 'tmp' was  
not declared in this scope
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:41: warning: unused  
variable 'id'
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp: In member function  
'bool lyx::TexRow::getIdFromRow(int, int&, int&) const':
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:49: error: 'rowlist'  
was not declared in this scope
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:55: error: 'rowlist'  
was not declared in this scope
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp: In member function  
'int lyx::TexRow::getRowFromIdPos(int, int) const':
/Users/sts/Quellen/mac/lyx-devel/src/TexRow.cpp:68: error: 'rowlist'  
was not declared in this scope



Stefan



PGP.sig
Description: Signierter Teil der Nachricht


Re: [patch] linking source view with text

2007-06-20 Thread Bo Peng

Err... what doesn't work exactly? This texrow stuff work at the outer
paragraphs level, so there should be no particular problem with tables.


I meant, if you click on texts inside table, your gray bar does not go
there. It always stays at the first line (\begin{table}?)

Bo


Re: [patch] linking source view with text

2007-06-20 Thread Alfredo Braunstein
Stefan Schimanski wrote:

> Cool! 

Thanks.

> Had nearly started to work on this feature myself. 

No worries... there's plenty of fun stuff in this area it seems ;-)

A/





Re: [patch] linking source view with text

2007-06-20 Thread Alfredo Braunstein
Bo Peng wrote:

> I am not familiar with textrow() stuff, I guess Abdel can comment on
> that. One thing I notice that your patch does not work for tables.

Err... what doesn't work exactly? This texrow stuff work at the outer
paragraphs level, so there should be no particular problem with tables.

> The viewsource part is fine to me.

Cool.

Thanks, Alfredo




Re: [patch] linking source view with text

2007-06-20 Thread Bo Peng

On 6/20/07, Bo Peng <[EMAIL PROTECTED]> wrote:

> This is probably 1.5.x stuff at minimum, but I'd appreciate comments very
> much nevertheless...

Looks good to me right now...


I am not familiar with textrow() stuff, I guess Abdel can comment on
that. One thing I notice that your patch does not work for tables.

The viewsource part is fine to me.

Cheers,
Bo


Re: [patch] linking source view with text

2007-06-20 Thread Bo Peng

This is probably 1.5.x stuff at minimum, but I'd appreciate comments very
much nevertheless...


Looks good to me right now...


- the reverse lookup source-> text (easy)
- more fine-grained control than latex lines (harder but a cool project IMO,
I think I have good ideas about it)
- search in the source window (easy)


After tex2lyx is merged with lyx (I like this idea), I think we can

1. export a 'tagged' version of selected text to view source. I mean
something like invisible paragarph id to help matching latex code with
lyx buffer.

2. allow a user to edit in this view source window, and use tex2lyx to
convert it to lyx.

This would be another fun project.

Cheers,
Bo


Re: [patch] linking source view with text

2007-06-20 Thread Stefan Schimanski


Am 20.06.2007 um 17:06 schrieb Alfredo Braunstein:

The following short patch is a links the source view window with  
the work

area: now when navigating with the cursor the line of the latex source
which should contain the corresponding position of the cursor  
position is

selected.

The patch includes an orthogonal simplification to rowlist (for the  
same

price).

This is probably 1.5.x stuff at minimum, but I'd appreciate  
comments very

much nevertheless...


Cool! Had nearly started to work on this feature myself.

Stefan


I have in mind several ways of enhancing this stuff:

- the reverse lookup source-> text (easy)
- more fine-grained control than latex lines (harder but a cool  
project IMO,

I think I have good ideas about it)
- search in the source window (easy)


PGP.sig
Description: Signierter Teil der Nachricht