regardless of the original format.
- Mac file writing supported too. Flag -M, --mac. Toggle
Meta-O (MacOS? OS-X? =-)
+ - New smooth scroll code by Ken Tyler. New flag -S, --smooth,
+ changes to page_up() and page_down().
- nano.c:
main()
- Added vars oldcurrent and oldcurrent_x to check whether cursor
-/* config.h.in. Generated automatically from configure.in by autoheader. */
+/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */
/* Define if using alloca.c. */
#undef C_ALLOCA
char *toggle_regexp_msg;
#endif
+ char *toggle_smooth_msg;
+
toggle_const_msg = _("Constant cursor position");
toggle_autoindent_msg = _("Auto indent");
toggle_suspend_msg = _("Suspend");
toggle_case_msg = _("Case Sensitive Search");
toggle_dos_msg = _("Writing file in DOS format");
toggle_mac_msg = _("Writing file in Mac format");
+ toggle_smooth_msg = _("Smooth scrolling");
+
#ifdef HAVE_REGEX_H
toggle_regexp_msg = _("Regular expressions");
#endif
DOS_FILE, 0);
toggle_init_one(&toggles[11], TOGGLE_MAC_KEY, toggle_mac_msg,
MAC_FILE, 0);
+ toggle_init_one(&toggles[12], TOGGLE_SMOOTH_KEY, toggle_smooth_msg,
+ SMOOTHSCROLL, 0);
#ifdef ENABLE_MULTIBUFFER
- toggle_init_one(&toggles[12], TOGGLE_LOAD_KEY, toggle_load_msg,
+ toggle_init_one(&toggles[13], TOGGLE_LOAD_KEY, toggle_load_msg,
MULTIBUFFER, 0);
- toggle_init_one(&toggles[13], NANO_OPENPREV_KEY, nano_openprev_msg,
+ toggle_init_one(&toggles[14], NANO_OPENPREV_KEY, nano_openprev_msg,
0, '<');
- toggle_init_one(&toggles[14], NANO_OPENNEXT_KEY, nano_opennext_msg,
+ toggle_init_one(&toggles[15], NANO_OPENNEXT_KEY, nano_opennext_msg,
0, '>');
#endif
sc_init_one(&main_list[6], NANO_PREVPAGE_KEY, _("Prev Page"),
nano_prevpage_msg,
- 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, page_up);
+ 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, do_page_up);
sc_init_one(&main_list[7], NANO_NEXTPAGE_KEY, _("Next Page"),
nano_nextpage_msg,
- 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, page_down);
+ 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, do_page_down);
sc_init_one(&main_list[8], NANO_CUT_KEY, _("Cut Text"),
nano_cut_msg, 0, NANO_CUT_FKEY, 0, NOVIEW, do_cut_text);
sc_init_one(&help_list[0], NANO_PREVPAGE_KEY, _("Prev Page"),
nano_prevpage_msg,
- 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, page_up);
+ 0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, do_page_up);
sc_init_one(&help_list[1], NANO_NEXTPAGE_KEY, _("Next Page"),
nano_nextpage_msg,
- 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, page_down);
+ 0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, do_page_down);
sc_init_one(&help_list[2], NANO_EXIT_KEY, _("Exit"),
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
#define _(string) (string)
#endif
-void page_down_center(void)
+void page_down(void)
{
if (editbot != filebot) {
- edit_update(editbot->next, CENTER);
- center_cursor();
+ if (!ISSET(SMOOTHSCROLL)) {
+ edit_update(editbot->next, CENTER);
+ center_cursor();
+ } else {
+ edit_update(editbot, NONE);
+ }
} else {
- while (current != filebot)
- current = current->next;
- edit_update(current, CENTER);
+ if (!ISSET(SMOOTHSCROLL)) {
+ while (current != filebot)
+ current = current->next;
+ edit_update(current, CENTER);
+ }
}
update_cursor();
}
-int page_down(void)
+int do_page_down(void)
{
wrap_reset();
current_x = 0;
if (current_y < editwinrows - 1 && current != editbot)
current_y++;
else
- page_down_center();
+ page_down();
update_cursor();
update_line(current->prev, 0);
return 1;
}
-void page_up_center(void)
+void page_up(void)
{
if (edittop != fileage) {
- edit_update(edittop, CENTER);
- center_cursor();
+ if (!ISSET(SMOOTHSCROLL)) {
+ edit_update(edittop, CENTER);
+ center_cursor();
+ } else {
+ edit_update(edittop->prev, NONE);
+ }
} else
current_y = 0;
}
-int page_up(void)
+int do_page_up(void)
{
int i;
if (current_y > 0)
current_y--;
else
- page_up_center();
+ page_up();
update_cursor();
update_line(current->next, 0);
#ifdef HAVE_REGEX_H
printf(_
(" -R --regexp Use regular expressions for search\n"));
+#endif
+#ifndef NANO_SMALL
+ printf(_
+ (" -S --smooth Smooth scrolling\n"));
#endif
printf(_
(" -T [num] --tabsize=[num] Set width of a tab to num\n"));
#endif
printf(_(" -T [num] Set width of a tab to num\n"));
printf(_(" -R Use regular expressions for search\n"));
+#ifndef NANO_SMALL
+ printf(_(" -S Smooth scrolling\n"));
+#endif
printf(_(" -V Print version information and exit\n"));
printf(_(" -c Constantly show cursor position\n"));
printf(_(" -h Show this message\n"));
current = previous->next;
else
current = previous;
- page_up_center();
+ page_up();
} else {
if (previous->next)
current = previous->next;
#ifdef ENABLE_MULTIBUFFER
{"multibuffer", 0, 0, 'F'},
#endif
-
+#ifndef NANO_SMALL
+ {"smooth", 0, 0, 'S'},
+#endif
{0, 0, 0, 0}
};
#endif
#endif /* ENABLE_NANORC */
#ifdef HAVE_GETOPT_LONG
- while ((optchr = getopt_long(argc, argv, "h?DFMRT:Vabcefgijklmo:pr:s:tvwxz",
+ while ((optchr = getopt_long(argc, argv, "h?DFMRST:Vabcefgijklmo:pr:s:tvwxz",
long_options, &option_index)) != EOF) {
#else
while ((optchr =
- getopt(argc, argv, "h?DFMRT:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
+ getopt(argc, argv, "h?DFMRST:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
#endif
switch (optchr) {
case 'R':
SET(USE_REGEXP);
break;
+#endif
+#ifndef NANO_SMALL
+ case 'S':
+ SET(SMOOTHSCROLL);
+ break;
#endif
case 'V':
version();
#define CLEAR_BACKUPSTRING (1<<20)
#define DOS_FILE (1<<21)
#define MAC_FILE (1<<22)
+#define SMOOTHSCROLL (1<<23)
/* Control key sequences, changing these would be very very bad */
#define TOGGLE_LOAD_KEY NANO_ALT_F
#define TOGGLE_DOS_KEY NANO_ALT_D
#define TOGGLE_MAC_KEY NANO_ALT_O
+#define TOGGLE_SMOOTH_KEY NANO_ALT_S
/* Toggle stuff, these static lengths need to go away RSN */
#define WHEREIS_LIST_LEN (8 - NO_REGEX - NO_TOGGLES)
#define REPLACE_LIST_LEN (8 - NO_REGEX - NO_TOGGLES)
-#define TOGGLE_LEN (13 - NO_REGEX + MULTI_TOGGLES)
+#define TOGGLE_LEN (14 - NO_REGEX + MULTI_TOGGLES)
#define WRITEFILE_LIST_LEN (3 - NO_BROWSER)
#define INSERTFILE_LIST_LEN (2 - NO_BROWSER)
#define BROWSER_LIST_LEN 4
# Allow nano to be suspended with ^Z
# set suspend
+# Use smooth scrolling as the default
+# set smooth
+
# Allow multiple file buffers (using ^R inserts into separate buffer)
# You must have configured with --enable-multibuffer or --enable-extra for
# this to work
void new_magicline(void);
void splice_node(filestruct *begin, filestruct *newnode, filestruct *end);
void null_at(char *data, int index);
-void page_up_center(void);
+void page_up(void);
void blank_edit(void);
void search_init_globals(void);
void replace_abort(void);
int load_open_file(void), close_open_file(void);
#endif
-int page_up(void), page_down(void);
+int do_page_up(void), do_page_down(void);
int do_cursorpos(void), do_spell(void);
int do_up(void), do_down (void), do_right(void), do_left (void);
int do_home(void), do_end(void), total_refresh(void), do_mark(void);
{"nowrap", NO_WRAP},
{"nohelp", NO_HELP},
{"suspend", SUSPEND},
-{"multibuffer", MULTIBUFFER}};
+{"multibuffer", MULTIBUFFER},
+{"smooth", SMOOTHSCROLL}};
/* We have an error in some part of the rcfile; put it on stderr and
make the user hit return to continue starting up nano */