since KEEP_CUTBUFFER is only used in cut.c, make it a static variable in

cut.c instead of a flag, and unset it in other files via the new
function cutbuffer_reset()


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1781 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-05-29 15:36:58 +00:00
parent 12e066f9d4
commit c833d9e80f
5 changed files with 53 additions and 45 deletions

View File

@ -93,6 +93,9 @@ CVS code -
to do_refresh so as not to conflict with refresh(). (DLR)
- Add some comments better explaining what is disabled in
restricted mode and why. (DLR)
- Since KEEP_CUTBUFFER is only used in cut.c, make it a static
variable in cut.c instead of a flag, and unset it in other
files via the new function cutbuffer_reset(). (DLR)
- files.c:
add_open_file()
- Rearrange the NANO_SMALL #ifdef so that the code to set the

View File

@ -28,17 +28,22 @@
#include "proto.h"
#include "nano.h"
static int marked_cut; /* Is the cutbuffer from a mark?
* 0 means whole-line cut, 1 means mark,
* 2 means cut-from-cursor. */
static int keep_cutbuffer = FALSE;
/* Should we keep the contents of the cutbuffer? */
static int marked_cut;
/* Is the cutbuffer from a mark? 0 means whole-line cut, 1
* means mark, and 2 means cut-from-cursor. */
#ifndef NANO_SMALL
static int concatenate_cut; /* Should we add this cut string to the
* end of the last one? */
static int concatenate_cut;
/* Should we add this cut string to the end of the last one? */
#endif
static filestruct *cutbottom = NULL;
/* Pointer to end of cutbuffer. */
/* Pointer to end of cutbuffer. */
void cutbuffer_reset(void)
{
keep_cutbuffer = FALSE;
}
filestruct *get_cutbottom(void)
{
@ -202,7 +207,7 @@ int do_cut_text(void)
check_statblank();
if (!ISSET(KEEP_CUTBUFFER)) {
if (!keep_cutbuffer) {
free_filestruct(cutbuffer);
cutbuffer = NULL;
marked_cut = 0;
@ -215,7 +220,7 @@ int do_cut_text(void)
}
/* You can't cut the magicline except with the mark. But trying
* does clear the cutbuffer if KEEP_CUTBUFFER is not set. */
* does clear the cutbuffer if keep_cutbuffer is FALSE. */
if (current == filebot
#ifndef NANO_SMALL
&& !ISSET(MARK_ISSET)
@ -223,7 +228,7 @@ int do_cut_text(void)
)
return 0;
SET(KEEP_CUTBUFFER);
keep_cutbuffer = TRUE;
#ifndef NANO_SMALL
if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) {

View File

@ -3554,7 +3554,7 @@ int main(int argc, char *argv[])
print_view_warning();
else {
if (s->func != do_cut_text)
UNSET(KEEP_CUTBUFFER);
cutbuffer_reset();
s->func();
}
keyhandled = 1;
@ -3564,7 +3564,7 @@ int main(int argc, char *argv[])
/* And for toggle switches */
for (t = toggles; t != NULL; t = t->next)
if (kbinput == t->val) {
UNSET(KEEP_CUTBUFFER);
cutbuffer_reset();
do_toggle(t);
keyhandled = 1;
}
@ -3590,7 +3590,7 @@ int main(int argc, char *argv[])
print_view_warning();
else {
if (s->func != do_cut_text)
UNSET(KEEP_CUTBUFFER);
cutbuffer_reset();
s->func();
}
keyhandled = 1;
@ -3601,7 +3601,7 @@ int main(int argc, char *argv[])
}
if (!keyhandled)
UNSET(KEEP_CUTBUFFER);
cutbuffer_reset();
/* Don't even think about changing this string */
if (kbinput == NANO_CONTROL_Q)

View File

@ -253,36 +253,35 @@ typedef struct historyheadtype {
/* Bitwise flags so we can save space (or more correctly, not waste
* it). */
#define MODIFIED (1<<0)
#define KEEP_CUTBUFFER (1<<1)
#define CASE_SENSITIVE (1<<2)
#define MARK_ISSET (1<<3)
#define CONSTUPDATE (1<<4)
#define NO_HELP (1<<5)
#define NOFOLLOW_SYMLINKS (1<<6)
#define SUSPEND (1<<7)
#define NO_WRAP (1<<8)
#define AUTOINDENT (1<<9)
#define VIEW_MODE (1<<10)
#define USE_MOUSE (1<<11)
#define USE_REGEXP (1<<12)
#define TEMP_OPT (1<<13)
#define CUT_TO_END (1<<14)
#define REVERSE_SEARCH (1<<15)
#define MULTIBUFFER (1<<16)
#define DOS_FILE (1<<17)
#define MAC_FILE (1<<18)
#define SMOOTHSCROLL (1<<19)
#define DISABLE_CURPOS (1<<20) /* Damn, we still need it. */
#define REBIND_DELETE (1<<21)
#define NO_CONVERT (1<<22)
#define BACKUP_FILE (1<<23)
#define NO_RCFILE (1<<24)
#define COLOR_SYNTAX (1<<25)
#define PRESERVE (1<<26)
#define HISTORY_CHANGED (1<<27)
#define HISTORYLOG (1<<28)
#define RESTRICTED (1<<29)
#define SMART_HOME (1<<30)
#define CASE_SENSITIVE (1<<1)
#define MARK_ISSET (1<<2)
#define CONSTUPDATE (1<<3)
#define NO_HELP (1<<4)
#define NOFOLLOW_SYMLINKS (1<<5)
#define SUSPEND (1<<6)
#define NO_WRAP (1<<7)
#define AUTOINDENT (1<<8)
#define VIEW_MODE (1<<9)
#define USE_MOUSE (1<<10)
#define USE_REGEXP (1<<11)
#define TEMP_OPT (1<<12)
#define CUT_TO_END (1<<13)
#define REVERSE_SEARCH (1<<14)
#define MULTIBUFFER (1<<15)
#define DOS_FILE (1<<16)
#define MAC_FILE (1<<17)
#define SMOOTHSCROLL (1<<18)
#define DISABLE_CURPOS (1<<19) /* Damn, we still need it. */
#define REBIND_DELETE (1<<20)
#define NO_CONVERT (1<<21)
#define BACKUP_FILE (1<<22)
#define NO_RCFILE (1<<23)
#define COLOR_SYNTAX (1<<24)
#define PRESERVE (1<<25)
#define HISTORY_CHANGED (1<<26)
#define HISTORYLOG (1<<27)
#define RESTRICTED (1<<28)
#define SMART_HOME (1<<29)
/* Control key sequences, changing these would be very very bad. */
#define NANO_CONTROL_SPACE 0

View File

@ -142,6 +142,7 @@ void update_color(void);
#endif /* ENABLE_COLOR */
/* Public functions in cut.c */
void cutbuffer_reset(void);
filestruct *get_cutbottom(void);
void add_to_cutbuffer(filestruct *inptr, int allow_concat);
void cut_marked_segment(void);