tweaks: rename a struct element, to make sense

master
Benno Schulenberg 2019-03-21 17:23:49 +01:00
parent 6755b7c0a0
commit cddfcb1b9d
11 changed files with 74 additions and 74 deletions

View File

@ -217,7 +217,7 @@ void color_update(void)
/* If the filename didn't match anything, try the first line. */
if (sint == NULL && !inhelp) {
for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (found_in_list(sint->headers, openfile->fileage->data))
if (found_in_list(sint->headers, openfile->filetop->data))
break;
}
}
@ -364,7 +364,7 @@ void precalc_multicolorinfo(void)
if (ink->end == NULL)
continue;
for (line = openfile->fileage; line != NULL; line = line->next) {
for (line = openfile->filetop; line != NULL; line = line->next) {
int index = 0;
alloc_multidata_if_needed(line);

View File

@ -134,7 +134,7 @@ void do_backspace(void)
zap_text();
else
#endif
if (openfile->current != openfile->fileage || openfile->current_x > 0) {
if (openfile->current != openfile->filetop || openfile->current_x > 0) {
do_left();
do_deletion(BACK);
}

View File

@ -117,12 +117,12 @@ void make_new_buffer(void)
/* Initialize the text and pointers of the current openfile struct. */
void initialize_buffer_text(void)
{
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filetop = make_new_node(NULL);
openfile->filetop->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
openfile->filebot = openfile->filetop;
openfile->edittop = openfile->filetop;
openfile->current = openfile->filetop;
openfile->firstcolumn = 0;
openfile->current_x = 0;
@ -490,7 +490,7 @@ bool open_buffer(const char *filename, bool new_buffer)
* the filename and put the cursor at the start of the buffer. */
if (rc != -1 && new_buffer) {
openfile->filename = mallocstrcpy(openfile->filename, realname);
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = 0;
openfile->placewewant = 0;
}
@ -528,7 +528,7 @@ void replace_buffer(const char *filename)
/* Throw away the text of the file. */
cutbuffer = NULL;
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = 0;
#ifndef NANO_TINY
add_undo(CUT_TO_EOF);
@ -603,7 +603,7 @@ void prepare_for_display(void)
/* If there are multiline coloring regexes, and there is no
* multiline cache data yet, precalculate it now. */
if (openfile->syntax && openfile->syntax->nmultis > 0 &&
openfile->fileage->multidata == NULL)
openfile->filetop->multidata == NULL)
precalc_multicolorinfo();
have_palette = FALSE;
@ -1201,7 +1201,7 @@ void do_insertfile(void)
#ifdef ENABLE_MULTIBUFFER
/* If this is a new buffer, put the cursor at the top. */
if (ISSET(MULTIBUFFER)) {
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = 0;
openfile->placewewant = 0;
@ -1593,7 +1593,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
/* Instead of returning in this function, you should always
* set retval and then goto cleanup_and_exit. */
size_t lineswritten = 0;
const linestruct *fileptr = openfile->fileage;
const linestruct *fileptr = openfile->filetop;
int fd;
/* The file descriptor we use. */
mode_t original_umask = 0;
@ -1999,7 +1999,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
/* If the syntax changed, discard and recompute the multidata. */
if (strcmp(oldname, newname) != 0) {
linestruct *line = openfile->fileage;
linestruct *line = openfile->filetop;
while (line != NULL) {
free(line->multidata);

View File

@ -231,7 +231,7 @@ void do_help(void)
edit_refresh();
location = 0;
line = openfile->fileage;
line = openfile->filetop;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {

View File

@ -26,7 +26,7 @@
/* Move to the first line of the file. */
void to_first_line(void)
{
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = 0;
openfile->placewewant = 0;
@ -572,7 +572,7 @@ void do_left(void)
if (openfile->current_x > 0)
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->fileage) {
else if (openfile->current != openfile->filetop) {
openfile->current = openfile->current->prev;
openfile->current_x = strlen(openfile->current->data);
}

View File

@ -205,11 +205,11 @@ partition *partition_buffer(linestruct *top, size_t top_x,
/* If the top and bottom of the partition are different from the top
* and bottom of the buffer, save the latter and then set them
* to top and bot. */
if (top != openfile->fileage) {
p->fileage = openfile->fileage;
openfile->fileage = top;
if (top != openfile->filetop) {
p->filetop = openfile->filetop;
openfile->filetop = top;
} else
p->fileage = NULL;
p->filetop = NULL;
if (bot != openfile->filebot) {
p->filebot = openfile->filebot;
openfile->filebot = bot;
@ -239,21 +239,21 @@ partition *partition_buffer(linestruct *top, size_t top_x,
return p;
}
/* Unpartition the current buffer so that it stretches from (fileage, 0)
/* Unpartition the current buffer so that it stretches from (filetop, 0)
* to (filebot, $) again. */
void unpartition_buffer(partition **p)
{
/* Reattach the line above the top of the partition, and restore the
* text before top_x from top_data. Free top_data when we're done
* with it. */
openfile->fileage->prev = (*p)->top_prev;
if (openfile->fileage->prev != NULL)
openfile->fileage->prev->next = openfile->fileage;
openfile->fileage->data = charealloc(openfile->fileage->data,
strlen((*p)->top_data) + strlen(openfile->fileage->data) + 1);
charmove(openfile->fileage->data + strlen((*p)->top_data),
openfile->fileage->data, strlen(openfile->fileage->data) + 1);
strncpy(openfile->fileage->data, (*p)->top_data, strlen((*p)->top_data));
openfile->filetop->prev = (*p)->top_prev;
if (openfile->filetop->prev != NULL)
openfile->filetop->prev->next = openfile->filetop;
openfile->filetop->data = charealloc(openfile->filetop->data,
strlen((*p)->top_data) + strlen(openfile->filetop->data) + 1);
charmove(openfile->filetop->data + strlen((*p)->top_data),
openfile->filetop->data, strlen(openfile->filetop->data) + 1);
strncpy(openfile->filetop->data, (*p)->top_data, strlen((*p)->top_data));
free((*p)->top_data);
/* Reattach the line below the bottom of the partition, and restore
@ -269,8 +269,8 @@ void unpartition_buffer(partition **p)
/* Restore the top and bottom of the buffer, if they were
* different from the top and bottom of the partition. */
if ((*p)->fileage != NULL)
openfile->fileage = (*p)->fileage;
if ((*p)->filetop != NULL)
openfile->filetop = (*p)->filetop;
if ((*p)->filebot != NULL)
openfile->filebot = (*p)->filebot;
@ -302,17 +302,17 @@ void extract_buffer(linestruct **file_top, linestruct **file_bot,
* the edit window is inside the partition, and keep track of
* whether the mark begins inside the partition. */
filepart = partition_buffer(top, top_x, bot, bot_x);
edittop_inside = (openfile->edittop->lineno >= openfile->fileage->lineno &&
edittop_inside = (openfile->edittop->lineno >= openfile->filetop->lineno &&
openfile->edittop->lineno <= openfile->filebot->lineno);
#ifndef NANO_TINY
if (openfile->mark) {
mark_inside = (openfile->mark->lineno >= openfile->fileage->lineno &&
mark_inside = (openfile->mark->lineno >= openfile->filetop->lineno &&
openfile->mark->lineno <= openfile->filebot->lineno &&
(openfile->mark != openfile->fileage ||
(openfile->mark != openfile->filetop ||
openfile->mark_x >= top_x) &&
(openfile->mark != openfile->filebot ||
openfile->mark_x <= bot_x));
same_line = (openfile->mark == openfile->fileage);
same_line = (openfile->mark == openfile->filetop);
}
#endif
@ -323,7 +323,7 @@ void extract_buffer(linestruct **file_top, linestruct **file_bot,
/* If file_top is empty, just move all the text directly into
* it. This is equivalent to tacking the text in top onto the
* (lack of) text at the end of file_top. */
*file_top = openfile->fileage;
*file_top = openfile->filetop;
*file_bot = openfile->filebot;
/* Renumber, starting with file_top. */
@ -335,33 +335,33 @@ void extract_buffer(linestruct **file_top, linestruct **file_bot,
* file_bot. */
(*file_bot)->data = charealloc((*file_bot)->data,
strlen((*file_bot)->data) +
strlen(openfile->fileage->data) + 1);
strcat((*file_bot)->data, openfile->fileage->data);
strlen(openfile->filetop->data) + 1);
strcat((*file_bot)->data, openfile->filetop->data);
/* Attach the line after top to the line after file_bot. Then,
* if there's more than one line after top, move file_bot down
* to bot. */
(*file_bot)->next = openfile->fileage->next;
(*file_bot)->next = openfile->filetop->next;
if ((*file_bot)->next != NULL) {
(*file_bot)->next->prev = *file_bot;
*file_bot = openfile->filebot;
}
delete_node(openfile->fileage);
delete_node(openfile->filetop);
/* Renumber, starting at the last line of the original buffer. */
renumber(file_bot_save);
}
/* Since the text has now been saved, remove it from the buffer. */
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
openfile->filetop = make_new_node(NULL);
openfile->filetop->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->filetop;
/* Restore the current line and cursor position. If the mark begins
* inside the partition, set the beginning of the mark to where the
* saved text used to start. */
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = top_x;
#ifndef NANO_TINY
if (mark_inside) {
@ -372,7 +372,7 @@ void extract_buffer(linestruct **file_top, linestruct **file_bot,
openfile->mark = openfile->current;
#endif
top_save = openfile->fileage;
top_save = openfile->filetop;
/* Unpartition the buffer so that it contains all the text
* again, minus the saved text. */
@ -422,13 +422,13 @@ void ingraft_buffer(linestruct *somebuffer)
* whether the current line is at the top of the edit window. */
filepart = partition_buffer(openfile->current, openfile->current_x,
openfile->current, openfile->current_x);
edittop_inside = (openfile->edittop == openfile->fileage);
free_lines(openfile->fileage);
edittop_inside = (openfile->edittop == openfile->filetop);
free_lines(openfile->filetop);
/* Put the top and bottom of the current buffer at the top and
* bottom of the passed buffer. */
openfile->fileage = somebuffer;
openfile->filebot = openfile->fileage;
openfile->filetop = somebuffer;
openfile->filebot = openfile->filetop;
while (openfile->filebot->next != NULL)
openfile->filebot = openfile->filebot->next;
@ -438,7 +438,7 @@ void ingraft_buffer(linestruct *somebuffer)
/* Refresh the mark's pointer, and compensate the mark's
* x coordinate for the change in the current line. */
if (openfile->fileage == openfile->filebot) {
if (openfile->filetop == openfile->filebot) {
#ifndef NANO_TINY
if (openfile->mark && single_line) {
openfile->mark = openfile->current;
@ -453,7 +453,7 @@ void ingraft_buffer(linestruct *somebuffer)
#ifndef NANO_TINY
else if (openfile->mark && single_line) {
if (right_side_up)
openfile->mark = openfile->fileage;
openfile->mark = openfile->filetop;
else {
openfile->mark = openfile->current;
openfile->mark_x += openfile->current_x - current_x_save;
@ -466,7 +466,7 @@ void ingraft_buffer(linestruct *somebuffer)
clock_t start = clock();
#endif
/* Add the number of characters in the copied text to the file size. */
openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
openfile->totsize += get_totsize(openfile->filetop, openfile->filebot);
#ifdef DEBUG
statusline(ALERT, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
#endif
@ -474,9 +474,9 @@ void ingraft_buffer(linestruct *somebuffer)
/* If we pasted onto the first line of the edit window, the corresponding
* record has been freed, so... point at the start of the copied text. */
if (edittop_inside)
openfile->edittop = openfile->fileage;
openfile->edittop = openfile->filetop;
top_save = openfile->fileage;
top_save = openfile->filetop;
/* Unpartition the buffer so that it contains all the text
* again, plus the copied text. */
@ -516,7 +516,7 @@ void unlink_opennode(openfilestruct *fileptr)
void delete_opennode(openfilestruct *fileptr)
{
free(fileptr->filename);
free_lines(fileptr->fileage);
free_lines(fileptr->filetop);
#ifndef NANO_TINY
free(fileptr->current_stat);
free(fileptr->lock_filename);
@ -1145,7 +1145,7 @@ bool scoop_stdin(void)
/* Read the input into a new buffer. */
open_buffer("", TRUE);
read_file(stream, 0, "stdin", TRUE);
openfile->edittop = openfile->fileage;
openfile->edittop = openfile->filetop;
fprintf(stderr, ".\n");
/* Reconnect the tty as the input source. */

View File

@ -286,7 +286,7 @@ typedef struct linestruct {
} linestruct;
typedef struct partition {
linestruct *fileage;
linestruct *filetop;
/* The top line of this portion of the file. */
linestruct *top_prev;
/* The line before the top line of this portion of the file. */
@ -360,7 +360,7 @@ typedef struct poshiststruct {
typedef struct openfilestruct {
char *filename;
/* The file's name. */
linestruct *fileage;
linestruct *filetop;
/* The file's first line. */
linestruct *filebot;
/* The file's last line. */

View File

@ -279,7 +279,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
if (ISSET(BACKWARDS_SEARCH))
line = openfile->filebot;
else
line = openfile->fileage;
line = openfile->filetop;
if (modus == JUSTFIND) {
statusbar(_("Search Wrapped"));
@ -744,7 +744,7 @@ void ask_for_replacement(void)
/* Go to the specified line and x position. */
void goto_line_posx(ssize_t line, size_t pos_x)
{
for (openfile->current = openfile->fileage; line > 1 &&
for (openfile->current = openfile->filetop; line > 1 &&
openfile->current != openfile->filebot; line--)
openfile->current = openfile->current->next;
@ -804,7 +804,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
line = 1;
/* Iterate to the requested line. */
for (openfile->current = openfile->fileage; line > 1 &&
for (openfile->current = openfile->filetop; line > 1 &&
openfile->current != openfile->filebot; line--)
openfile->current = openfile->current->next;

View File

@ -1035,7 +1035,7 @@ bool execute_command(const char *command)
add_undo(COUPLE_BEGIN);
openfile->undotop->strdata = mallocstrcpy(NULL, _("filtering"));
if (openfile->mark == NULL) {
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = 0;
}
add_undo(CUT);
@ -1045,7 +1045,7 @@ bool execute_command(const char *command)
if (fork() == 0) {
close(to_fd[0]);
send_data(cutbuffer != NULL ? cutbuffer : openfile->fileage, to_fd[1]);
send_data(cutbuffer != NULL ? cutbuffer : openfile->filetop, to_fd[1]);
close(to_fd[1]);
exit(0);
}
@ -1795,7 +1795,7 @@ bool begpar(const linestruct *const line, int depth)
/* If this is the very first line of the buffer, it counts as a BOP
* even when it contains no text. */
if (line == openfile->fileage)
if (line == openfile->filetop)
return TRUE;
/* If recursion is going too deep, just say it's not a BOP. */
@ -2035,7 +2035,7 @@ void do_justify(bool full_justify)
/* When justifying the entire buffer, start at the top. Otherwise, when
* in a paragraph but not at its beginning, move back to its first line. */
if (full_justify)
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
else if (inpar(openfile->current) && !begpar(openfile->current, 0))
do_para_begin(&openfile->current);
@ -2358,7 +2358,7 @@ bool fix_spello(const char *word)
#endif
/* Otherwise, start from the top of the file. */
{
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = 0;
}
@ -3141,7 +3141,7 @@ void do_wordlinechar_count(void)
}
/* Start at the top of the file. */
openfile->current = openfile->fileage;
openfile->current = openfile->filetop;
openfile->current_x = 0;
openfile->placewewant = 0;
@ -3158,8 +3158,8 @@ void do_wordlinechar_count(void)
/* Get the total line and character counts, as "wc -l" and "wc -c"
* do, but get the latter in multibyte characters. */
if (was_mark) {
nlines = openfile->filebot->lineno - openfile->fileage->lineno + 1;
chars = get_totsize(openfile->fileage, openfile->filebot);
nlines = openfile->filebot->lineno - openfile->filetop->lineno + 1;
chars = get_totsize(openfile->filetop, openfile->filebot);
/* Unpartition the buffer so that it contains all the text
* again, and turn the mark back on. */
@ -3265,7 +3265,7 @@ void complete_a_word(void)
openfile->last_action = OTHER;
/* Initialize the starting point for searching. */
pletion_line = openfile->fileage;
pletion_line = openfile->filetop;
pletion_x = 0;
/* Wipe the "No further matches" message. */

View File

@ -452,7 +452,7 @@ void new_magicline(void)
void remove_magicline(void)
{
if (openfile->filebot->data[0] == '\0' &&
openfile->filebot != openfile->fileage) {
openfile->filebot != openfile->filetop) {
openfile->filebot = openfile->filebot->prev;
free_lines(openfile->filebot->next);
openfile->filebot->next = NULL;

View File

@ -2928,7 +2928,7 @@ int go_back_chunks(int nrows, linestruct **line, size_t *leftedge)
if (chunk >= i)
return go_forward_chunks(chunk - i, line, leftedge);
if (*line == openfile->fileage)
if (*line == openfile->filetop)
break;
i -= chunk;
@ -3414,7 +3414,7 @@ void do_cursorpos(bool force)
saved_byte = openfile->current->data[openfile->current_x];
openfile->current->data[openfile->current_x] = '\0';
sum = get_totsize(openfile->fileage, openfile->current);
sum = get_totsize(openfile->filetop, openfile->current);
openfile->current->data[openfile->current_x] = saved_byte;