tweaks: elide a helper function, in preparation for an improvement

This commit is contained in:
Benno Schulenberg 2020-01-09 10:59:21 +01:00
parent 0e559c5bbc
commit e3edce4e7b
2 changed files with 10 additions and 15 deletions

View File

@ -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. */

View File

@ -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);