예제 #1
0
파일: clear.c 프로젝트: bugengine/BugEngine
int wclrtobot(WINDOW *win)
{
    int savey, savex;

    PDC_LOG(("wclrtobot() - called\n"));

    if (!win)
        return ERR;

    savey = win->_cury;
    savex = win->_curx;

    /* should this involve scrolling region somehow ? */

    if (win->_cury + 1 < win->_maxy)
    {
        win->_curx = 0;
        win->_cury++;
        for (; win->_maxy > win->_cury; win->_cury++)
            wclrtoeol(win);
        win->_cury = savey;
        win->_curx = savex;
    }
    wclrtoeol(win);

    PDC_sync(win);
    return OK;
}
예제 #2
0
int wvline(WINDOW *win, chtype ch, int n)
{
    int endpos, x;

    PDC_LOG(("wvline() - called\n"));

    if (!win || n < 1)
        return ERR;

    endpos = min(win->_cury + n, win->_maxy);
    x = win->_curx;

    ch = _attr_passthru(win, ch ? ch : ACS_VLINE);

    for (n = win->_cury; n < endpos; n++)
    {
        win->_y[n][x] = ch;

        if (x < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
            win->_firstch[n] = x;

        if (x > win->_lastch[n])
            win->_lastch[n] = x;
    }

    PDC_sync(win);

    return OK;
}
예제 #3
0
파일: clear.c 프로젝트: bugengine/BugEngine
int wclrtoeol(WINDOW *win)
{
    int x, y, minx;
    chtype blank, *ptr;

    PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n",
             win->_cury, win->_curx));

    if (!win)
        return ERR;

    y = win->_cury;
    x = win->_curx;

    /* wrs (4/10/93) account for window background */

    blank = win->_bkgd;

    for (minx = x, ptr = &win->_y[y][x]; minx < win->_maxx; minx++, ptr++)
        *ptr = blank;

    if (x < win->_firstch[y] || win->_firstch[y] == _NO_CHANGE)
        win->_firstch[y] = x;

    win->_lastch[y] = win->_maxx - 1;

    PDC_sync(win);
    return OK;
}
예제 #4
0
int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts)
{
    chtype *dest, newattr;
    int startpos, endpos;

    PDC_LOG(("wchgat() - called\n"));

    if (!win)
        return ERR;

    newattr = (attr & A_ATTRIBUTES) | COLOR_PAIR(color);

    startpos = win->_curx;
    endpos = ((n < 0) ? win->_maxx : min(startpos + n, win->_maxx)) - 1;
    dest = win->_y[win->_cury];

    for (n = startpos; n <= endpos; n++)
        dest[n] = (dest[n] & A_CHARTEXT) | newattr;

    n = win->_cury;

    if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
        win->_firstch[n] = startpos;

    if (endpos > win->_lastch[n])
        win->_lastch[n] = endpos;

    PDC_sync(win);

    return OK;
}
예제 #5
0
파일: delch.c 프로젝트: EvilTeach/Github
int wdelch(WINDOW *win)
{
    int y, x, maxx;
    chtype *temp1;

    PDC_LOG(("wdelch() - called\n"));

    if (!win)
        return ERR;

    y = win->_cury;
    x = win->_curx;
    maxx = win->_maxx - 1;
    temp1 = &win->_y[y][x];

    memmove(temp1, temp1 + 1, (maxx - x) * sizeof(chtype));

    /* wrs (4/10/93) account for window background */

    win->_y[y][maxx] = win->_bkgd;

    win->_lastch[y] = maxx;

    if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
        win->_firstch[y] = x;

    PDC_sync(win);

    return OK;
}
예제 #6
0
int whline(WINDOW *win, chtype ch, int n)
{
    chtype *dest;
    int startpos, endpos;

    PDC_LOG(("whline() - called\n"));

    if (!win || n < 1)
        return ERR;

    startpos = win->_curx;
    endpos = min(startpos + n, win->_maxx) - 1;
    dest = win->_y[win->_cury];
    ch = _attr_passthru(win, ch ? ch : ACS_HLINE);

    for (n = startpos; n <= endpos; n++)
        dest[n] = ch;

    n = win->_cury;

    if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
        win->_firstch[n] = startpos;

    if (endpos > win->_lastch[n])
        win->_lastch[n] = endpos;

    PDC_sync(win);

    return OK;
}
예제 #7
0
int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, 
            chtype tl, chtype tr, chtype bl, chtype br)
{
    int i, ymax, xmax;

    PDC_LOG(("wborder() - called\n"));

    if (!win)
        return ERR;

    ymax = win->_maxy - 1;
    xmax = win->_maxx - 1;

    ls = _attr_passthru(win, ls ? ls : ACS_VLINE);
    rs = _attr_passthru(win, rs ? rs : ACS_VLINE);
    ts = _attr_passthru(win, ts ? ts : ACS_HLINE);
    bs = _attr_passthru(win, bs ? bs : ACS_HLINE);
    tl = _attr_passthru(win, tl ? tl : ACS_ULCORNER);
    tr = _attr_passthru(win, tr ? tr : ACS_URCORNER);
    bl = _attr_passthru(win, bl ? bl : ACS_LLCORNER);
    br = _attr_passthru(win, br ? br : ACS_LRCORNER);

    for (i = 1; i < xmax; i++)
    {
        win->_y[0][i] = ts;
        win->_y[ymax][i] = bs;
    }

    for (i = 1; i < ymax; i++)
    {
        win->_y[i][0] = ls;
        win->_y[i][xmax] = rs;
    }

    win->_y[0][0] = tl;
    win->_y[0][xmax] = tr;
    win->_y[ymax][0] = bl;
    win->_y[ymax][xmax] = br;

    for (i = 0; i <= ymax; i++)
    {
        win->_firstch[i] = 0;
        win->_lastch[i] = xmax;
    }

    PDC_sync(win);

    return OK;
}
예제 #8
0
파일: scroll.c 프로젝트: hulu1528/PDCurses
int wscrl(WINDOW *win, int n)
{
    int i, l, dir, start, end;
    chtype blank, *temp;

    /* Check if window scrolls. Valid for window AND pad */

    if (!win || !win->_scroll || !n)
        return ERR;

    blank = win->_bkgd;

    if (n > 0)
    {
        start = win->_tmarg;
        end = win->_bmarg;
        dir = 1;
    }
    else
    {
        start = win->_bmarg;
        end = win->_tmarg;
        dir = -1;
    }

    for (l = 0; l < (n * dir); l++) 
    {
        temp = win->_y[start];

        /* re-arrange line pointers */

        for (i = start; i != end; i += dir)
            win->_y[i] = win->_y[i + dir];

        win->_y[end] = temp;

        /* make a blank line */

        for (i = 0; i < win->_maxx; i++)
            *temp++ = blank;
    }

    touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1);

    PDC_sync(win);
    return OK;
}
예제 #9
0
파일: bkgd.c 프로젝트: hulu1528/PDCurses
int wbkgd(WINDOW *win, chtype ch)
{
    int x, y;
    chtype oldcolr, oldch, newcolr, newch, colr, attr;
    chtype oldattr = 0, newattr = 0;
    chtype *winptr;

    PDC_LOG(("wbkgd() - called\n"));

    if (!win)
        return ERR;

    if (win->_bkgd == ch)
        return OK;

    oldcolr = win->_bkgd & A_COLOR;
    if (oldcolr)
        oldattr = (win->_bkgd & A_ATTRIBUTES) ^ oldcolr;

    oldch = win->_bkgd & A_CHARTEXT;

    wbkgdset(win, ch);

    newcolr = win->_bkgd & A_COLOR;
    if (newcolr)
        newattr = (win->_bkgd & A_ATTRIBUTES) ^ newcolr;

    newch = win->_bkgd & A_CHARTEXT;

    /* what follows is what seems to occur in the System V 
       implementation of this routine */

    for (y = 0; y < win->_maxy; y++)
    {
        for (x = 0; x < win->_maxx; x++)
        {
            winptr = win->_y[y] + x;

            ch = *winptr;

            /* determine the colors and attributes of the character read 
               from the window */

            colr = ch & A_COLOR;
            attr = ch & (A_ATTRIBUTES ^ A_COLOR);

            /* if the color is the same as the old background color, 
               then make it the new background color, otherwise leave it */

            if (colr == oldcolr)
                colr = newcolr;

            /* remove any attributes (non color) from the character that 
               were part of the old background, then combine the 
               remaining ones with the new background */

            attr ^= oldattr;
            attr |= newattr;

            /* change character if it is there because it was the old 
               background character */

            ch &= A_CHARTEXT;
            if (ch == oldch)
                ch = newch;

            ch |= (attr | colr);

            *winptr = ch;

        }
    }

    touchwin(win);
    PDC_sync(win);
    return OK;
}
예제 #10
0
파일: insch.c 프로젝트: bugengine/BugEngine
int winsch(WINDOW *win, chtype ch)
{
    int x, y;
    chtype attr;
    bool xlat;

    PDC_LOG(("winsch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
             win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));

    if (!win)
        return ERR;

    x = win->_curx;
    y = win->_cury;

    if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
        return ERR;

    xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
    attr = ch & A_ATTRIBUTES;
    ch &= A_CHARTEXT;

    if (xlat && (ch < ' ' || ch == 0x7f))
    {
        int x2;

        switch (ch)
        {
        case '\t':
            for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++)
            {
                if (winsch(win, attr | ' ') == ERR)
                    return ERR;
            }
            return OK;

        case '\n':
            wclrtoeol(win);
            break;

        case 0x7f:
            if (winsch(win, attr | '?') == ERR)
                return ERR;

            return winsch(win, attr | '^');

        default:
            /* handle control chars */

            if (winsch(win, attr | (ch + '@')) == ERR)
                return ERR;

            return winsch(win, attr | '^');
        }
    }
    else
    {
        int maxx;
        chtype *temp;

        /* If the incoming character doesn't have its own attribute,
           then use the current attributes for the window. If it has
           attributes but not a color component, OR the attributes to
           the current attributes for the window. If it has a color
           component, use the attributes solely from the incoming
           character. */

        if (!(attr & A_COLOR))
            attr |= win->_attrs;

        /* wrs (4/10/93): Apply the same sort of logic for the window
           background, in that it only takes precedence if other color
           attributes are not there and that the background character
           will only print if the printing character is blank. */

        if (!(attr & A_COLOR))
            attr |= win->_bkgd & A_ATTRIBUTES;
        else
            attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);

        if (ch == ' ')
            ch = win->_bkgd & A_CHARTEXT;

        /* Add the attribute back into the character. */

        ch |= attr;

        maxx = win->_maxx;
        temp = &win->_y[y][x];

        memmove(temp + 1, temp, (maxx - x - 1) * sizeof(chtype));

        win->_lastch[y] = maxx - 1;

        if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
            win->_firstch[y] = x;

        *temp = ch;
    }

    PDC_sync(win);

    return OK;
}
예제 #11
0
파일: addch.cpp 프로젝트: chenbk85/QOR
//------------------------------------------------------------------------------
int waddch( WINDOW* win, const chtype ch )
{
	__QCS_FCONTEXT( "waddch" );

    int x, y;
    chtype text, attr;
    bool xlat;

    PDC_LOG(("waddch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
             win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));

    if( !win )
	{
        return ERR;
	}

    x = win->_curx;
    y = win->_cury;

    if( y > win->_maxy || x > win->_maxx || y < 0 || x < 0 )
	{
        return ERR;
	}

    xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
    text = ch & A_CHARTEXT;
    attr = ch & A_ATTRIBUTES;

    if( xlat && ( text < ' ' || text == 0x7f ) )
    {
        int x2;

        switch( text )
        {
        case '\t':
            for( x2 = ( ( x / TABSIZE ) + 1 ) * TABSIZE; x < x2; x++ )
            {
                if( waddch( win, attr | ' ' ) == ERR )
				{
                    return ERR;
				}

                // if tab to next line, exit the loop

                if( !win->_curx )
				{
                    break;
				}
            }
            return 0;

        case '\n':
            // if lf -> crlf

            if( !SP->raw_out )
			{
                x = 0;
			}

            wclrtoeol( win );

            if( ++y > win->_bmarg )
            {
                y--;

                if( wscrl( win, 1 ) == ERR )
				{
                    return ERR;
				}
            }

            break;

        case '\b':
            // don't back over left margin

            if( --x < 0 )
        case '\r':
			{
                x = 0;
			}
            break;

        case 0x7f:

            if( waddch( win, attr | '^' ) == ERR )
			{
                return ERR;
			}

            return waddch( win, attr | '?' );

        default:
            // handle control chars

            if( waddch( win, attr | '^' ) == ERR )
			{
                return ERR;
			}

            return waddch( win, ch + '@' );
        }
    }
    else
    {
        /* If the incoming character doesn't have its own attribute,
           then use the current attributes for the window. If it has
           attributes but not a color component, OR the attributes to
           the current attributes for the window. If it has a color
           component, use the attributes solely from the incoming
           character. */

        if( !( attr & A_COLOR ) )
		{
            attr |= win->_attrs;
		}

        /* wrs (4/10/93): Apply the same sort of logic for the window 
           background, in that it only takes precedence if other color 
           attributes are not there and that the background character 
           will only print if the printing character is blank. */

        if( !( attr & A_COLOR ) )
		{
            attr |= win->_bkgd & A_ATTRIBUTES;
		}
        else
		{
            attr |= win->_bkgd & ( A_ATTRIBUTES ^ A_COLOR );
		}

        if( text == ' ' )
		{
            text = win->_bkgd & A_CHARTEXT;
		}

        // Add the attribute back into the character.

        text |= attr;

        /* Only change _firstch/_lastch if the character to be added is
           different from the character/attribute that is already in
           that position in the window. */

        if( win->_y[ y ][ x ] != text )
        {
            if( win->_firstch[ y ] == _NO_CHANGE )
			{
                win->_firstch[ y ] = win->_lastch[ y ] = x;
			}
            else
			{
                if( x < win->_firstch[ y ] )
				{
                    win->_firstch[ y ] = x;
				}
                else
				{
                    if( x > win->_lastch[ y ] )
					{
                        win->_lastch[ y ] = x;
					}
				}
			}

            win->_y[ y ][ x ] = text;
        }

        if( ++x >= win->_maxx )
        {
            // wrap around test

            x = 0;

            if( ++y > win->_bmarg )
            {
                y--;

                if( wscrl( win, 1 ) == ERR )
                {
                    PDC_sync( win );
                    return ERR;
                }
            }
        }
    }

    win->_curx = x;
    win->_cury = y;

    if( win->_immed )
	{
        wrefresh( win );
	}

    if( win->_sync )
	{
        wsyncup( win );
	}

    return 0;
}
예제 #12
0
파일: bkgd.cpp 프로젝트: chenbk85/QOR
//------------------------------------------------------------------------------
int wbkgd( WINDOW* win, chtype ch )
{
	__QCS_FCONTEXT( "wbkgd" );

    int x, y;
    chtype oldcolr, oldch, newcolr, newch, colr, attr;
    chtype oldattr = 0, newattr = 0;
    chtype *winptr;

    if( !win )
	{
        return ERR;
	}

    if( win->_bkgd == ch )
	{
        return 0;
	}

    oldcolr = win->_bkgd & A_COLOR;
    if( oldcolr )
	{
        oldattr = (win->_bkgd & A_ATTRIBUTES) ^ oldcolr;
	}

    oldch = win->_bkgd & A_CHARTEXT;

    wbkgdset( win, ch );

    newcolr = win->_bkgd & A_COLOR;
    if( newcolr )
	{
        newattr = (win->_bkgd & A_ATTRIBUTES) ^ newcolr;
	}

    newch = win->_bkgd & A_CHARTEXT;

    // what follows is what seems to occur in the System V implementation of this routine

    for( y = 0; y < win->_maxy; y++ )
    {
        for( x = 0; x < win->_maxx; x++ )
        {
            winptr = win->_y[ y ] + x;

            ch = *winptr;

            // determine the colors and attributes of the character read from the window

            colr = ch & A_COLOR;
            attr = ch & ( A_ATTRIBUTES ^ A_COLOR );

            // if the color is the same as the old background color, then make it the new background color, otherwise leave it 

            if( colr == oldcolr )
			{
                colr = newcolr;
			}

            // remove any attributes (non color) from the character that were part of the old background, then combine the remaining ones with the new background 

            attr ^= oldattr;
            attr |= newattr;

            // change character if it is there because it was the old background character

            ch &= A_CHARTEXT;
            if( ch == oldch )
			{
                ch = newch;
			}

            ch |= ( attr | colr );

            *winptr = ch;
        }
    }

    touchwin( win );
    PDC_sync( win );
    return 0;
}