⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xdisplay.c

📁 spice中支持多层次元件模型仿真的可单独运行的插件源码
💻 C
📖 第 1 页 / 共 2 页
字号:
                for (tl = top->seealso; tl; tl = tl->next)                    if (but == &tl->button)                        return (tl);                fprintf(stderr, "Ack, no matching button.\n");            }            break;                    default:            fprintf(stderr, "Strange event type %d\n", event.type);            break;        }    }}/* Kill a window. */voidhlp_xkillwin(top)    topic *top;{    topic *last;    if (top == topics)        topics = top->winlink;    else {        for (last = topics; last->winlink; last = last->winlink)            if (last->winlink == top) {                last->winlink = top->winlink;                break;            }        if (!last->winlink) {            fprintf(stderr, "window not in list!!\n");            return;        }    }    XDestroyWindow(top->win);    XFlush();    return;}static voidputtitle(top)    topic *top;{    XPixSet(top->win, 0, 0, top->xpix, titlefont->height + 1, BlackPixel);    XText(top->win, INT_BORDER, 0, top->title, strlen(top->title),            titlefont->id, WhitePixel, BlackPixel);    return;}/* Print text.  This is kind of tough, since we have to use different fonts * depending on whether we have bold, italic, or roman. */ static voiddrawtext(top, first, last)    topic *top;    int first, last;{    int i, curxpos, curypos;    wordlist *wl;    char *s, *t, save;    FontInfo *ft = regfont, *nft = regfont;    if (first < 0)        first = 0;    if (last >= top->lines)        last = top->lines - 1;    for (i = first, wl = top->text; i && wl; i--)        wl = wl->wl_next;    for (i = top->curtopline; i && wl; i--)        wl = wl->wl_next;    for (i = first; (i <= last) && wl; i++, wl = wl->wl_next) {        curxpos = INT_BORDER;        curypos = i * lineheight + INT_BORDER + titlefont->height;        for (s = wl->wl_word; *s; ) {            for (t = s; *t; t++) {                if ((t[0] == '\033') && (t[1] == 'G')) {                    nft = boldfont;                    break;                } else if ((t[0] == '\033') && (t[1] == 'H')) {                    nft = regfont;                    break;                } else if (t[0] == '\033') {                    nft = ft;                    break;                } else if ((t[0] == '_') && (t[1] == '\b')) {                    nft = italicfont;                    break;                } else if (ft == italicfont) {                    nft = regfont;                    t++;                    break;                }            }            /* Now print everything between s and t (but not *t) */            if (ft == boldfont)                XText(top->win, curxpos, curypos - 2, s, t - s,                    ft->id, BlackPixel, WhitePixel);            else                XText(top->win, curxpos, curypos, s, t - s,                    ft->id, BlackPixel, WhitePixel);            /* This is gross... */            save = *t;            *t = '\0';            curxpos += XStringWidth(s, ft, 0, 0);            *t = save;            if (*t && (ft != italicfont))                s = t + 2;            else                s = t;            ft = nft;        }    }    if (top->curtopline + MAX_LINES < top->numlines)        XText(top->win, top->xpix / 2, MAX_LINES * lineheight +                INT_BORDER + titlefont->height, "- more -", 8,                buttonfont->id, BlackPixel, WhitePixel);    else        XText(top->win, top->xpix / 2, MAX_LINES * lineheight +                INT_BORDER + titlefont->height, "        ", 8,                buttonfont->id, BlackPixel, WhitePixel);    return;}/* This draws a button in the button font, with a box around it. */static voiddrawbutton(top, but)    topic *top;    button *but;{    but->height = buttonfont->height + 6;    if ((hlp_buttonstyle != BS_UNIF) || (but->width == 0))        but->width = XStringWidth(but->text, buttonfont, 0, 0) + 6;    /* This should look sort of neat... */    XPixSet(top->win, but->x + 1, but->y + 1, but->width - 1,            but->height - 2, BlackPixel);    XPixSet(top->win, but->x + 2, but->y + 2, but->width - 3,            but->height - 4, WhitePixel);    XText(top->win, but->x + 3, but->y + 3, but->text, strlen(but->text),            buttonfont->id, BlackPixel, WhitePixel);    return;}#define within(but, xp, yp) (((xp) >= (but)->x) && ((xp) <= (but)->x + \        (but)->width) &&  ((yp) >= (but)->y) && ((yp) <= (but)->y + \        (but)->height))static button *findbutton(top, x, y)    topic *top;    int x, y;{    toplink *tl;    if (within(&top->but_quit, x, y))        return (&top->but_quit);    if (within(&top->but_delete, x, y))        return (&top->but_delete);    if (within(&top->but_next, x, y) && (top->numlines > MAX_LINES))        return (&top->but_next);    if (within(&top->but_prev, x, y) && (top->numlines > MAX_LINES))        return (&top->but_prev);    for (tl = top->subtopics; tl; tl = tl->next)        if (within(&tl->button, x, y))            return (&tl->button);    for (tl = top->seealso; tl; tl = tl->next)        if (within(&tl->button, x, y))            return (&tl->button);    return (NULL);}static voidcalcpos(tls, width)    toplink *tls;    int width;{    toplink *tl;    int maxwidth = 0, ncols, nrows, nbuts = 0, x, y;    if (!tls)        return;    for (tl = tls; tl; tl = tl->next) {        tl->button.width = XStringWidth(tl->button.text, buttonfont,                0, 0) + 6;        tl->button.height = buttonfont->height + 6;        if (tl->button.width + BUTTON_XPAD > maxwidth)            maxwidth = tl->button.width + BUTTON_XPAD;        nbuts++;    }    if (hlp_buttonstyle == BS_UNIF)        for (tl = tls; tl; tl = tl->next)            tl->button.width = maxwidth - BUTTON_XPAD;    ncols = width / maxwidth;    if (!ncols) {        fprintf(stderr, "Help, button too big!!\n");        return;    }    if (ncols > nbuts)        ncols = nbuts;    maxwidth = width / ncols;    nrows = nbuts / ncols;    if (nrows * ncols < nbuts)        nrows++;        for (tl = tls, x = y = 0; tl; tl = tl->next) {        if (x == ncols) {            fprintf(stderr, "Ack, too many buttons\n");            return;        }        if (hlp_buttonstyle == BS_CENTER)            tl->button.x = x * maxwidth + BUTTON_XPAD + (maxwidth -                    tl->button.width) / 2;        else            tl->button.x = x * maxwidth + BUTTON_XPAD;        tl->button.y = y * (buttonfont->height + 6 + BUTTON_YPAD) +                BUTTON_YPAD;        if (++y == nrows) {            y = 0;            x++;        }    }    return;}#define sq_overlap(x1, y1, w1, h1, x2, y2, w2, h2)      \    (!((((x1) < (x2)) && ((x1) + (w1) < (x2)) ||        \    ((x1) > (x2) + (w2)) && ((x1) + (w1) > (x2) + (w2))) || \    (((y1) < (y2)) && ((y1) + (h1) < (y2)) ||       \    ((y1) > (y2) + (h2)) && ((y1) + (h1) > (y2) + (h2)))))    static voidredraw(top, x, y, w, h)    topic *top;    int x, y, w, h;{    int y1 = (y - titlefont->height) / lineheight - 1;    int y2 = (y + h - titlefont->height) / lineheight + 1;    toplink *tl;    if (y < titlefont->height) {        puttitle(top);        drawbutton(top, &top->but_quit);        drawbutton(top, &top->but_delete);        if (top->numlines > MAX_LINES) {            drawbutton(top, &top->but_next);            drawbutton(top, &top->but_prev);        }    }    drawtext(top, y1, y2);    for (tl = top->subtopics; tl; tl = tl->next)        if (sq_overlap(x, y, w, h, tl->button.x, tl->button.y,                tl->button.width, tl->button.height))            drawbutton(top, &tl->button);    for (tl = top->seealso; tl; tl = tl->next)        if (sq_overlap(x, y, w, h, tl->button.x, tl->button.y,                tl->button.width, tl->button.height))            drawbutton(top, &tl->button);    if (top->subtopics)        XText(top->win, INT_BORDER, top->sublabypos,            SUB_TOPICS, strlen(SUB_TOPICS),            titlefont->id, BlackPixel, WhitePixel);    if (top->seealso)        XText(top->win, INT_BORDER, top->salabypos,            SEE_ALSO, strlen(SEE_ALSO),             titlefont->id, BlackPixel, WhitePixel);    return;}voidhlp_xwait(top, on)    topic *top;    bool on;{    XDefineCursor(top->win, on ? waitcur : cursor);    XFlush();    return;}#else#ifndef HAS_X11/* ARGSUSED */ bool hlp_xdisplay(top) topic *top; { return (false); }/* ARGSUSED */ void hlp_xkillwin(top) topic *top; { }#endif/* ARGSUSED */ void hlp_xwait(top, on) topic *top; bool on; { }void hlp_xclosedisplay() {}toplink * hlp_xhandle(pp) topic **pp; { *pp = NULL; return (NULL); }#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -