Esempio n. 1
0
/*
 * MarkOverlap - mark who a "new" window has overlapped
 */
void MarkOverlap( window_id wn )
{
    wind        *w, *wo;
    int         i, j, k;
    char        *whoover, *img;

    w = AccessWindow( wn );
    whoover = w->whooverlapping;

    for( j = w->y1; j <= w->y2; j++ ) {
        img = &ScreenImage[w->x1 + j * WindMaxWidth];
        for( i = w->x1; i <= w->x2; i++ ) {
            /*
             * if there is a character under us,
             * mark the window it belongs to as being overlapped,
             * and mark us as overlapping it
             */
            if( *img != NO_CHAR ) {
                wo = AccessWindow( *img );
                k = (i - wo->x1) + (j - wo->y1) * wo->width;
                wo->overlap[k] = (char) wn;
                wo->overcnt[j - wo->y1]++;
                ReleaseWindow( wo );
            }
            *whoover = *img;
            *img = (char) wn;
            img++;
            whoover++;
        }
    }
    ReleaseWindow( w );

} /* MarkOverlap */
Esempio n. 2
0
/*
 * PositionVerticalScrollThumb - draw the scroll thumb on the screen
 */
void PositionVerticalScrollThumb( window_id wn, linenum curr, linenum last )
{
    wind        *w;
    int         height;
    int         newpos;

    w = AccessWindow( wn );
    if( !w->has_gadgets || !w->has_border ) {
        ReleaseWindow( w );
        return;
    }
    height = w->y2 - w->y1 - THUMB_START * 2;
    if( height <= 0 ) {
        newpos = 0;
    } else if( curr == 1 ) {
        newpos = THUMB_START;
    } else {
        newpos = (int)(((long) (height - 1) * curr) / last) + THUMB_START + 1;
    }
    if( w->vert_scroll_pos != newpos ) {
        DrawVerticalThumb( w, EditVars.GadgetString[WB_RIGHTSIDE] );
    }
    w->vert_scroll_pos = newpos;
    DrawVerticalThumb( w, EditVars.GadgetString[WB_THUMB] );

    ReleaseWindow( w );

} /* PositionVerticalScrollThumb */
Esempio n. 3
0
/*
 * ShiftWindowUpDown - shift the stuff in a window in an up/down direction
 */
void ShiftWindowUpDown( window_id id, int diff )
{
    wind                *w;
    int                 start, spl, i, j;
    int                 sline, eline, add;
    char_info           _FAR *scr_d;
    char_info           *txt_s, *txt_d;

    if( EditFlags.DisplayHold || EditFlags.Quiet ) {
        return;
    }
    w = AccessWindow( id );
    if( w->has_border ) {
        start = 1;
        spl = 0;
    } else {
        start = 0;
        spl = -1;
    }
    if( diff < 0 ) {
        sline = w->text_lines + diff;
        eline = 1;
        add = -1;
    } else {
        sline = diff + 1;
        eline = w->text_lines;
        add = 1;
    }

    /*
     * current window is never overlapped, so we can just blast away
     */
    sline += spl;
    eline += spl;
    i = sline;
    while( 1 ) {
        txt_s = (char_info *) &w->text[(i * w->width + start) * sizeof( char_info )];
        txt_d = (char_info *) &w->text[((i - diff) * w->width + start) *
                                       sizeof( char_info )];
        scr_d = (char_info _FAR *) &Scrn[(w->x1 + start + (w->y1 + i - diff) *
                                          WindMaxWidth) * sizeof( char_info )];
        for( j = 0; j < w->text_cols; j++ ) {
            WRITE_SCREEN( scr_d[j], txt_s[j] );
            WRITE_SCREEN_DATA( txt_d[j], txt_s[j] );
        }
#ifdef __VIO__
        MyVioShowBuf( (unsigned)((char *) scr_d - Scrn), w->text_cols );
#endif
        if( i == eline ) {
            break;
        }
        i += add;
    }
    ReleaseWindow( w );

} /* ShiftWindowUpDown */
Esempio n. 4
0
/*
 * ClearWindow - do just that
 */
void ClearWindow( window_id wn )
{
    wind                *w;
    window_id           *over;
    char_info           *txt;
    char_info           _FAR *scr;
    unsigned            oscr;
    int                 j, i, shift, addr;
    char_info           what = {0, 0};

    if( EditFlags.Quiet ) {
        return;
    }
    w = AccessWindow( wn );

    /*
     * clear text area
     */
    what.cinfo_char = ' ';
    what.cinfo_attr = MAKE_ATTR( w, w->text_color, w->background_color );
    shift = 0;
    addr = 0;
    if( w->has_border ) {
        shift = 1;
        addr = w->width + shift;
    }
    for( j = w->y1 + shift; j <= w->y2 - shift; j++ ) {
        oscr = w->x1 + shift + j * EditVars.WindMaxWidth;
        scr = &Scrn[oscr];
        txt = &(w->text[addr]);
        over = &(w->overlap[addr]);
        for( i = w->x1 + shift; i <= w->x2 - shift; i++ ) {
            WRITE_SCREEN_DATA( *txt++, what );
            if( *over++ == NO_WINDOW ) {
                WRITE_SCREEN( *scr, what );
            }
            scr++;
        }
#ifdef __VIO__
        MyVioShowBuf( oscr, w->width - 2 * shift ); // inside of window only
#endif
        addr += w->width;
    }

    ReleaseWindow( w );

} /* ClearWindow */
Esempio n. 5
0
/*
 * ResizeWindow - give a window a new size
 */
vi_rc ResizeWindow( window_id wid, windim x1, windim y1, windim x2, windim y2, bool scrflag )
{
    window      *oldw;
//    int         bt, k;
//    char        *txt, *tptr;
//    char        *ot;
//    int         i, j;

    oldw = WINDOW_FROM_ID( wid );
    AccessWindow( oldw );

    if( !ValidDimension( x1, y1, x2, y2, oldw->has_border ) ) {
        ReleaseWindow( oldw );
        return( ERR_WIND_INVALID );
    }
    RestoreOverlap( wid, scrflag );

    AllocWindow( wid, x1, y1, x2, y2, oldw->has_border, oldw->has_gadgets, true,
            oldw->border_color1, oldw->border_color2, oldw->text_color, oldw->background_color );
    MarkOverlap( wid );

    /*
     * display the new text
     */
    ClearWindow( wid );
    if( oldw->title != NULL ) {
        WindowTitle( wid, oldw->title );
    } else {
        DrawBorder( wid );
    }
    DCResize( CurrentInfo );
    DCDisplayAllLines();
    DCUpdate();

    FreeWindow( oldw );
    ReleaseWindow( WINDOW_FROM_ID( wid ) );

    return( ERR_NO_ERR );

} /* ResizeWindow */
Esempio n. 6
0
/*
 * ResetOverlap - set so no overlap of window
 */
void ResetOverlap( wind *w )
{
    char        *over, *whoover;
    int         i, j;

    AccessWindow( w->id );
    over = w->overlap;
    whoover = w->whooverlapping;

    for( j = w->y1; j <= w->y2; j++ ) {
        for( i = w->x1; i <= w->x2; i++ ) {
            *over++ = NO_CHAR;
            *whoover++ = NO_CHAR;
        }
    }

    for( i = 0; i < w->height; i++ ) {
        w->overcnt[i] = 0;
    }
    ReleaseWindow( w );

} /* ResetOverlap */
Esempio n. 7
0
/*
 * reDisplayWindow - redisplay the saved window text
 */
static void reDisplayWindow( window_id wn )
{
    wind                *w;
    char_info           *txt;
    window_id           *over;
    char_info           _FAR *scr;
    unsigned            oscr;
    int                 j, i;

    if( EditFlags.Quiet ) {
        return;
    }
    w = AccessWindow( wn );

    /*
     * re-display text area
     */
    txt = w->text;
    over = w->overlap;
    for( j = w->y1; j <= w->y2; j++ ) {
        oscr = w->x1 + j * EditVars.WindMaxWidth;
        scr = &Scrn[oscr];
        for( i = w->x1; i <= w->x2; i++ ) {
            if( *over++ == NO_WINDOW ) {
                WRITE_SCREEN( *scr, *txt );
            }
            scr++;
            txt++;
        }
#ifdef __VIO__
        MyVioShowBuf( oscr, w->width );
#endif
    }

    DrawBorder( wn );
    ReleaseWindow( w );

} /* reDisplayWindow */
Esempio n. 8
0
/*
 * RestoreOverlap - restore overlap information from a window that is
 *                  "going away" - either relocating or dying
 */
void RestoreOverlap( window_id wn, bool scrflag )
{
    wind                *w, *wo, *o;
    int                 i, j, k, l;
    char                *whoover, *over, *img;
    char_info           _FAR *scr;
#ifdef __VIO__
    unsigned            oscr;
#endif

    if( EditFlags.Quiet ) {
        scrflag = FALSE;
    }
    w = AccessWindow( wn );
    whoover = w->whooverlapping;
    over = w->overlap;

    for( j = w->y1; j <= w->y2; j++ ) {
        if( scrflag ) {
            scr = (char_info _FAR *) &Scrn[(w->x1 + j * WindMaxWidth) *
                                           sizeof( char_info )];
#ifdef __VIO__
            oscr = (unsigned) ((char *)scr - Scrn);
#endif
        }
        img = &ScreenImage[w->x1 + j * WindMaxWidth];
        for( i = w->x1; i <= w->x2; i++ ) {

            /*
             * if we are over someone, then reset the screen
             * with the proper information
             *
             * if we are not over someone, check for over us
             */
            if( *whoover != NO_CHAR ) {
                wo = AccessWindow( *whoover );
                k = (i - wo->x1) + (j - wo->y1) * wo->width;
                /*
                 * if we are being overlapped at the same
                 * spot, then point the guy overlapping us
                 * at the guy we are overlapping
                 *
                 * otherwise, mark the guy we are overlapping
                 * as not being overlapped, and restore his
                 * text to the screen
                 */
                if( *over != NO_CHAR ) {
                    o = AccessWindow( *over );
                    l = (i - o->x1) + (j - o->y1) * o->width;
                    o->whooverlapping[l] = *whoover;
                    wo->overlap[k] = *over;
                    ReleaseWindow( o );
                } else {
                    wo->overlap[k] = NO_CHAR;
                    wo->overcnt[j - wo->y1]--;
                    if( scrflag ) {
                        WRITE_SCREEN( *scr, ((char_info *)wo->text)[k] );
                    }
                    *img = *whoover;
                }
                ReleaseWindow( wo );
            } else {
                /*
                 * we are not overlapping anyone, so
                 * see if anyone is overlapping us;
                 * if so, reset them to be not overlapping
                 * anyone
                 *
                 * if not, clear the screen
                 */
                if( *over != NO_CHAR ) {
                    o = AccessWindow( *over );
                    l = (i - o->x1) + (j - o->y1) * o->width;
                    o->whooverlapping[l] = NO_CHAR;
                    ReleaseWindow( o );
                } else {
                    if( scrflag ) {
                        WRITE_SCREEN( *scr, WindowNormalAttribute );
                    }
                    *img = NO_CHAR;
                }
            }
            img++;
            over++;
            whoover++;
            if( scrflag ) {
                scr++;
            }
        }
#ifdef __VIO__
        if( scrflag ) {
            MyVioShowBuf( oscr, w->width );
        }
#endif

    }
    ReleaseWindow( w );

} /* RestoreOverlap */
Esempio n. 9
0
/*
 * ResizeWindow - give a window a new size
 */
vi_rc ResizeWindow( window_id wn, int x1, int y1, int x2, int y2, int scrflag )
{
    wind        *tmp, *w;
    int         bt, k;
//    char        *txt, *tptr;
//    char        *ot;
//    int         i, j;

    w = AccessWindow( wn );

    if( !ValidDimension( x1, y1, x2, y2, w->has_border ) ) {
        ReleaseWindow( w );
        return( ERR_WIND_INVALID );
    }

    tmp = AllocWindow( x1, y1, x2, y2, w->has_border, w->border_color1,
                       w->border_color2, w->text_color, w->background_color );
    tmp->id = wn;
    tmp->has_gadgets = w->has_gadgets;
    // txt = MemAlloc( w->width + 1 );
    // tptr = txt;

    RestoreOverlap( wn, scrflag );

    Windows[wn] = tmp;
    tmp->accessed = TRUE;
    ResetOverlap( tmp );
    MarkOverlap( wn );

    /*
     * display the new text
     */
    k = 1;
    bt = (int) w->has_border;
    ClearWindow( wn );
    if( w->title != NULL ) {
        WindowTitle( wn, w->title );
    } else {
        DrawBorder( wn );
    }
#if 0
    for( j = bt; j < w->height - bt; j++ ) {

        ot = &(w->text[(j * w->width) * sizeof( char_info )]);
        for( i = bt; i < w->width - bt; i++ ) {
            *txt++ = ot[i * sizeof( char_info )];
        }
        *txt = 0;
        DisplayLineInWindow( wn, k++, tptr );
        txt = tptr;
    }
#else
    DCResize( CurrentInfo );
    DCDisplayAllLines();
    DCUpdate();
#endif

    FreeWindow( w );

    ReleaseWindow( tmp );
    return( ERR_NO_ERR );

} /* ResizeWindow */
Esempio n. 10
0
/*
 * DrawBorder - display border
 */
void DrawBorder( window_id wn )
{
    wind                *w;
    int                 i, j, k, stc, etc, ctc;
    int                 tl, bl, tr, br;
    int                 xtl, xbl, xtr, xbr;
    char                *over, c;
    unsigned short      clr;
    char_info           what, what2;
    char_info           _FAR *scr;
    char_info           *txt;
    int                 topscol, topecol, topccol;
    char                *wb;

    if( EditFlags.Quiet ) {
        return;
    }
    if( !Windows[wn]->has_border ) {
        return;
    }
    w = AccessWindow( wn );
    txt = (char_info *) w->text;
    over = w->overlap;
    scr = (char_info _FAR *) Scrn;

    if( w->has_gadgets ) {
        wb = GadgetString;
    } else {
        wb = WindowBordersNG;
    }

    /*
     * set up for border addendums (title and misc top data)
     */
    if( w->title != NULL ) {
        stc = (w->width - strlen( w->title )) / 2 - 1;
        if( stc < 1 ) {
            stc = 1;
        }
        etc = stc + strlen( w->title ) + 1;
        ctc = 0;
    }
    if( w->borderdata != NULL ) {
        topscol = w->bordercol;
        topecol = topscol + strlen( w->borderdata ) - 1;
        topccol = 0;
    }

    tl = (w->x1) + (w->y1) * WindMaxWidth;
    tr = (w->x2) + (w->y1) * WindMaxWidth;
    bl = (w->x1) + (w->y2) * WindMaxWidth;
    br = (w->x2) + (w->y2) * WindMaxWidth;
    xtl = 0;
    xtr = w->width - 1;
    xbl = (w->height - 1) * w->width;
    xbr = w->width - 1 + (w->height - 1) * w->width;
    clr = MAKE_ATTR( w, w->border_color1, w->border_color2 );
    what.attr = clr;
    what2.attr = clr;

    /*
     * do the corner pieces
     */
    what.ch = wb[WB_TOPLEFT];
    WRITE_SCREEN_DATA( txt[xtl], what );
    if( over[xtl] == NO_CHAR ) {
        WRITE_SCREEN( scr[tl], what );
    }
    what.ch = wb[WB_TOPRIGHT];
    WRITE_SCREEN_DATA( txt[xtr], what );
    if( over[xtr] == NO_CHAR ) {
        WRITE_SCREEN( scr[tr], what );
    }
    what.ch = wb[WB_BOTTOMLEFT];
    WRITE_SCREEN_DATA( txt[xbl], what );
    if( over[xbl] == NO_CHAR ) {
        WRITE_SCREEN( scr[bl], what );
    }
    what.ch = wb[WB_BOTTOMRIGHT];
    WRITE_SCREEN_DATA( txt[xbr], what );
    if( over[xbr] == NO_CHAR ) {
        WRITE_SCREEN( scr[br], what );
    }

    /*
     * do the left side
     */
    what.ch = wb[WB_LEFTSIDE];
    k = xtl + w->width;
    j = tl + WindMaxWidth;
    for( i = 1; i < w->height - 1; i++ ) {
        WRITE_SCREEN_DATA( txt[k], what );
        if( over[k] == NO_CHAR ) {
            WRITE_SCREEN( scr[j], what );
#ifdef __VIO__
            MyVioShowBuf( sizeof( char_info ) * j, 1 );
#endif
        }
        k += w->width;
        j += WindMaxWidth;
    }

    /*
     * do the right side
     */
    what.ch = wb[WB_RIGHTSIDE];
    k = xtr + w->width;
    j = tr + WindMaxWidth;
    for( i = 1; i < w->height - 1; i++ ) {
        WRITE_SCREEN_DATA( txt[k], what );
        if( over[k] == NO_CHAR ) {
            WRITE_SCREEN( scr[j], what );
#ifdef __VIO__
            MyVioShowBuf( sizeof( char_info ) * j, 1 );
#endif
        }
        k += w->width;
        j += WindMaxWidth;
    }

    /*
     * now do bottom and top
     */
    what2.ch = wb[WB_TOPBOTTOM];
    for( i = 1; i < w->width - 1; i++ ) {
        k = xtl + i;
        c = wb[5];
        if( w->title != NULL ) {
            if( i >= stc && i <= etc ) {
                if( i == stc ) {
                    c = wb[WB_RIGHTT];
                } else if( i == etc ) {
                    c = wb[WB_LEFTT];
                } else {
                    c = w->title[ctc++];
                }
            }
        }
        if( w->borderdata != NULL ) {
            if( i >= topscol && i <= topecol ) {
                c = w->borderdata[topccol++];
            }
        }
        what.ch = c;
        WRITE_SCREEN_DATA( txt[k], what );
        if( over[k] == NO_CHAR ) {
            WRITE_SCREEN( scr[tl + i] , what );
        }

        k = xbl + i;
        WRITE_SCREEN_DATA( txt[k], what2 );
        if( over[k] == NO_CHAR ) {
            WRITE_SCREEN( scr[bl + i] , what2 );
        }
    }

    /*
     * add side gadgets
     */
    if( w->has_gadgets || w->has_scroll_gadgets ) {
        what.ch = wb[WB_UPTRIANGLE];
        WRITE_SCREEN_DATA( txt[xtr + w->width], what );
        if( over[xtr + w->width] == NO_CHAR ) {
            WRITE_SCREEN( scr[tr + WindMaxWidth], what );
#ifdef __VIO__
            MyVioShowBuf( sizeof( char_info ) * (tr + WindMaxWidth), 1 );
#endif
        }
        what.ch = wb[WB_DOWNTRIANGLE];
        WRITE_SCREEN_DATA( txt[xbr - w->width], what );
        if( over[xbr - w->width] == NO_CHAR ) {
            WRITE_SCREEN( scr[br - WindMaxWidth], what );
#ifdef __VIO__
            MyVioShowBuf( sizeof( char_info ) * (br - WindMaxWidth), 1 );
#endif
        }
    }
#ifdef __VIO__
    MyVioShowBuf( sizeof( char_info ) * tl, w->width );
    MyVioShowBuf( sizeof( char_info ) * bl, w->width );
#endif
    if( w->has_gadgets ) {
        DrawVerticalThumb( w, GadgetString[WB_THUMB] );
    }
    ReleaseWindow( w );

} /* DrawBorder */
Esempio n. 11
0
/*
 * displayLineInWindowGeneric - takes an ss_block directly
 */
vi_rc displayLineInWindowGeneric( window_id wn, int c_line_no,
                                char *text, int start_col, ss_block *ss )
{
    wind                *w;
    char_info           *txt;
    char                *over, *tmp, *otmp;
    char_info           _FAR *scr;
    int                 addr, start, end, a, spend;
    int                 cnt1, cnt2, startc, spl;
    char_info           blank, what;
#ifdef __VIO__
    unsigned            oscr;
    unsigned            tbytes;
#endif
    bool                has_mouse, write_eol;
    unsigned            ss_i; // index into text, not ss[ss_i]

    if( EditFlags.Quiet ) {
        return( ERR_NO_ERR );
    }
    w = Windows[wn];

    write_eol = FALSE;
    if( EditFlags.RealTabs ) {
        a = strlen( text );
        otmp = tmp = StaticAlloc();
        ExpandTabsInABuffer( text, a, tmp, MaxLinem1 + 2 );
    } else {
        tmp = text;
    }
    tmp += start_col;
    a = strlen( tmp );

    /*
     * find dimensions of line
     */
    if( w->has_border ) {
        if( c_line_no < 1 || c_line_no > w->height - 2 ) {
            if( EditFlags.RealTabs ) {
                StaticFree( otmp );
            }
            return( ERR_WIND_NO_SUCH_LINE );
        }
        start = 1;
        spl = c_line_no;
        spend = end = w->width - 1;
        if( a < end - 1 ) {
            end = a + 1;
        } else if( a >= end ) {
            write_eol = TRUE;
        }
    } else {
        if( c_line_no < 1 || c_line_no > w->height ) {
            if( EditFlags.RealTabs ) {
                StaticFree( otmp );
            }
            return( ERR_WIND_NO_SUCH_LINE );
        }
        start = 0;
        spl = c_line_no - 1;
        spend = end = w->width;
        if( a < end ) {
            end = a;
        } else if( a > end ) {
            write_eol = TRUE;
        }
    }
    startc = start;
    cnt1 = end - start;
    cnt2 = spend - end;

    c_line_no--;
    w = AccessWindow( wn );

    /*
     * initialize
     */
    addr = startc + spl * w->width;
    txt = (char_info *) &(w->text[sizeof( char_info ) * addr]);
    scr = (char_info _FAR *) &Scrn[(w->x1 + startc +
                                   (spl + w->y1) * WindMaxWidth) * sizeof(char_info)];
#ifdef __VIO__
    oscr = (unsigned) ((char *) scr - Scrn);
    tbytes = cnt1 + cnt2;
#endif

    ss_i = 0;
    what.attr = MAKE_ATTR( w, SEType[ss->type].foreground,
                              SEType[ss->type].background );
    blank.ch = ' ';

    has_mouse = DisplayMouse( FALSE );

    /*
     * display line
     */
    if( w->overcnt[spl] ) {
        over = &(w->overlap[addr]);
        while( cnt1-- != 0 ) {
            what.ch = (*tmp);
            WRITE_SCREEN_DATA( *txt, what );
            if( *over++ == NO_CHAR ) {
                WRITE_SCREEN( *scr, what );
            }
            tmp++;
            scr++;
            txt++;
            if( ++ss_i > ss->end ) {
                ss++;
                what.attr = MAKE_ATTR( w, SEType[ss->type].foreground,
                                          SEType[ss->type].background );
            }
        }
        if( write_eol && *(over - 1) == NO_CHAR ) {
            WriteLongLineMarker( wn, &( SEType[SE_EOFTEXT] ),
                                 txt - 1, scr - 1, *(tmp - 1) );
        } else {
            blank.attr = MAKE_ATTR( w, SEType[ss->type].foreground,
                                       SEType[ss->type].background );
            while( cnt2-- != 0 ) {
                WRITE_SCREEN_DATA( *txt, blank );
                if( *over++ == NO_CHAR ) {
                    WRITE_SCREEN( *scr, blank );
                }
                scr++;
                txt++;
            }
        }
    } else {
        while( cnt1-- != 0 ) {
            what.ch = (*tmp);
            WRITE_SCREEN_DATA( *txt, what );
            WRITE_SCREEN( *scr, what );
            scr++;
            txt++;
            tmp++;
            if( ++ss_i > ss->end ) {
                ss++;
                what.attr = MAKE_ATTR( w, SEType[ss->type].foreground,
                                          SEType[ss->type].background );
            }
        }
        if( write_eol ) {
            WriteLongLineMarker( wn, &( SEType[SE_EOFTEXT] ),
                                 txt - 1, scr - 1, *(tmp - 1) );
        } else {
            blank.attr = MAKE_ATTR( w, SEType[ss->type].foreground,
                                       SEType[ss->type].background );
            while( cnt2-- != 0 ) {
                WRITE_SCREEN_DATA( *txt, blank );
                WRITE_SCREEN( *scr, blank );
                txt++;
                scr++;
            }
        }
    }

#ifdef __VIO__
    MyVioShowBuf( oscr, tbytes );
#endif
    if( EditFlags.RealTabs ) {
        StaticFree( otmp );
    }
    ReleaseWindow( w );
    DisplayMouse( has_mouse );
    return( ERR_NO_ERR );

} /* displayLineInWindowGeneric */
Esempio n. 12
0
/*
 * SetCharInWindowWithColor - do just that, using given colors
 */
vi_rc SetCharInWindowWithColor( window_id wn, int line, int col, char text,
                              type_style *style )
{
    wind                *w;
    char                *over;
    int                 attr, addr, start, spl;
    char_info           tmp;
    char_info           *txt;
    char_info           _FAR *scr;
    bool                has_mouse;

    if( EditFlags.Quiet ) {
        return( ERR_NO_ERR );
    }
    w = Windows[wn];

    /*
     * find dimensions of line
     */
    if( w->has_border ) {
        if( line < 1 || line > w->height - 2 ) {
            return( ERR_WIND_NO_SUCH_LINE );
        }
        start = 1;
        spl = line;
    } else {
        if( line < 1 || line > w->height ) {
            return( ERR_WIND_NO_SUCH_LINE );
        }
        start = 0;
        spl = line - 1;
    }
    if( col < 1 || col > w->width ) {
        return( ERR_WIND_NO_SUCH_COLUMN );
    }
    line--;
    col--;

    /*
     * initialize
     */
    w = AccessWindow( wn );
    addr = col + start + spl * w->width;
    txt = (char_info *) &(w->text[sizeof( char_info ) * addr]);
    scr = (char_info _FAR *) &Scrn[(w->x1 + start + col + (spl + w->y1) *
                                    WindMaxWidth) * sizeof( char_info )];
    attr = MAKE_ATTR( w, style->foreground, style->background );

    /*
     * display char
     */
    has_mouse = DisplayMouse( FALSE );
    over = &(w->overlap[addr]);
    tmp.attr = attr;
    tmp.ch = text;
    WRITE_SCREEN_DATA( *txt, tmp );
    if( *over == NO_CHAR ) {
        WRITE_SCREEN( *scr, tmp );
    }
#ifdef __VIO__
    MyVioShowBuf( (unsigned)((char *) scr - Scrn), 1 );
#endif

    ReleaseWindow( w );
    DisplayMouse( has_mouse );
    return( ERR_NO_ERR );

} /* SetCharInWindowWithColor */
Esempio n. 13
0
/*
 * changeColorOfDisplayLine - do just that, using given colors and column range
 */
static void changeColorOfDisplayLine( int line, int scol, int ecol, type_style *s )
{
    wind                *w;
    char                *over;
    char_info           _FAR *scr;
    char_info           what;
#ifdef __VIO__
    unsigned            oscr;
    unsigned            onscr;
#endif
    int                 attr, t, end, spend, cnt1, cnt2, sscol, spl;

    if( EditFlags.Quiet ) {
        return;
    }
    w = AccessWindow( CurrentWindow );

    /*
     * find dimensions of line
     */
    if( w->has_border ) {
        if( line < 1 || line > w->height - 2 ) {
            ReleaseWindow( w );
            return;
        }
        spl = line;
        sscol = 1 + scol;
        spend = end = ecol + 2;
        if( spend > w->width - 1 ) {
            spend = end = w->width - 1;
        }
        if( sscol < 1 ) {
            sscol = 1;
        }
    } else {
        if( line < 1 || line > w->height ) {
            ReleaseWindow( w );
            return;
        }
        spl = line - 1;
        sscol = scol;
        spend = end = ecol + 1;
        if( spend > w->width ) {
            spend = end = w->width;
        }
        if( sscol < 0 ) {
            sscol = 0;
        }
    }
    cnt1 = end - sscol;
    cnt2 = spend - end;

    line--;

    /*
     * initialize
     */
    t = sscol + spl * w->width;
    scr = (char_info _FAR *) &Scrn[(w->x1 + sscol + (spl + w->y1) * WindMaxWidth) *
                                   sizeof( char_info )];
#ifdef __VIO__
    oscr = (unsigned) ((char _FAR *) scr - Scrn);
    onscr = 0;
#endif
    attr = MAKE_ATTR( w, s->foreground, s->background );
    what.attr = attr;

    /*
     * display line
     */
    if( w->overcnt[spl] ) {
        over = w->overlap + t;
        while( cnt1-- != 0 ) {
            if( *over++ == NO_CHAR ) {
                what.ch = (*scr).ch;
                WRITE_SCREEN( *scr, what );
#ifdef __VIO__
                onscr++;
#endif
            }
            scr++;
        }
        while( cnt2-- != 0 ) {
            if( *over++ == NO_CHAR ) {
                what.ch = (*scr).ch;
                WRITE_SCREEN( *scr, what );
#ifdef __VIO__
                onscr++;
#endif
            }
            scr++;
        }
    } else {
        while( cnt1-- != 0 ) {
            what.ch = (*scr).ch;
            WRITE_SCREEN( *scr, what );
#ifdef __VIO__
            onscr++;
#endif
            scr++;
        }
        while( cnt2-- != 0 ) {
            what.ch = (*scr).ch;
            WRITE_SCREEN( *scr, what );
#ifdef __VIO__
            onscr++;
#endif
            scr++;
        }
    }
#ifdef __VIO__
    MyVioShowBuf( oscr, onscr );
#endif
    ReleaseWindow( w );

} /* changeColorOfDisplayLine */
Esempio n. 14
0
/*
 * DisplayCrossLineInWindow - do just that, using given colors
 */
void DisplayCrossLineInWindow( window_id wn, int line )
{
    wind                *w;
    char                *over;
    char_info           *txt;
    char_info           _FAR *scr;
#ifdef __VIO__
    unsigned            oscr;
#endif
    int                 addr, i;
    char_info           what;

    if( EditFlags.Quiet ) {
        return;
    }
    w = Windows[wn];

    /*
     * find dimensions of line
     */
    if( !w->has_border ) {
        return;
    }
    if( line < 1 || line > w->height - 2 ) {
        return;
    }
    line--;

    /*
     * initialize
     */
    w = AccessWindow( wn );
    addr = 1 + (1 + line) * w->width;
    txt = (char_info *) &(w->text[sizeof( char_info ) * addr]);
    scr = (char_info _FAR *) &Scrn[(w->x1 + (1 + line + w->y1) * WindMaxWidth) *
                                    sizeof( char_info )];
#ifdef __VIO__
    oscr = (unsigned) ((char _FAR *) (scr) - Scrn);
#endif
    what.attr = MAKE_ATTR( w, w->border_color1, w->border_color2 );
    what.ch = WindowBordersNG[WB_LEFTT];

    over = &(w->overlap[addr]);
    if( *over++ == NO_CHAR ) {
        WRITE_SCREEN( *scr, what );
    }
    WRITE_SCREEN_DATA( *txt, what );
    txt++;
    scr++;

    what.ch = WindowBordersNG[WB_TOPBOTTOM];
    for( i = w->x1 + 1; i < w->x2; i++ ) {
        if( *over++ == NO_CHAR ) {
            WRITE_SCREEN( *scr, what );
        }
        WRITE_SCREEN_DATA( *txt, what );
        txt++;
        scr++;
    }

    if( line != w->height - 3 && line != 0 ) {
        what.ch = WindowBordersNG[WB_RIGHTT];
        WRITE_SCREEN_DATA( *txt, what );
        if( *over == NO_CHAR ) {
            WRITE_SCREEN( *scr, what );
        }
        scr++;
        txt++;
    }

#ifdef __VIO__
    MyVioShowBuf( oscr, w->width );
#endif
    ReleaseWindow( w );

} /* DisplayCrossLineInWindow */