mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-26 06:39:43 +03:00
tweaks: move a function to where it is used
This commit is contained in:
parent
38af812a82
commit
71c35d3ca2
42
src/files.c
42
src/files.c
@ -469,48 +469,6 @@ bool open_buffer(const char *filename, bool new_one)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SPELLER
|
||||
/* Open the specified file, and if that succeeds, remove the text of the marked
|
||||
* region or of the entire buffer and read the file contents into its place. */
|
||||
bool replace_buffer(const char *filename, undo_type action, bool marked,
|
||||
const char *operation)
|
||||
{
|
||||
linestruct *was_cutbuffer = cutbuffer;
|
||||
int descriptor;
|
||||
FILE *f;
|
||||
|
||||
descriptor = open_file(filename, FALSE, &f);
|
||||
|
||||
if (descriptor < 0)
|
||||
return FALSE;
|
||||
|
||||
cutbuffer = NULL;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_BEGIN, operation);
|
||||
|
||||
/* Cut either the marked region or the whole buffer. */
|
||||
add_undo(action, NULL);
|
||||
#endif
|
||||
do_snip(FALSE, marked, !marked, FALSE);
|
||||
#ifndef NANO_TINY
|
||||
update_undo(action);
|
||||
#endif
|
||||
|
||||
/* Discard what was cut. */
|
||||
free_lines(cutbuffer);
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Insert the spell-checked file into the cleared area. */
|
||||
read_file(f, descriptor, filename, TRUE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_END, operation);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* ENABLE_SPELLER */
|
||||
|
||||
/* Mark the current file as modified if it isn't already, and
|
||||
* then update the title bar to display the file's new status. */
|
||||
void set_modified(void)
|
||||
|
@ -278,10 +278,6 @@ void make_new_buffer(void);
|
||||
bool delete_lockfile(const char *lockfilename);
|
||||
#endif
|
||||
bool open_buffer(const char *filename, bool new_buffer);
|
||||
#ifdef ENABLE_SPELLER
|
||||
bool replace_buffer(const char *filename, undo_type action, bool marked,
|
||||
const char *operation);
|
||||
#endif
|
||||
void set_modified(void);
|
||||
void prepare_for_display(void);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
|
40
src/text.c
40
src/text.c
@ -2479,6 +2479,46 @@ const char *do_int_speller(const char *tempfile_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Open the specified file, and if that succeeds, remove the text of the marked
|
||||
* region or of the entire buffer and read the file contents into its place. */
|
||||
bool replace_buffer(const char *filename, undo_type action, bool marked,
|
||||
const char *operation)
|
||||
{
|
||||
linestruct *was_cutbuffer = cutbuffer;
|
||||
int descriptor;
|
||||
FILE *f;
|
||||
|
||||
descriptor = open_file(filename, FALSE, &f);
|
||||
|
||||
if (descriptor < 0)
|
||||
return FALSE;
|
||||
|
||||
cutbuffer = NULL;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_BEGIN, operation);
|
||||
|
||||
/* Cut either the marked region or the whole buffer. */
|
||||
add_undo(action, NULL);
|
||||
#endif
|
||||
do_snip(FALSE, marked, !marked, FALSE);
|
||||
#ifndef NANO_TINY
|
||||
update_undo(action);
|
||||
#endif
|
||||
|
||||
/* Discard what was cut. */
|
||||
free_lines(cutbuffer);
|
||||
cutbuffer = was_cutbuffer;
|
||||
|
||||
/* Insert the spell-checked file into the cleared area. */
|
||||
read_file(f, descriptor, filename, TRUE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(COUPLE_END, operation);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Execute the given program, with the given temp file as last argument. */
|
||||
const char *treat(char *tempfile_name, char *theprogram, bool spelling)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user