mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-11 11:59:24 +03:00
add smart home key
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1751 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
684e7ebd37
commit
c7acf69cb2
13
ChangeLog
13
ChangeLog
@ -53,6 +53,16 @@ CVS code -
|
||||
- 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
|
||||
@ -231,6 +241,7 @@ CVS code -
|
||||
- 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)
|
||||
@ -239,9 +250,11 @@ CVS code -
|
||||
- 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
|
||||
|
@ -35,6 +35,13 @@ replace" and "go to line number".
|
||||
.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 ~.
|
||||
|
@ -108,6 +108,13 @@ acts like Delete on your system.
|
||||
\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
|
||||
|
@ -79,6 +79,13 @@
|
||||
## 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
|
||||
|
||||
@ -208,7 +215,7 @@
|
||||
## 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))?\>"
|
||||
|
@ -107,6 +107,13 @@ Email bug reports to @email{nano@@nano-editor.org}.
|
||||
|
||||
@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 ~.
|
||||
@ -346,6 +353,9 @@ toggles the -D (@code{--dos}) command line flag.
|
||||
@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.
|
||||
|
||||
|
@ -231,7 +231,7 @@ void toggle_init(void)
|
||||
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
|
||||
@ -263,6 +263,7 @@ void toggle_init(void)
|
||||
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
|
||||
@ -296,6 +297,7 @@ void toggle_init(void)
|
||||
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
|
||||
|
22
src/move.c
22
src/move.c
@ -23,14 +23,32 @@
|
||||
|
||||
#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;
|
||||
|
@ -633,6 +633,7 @@ void usage(void)
|
||||
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"));
|
||||
@ -3057,6 +3058,7 @@ int main(int argc, char *argv[])
|
||||
{"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'},
|
||||
@ -3085,11 +3087,11 @@ int main(int argc, char *argv[])
|
||||
#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) {
|
||||
@ -3103,6 +3105,9 @@ int main(int argc, char *argv[])
|
||||
/* Pico compatibility flags */
|
||||
break;
|
||||
#ifndef NANO_SMALL
|
||||
case 'A':
|
||||
SET(SMART_HOME);
|
||||
break;
|
||||
case 'B':
|
||||
SET(BACKUP_FILE);
|
||||
break;
|
||||
|
@ -278,6 +278,7 @@ typedef struct historyheadtype {
|
||||
#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
|
||||
@ -446,6 +447,7 @@ typedef struct historyheadtype {
|
||||
#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
|
||||
|
@ -80,6 +80,7 @@ const static rcoption rcopts[] = {
|
||||
{"regexp", USE_REGEXP},
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTHSCROLL},
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
|
13
src/winio.c
13
src/winio.c
@ -1332,7 +1332,18 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user