commit 4dcd070cdf0aa43113d11b03f25e60d71f0c8009
parent 0362c58b376cec6810fa7b9792a97c66708ccb4e
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Fri, 3 Oct 2003 04:20:28 +0000
fix problems with the marking highlight's being drawn improperly in some
cases
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1564 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -145,6 +145,9 @@ CVS code -
titlebar()
- Fix problem with the available space for a filename on the
titlebar's being short by one. (DLR)
+ edit_add()
+ - Fix problems with the marking highlight's being drawn
+ improperly in some cases. (DLR)
edit_update()
- Tweak for efficiency and remove the fix_editbot() call. (David
Benbennick)
diff --git a/src/winio.c b/src/winio.c
@@ -1277,15 +1277,33 @@ void edit_add(const filestruct *fileptr, const char *converted,
if (bot->lineno > fileptr->lineno || bot_x > endpos)
bot_x = endpos;
- /* the selected bit of fileptr is on this page */
+ /* The selected bit of fileptr is on this page. */
if (top_x < endpos && bot_x > startpos) {
assert(startpos <= top_x);
- x_start = strnlenpt(fileptr->data + startpos, top_x - startpos);
+
+ /* x_start is the expanded location of the beginning of the
+ * mark minus the beginning of the page. */
+ x_start = strnlenpt(fileptr->data, top_x) - start;
if (bot_x >= endpos)
- paintlen = -1; /* Paint everything. */
+ /* If the end of the mark is off the page, paintlen is
+ * -1, meaning that everything on the line gets
+ * painted. */
+ paintlen = -1;
else
- paintlen = strnlenpt(fileptr->data + top_x, bot_x - top_x);
+ /* Otherwise, paintlen is the expanded location of the
+ * end of the mark minus the expanded location of the
+ * beginning of the mark. */
+ paintlen = strnlenpt(fileptr->data, bot_x) - (x_start +
+ start);
+
+ /* If x_start is before the beginning of the page, shift
+ * paintlen x_start characters to compensate, and put
+ * x_start at the beginning of the page. */
+ if (x_start < 0) {
+ paintlen += x_start;
+ x_start = 0;
+ }
assert(x_start >= 0 && x_start <= strlen(converted));