diff --git a/src/move.c b/src/move.c index 7fe82b9..b1a6119 100644 --- a/src/move.c +++ b/src/move.c @@ -475,13 +475,14 @@ void do_down(bool scroll_only) #ifndef NANO_TINY if (ISSET(SOFTWRAP)) { /* Compute the number of lines to scroll. */ - amount = strlenpt(openfile->current->data) / COLS - xplustabs() / COLS + - strlenpt(openfile->current->next->data) / COLS + + amount = strlenpt(openfile->current->data) / (COLS - margin) - + xplustabs() / (COLS -margin) + + strlenpt(openfile->current->next->data) / (COLS - margin) + openfile->current_y - editwinrows + 2; topline = openfile->edittop; /* Reduce the amount when there are overlong lines at the top. */ for (enough = 1; enough < amount; enough++) { - amount -= strlenpt(topline->data) / COLS; + amount -= strlenpt(topline->data) / (COLS - margin); if (amount > 0) topline = topline->next; if (amount < enough) { diff --git a/src/winio.c b/src/winio.c index ae73f92..639bc9b 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2253,7 +2253,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int size_t startpos = actual_x(fileptr->data, start); /* The position in fileptr->data of the leftmost character * that displays at least partially on the window. */ - size_t endpos = actual_x(fileptr->data, start + COLS - 1) + 1; + size_t endpos = actual_x(fileptr->data, start + COLS - margin - 1) + 1; /* The position in fileptr->data of the first character that is * completely off the window to the right. * @@ -2262,7 +2262,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int #endif assert(openfile != NULL && fileptr != NULL && converted != NULL); - assert(strlenpt(converted) <= COLS); + assert(strlenpt(converted) <= COLS - margin); #ifdef ENABLE_LINENUMBERS if (ISSET(LINE_NUMBERS)) { @@ -2529,7 +2529,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int strnlenpt(fileptr->data, endmatch.rm_eo) - start - x_start); - assert(0 <= x_start && x_start < COLS); + assert(0 <= x_start && x_start < COLS - margin); mvwaddnstr(edit, line, x_start + margin, converted + index, paintlen); @@ -2558,7 +2558,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int if (end_line == NULL) break; - assert(0 <= x_start && x_start < COLS); + assert(0 <= x_start && x_start < COLS - margin); /* Paint the rest of the line. */ mvwaddnstr(edit, line, x_start + margin, converted + index, -1); @@ -2693,11 +2693,11 @@ int update_line(filestruct *fileptr, size_t index) /* Expand the line, replacing tabs with spaces, and control * characters with their displayed forms. */ #ifdef NANO_TINY - converted = display_string(fileptr->data, page_start, COLS, TRUE); + converted = display_string(fileptr->data, page_start, COLS - margin, TRUE); #else - converted = display_string(fileptr->data, page_start, COLS, !ISSET(SOFTWRAP)); + converted = display_string(fileptr->data, page_start, COLS - margin, !ISSET(SOFTWRAP)); #ifdef DEBUG - if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2) + if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - margin - 2) fprintf(stderr, "update_line(): converted(1) line = %s\n", converted); #endif #endif /* !NANO_TINY */ @@ -2725,9 +2725,9 @@ int update_line(filestruct *fileptr, size_t index) /* Expand the line, replacing tabs with spaces, and control * characters with their displayed forms. */ - converted = display_string(fileptr->data, index, COLS, !ISSET(SOFTWRAP)); + converted = display_string(fileptr->data, index, COLS - margin, !ISSET(SOFTWRAP)); #ifdef DEBUG - if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2) + if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - margin - 2) fprintf(stderr, "update_line(): converted(2) line = %s\n", converted); #endif @@ -2993,7 +2993,7 @@ void edit_update(update_type manner) goal = editwinrows - 1; #ifndef NANO_TINY if (ISSET(SOFTWRAP)) - goal -= strlenpt(openfile->current->data) / COLS ; + goal -= strlenpt(openfile->current->data) / (COLS - margin); #endif } } else { @@ -3133,7 +3133,7 @@ void spotlight(bool active, const char *word) size_t word_len = strlenpt(word), room; /* Compute the number of columns that are available for the word. */ - room = COLS + get_page_start(xplustabs()) - xplustabs(); + room = COLS - margin + get_page_start(xplustabs()) - xplustabs(); assert(room > 0); @@ -3273,7 +3273,7 @@ void do_credits(void) } else what = credits[crpos]; - start_x = COLS / 2 - strlenpt(what) / 2 - 1; + start_x = (COLS - margin) / 2 - strlenpt(what) / 2 - 1; mvwaddstr(edit, editwinrows - 1 - (editwinrows % 2), start_x, what); }