Esempio n. 1
0
void *uiinitdialog( char *heading, ATTR attr, char *lines[],
            unsigned int extra_rows, int maxlen, int rpos, int cpos )
{
    VSCREEN             *vs;
    int                 len;
    unsigned            width;
    int                 i;
    unsigned            depth;
    unsigned            linelen;
    char                *s, *t, *line;
    SAREA               area;

    uisetscreenarea( &area, TRUE, FALSE );
    width = UIData->width - 2;
    for( depth = 0, i = 0 ; lines[ i ] != NULL ; ++i ) {
        s = lines[ i ];
        len = strlen( s );
        for( t = s + len ; s < t ; ) {
            ++ depth;
            linelen = ui_split_line( &s, t, width );
            if( maxlen < linelen + 2 ) {
                maxlen = linelen + 2;
            }
        }
    }
    if( depth > 0 ) {
        /* never put text on the first line of the dialog */
        ++depth;
    }
    if( maxlen > width )
        maxlen = width;
    vs = makevs( heading, maxlen, depth + extra_rows, cpos, rpos );
    uisetarea( &area, vs );
    width = area.width;
    area.row = 1;
    area.height = 1;
    for( i = 0 ; lines[ i ] != NULL ; ++i ) {
        s = lines[ i ];
        len = strlen( s );
        for( t = s + len ; s < t ; ) {
            line = s;
            linelen = ui_split_line( &s, t, width );
            uicntrtext( vs, &area, attr, linelen, line );
            area.row += 1;
        }
    }
    return( vs );
}
Esempio n. 2
0
VSCREEN *uiinitdialog( const char *title, ATTR attr, char *lines[],
                uisize extra_rows, uisize maxlen, int rpos, int cpos )
{
    VSCREEN             *vs;
    uisize              width;
    int                 i;
    uisize              depth;
    uisize              linelen;
    char                *s, *t, *line;
    SAREA               area;

    uisetscreenarea( &area, true, false );
    width = UIData->width - 2;
    depth = 0;
    for( i = 0; lines[i] != NULL; ++i ) {
        s = lines[i];
        for( t = s + strlen( s ); s < t; ) {
            depth++;
            linelen = ui_split_line( &s, t, width );
            if( maxlen < linelen + 2 ) {
                maxlen = linelen + 2;
            }
        }
    }
    if( depth > 0 ) {
        /* never put text on the first line of the dialog */
        depth++;
    }
    if( maxlen > width )
        maxlen = width;
    vs = makevs( title, maxlen, depth + extra_rows, cpos, rpos );
    uisetarea( &area, vs );
    width = area.width;
    area.row = 1;
    area.height = 1;
    for( i = 0; lines[i] != NULL; ++i ) {
        s = lines[i];
        for( t = s + strlen( s ); s < t; ) {
            line = s;
            linelen = ui_split_line( &s, t, width );
            uicntrtext( vs, &area, attr, linelen, line );
            area.row += 1;
        }
    }
    return( vs );
}