From: David Lawrence Ramsey Date: Mon, 19 Jun 2006 14:18:22 +0000 (+0000) Subject: in help_line_len(), properly handle the case where we can't break the X-Git-Tag: v1.3.12~14 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=186c795b8849ac5135a5c59b70043e8b2ac4cda9;p=nano.git in help_line_len(), properly handle the case where we can't break the line of help text, and wrap the line of help text at (COLS - 1) instead of (COLS - 8), for consistency git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3666 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index a92a28d1..0c9b39ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -267,6 +267,12 @@ CVS code - consistency with the file browser. (DLR, suggested by Benno Schulenberg) - Remove redundant key checks. (DLR) + help_line_len() + - Properly handle the case where we can't break the line of help + text. (DLR) + - Wrap the line of help text at (COLS - 1) instead of + (COLS - 8), for consistency. (DLR, suggested by Benno + Schulenberg) - nano.c: print1opt_full() - Rename to print_opt_full(), for consistency. (DLR) diff --git a/src/help.c b/src/help.c index 84b7ba3d..9beb74dc 100644 --- a/src/help.c +++ b/src/help.c @@ -596,21 +596,22 @@ void parse_help_input(int *kbinput, bool *meta_key, bool *func_key) /* Calculate the next line of help_text, starting at ptr. */ size_t help_line_len(const char *ptr) { - int help_cols = (COLS > 24) ? COLS - 8 : 24; + int help_cols = (COLS > 24) ? COLS - 1 : 24; - /* Try to break the line at (COLS - 8) columns if we have more than + /* Try to break the line at (COLS - 1) columns if we have more than * 24 columns, and at 24 columns otherwise. */ - size_t retval = break_line(ptr, help_cols, TRUE); + ssize_t wrap_loc = break_line(ptr, help_cols, TRUE); + size_t retval = (wrap_loc < 0) ? 0 : wrap_loc; size_t retval_save = retval; /* Get the length of the entire line up to a null or a newline. */ while (*(ptr + retval) != '\0' && *(ptr + retval) != '\n') retval += move_mbright(ptr + retval, 0); - /* If the entire line doesn't go more than 8 columns beyond where we + /* If the entire line doesn't go more than 1 column beyond where we * tried to break it, we should display it as-is. Otherwise, we * should display it only up to the break. */ - if (strnlenpt(ptr, retval) > help_cols + 8) + if (strnlenpt(ptr, retval) > help_cols + 1) retval = retval_save; return retval;