From f3a07b2d7ea2f2f9a4071d729a7960322eca0922 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Fri, 29 Mar 2002 15:15:38 +0000
Subject: [PATCH] - winio.c:do_cursorpos() - Make col numbering start from 1
 (suggested by Andrew Ho)

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1155 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog | 2 ++
 winio.c   | 9 +++------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 021d7fac..540ea9f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -53,6 +53,8 @@ CVS code -
 - winio.c:
   do_credits()
 	- Add Thomas Dickey.
+  do_cursorpos()
+	- Make col numbering start from 1 (suggested by Andrew Ho).
   update_line(), xpt()
 	- Add check for 127 (DLR).
 - po/sv.po:
diff --git a/winio.c b/winio.c
index 1168e9e2..52e46f01 100644
--- a/winio.c
+++ b/winio.c
@@ -1607,10 +1607,7 @@ int do_cursorpos(int constant)
     if (old_totsize == -1)
 	old_totsize = totsize;
 
-    if (strlen(current->data) == 0)
-	colpct = 0;
-    else
-	colpct = 100 * xplustabs() / xpt(current, strlen(current->data));
+    colpct = 100 * (xplustabs() + 1) / (xpt(current, strlen(current->data)) + 1);
 
     for (fileptr = fileage; fileptr != current && fileptr != NULL;
 	 fileptr = fileptr->next)
@@ -1640,8 +1637,8 @@ int do_cursorpos(int constant)
     if (!constant || (old_i != i || old_totsize != totsize)) {
 	statusbar(_
 		  ("line %d/%d (%.0f%%), col %ld/%ld (%.0f%%), char %ld/%ld (%.0f%%)"),
-		  current->lineno, totlines, linepct, xplustabs(), 
-		  xpt(current, strlen(current->data)), colpct, i, j, bytepct);
+		  current->lineno, totlines, linepct, xplustabs() + 1, 
+		  xpt(current, strlen(current->data)) + 1, colpct, i, j, bytepct);
     }
 
     old_i = i;
-- 
GitLab