From a9aa0ef997fd406bcf8b82d9ebe03e47a8a197f3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 16 Aug 2015 08:43:56 +0000 Subject: [PATCH] Avoiding wide paragraphs of running text in the help screens, wrapping them at 74 columns if the screen is wider. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5358 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 4 ++++ src/help.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0eeace1c..daa57b15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-08-16 Benno Schulenberg + * src/help.c (help_init, help_line_len): Avoid wide paragraphs of text + in the help screens: wrap them at 74 columns if the screen is wider. + 2015-08-13 Benno Schulenberg * src/search.c (do_find_bracket): Remove mistaken comparison between pointer and literal character. Found with cppcheck. diff --git a/src/help.c b/src/help.c index 4c9e5534..ee35b154 100644 --- a/src/help.c +++ b/src/help.c @@ -32,6 +32,10 @@ static char *help_text = NULL; /* The text displayed in the help window. */ +static char *end_of_intro = NULL; + /* The point in the help text where the introductory paragraphs end + * and the shortcut descriptions begin. */ + /* Our main help browser function. refresh_func is the function we will * call to refresh the edit window. */ void do_help(void (*refresh_func)(void)) @@ -399,6 +403,9 @@ void help_init(void) ptr = help_text + strlen(help_text); + /* Remember this end-of-introduction, start-of-shortcuts. */ + end_of_intro = ptr; + /* Now add our shortcut info. */ for (f = allfuncs; f != NULL; f = f->next) { @@ -491,9 +498,12 @@ functionptrtype parse_help_input(int *kbinput) size_t help_line_len(const char *ptr) { int help_cols = (COLS > 24) ? COLS - 1 : 24; + /* The target width for wrapping long lines. */ + + /* Avoid overwide paragraphs in the introductory text. */ + if (ptr < end_of_intro && COLS > 74) + help_cols = 74; - /* Try to break the line at (COLS - 1) columns if we have more than - * 24 columns, and at 24 columns otherwise. */ ssize_t wrap_loc = break_line(ptr, help_cols, TRUE); size_t retval = (wrap_loc < 0) ? 0 : wrap_loc; size_t retval_save = retval;