From e10debd14b3a009131ed59c324fa6daa7d8f701a Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Tue, 22 Aug 2000 01:26:42 +0000
Subject: [PATCH] Updates by Ben Roberts

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@186 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |  5 +++++
 nano.c      | 18 ++++++++++++++++++
 po/nano.pot | 48 ++++++++++++++++++++++++------------------------
 search.c    |  1 +
 4 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5cee4e32..4ad19a76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
 CVS Code
+- nano.c:
+  do_mouse()
+	- Patch for handling lines w/tabs and mouse better (Ben Roberts).
 - winio.c:
   total_refresh()
 	- Added edit_refresh() call to actually update the screen if messy.
@@ -9,6 +12,8 @@ CVS Code
   search_abort()
 	- Now calls edit_refresh_clearok when MARK_ISSET to handle screen
 	  ugliness bug (reported by Ken Tyler).
+  findnextstr():
+	- Added reset for placewewant (Ben Roberts).
 
 nano-0.9.16 - 08/09/2000
 - cut.c:
diff --git a/nano.c b/nano.c
index a1e25a95..06ac42e4 100644
--- a/nano.c
+++ b/nano.c
@@ -1155,6 +1155,7 @@ int do_exit(void)
 void do_mouse(void)
 {
     MEVENT mevent;
+    int foo = 0, tab_found = 0;
 
     if (getmouse(&mevent) == ERR)
 	return;
@@ -1197,6 +1198,23 @@ void do_mouse(void)
 	}
     }
     current_x = mevent.x;
+    placewewant = current_x;
+    while(foo < current_x) {
+	if(current->data[foo] == NANO_CONTROL_I) {
+	    current_x -= tabsize - (foo % tabsize);
+	    tab_found = 1;
+	} else if(current->data[foo] & 0x80)
+	    ;
+	else if(current->data[foo] < 32)
+	    current_x--;
+	foo++;
+    }
+    /* This is where tab_found comes in.  I can't figure out why,
+     * but without it any line with a tab will place the cursor
+     * one character behind.  Whatever, this fixes it. */
+    if(tab_found == 1)
+	current_x++;
+
     if (current_x > strlen(current->data))
 	current_x = strlen(current->data);
 
diff --git a/po/nano.pot b/po/nano.pot
index df108f8f..4e466b1f 100644
--- a/po/nano.pot
+++ b/po/nano.pot
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2000-08-18 23:52-0400\n"
+"POT-Creation-Date: 2000-08-21 21:18-0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -32,7 +32,7 @@ msgstr ""
 msgid "Read %d lines"
 msgstr ""
 
-#: files.c:217 search.c:173 search.c:191
+#: files.c:217 search.c:174 search.c:192
 #, c-format
 msgid "\"%s\" not found"
 msgstr ""
@@ -613,48 +613,48 @@ msgstr ""
 msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "
 msgstr ""
 
-#: nano.c:1257
+#: nano.c:1275
 msgid "Cannot resize top win"
 msgstr ""
 
-#: nano.c:1259
+#: nano.c:1277
 msgid "Cannot move top win"
 msgstr ""
 
-#: nano.c:1261
+#: nano.c:1279
 msgid "Cannot resize edit win"
 msgstr ""
 
-#: nano.c:1263
+#: nano.c:1281
 msgid "Cannot move edit win"
 msgstr ""
 
-#: nano.c:1265
+#: nano.c:1283
 msgid "Cannot resize bottom win"
 msgstr ""
 
-#: nano.c:1267
+#: nano.c:1285
 msgid "Cannot move bottom win"
 msgstr ""
 
-#: nano.c:1733
+#: nano.c:1751
 msgid "Main: set up windows\n"
 msgstr ""
 
-#: nano.c:1755
+#: nano.c:1773
 msgid "Main: bottom win\n"
 msgstr ""
 
-#: nano.c:1761
+#: nano.c:1779
 msgid "Main: open file\n"
 msgstr ""
 
-#: nano.c:1829
+#: nano.c:1847
 #, c-format
 msgid "I got Alt-[-%c! (%d)\n"
 msgstr ""
 
-#: nano.c:1845
+#: nano.c:1863
 #, c-format
 msgid "I got Alt-%c! (%d)\n"
 msgstr ""
@@ -687,51 +687,51 @@ msgstr ""
 msgid "Search Cancelled"
 msgstr ""
 
-#: search.c:187
+#: search.c:188
 msgid "Search Wrapped"
 msgstr ""
 
-#: search.c:243
+#: search.c:244
 #, c-format
 msgid "Replaced %d occurences"
 msgstr ""
 
-#: search.c:245
+#: search.c:246
 msgid "Replaced 1 occurence"
 msgstr ""
 
-#: search.c:380 search.c:401 search.c:424
+#: search.c:381 search.c:402 search.c:425
 msgid "Replace Cancelled"
 msgstr ""
 
-#: search.c:397
+#: search.c:398
 #, c-format
 msgid "Replace with [%s]"
 msgstr ""
 
 #. last_search is empty
-#: search.c:422
+#: search.c:423
 msgid "Replace with"
 msgstr ""
 
-#: search.c:463
+#: search.c:464
 msgid "Replace this instance?"
 msgstr ""
 
 #. Ask for it
-#: search.c:514
+#: search.c:515
 msgid "Enter line number"
 msgstr ""
 
-#: search.c:516
+#: search.c:517
 msgid "Aborted"
 msgstr ""
 
-#: search.c:536
+#: search.c:537
 msgid "Come on, be reasonable"
 msgstr ""
 
-#: search.c:541
+#: search.c:542
 #, c-format
 msgid "Only %d lines available, skipping to last line"
 msgstr ""
diff --git a/search.c b/search.c
index e5a3b05d..8667e219 100644
--- a/search.c
+++ b/search.c
@@ -159,6 +159,7 @@ filestruct *findnextstr(int quiet, filestruct * begin, char *needle)
 
 	if (past_editbot)
 	    edit_update(current, CENTER);
+	placewewant = xplustabs();
 	reset_cursor();
     } else {			/* We're at EOF, go back to the top, once */
 
-- 
GitLab