From 75c070976f4fd44869b81c619d0a544c4d8bee4a Mon Sep 17 00:00:00 2001 From: faissaloo Date: Fri, 26 Aug 2016 16:35:59 +0100 Subject: [PATCH 07/20] Fixes page wrap bug --- src/global.c | 1 + src/proto.h | 1 + src/utils.c | 6 +++--- src/winio.c | 10 ++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/global.c b/src/global.c index 69c6647..fdeb8a9 100644 --- a/src/global.c +++ b/src/global.c @@ -43,6 +43,7 @@ bool focusing = TRUE; message_type lastmessage = HUSH; /* Messages of type HUSH should not overwrite type MILD nor ALERT. */ +int margin = 0; #ifndef NANO_TINY int controlleft = CONTROL_LEFT; int controlright = CONTROL_RIGHT; diff --git a/src/proto.h b/src/proto.h index 6396f37..49a3b11 100644 --- a/src/proto.h +++ b/src/proto.h @@ -36,6 +36,7 @@ extern bool focusing; extern message_type lastmessage; +extern int margin; #ifndef NANO_TINY extern int controlleft; extern int controlright; diff --git a/src/utils.c b/src/utils.c index 67d90d8..a32a2b0 100644 --- a/src/utils.c +++ b/src/utils.c @@ -439,12 +439,12 @@ char *free_and_assign(char *dest, char *src) * get_page_start(column) < COLS). */ size_t get_page_start(size_t column) { - if (column == 0 || column < COLS - 1) + if (column == 0 || column < COLS - 1-margin) return 0; else if (COLS > 8) - return column - 7 - (column - 7) % (COLS - 8); + return column - 7 - (column - 7) % (COLS - 8-margin); else - return column - (COLS - 2); + return column - (COLS - 2-margin); } /* Return the placewewant associated with current_x, i.e. the zero-based diff --git a/src/winio.c b/src/winio.c index a29d02a..a6523fa 100644 --- a/src/winio.c +++ b/src/winio.c @@ -37,8 +37,6 @@ #define BRANDING PACKAGE_STRING #endif -int margin=0; - static int *key_buffer = NULL; /* The keystroke buffer, containing all the keystrokes we * haven't handled yet at a given point. */ @@ -1811,7 +1809,7 @@ char *display_string(const char *buf, size_t start_col, size_t span, converted[index] = '\0'; /* Make sure converted takes up no more than span columns. */ - index = actual_x(converted, span); + index = actual_x(converted, span-margin-1); null_at(&converted, index); return converted; @@ -2701,9 +2699,9 @@ int update_line(filestruct *fileptr, size_t index) if (!ISSET(SOFTWRAP)) { #endif if (page_start > 0) - mvwaddch(edit, line, 0, '$'); - if (strlenpt(fileptr->data) > page_start + COLS-margin) - mvwaddch(edit, line, COLS - 1, '$'); + mvwaddch(edit, line, margin-1, '$'); + if (strlenpt(fileptr->data) > page_start + COLS-margin-1) + mvwaddch(edit, line, COLS-1, '$'); #ifndef NANO_TINY } else { size_t full_length = strlenpt(fileptr->data); -- 2.7.4