Example #1
0
/* toUpper:
 * Convert characters to uppercase
 */
char *toUpper(Expr_t * pgm, char *s, Sfio_t* tmps)
{
    int c;

    while ((c = *s++))
	sfputc (tmps, toupper (c));

    return exstring(pgm, sfstruse(tmps));
}
Example #2
0
/* canon:
 * Canonicalize a string for printing.
 */
char *canon(Expr_t * pgm, char *arg)
{
    char *p;

    p = agcanonStr(arg);
    if (p != arg)
	p = exstring(pgm, p);

    return p;
}
Example #3
0
/*
 * Read single line from stream.
 * Return "" on EOF.
 */
char *readLine(Expr_t * ex, int fd)
{
    Sfio_t *sp;
    int c;
    Sfio_t *tmps;
    char *line;

    if (fd < 0 || fd >= elementsof(ex->file) || !((sp = ex->file[fd]))) {
	exerror("readL: %d: invalid descriptor", fd);
	return exstring(ex, "");
    }
    tmps = sfstropen();
    while (((c = sfgetc(sp)) > 0) && (c != '\n'))
	sfputc(tmps, c);
    if (c == '\n')
	sfputc(tmps, c);
    line = exstring(ex, sfstruse(tmps));
    sfclose(tmps);
    return line;
}
Example #4
0
File: guiwin.c Project: mbert/elvis
static ELVBOOL gwcreategw(char *name, char *firstcmd)
{
    GUI_WINDOW      *gwp;
    DWORD           dwStyle = WS_CHILD | WS_CLIPSIBLINGS |
                              WS_BORDER | WS_VISIBLE;

    /* allocate a new GUI_WINDOW */
    if ((gwp = calloc (1, sizeof (GUI_WINDOW))) == NULL)
        return ElvFalse;
    gwp->nextp = gw_def_win.nextp;
    gw_def_win.nextp = gwp;
    gwp->bg = colorinfo[COLOR_FONT_NORMAL].bg;

    /* set default options */
    gwp->options = gw_def_win.options;
    o_font(gwp) = CHARdup(o_font(&gw_def_win));
    o_propfont(gwp) = CHARdup(o_propfont(&gw_def_win));
    o_titleformat(gwp) = CHARdup(o_titleformat(&gw_def_win));

    /* create the Windows windows */
    gwp->frameHWnd = CreateWindow ("ElvisFrameWnd", "WinElvis",
                                   WS_OVERLAPPEDWINDOW,
                                   CW_USEDEFAULT, 0,
                                   CW_USEDEFAULT, 0,
                                   NULL, NULL, hInst, NULL);
    gw_create_toolbar (gwp);
    gw_create_status_bar (gwp);
    if (o_scrollbar (gwp))
        dwStyle |= WS_VSCROLL;
    gwp->clientHWnd = CreateWindow ("ElvisClientWnd", NULL,
                                    dwStyle, 0, 0, 0, 0,
                                    gwp->frameHWnd, NULL, hInst, NULL);
    gwp->menuHndl = o_menubar (gwp) ?
                    LoadMenu (hInst, MAKEINTRESOURCE (IDM_ELVIS)) : NULL;
    SetMenu (gwp->frameHWnd, gwp->menuHndl);
    if (gwp->menuHndl != NULL)
        DrawMenuBar (gwp->frameHWnd);

    /* resize client window */
    SendMessage (gwp->frameHWnd, WM_SIZE, 0, 0);

    /* set the cursor */
    ShowCursor (FALSE);
    SetCursor (hLeftArrow);
    ShowCursor (TRUE);

    /* set the fonts */
    gw_set_fonts (gwp);

    /* set new title */
    gwretitle ((GUIWIN *)gwp, name);

    /* set window size */
    gw_get_win_size (gwp);
    gw_set_win_size (gwp, 0);

    /* tell elvis that we have a new window */
    eventcreate((GUIWIN *)gwp, &gwp->options.scrollbar, name,
                gwp->numrows, gwp->numcols);

    /* make window active */
    eventfocus((GUIWIN *)gwp, ElvTrue);
    gwp->active = 1;

    /* show the window */
    ShowWindow (gwp->frameHWnd, SW_SHOW);

    /* accept dragging of files */
    DragAcceptFiles (gwp->clientHWnd, TRUE);

    /* disable printing if no printing */
    if (!gw_printing_ok)
        gw_disable_printing (gwp);

    /* if there is a firstcmd, then execute it */
    if (firstcmd)
    {
        winoptions(winofgw((GUIWIN *)gwp));
        exstring(windefault, toCHAR(firstcmd), "+cmd");
    }

    return ElvTrue;
}