- Tweak a few functions to remove the assumption that the file
always ends in a magicline. Changes to cut_line(),
do_cut_till_end(), open_buffer(), read_file(), write_file(),
- do_last_line(), do_para_end(), backup_lines(),
+ do_last_line(), do_para_end(), do_wrap(), backup_lines(),
find_paragraph(), do_justify(), do_alt_speller(), and
do_wordlinechar_count(). (DLR)
- Tweak a few functions to rely on fileage and filebot instead
- Only include the whole_word parameter when DISABLE_SPELLER
isn't defined, as it's only used then. (DLR)
- text.c:
+ do_wrap()
+ - Rename variable wrapping to prepending, to avoid confusion.
+ (DLR)
break_line()
- Only include the newline parameter if DISABLE_HELP isn't
defined, as it's only used then. (DLR)
/* The text after the wrap point. */
size_t after_break_len;
/* The length of after_break. */
- bool wrapping = FALSE;
+ bool prepending = FALSE;
/* Do we prepend to the next line? */
const char *next_line = NULL;
/* The next line, minus indentation. */
next_line_len = strlen(next_line);
if (after_break_len + next_line_len <= fill) {
- wrapping = TRUE;
+ prepending = TRUE;
new_line_len += next_line_len;
}
}
#ifndef NANO_TINY
if (ISSET(AUTOINDENT)) {
- if (wrapping) {
- /* If we're wrapping, the indentation will come from the
+ if (prepending) {
+ /* If we're prepending, the indentation will come from the
* next line. */
indent_string = next_line;
indent_len = indent_length(indent_string);
/* Break the current line at the wrap point. */
null_at(&line->data, wrap_loc);
- if (wrapping) {
- /* If we're wrapping, copy the text from the next line, minus
+ if (prepending) {
+ /* If we're prepending, copy the text from the next line, minus
* the indentation that we already copied above. */
strcat(new_line, next_line);
splice_node(openfile->current, make_new_node(openfile->current),
openfile->current->next);
+ if (openfile->filebot == openfile->current)
+ openfile->filebot = openfile->current->next;
+
openfile->current->next->data = new_line;
openfile->totsize++;
/* Each line knows its line number. We recalculate these if we
* inserted a new line. */
- if (!wrapping)
+ if (!prepending)
renumber(line);
/* If the cursor was after the break point, we must move it. We
* also clear the same_line_wrap flag in this case. */
if (openfile->current_x > wrap_loc) {
same_line_wrap = FALSE;
+
+ if (openfile->filebot == openfile->current)
+ openfile->filebot = openfile->current->next;
+
openfile->current = openfile->current->next;
openfile->current_x -= wrap_loc
#ifndef NANO_TINY
#ifndef NANO_TINY
/* If the mark was on this line after the wrap point, we move it
- * down. If it was on the next line and we wrapped onto that line,
+ * down. If it was on the next line and we prepended to that line,
* we move it right. */
if (openfile->mark_set) {
if (openfile->mark_begin == line && openfile->mark_begin_x >
wrap_loc) {
openfile->mark_begin = line->next;
openfile->mark_begin_x -= wrap_loc - indent_len + 1;
- } else if (wrapping && openfile->mark_begin == line->next)
+ } else if (prepending && openfile->mark_begin == line->next)
openfile->mark_begin_x += after_break_len;
}
#endif