- Wrap the long jump code in NANO_SMALL #ifdefs, since we only
use it if we're resizing the window, which is disabled when
NANO_SMALL is defined. (DLR)
+ - Add smart home key option, accessible via -A/--smarthome on
+ the command line, "set smarthome" in the rcfile, and the
+ Meta-H toggle in the edit window. Smart home works as
+ follows: When Home is pressed anywhere but at the very
+ beginning of non-whitespace characters on a line, the cursor
+ will jump to that beginning (either forwards or backwards).
+ If the cursor is already at that position, it will jump to the
+ true beginning of the line. This option is disabled in tiny
+ mode. Changes to do_home(), nanogetstr(), etc. (DLR;
+ suggested by Stephan T. Lavavej)
- files.c:
add_open_file()
- Rearrange the NANO_SMALL #ifdef so that the code to set the
- nano.1:
- Document restricted mode. (IO ERROR) DLR: Add minor
modifications to account for the above changes.
+ - Document the smart home key option. (DLR)
- nano.texi:
- Fix toggle inaccuracies: Meta-L now toggles line wrapping, and
Meta-< and Meta-> aren't toggles. (DLR)
- Fix version number inaccuracies: Search/replace history and
sorting/uniqueness filtering for the internal spell chacker
were added in nano 1.1.99pre1. (DLR)
+ - Document the smart home key option. (DLR)
- nanorc.sample:
- Add missing mouse entry, and update the nanorc sample regexes
to account for the backupdir and mouse options. (DLR)
+ - Add smarthome description. (DLR)
- README.CVS:
- Increase the minimum required autoconf version to 2.54, and
change the recommended automake version 1.7 to the minimum
.B \+\fILINE\fP
Places cursor at \fILINE\fP on startup.
.TP
+.B \-A (\-\-smarthome)
+Make the Home key smarter. When Home is pressed anywhere but at the
+very beginning of non-whitespace characters on a line, the cursor will
+jump to that beginning (either forwards or backwards). If the cursor is
+already at that position, it will jump to the true beginning of the
+line.
+.TP
.B \-B (\-\-backup)
When saving a file, back up the previous version of it to the current
filename suffixed with a ~.
\fBset/unset regexp\fP
Do regular expression searches by default.
.TP
+\fBset/unset smarthome\fP
+Make the Home key smarter. When Home is pressed anywhere but at the
+very beginning of non-whitespace characters on a line, the cursor will
+jump to that beginning (either forwards or backwards). If the cursor is
+already at that position, it will jump to the true beginning of the
+line.
+.TP
\fBset/unset smooth\fP
Use smooth scrolling by default.
.TP
## Do extended regular expression searches by default.
# set regexp
+## Make the Home key smarter. When Home is pressed anywhere but at the
+## very beginning of non-whitespace characters on a line, the cursor
+## will jump to that beginning (either forwards or backwards). If the
+## cursor is already at that position, it will jump to the true
+## beginning of the line.
+# set smarthome
+
## Use smooth scrolling as the default.
# set smooth
## highlight possible errors and parameters
#color brightwhite "^ *(set|unset|syntax|color).*$"
## set, unset and syntax
-#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|rebinddelete|regexp|smooth|speller|suspend|tabsize|tempfile|view)"
+#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|rebinddelete|regexp|smarthome|smooth|speller|suspend|tabsize|tempfile|view)"
#color green "^ *(set|unset|syntax)\>"
## colors
#color yellow "^ *color +(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
@table @code
+@item -A, --smarthome
+Make the Home key smarter. When Home is pressed anywhere but at the
+very beginning of non-whitespace characters on a line, the cursor will
+jump to that beginning (either forwards or backwards). If the cursor is
+already at that position, it will jump to the true beginning of the
+line.
+
@item -B, --backup
When saving a file, back up the previous version of it to the current
filename suffixed with a ~.
@item Multiple Files Toggle (Meta-F)
toggles the -F (@code{--multibuffer}) command line flag.
+@item Backup File Toggle (Meta-H)
+toggles the -A (@code{--smarthome}) command line flag.
+
@item AutoIndent Toggle (Meta-I)
toggles the -i (@code{--autoindent}) command line flag.
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
*toggle_nohelp_msg, *toggle_cuttoend_msg,
*toggle_noconvert_msg, *toggle_dos_msg, *toggle_mac_msg,
- *toggle_backup_msg, *toggle_smooth_msg;
+ *toggle_backup_msg, *toggle_smooth_msg, *toggle_smarthome_msg;
#ifndef DISABLE_MOUSE
char *toggle_mouse_msg;
#endif
toggle_mac_msg = _("Writing file in Mac format");
toggle_backup_msg = _("Backing up file");
toggle_smooth_msg = _("Smooth scrolling");
+ toggle_smarthome_msg = _("Smart home key");
#ifdef ENABLE_COLOR
toggle_syntax_msg = _("Color syntax highlighting");
#endif
toggle_init_one(TOGGLE_BACKUP_KEY, toggle_backup_msg, BACKUP_FILE);
}
toggle_init_one(TOGGLE_SMOOTH_KEY, toggle_smooth_msg, SMOOTHSCROLL);
+ toggle_init_one(TOGGLE_SMARTHOME_KEY, toggle_smarthome_msg, SMART_HOME);
#ifdef ENABLE_COLOR
toggle_init_one(TOGGLE_SYNTAX_KEY, toggle_syntax_msg, COLOR_SYNTAX);
#endif
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <assert.h>
#include "proto.h"
#include "nano.h"
int do_home(void)
{
- current_x = 0;
- placewewant = 0;
+#ifndef NANO_SMALL
+ if (ISSET(SMART_HOME)) {
+ int old_current_x = current_x;
+
+ for (current_x = 0; isblank(current->data[current_x]) &&
+ current->data[current_x] != '\0'; current_x++)
+ ;
+
+ if (current_x == old_current_x || current->data[current_x] == '\0')
+ current_x = 0;
+
+ placewewant = xplustabs();
+ } else {
+#endif
+ current_x = 0;
+ placewewant = 0;
+#ifndef NANO_SMALL
+ }
+#endif
check_statblank();
update_line(current, current_x);
return 1;
print1opt("-h, -?", "--help", _("Show this message"));
print1opt(_("+LINE"), "", _("Start at line number LINE"));
#ifndef NANO_SMALL
+ print1opt("-A", "--smarthome", _("Enable smart home key"));
print1opt("-B", "--backup", _("Backup existing files on save"));
print1opt("-D", "--dos", _("Write file in DOS format"));
print1opt("-E", "--backupdir=[dir]", _("Directory for writing backup files"));
{"nohelp", 0, 0, 'x'},
{"suspend", 0, 0, 'z'},
#ifndef NANO_SMALL
+ {"smarthome", 0, 0, 'A'},
{"backup", 0, 0, 'B'},
{"dos", 0, 0, 'D'},
{"backupdir", 1, 0, 'E'},
#endif
#ifdef HAVE_GETOPT_LONG
- while ((optchr = getopt_long(argc, argv, "h?BDE:FHIMNQ:RST:VY:Zabcdefgijklmo:pr:s:tvwxz",
+ while ((optchr = getopt_long(argc, argv, "h?ABDE:FHIMNQ:RST:VY:Zabcdefgijklmo:pr:s:tvwxz",
long_options, NULL)) != -1) {
#else
while ((optchr =
- getopt(argc, argv, "h?BDE:FHIMNQ:RST:VY:Zabcdefgijklmo:pr:s:tvwxz")) != -1) {
+ getopt(argc, argv, "h?ABDE:FHIMNQ:RST:VY:Zabcdefgijklmo:pr:s:tvwxz")) != -1) {
#endif
switch (optchr) {
/* Pico compatibility flags */
break;
#ifndef NANO_SMALL
+ case 'A':
+ SET(SMART_HOME);
+ break;
case 'B':
SET(BACKUP_FILE);
break;
#define HISTORY_CHANGED (1<<27)
#define HISTORYLOG (1<<28)
#define RESTRICTED (1<<29)
+#define SMART_HOME (1<<30)
/* Control key sequences, changing these would be very very bad. */
#define NANO_CONTROL_SPACE 0
#define TOGGLE_NOCONVERT_KEY NANO_ALT_N
#define TOGGLE_BACKUP_KEY NANO_ALT_B
#define TOGGLE_SYNTAX_KEY NANO_ALT_Y
+#define TOGGLE_SMARTHOME_KEY NANO_ALT_H
#endif /* !NANO_SMALL */
#define MAIN_VISIBLE 12
{"regexp", USE_REGEXP},
#endif
#ifndef NANO_SMALL
+ {"smarthome", SMART_HOME},
{"smooth", SMOOTHSCROLL},
#endif
#ifndef DISABLE_SPELLER
break;
#endif
case NANO_HOME_KEY:
- x = 0;
+#ifndef NANO_SMALL
+ if (ISSET(SMART_HOME)) {
+ int old_x = x;
+
+ for (x = 0; isblank(answer[x]) && x < xend; x++)
+ ;
+
+ if (x == old_x || x == xend)
+ x = 0;
+ } else
+#endif
+ x = 0;
break;
case NANO_END_KEY:
x = xend;