- global.c:
shortcut_init()
- Remove redundant NANO_SMALL #ifdef. (DLR)
+- nano.c:
+ do_para_begin(), do_para_end()
+ - Maintain current_y as do_justify() does, for consistency with
+ it. (DLR)
- rcfile.c:
parse_rcfile()
- Add missing brackets around an if statement block so that
- If there are more than MAIN_VISIBLE shortcuts available, only
register clicks on the first MAIN_VISIBLE shortcuts, since
bottombars() only shows that many shortcuts. (DLR)
+ edit_refresh()
+ - Call edit_update() with NONE instead of CENTER when smooth
+ scrolling is on, for consistency with the movement routines.
+ (DLR)
edit_update()
- Simplify so as not to require the fileptr parameter anymore,
since it's set to current in all calls. (DLR)
+ - Add comments better explaining what the update actually does,
+ avoid an infinite loop when location is NONE and current_y is
+ greater than (editwinrows - 1), and make sure that the bottom
+ line of the file is at the bottom line of the screen if it's
+ onscreen and location is NONE. (DLR)
do_yesno()
- Don't bother assigning the value of get_mouseinput() to
anything. Since allow_shortcuts is FALSE, its return value
if (current->lineno < edittop->lineno ||
current->lineno >= edittop->lineno + editwinrows)
- /* Note that edit_update() changes edittop so that
- * current->lineno = edittop->lineno + editwinrows / 2. Thus
- * when it then calls edit_refresh(), there is no danger of
- * getting an infinite loop. */
- edit_update(CENTER);
+ /* Note that edit_update() changes edittop so that it's in range
+ * of current. Thus, when it then calls edit_refresh(), there
+ * is no danger of getting an infinite loop. */
+ edit_update(
+#ifndef NANO_SMALL
+ ISSET(SMOOTHSCROLL) ? NONE :
+#endif
+ CENTER);
else {
int nlines = 0;
const filestruct *foo = edittop;
}
}
-/* A nice generic routine to update the edit buffer. */
+/* A nice generic routine to update the edit buffer. We keep current in
+ * the same place and move edittop to put it in range of current. */
void edit_update(topmidnone location)
{
filestruct *foo = current;
return;
if (location != TOP) {
- int goal = (location == NONE) ? current_y : editwinrows / 2;
+ /* If location is CENTER, we move edittop up (editwinrows / 2)
+ * lines. This puts current at the center of the screen. If
+ * location is NONE, we move edittop up current_y lines if
+ * current_y is in range of the screen, 0 lines if current_y is
+ * less than 0, or (editwinrows - 1) lines if current_y is
+ * greater than (editwinrows - 1). This puts current at the
+ * same place on the screen as before, or at the top or bottom
+ * of the screen if edittop is beyond either. */
+ int goal;
+
+ if (location == CENTER)
+ goal = editwinrows / 2;
+ else {
+ goal = current_y;
+
+ /* Limit goal to (editwinrows - 1) lines maximum. */
+ if (goal > editwinrows - 1)
+ goal = editwinrows - 1;
+
+ /* If the last line of the file is onscreen but isn't at the
+ * bottom of the screen, set goal so that it will be after
+ * we update. */
+ if (foo->lineno + editwinrows >= filebot->lineno)
+ goal = (editwinrows - 1) - (filebot->lineno - foo->lineno);
+ }
for (; goal > 0 && foo->prev != NULL; goal--)
foo = foo->prev;
}
+
edittop = foo;
edit_refresh();
}