nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit a5b29539b117bd9d1504eb1135bc212e985b46c1
parent 9e438cdce16ed63ac10cec3a97b20950707d9d73
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sun, 16 Aug 2015 12:20:24 +0000

Renaming and reordering most of 'help_line_len()'.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5363 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 1+
Msrc/help.c | 34+++++++++++++++++-----------------
2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -8,6 +8,7 @@ * src/help.c (help_line_len): The wrap location can be beyond the EOL, so for determining the length of the current line, don't start at that location but at the beginning. This fixes Savannah bug #45770. + * src/help.c (help_line_len): Rename and reorder most of it. 2015-08-13 Benno Schulenberg <bensberg@justemail.net> * src/search.c (do_find_bracket): Remove mistaken comparison between diff --git a/src/help.c b/src/help.c @@ -501,30 +501,30 @@ functionptrtype parse_help_input(int *kbinput) /* Calculate the displayable length of the help-text line starting at ptr. */ size_t help_line_len(const char *ptr) { - int help_cols = (COLS > 24) ? COLS - 1 : 24; + size_t wrapping_point = (COLS > 24) ? COLS - 1 : 24; /* The target width for wrapping long lines. */ + ssize_t wrap_location; + /* Actual position where the line can be wrapped. */ + size_t length = 0; + /* Full length of the line, until the first newline. */ /* Avoid overwide paragraphs in the introductory text. */ if (ptr < end_of_intro && COLS > 74) - help_cols = 74; + wrapping_point = 74; - ssize_t wrap_loc = break_line(ptr, help_cols, TRUE); - size_t retval = (wrap_loc < 0) ? 0 : wrap_loc; - size_t retval_save = retval; - - retval = 0; + wrap_location = break_line(ptr, wrapping_point, TRUE); /* 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 one 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 + 1) - retval = retval_save; - - return retval; + while (*(ptr + length) != '\0' && *(ptr + length) != '\n') + length = move_mbright(ptr, length); + + /* If the entire line will just fit the screen, don't wrap it. */ + if (strnlenpt(ptr, length) <= wrapping_point + 1) + return length; + else if (wrap_location > 0) + return wrap_location; + else + return 0; } #endif /* !DISABLE_HELP */