diff --git a/ChangeLog b/ChangeLog index 5e7b63c853113c0149b8d9a799250518d8e77dd9..48a1626142229076bd788808965568653475e020 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,13 +53,12 @@ CVS code - (mostly) work properly with files containing multibyte characters, and text display of such files should now (mostly) work properly as well. New functions control_rep(), - parse_char(), move_left(), move_right(), and - display_string_len(); changes to do_left(), do_right(), - do_delete(), breakable(), break_line(), do_output(), - get_buffer(), unget_input(), actual_x(), strnlenpt(), - display_string(), titlebar(), statusbar(), onekey(), - edit_add(), do_replace_highlight(), and do_credits(). (David - Benbennick and DLR) + parse_char(), move_left(), and move_right(); changes to + do_left(), do_right(), do_delete(), breakable(), break_line(), + do_output(), get_buffer(), unget_input(), actual_x(), + strnlenpt(), display_string(), titlebar(), statusbar(), + onekey(), edit_add(), do_replace_highlight(), and + do_credits(). (David Benbennick and DLR) - Overhaul the high-level input routines for the statusbar to make them read the shortcut lists for functions instead of manually running them, to make nanogetstr() less complex, and diff --git a/src/proto.h b/src/proto.h index 2f06b7910002c3c8d42169167f6125218f26176b..5c8e560a13649a229debf8124ecbef7a1f5fd89d 100644 --- a/src/proto.h +++ b/src/proto.h @@ -601,8 +601,6 @@ void blank_edit(void); void blank_statusbar(void); void check_statusblank(void); void blank_bottombars(void); -size_t display_string_len(const char *buf, size_t start_col, size_t - end_col); char *display_string(const char *buf, size_t start_col, size_t len, bool dollars); void nanoget_repaint(const char *buf, const char *inputbuf, size_t x); diff --git a/src/winio.c b/src/winio.c index fa424ee72dcd0076555858606c0ed6344a4ffa08..0ac50dee0634907f703522a9f516d540ed6de575 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2148,90 +2148,6 @@ void blank_bottombars(void) } } -/* buf is a multibyte string to be displayed. We need to expand tabs - * and control characters. How many bytes do we need to display? - * start_col is the column of *buf (usually 0). We display to - * (end_col - 1). */ -size_t display_string_len(const char *buf, size_t start_col, size_t - end_col) -{ - size_t retval = 0; - - assert(buf != NULL); - - /* Throughout the loop, we maintain the fact that *buf displays at - * column start_col. */ - while (start_col <= end_col && *buf != '\0') { - int wide_buf, mb_buf_len; -#ifdef NANO_WIDE - bool bad_char; -#endif - size_t old_col = start_col; - - mb_buf_len = parse_char(buf, &wide_buf -#ifdef NANO_WIDE - , &bad_char -#endif - , &start_col); - -#ifdef NANO_WIDE - /* If buf contains a null byte or an invalid multibyte - * character, interpret that character as though it's a wide - * character. */ - if (!ISSET(NO_UTF8) && bad_char) { - char *bad_mb_buf = charalloc(MB_CUR_MAX); - int bad_mb_buf_len; - - /* If we have a control character, add one byte to account - * for the "^" that will be displayed in front of it, and - * translate the character to its visible equivalent as - * returned by control_rep(). */ - if (is_cntrl_char(wide_buf)) { - retval++; - wide_buf = control_rep((unsigned char)wide_buf); - } - - /* Translate the wide character to its multibyte - * equivalent. */ - bad_mb_buf_len = wctomb(bad_mb_buf, (wchar_t)wide_buf); - - if (bad_mb_buf_len != -1) - retval += bad_mb_buf_len; - - free(bad_mb_buf); - } else { -#endif - /* If we have a tab, get its width in bytes using the - * current value of col. */ - if (wide_buf == '\t') - retval += start_col - old_col; - /* If we have a control character, add one byte to account - * for the "^" that will be displayed in front of it, and - * then add the number of bytes for its visible equivalent - * as returned by control_rep(). */ - else if (is_cntrl_char(wide_buf)) { - char ctrl_mb_buf = control_rep((unsigned char)wide_buf); - - retval++; - retval += parse_char(&ctrl_mb_buf, NULL -#ifdef NANO_WIDE - , NULL -#endif - , NULL); - /* If we have a normal character, add its width in bytes - * normally. */ - } else - retval += mb_buf_len; -#ifdef NANO_WIDE - } - - buf += mb_buf_len; -#endif - } - - return retval; -} - /* Convert buf into a string that can be displayed on screen. The * caller wants to display buf starting with column start_col, and * extending for at most len columns. start_col is zero-based. len is @@ -2266,14 +2182,12 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool assert(column <= start_col); - alloc_len = display_string_len(buf + start_index, start_col, - start_col + len); #ifdef NANO_WIDE if (!ISSET(NO_UTF8)) - alloc_len += MB_CUR_MAX * 2; + alloc_len = MB_CUR_MAX * (len + 2); else #endif - alloc_len += 2; + alloc_len = len + 2; converted = charalloc(alloc_len + 1); index = 0;