when justifying, don't remove a space after a duplicate character in
punct anymore, as it doesn't really make us more compatible with Pico git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2369 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
7b918c76ee
commit
15540051ac
|
@ -176,9 +176,11 @@ CVS code -
|
|||
duplicating code. Also overhaul the justify code to make it
|
||||
leave the right number of spaces at the ends of the lines of a
|
||||
paragraph, to make it (partially) support multibyte
|
||||
characters, and to make it simpler. New functions
|
||||
do_para_begin_void() and do_para_end_void(); changes to
|
||||
justify_format(), do_para_begin(), inpar(), do_para_end(),
|
||||
characters, and to make it simpler. Also, don't remove a
|
||||
space after a duplicate character in punct anymore, as it
|
||||
doesn't really make us more compatible with Pico. New
|
||||
functions do_para_begin_void() and do_para_end_void(); changes
|
||||
to justify_format(), do_para_begin(), inpar(), do_para_end(),
|
||||
break_line(), do_para_search() (renamed find_paragraph()), and
|
||||
do_justify(); removal of breakable(). (DLR)
|
||||
- Still more steps toward full wide/multibyte character support.
|
||||
|
|
62
src/nano.c
62
src/nano.c
|
@ -2353,9 +2353,8 @@ size_t indent_length(const char *line)
|
|||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
/* justify_format() replaces blanks with spaces and multiple spaces by 1
|
||||
* (except it maintains 2 after a non-repeated character in punct
|
||||
* followed by a character in brackets, and removes all at the end of
|
||||
* the line).
|
||||
* (except it maintains up to 2 after a character in punct optionally
|
||||
* followed by a character in brackets, and removes all from the end).
|
||||
*
|
||||
* justify_format() might make line->data shorter, and change the actual
|
||||
* pointer with null_at().
|
||||
|
@ -2393,54 +2392,23 @@ void justify_format(filestruct *paragraph, size_t skip)
|
|||
while (*end != '\0' && is_blank_char(*end)) {
|
||||
end++;
|
||||
shift++;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (mark_beginbuf == paragraph &&
|
||||
mark_beginx >= end - paragraph->data)
|
||||
mark_shift++;
|
||||
#endif
|
||||
}
|
||||
/* If this character is punctuation, there are two ways we can
|
||||
* handle it. */
|
||||
} else if (strchr(punct, *end) != NULL) {
|
||||
*new_end = *end;
|
||||
new_end++;
|
||||
end++;
|
||||
|
||||
/* If this character is punctuation followed by itself and
|
||||
* optionally followed by a bracket, make sure there is no
|
||||
* more than one blank after it, and make sure that the
|
||||
* blank is a space. */
|
||||
if (*end != '\0' && *end == *(end - 1)) {
|
||||
*new_end = *end;
|
||||
new_end++;
|
||||
end++;
|
||||
|
||||
if (*end != '\0' && strchr(brackets, *end) != NULL) {
|
||||
*new_end = *end;
|
||||
new_end++;
|
||||
end++;
|
||||
}
|
||||
|
||||
if (*end != '\0' && is_blank_char(*end)) {
|
||||
*new_end = ' ';
|
||||
new_end++;
|
||||
end++;
|
||||
}
|
||||
|
||||
while (*end != '\0' && is_blank_char(*end)) {
|
||||
end++;
|
||||
shift++;
|
||||
#ifndef NANO_SMALL
|
||||
/* Keep track of the change in the current line. */
|
||||
if (mark_beginbuf == paragraph &&
|
||||
mark_beginx >= end - paragraph->data)
|
||||
mark_shift++;
|
||||
#endif
|
||||
}
|
||||
/* If this character is punctuation optionally followed by a
|
||||
* bracket and then followed by spaces, make sure there are
|
||||
* no more than two blanks after it, and make sure that the
|
||||
* blanks are spaces. */
|
||||
} else {
|
||||
* bracket and then followed by blanks, make sure there are no
|
||||
* more than two blanks after it, and make sure that the blanks
|
||||
* are spaces. */
|
||||
} else if (strchr(punct, *end) != NULL) {
|
||||
*new_end = *end;
|
||||
new_end++;
|
||||
end++;
|
||||
|
||||
if (*end != '\0' && strchr(brackets, *end) != NULL) {
|
||||
*new_end = *end;
|
||||
new_end++;
|
||||
|
@ -2462,13 +2430,16 @@ void justify_format(filestruct *paragraph, size_t skip)
|
|||
while (*end != '\0' && is_blank_char(*end)) {
|
||||
end++;
|
||||
shift++;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Keep track of the change in the current line. */
|
||||
if (mark_beginbuf == paragraph &&
|
||||
mark_beginx >= end - paragraph->data)
|
||||
mark_shift++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* If this character is neither blank nor punctuation, leave it
|
||||
* alone. */
|
||||
} else {
|
||||
*new_end = *end;
|
||||
new_end++;
|
||||
|
@ -2480,6 +2451,7 @@ void justify_format(filestruct *paragraph, size_t skip)
|
|||
|
||||
*new_end = *end;
|
||||
|
||||
/* Make sure that there are no spaces at the end of the line. */
|
||||
while (new_end > new_paragraph_data + skip &&
|
||||
*(new_end - 1) == ' ') {
|
||||
new_end--;
|
||||
|
|
Loading…
Reference in New Issue