commit bc6787826a93abfe2207b8d9c4cf390e9a7e3aa7
parent b5f15cb574cfbd02f633d371d1139a4ded5ea82c
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 30 Jul 2018 15:40:03 -0500
speller: make replace_marked_buffer() use the cutting functions directly
Diffstat:
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -535,16 +535,14 @@ void replace_buffer(const char *filename)
#ifndef NANO_TINY
/* Open the specified file, and if that succeeds, blow away the text of
- * the current buffer at the given coordinates and read the file
+ * the current buffer covered by the mark and read the file
* contents into its place. */
-void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
- filestruct *bot, size_t bot_x)
+void replace_marked_buffer(const char *filename)
{
FILE *f;
int descriptor;
bool old_no_newlines = ISSET(NO_NEWLINES);
- filestruct *trash_top = NULL;
- filestruct *trash_bot = NULL;
+ filestruct *was_cutbuffer = cutbuffer;
descriptor = open_file(filename, FALSE, TRUE, &f);
@@ -554,10 +552,13 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
/* Don't add a magicline when replacing text in the buffer. */
SET(NO_NEWLINES);
- /* Throw away the text under the mark, and insert the processed file
- * where the marked text was. */
- extract_buffer(&trash_top, &trash_bot, top, top_x, bot, bot_x);
- free_filestruct(trash_top);
+ /* Throw away the text under the mark. */
+ cutbuffer = NULL;
+ do_cut_text(FALSE, TRUE, FALSE);
+ free_filestruct(cutbuffer);
+ cutbuffer = was_cutbuffer;
+
+ /* Insert the processed file where the marked text was. */
read_file(f, descriptor, filename, FALSE);
/* Restore the magicline behavior now that we're done fiddling. */
diff --git a/src/proto.h b/src/proto.h
@@ -269,8 +269,7 @@ bool open_buffer(const char *filename, bool new_buffer);
#ifdef ENABLE_SPELLER
void replace_buffer(const char *filename);
#ifndef NANO_TINY
-void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
- filestruct *bot, size_t bot_x);
+void replace_marked_buffer(const char *filename);
#endif
#endif
void prepare_for_display(void);
diff --git a/src/text.c b/src/text.c
@@ -2880,9 +2880,8 @@ const char *do_alt_speller(char *tempfile_name)
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
- openfile->mark = NULL;
- replace_marked_buffer(tempfile_name, top, top_x, bot, bot_x);
+ replace_marked_buffer(tempfile_name);
/* Adjust the end point of the marked region for any change in
* length of the region's last line. */