From dcd34b246abd9a055fa4c53043c94121ef013827 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 19 Jul 2020 10:17:21 +0200 Subject: [PATCH] tweaks: move a function to the file where it is used the most Also, fully exclude the function from the tiny version. --- src/cut.c | 3 ++- src/files.c | 10 ---------- src/nano.c | 8 ++++++++ src/prototypes.h | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/cut.c b/src/cut.c index 35b41066..3f0a5828 100644 --- a/src/cut.c +++ b/src/cut.c @@ -381,9 +381,10 @@ void ingraft_buffer(linestruct *topline) } if (topline != botline) { +#ifndef NANO_TINY /* First compute the softwrapped chunks for each line in the graft. */ compute_the_extra_rows_per_line_from(topline); - +#endif /* When inserting at end-of-buffer, update the relevant pointer. */ if (line->next == NULL) openfile->filebot = botline; diff --git a/src/files.c b/src/files.c index cdc3a1ce..c3b6c3e7 100644 --- a/src/files.c +++ b/src/files.c @@ -356,16 +356,6 @@ bool has_valid_path(const char *filename) return validity; } -/* Compute and store how many extra rows each line needs when softwrapping. */ -void compute_the_extra_rows_per_line_from(linestruct *fromline) -{ -#ifndef NANO_TINY - if (ISSET(SOFTWRAP)) - for (linestruct *line = fromline; line != NULL; line = line->next) - line->extrarows = extra_chunks_in(line); -#endif -} - /* This does one of three things. If the filename is "", it just creates * a new empty buffer. When the filename is not empty, it reads that file * into a new buffer when requested, otherwise into the existing buffer. */ diff --git a/src/nano.c b/src/nano.c index 8e8b9952..e4496732 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1009,6 +1009,14 @@ RETSIGTYPE handle_sigwinch(int signal) the_window_resized = TRUE; } +/* Compute and store how many extra rows each line needs when softwrapping. */ +void compute_the_extra_rows_per_line_from(linestruct *fromline) +{ + if (ISSET(SOFTWRAP)) + for (linestruct *line = fromline; line != NULL; line = line->next) + line->extrarows = extra_chunks_in(line); +} + /* Reinitialize and redraw the screen completely. */ void regenerate_screen(void) { diff --git a/src/prototypes.h b/src/prototypes.h index c6bd6b87..e823e3c1 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -275,7 +275,6 @@ void make_new_buffer(void); #ifndef NANO_TINY bool delete_lockfile(const char *lockfilename); #endif -void compute_the_extra_rows_per_line_from(linestruct *fromline); bool open_buffer(const char *filename, bool new_one); void set_modified(void); void prepare_for_display(void); @@ -418,6 +417,7 @@ void block_sigwinch(bool blockit); #endif #ifndef NANO_TINY RETSIGTYPE handle_sigwinch(int signal); +void compute_the_extra_rows_per_line_from(linestruct *fromline); void regenerate_screen(void); void do_toggle(int flag); #endif