Exemple #1
0
/* ---------- SETTEXT Message ------------ */
static int SetTextMsg(WINDOW wnd, char *Buf)
{
   	unsigned char *tp, *ep, *ttp;
   	int x = 0;
   	int sz = 0;
	int rtn;

	tp = Buf;
    /* --- compute the buffer size based on tabs in the text --- */
    while (*tp)    {
        if (*tp == '\t')    {
            /* --- tab, adjust the buffer length --- */
            int sps = cfg.Tabs - (x % cfg.Tabs);
            sz += sps;
            x += sps;
        }
        else    {
            /* --- not a tab, count the character --- */
            sz++;
            x++;
        }
        if (*tp == '\n')
            x = 0;    /* newline, reset x --- */
        tp++;
    }
    /* --- allocate a buffer --- */
    ep = DFcalloc(1, sz+1);
    /* --- detab the input file --- */
    tp = Buf;
    ttp = ep;
    x = 0;
    while (*tp)    {
        /* --- put the character (\t, too) into the buffer --- */
        x++;
        /* --- expand tab into subst tab (\f + 0x80)
						and expansions (\t + 0x80) --- */
        if (*tp == '\t')	{
	        *ttp++ = sTab;	/* --- substitute tab character --- */
            while ((x % cfg.Tabs) != 0)
                *ttp++ = pTab, x++;
		}
		else	{
	        *ttp++ = *tp;
        	if (*tp == '\n')
            	x = 0;
		}
        tp++;
    }
    *ttp = '\0';
	rtn = BaseWndProc(EDITOR, wnd, SETTEXT, (PARAM) ep, 0);
    free(ep);
	return rtn;
}
Exemple #2
0
int foreground, background;   /* current video colors */

static void TopLine(WINDOW, int, RECT);

/* --------- create a window ------------ */
WINDOW CreateWindow(
    CLASS class,              /* class of this window       */
    char *ttl,                /* title or NULL              */
    int left, int top,        /* upper left coordinates     */
    int height, int width,    /* dimensions                 */
    void *extension,          /* pointer to additional data */
    WINDOW parent,            /* parent of this window      */
    int (*wndproc)(struct window *,enum messages,PARAM,PARAM),
    int attrib)               /* window attribute           */
{
    WINDOW wnd = DFcalloc(1, sizeof(struct window));
    get_videomode();
    if (wnd != NULL)    {
        int base;
        /* ----- height, width = -1: fill the screen ------- */
        if (height == -1)
            height = SCREENHEIGHT;
        if (width == -1)
            width = SCREENWIDTH;
        /* ----- coordinates -1, -1 = center the window ---- */
        if (left == -1)
            wnd->rc.lf = (SCREENWIDTH-width)/2;
        else
            wnd->rc.lf = left;
        if (top == -1)
            wnd->rc.tp = (SCREENHEIGHT-height)/2;