+2010-01-12 Chris Allegretta <chrisa@asty.org>
+ * move.c (do_page_up, do_page_down): Fix issues with not enough scrolling down/up
+ and cursor centering.
+ * winio.c (edit_scroll): Remove lots of needless checking of line length for
+ soft wrapping code.
+ * winio.c (edit_update) - Remove extra code for when updating with old_current outside
+ of the new buffer boundary and centering issues.
+
2010-01-05 Tito <farmatito@tiscali.it>
- * search.c (update_history) - Fix bad length check causing search crash on armel platform.
+ * search.c (update_history): Fix bad length check causing search crash on armel platform.
2010-01-04 Chris Allegretta <chrisa@asty.org>
- * winio.c: edit_update, edit_redraw - Fix search not scrolling to the middle of the screen
+ * winio.c: edit_update, edit_redraw: Fix search not scrolling to the middle of the screen
(reported by alpha@qzx.com) and places where we rely on maxrows but should not.
2009-12-26 Jordi Mallach <jordi@gnu.org>
/* 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 (!ISSET(SOFTWRAP) && openfile->current->lineno <= editwinrows - 2) {
+ if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) &&
+ openfile->current->lineno <= editwinrows - 2)) {
do_first_line();
return;
}
#endif
/* Scroll the edit window up a page. */
- edit_scroll(UP_DIR, editwinrows - skipped - 2);
+ openfile->current_y = 0;
+ edit_update(NONE);
}
/* Move down one page. */
openfile->placewewant);
/* Scroll the edit window down a page. */
- edit_scroll(DOWN_DIR, editwinrows - 2);
+ openfile->current_y = 0;
+ edit_update(NONE);
}
#ifndef DISABLE_JUSTIFY
#ifndef NANO_TINY
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
#endif
- editwinrows / 2);
+ editwinrows / 2 + 1);
/* If we're below the first line of the edit window, update the
* line we were on before and the line we're on now. The former
#ifndef NANO_TINY
|| scroll_only
#endif
- )
+ ) {
edit_scroll(DOWN_DIR,
#ifndef NANO_TINY
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
#endif
- editwinrows / 2);
+ editwinrows / 2 + 1);
+ edit_refresh_needed = TRUE;
+ }
/* If we're above the last line of the edit window, update the line
* we were on before and the line we're on now. The former needs to
* be redrawn if we're not on the first page, and the latter needs
#ifdef DEBUG
fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n");
#endif
- for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) {
- ssize_t len = strlenpt(foo->data) / COLS;
- if (len > 0)
- do_redraw = TRUE;
- i -= len;
- }
+ for (i = maxrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next)
+ ;
+
if (foo) {
extracuzsoft += strlenpt(foo->data) / COLS;
#ifdef DEBUG
(unsigned long) strlenpt(foo->data), (unsigned long) foo->lineno);
#endif
-
/* Now account for whether the edittop line itself is >COLS, if scrolling down */
for (foo = openfile->edittop; foo && extracuzsoft > 0; nlines++) {
extracuzsoft -= 1 + strlenpt(foo->data) / COLS;
foo = foo->next;
}
}
- } else if (ISSET(SOFTWRAP) && direction == UP_DIR) {
- for (foo = openfile->edittop, i = editwinrows; foo && i > 0; i--, foo = foo->prev) {
- if (strlenpt(foo->data) / COLS > 0) {
- do_redraw = TRUE;
- break;
- }
- }
}
/* Part 1: nlines is the number of lines we're going to scroll the
openfile->edittop = openfile->edittop->next;
}
/* Don't over-scroll on long lines */
- if (ISSET(SOFTWRAP))
- i -= strlenpt(openfile->edittop->data) / COLS;
+ if (ISSET(SOFTWRAP)) {
+ ssize_t len = strlenpt(openfile->edittop->data) / COLS;
+ i -= len;
+ if (len > 0)
+ do_redraw = TRUE;
+ }
}
- compute_maxrows();
/* Limit nlines to the number of lines we could scroll. */
nlines -= i;
* call edit_refresh() beforehand if we need to. */
if (nlines == 0 || do_redraw || nlines >= editwinrows) {
if (do_redraw || nlines >= editwinrows)
- edit_refresh();
+ edit_refresh_needed = TRUE;
return;
}
openfile->edittop->lineno || openfile->current->lineno >=
openfile->edittop->lineno + maxrows) {
+#ifdef DEBUG
+ fprintf(stderr, "edit_redraw(): line %lu was offscreen, oldcurrent = %lu edittop = %lu", openfile->current->lineno,
+ old_current->lineno, openfile->edittop->lineno);
+#endif
filestruct *old_edittop = openfile->edittop;
ssize_t nlines;
* then restore the original edittop. */
edit_update(CENTER);
- nlines = openfile->edittop->lineno - old_edittop->lineno;
-
- openfile->edittop = old_edittop;
-
/* Update old_current if we're not on the same page as
* before. */
if (do_redraw)
update_line(old_current, 0);
- /* Scroll the edit window up or down until edittop is in range
- * of current. */
- if (nlines < 0)
- edit_scroll(UP_DIR, -nlines);
- else
- edit_scroll(DOWN_DIR, nlines);
-
#ifndef NANO_TINY
/* If the mark is on, update all the lines between the old first
* line or old last line of the edit window (depending on
}
for (; goal > 0 && foo->prev != NULL; goal--) {
- if (ISSET(SOFTWRAP))
- goal -= 1 + strlenpt(foo->data) / COLS;
foo = foo->prev;
+ if (ISSET(SOFTWRAP) && foo)
+ goal -= strlenpt(foo->data) / COLS;
}
openfile->edittop = foo;
+#ifdef DEBUG
+ fprintf(stderr, "edit_udpate(), setting edittop to lineno %d\n", openfile->edittop->lineno);
+#endif
compute_maxrows();
+ edit_refresh_needed = TRUE;
}
/* Unconditionally redraw the entire screen. */