From 67d1951e4deeeb0e095cacf985b7ffabc1485872 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 31 Oct 2005 19:36:37 +0000
Subject: [PATCH] refactor the statusbar code to have and use
 statusbar_xplustabs(), for consistency

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3063 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |  6 +++---
 src/proto.h |  1 +
 src/winio.c | 13 ++++++++++---
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d03ad29c..80432903 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,9 +6,9 @@ CVS code -
 	  do_scroll_up() and do_scroll_down(); changes to
 	  shortcut_init(). (DLR, suggested by Mike Frysinger)
 	- Properly handle mouse clicks on the statusbar prompt text.
-	  New function get_statusbar_page_start(); changes to
-	  do_statusbar_mouse(), nanoget_repaint(), nanogetstr(), and
-	  statusq(). (DLR)
+	  New functions statusbar_xplustabs() and
+	  get_statusbar_page_start(); changes to do_statusbar_mouse(),
+	  nanoget_repaint(), nanogetstr(), and statusq(). (DLR)
 	- Since the statusbar prompt code needs at least 4 columns in
 	  order to work properly, make that the minimum number of
 	  columns nano requires to run, and remove assertions and code
diff --git a/src/proto.h b/src/proto.h
index 42654264..0a73aec4 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -632,6 +632,7 @@ bool do_statusbar_next_word(bool allow_punct);
 bool do_statusbar_prev_word(bool allow_punct);
 #endif
 void do_statusbar_verbatim_input(bool *got_enter);
+size_t statusbar_xplustabs(void);
 size_t get_statusbar_page_start(size_t start_col, size_t column);
 size_t xplustabs(void);
 size_t actual_x(const char *str, size_t xplus);
diff --git a/src/winio.c b/src/winio.c
index 76d86eb9..e59570f7 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -1876,11 +1876,10 @@ bool do_statusbar_mouse(void)
 
 	    /* Move to where the click occurred. */
 	    if (mouse_x > start_col && mouse_y == 0) {
-		size_t xpt = strnlenpt(answer, statusbar_x);
-
 		statusbar_x = actual_x(answer,
 			get_statusbar_page_start(start_col, start_col +
-			xpt) + mouse_x - start_col - 1);
+			statusbar_xplustabs()) + mouse_x - start_col -
+			1);
 		nanoget_repaint(answer, statusbar_x);
 	    }
 	}
@@ -2199,6 +2198,14 @@ void do_statusbar_verbatim_input(bool *got_enter)
     free(output);
 }
 
+/* Return the placewewant associated with statusbar_x, i.e, the
+ * zero-based column position of the cursor.  The value will be no
+ * smaller than statusbar_x. */
+size_t statusbar_xplustabs(void)
+{
+    return strnlenpt(answer, statusbar_x);
+}
+
 /* nano scrolls horizontally within a line in chunks.  This function
  * returns the column number of the first character displayed in the
  * statusbar prompt when the cursor is at the given column with the
-- 
GitLab