1 /* $NetBSD: border.c,v 1.13 2010/02/23 19:48:26 drochner Exp $ */ 2 3 /* 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Julian Coleman. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 #ifndef lint 34 __RCSID("$NetBSD: border.c,v 1.13 2010/02/23 19:48:26 drochner Exp $"); 35 #endif /* not lint */ 36 37 #include <stdlib.h> 38 #include <string.h> 39 40 #include "curses.h" 41 #include "curses_private.h" 42 43 #ifndef _CURSES_USE_MACROS 44 45 /* 46 * border -- 47 * Draw a border around stdscr using the specified 48 * delimiting characters. 49 */ 50 int 51 border(chtype left, chtype right, chtype top, chtype bottom, chtype topleft, 52 chtype topright, chtype botleft, chtype botright) 53 { 54 return wborder(stdscr, left, right, top, bottom, topleft, topright, 55 botleft, botright); 56 } 57 58 #endif 59 60 /* 61 * wborder -- 62 * Draw a border around the given window using the specified delimiting 63 * characters. 64 */ 65 int 66 wborder(WINDOW *win, chtype left, chtype right, chtype top, chtype bottom, 67 chtype topleft, chtype topright, chtype botleft, chtype botright) 68 { 69 #ifndef HAVE_WCHAR 70 int endy, endx, i; 71 __LDATA *fp, *lp; 72 73 if (!(left & __CHARTEXT)) 74 left |= ACS_VLINE; 75 if (!(right & __CHARTEXT)) 76 right |= ACS_VLINE; 77 if (!(top & __CHARTEXT)) 78 top |= ACS_HLINE; 79 if (!(bottom & __CHARTEXT)) 80 bottom |= ACS_HLINE; 81 if (!(topleft & __CHARTEXT)) 82 topleft |= ACS_ULCORNER; 83 if (!(topright & __CHARTEXT)) 84 topright |= ACS_URCORNER; 85 if (!(botleft & __CHARTEXT)) 86 botleft |= ACS_LLCORNER; 87 if (!(botright & __CHARTEXT)) 88 botright |= ACS_LRCORNER; 89 90 #ifdef DEBUG 91 __CTRACE(__CTRACE_INPUT, "wborder: left = %c, 0x%x\n", 92 left & __CHARTEXT, left & __ATTRIBUTES); 93 __CTRACE(__CTRACE_INPUT, "wborder: right = %c, 0x%x\n", 94 right & __CHARTEXT, right & __ATTRIBUTES); 95 __CTRACE(__CTRACE_INPUT, "wborder: top = %c, 0x%x\n", 96 top & __CHARTEXT, top & __ATTRIBUTES); 97 __CTRACE(__CTRACE_INPUT, "wborder: bottom = %c, 0x%x\n", 98 bottom & __CHARTEXT, bottom & __ATTRIBUTES); 99 __CTRACE(__CTRACE_INPUT, "wborder: topleft = %c, 0x%x\n", 100 topleft & __CHARTEXT, topleft & __ATTRIBUTES); 101 __CTRACE(__CTRACE_INPUT, "wborder: topright = %c, 0x%x\n", 102 topright & __CHARTEXT, topright & __ATTRIBUTES); 103 __CTRACE(__CTRACE_INPUT, "wborder: botleft = %c, 0x%x\n", 104 botleft & __CHARTEXT, botleft & __ATTRIBUTES); 105 __CTRACE(__CTRACE_INPUT, "wborder: botright = %c, 0x%x\n", 106 botright & __CHARTEXT, botright & __ATTRIBUTES); 107 #endif 108 109 /* Merge window and background attributes */ 110 left |= (left & __COLOR) ? (win->wattr & ~__COLOR) : win->wattr; 111 left |= (left & __COLOR) ? (win->battr & ~__COLOR) : win->battr; 112 right |= (right & __COLOR) ? (win->wattr & ~__COLOR) : win->wattr; 113 right |= (right & __COLOR) ? (win->battr & ~__COLOR) : win->battr; 114 top |= (top & __COLOR) ? (win->wattr & ~__COLOR) : win->wattr; 115 top |= (top & __COLOR) ? (win->battr & ~__COLOR) : win->battr; 116 bottom |= (bottom & __COLOR) ? (win->wattr & ~__COLOR) : win->wattr; 117 bottom |= (bottom & __COLOR) ? (win->battr & ~__COLOR) : win->battr; 118 topleft |= (topleft & __COLOR) ? (win->wattr & ~__COLOR) : win->wattr; 119 topleft |= (topleft & __COLOR) ? (win->battr & ~__COLOR) : win->battr; 120 topright |= (topright & __COLOR) ? (win->wattr & ~__COLOR) : win->wattr; 121 topright |= (topright & __COLOR) ? (win->battr & ~__COLOR) : win->battr; 122 botleft |= (botleft & __COLOR) ? (win->wattr & ~__COLOR) : win->wattr; 123 botleft |= (botleft & __COLOR) ? (win->battr & ~__COLOR) : win->battr; 124 botright |= (botright & __COLOR) ? (win->wattr & ~__COLOR) : win->wattr; 125 botright |= (botright & __COLOR) ? (win->battr & ~__COLOR) : win->battr; 126 127 endx = win->maxx - 1; 128 endy = win->maxy - 1; 129 fp = win->alines[0]->line; 130 lp = win->alines[endy]->line; 131 132 /* Sides */ 133 for (i = 1; i < endy; i++) { 134 win->alines[i]->line[0].ch = (wchar_t) left & __CHARTEXT; 135 win->alines[i]->line[0].attr = (attr_t) left & __ATTRIBUTES; 136 win->alines[i]->line[endx].ch = (wchar_t) right & __CHARTEXT; 137 win->alines[i]->line[endx].attr = (attr_t) right & __ATTRIBUTES; 138 } 139 for (i = 1; i < endx; i++) { 140 fp[i].ch = (wchar_t) top & __CHARTEXT; 141 fp[i].attr = (attr_t) top & __ATTRIBUTES; 142 lp[i].ch = (wchar_t) bottom & __CHARTEXT; 143 lp[i].attr = (attr_t) bottom & __ATTRIBUTES; 144 } 145 146 /* Corners */ 147 if (!(win->maxx == LINES && win->maxy == COLS && 148 (win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN))) { 149 fp[0].ch = (wchar_t) topleft & __CHARTEXT; 150 fp[0].attr = (attr_t) topleft & __ATTRIBUTES; 151 fp[endx].ch = (wchar_t) topright & __CHARTEXT; 152 fp[endx].attr = (attr_t) topright & __ATTRIBUTES; 153 lp[0].ch = (wchar_t) botleft & __CHARTEXT; 154 lp[0].attr = (attr_t) botleft & __ATTRIBUTES; 155 lp[endx].ch = (wchar_t) botright & __CHARTEXT; 156 lp[endx].attr = (attr_t) botright & __ATTRIBUTES; 157 } 158 __touchwin(win); 159 return (OK); 160 #else /* HAVE_WCHAR */ 161 cchar_t ls, rs, ts, bs, tl, tr, bl, br; 162 cchar_t *lsp, *rsp, *tsp, *bsp, *tlp, *trp, *blp, *brp; 163 164 #define S(in, out) \ 165 if (in & __CHARTEXT) { \ 166 __cursesi_chtype_to_cchar(in, &out); \ 167 out##p = &out; \ 168 } else \ 169 out##p = NULL 170 S(left, ls); 171 S(right, rs); 172 S(top, ts); 173 S(bottom, bs); 174 S(topleft, tl); 175 S(topright, tr); 176 S(botleft, bl); 177 S(botright, br); 178 #undef S 179 return wborder_set(win, lsp, rsp, tsp, bsp, tlp, trp, blp, brp); 180 #endif /* HAVE_WCHAR */ 181 } 182 183 int border_set(const cchar_t *ls, const cchar_t *rs, const cchar_t *ts, 184 const cchar_t *bs, const cchar_t *tl, const cchar_t *tr, 185 const cchar_t *bl, const cchar_t *br) 186 { 187 #ifndef HAVE_WCHAR 188 return ERR; 189 #else 190 return wborder_set(stdscr, ls, rs, ts, bs, tl, tr, bl, br); 191 #endif /* HAVE_WCHAR */ 192 } 193 194 int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs, 195 const cchar_t *ts, const cchar_t *bs, 196 const cchar_t *tl, const cchar_t *tr, 197 const cchar_t *bl, const cchar_t *br) 198 { 199 #ifndef HAVE_WCHAR 200 return ERR; 201 #else 202 int endy, endx, i, j, k, cw, pcw, tlcw, blcw, trcw, brcw; 203 cchar_t left, right, bottom, top, topleft, topright, botleft, botright; 204 nschar_t *np, *tnp; 205 206 if ( ls && wcwidth( ls->vals[ 0 ])) 207 memcpy( &left, ls, sizeof( cchar_t )); 208 else 209 memcpy( &left, WACS_VLINE, sizeof( cchar_t )); 210 if ( rs && wcwidth( rs->vals[ 0 ])) 211 memcpy( &right, rs, sizeof( cchar_t )); 212 else 213 memcpy( &right, WACS_VLINE, sizeof( cchar_t )); 214 if ( ts && wcwidth( ts->vals[ 0 ])) 215 memcpy( &top, ts, sizeof( cchar_t )); 216 else 217 memcpy( &top, WACS_HLINE, sizeof( cchar_t )); 218 if ( bs && wcwidth( bs->vals[ 0 ])) 219 memcpy( &bottom, bs, sizeof( cchar_t )); 220 else 221 memcpy( &bottom, WACS_HLINE, sizeof( cchar_t )); 222 if ( tl && wcwidth( tl->vals[ 0 ])) 223 memcpy( &topleft, tl, sizeof( cchar_t )); 224 else 225 memcpy( &topleft, WACS_ULCORNER, sizeof( cchar_t )); 226 if ( tr && wcwidth( tr->vals[ 0 ])) 227 memcpy( &topright, tr, sizeof( cchar_t )); 228 else 229 memcpy( &topright, WACS_URCORNER, sizeof( cchar_t )); 230 if ( bl && wcwidth( bl->vals[ 0 ])) 231 memcpy( &botleft, bl, sizeof( cchar_t )); 232 else 233 memcpy( &botleft, WACS_LLCORNER, sizeof( cchar_t )); 234 if ( br && wcwidth( br->vals[ 0 ])) 235 memcpy( &botright, br, sizeof( cchar_t )); 236 else 237 memcpy( &botright, WACS_LRCORNER, sizeof( cchar_t )); 238 239 #ifdef DEBUG 240 __CTRACE(__CTRACE_INPUT, "wborder_set: left = %c, 0x%x\n", 241 left.vals[0], left.attributes ); 242 __CTRACE(__CTRACE_INPUT, "wborder_set: right = %c, 0x%x\n", 243 right.vals[0], right.attributes ); 244 __CTRACE(__CTRACE_INPUT, "wborder_set: top = %c, 0x%x\n", 245 top.vals[0], top.attributes ); 246 __CTRACE(__CTRACE_INPUT, "wborder_set: bottom = %c, 0x%x\n", 247 bottom.vals[0], bottom.attributes ); 248 __CTRACE(__CTRACE_INPUT, "wborder_set: topleft = %c, 0x%x\n", 249 topleft.vals[0], topleft.attributes ); 250 __CTRACE(__CTRACE_INPUT, "wborder_set: topright = %c, 0x%x\n", 251 topright.vals[0], topright.attributes ); 252 __CTRACE(__CTRACE_INPUT, "wborder_set: botleft = %c, 0x%x\n", 253 botleft.vals[0], botleft.attributes ); 254 __CTRACE(__CTRACE_INPUT, "wborder_set: botright = %c, 0x%x\n", 255 botright.vals[0], botright.attributes ); 256 #endif 257 258 /* Merge window attributes */ 259 left.attributes |= (left.attributes & __COLOR) ? 260 (win->wattr & ~__COLOR) : win->wattr; 261 right.attributes |= (right.attributes & __COLOR) ? 262 (win->wattr & ~__COLOR) : win->wattr; 263 top.attributes |= (top.attributes & __COLOR) ? 264 (win->wattr & ~__COLOR) : win->wattr; 265 bottom.attributes |= (bottom.attributes & __COLOR) ? 266 (win->wattr & ~__COLOR) : win->wattr; 267 topleft.attributes |= (topleft.attributes & __COLOR) ? 268 (win->wattr & ~__COLOR) : win->wattr; 269 topright.attributes |= (topright.attributes & __COLOR) ? 270 (win->wattr & ~__COLOR) : win->wattr; 271 botleft.attributes |= (botleft.attributes & __COLOR) ? 272 (win->wattr & ~__COLOR) : win->wattr; 273 botright.attributes |= (botright.attributes & __COLOR) ? 274 (win->wattr & ~__COLOR) : win->wattr; 275 276 endx = win->maxx - 1; 277 endy = win->maxy - 1; 278 279 /* Sides */ 280 for (i = 1; i < endy; i++) { 281 /* left border */ 282 cw = wcwidth( left.vals[ 0 ]); 283 if (cw < 0) 284 cw = 1; 285 for ( j = 0; j < cw; j++ ) { 286 win->alines[i]->line[j].ch = left.vals[ 0 ]; 287 win->alines[i]->line[j].attr = left.attributes; 288 np = win->alines[i]->line[j].nsp; 289 if (np) { 290 while ( np ) { 291 tnp = np->next; 292 free( np ); 293 np = tnp; 294 } 295 win->alines[i]->line[j].nsp = NULL; 296 } 297 if ( j ) 298 SET_WCOL( win->alines[i]->line[j], -j ); 299 else { 300 SET_WCOL( win->alines[i]->line[j], cw ); 301 if ( left.elements > 1 ) { 302 for (k = 1; k < left.elements; k++) { 303 np = (nschar_t *)malloc(sizeof(nschar_t)); 304 if (!np) 305 return ERR; 306 np->ch = left.vals[ k ]; 307 np->next = win->alines[i]->line[j].nsp; 308 win->alines[i]->line[j].nsp 309 = np; 310 } 311 } 312 } 313 } 314 for ( j = cw; WCOL( win->alines[i]->line[j]) < 0; j++ ) { 315 #ifdef DEBUG 316 __CTRACE(__CTRACE_INPUT, 317 "wborder_set: clean out partial char[%d]", j); 318 #endif /* DEBUG */ 319 win->alines[i]->line[j].ch = ( wchar_t )btowc(win->bch); 320 if (_cursesi_copy_nsp(win->bnsp, 321 &win->alines[i]->line[j]) == ERR) 322 return ERR; 323 SET_WCOL( win->alines[i]->line[j], 1 ); 324 } 325 /* right border */ 326 cw = wcwidth( right.vals[ 0 ]); 327 if (cw < 0) 328 cw = 1; 329 pcw = WCOL( win->alines[i]->line[endx - cw]); 330 for ( j = endx - cw + 1; j <= endx; j++ ) { 331 win->alines[i]->line[j].ch = right.vals[ 0 ]; 332 win->alines[i]->line[j].attr = right.attributes; 333 np = win->alines[i]->line[j].nsp; 334 if (np) { 335 while ( np ) { 336 tnp = np->next; 337 free( np ); 338 np = tnp; 339 } 340 win->alines[i]->line[j].nsp = NULL; 341 } 342 if ( j == endx - cw + 1 ) { 343 SET_WCOL( win->alines[i]->line[j], cw ); 344 if ( right.elements > 1 ) { 345 for (k = 1; k < right.elements; k++) { 346 np = (nschar_t *)malloc(sizeof(nschar_t)); 347 if (!np) 348 return ERR; 349 np->ch = right.vals[ k ]; 350 np->next = win->alines[i]->line[j].nsp; 351 win->alines[i]->line[j].nsp 352 = np; 353 } 354 } 355 } else 356 SET_WCOL( win->alines[i]->line[j], 357 endx - cw + 1 - j ); 358 } 359 if ( pcw != 1 ) { 360 #ifdef DEBUG 361 __CTRACE(__CTRACE_INPUT, 362 "wborder_set: clean out partial chars[%d:%d]", 363 endx - cw + pcw, endx - cw ); 364 #endif /* DEBUG */ 365 k = pcw < 0 ? endx -cw + pcw : endx - cw; 366 for ( j = endx - cw; j >= k; j-- ) { 367 win->alines[i]->line[j].ch 368 = (wchar_t)btowc(win->bch); 369 if (_cursesi_copy_nsp(win->bnsp, 370 &win->alines[i]->line[j]) == ERR) 371 return ERR; 372 win->alines[i]->line[j].attr = win->battr; 373 SET_WCOL( win->alines[i]->line[j], 1 ); 374 } 375 } 376 } 377 tlcw = wcwidth( topleft.vals[ 0 ]); 378 if (tlcw < 0) 379 tlcw = 1; 380 blcw = wcwidth( botleft.vals[ 0 ]); 381 if (blcw < 0) 382 blcw = 1; 383 trcw = wcwidth( topright.vals[ 0 ]); 384 if (trcw < 0) 385 trcw = 1; 386 brcw = wcwidth( botright.vals[ 0 ]); 387 if (brcw < 0) 388 brcw = 1; 389 /* upper border */ 390 cw = wcwidth( top.vals[ 0 ]); 391 if (cw < 0) 392 cw = 1; 393 for (i = tlcw; i <= min( endx - cw, endx - trcw ); i += cw ) { 394 for ( j = 0; j < cw; j++ ) { 395 win->alines[ 0 ]->line[i + j].ch = top.vals[ 0 ]; 396 win->alines[ 0 ]->line[i + j].attr = top.attributes; 397 np = win->alines[ 0 ]->line[i + j].nsp; 398 if (np) { 399 while ( np ) { 400 tnp = np->next; 401 free( np ); 402 np = tnp; 403 } 404 win->alines[ 0 ]->line[i + j].nsp = NULL; 405 } 406 if ( j ) 407 SET_WCOL( win->alines[ 0 ]->line[ i + j ], -j ); 408 else { 409 SET_WCOL( win->alines[ 0 ]->line[ i + j ], cw ); 410 if ( top.elements > 1 ) { 411 for ( k = 1; k < top.elements; k++ ) { 412 np = (nschar_t *)malloc(sizeof(nschar_t)); 413 if (!np) 414 return ERR; 415 np->ch = top.vals[ k ]; 416 np->next = win->alines[0]->line[i + j].nsp; 417 win->alines[0]->line[i + j].nsp 418 = np; 419 } 420 } 421 } 422 } 423 } 424 while ( i <= endx - trcw ) { 425 win->alines[0]->line[i].ch = 426 ( wchar_t )btowc(( int ) win->bch ); 427 if (_cursesi_copy_nsp(win->bnsp, 428 &win->alines[0]->line[i]) == ERR) 429 return ERR; 430 win->alines[ 0 ]->line[ i ].attr = win->battr; 431 SET_WCOL( win->alines[ 0 ]->line[ i ], 1 ); 432 i++; 433 } 434 /* lower border */ 435 for (i = blcw; i <= min( endx - cw, endx - brcw ); i += cw ) { 436 for ( j = 0; j < cw; j++ ) { 437 win->alines[ endy ]->line[i + j].ch = bottom.vals[ 0 ]; 438 win->alines[endy]->line[i + j].attr = bottom.attributes; 439 np = win->alines[ endy ]->line[i + j].nsp; 440 if (np) { 441 while ( np ) { 442 tnp = np->next; 443 free( np ); 444 np = tnp; 445 } 446 win->alines[ endy ]->line[i + j].nsp = NULL; 447 } 448 if ( j ) 449 SET_WCOL( win->alines[endy]->line[i + j], -j); 450 else { 451 SET_WCOL( win->alines[endy]->line[i + j], cw ); 452 if ( bottom.elements > 1 ) { 453 for ( k = 1; k < bottom.elements; 454 k++ ) { 455 if ( !( np = ( nschar_t *)malloc( sizeof( nschar_t )))) 456 return ERR; 457 np->ch = bottom.vals[ k ]; 458 np->next = win->alines[endy]->line[i + j].nsp; 459 win->alines[endy]->line[i + j].nsp = np; 460 } 461 } 462 } 463 } 464 } 465 while ( i <= endx - brcw ) { 466 win->alines[endy]->line[i].ch = 467 (wchar_t)btowc((int) win->bch ); 468 if (_cursesi_copy_nsp(win->bnsp, 469 &win->alines[endy]->line[i]) == ERR) 470 return ERR; 471 win->alines[ endy ]->line[ i ].attr = win->battr; 472 SET_WCOL( win->alines[ endy ]->line[ i ], 1 ); 473 i++; 474 } 475 476 /* Corners */ 477 if (!(win->maxx == LINES && win->maxy == COLS && 478 (win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN))) { 479 for ( i = 0; i < tlcw; i++ ) { 480 win->alines[ 0 ]->line[i].ch = topleft.vals[ 0 ]; 481 win->alines[ 0 ]->line[i].attr = topleft.attributes; 482 np = win->alines[ 0 ]->line[i].nsp; 483 if (np) { 484 while ( np ) { 485 tnp = np->next; 486 free( np ); 487 np = tnp; 488 } 489 win->alines[ 0 ]->line[i].nsp = NULL; 490 } 491 if ( i ) 492 SET_WCOL( win->alines[ 0 ]->line[ i ], -i ); 493 else { 494 SET_WCOL( win->alines[ 0 ]->line[ i ], tlcw ); 495 if ( topleft.elements > 1 ) { 496 for ( k = 1; k < topleft.elements; 497 k++ ) { 498 np = (nschar_t *)malloc(sizeof(nschar_t)); 499 if (!np) 500 return ERR; 501 np->ch = topleft.vals[ k ]; 502 np->next = win->alines[ 0 ]->line[i].nsp; 503 win->alines[ 0 ]->line[i].nsp 504 = np; 505 } 506 } 507 } 508 } 509 for ( i = endx - trcw + 1; i <= endx; i++ ) { 510 win->alines[ 0 ]->line[i].ch = topright.vals[ 0 ]; 511 win->alines[ 0 ]->line[i].attr = topright.attributes; 512 np = win->alines[ 0 ]->line[i].nsp; 513 if (np) { 514 while ( np ) { 515 tnp = np->next; 516 free( np ); 517 np = tnp; 518 } 519 win->alines[ 0 ]->line[i].nsp = NULL; 520 } 521 if ( i == endx - trcw + 1 ) { 522 SET_WCOL( win->alines[ 0 ]->line[ i ], trcw ); 523 if ( topright.elements > 1 ) { 524 for ( k = 1; k < topright.elements; 525 k++ ) { 526 np = (nschar_t *)malloc(sizeof(nschar_t)); 527 if (!np) 528 return ERR; 529 np->ch = topright.vals[ k ]; 530 np->next = win->alines[0]->line[i].nsp; 531 win->alines[ 0 ]->line[i].nsp 532 = np; 533 } 534 } 535 } else 536 SET_WCOL( win->alines[ 0 ]->line[ i ], 537 endx - trcw + 1 - i ); 538 } 539 for ( i = 0; i < blcw; i++ ) { 540 win->alines[ endy ]->line[i].ch = botleft.vals[ 0 ]; 541 win->alines[ endy ]->line[i].attr = botleft.attributes; 542 np = win->alines[ endy ]->line[i].nsp; 543 if (np) { 544 while ( np ) { 545 tnp = np->next; 546 free( np ); 547 np = tnp; 548 } 549 win->alines[ endy ]->line[i].nsp = NULL; 550 } 551 if ( i ) 552 SET_WCOL( win->alines[endy]->line[i], -i ); 553 else { 554 SET_WCOL( win->alines[endy]->line[i], blcw ); 555 if ( botleft.elements > 1 ) { 556 for ( k = 1; k < botleft.elements; 557 k++ ) { 558 np = (nschar_t *)malloc(sizeof(nschar_t)); 559 if (!np) 560 return ERR; 561 np->ch = botleft.vals[ k ]; 562 np->next = win->alines[endy]->line[i].nsp; 563 win->alines[endy]->line[i].nsp 564 = np; 565 } 566 } 567 } 568 } 569 for ( i = endx - brcw + 1; i <= endx; i++ ) { 570 win->alines[ endy ]->line[i].ch = botright.vals[ 0 ]; 571 win->alines[ endy ]->line[i].attr = botright.attributes; 572 np = win->alines[ endy ]->line[i].nsp; 573 if (np) { 574 while ( np ) { 575 tnp = np->next; 576 free( np ); 577 np = tnp; 578 } 579 win->alines[ endy ]->line[i].nsp = NULL; 580 } 581 if ( i == endx - brcw + 1 ) { 582 SET_WCOL( win->alines[ endy ]->line[ i ], 583 brcw ); 584 if ( botright.elements > 1 ) { 585 for ( k = 1; k < botright.elements; k++ ) { 586 np = (nschar_t *)malloc(sizeof(nschar_t)); 587 if (!np) 588 return ERR; 589 np->ch = botright.vals[ k ]; 590 np->next = win->alines[endy]->line[i].nsp; 591 win->alines[endy]->line[i].nsp 592 = np; 593 } 594 } 595 } else 596 SET_WCOL( win->alines[ endy ]->line[ i ], 597 endx - brcw + 1 - i ); 598 } 599 } 600 __touchwin(win); 601 return (OK); 602 #endif /* HAVE_WCHAR */ 603 } 604