Commit 64661ac1 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

rename filebuffer to openfile. as it's shorter

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2834 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 81 additions and 83 deletions
+81 -83
...@@ -6,7 +6,7 @@ CVS code - ...@@ -6,7 +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) - Rename variable open_files openfile, 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)
......
...@@ -99,133 +99,132 @@ void free_openfilestruct(openfilestruct *src) ...@@ -99,133 +99,132 @@ void free_openfilestruct(openfilestruct *src)
} }
#endif #endif
/* Add/update an entry to the filebuffer openfilestruct. If update is /* Add/update an entry to the openfile 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 && filebuffer == NULL) if (update && openfile == NULL)
return; return;
/* If there are no entries in filebuffer, make the first one. */ /* If there are no entries in openfile, make the first one. */
if (filebuffer == NULL) { if (openfile == NULL) {
filebuffer = make_new_opennode(); openfile = make_new_opennode();
splice_opennode(filebuffer, filebuffer, filebuffer); splice_opennode(openfile, openfile, openfile);
/* Otherwise, if we're not updating, make a new entry for /* Otherwise, if we're not updating, make a new entry for
* filebuffer and splice it in after the current entry. */ * openfile and splice it in after the current entry. */
} else if (!update) { } else if (!update) {
splice_opennode(filebuffer, make_new_opennode(), splice_opennode(openfile, make_new_opennode(), openfile->next);
filebuffer->next); openfile = openfile->next;
filebuffer = filebuffer->next;
} }
/* Save the current filename. */ /* Save the current filename. */
filebuffer->filename = mallocstrcpy(filebuffer->filename, filename); openfile->filename = mallocstrcpy(openfile->filename, filename);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Save the current file's stat. */ /* Save the current file's stat. */
filebuffer->originalfilestat = originalfilestat; openfile->originalfilestat = originalfilestat;
#endif #endif
/* Save the current file buffer. */ /* Save the current file buffer. */
filebuffer->fileage = fileage; openfile->fileage = fileage;
filebuffer->filebot = filebot; openfile->filebot = filebot;
/* Save the current top of the edit window. */ /* Save the current top of the edit window. */
filebuffer->edittop = edittop; openfile->edittop = edittop;
/* Save the current line. */ /* Save the current line. */
filebuffer->current = current; openfile->current = current;
/* Save the current cursor position. */ /* Save the current cursor position. */
filebuffer->current_x = current_x; openfile->current_x = current_x;
/* Save the current place we want. */ /* Save the current place we want. */
filebuffer->placewewant = placewewant; openfile->placewewant = placewewant;
/* Save the current total number of lines. */ /* Save the current total number of lines. */
filebuffer->totlines = totlines; openfile->totlines = totlines;
/* Save the current total size. */ /* Save the current total size. */
filebuffer->totsize = totsize; openfile->totsize = totsize;
/* Start with no flags saved. */ /* Start with no flags saved. */
filebuffer->flags = 0; openfile->flags = 0;
/* Save the current modification status. */ /* Save the current modification status. */
if (ISSET(MODIFIED)) if (ISSET(MODIFIED))
filebuffer->flags |= MODIFIED; openfile->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)) {
filebuffer->flags |= MARK_ISSET; openfile->flags |= MARK_ISSET;
filebuffer->mark_beginbuf = mark_beginbuf; openfile->mark_beginbuf = mark_beginbuf;
filebuffer->mark_beginx = mark_beginx; openfile->mark_beginx = mark_beginx;
} }
/* Save the current file format. */ /* Save the current file format. */
filebuffer->fmt = fmt; openfile->fmt = fmt;
#endif #endif
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "filename is %s\n", filebuffer->filename); fprintf(stderr, "filename is %s\n", openfile->filename);
#endif #endif
} }
/* Read the current entry in the filebuffer structure and set up the /* Read the current entry in the openfile 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(filebuffer != NULL); assert(openfile != NULL);
/* Restore the current filename. */ /* Restore the current filename. */
filename = mallocstrcpy(filename, filebuffer->filename); filename = mallocstrcpy(filename, openfile->filename);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Restore the current file's stat. */ /* Restore the current file's stat. */
originalfilestat = filebuffer->originalfilestat; originalfilestat = openfile->originalfilestat;
#endif #endif
/* Restore the current file buffer. */ /* Restore the current file buffer. */
fileage = filebuffer->fileage; fileage = openfile->fileage;
filebot = filebuffer->filebot; filebot = openfile->filebot;
/* Restore the current top of the edit window. */ /* Restore the current top of the edit window. */
edittop = filebuffer->edittop; edittop = openfile->edittop;
/* Restore the current line. */ /* Restore the current line. */
current = filebuffer->current; current = openfile->current;
/* Restore the current cursor position. */ /* Restore the current cursor position. */
current_x = filebuffer->current_x; current_x = openfile->current_x;
/* Restore the current place we want. */ /* Restore the current place we want. */
placewewant = filebuffer->placewewant; placewewant = openfile->placewewant;
/* Restore the current total number of lines. */ /* Restore the current total number of lines. */
totlines = filebuffer->totlines; totlines = openfile->totlines;
/* Restore the current total size. */ /* Restore the current total size. */
totsize = filebuffer->totsize; totsize = openfile->totsize;
/* Restore the current modification status. */ /* Restore the current modification status. */
if (filebuffer->flags & MODIFIED) if (openfile->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 (filebuffer->flags & MARK_ISSET) { if (openfile->flags & MARK_ISSET) {
mark_beginbuf = filebuffer->mark_beginbuf; mark_beginbuf = openfile->mark_beginbuf;
mark_beginx = filebuffer->mark_beginx; mark_beginx = openfile->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 = filebuffer->fmt; fmt = openfile->fmt;
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
...@@ -240,23 +239,23 @@ void load_open_file(void) ...@@ -240,23 +239,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(filebuffer != NULL); assert(openfile != 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 (filebuffer == filebuffer->next) { if (openfile == openfile->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. */
filebuffer = next_file ? filebuffer->next : filebuffer->prev; openfile = next_file ? openfile->next : openfile->prev;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "filename is %s\n", filebuffer->filename); fprintf(stderr, "filename is %s\n", openfile->filename);
#endif #endif
/* Load the file we switched to. */ /* Load the file we switched to. */
...@@ -264,44 +263,44 @@ void open_prevnext_file(bool next_file) ...@@ -264,44 +263,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"),
((filebuffer->filename[0] == '\0') ? _("New Buffer") : ((openfile->filename[0] == '\0') ? _("New Buffer") :
filebuffer->filename)); openfile->filename));
#ifdef DEBUG #ifdef DEBUG
dump_buffer(current); dump_buffer(current);
#endif #endif
} }
/* Open the previous entry in the filebuffer structure. This function /* Open the previous entry in the openfile 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 filebuffer structure. This function is /* Open the next entry in the openfile 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 filebuffer filestruct. After deletion of an /* Delete an entry from the openfile 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(filebuffer != NULL); assert(openfile != NULL);
/* If only one file is open, get out. */ /* If only one file is open, get out. */
if (filebuffer == filebuffer->next) if (openfile == openfile->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(filebuffer->prev); unlink_opennode(openfile->prev);
/* Reinitialize the shortcut list. */ /* Reinitialize the shortcut list. */
shortcut_init(FALSE); shortcut_init(FALSE);
...@@ -388,7 +387,7 @@ void load_file(void) ...@@ -388,7 +387,7 @@ void load_file(void)
current = fileage; current = fileage;
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Add a new entry to the filebuffer structure. */ /* Add a new entry to the openfile structure. */
add_open_file(FALSE); add_open_file(FALSE);
/* Reinitialize the shortcut list. */ /* Reinitialize the shortcut list. */
...@@ -685,7 +684,7 @@ void execute_command(const char *command) ...@@ -685,7 +684,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 filebuffer structure. */ /* Update the current entry in the openfile structure. */
add_open_file(TRUE); add_open_file(TRUE);
new_file(); new_file();
UNSET(MODIFIED); UNSET(MODIFIED);
...@@ -694,7 +693,7 @@ void execute_command(const char *command) ...@@ -694,7 +693,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 filebuffer structure. */ /* Add this new entry to the openfile structure. */
if (ISSET(MULTIBUFFER)) if (ISSET(MULTIBUFFER))
load_file(); load_file();
#endif /* ENABLE_MULTIBUFFER */ #endif /* ENABLE_MULTIBUFFER */
...@@ -713,7 +712,7 @@ void load_buffer(const char *name) ...@@ -713,7 +712,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 filebuffer entry. */ * a new openfile 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 +727,7 @@ void load_buffer(const char *name) ...@@ -728,7 +727,7 @@ void load_buffer(const char *name)
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Update the current entry in the filebuffer structure. */ /* Update the current entry in the openfile structure. */
add_open_file(TRUE); add_open_file(TRUE);
#endif #endif
...@@ -763,7 +762,7 @@ void load_buffer(const char *name) ...@@ -763,7 +762,7 @@ void load_buffer(const char *name)
#endif #endif
} }
/* Add this new entry to the filebuffer structure if we have /* Add this new entry to the openfile 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 +1925,7 @@ int do_writeout(bool exiting) ...@@ -1926,7 +1925,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 filebuffer structure. */ * the openfile structure. */
if (!exiting) if (!exiting)
add_open_file(TRUE); add_open_file(TRUE);
#endif #endif
......
...@@ -69,8 +69,8 @@ partition *filepart = NULL; /* A place to store a portion of the ...@@ -69,8 +69,8 @@ partition *filepart = NULL; /* A place to store a portion of the
file struct */ file struct */
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
openfilestruct *filebuffer = NULL; /* The list of open file openfilestruct *openfile = NULL;
buffers */ /* The list of open file buffers */
#endif #endif
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
...@@ -413,8 +413,7 @@ void shortcut_init(bool unjustify) ...@@ -413,8 +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
filebuffer != NULL && filebuffer != filebuffer->next ? openfile != NULL && openfile != openfile->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,
NANO_NO_KEY, VIEW, do_exit); NANO_NO_KEY, VIEW, do_exit);
...@@ -1243,12 +1242,12 @@ void thanks_for_all_the_fish(void) ...@@ -1243,12 +1242,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 (filebuffer != NULL) { if (openfile != NULL) {
/* Make sure filebuffer->fileage is up to date, in case we've /* Make sure openfile->fileage is up to date, in case we've
* cut the top line of the file. */ * cut the top line of the file. */
filebuffer->fileage = fileage; openfile->fileage = fileage;
free_openfilestruct(filebuffer); free_openfilestruct(openfile);
} }
#else #else
if (fileage != NULL) if (fileage != NULL)
......
...@@ -521,19 +521,19 @@ void die(const char *msg, ...) ...@@ -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 (filebuffer != NULL) { if (openfile != NULL) {
openfilestruct *tmp = filebuffer; openfilestruct *tmp = openfile;
while (tmp != filebuffer->next) { while (tmp != openfile->next) {
filebuffer = filebuffer->next; openfile = openfile->next;
/* Save the current file buffer if it's been modified. */ /* Save the current file buffer if it's been modified. */
if (filebuffer->flags & MODIFIED) { if (openfile->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 = filebuffer->fileage; fileage = openfile->fileage;
filebot = filebuffer->filebot; filebot = openfile->filebot;
die_save_file(filebuffer->filename); die_save_file(openfile->filename);
} }
} }
} }
...@@ -2544,7 +2544,7 @@ void do_spell(void) ...@@ -2544,7 +2544,7 @@ void do_spell(void)
} }
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Update the current filebuffer entry before spell-checking, in /* Update the current openfile entry before spell-checking, in
* case any problems occur. */ * case any problems occur. */
add_open_file(TRUE); add_open_file(TRUE);
#endif #endif
...@@ -4667,7 +4667,7 @@ int main(int argc, char **argv) ...@@ -4667,7 +4667,7 @@ int main(int argc, char **argv)
new_file(); new_file();
UNSET(VIEW_MODE); UNSET(VIEW_MODE);
/* Add this new entry to the filebuffer structure if we have /* Add this new entry to the openfile 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();
......
...@@ -101,7 +101,7 @@ extern filestruct *mark_beginbuf; ...@@ -101,7 +101,7 @@ extern filestruct *mark_beginbuf;
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
extern openfilestruct *filebuffer; extern openfilestruct *openfile;
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment