break_pos = break_line(current->data + indent_len,
fill - strnlenpt(current->data, indent_len),
TRUE);
- if (break_pos == -1 || break_pos + indent_len ==
- line_len)
+ if (break_pos == -1 ||
+ break_pos + indent_len == line_len)
/* We can't break the line, or don't need to, so
* just go on to the next. */
goto continue_loc;
#endif
for (i = 0; i < kbinput_len; i++) {
+ /* Null to newline, if needed. */
+ if (kbinput[i] == '\0')
+ kbinput[i] = '\n';
+ /* Newline to Enter, if needed. */
+ else if (kbinput[i] == '\n') {
+ do_enter();
+ continue;
+ }
+
#ifdef NANO_WIDE
/* Change the wide character to its multibyte value. If it's
* invalid, go on to the next character. */
}
#endif
- /* Null to newline, if needed. */
- if (key[0] == '\0' && key_len == 1)
- key[0] = '\n';
- /* Newline to Enter, if needed. */
- else if (key[0] == '\n' && key_len == 1) {
- do_enter();
- continue;
- }
-
/* When a character is inserted on the current magicline, it
* means we need a new one! */
if (filebot == current)
#endif /* !NANO_SMALL */
}
-/* Just update one line in the edit buffer. Basically a wrapper for
- * edit_add().
+/* Just update one line in the edit buffer. This is basically a wrapper
+ * for edit_add().
*
* If fileptr != current, then index is considered 0. The line will be
* displayed starting with fileptr->data[index]. Likely args are
void update_line(const filestruct *fileptr, size_t index)
{
int line;
- /* line in the edit window for CURSES calls */
+ /* The line in the edit window that we want to update. */
char *converted;
/* fileptr->data converted to have tabs and control characters
* expanded. */
if (line < 0 || line >= editwinrows)
return;
- /* First, blank out the line (at a minimum) */
+ /* First, blank out the line. */
mvwaddstr(edit, line, 0, hblank);
/* Next, convert variables that index the line to their equivalent
index = (fileptr == current) ? strnlenpt(fileptr->data, index) : 0;
page_start = get_page_start(index);
- /* Expand the line, replacing Tab by spaces, and control characters
- * by their display form. */
+ /* Expand the line, replacing tabs with spaces, and control
+ * characters with their displayed forms. */
converted = display_string(fileptr->data, page_start, COLS);
- /* Now, paint the line */
+ /* Paint the line. */
edit_add(fileptr, converted, line, page_start);
free(converted);