2009-08-13 Chris Allegretta <chrisa@asty.org>
* New global flag implementation courtesy of Adam Wysocki <gophi@arcabit.pl>, allows previous undo flag to be implemented consistent with other flags. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4400 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
7f38820fba
commit
a48507d32a
|
@ -1,4 +1,9 @@
|
||||||
|
2009-08-13 Chris Allegretta <chrisa@asty.org>
|
||||||
|
* New global flag implementation courtesy of Adam Wysocki <gophi@arcabit.pl>, allows
|
||||||
|
previous undo flag to be implemented consistent with other flags.
|
||||||
|
|
||||||
GNU nano 2.1.10 - 2009.07.28
|
GNU nano 2.1.10 - 2009.07.28
|
||||||
|
|
||||||
2009-07-27 Chris Allegretta <chrisa@asty.org>
|
2009-07-27 Chris Allegretta <chrisa@asty.org>
|
||||||
* text.c (undo_cut, redo_cut): Don't actually try and undo/redo an empty cut, i.e. the magicline.
|
* text.c (undo_cut, redo_cut): Don't actually try and undo/redo an empty cut, i.e. the magicline.
|
||||||
Fixes crash on cutting last line discovered by Eitan Adler <eitanadlerlist@gmail.com>.
|
Fixes crash on cutting last line discovered by Eitan Adler <eitanadlerlist@gmail.com>.
|
||||||
|
|
|
@ -36,9 +36,6 @@ 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
|
||||||
|
@ -55,7 +52,7 @@ char *last_search = NULL;
|
||||||
char *last_replace = NULL;
|
char *last_replace = NULL;
|
||||||
/* The last replacement string we searched for. */
|
/* The last replacement string we searched for. */
|
||||||
|
|
||||||
long flags = 0;
|
unsigned flags[4] = {0, 0, 0, 0};
|
||||||
/* Our flag containing the states of all global options. */
|
/* Our flag containing the states of all global options. */
|
||||||
WINDOW *topwin;
|
WINDOW *topwin;
|
||||||
/* The top portion of the window, where we display the version
|
/* The top portion of the window, where we display the version
|
||||||
|
@ -781,7 +778,7 @@ 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);
|
||||||
|
|
||||||
if (use_undo) {
|
if (ISSET(UNDOABLE)) {
|
||||||
add_to_funcs(DO_UNDO, MMAIN, N_("Undo"),
|
add_to_funcs(DO_UNDO, MMAIN, N_("Undo"),
|
||||||
IFSCHELP(nano_undo_msg), FALSE, NOVIEW);
|
IFSCHELP(nano_undo_msg), FALSE, NOVIEW);
|
||||||
|
|
||||||
|
@ -1069,7 +1066,7 @@ 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);
|
||||||
if (use_undo) {
|
if (ISSET(UNDOABLE)) {
|
||||||
add_to_sclist(MMAIN, "M-U", DO_UNDO, 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(MMAIN, "M-E", DO_REDO, 0, TRUE);
|
||||||
}
|
}
|
||||||
|
|
11
src/nano.c
11
src/nano.c
|
@ -2213,7 +2213,7 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
case 'u':
|
case 'u':
|
||||||
use_undo = TRUE;
|
SET(UNDOABLE);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 'v':
|
case 'v':
|
||||||
|
@ -2277,7 +2277,10 @@ int main(int argc, char **argv)
|
||||||
char *alt_speller_cpy = alt_speller;
|
char *alt_speller_cpy = alt_speller;
|
||||||
#endif
|
#endif
|
||||||
ssize_t tabsize_cpy = tabsize;
|
ssize_t tabsize_cpy = tabsize;
|
||||||
long flags_cpy = flags;
|
unsigned flags_cpy[sizeof(flags) / sizeof(flags[0])];
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
memcpy(flags_cpy, flags, sizeof(flags_cpy));
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
operating_dir = NULL;
|
operating_dir = NULL;
|
||||||
|
@ -2329,7 +2332,9 @@ int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
if (tabsize_cpy != -1)
|
if (tabsize_cpy != -1)
|
||||||
tabsize = tabsize_cpy;
|
tabsize = tabsize_cpy;
|
||||||
flags |= flags_cpy;
|
|
||||||
|
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
|
||||||
|
flags[i] |= flags_cpy[i];
|
||||||
}
|
}
|
||||||
#ifdef DISABLE_ROOTWRAPPING
|
#ifdef DISABLE_ROOTWRAPPING
|
||||||
/* If we don't have any rcfiles, --disable-wrapping-as-root is used,
|
/* If we don't have any rcfiles, --disable-wrapping-as-root is used,
|
||||||
|
|
83
src/nano.h
83
src/nano.h
|
@ -55,10 +55,13 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Macros for flags. */
|
/* Macros for flags. */
|
||||||
#define SET(bit) flags |= bit
|
#define FLAGOFF(flag) ((flag) / (sizeof(unsigned) * 8))
|
||||||
#define UNSET(bit) flags &= ~bit
|
#define FLAGMASK(flag) (1 << ((flag) % (sizeof(unsigned) * 8)))
|
||||||
#define ISSET(bit) ((flags & bit) != 0)
|
#define FLAGS(flag) flags[FLAGOFF(flag)]
|
||||||
#define TOGGLE(bit) flags ^= bit
|
#define SET(flag) FLAGS(flag) |= FLAGMASK(flag)
|
||||||
|
#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag)
|
||||||
|
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
|
||||||
|
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
|
||||||
|
|
||||||
/* Macros for character allocation and more. */
|
/* Macros for character allocation and more. */
|
||||||
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
|
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
|
||||||
|
@ -450,40 +453,44 @@ typedef struct subnfunc {
|
||||||
} subnfunc;
|
} subnfunc;
|
||||||
|
|
||||||
|
|
||||||
/* Bitwise flags so that we can save space (or, more correctly, not
|
/* Enumeration to be used in flags table. See FLAGBIT and FLAGOFF
|
||||||
* waste it). */
|
* definitions. */
|
||||||
#define CASE_SENSITIVE (1<<0)
|
enum
|
||||||
#define CONST_UPDATE (1<<1)
|
{
|
||||||
#define NO_HELP (1<<2)
|
CASE_SENSITIVE,
|
||||||
#define NOFOLLOW_SYMLINKS (1<<3)
|
CONST_UPDATE,
|
||||||
#define SUSPEND (1<<4)
|
NO_HELP,
|
||||||
#define NO_WRAP (1<<5)
|
NOFOLLOW_SYMLINKS,
|
||||||
#define AUTOINDENT (1<<6)
|
SUSPEND,
|
||||||
#define VIEW_MODE (1<<7)
|
NO_WRAP,
|
||||||
#define USE_MOUSE (1<<8)
|
AUTOINDENT,
|
||||||
#define USE_REGEXP (1<<9)
|
VIEW_MODE,
|
||||||
#define TEMP_FILE (1<<10)
|
USE_MOUSE,
|
||||||
#define CUT_TO_END (1<<11)
|
USE_REGEXP,
|
||||||
#define BACKWARDS_SEARCH (1<<12)
|
TEMP_FILE,
|
||||||
#define MULTIBUFFER (1<<13)
|
CUT_TO_END,
|
||||||
#define SMOOTH_SCROLL (1<<14)
|
BACKWARDS_SEARCH,
|
||||||
#define REBIND_DELETE (1<<15)
|
MULTIBUFFER,
|
||||||
#define REBIND_KEYPAD (1<<16)
|
SMOOTH_SCROLL,
|
||||||
#define NO_CONVERT (1<<17)
|
REBIND_DELETE,
|
||||||
#define BACKUP_FILE (1<<18)
|
REBIND_KEYPAD,
|
||||||
#define NO_COLOR_SYNTAX (1<<19)
|
NO_CONVERT,
|
||||||
#define PRESERVE (1<<20)
|
BACKUP_FILE,
|
||||||
#define HISTORYLOG (1<<21)
|
NO_COLOR_SYNTAX,
|
||||||
#define RESTRICTED (1<<22)
|
PRESERVE,
|
||||||
#define SMART_HOME (1<<23)
|
HISTORYLOG,
|
||||||
#define WHITESPACE_DISPLAY (1<<24)
|
RESTRICTED,
|
||||||
#define MORE_SPACE (1<<25)
|
SMART_HOME,
|
||||||
#define TABS_TO_SPACES (1<<26)
|
WHITESPACE_DISPLAY,
|
||||||
#define QUICK_BLANK (1<<27)
|
MORE_SPACE,
|
||||||
#define WORD_BOUNDS (1<<28)
|
TABS_TO_SPACES,
|
||||||
#define NO_NEWLINES (1<<29)
|
QUICK_BLANK,
|
||||||
#define BOLD_TEXT (1<<30)
|
WORD_BOUNDS,
|
||||||
#define QUIET (1<<31)
|
NO_NEWLINES,
|
||||||
|
BOLD_TEXT,
|
||||||
|
QUIET,
|
||||||
|
UNDOABLE,
|
||||||
|
};
|
||||||
|
|
||||||
/* Flags for which menus in which a given function should be present */
|
/* Flags for which menus in which a given function should be present */
|
||||||
#define MMAIN (1<<0)
|
#define MMAIN (1<<0)
|
||||||
|
|
|
@ -41,7 +41,7 @@ extern ssize_t wrap_at;
|
||||||
extern char *last_search;
|
extern char *last_search;
|
||||||
extern char *last_replace;
|
extern char *last_replace;
|
||||||
|
|
||||||
extern long flags;
|
extern unsigned flags[4];
|
||||||
extern WINDOW *topwin;
|
extern WINDOW *topwin;
|
||||||
extern WINDOW *edit;
|
extern WINDOW *edit;
|
||||||
extern WINDOW *bottomwin;
|
extern WINDOW *bottomwin;
|
||||||
|
|
|
@ -909,15 +909,6 @@ void parse_rcfile(FILE *rcstream
|
||||||
option = ptr;
|
option = ptr;
|
||||||
ptr = parse_next_word(ptr);
|
ptr = parse_next_word(ptr);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
/* FIXME: Hack which should go away ASAP */
|
|
||||||
if (strcasecmp(option, "undo") == 0) {
|
|
||||||
use_undo = TRUE;
|
|
||||||
shortcut_init(0);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; rcopts[i].name != NULL; i++) {
|
for (i = 0; rcopts[i].name != NULL; i++) {
|
||||||
if (strcasecmp(option, rcopts[i].name) == 0) {
|
if (strcasecmp(option, rcopts[i].name) == 0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -837,7 +837,7 @@ 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)
|
if (!ISSET(UNDOABLE))
|
||||||
return;
|
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,
|
||||||
|
@ -962,7 +962,7 @@ void update_undo(undo_type action)
|
||||||
int len = 0;
|
int len = 0;
|
||||||
openfilestruct *fs = openfile;
|
openfilestruct *fs = openfile;
|
||||||
|
|
||||||
if (!use_undo)
|
if (!ISSET(UNDOABLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
Loading…
Reference in New Issue