Commit c833d9e8 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
parent 12e066f9
Showing with 53 additions and 45 deletions
+53 -45
...@@ -93,6 +93,9 @@ CVS code - ...@@ -93,6 +93,9 @@ CVS code -
to do_refresh so as not to conflict with refresh(). (DLR) to do_refresh so as not to conflict with refresh(). (DLR)
- Add some comments better explaining what is disabled in - Add some comments better explaining what is disabled in
restricted mode and why. (DLR) 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: - files.c:
add_open_file() add_open_file()
- Rearrange the NANO_SMALL #ifdef so that the code to set the - Rearrange the NANO_SMALL #ifdef so that the code to set the
......
...@@ -28,17 +28,22 @@ ...@@ -28,17 +28,22 @@
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
static int marked_cut; /* Is the cutbuffer from a mark? static int keep_cutbuffer = FALSE;
* 0 means whole-line cut, 1 means mark, /* Should we keep the contents of the cutbuffer? */
* 2 means cut-from-cursor. */ 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 #ifndef NANO_SMALL
static int concatenate_cut; /* Should we add this cut string to the static int concatenate_cut;
* end of the last one? */ /* Should we add this cut string to the end of the last one? */
#endif #endif
static filestruct *cutbottom = NULL; 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) filestruct *get_cutbottom(void)
{ {
...@@ -202,7 +207,7 @@ int do_cut_text(void) ...@@ -202,7 +207,7 @@ int do_cut_text(void)
check_statblank(); check_statblank();
if (!ISSET(KEEP_CUTBUFFER)) { if (!keep_cutbuffer) {
free_filestruct(cutbuffer); free_filestruct(cutbuffer);
cutbuffer = NULL; cutbuffer = NULL;
marked_cut = 0; marked_cut = 0;
...@@ -215,7 +220,7 @@ int do_cut_text(void) ...@@ -215,7 +220,7 @@ int do_cut_text(void)
} }
/* You can't cut the magicline except with the mark. But trying /* 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 if (current == filebot
#ifndef NANO_SMALL #ifndef NANO_SMALL
&& !ISSET(MARK_ISSET) && !ISSET(MARK_ISSET)
...@@ -223,7 +228,7 @@ int do_cut_text(void) ...@@ -223,7 +228,7 @@ int do_cut_text(void)
) )
return 0; return 0;
SET(KEEP_CUTBUFFER); keep_cutbuffer = TRUE;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) { if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) {
......
...@@ -3554,7 +3554,7 @@ int main(int argc, char *argv[]) ...@@ -3554,7 +3554,7 @@ int main(int argc, char *argv[])
print_view_warning(); print_view_warning();
else { else {
if (s->func != do_cut_text) if (s->func != do_cut_text)
UNSET(KEEP_CUTBUFFER); cutbuffer_reset();
s->func(); s->func();
} }
keyhandled = 1; keyhandled = 1;
...@@ -3564,7 +3564,7 @@ int main(int argc, char *argv[]) ...@@ -3564,7 +3564,7 @@ int main(int argc, char *argv[])
/* And for toggle switches */ /* And for toggle switches */
for (t = toggles; t != NULL; t = t->next) for (t = toggles; t != NULL; t = t->next)
if (kbinput == t->val) { if (kbinput == t->val) {
UNSET(KEEP_CUTBUFFER); cutbuffer_reset();
do_toggle(t); do_toggle(t);
keyhandled = 1; keyhandled = 1;
} }
...@@ -3590,7 +3590,7 @@ int main(int argc, char *argv[]) ...@@ -3590,7 +3590,7 @@ int main(int argc, char *argv[])
print_view_warning(); print_view_warning();
else { else {
if (s->func != do_cut_text) if (s->func != do_cut_text)
UNSET(KEEP_CUTBUFFER); cutbuffer_reset();
s->func(); s->func();
} }
keyhandled = 1; keyhandled = 1;
...@@ -3601,7 +3601,7 @@ int main(int argc, char *argv[]) ...@@ -3601,7 +3601,7 @@ int main(int argc, char *argv[])
} }
if (!keyhandled) if (!keyhandled)
UNSET(KEEP_CUTBUFFER); cutbuffer_reset();
/* Don't even think about changing this string */ /* Don't even think about changing this string */
if (kbinput == NANO_CONTROL_Q) if (kbinput == NANO_CONTROL_Q)
......
...@@ -253,36 +253,35 @@ typedef struct historyheadtype { ...@@ -253,36 +253,35 @@ typedef struct historyheadtype {
/* Bitwise flags so we can save space (or more correctly, not waste /* Bitwise flags so we can save space (or more correctly, not waste
* it). */ * it). */
#define MODIFIED (1<<0) #define MODIFIED (1<<0)
#define KEEP_CUTBUFFER (1<<1) #define CASE_SENSITIVE (1<<1)
#define CASE_SENSITIVE (1<<2) #define MARK_ISSET (1<<2)
#define MARK_ISSET (1<<3) #define CONSTUPDATE (1<<3)
#define CONSTUPDATE (1<<4) #define NO_HELP (1<<4)
#define NO_HELP (1<<5) #define NOFOLLOW_SYMLINKS (1<<5)
#define NOFOLLOW_SYMLINKS (1<<6) #define SUSPEND (1<<6)
#define SUSPEND (1<<7) #define NO_WRAP (1<<7)
#define NO_WRAP (1<<8) #define AUTOINDENT (1<<8)
#define AUTOINDENT (1<<9) #define VIEW_MODE (1<<9)
#define VIEW_MODE (1<<10) #define USE_MOUSE (1<<10)
#define USE_MOUSE (1<<11) #define USE_REGEXP (1<<11)
#define USE_REGEXP (1<<12) #define TEMP_OPT (1<<12)
#define TEMP_OPT (1<<13) #define CUT_TO_END (1<<13)
#define CUT_TO_END (1<<14) #define REVERSE_SEARCH (1<<14)
#define REVERSE_SEARCH (1<<15) #define MULTIBUFFER (1<<15)
#define MULTIBUFFER (1<<16) #define DOS_FILE (1<<16)
#define DOS_FILE (1<<17) #define MAC_FILE (1<<17)
#define MAC_FILE (1<<18) #define SMOOTHSCROLL (1<<18)
#define SMOOTHSCROLL (1<<19) #define DISABLE_CURPOS (1<<19) /* Damn, we still need it. */
#define DISABLE_CURPOS (1<<20) /* Damn, we still need it. */ #define REBIND_DELETE (1<<20)
#define REBIND_DELETE (1<<21) #define NO_CONVERT (1<<21)
#define NO_CONVERT (1<<22) #define BACKUP_FILE (1<<22)
#define BACKUP_FILE (1<<23) #define NO_RCFILE (1<<23)
#define NO_RCFILE (1<<24) #define COLOR_SYNTAX (1<<24)
#define COLOR_SYNTAX (1<<25) #define PRESERVE (1<<25)
#define PRESERVE (1<<26) #define HISTORY_CHANGED (1<<26)
#define HISTORY_CHANGED (1<<27) #define HISTORYLOG (1<<27)
#define HISTORYLOG (1<<28) #define RESTRICTED (1<<28)
#define RESTRICTED (1<<29) #define SMART_HOME (1<<29)
#define SMART_HOME (1<<30)
/* Control key sequences, changing these would be very very bad. */ /* Control key sequences, changing these would be very very bad. */
#define NANO_CONTROL_SPACE 0 #define NANO_CONTROL_SPACE 0
......
...@@ -142,6 +142,7 @@ void update_color(void); ...@@ -142,6 +142,7 @@ void update_color(void);
#endif /* ENABLE_COLOR */ #endif /* ENABLE_COLOR */
/* Public functions in cut.c */ /* Public functions in cut.c */
void cutbuffer_reset(void);
filestruct *get_cutbottom(void); filestruct *get_cutbottom(void);
void add_to_cutbuffer(filestruct *inptr, int allow_concat); void add_to_cutbuffer(filestruct *inptr, int allow_concat);
void cut_marked_segment(void); void cut_marked_segment(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment