Esempio n. 1
0
/*
 * DrawVerticalThumb - draw the scroll thumb on the screen
 */
void DrawVerticalThumb( wind *w, char ch )
{
    char_info   what = {0, 0};
    int         addr;
    char_info   *txt;
    window_id   *over;
    unsigned    oscr;

    if( w->vert_scroll_pos < THUMB_START || EditFlags.Quiet ) {
        return;
    }

    txt = w->text;
    over = w->overlap;

    what.cinfo_char = ch;
    what.cinfo_attr = MAKE_ATTR( w, w->border_color1, w->border_color2 );

    addr = w->width - 1 + w->vert_scroll_pos * w->width;
    oscr = (w->x2) + (w->y1 + w->vert_scroll_pos) * EditVars.WindMaxWidth;

    WRITE_SCREEN_DATA( txt[addr], what );
    if( over[addr] == NO_WINDOW ) {
        WRITE_SCREEN( Scrn[oscr], what );
    }
#ifdef __VIO__
    MyVioShowBuf( oscr, 1 );
#endif

} /* DrawVerticalThumb */
Esempio n. 2
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. 3
0
static void WriteLongLineMarker( window_id wn, type_style *style,
                                 char_info *txt, char_info _FAR *scr, char old )
{
    char_info   info;

    if( wn != CurrentWindow || !EditFlags.MarkLongLines ) {
        return;
    }
    info.attr = MAKE_ATTR( Windows[wn], style->background, style->foreground );
    if( EndOfLineChar ) {
        info.ch = EndOfLineChar;
    } else {
        info.ch = old;
    }
    WRITE_SCREEN_DATA( *txt, info );
    WRITE_SCREEN( *scr, info );
}
Esempio n. 4
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. 5
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. 6
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. 7
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. 8
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 */