fix alternate spell checker breakage: don't lose colors after using it

on a file


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2913 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-07-23 00:41:45 +00:00
parent c009759c23
commit c00513b65e
4 changed files with 20 additions and 36 deletions

View File

@ -64,20 +64,12 @@ void initialize_buffer(void)
openfile->filename = mallocstrcpy(NULL, ""); openfile->filename = mallocstrcpy(NULL, "");
openfile->fileage = make_new_node(NULL); initialize_buffer_text();
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
openfile->current_x = 0; openfile->current_x = 0;
openfile->placewewant = 0; openfile->placewewant = 0;
openfile->current_y = 0; openfile->current_y = 0;
openfile->totlines = 1;
openfile->totsize = 0;
openfile->modified = FALSE; openfile->modified = FALSE;
#ifndef NANO_SMALL #ifndef NANO_SMALL
openfile->mark_set = FALSE; openfile->mark_set = FALSE;
@ -94,22 +86,22 @@ void initialize_buffer(void)
#endif #endif
} }
#ifndef DISABLE_SPELLER /* Initialize the text of the current entry of the openfile
/* Reinitialize the current entry of the openfile openfilestruct. */ * openfilestruct. */
void reinitialize_buffer(void) void initialize_buffer_text(void)
{ {
assert(openfile != NULL && openfile->filename != NULL && openfile->fileage != NULL); assert(openfile != NULL);
free(openfile->filename); openfile->fileage = make_new_node(NULL);
free_filestruct(openfile->fileage); openfile->fileage->data = mallocstrcpy(NULL, "");
#ifndef NANO_SMALL
if (openfile->current_stat != NULL)
free(openfile->current_stat);
#endif
initialize_buffer(); openfile->filebot = openfile->fileage;
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
openfile->totlines = 1;
openfile->totsize = 0;
} }
#endif
/* If it's not "", filename is a file to open. We make a new buffer, if /* If it's not "", filename is a file to open. We make a new buffer, if
* necessary, and then open and read the file, if applicable. */ * necessary, and then open and read the file, if applicable. */

View File

@ -2187,7 +2187,6 @@ const char *do_int_speller(const char *tempfile_name)
const char *do_alt_speller(char *tempfile_name) const char *do_alt_speller(char *tempfile_name)
{ {
int alt_spell_status; int alt_spell_status;
char *filename_save;
size_t current_x_save = openfile->current_x; size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant; size_t pww_save = openfile->placewewant;
ssize_t current_y_save = openfile->current_y; ssize_t current_y_save = openfile->current_y;
@ -2301,14 +2300,9 @@ const char *do_alt_speller(char *tempfile_name)
/* Set up the window size. */ /* Set up the window size. */
window_size_init(); window_size_init();
/* Save the current filename. */ /* Reinitialize the text of the current buffer. */
filename_save = mallocstrcpy(NULL, openfile->filename); free_filestruct(openfile->fileage);
initialize_buffer_text();
/* Reinitialize the current buffer. */
reinitialize_buffer();
/* Restore the current filename. */
openfile->filename = filename_save;
/* Reload the temp file. Open it, read it into the current buffer, /* Reload the temp file. Open it, read it into the current buffer,
* and move back to the first line of the buffer. */ * and move back to the first line of the buffer. */

View File

@ -209,14 +209,14 @@ typedef struct openfilestruct {
filestruct *filebot; /* Current file's last line. */ filestruct *filebot; /* Current file's last line. */
filestruct *edittop; /* Current top of edit window. */ filestruct *edittop; /* Current top of edit window. */
filestruct *current; /* Current file's line. */ 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 current_x; /* Current file's x-coordinate size_t current_x; /* Current file's x-coordinate
* position. */ * position. */
size_t placewewant; /* Current file's place we want. */ size_t placewewant; /* Current file's place we want. */
ssize_t current_y; /* Current file's y-coordinate ssize_t current_y; /* Current file's y-coordinate
* position. */ * position. */
size_t totlines; /* Current file's total number of
* lines. */
size_t totsize; /* Current file's total size. */
bool modified; /* Current file's modification bool modified; /* Current file's modification
* status. */ * status. */
#ifndef NANO_SMALL #ifndef NANO_SMALL

View File

@ -235,9 +235,7 @@ void do_uncut_text(void);
/* Public functions in files.c. */ /* Public functions in files.c. */
void make_new_buffer(void); void make_new_buffer(void);
void initialize_buffer(void); void initialize_buffer(void);
#ifndef DISABLE_SPELLER void initialize_buffer_text(void);
void reinitialize_buffer(void);
#endif
void open_buffer(const char *filename); void open_buffer(const char *filename);
void display_buffer(void); void display_buffer(void);
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER