tweaks: normalize the indentation after the previous change

Also rewrap two lines, reshuffle three, and improve three comments.
master
Benno Schulenberg 2020-02-17 13:35:52 +01:00
parent b3faf353c9
commit 3c4a4b04ce
1 changed files with 33 additions and 36 deletions

View File

@ -1649,65 +1649,62 @@ void inject(char *burst, size_t count)
} }
#endif #endif
/* Encode an embedded NUL byte as 0x0A. */ /* Encode an embedded NUL byte as 0x0A. */
for (size_t index = 0; index < count; index++) for (size_t index = 0; index < count; index++)
if (burst[index] == '\0') if (burst[index] == '\0')
burst[index] = '\n'; burst[index] = '\n';
#ifndef NANO_TINY #ifndef NANO_TINY
/* Only add a new undo item when the current item is not an ADD or when /* Only add a new undo item when the current item is not an ADD or when
* the current typing is not contiguous with the previous typing. */ * the current typing is not contiguous with the previous typing. */
if (openfile->last_action != ADD || if (openfile->last_action != ADD ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno || openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
openfile->current_undo->mark_begin_x != openfile->current_x) openfile->current_undo->mark_begin_x != openfile->current_x)
add_undo(ADD, NULL); add_undo(ADD, NULL);
#endif #endif
/* Make room for the new bytes and copy them into the line. */ /* Make room for the new bytes and copy them into the line. */
openfile->current->data = charealloc(openfile->current->data, openfile->current->data = charealloc(openfile->current->data,
current_len + count + 1); current_len + count + 1);
memmove(openfile->current->data + openfile->current_x + count, memmove(openfile->current->data + openfile->current_x + count,
openfile->current->data + openfile->current_x, openfile->current->data + openfile->current_x,
current_len - openfile->current_x + 1); current_len - openfile->current_x + 1);
strncpy(openfile->current->data + openfile->current_x, strncpy(openfile->current->data + openfile->current_x, burst, count);
burst, count);
openfile->totsize += mbstrlen(burst);
set_modified();
#ifndef NANO_TINY #ifndef NANO_TINY
/* Note that current_x has not yet been incremented. */ /* When the mark is to the right of the cursor, compensate its position. */
if (openfile->current == openfile->mark && if (openfile->current == openfile->mark &&
openfile->current_x < openfile->mark_x) openfile->current_x < openfile->mark_x)
openfile->mark_x += count; openfile->mark_x += count;
/* When the cursor is on the top row and not on the first chunk /* When the cursor is on the top row and not on the first chunk
* of a line, adding text there might change the preceding chunk * of a line, adding text there might change the preceding chunk
* and thus require an adjustment of firstcolumn. */ * and thus require an adjustment of firstcolumn. */
if (openfile->current == openfile->edittop && if (openfile->current == openfile->edittop && openfile->firstcolumn > 0) {
openfile->firstcolumn > 0) { ensure_firstcolumn_is_aligned();
ensure_firstcolumn_is_aligned(); refresh_needed = TRUE;
refresh_needed = TRUE; }
}
#endif #endif
/* If text was added to the magic line, create a new magic line. */
if (openfile->filebot == openfile->current && !ISSET(NO_NEWLINES)) {
new_magicline();
if (margin > 0)
refresh_needed = TRUE;
}
openfile->current_x += count; openfile->current_x += count;
/* If we've added text to the magic line, create a new magic line. */ openfile->totsize += mbstrlen(burst);
if (openfile->filebot == openfile->current && !ISSET(NO_NEWLINES)) { set_modified();
new_magicline();
if (margin > 0)
refresh_needed = TRUE;
}
#ifndef NANO_TINY #ifndef NANO_TINY
update_undo(ADD); update_undo(ADD);
#endif #endif
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
/* If text gets wrapped, the edit window needs a refresh. */ /* Wrap the line when needed, and if so, schedule a refresh. */
if (ISSET(BREAK_LONG_LINES) && do_wrap()) if (ISSET(BREAK_LONG_LINES) && do_wrap())
refresh_needed = TRUE; refresh_needed = TRUE;
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY