mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-29 05:39:55 +03:00
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-d3aeb78583b8
This commit is contained in:
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
|
||||
|
||||
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.
|
||||
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;
|
||||
/* Have we set jump_buf so that we return to main() after a
|
||||
* SIGWINCH? */
|
||||
bool use_undo = FALSE;
|
||||
/* Are we actually using the undo code - disabled by default
|
||||
as the undo code is too unstable */
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
@ -55,7 +52,7 @@ char *last_search = NULL;
|
||||
char *last_replace = NULL;
|
||||
/* 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. */
|
||||
WINDOW *topwin;
|
||||
/* 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"),
|
||||
IFSCHELP(nano_unindent_msg), FALSE, NOVIEW);
|
||||
|
||||
if (use_undo) {
|
||||
if (ISSET(UNDOABLE)) {
|
||||
add_to_funcs(DO_UNDO, MMAIN, N_("Undo"),
|
||||
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-}", DO_INDENT_VOID, 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-E", DO_REDO, 0, TRUE);
|
||||
}
|
||||
|
11
src/nano.c
11
src/nano.c
@ -2213,7 +2213,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case 'u':
|
||||
use_undo = TRUE;
|
||||
SET(UNDOABLE);
|
||||
break;
|
||||
#endif
|
||||
case 'v':
|
||||
@ -2277,7 +2277,10 @@ int main(int argc, char **argv)
|
||||
char *alt_speller_cpy = alt_speller;
|
||||
#endif
|
||||
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
|
||||
operating_dir = NULL;
|
||||
@ -2329,7 +2332,9 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
if (tabsize_cpy != -1)
|
||||
tabsize = tabsize_cpy;
|
||||
flags |= flags_cpy;
|
||||
|
||||
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
|
||||
flags[i] |= flags_cpy[i];
|
||||
}
|
||||
#ifdef DISABLE_ROOTWRAPPING
|
||||
/* 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
|
||||
|
||||
/* Macros for flags. */
|
||||
#define SET(bit) flags |= bit
|
||||
#define UNSET(bit) flags &= ~bit
|
||||
#define ISSET(bit) ((flags & bit) != 0)
|
||||
#define TOGGLE(bit) flags ^= bit
|
||||
#define FLAGOFF(flag) ((flag) / (sizeof(unsigned) * 8))
|
||||
#define FLAGMASK(flag) (1 << ((flag) % (sizeof(unsigned) * 8)))
|
||||
#define FLAGS(flag) flags[FLAGOFF(flag)]
|
||||
#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. */
|
||||
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
|
||||
@ -450,40 +453,44 @@ typedef struct subnfunc {
|
||||
} subnfunc;
|
||||
|
||||
|
||||
/* Bitwise flags so that we can save space (or, more correctly, not
|
||||
* waste it). */
|
||||
#define CASE_SENSITIVE (1<<0)
|
||||
#define CONST_UPDATE (1<<1)
|
||||
#define NO_HELP (1<<2)
|
||||
#define NOFOLLOW_SYMLINKS (1<<3)
|
||||
#define SUSPEND (1<<4)
|
||||
#define NO_WRAP (1<<5)
|
||||
#define AUTOINDENT (1<<6)
|
||||
#define VIEW_MODE (1<<7)
|
||||
#define USE_MOUSE (1<<8)
|
||||
#define USE_REGEXP (1<<9)
|
||||
#define TEMP_FILE (1<<10)
|
||||
#define CUT_TO_END (1<<11)
|
||||
#define BACKWARDS_SEARCH (1<<12)
|
||||
#define MULTIBUFFER (1<<13)
|
||||
#define SMOOTH_SCROLL (1<<14)
|
||||
#define REBIND_DELETE (1<<15)
|
||||
#define REBIND_KEYPAD (1<<16)
|
||||
#define NO_CONVERT (1<<17)
|
||||
#define BACKUP_FILE (1<<18)
|
||||
#define NO_COLOR_SYNTAX (1<<19)
|
||||
#define PRESERVE (1<<20)
|
||||
#define HISTORYLOG (1<<21)
|
||||
#define RESTRICTED (1<<22)
|
||||
#define SMART_HOME (1<<23)
|
||||
#define WHITESPACE_DISPLAY (1<<24)
|
||||
#define MORE_SPACE (1<<25)
|
||||
#define TABS_TO_SPACES (1<<26)
|
||||
#define QUICK_BLANK (1<<27)
|
||||
#define WORD_BOUNDS (1<<28)
|
||||
#define NO_NEWLINES (1<<29)
|
||||
#define BOLD_TEXT (1<<30)
|
||||
#define QUIET (1<<31)
|
||||
/* Enumeration to be used in flags table. See FLAGBIT and FLAGOFF
|
||||
* definitions. */
|
||||
enum
|
||||
{
|
||||
CASE_SENSITIVE,
|
||||
CONST_UPDATE,
|
||||
NO_HELP,
|
||||
NOFOLLOW_SYMLINKS,
|
||||
SUSPEND,
|
||||
NO_WRAP,
|
||||
AUTOINDENT,
|
||||
VIEW_MODE,
|
||||
USE_MOUSE,
|
||||
USE_REGEXP,
|
||||
TEMP_FILE,
|
||||
CUT_TO_END,
|
||||
BACKWARDS_SEARCH,
|
||||
MULTIBUFFER,
|
||||
SMOOTH_SCROLL,
|
||||
REBIND_DELETE,
|
||||
REBIND_KEYPAD,
|
||||
NO_CONVERT,
|
||||
BACKUP_FILE,
|
||||
NO_COLOR_SYNTAX,
|
||||
PRESERVE,
|
||||
HISTORYLOG,
|
||||
RESTRICTED,
|
||||
SMART_HOME,
|
||||
WHITESPACE_DISPLAY,
|
||||
MORE_SPACE,
|
||||
TABS_TO_SPACES,
|
||||
QUICK_BLANK,
|
||||
WORD_BOUNDS,
|
||||
NO_NEWLINES,
|
||||
BOLD_TEXT,
|
||||
QUIET,
|
||||
UNDOABLE,
|
||||
};
|
||||
|
||||
/* Flags for which menus in which a given function should be present */
|
||||
#define MMAIN (1<<0)
|
||||
|
@ -41,7 +41,7 @@ extern ssize_t wrap_at;
|
||||
extern char *last_search;
|
||||
extern char *last_replace;
|
||||
|
||||
extern long flags;
|
||||
extern unsigned flags[4];
|
||||
extern WINDOW *topwin;
|
||||
extern WINDOW *edit;
|
||||
extern WINDOW *bottomwin;
|
||||
|
@ -909,15 +909,6 @@ void parse_rcfile(FILE *rcstream
|
||||
option = 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++) {
|
||||
if (strcasecmp(option, rcopts[i].name) == 0) {
|
||||
#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 */
|
||||
ssize_t wrap_loc; /* For calculating split beginning */
|
||||
|
||||
if (!use_undo)
|
||||
if (!ISSET(UNDOABLE))
|
||||
return;
|
||||
|
||||
/* 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;
|
||||
openfilestruct *fs = openfile;
|
||||
|
||||
if (!use_undo)
|
||||
if (!ISSET(UNDOABLE))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user