-2015-12-03 Benno Schulenberg <bensberg@justemail.net>
+2015-12-04 Benno Schulenberg <bensberg@justemail.net>
* src/proto.h: Avoid a compilation warning.
* src/color.c (reset_multis_for_id, reset_multis_before/after):
Fuse these three functions into a single one.
+ * src/*.c: Rewrap some lines and tweak some comments.
2015-12-03 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (discard_until): Move the trimming of the undo stack
}
#endif
- /* Convert newlines to nulls, just before we insert the file
- * or execute the command. */
+ /* Convert newlines to nulls in the given filename. */
sunder(answer);
align(&answer);
/* Update the current x-coordinate to account for the
* number of characters inserted on the current line.
- * If the mark begins inside the partition, adjust the
- * mark coordinates to compensate for the change in the
- * current line. */
+ * If the mark was positioned after the cursor and on the
+ * same line, adjust the mark's coordinates to compensate
+ * for the change in this line. */
openfile->current_x = strlen(openfile->filebot->data);
if (openfile->fileage == openfile->filebot) {
#ifndef NANO_TINY
/* Match against files relative to the current working directory. */
if (matches == NULL)
- matches = cwd_tab_completion(buf, allow_files, &num_matches,
- *place);
+ matches = cwd_tab_completion(buf, allow_files, &num_matches, *place);
buf_len = strlen(buf);
#endif
while (i < output_len) {
- /* If allow_cntrls is TRUE, convert nulls and newlines
- * properly. */
+ /* If allow_cntrls is TRUE, convert nulls and newlines properly. */
if (allow_cntrls) {
/* Null to newline, if needed. */
if (output[i] == '\0')
i += char_buf_len;
- /* If allow_cntrls is FALSE, filter out an ASCII control
- * character. */
- if (!allow_cntrls && is_ascii_cntrl_char(*(output + i -
- char_buf_len)))
+ /* If allow_cntrls is FALSE, filter out an ASCII control character. */
+ if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_buf_len)))
continue;
/* If the NO_NEWLINES flag isn't set, when a character is
* added to the magicline, it means we need a new magicline. */
- if (!ISSET(NO_NEWLINES) && openfile->filebot ==
- openfile->current)
+ if (!ISSET(NO_NEWLINES) && openfile->filebot == openfile->current)
new_magicline();
/* More dangerousness fun =) */
openfile->current->data = charealloc(openfile->current->data,
- current_len + (char_buf_len * 2));
+ current_len + (char_buf_len * 2));
assert(openfile->current_x <= current_len);
- charmove(openfile->current->data + openfile->current_x +
- char_buf_len, openfile->current->data +
- openfile->current_x, current_len - openfile->current_x +
- char_buf_len);
+ charmove(openfile->current->data + openfile->current_x + char_buf_len,
+ openfile->current->data + openfile->current_x,
+ current_len - openfile->current_x + char_buf_len);
strncpy(openfile->current->data + openfile->current_x, char_buf,
char_buf_len);
current_len += char_buf_len;
add_undo(ADD);
/* Note that current_x has not yet been incremented. */
- if (openfile->mark_set && openfile->current ==
- openfile->mark_begin && openfile->current_x <
- openfile->mark_begin_x)
+ if (openfile->mark_set && openfile->current == openfile->mark_begin &&
+ openfile->current_x < openfile->mark_begin_x)
openfile->mark_begin_x += char_buf_len;
#endif
/* When the join was done by a Backspace at the tail of the file,
* and the nonewlines flag isn't set, do not re-add a newline that
* wasn't actually deleted; just position the cursor. */
- if (u->xflags == WAS_FINAL_BACKSPACE && !ISSET(NO_NEWLINES)) {
+ if (u->xflags == WAS_FINAL_BACKSPACE && !ISSET(NO_NEWLINES)) {
goto_line_posx(openfile->filebot->lineno, 0);
break;
}
return;
}
#ifdef DEBUG
- fprintf(stderr, "data we're about to redo = \"%s\"\n", f->data);
- fprintf(stderr, "Redo running for type %d\n", u->type);
+ fprintf(stderr, " >> Redo running for type %d\n", u->type);
+ fprintf(stderr, " >> Data we're about to redo = \"%s\"\n", f->data);
#endif
switch (u->type) {
} else
u->xflags = WAS_MARKED_FORWARD;
} else {
- /* Compute cutbottom for the uncut using our copy. */
+ /* Compute the end of the cut for the undo, using our copy. */
u->cutbottom = u->cutbuffer;
while (u->cutbottom->next != NULL)
u->cutbottom = u->cutbottom->next;
- u->lineno = u->mark_begin_lineno + u->cutbottom->lineno - u->cutbuffer->lineno;
+ u->lineno = u->mark_begin_lineno + u->cutbottom->lineno -
+ u->cutbuffer->lineno;
if (ISSET(CUT_TO_END) || u->type == CUT_EOF) {
u->begin = strlen(u->cutbottom->data);
if (u->lineno == u->mark_begin_lineno)
}
/* Copy the first n characters of one malloc()ed string to another
- * pointer. Should be used as: "dest = mallocstrncpy(dest, src,
- * n);". */
+ * pointer. Should be used as: "dest = mallocstrncpy(dest, src, n);". */
char *mallocstrncpy(char *dest, const char *src, size_t n)
{
if (src == NULL)
* "dest = mallocstrcpy(dest, src);". */
char *mallocstrcpy(char *dest, const char *src)
{
- return mallocstrncpy(dest, src, (src == NULL) ? 1 :
- strlen(src) + 1);
+ return mallocstrncpy(dest, src, (src == NULL) ? 1 : strlen(src) + 1);
}
/* Free the malloc()ed string at dest and return the malloc()ed string
26;
}
-/* Display the shortcut list in s on the last two rows of the bottom
- * portion of the window. */
+/* Display the shortcut list corresponding to menu on the last two rows
+ * of the bottom portion of the window. */
void bottombars(int menu)
{
size_t i, colwidth, slen;