commit e3edce4e7b272c5538b2260d9336f7d615cb420a
parent 0e559c5bbc2218d08ebf4bcb3a6d190f8fcacbde
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 9 Jan 2020 10:59:21 +0100
tweaks: elide a helper function, in preparation for an improvement
Diffstat:
2 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/src/help.c b/src/help.c
@@ -43,14 +43,22 @@ static size_t location;
void wrap_help_text_into_buffer(void)
{
size_t sum = 0;
+ /* Avoid overtight and overwide paragraphs in the introductory text. */
+ size_t wrapping_point = (COLS < 24) ? 24 : (COLS > 74) ? 74 : COLS;
const char *ptr = start_of_body;
make_new_buffer();
/* Copy the help text into the just-created new buffer. */
while (*ptr != '\0') {
- int length = help_line_len(ptr);
- char *oneline = nmalloc(length + 1);
+ int length;
+ char *oneline;
+
+ if (ptr >= end_of_intro)
+ wrapping_point = (COLS < 24) ? 24 : COLS;
+
+ length = break_line(ptr, wrapping_point, TRUE);
+ oneline = nmalloc(length + 1);
snprintf(oneline, length + 1, "%s", ptr);
free(openfile->current->data);
@@ -572,18 +580,6 @@ functionptrtype parse_help_input(int *kbinput)
}
return func_from_key(kbinput);
}
-
-/* Calculate the displayable length of the help-text line starting at ptr. */
-size_t help_line_len(const char *ptr)
-{
- size_t wrapping_point = (COLS < 24) ? 24 : COLS;
-
- /* Avoid overwide paragraphs in the introductory text. */
- if (ptr < end_of_intro && COLS > 74)
- wrapping_point = 74;
-
- return break_line(ptr, wrapping_point, TRUE);
-}
#endif /* ENABLE_HELP */
/* Start the help viewer, or indicate that there is no help. */
diff --git a/src/proto.h b/src/proto.h
@@ -340,7 +340,6 @@ const char *flagtostr(int flag);
void wrap_help_text_into_buffer(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
-size_t help_line_len(const char *ptr);
#endif
void do_help(void);