nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 9aa382e69e19af65f83d06a69b7c3de1c65d35c6
parent 929e1b68098d14c3143910eb4353acc33b9f6f20
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Tue, 11 Sep 2018 01:06:32 -0500

text: make justify_format() work on any buffer

The function assumes that it works on the current buffer by handling
'totsize' and the mark.  Remove this handling to make the function
more general, which is needed to make it undoable eventually.

This breaks the function somewhat.  Fixes for this are forthcoming.

Diffstat:
Msrc/text.c | 28----------------------------
1 file changed, 0 insertions(+), 28 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -1863,9 +1863,6 @@ void justify_format(filestruct *paragraph, size_t skip) { char *end, *new_end, *new_paragraph_data; size_t shift = 0; -#ifndef NANO_TINY - size_t mark_shift = 0; -#endif end = paragraph->data + skip; new_paragraph_data = charalloc(strlen(paragraph->data) + 1); @@ -1889,13 +1886,6 @@ void justify_format(filestruct *paragraph, size_t skip) end += end_len; shift += end_len; - -#ifndef NANO_TINY - /* Keep track of the change in the current line. */ - if (openfile->mark == paragraph && - openfile->mark_x >= end - paragraph->data) - mark_shift += end_len; -#endif } /* If this character is punctuation optionally followed by a * bracket and then followed by blanks, change no more than two @@ -1943,13 +1933,6 @@ void justify_format(filestruct *paragraph, size_t skip) end += end_len; shift += end_len; - -#ifndef NANO_TINY - /* Keep track of the change in the current line. */ - if (openfile->mark == paragraph && - openfile->mark_x >= end - paragraph->data) - mark_shift += end_len; -#endif } /* If this character is neither blank nor punctuation, leave it * unchanged. */ @@ -1974,20 +1957,9 @@ void justify_format(filestruct *paragraph, size_t skip) } if (shift > 0) { - openfile->totsize -= shift; null_at(&new_paragraph_data, new_end - new_paragraph_data); free(paragraph->data); paragraph->data = new_paragraph_data; - -#ifndef NANO_TINY - /* Adjust the mark coordinates to compensate for the change in - * the current line. */ - if (openfile->mark == paragraph) { - openfile->mark_x -= mark_shift; - if (openfile->mark_x > new_end - new_paragraph_data) - openfile->mark_x = new_end - new_paragraph_data; - } -#endif } else free(new_paragraph_data); }