Re: Patch to fix #44

2002-04-11 Thread John Levon

On Thu, Apr 11, 2002 at 09:48:32AM +0200, Juergen Vigna wrote:

> you're busy (as I am) so I explain it to you another time. Normally LyX put's
> the cursor "before" the specified position (there is one exeption). In the
> case of a NeedFullRow or displayed inset we want to set the cursor NOT in
> front of the inset but at the end of the row before (if it is of the same
> paragraph!), BUT we need the y position of the original position as otherwise
> when we enter the inset we have a wrong outside y() and the insetcursor depends
> on it, therefor for the inset we need the y position BEFORE the inset!
> Explained well enough?
> 
 
...

> > I do not understand the comment.
> 
> Well it should say the y positon before the inset or something like that feel
> free to give me a better short description for it.

Why a short description ? Use the one above (suitable edited). This is
really really obscure code, and there is far too much of it that's
missing explanations like the one above.

regards
john

-- 
"I never understood what's so hard about picking a unique
 first and last name - and not going beyond the 6 character limit."
- Toon Moene



Re: Patch to fix #44

2002-04-11 Thread Juergen Vigna


On 10-Apr-2002 Lars Gullik Bjønnes wrote:

> I do not like it a lot sinced it introcues a iy() in lyxcursor. what
> is this iy really and why is it needed.
> 

Well you did read my comment on bug #44 in lyxbugs, didn't you? But I know
you're busy (as I am) so I explain it to you another time. Normally LyX put's
the cursor "before" the specified position (there is one exeption). In the
case of a NeedFullRow or displayed inset we want to set the cursor NOT in
front of the inset but at the end of the row before (if it is of the same
paragraph!), BUT we need the y position of the original position as otherwise
when we enter the inset we have a wrong outside y() and the insetcursor depends
on it, therefor for the inset we need the y position BEFORE the inset!
Explained well enough?

>| -y -= (text.cursor.y());
>| +y -= (text.cursor.iy());
> 
> feel free to remove the parantesis as well.

Sure

>| +/// the y position if we put the cursor at the end of the upper row!
>| +int iy_;
>
> I do not understand the comment.

Well it should say the y positon before the inset or something like that feel
free to give me a better short description for it.

> 
>| +bool flag = true;
> 
> I hate variables just called flag, what is this a flag for? What does
> it mean?

Me too but it is really obvious for what it is needed and the function is
really short!

> should it really have been called
> "there_is_a_space_on_the_last_posisiton"?

no it should be

ignore_the_space_on_the_last_position

>| +Inset * ins;
>| +// we have to consider a space on the last position in this case!
>| +if (row->next() && row->par() == row->next()->par() &&
>| +row->next()->par()->getChar(last+1) == Paragraph::META_INSET &&
>| +(ins=row->next()->par()->getInset(last+1)) &&
>| +(ins->needFullRow() || ins->display()))
>| +{
>| +flag = false;
>| +}
>|  if (last >= row->pos()
>|  && row->next()
>|  && row->next()->par() == row->par()
>| -&& row->par()->isSeparator(last))
>| +&& row->par()->isSeparator(last)
>| +&& flag)
>|  return last - 1;
>|  else
>|  return last;
> 
> If it fix the problem then ok... 

It fixes it but we have one more (but it is VERY unlikely someone discovered
it. It only happens if you have one or more full rows with ONLY chars
(no separators), try it and then try to press the "End" button and look where
the cursor goes ;)

But as I said it's very unlikely that someone sees this and it still puts the
inserted char in the right row, not like with the inset that it has the cursor
in the row below and inserts chars in the row above.

Well I commit it then!

   Jug

--
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Italienallee 13/N   Tel/Fax: +39-0471-450260 / +39-0471-450253
I-39100 Bozen   Web: http://www.sad.it/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._

Hlade's Law:
If you have a difficult task, give it to a lazy person --
they will find an easier way to do it.




Re: Patch to fix #44

2002-04-10 Thread Lars Gullik Bjønnes

Juergen Vigna <[EMAIL PROTECTED]> writes:

| Please have a look at the attached patch it fixes #44. If noone
| complains I will commit it tomorrow and close the bug.

I do not like it a lot sinced it introcues a iy() in lyxcursor. what
is this iy really and why is it needed.


| - y -= (text.cursor.y());
| + y -= (text.cursor.iy());

feel free to remove the parantesis as well.
  
| + /// the y position if we put the cursor at the end of the upper row!
| + int iy_;

I do not understand the comment.

| + bool flag = true;

I hate variables just called flag, what is this a flag for? What does
it mean?

should it really have been called
"there_is_a_space_on_the_last_posisiton"?

| + Inset * ins;
| + // we have to consider a space on the last position in this case!
| + if (row->next() && row->par() == row->next()->par() &&
| + row->next()->par()->getChar(last+1) == Paragraph::META_INSET &&
| + (ins=row->next()->par()->getInset(last+1)) &&
| + (ins->needFullRow() || ins->display()))
| + {
| + flag = false;
| + }
|   if (last >= row->pos()
|   && row->next()
|   && row->next()->par() == row->par()
| - && row->par()->isSeparator(last))
| + && row->par()->isSeparator(last)
| + && flag)
|   return last - 1;
|   else
|   return last;

If it fix the problem then ok... 

-- 
Lgb



Patch to fix #44

2002-04-10 Thread Juergen Vigna

Please have a look at the attached patch it fixes #44. If noone
complains I will commit it tomorrow and close the bug.

 Jug
--
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen VignaE-Mail:  [EMAIL PROTECTED]
Italienallee 13/N   Tel/Fax: +39-0471-450260 / +39-0471-450253
I-39100 Bozen   Web: http://www.sad.it/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._

Life is like a sewer.  What you get out of it depends on what you put into it.
-- Tom Lehrer



Index: src/BufferView2.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView2.C,v
retrieving revision 1.124
diff -u -p -r1.124 BufferView2.C
--- src/BufferView2.C   29 Mar 2002 15:49:44 -  1.124
+++ src/BufferView2.C   10 Apr 2002 15:13:27 -
@@ -572,7 +572,7 @@ void BufferView::showLockedInsetCursor(i
shape = (txt->real_current_font.isVisibleRightToLeft())
? LyXScreen::REVERSED_L_SHAPE
: LyXScreen::L_SHAPE;
-   y += cursor.y() + theLockingInset()->insetInInsetY();
+   y += cursor.iy() + theLockingInset()->insetInInsetY();
pimpl_->screen_->showManualCursor(text, x, y, asc, desc,
  shape);
}
@@ -590,7 +590,7 @@ void BufferView::hideLockedInsetCursor()
 bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
 {
if (theLockingInset() && available()) {
-   y += text->cursor.y() + theLockingInset()->insetInInsetY();
+   y += text->cursor.iy() + theLockingInset()->insetInInsetY();
if (pimpl_->screen_->fitManualCursor(text, this, x, y, asc, desc)) {
updateScrollbar();
return true;
Index: src/BufferView_pimpl.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.222
diff -u -p -r1.222 BufferView_pimpl.C
--- src/BufferView_pimpl.C  5 Apr 2002 15:17:23 -   1.222
+++ src/BufferView_pimpl.C  10 Apr 2002 15:13:38 -
@@ -951,7 +951,7 @@ Inset * BufferView::Pimpl::checkInset(Ly
 
x -= b.x1;
// The origin of an inset is on the baseline
-   y -= (text.cursor.y());
+   y -= (text.cursor.iy());
 
return inset;
 }
Index: src/lyxcursor.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxcursor.C,v
retrieving revision 1.12
diff -u -p -r1.12 lyxcursor.C
--- src/lyxcursor.C 21 Mar 2002 17:25:12 -  1.12
+++ src/lyxcursor.C 10 Apr 2002 15:13:38 -
@@ -94,6 +94,18 @@ int LyXCursor::y() const
 }
 
 
+void LyXCursor::iy(int i)
+{
+   iy_ = i;
+}
+
+
+int LyXCursor::iy() const
+{
+   return iy_;
+}
+
+
 void LyXCursor::row(Row * r)
 {
row_ = r;
Index: src/lyxcursor.h
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxcursor.h,v
retrieving revision 1.22
diff -u -p -r1.22 lyxcursor.h
--- src/lyxcursor.h 21 Mar 2002 17:25:12 -  1.22
+++ src/lyxcursor.h 10 Apr 2002 15:13:38 -
@@ -52,6 +52,10 @@ public:
///
int y() const;
///
+   void iy(int i);
+   ///
+   int iy() const;
+   ///
void row(Row * r);
///
Row * row() const;
@@ -68,6 +72,8 @@ private:
int x_fix_;
///
int y_;
+   /// the y position if we put the cursor at the end of the upper row!
+   int iy_;
///
Row * row_;
 };
Index: src/text.C
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.239
diff -u -p -r1.239 text.C
--- src/text.C  21 Mar 2002 17:25:29 -  1.239
+++ src/text.C  10 Apr 2002 15:13:52 -
@@ -254,10 +254,21 @@ pos_type LyXText::rowLast(Row const * ro
 pos_type LyXText::rowLastPrintable(Row const * row) const
 {
pos_type const last = rowLast(row);
+   bool flag = true;
+   Inset * ins;
+   // we have to consider a space on the last position in this case!
+   if (row->next() && row->par() == row->next()->par() &&
+   row->next()->par()->getChar(last+1) == Paragraph::META_INSET &&
+   (ins=row->next()->par()->getInset(last+1)) &&
+   (ins->needFullRow() || ins->display()))
+   {
+   flag = false;
+   }
if (last >= row->pos()
&& row->next()
&& row->next()->par() == row->par()
-   && row->par()->isSeparator(last))
+   && row->par()->isSeparator(last)
+   && flag)
return last - 1;
else
return last;
@@ -1134,10 +1145,11 @@