static unsigned long hs_hash(const void *object, unsigned long seed) { const ck_key_t *c = object; unsigned long h; h = (unsigned long)__hash((const char *)c, c->len, seed); return h; }
WINDOW * __newwin(SCREEN *screen, int nlines, int ncols, int by, int bx, int ispad) { WINDOW *win; __LINE *lp; int i, j; int maxy, maxx; __LDATA *sp; if (by < 0 || bx < 0) return (NULL); maxy = nlines > 0 ? nlines : LINES - by + nlines; maxx = ncols > 0 ? ncols : COLS - bx + ncols; if ((win = __makenew(screen, maxy, maxx, by, bx, 0, ispad)) == NULL) return (NULL); win->bch = ' '; if (__using_color) win->battr = __default_color; else win->battr = 0; win->nextp = win; win->ch_off = 0; win->orig = NULL; win->reqy = nlines; win->reqx = ncols; #ifdef DEBUG __CTRACE(__CTRACE_WINDOW, "newwin: win->ch_off = %d\n", win->ch_off); #endif for (i = 0; i < maxy; i++) { lp = win->alines[i]; if (ispad) lp->flags = __ISDIRTY; else lp->flags = 0; for (sp = lp->line, j = 0; j < maxx; j++, sp++) { sp->attr = 0; #ifndef HAVE_WCHAR sp->ch = win->bch; #else sp->ch = ( wchar_t )btowc(( int ) win->bch ); sp->nsp = NULL; SET_WCOL( *sp, 1 ); #endif /* HAVE_WCHAR */ } lp->hash = __hash((char *)(void *)lp->line, (size_t) (ncols * __LDATASIZE)); } return (win); }
/* * This code is shared with mvwin(). */ void __set_subwin(WINDOW *orig, WINDOW *win) { int i; __LINE *lp, *olp; #ifdef HAVE_WCHAR __LDATA *cp; int j; nschar_t *np; #endif /* HAVE_WCHAR */ win->ch_off = win->begx - orig->begx; /* Point line pointers to line space. */ for (lp = win->lspace, i = 0; i < win->maxy; i++, lp++) { win->alines[i] = lp; olp = orig->alines[i + win->begy - orig->begy]; #ifdef DEBUG lp->sentinel = SENTINEL_VALUE; #endif lp->line = &olp->line[win->ch_off]; lp->firstchp = &olp->firstch; lp->lastchp = &olp->lastch; #ifndef HAVE_WCHAR lp->hash = __hash((char *)(void *)lp->line, (size_t) (win->maxx * __LDATASIZE)); #else for ( cp = lp->line, j = 0; j < win->maxx; j++, cp++ ) { lp->hash = __hash_more( &cp->ch, sizeof( wchar_t ), lp->hash ); lp->hash = __hash_more( &cp->attr, sizeof( wchar_t ), lp->hash ); if ( cp->nsp ) { np = cp->nsp; while ( np ) { lp->hash = __hash_more( &np->ch, sizeof( wchar_t ), lp->hash ); np = np->next; } } } #endif /* HAVE_WCHAR */ } #ifdef DEBUG __CTRACE(__CTRACE_WINDOW, "__set_subwin: win->ch_off = %d\n", win->ch_off); #endif }
uint32_t mtev_hash__hash(const char *k, uint32_t length, uint32_t initval) { return __hash(k,length,initval); }
/* * __resizewin -- * Resize the given window. */ static int __resizewin(WINDOW *win, int nlines, int ncols) { __LINE *lp, *olp, **newlines, *newlspace; __LDATA *sp; __LDATA *newwspace; int i, j; int y, x; WINDOW *swin; #ifdef DEBUG __CTRACE(__CTRACE_WINDOW, "resize: (%p, %d, %d)\n", win, nlines, ncols); __CTRACE(__CTRACE_WINDOW, "resize: win->wattr = %08x\n", win->wattr); __CTRACE(__CTRACE_WINDOW, "resize: win->flags = %#.4x\n", win->flags); __CTRACE(__CTRACE_WINDOW, "resize: win->maxy = %d\n", win->maxy); __CTRACE(__CTRACE_WINDOW, "resize: win->maxx = %d\n", win->maxx); __CTRACE(__CTRACE_WINDOW, "resize: win->begy = %d\n", win->begy); __CTRACE(__CTRACE_WINDOW, "resize: win->begx = %d\n", win->begx); __CTRACE(__CTRACE_WINDOW, "resize: win->scr_t = %d\n", win->scr_t); __CTRACE(__CTRACE_WINDOW, "resize: win->scr_b = %d\n", win->scr_b); #endif /* * free up any non-spacing storage before we lose the * pointers... */ #ifdef HAVE_WCHAR __cursesi_win_free_nsp(win); #endif if (nlines <= 0 || ncols <= 0) nlines = ncols = 0; else { /* Reallocate line pointer array and line space. */ newlines = realloc(win->alines, nlines * sizeof(__LINE *)); if (newlines == NULL) return ERR; win->alines = newlines; newlspace = realloc(win->lspace, nlines * sizeof(__LINE)); if (newlspace == NULL) return ERR; win->lspace = newlspace; } /* Don't allocate window and line space if it's a subwindow */ if (win->orig == NULL) { /* * Allocate window space in one chunk. */ if (ncols != 0) { newwspace = realloc(win->wspace, ncols * nlines * sizeof(__LDATA)); if (newwspace == NULL) return ERR; win->wspace = newwspace; } /* * Point line pointers to line space, and lines themselves into * window space. */ for (lp = win->lspace, i = 0; i < nlines; i++, lp++) { win->alines[i] = lp; lp->line = &win->wspace[i * ncols]; #ifdef DEBUG lp->sentinel = SENTINEL_VALUE; #endif lp->firstchp = &lp->firstch; lp->lastchp = &lp->lastch; lp->firstch = 0; lp->lastch = ncols - 1; lp->flags = __ISDIRTY; } } else { win->ch_off = win->begx - win->orig->begx; /* Point line pointers to line space. */ for (lp = win->lspace, i = 0; i < nlines; i++, lp++) { win->alines[i] = lp; olp = win->orig->alines[i + win->begy - win->orig->begy]; lp->line = &olp->line[win->ch_off]; #ifdef DEBUG lp->sentinel = SENTINEL_VALUE; #endif lp->firstchp = &olp->firstch; lp->lastchp = &olp->lastch; lp->flags = __ISDIRTY; } } win->cury = win->curx = 0; win->maxy = nlines; win->maxx = ncols; win->scr_b = win->maxy - 1; __swflags(win); /* * we must zot the window contents otherwise lines may pick * up attributes from the previous line when the window is * made smaller. The client will redraw the window anyway * so this is no big deal. */ for (i = 0; i < win->maxy; i++) { lp = win->alines[i]; for (sp = lp->line, j = 0; j < win->maxx; j++, sp++) { sp->attr = 0; #ifndef HAVE_WCHAR sp->ch = win->bch; #else sp->ch = ( wchar_t )btowc(( int ) win->bch ); sp->nsp = NULL; if (_cursesi_copy_nsp(win->bnsp, sp) == ERR) return ERR; SET_WCOL( *sp, 1 ); #endif /* HAVE_WCHAR */ } lp->hash = __hash((char *)(void *)lp->line, (size_t) (ncols * __LDATASIZE)); } #ifdef DEBUG __CTRACE(__CTRACE_WINDOW, "resize: win->wattr = %08x\n", win->wattr); __CTRACE(__CTRACE_WINDOW, "resize: win->flags = %#.4x\n", win->flags); __CTRACE(__CTRACE_WINDOW, "resize: win->maxy = %d\n", win->maxy); __CTRACE(__CTRACE_WINDOW, "resize: win->maxx = %d\n", win->maxx); __CTRACE(__CTRACE_WINDOW, "resize: win->begy = %d\n", win->begy); __CTRACE(__CTRACE_WINDOW, "resize: win->begx = %d\n", win->begx); __CTRACE(__CTRACE_WINDOW, "resize: win->scr_t = %d\n", win->scr_t); __CTRACE(__CTRACE_WINDOW, "resize: win->scr_b = %d\n", win->scr_b); #endif if (win->orig == NULL) { /* bound subwindows to new size and fixup their pointers */ for (swin = win->nextp; swin != win; swin = swin->nextp) { y = swin->reqy; if (swin->begy > win->begy + win->maxy) swin->begy = win->begy + win->maxy - 1; if (swin->begy + y > win->begy + win->maxy) y = 0; if (y <= 0) y += win->begy + win->maxy - swin->begy; if (y < 1) y = 1; x = swin->reqx; if (swin->begx > win->begx + win->maxx) swin->begx = win->begx + win->maxx - 1; if (swin->begx + x > win->begx + win->maxx) x = 0; if (x <= 0) x += win->begy + win->maxx - swin->begx; if (x < 1) x = 1; __resizewin(swin, y, x); } } return OK; }