rename variable open_files filebuffer, for consistency

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2831 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-07-08 02:51:58 +00:00
parent 90573296ea
commit 503f278547
5 changed files with 81 additions and 80 deletions

View File

@ -6,6 +6,7 @@ CVS code -
renumber_all(), renumber(), do_alt_speller(), and renumber_all(), renumber(), do_alt_speller(), and
backup_lines(). (DLR) backup_lines(). (DLR)
- Reorder some functions for consistency. (DLR) - Reorder some functions for consistency. (DLR)
- Rename variable open_files filebuffer, for consistency. (DLR)
- global.c: - global.c:
shortcut_init() shortcut_init()
- Simplify wording of nano_gotoline_msg. (Jordi) - Simplify wording of nano_gotoline_msg. (Jordi)

View File

@ -99,133 +99,133 @@ void free_openfilestruct(openfilestruct *src)
} }
#endif #endif
/* Add/update an entry to the open_files openfilestruct. If update is /* Add/update an entry to the filebuffer openfilestruct. If update is
* FALSE, a new entry is created; otherwise, the current entry is * FALSE, a new entry is created; otherwise, the current entry is
* updated. */ * updated. */
void add_open_file(bool update) void add_open_file(bool update)
{ {
if (update && open_files == NULL) if (update && filebuffer == NULL)
return; return;
/* If there are no entries in open_files, make the first one. */ /* If there are no entries in filebuffer, make the first one. */
if (open_files == NULL) { if (filebuffer == NULL) {
open_files = make_new_opennode(); filebuffer = make_new_opennode();
splice_opennode(open_files, open_files, open_files); splice_opennode(filebuffer, filebuffer, filebuffer);
/* Otherwise, if we're not updating, make a new entry for /* Otherwise, if we're not updating, make a new entry for
* open_files and splice it in after the current entry. */ * filebuffer and splice it in after the current entry. */
} else if (!update) { } else if (!update) {
splice_opennode(open_files, make_new_opennode(), splice_opennode(filebuffer, make_new_opennode(),
open_files->next); filebuffer->next);
open_files = open_files->next; filebuffer = filebuffer->next;
} }
/* Save the current filename. */ /* Save the current filename. */
open_files->filename = mallocstrcpy(open_files->filename, filename); filebuffer->filename = mallocstrcpy(filebuffer->filename, filename);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Save the current file's stat. */ /* Save the current file's stat. */
open_files->originalfilestat = originalfilestat; filebuffer->originalfilestat = originalfilestat;
#endif #endif
/* Save the current file buffer. */ /* Save the current file buffer. */
open_files->fileage = fileage; filebuffer->fileage = fileage;
open_files->filebot = filebot; filebuffer->filebot = filebot;
/* Save the current top of the edit window. */ /* Save the current top of the edit window. */
open_files->edittop = edittop; filebuffer->edittop = edittop;
/* Save the current line. */ /* Save the current line. */
open_files->current = current; filebuffer->current = current;
/* Save the current cursor position. */ /* Save the current cursor position. */
open_files->current_x = current_x; filebuffer->current_x = current_x;
/* Save the current place we want. */ /* Save the current place we want. */
open_files->placewewant = placewewant; filebuffer->placewewant = placewewant;
/* Save the current total number of lines. */ /* Save the current total number of lines. */
open_files->totlines = totlines; filebuffer->totlines = totlines;
/* Save the current total size. */ /* Save the current total size. */
open_files->totsize = totsize; filebuffer->totsize = totsize;
/* Start with no flags saved. */ /* Start with no flags saved. */
open_files->flags = 0; filebuffer->flags = 0;
/* Save the current modification status. */ /* Save the current modification status. */
if (ISSET(MODIFIED)) if (ISSET(MODIFIED))
open_files->flags |= MODIFIED; filebuffer->flags |= MODIFIED;
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Save the current marking status and mark, if applicable. */ /* Save the current marking status and mark, if applicable. */
if (ISSET(MARK_ISSET)) { if (ISSET(MARK_ISSET)) {
open_files->flags |= MARK_ISSET; filebuffer->flags |= MARK_ISSET;
open_files->mark_beginbuf = mark_beginbuf; filebuffer->mark_beginbuf = mark_beginbuf;
open_files->mark_beginx = mark_beginx; filebuffer->mark_beginx = mark_beginx;
} }
/* Save the current file format. */ /* Save the current file format. */
open_files->fmt = fmt; filebuffer->fmt = fmt;
#endif #endif
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "filename is %s\n", open_files->filename); fprintf(stderr, "filename is %s\n", filebuffer->filename);
#endif #endif
} }
/* Read the current entry in the open_files structure and set up the /* Read the current entry in the filebuffer structure and set up the
* currently open file buffer using that entry's information. */ * currently open file buffer using that entry's information. */
void load_open_file(void) void load_open_file(void)
{ {
assert(open_files != NULL); assert(filebuffer != NULL);
/* Restore the current filename. */ /* Restore the current filename. */
filename = mallocstrcpy(filename, open_files->filename); filename = mallocstrcpy(filename, filebuffer->filename);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Restore the current file's stat. */ /* Restore the current file's stat. */
originalfilestat = open_files->originalfilestat; originalfilestat = filebuffer->originalfilestat;
#endif #endif
/* Restore the current file buffer. */ /* Restore the current file buffer. */
fileage = open_files->fileage; fileage = filebuffer->fileage;
filebot = open_files->filebot; filebot = filebuffer->filebot;
/* Restore the current top of the edit window. */ /* Restore the current top of the edit window. */
edittop = open_files->edittop; edittop = filebuffer->edittop;
/* Restore the current line. */ /* Restore the current line. */
current = open_files->current; current = filebuffer->current;
/* Restore the current cursor position. */ /* Restore the current cursor position. */
current_x = open_files->current_x; current_x = filebuffer->current_x;
/* Restore the current place we want. */ /* Restore the current place we want. */
placewewant = open_files->placewewant; placewewant = filebuffer->placewewant;
/* Restore the current total number of lines. */ /* Restore the current total number of lines. */
totlines = open_files->totlines; totlines = filebuffer->totlines;
/* Restore the current total size. */ /* Restore the current total size. */
totsize = open_files->totsize; totsize = filebuffer->totsize;
/* Restore the current modification status. */ /* Restore the current modification status. */
if (open_files->flags & MODIFIED) if (filebuffer->flags & MODIFIED)
SET(MODIFIED); SET(MODIFIED);
else else
UNSET(MODIFIED); UNSET(MODIFIED);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Restore the current marking status and mark, if applicable. */ /* Restore the current marking status and mark, if applicable. */
if (open_files->flags & MARK_ISSET) { if (filebuffer->flags & MARK_ISSET) {
mark_beginbuf = open_files->mark_beginbuf; mark_beginbuf = filebuffer->mark_beginbuf;
mark_beginx = open_files->mark_beginx; mark_beginx = filebuffer->mark_beginx;
SET(MARK_ISSET); SET(MARK_ISSET);
} else } else
UNSET(MARK_ISSET); UNSET(MARK_ISSET);
/* Restore the current file format. */ /* Restore the current file format. */
fmt = open_files->fmt; fmt = filebuffer->fmt;
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
@ -240,23 +240,23 @@ void load_open_file(void)
/* Open either the next or previous file buffer. */ /* Open either the next or previous file buffer. */
void open_prevnext_file(bool next_file) void open_prevnext_file(bool next_file)
{ {
assert(open_files != NULL); assert(filebuffer != NULL);
add_open_file(TRUE); add_open_file(TRUE);
/* If only one file buffer is open, indicate it on the statusbar and /* If only one file buffer is open, indicate it on the statusbar and
* get out. */ * get out. */
if (open_files == open_files->next) { if (filebuffer == filebuffer->next) {
statusbar(_("No more open file buffers")); statusbar(_("No more open file buffers"));
return; return;
} }
/* Switch to the next or previous file, depending on the value of /* Switch to the next or previous file, depending on the value of
* next. */ * next. */
open_files = next_file ? open_files->next : open_files->prev; filebuffer = next_file ? filebuffer->next : filebuffer->prev;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "filename is %s\n", open_files->filename); fprintf(stderr, "filename is %s\n", filebuffer->filename);
#endif #endif
/* Load the file we switched to. */ /* Load the file we switched to. */
@ -264,44 +264,44 @@ void open_prevnext_file(bool next_file)
/* And indicate the switch on the statusbar. */ /* And indicate the switch on the statusbar. */
statusbar(_("Switched to %s"), statusbar(_("Switched to %s"),
((open_files->filename[0] == '\0') ? _("New Buffer") : ((filebuffer->filename[0] == '\0') ? _("New Buffer") :
open_files->filename)); filebuffer->filename));
#ifdef DEBUG #ifdef DEBUG
dump_buffer(current); dump_buffer(current);
#endif #endif
} }
/* Open the previous entry in the open_files structure. This function /* Open the previous entry in the filebuffer structure. This function
* is used by the shortcut list. */ * is used by the shortcut list. */
void open_prevfile_void(void) void open_prevfile_void(void)
{ {
open_prevnext_file(FALSE); open_prevnext_file(FALSE);
} }
/* Open the next entry in the open_files structure. This function is /* Open the next entry in the filebuffer structure. This function is
* used by the shortcut list. */ * used by the shortcut list. */
void open_nextfile_void(void) void open_nextfile_void(void)
{ {
open_prevnext_file(TRUE); open_prevnext_file(TRUE);
} }
/* Delete an entry from the open_files filestruct. After deletion of an /* Delete an entry from the filebuffer filestruct. After deletion of an
* entry, the next entry is opened. Return TRUE on success or FALSE if * entry, the next entry is opened. Return TRUE on success or FALSE if
* there are no more open file buffers. */ * there are no more open file buffers. */
bool close_open_file(void) bool close_open_file(void)
{ {
assert(open_files != NULL); assert(filebuffer != NULL);
/* If only one file is open, get out. */ /* If only one file is open, get out. */
if (open_files == open_files->next) if (filebuffer == filebuffer->next)
return FALSE; return FALSE;
/* Open the next file. */ /* Open the next file. */
open_nextfile_void(); open_nextfile_void();
/* Close the file we had open before. */ /* Close the file we had open before. */
unlink_opennode(open_files->prev); unlink_opennode(filebuffer->prev);
/* Reinitialize the shortcut list. */ /* Reinitialize the shortcut list. */
shortcut_init(FALSE); shortcut_init(FALSE);
@ -388,7 +388,7 @@ void load_file(void)
current = fileage; current = fileage;
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Add a new entry to the open_files structure. */ /* Add a new entry to the filebuffer structure. */
add_open_file(FALSE); add_open_file(FALSE);
/* Reinitialize the shortcut list. */ /* Reinitialize the shortcut list. */
@ -685,7 +685,7 @@ void execute_command(const char *command)
{ {
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER)) { if (ISSET(MULTIBUFFER)) {
/* Update the current entry in the open_files structure. */ /* Update the current entry in the filebuffer structure. */
add_open_file(TRUE); add_open_file(TRUE);
new_file(); new_file();
UNSET(MODIFIED); UNSET(MODIFIED);
@ -694,7 +694,7 @@ void execute_command(const char *command)
#endif /* ENABLE_MULTIBUFFER */ #endif /* ENABLE_MULTIBUFFER */
open_pipe(command); open_pipe(command);
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Add this new entry to the open_files structure. */ /* Add this new entry to the filebuffer structure. */
if (ISSET(MULTIBUFFER)) if (ISSET(MULTIBUFFER))
load_file(); load_file();
#endif /* ENABLE_MULTIBUFFER */ #endif /* ENABLE_MULTIBUFFER */
@ -713,7 +713,7 @@ void load_buffer(const char *name)
/* new_buffer says whether we load into this buffer or a new /* new_buffer says whether we load into this buffer or a new
* one. If new_buffer is TRUE, we display "New File" if the * one. If new_buffer is TRUE, we display "New File" if the
* file is not found, and if it is found we set filename and add * file is not found, and if it is found we set filename and add
* a new open_files entry. */ * a new filebuffer entry. */
FILE *f; FILE *f;
int rc; int rc;
/* rc == -2 means that the statusbar displayed "New File". -1 /* rc == -2 means that the statusbar displayed "New File". -1
@ -728,7 +728,7 @@ void load_buffer(const char *name)
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Update the current entry in the open_files structure. */ /* Update the current entry in the filebuffer structure. */
add_open_file(TRUE); add_open_file(TRUE);
#endif #endif
@ -763,7 +763,7 @@ void load_buffer(const char *name)
#endif #endif
} }
/* Add this new entry to the open_files structure if we have /* Add this new entry to the filebuffer structure if we have
* multibuffer support, or to the main filestruct if we don't. */ * multibuffer support, or to the main filestruct if we don't. */
if (rc != -1 && new_buffer) if (rc != -1 && new_buffer)
load_file(); load_file();
@ -1926,7 +1926,7 @@ int do_writeout(bool exiting)
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* If we're not about to exit, update the current entry in /* If we're not about to exit, update the current entry in
* the open_files structure. */ * the filebuffer structure. */
if (!exiting) if (!exiting)
add_open_file(TRUE); add_open_file(TRUE);
#endif #endif

View File

@ -69,7 +69,7 @@ partition *filepart = NULL; /* A place to store a portion of the
file struct */ file struct */
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
openfilestruct *open_files = NULL; /* The list of open file openfilestruct *filebuffer = NULL; /* The list of open file
buffers */ buffers */
#endif #endif
@ -413,7 +413,7 @@ void shortcut_init(bool unjustify)
/* Translators: try to keep this string under 10 characters long */ /* Translators: try to keep this string under 10 characters long */
sc_init_one(&main_list, NANO_EXIT_KEY, sc_init_one(&main_list, NANO_EXIT_KEY,
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
open_files != NULL && open_files != open_files->next ? filebuffer != NULL && filebuffer != filebuffer->next ?
N_("Close") : N_("Close") :
#endif #endif
exit_msg, IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY, exit_msg, IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
@ -1243,12 +1243,12 @@ void thanks_for_all_the_fish(void)
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Free the memory associated with each open file buffer. */ /* Free the memory associated with each open file buffer. */
if (open_files != NULL) { if (filebuffer != NULL) {
/* Make sure open_files->fileage is up to date, in case we've /* Make sure filebuffer->fileage is up to date, in case we've
* cut the top line of the file. */ * cut the top line of the file. */
open_files->fileage = fileage; filebuffer->fileage = fileage;
free_openfilestruct(open_files); free_openfilestruct(filebuffer);
} }
#else #else
if (fileage != NULL) if (fileage != NULL)

View File

@ -521,19 +521,19 @@ void die(const char *msg, ...)
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Save all of the other modified file buffers, if any. */ /* Save all of the other modified file buffers, if any. */
if (open_files != NULL) { if (filebuffer != NULL) {
openfilestruct *tmp = open_files; openfilestruct *tmp = filebuffer;
while (tmp != open_files->next) { while (tmp != filebuffer->next) {
open_files = open_files->next; filebuffer = filebuffer->next;
/* Save the current file buffer if it's been modified. */ /* Save the current file buffer if it's been modified. */
if (open_files->flags & MODIFIED) { if (filebuffer->flags & MODIFIED) {
/* Set fileage and filebot to match the current file /* Set fileage and filebot to match the current file
* buffer, and then write it to disk. */ * buffer, and then write it to disk. */
fileage = open_files->fileage; fileage = filebuffer->fileage;
filebot = open_files->filebot; filebot = filebuffer->filebot;
die_save_file(open_files->filename); die_save_file(filebuffer->filename);
} }
} }
} }
@ -2533,7 +2533,7 @@ void do_spell(void)
} }
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Update the current open_files entry before spell-checking, in /* Update the current filebuffer entry before spell-checking, in
* case any problems occur. */ * case any problems occur. */
add_open_file(TRUE); add_open_file(TRUE);
#endif #endif
@ -4651,7 +4651,7 @@ int main(int argc, char **argv)
new_file(); new_file();
UNSET(VIEW_MODE); UNSET(VIEW_MODE);
/* Add this new entry to the open_files structure if we have /* Add this new entry to the filebuffer structure if we have
* multibuffer support, or to the main filestruct if we * multibuffer support, or to the main filestruct if we
* don't. */ * don't. */
load_file(); load_file();

View File

@ -101,7 +101,7 @@ extern filestruct *mark_beginbuf;
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
extern openfilestruct *open_files; extern openfilestruct *filebuffer;
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR