* src/move.c (do_down) - Correctly compute the minimum amount
to scroll when softwrap is on and there are overlong lines.
* src/winio.c (edit_scroll) - Disable amount computation here.
+ * src/move.c (do_down) - Trim some redundant code, and correct
+ the scrolling behaviour when softwrap is off -- the construct
+ (amount ? amount : 1) wasn't doing what I intended.
2014-03-01 Chris Allegretta <chrisa@asty.org>
* global.c (shortcut_init) - fix an issue with the split
#endif
)
{
- bool onlastline = FALSE;
+#ifndef NANO_TINY
int amount, enough = 0;
filestruct *topline;
+#endif
/* If we're at the bottom of the file, get out. */
if (openfile->current == openfile->filebot)
return;
-
assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
/* Move the current line of the edit window down. */
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
+#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
- if (openfile->current->lineno - openfile->edittop->lineno >= maxrows)
- onlastline = TRUE;
/* Compute the amount to scroll. */
amount = (strlenpt(openfile->current->data) / COLS + openfile->current_y + 2
+ strlenpt(openfile->current->prev->data) / COLS - editwinrows);
topline = topline->next;
}
}
+#endif
/* If scroll_only is FALSE and if we're on the last line of the
* edit window, scroll the edit window down one line if we're in
* smooth scrolling mode, or down half a page if we're not. If
* scroll_only is TRUE, scroll the edit window down one line
* unconditionally. */
- if (onlastline || openfile->current_y == editwinrows - 1
+ if (openfile->current_y == editwinrows - 1
#ifndef NANO_TINY
- || scroll_only
+ || amount > 0 || scroll_only
#endif
) {
+#ifndef NANO_TINY
+ if (amount < 1 || scroll_only)
+ amount = 1;
+#endif
edit_scroll(DOWN_DIR,
#ifndef NANO_TINY
- (ISSET(SMOOTH_SCROLL) || scroll_only) ? (amount ? amount : 1) :
+ (ISSET(SMOOTH_SCROLL) || scroll_only) ? amount :
#endif
editwinrows / 2 + 1);
-
- edit_refresh_needed = TRUE;
- } else if (amount > 0) {
- edit_scroll(DOWN_DIR, amount);
edit_refresh_needed = TRUE;
}
/* If we're above the last line of the edit window, update the line