From 44e7f82e0ed3c6e51ae26ec98b01bf44dbc5deb0 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Tue, 30 Mar 2004 04:17:10 +0000 Subject: [PATCH] minor tweaks; also remove the need for the JUSTIFY_MODE flag git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1703 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 9 +++++++++ src/cut.c | 16 ++++++++-------- src/nano.c | 16 +++++++--------- src/nano.h | 1 - src/proto.h | 2 +- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2cfedb3..e6f4448c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -45,6 +45,10 @@ CVS code - - Rename several variables to make their use clearer and to avoid conflicts. (DLR) - Set the input mode before turning the keypad on. (DLR) +- cut.c: + add_to_cutbuffer() + - Add parameter allow_concat to determine whether we're allowed + to concatenate strings in the cutbuffer. (DLR) - files.c: do_insertfile() - Wrap one reference to NANO_EXTCMD_KEY in a NANO_SMALL #ifdef. @@ -96,6 +100,10 @@ CVS code - bracket_mode set to TRUE even though we aren't doing a bracket search, since after the above efficiency tweaks, it's now more accurately called can_display_wrap. (DLR) + indent_length() + - Remove unneeded #ifdef. (David Benbennick) + do_justify() + - Remove references to the now-unneeded JUSTIFY_MODE flag. (DLR) signal_init() - Trap SIGQUIT in addition to turning it off via termios in main(). This is consistent with SIGINT, which we trap here @@ -120,6 +128,7 @@ CVS code - - nano.h: - Move the NANO_H include guard up before the first #include. (DLR) + - Remove the now-unneeded JUSTIFY_MODE flag. (DLR) - search.c: regexp_cleanup() - Only do anything if REGEXP_COMPILED is set. (David Benbennick) diff --git a/src/cut.c b/src/cut.c index 40295800..e7b561df 100644 --- a/src/cut.c +++ b/src/cut.c @@ -45,7 +45,7 @@ filestruct *get_cutbottom(void) return cutbottom; } -void add_to_cutbuffer(filestruct *inptr) +void add_to_cutbuffer(filestruct *inptr, int allow_concat) { #ifdef DEBUG fprintf(stderr, "add_to_cutbuffer(): inptr->data = %s\n", inptr->data); @@ -54,9 +54,9 @@ void add_to_cutbuffer(filestruct *inptr) if (cutbuffer == NULL) cutbuffer = inptr; #ifndef NANO_SMALL - else if (concatenate_cut && !ISSET(JUSTIFY_MODE)) { + else if (allow_concat && concatenate_cut) { /* Just tack the text in inptr onto the text in cutbottom, - * unless we're backing up lines while justifying text. */ + * unless allow_concat is false. */ cutbottom->data = charealloc(cutbottom->data, strlen(cutbottom->data) + strlen(inptr->data) + 1); strcat(cutbottom->data, inptr->data); @@ -207,7 +207,7 @@ int do_cut_text(void) cutbuffer = NULL; marked_cut = 0; #ifndef NANO_SMALL - concatenate_cut = 0; + concatenate_cut = FALSE; #endif #ifdef DEBUG fprintf(stderr, "Blew away cutbuffer =)\n"); @@ -238,7 +238,7 @@ int do_cut_text(void) junk->data = charalloc(1); junk->data[0] = '\0'; - add_to_cutbuffer(junk); + add_to_cutbuffer(junk, TRUE); #ifdef DEBUG dump_buffer(cutbuffer); #endif @@ -265,7 +265,7 @@ int do_cut_text(void) * the first line of any cut done immediately afterward to the * end of this cut, as Pico does. */ if (current == mark_beginbuf && current_x < strlen(current->data)) - concatenate_cut = 1; + concatenate_cut = TRUE; marked_cut = 1; edit_refresh(); set_modified(); @@ -279,7 +279,7 @@ int do_cut_text(void) fileptr = current; current = current->next; current->prev = fileptr->prev; - add_to_cutbuffer(fileptr); + add_to_cutbuffer(fileptr, TRUE); #ifdef DEBUG dump_buffer(cutbuffer); #endif @@ -298,7 +298,7 @@ int do_cut_text(void) set_modified(); marked_cut = 0; #ifndef NANO_SMALL - concatenate_cut = 0; + concatenate_cut = FALSE; #endif return 1; } diff --git a/src/nano.c b/src/nano.c index 79debfd6..3b1c1eb6 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1881,7 +1881,7 @@ int do_spell(void) #endif } -#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY) +#if !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY) /* The "indentation" of a line is the white-space between the quote part * and the non-white-space of the line. */ size_t indent_length(const char *line) @@ -1895,7 +1895,7 @@ size_t indent_length(const char *line) } return len; } -#endif /* !DISABLE_WRAPPING && !NANO_SMALL || !DISABLE_JUSTIFY */ +#endif /* !NANO_SMALL || !DISABLE_JUSTIFY */ #ifndef DISABLE_JUSTIFY /* justify_format() replaces Tab by Space and multiple spaces by 1 (except @@ -2041,9 +2041,9 @@ size_t indents_match(const char *a_line, size_t a_indent, } /* Put the next par_len lines, starting with first_line, in the cut - * buffer. We assume there are enough lines after first_line. We leave - * copies of the lines in place, too. We return the new copy of - * first_line. */ + * buffer, not allowing them to be concatenated. We assume there are + * enough lines after first_line. We leave copies of the lines in + * place, too. We return the new copy of first_line. */ filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t quote_len) { @@ -2071,7 +2071,7 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len, quote_len + indent_length(bob->data + quote_len)); assert(alice != NULL && bob != NULL); - add_to_cutbuffer(alice); + add_to_cutbuffer(alice, FALSE); splice_node(bob->prev, bob, bob->next); alice = bob->next; } @@ -2457,7 +2457,6 @@ int do_justify(void) /* Next step, we loop through the lines of this paragraph, justifying * each one individually. */ - SET(JUSTIFY_MODE); for (; par_len > 0; current_y++, par_len--) { size_t line_len; size_t display_len; @@ -2609,7 +2608,6 @@ int do_justify(void) continue_loc: current = current->next; } - UNSET(JUSTIFY_MODE); /* We are now done justifying the paragraph. There are cleanup things * to do, and we check for unjustify. */ @@ -2669,7 +2667,7 @@ int do_justify(void) if (first_mod_line != NULL) { filestruct *cutbottom = get_cutbottom(); - /* Splice the cutbuffer back into the file. */ + /* Splice the cut buffer back into the file. */ cutbottom->next = last_par_line->next; cutbottom->next->prev = cutbottom; /* The line numbers after the end of the paragraph have diff --git a/src/nano.h b/src/nano.h index 1e998703..2649ed3f 100644 --- a/src/nano.h +++ b/src/nano.h @@ -296,7 +296,6 @@ typedef struct historyheadtype { #define PRESERVE (1<<27) #define HISTORY_CHANGED (1<<28) #define HISTORYLOG (1<<29) -#define JUSTIFY_MODE (1<<30) /* Control key sequences, changing these would be very very bad. */ #define NANO_CONTROL_SPACE 0 diff --git a/src/proto.h b/src/proto.h index 0e0ffb80..70556739 100644 --- a/src/proto.h +++ b/src/proto.h @@ -143,7 +143,7 @@ void update_color(void); /* Public functions in cut.c */ filestruct *get_cutbottom(void); -void add_to_cutbuffer(filestruct *inptr); +void add_to_cutbuffer(filestruct *inptr, int allow_concat); void cut_marked_segment(void); int do_cut_text(void); int do_uncut_text(void); -- 2.39.5