2009-11-24 Chris Allegretta <chrisa@asty.org>

* move.c (do_page_up, do_page_down): Make these functions work better with soft
          line wrapping. 
        * winio.c (compute_maxrows): Make maxrows calculation more accurate when all lines are > COLS.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4441 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2009-11-24 17:15:53 +00:00
parent c82f038855
commit e2df2c899d
3 changed files with 22 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2009-11-24 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down): Make these functions work better with soft
line wrapping.
* winio.c (compute_maxrows): Make maxrows calculation more accurate when all lines are > COLS.
2009-11-22 Chris Allegretta <chrisa@asty.org>
* nano.c (main): Allow edit_refresh_needed to take effect when using --enable-tiny
(fixes Savannah bug 28076 reported by David Lawrence Ramsey).

View File

@ -50,18 +50,19 @@ void do_last_line(void)
/* Move up one page. */
void do_page_up(void)
{
int i;
int i, skipped = 0;
/* If there's less than a page of text left on the screen, put the
* cursor at the beginning of the first line of the file, and then
* update the edit window. */
if (openfile->current->lineno <= editwinrows - 2) {
if (!ISSET(SOFTWRAP) && openfile->current->lineno <= editwinrows - 2) {
do_first_line();
return;
}
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
#ifndef NANO_TINY
if (!ISSET(SMOOTH_SCROLL)) {
#endif
@ -71,15 +72,23 @@ void do_page_up(void)
}
#endif
for (i = editwinrows - 2; i > 0 && openfile->current !=
openfile->fileage; i--)
for (i = editwinrows - 2; i - skipped > 0 && openfile->current !=
openfile->fileage; i--) {
openfile->current = openfile->current->prev;
if (ISSET(SOFTWRAP) && openfile->current)
skipped += strlenpt(openfile->current->data) / COLS;
}
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
#ifdef DEBUG
fprintf(stderr, "do_page_up: openfile->current->lineno = %lu, skipped = %d\n", (unsigned long) openfile->current->lineno, skipped);
#endif
/* Scroll the edit window up a page. */
edit_scroll(UP_DIR, editwinrows - 2);
edit_scroll(UP_DIR, editwinrows - skipped - 2);
}
/* Move down one page. */
@ -107,15 +116,11 @@ void do_page_down(void)
}
#endif
#ifdef DEBUG
fprintf(stderr, "do_page_down: maxrows = %d\n", maxrows);
#endif
for (i = maxrows - 2; i > 0 && openfile->current !=
openfile->filebot; i--) {
openfile->current = openfile->current->next;
#ifdef DEBUG
fprintf(stderr, "do_page_down: moving to line %d\n", openfile->current->lineno);
fprintf(stderr, "do_page_down: moving to line %lu\n", (unsigned long) openfile->current->lineno);
#endif
}

View File

@ -2949,7 +2949,8 @@ void compute_maxrows(void)
maxrows = 0;
for (n = 0; n < editwinrows && foo; n++) {
maxrows += 1 - strlenpt(foo->data) / COLS;
maxrows ++;
n += strlenpt(foo->data) / COLS;
foo = foo->next;
}