[Aptitude-svn-commit] r3504 - in branches/aptitude-0.3/aptitude: . src/vscreen
Daniel Burrows
dburrows@costa.debian.org
Tue, 28 Jun 2005 14:21:16 +0000
Author: dburrows
Date: Tue Jun 28 14:21:13 2005
New Revision: 3504
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.cc
Log:
Fix normalize_cursor.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Tue Jun 28 14:21:13 2005
@@ -2,6 +2,10 @@
* src/vscreen/vs_editline.cc:
+ Correct several errors in how normalize_cursor works.
+
+ * src/vscreen/vs_editline.cc:
+
Fix get_char() to produce correct results (oops).
* src/vscreen/config/colors.cc:
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.cc Tue Jun 28 14:21:13 2005
@@ -103,25 +103,35 @@
// Need to move the screen start to this far behind the cursor
// loc.
int decamt=0;
+ bool needs_move=false;
if(cursorx>=w-2)
- decamt=2;
+ {
+ decamt=w-2;
+ needs_move=true;
+ }
else if(cursorx<2)
- decamt=w-2;
-
- // Do it by moving back this many chars
- size_t chars=0;
-
- while(decamt>0 && chars<curloc+prompt.size())
{
- ++chars;
- decamt-=wcwidth(get_char(prompt.size()+curloc-chars));
+ decamt=2;
+ needs_move=true;
}
- if(decamt<0 && chars>1)
- --chars;
+ if(needs_move) // equivalent to but more readable than decamt!=0
+ {
+ // Do it by moving back this many chars
+ size_t chars=0;
+
+ while(decamt>0 && chars<curloc+prompt.size())
+ {
+ ++chars;
+ decamt-=wcwidth(get_char(prompt.size()+curloc-chars));
+ }
- startloc=curloc-chars;
+ if(decamt<0 && chars>1)
+ --chars;
+
+ startloc=curloc+prompt.size()-chars;
+ }
}
else
{