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
master
David Lawrence Ramsey 2004-03-30 04:17:10 +00:00
parent 0b047c561d
commit 44e7f82e0e
5 changed files with 25 additions and 19 deletions

View File

@ -45,6 +45,10 @@ CVS code -
- Rename several variables to make their use clearer and to - Rename several variables to make their use clearer and to
avoid conflicts. (DLR) avoid conflicts. (DLR)
- Set the input mode before turning the keypad on. (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: - files.c:
do_insertfile() do_insertfile()
- Wrap one reference to NANO_EXTCMD_KEY in a NANO_SMALL #ifdef. - 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 bracket_mode set to TRUE even though we aren't doing a bracket
search, since after the above efficiency tweaks, it's now more search, since after the above efficiency tweaks, it's now more
accurately called can_display_wrap. (DLR) 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() signal_init()
- Trap SIGQUIT in addition to turning it off via termios in - Trap SIGQUIT in addition to turning it off via termios in
main(). This is consistent with SIGINT, which we trap here main(). This is consistent with SIGINT, which we trap here
@ -120,6 +128,7 @@ CVS code -
- nano.h: - nano.h:
- Move the NANO_H include guard up before the first #include. - Move the NANO_H include guard up before the first #include.
(DLR) (DLR)
- Remove the now-unneeded JUSTIFY_MODE flag. (DLR)
- search.c: - search.c:
regexp_cleanup() regexp_cleanup()
- Only do anything if REGEXP_COMPILED is set. (David Benbennick) - Only do anything if REGEXP_COMPILED is set. (David Benbennick)

View File

@ -45,7 +45,7 @@ filestruct *get_cutbottom(void)
return cutbottom; return cutbottom;
} }
void add_to_cutbuffer(filestruct *inptr) void add_to_cutbuffer(filestruct *inptr, int allow_concat)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "add_to_cutbuffer(): inptr->data = %s\n", inptr->data); fprintf(stderr, "add_to_cutbuffer(): inptr->data = %s\n", inptr->data);
@ -54,9 +54,9 @@ void add_to_cutbuffer(filestruct *inptr)
if (cutbuffer == NULL) if (cutbuffer == NULL)
cutbuffer = inptr; cutbuffer = inptr;
#ifndef NANO_SMALL #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, /* 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, cutbottom->data = charealloc(cutbottom->data,
strlen(cutbottom->data) + strlen(inptr->data) + 1); strlen(cutbottom->data) + strlen(inptr->data) + 1);
strcat(cutbottom->data, inptr->data); strcat(cutbottom->data, inptr->data);
@ -207,7 +207,7 @@ int do_cut_text(void)
cutbuffer = NULL; cutbuffer = NULL;
marked_cut = 0; marked_cut = 0;
#ifndef NANO_SMALL #ifndef NANO_SMALL
concatenate_cut = 0; concatenate_cut = FALSE;
#endif #endif
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Blew away cutbuffer =)\n"); fprintf(stderr, "Blew away cutbuffer =)\n");
@ -238,7 +238,7 @@ int do_cut_text(void)
junk->data = charalloc(1); junk->data = charalloc(1);
junk->data[0] = '\0'; junk->data[0] = '\0';
add_to_cutbuffer(junk); add_to_cutbuffer(junk, TRUE);
#ifdef DEBUG #ifdef DEBUG
dump_buffer(cutbuffer); dump_buffer(cutbuffer);
#endif #endif
@ -265,7 +265,7 @@ int do_cut_text(void)
* the first line of any cut done immediately afterward to the * the first line of any cut done immediately afterward to the
* end of this cut, as Pico does. */ * end of this cut, as Pico does. */
if (current == mark_beginbuf && current_x < strlen(current->data)) if (current == mark_beginbuf && current_x < strlen(current->data))
concatenate_cut = 1; concatenate_cut = TRUE;
marked_cut = 1; marked_cut = 1;
edit_refresh(); edit_refresh();
set_modified(); set_modified();
@ -279,7 +279,7 @@ int do_cut_text(void)
fileptr = current; fileptr = current;
current = current->next; current = current->next;
current->prev = fileptr->prev; current->prev = fileptr->prev;
add_to_cutbuffer(fileptr); add_to_cutbuffer(fileptr, TRUE);
#ifdef DEBUG #ifdef DEBUG
dump_buffer(cutbuffer); dump_buffer(cutbuffer);
#endif #endif
@ -298,7 +298,7 @@ int do_cut_text(void)
set_modified(); set_modified();
marked_cut = 0; marked_cut = 0;
#ifndef NANO_SMALL #ifndef NANO_SMALL
concatenate_cut = 0; concatenate_cut = FALSE;
#endif #endif
return 1; return 1;
} }

View File

@ -1881,7 +1881,7 @@ int do_spell(void)
#endif #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 /* The "indentation" of a line is the white-space between the quote part
* and the non-white-space of the line. */ * and the non-white-space of the line. */
size_t indent_length(const char *line) size_t indent_length(const char *line)
@ -1895,7 +1895,7 @@ size_t indent_length(const char *line)
} }
return len; return len;
} }
#endif /* !DISABLE_WRAPPING && !NANO_SMALL || !DISABLE_JUSTIFY */ #endif /* !NANO_SMALL || !DISABLE_JUSTIFY */
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
/* justify_format() replaces Tab by Space and multiple spaces by 1 (except /* 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 /* 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 * buffer, not allowing them to be concatenated. We assume there are
* copies of the lines in place, too. We return the new copy of * enough lines after first_line. We leave copies of the lines in
* first_line. */ * place, too. We return the new copy of first_line. */
filestruct *backup_lines(filestruct *first_line, size_t par_len, filestruct *backup_lines(filestruct *first_line, size_t par_len,
size_t quote_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)); quote_len + indent_length(bob->data + quote_len));
assert(alice != NULL && bob != NULL); assert(alice != NULL && bob != NULL);
add_to_cutbuffer(alice); add_to_cutbuffer(alice, FALSE);
splice_node(bob->prev, bob, bob->next); splice_node(bob->prev, bob, bob->next);
alice = bob->next; alice = bob->next;
} }
@ -2457,7 +2457,6 @@ int do_justify(void)
/* Next step, we loop through the lines of this paragraph, justifying /* Next step, we loop through the lines of this paragraph, justifying
* each one individually. */ * each one individually. */
SET(JUSTIFY_MODE);
for (; par_len > 0; current_y++, par_len--) { for (; par_len > 0; current_y++, par_len--) {
size_t line_len; size_t line_len;
size_t display_len; size_t display_len;
@ -2609,7 +2608,6 @@ int do_justify(void)
continue_loc: continue_loc:
current = current->next; current = current->next;
} }
UNSET(JUSTIFY_MODE);
/* We are now done justifying the paragraph. There are cleanup things /* We are now done justifying the paragraph. There are cleanup things
* to do, and we check for unjustify. */ * to do, and we check for unjustify. */
@ -2669,7 +2667,7 @@ int do_justify(void)
if (first_mod_line != NULL) { if (first_mod_line != NULL) {
filestruct *cutbottom = get_cutbottom(); 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 = last_par_line->next;
cutbottom->next->prev = cutbottom; cutbottom->next->prev = cutbottom;
/* The line numbers after the end of the paragraph have /* The line numbers after the end of the paragraph have

View File

@ -296,7 +296,6 @@ typedef struct historyheadtype {
#define PRESERVE (1<<27) #define PRESERVE (1<<27)
#define HISTORY_CHANGED (1<<28) #define HISTORY_CHANGED (1<<28)
#define HISTORYLOG (1<<29) #define HISTORYLOG (1<<29)
#define JUSTIFY_MODE (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

View File

@ -143,7 +143,7 @@ void update_color(void);
/* Public functions in cut.c */ /* Public functions in cut.c */
filestruct *get_cutbottom(void); filestruct *get_cutbottom(void);
void add_to_cutbuffer(filestruct *inptr); void add_to_cutbuffer(filestruct *inptr, int allow_concat);
void cut_marked_segment(void); void cut_marked_segment(void);
int do_cut_text(void); int do_cut_text(void);
int do_uncut_text(void); int do_uncut_text(void);