2009-07-11 Chris Allegretta <chrisa@asty.org>

* nano-regress: Small tweaks
	* Change undo code to off unless unabled via a command line option (-u/--undo).  Until this code
	  stabilizes this is the only responsible way to treat it.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4395 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2009-07-12 03:36:58 +00:00
parent a4c2b99e40
commit ad37e67dd2
7 changed files with 47 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2009-07-11 Chris Allegretta <chrisa@asty.org>
* nano-regress: Small tweaks
* Change undo code to off unless unabled via a command line option (-u/--undo). Until this code
stabilizes this is the only responsible way to treat it.
2009-03-08 Chris Allegretta <chrisa@asty.org> 2009-03-08 Chris Allegretta <chrisa@asty.org>
* TODO - Break out some targets for various features into 2.2 * TODO - Break out some targets for various features into 2.2
and 2.4 series for things which are feasible. and 2.4 series for things which are feasible.

View File

@ -189,6 +189,10 @@ Enable alternative spell checker command.
Always save changed buffer without prompting. Same as Pico's \fB-t\fP Always save changed buffer without prompting. Same as Pico's \fB-t\fP
option. option.
.TP .TP
.B \-u (\-\-undo)
Enable experimental generic-purpose undo code. By default, the undo and redo
shortcuts are Meta-U and Meta-E, respectively.
.TP
.B \-v (\-\-view) .B \-v (\-\-view)
View file (read only) mode. View file (read only) mode.
.TP .TP

View File

@ -16,10 +16,11 @@ foreach my $name (@combos) {
my @args = @$name; my @args = @$name;
my $pct = $i / $#combos * 100; my $pct = $i / $#combos * 100;
printf "Trying with options: @args, %d%% done...\n", $pct; printf "Trying with options: @args, %d%% done...\n", $pct;
system("(./configure @args && make clean all) >/dev/null 2>&1"); my $cmd = "./configure @args && make clean all";
system("($cmd) >/dev/null 2>&1");
if ($? != 0) { if ($? != 0) {
print "Build failed for args: @args\n"; print "Build failed for args: @args\n";
print "Try running make to reproduce\n"; print "To reproduce, run:\n $cmd\n";
exit(1); exit(1);
} }
$i++; $i++;

View File

@ -36,6 +36,9 @@ sigjmp_buf jump_buf;
bool jump_buf_main = FALSE; bool jump_buf_main = FALSE;
/* Have we set jump_buf so that we return to main() after a /* Have we set jump_buf so that we return to main() after a
* SIGWINCH? */ * SIGWINCH? */
bool use_undo = FALSE;
/* Are we actually using the undo code - disabled by default
as the undo code is too unstable */
#endif #endif
#ifndef DISABLE_WRAPJUSTIFY #ifndef DISABLE_WRAPJUSTIFY
@ -778,11 +781,13 @@ void shortcut_init(bool unjustify)
add_to_funcs(DO_UNINDENT, MMAIN, N_("Unindent Text"), add_to_funcs(DO_UNINDENT, MMAIN, N_("Unindent Text"),
IFSCHELP(nano_unindent_msg), FALSE, NOVIEW); IFSCHELP(nano_unindent_msg), FALSE, NOVIEW);
add_to_funcs(DO_UNDO, MMAIN, N_("Undo"), if (use_undo) {
IFSCHELP(nano_undo_msg), FALSE, NOVIEW); add_to_funcs(DO_UNDO, MMAIN, N_("Undo"),
IFSCHELP(nano_undo_msg), FALSE, NOVIEW);
add_to_funcs(DO_REDO, MMAIN, N_("Redo"), add_to_funcs(DO_REDO, MMAIN, N_("Redo"),
IFSCHELP(nano_redo_msg), TRUE, NOVIEW); IFSCHELP(nano_redo_msg), TRUE, NOVIEW);
}
#endif #endif
@ -1064,8 +1069,10 @@ void shortcut_init(bool unjustify)
add_to_sclist(MMAIN, "M-6", DO_COPY_TEXT, 0, TRUE); add_to_sclist(MMAIN, "M-6", DO_COPY_TEXT, 0, TRUE);
add_to_sclist(MMAIN, "M-}", DO_INDENT_VOID, 0, TRUE); add_to_sclist(MMAIN, "M-}", DO_INDENT_VOID, 0, TRUE);
add_to_sclist(MMAIN, "M-{", DO_UNINDENT, 0, TRUE); add_to_sclist(MMAIN, "M-{", DO_UNINDENT, 0, TRUE);
add_to_sclist(MMAIN, "M-U", DO_UNDO, 0, TRUE); if (use_undo) {
add_to_sclist(MMAIN, "M-E", DO_REDO, 0, TRUE); add_to_sclist(MMAIN, "M-U", DO_UNDO, 0, TRUE);
add_to_sclist(MMAIN, "M-E", DO_REDO, 0, TRUE);
}
add_to_sclist(MALL, "^F", DO_RIGHT, 0, TRUE); add_to_sclist(MALL, "^F", DO_RIGHT, 0, TRUE);
add_to_sclist(MALL, "^B", DO_LEFT, 0, TRUE); add_to_sclist(MALL, "^B", DO_LEFT, 0, TRUE);
add_to_sclist(MMAIN, "^Space", DO_NEXT_WORD_VOID, 0, TRUE); add_to_sclist(MMAIN, "^Space", DO_NEXT_WORD_VOID, 0, TRUE);

View File

@ -891,6 +891,10 @@ void usage(void)
#endif #endif
print_opt("-t", "--tempfile", print_opt("-t", "--tempfile",
N_("Auto save on exit, don't prompt")); N_("Auto save on exit, don't prompt"));
#ifndef NANO_TINY
print_opt("-u", "--undo", N_("Allow generic undo [EXPERIMENTAL]"));
#endif
print_opt("-v", "--view", N_("View mode (read-only)")); print_opt("-v", "--view", N_("View mode (read-only)"));
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
print_opt("-w", "--nowrap", N_("Don't wrap long lines")); print_opt("-w", "--nowrap", N_("Don't wrap long lines"));
@ -2012,6 +2016,7 @@ int main(int argc, char **argv)
{"noconvert", 0, NULL, 'N'}, {"noconvert", 0, NULL, 'N'},
{"smooth", 0, NULL, 'S'}, {"smooth", 0, NULL, 'S'},
{"quickblank", 0, NULL, 'U'}, {"quickblank", 0, NULL, 'U'},
{"undo", 0, NULL, 'u'},
{"wordbounds", 0, NULL, 'W'}, {"wordbounds", 0, NULL, 'W'},
{"autoindent", 0, NULL, 'i'}, {"autoindent", 0, NULL, 'i'},
{"cut", 0, NULL, 'k'}, {"cut", 0, NULL, 'k'},
@ -2053,11 +2058,11 @@ int main(int argc, char **argv)
while ((optchr = while ((optchr =
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv, getopt_long(argc, argv,
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tvwxz", "h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz",
long_options, NULL) long_options, NULL)
#else #else
getopt(argc, argv, getopt(argc, argv,
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tvwxz") "h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz")
#endif #endif
) != -1) { ) != -1) {
switch (optchr) { switch (optchr) {
@ -2206,6 +2211,11 @@ int main(int argc, char **argv)
case 't': case 't':
SET(TEMP_FILE); SET(TEMP_FILE);
break; break;
#ifndef NANO_TINY
case 'u':
use_undo = TRUE;
break;
#endif
case 'v': case 'v':
SET(VIEW_MODE); SET(VIEW_MODE);
break; break;

View File

@ -30,6 +30,7 @@
#ifndef NANO_TINY #ifndef NANO_TINY
extern sigjmp_buf jump_buf; extern sigjmp_buf jump_buf;
extern bool jump_buf_main; extern bool jump_buf_main;
extern bool use_undo;
#endif #endif
#ifndef DISABLE_WRAPJUSTIFY #ifndef DISABLE_WRAPJUSTIFY

View File

@ -508,9 +508,9 @@ void do_undo(void)
case ENTER: case ENTER:
undidmsg = _("line break"); undidmsg = _("line break");
if (f->next) { if (f->next) {
filestruct *foo = f->next;
f->data = nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1); f->data = nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1);
strcat(f->data, f->next->data); strcat(f->data, f->next->data);
filestruct *foo = f->next;
unlink_node(foo); unlink_node(foo);
delete_node(foo); delete_node(foo);
} }
@ -555,7 +555,7 @@ void do_undo(void)
void do_redo(void) void do_redo(void)
{ {
undo *u = openfile->undotop; undo *u = openfile->undotop;
filestruct *f = openfile->current, *t; filestruct *f = openfile->current;
int len = 0; int len = 0;
char *undidmsg, *data; char *undidmsg, *data;
@ -829,6 +829,9 @@ void add_undo(undo_type current_action)
static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut */ static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut */
ssize_t wrap_loc; /* For calculating split beginning */ ssize_t wrap_loc; /* For calculating split beginning */
if (!use_undo)
return;
/* Ugh, if we were called while cutting not-to-end, non-marked and on the same lineno, /* Ugh, if we were called while cutting not-to-end, non-marked and on the same lineno,
we need to abort here */ we need to abort here */
u = fs->current_undo; u = fs->current_undo;
@ -951,6 +954,9 @@ void update_undo(undo_type action)
int len = 0; int len = 0;
openfilestruct *fs = openfile; openfilestruct *fs = openfile;
if (!use_undo)
return;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %d", fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %d",
action, fs->last_action, openfile->current->lineno); action, fs->last_action, openfile->current->lineno);
@ -1051,6 +1057,7 @@ void update_undo(undo_type action)
break; break;
case UNSPLIT: case UNSPLIT:
/* These cases are handled by the earlier check for a new line and action */ /* These cases are handled by the earlier check for a new line and action */
case ENTER:
case OTHER: case OTHER:
break; break;
} }