inpar(), backup_lines(), find_paragraph(), do_justify(),
do_justify_void(), do_full_justify(), and do_word_count() (all
moved to text.c). (DLR)
+ - Since the total number of lines in a file is the same as the
+ number of its last line when all its lines are numbered
+ properly, use that in place of openfile->totlines, and
+ eliminate references to openfile->totlines. Changes to
+ initialize_buffer_text(), read_file(), move_to_filestruct(),
+ copy_from_filestruct(), do_delete(), do_enter(), do_wrap(),
+ do_justify(), do_alt_speller(), do_wordlinechar_count(),
+ new_magicline(), remove_magicline(), and do_cursorpos(). (DLR)
- color.c:
- Remove unneeded string.h and fcntl.h includes. (DLR)
- chars.c:
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
- openfile->totlines = 1;
openfile->totsize = 0;
}
#endif
statusbar(P_("Read %lu line", "Read %lu lines",
(unsigned long)num_lines), (unsigned long)num_lines);
-
- openfile->totlines += num_lines;
}
/* Open the file (and decide if it exists). If newfie is TRUE, display
if (openfile->filebot->data[0] != '\0')
new_magicline();
-
- /* Set totlines to the new number of lines in the file. */
- openfile->totlines = openfile->filebot->lineno;
}
/* Copy all the text from the filestruct beginning with file_top and
if (openfile->filebot->data[0] != '\0')
new_magicline();
-
- /* Set totlines to the new number of lines in the file. */
- openfile->totlines = openfile->filebot->lineno;
}
/* Create a new openfilestruct node. */
filestruct *filebot; /* Current file's last line. */
filestruct *edittop; /* Current top of edit window. */
filestruct *current; /* Current file's line. */
- size_t totlines; /* Current file's total number of
- * lines. */
- size_t totsize; /* Current file's total size. */
+ size_t totsize; /* Current file's total number of
+ * characters. */
size_t current_x; /* Current file's x-coordinate
* position. */
size_t placewewant; /* Current file's place we want. */
unlink_node(foo);
delete_node(foo);
renumber(openfile->current);
- openfile->totlines--;
openfile->totsize--;
#ifndef DISABLE_WRAPPING
wrap_reset();
edit_refresh();
- openfile->totlines++;
openfile->totsize++;
set_modified();
openfile->placewewant = xplustabs();
openfile->current->next->data = new_line;
- openfile->totlines++;
openfile->totsize++;
}
/* Will be the line containing the newline after the last line
* of the result. Also for restoring after unjustify. */
- /* We save these variables to be restored if the user unjustifies.
- * Note that we don't need to save totlines. */
+ /* We save these variables to be restored if the user
+ * unjustifies. */
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
ssize_t current_y_save = openfile->current_y;
i--;
par_len--;
- openfile->totlines--;
openfile->totsize--;
}
openfile->current->data + break_pos);
par_len++;
- openfile->totlines++;
openfile->totsize += indent_len + 1;
#ifndef NANO_SMALL
}
/* We are now done justifying the paragraph or the file, so clean
- * up. totlines, totsize, and current_y have been maintained above.
- * Set last_par_line to the new end of the paragraph, update
- * fileage, and renumber since edit_refresh() needs the line numbers
- * to be right (but only do the last two if we actually justified
+ * up. totsize, and current_y have been maintained above. Set
+ * last_par_line to the new end of the paragraph, update fileage,
+ * and renumber, since edit_refresh() needs the line numbers to be
+ * right (but only do the last two if we actually justified
* something). */
last_par_line = openfile->current;
if (first_par_line != NULL) {
/* Restore variables from before the justify. */
openfile->totsize = totsize_save;
- openfile->totlines = openfile->filebot->lineno;
#ifndef NANO_SMALL
if (openfile->mark_set) {
openfile->mark_begin = mark_begin_save;
unpartition_filestruct(&filepart);
/* Renumber starting with the beginning line of the old
- * partition. Also set totlines to the new number of lines in
- * the file, add the number of characters in the spell-checked
- * marked text to the saved value of totsize, and then make that
- * saved value the actual value. */
+ * partition. Also add the number of characters in the
+ * spell-checked marked text to the saved value of totsize, and
+ * then make that saved value the actual value. */
renumber(top_save);
- openfile->totlines = openfile->filebot->lineno;
totsize_save += openfile->totsize;
openfile->totsize = totsize_save;
#ifndef NANO_SMALL
void do_wordlinechar_count(void)
{
- size_t words = 0, lines = 0, chars = 0;
+ size_t words = 0, chars = 0;
+ ssize_t lines = 0;
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
filestruct *current_save = openfile->current;
unpartition_filestruct(&filepart);
openfile->mark_set = TRUE;
} else {
- lines = openfile->totlines;
+ lines = openfile->filebot->lineno;
chars = openfile->totsize;
}
/* Display the total word, line, and character counts on the
* statusbar. */
- statusbar("%sWords: %lu Lines: %lu Chars: %lu", old_mark_set ?
- _("(In Selection) ") : "", (unsigned long)words,
- (unsigned long)lines, (unsigned long)chars);
+ statusbar("%sWords: %lu Lines: %ld Chars: %lu", old_mark_set ?
+ _("(In Selection) ") : "", (unsigned long)words, (long)lines,
+ (unsigned long)chars);
}
#endif /* !NANO_SMALL */
openfile->filebot->next->next = NULL;
openfile->filebot->next->lineno = openfile->filebot->lineno + 1;
openfile->filebot = openfile->filebot->next;
- openfile->totlines++;
openfile->totsize++;
}
openfile->filebot = openfile->filebot->prev;
free_filestruct(openfile->filebot->next);
openfile->filebot->next = NULL;
- openfile->totlines--;
openfile->totsize--;
}
}
size_t cur_lenpt = strlenpt(openfile->current->data) + 1;
int linepct, colpct, charpct;
- assert(openfile->current != NULL && openfile->fileage != NULL && openfile->totlines != 0);
+ assert(openfile->current != NULL && openfile->fileage != NULL);
c = openfile->current->data[openfile->current_x];
f = openfile->current->next;
/* Display the current cursor position on the statusbar, and set
* disable_cursorpos to FALSE. */
- linepct = 100 * openfile->current->lineno / openfile->totlines;
+ linepct = 100 * openfile->current->lineno /
+ openfile->filebot->lineno;
colpct = 100 * cur_xpt / cur_lenpt;
charpct = (openfile->totsize == 0) ? 0 : 100 * i /
openfile->totsize;
statusbar(
- _("line %ld/%lu (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"),
+ _("line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"),
(long)openfile->current->lineno,
- (unsigned long)openfile->totlines, linepct,
+ (long)openfile->filebot->lineno, linepct,
(unsigned long)cur_xpt, (unsigned long)cur_lenpt, colpct,
(unsigned long)i, (unsigned long)openfile->totsize, charpct);