- /*
- * If the rendition is the same for the whole string, display it as a
- * quoted string, followed by the rendition. Otherwise, use the more
- * detailed trace function that displays each character separately.
- */
- if (same) {
- static const char d_quote[] =
- {D_QUOTE, 0};
-
- result = _nc_trace_bufcat(bufnum, d_quote);
- while (len-- > 0) {
- if ((found = _nc_altcharset_name(attr, CharOfD(buf))) != 0) {
- result = _nc_trace_bufcat(bufnum, found);
- attr &= ~A_ALTCHARSET;
- } else if (!isnac(CHDEREF(buf))) {
- PUTC_DATA;
-
- PUTC_INIT;
- do {
- PUTC_ch = PUTC_i < CCHARW_MAX ? buf->chars[PUTC_i] : L'\0';
- PUTC_n = wcrtomb(PUTC_buf, buf->chars[PUTC_i], &PUT_st);
- if (PUTC_ch == L'\0')
- --PUTC_n;
- if (PUTC_n <= 0)
- break;
- for (n = 0; n < PUTC_n; n++) {
+ return _nc_viswbuf2(0, mybuf);
+}
+#endif /* USE_WIDEC_SUPPORT */
+
+/* use these functions for displaying parts of a line within a window */
+NCURSES_EXPORT(const char *)
+_nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
+{
+ char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
+
+ if (result != 0) {
+ int first = 0;
+
+#if USE_WIDEC_SUPPORT
+ if (len < 0)
+ len = _nc_wchstrlen(buf);
+#endif /* USE_WIDEC_SUPPORT */
+
+ /*
+ * Display one or more strings followed by attributes.
+ */
+ while (first < len) {
+ attr_t attr = AttrOf(buf[first]);
+ int last = len - 1;
+ int j;
+
+ for (j = first + 1; j < len; ++j) {
+ if (!SameAttrOf(buf[j], buf[first])) {
+ last = j - 1;
+ break;
+ }
+ }
+
+ (void) _nc_trace_bufcat(bufnum, l_brace);
+ (void) _nc_trace_bufcat(bufnum, d_quote);
+ for (j = first; j <= last; ++j) {
+ const char *found = _nc_altcharset_name(attr, (chtype)
+ CharOf(buf[j]));
+ if (found != 0) {
+ (void) _nc_trace_bufcat(bufnum, found);
+ attr &= ~A_ALTCHARSET;
+ } else
+#if USE_WIDEC_SUPPORT
+ if (!isWidecExt(buf[j])) {
+ PUTC_DATA;
+
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+ int k;