Exemplo n.º 1
0
VSCREEN intern *uiopen( SAREA *area, const char *title, screen_flags flags )
/**************************************************************************/
{
    VSCREEN             *s;

    s = uimalloc( sizeof( VSCREEN ) );
    if( s == NULL ) {
        return( s );
    }
    s->event = EV_NO_EVENT;
    s->area = *area;
    s->flags = flags;
    s->col = 0;
    s->row = 0;
    s->cursor = C_OFF;
    s->title = NULL;
    s->dynamic_title = false;
    if( title != NULL ) {
        unsigned    len;
        char        *str;

        len = strlen( title );
        str = uimalloc( len + 1 );
        memcpy( str, title, len );
        str[len] = '\0';
        s->title = str;
        s->dynamic_title = true;
    }
    uivopen( s );
    return( s );
}
Exemplo n.º 2
0
void uiupdatecombobox( a_combo_box *combo )
{
    char                *str;
    a_list              *list;
    an_edit_control     *edit;
    UIPICKGETTEXT       *fn_get;

    edit  = &combo->edit;
    list  = &combo->list;
    str = (char *)uimalloc( CTRL_BUF_LEN + 1 );
    if( str != NULL ) {
        fn_get = list->get;
        if( fn_get == NULL )
            fn_get = uigetlistelement;
        if( (*fn_get)( list->data_handle, list->choice, str, CTRL_BUF_LEN ) ) {
            /* str does not have to be null terminated */
            /* terminate it at maximum length */
            str[CTRL_BUF_LEN] = '\0';
            uifree( edit->buffer );
            edit->buffer = str;
            edit->length = strlen( str );
        } else {
            uifree( str );
        }
    }
}
Exemplo n.º 3
0
int TrieInit(void)
{

    KeyTrie.child = uimalloc( TRIE_TOP * sizeof( eNode ) );
    if( KeyTrie.child == NULL )
        return( FALSE );
    KeyTrie.alc_child = TRIE_TOP;
    KeyTrie.num_child = 0;
    return( TRUE );
}
Exemplo n.º 4
0
static void copyLBLinetoEditCtl( unsigned index )
{
    char        *lb_item;
    unsigned    len;

    lb_item = uimalloc( MAX_EDIT_LINE_LEN );
    GetListBoxItem( &listData, index, lb_item, MAX_EDIT_LINE_LEN );
    len = strlen( lb_item );
    uifree( editCtl.buffer );
    editCtl.buffer = lb_item;
    editCtl.length = len;
    uiupdateedit( curHelpDialog, editVField );
    uiprintfield( curHelpDialog, editVField );
}
Exemplo n.º 5
0
a_dialog *uibegdialog( const char *title, VFIELD *fields, unsigned rows, unsigned cols, int rpos, int cpos )
{
    char                *lines[1];
    a_dialog            *ui_dlg_info;

    lines[0] = NULL;
    ui_dlg_info = uimalloc( sizeof( a_dialog ) );
    if( ui_dlg_info == NULL ) {
        return( NULL );
    }
    ui_dlg_info->field = 0;
    ui_dlg_info->edit_data = NULL;
    ui_dlg_info->moving = false;
    ui_dlg_info->vs = uiinitdialog( title, UIData->attrs[ATTR_NORMAL], lines, rows, cols, rpos, cpos );
    uireinitdialog( ui_dlg_info, fields );
    return( ui_dlg_info );
}
Exemplo n.º 6
0
a_list_info *uibeglistbox( VSCREEN *vs, SAREA *area, a_list *list )
{
    a_list_info     *box;
    int             maxline;

    box = uimalloc( sizeof( a_list_info ) );
    if( box == NULL ) {
        return( NULL );
    }
    if( list->get == NULL ) {
        list->get = uigetlistelement;
    }
    box->vs     = vs;
    box->area   = *area;
    box->line   = list->choice;
    box->row    = list->choice;
    box->attr   = ATTR_EDIT;

    maxline = uilistsize( list );

    box->gadget.win = box->vs;          // Initialize gadget
    box->gadget.dir = VERTICAL;
    box->gadget.anchor = box->area.col + box->area.width + 1;
    box->gadget.start = box->area.row + 1;
    box->gadget.end = box->area.row + box->area.height;
    box->gadget.forward = EV_SCROLL_LINE_DOWN;
    box->gadget.backward = EV_SCROLL_LINE_UP;
    box->gadget.slider = EV_SCROLL_VERTICAL,
    box->gadget.pageforward = EV_SCROLL_PAGE_DOWN;
    box->gadget.pagebackward = EV_SCROLL_PAGE_UP;
    box->gadget.total_size = (int)maxline;
    if( box->gadget.total_size < (int)box->area.height )
        box->gadget.total_size = (int)box->area.height;
    box->gadget.page_size = box->area.height;
    box->gadget.pos = 0;
    box->gadget.flags = GADGET_NONE;
    uiinitgadget( &box->gadget );

    list->box = box;
    setstartline( list );
    uipaintlistbox( list );

    return( box );
}
Exemplo n.º 7
0
void uiupdatecombobox( a_combo_box *combo )
{
    char                *str;
    a_list              *list;
    an_edit_control     *edit;

    edit  = &combo->edit;
    list  = &combo->list;
    str = (char *)uimalloc( CTRL_BUF_LEN );
    if( str != NULL ) {
        if( (*list->get)( list->data, list->choice, str, CTRL_BUF_LEN ) ) {
            uifree( edit->buffer );
            edit->buffer = str;
            edit->length = strlen( str );
        } else {
            uifree( str );
        }
    }
}
Exemplo n.º 8
0
int intern initbios( void )
/*******************/
{
    int                 initialized = FALSE;
    int                 i;

    if( initmonitor() ) {

        UIData->screen.origin = (LPPIXEL) uimalloc(
            UIData->width * UIData->height * sizeof( PIXEL )
        );

        for( i = 0 ; i < UIData->width * UIData->height ; ++i ){
            UIData->screen.origin[i].ch = ' ';
            UIData->screen.origin[i].attr = 7;
        } /* end for */

        UIData->screen.increment = UIData->width;

        uiinitcursor();
        initkeyboard();

        /* No mouse support in NetWare! */

        UIData->mouse_acc_delay = 0;
        UIData->mouse_rpt_delay = 0;
        UIData->mouse_clk_delay = 0;
        UIData->mouse_speed     = 0;

/* A 500 millisecond tick delay is pretty reasonable. */

        UIData->tick_delay      = uiclockdelay( 500 );

        initialized = TRUE;
    } /* end if */

    return( initialized );

} /* end initbios */
Exemplo n.º 9
0
void uipaintlistbox( a_list *list )
{
    ORD         i;
    char        *buf;
    bool        ok;
    int         length;
    ATTR        attr;

    if( list->box == NULL ) {
        return;
    }

    length = list->box->area.width + 1;
    buf = ( char * )uimalloc( length );

    for( i = 0 ; i < list->box->area.height ; ++i ) {
        attr = ATTR_NORMAL;
        if( list->box->row == i + list->box->line ) {
            attr = list->box->attr;
        }
        ok = (*list->get)( list->data, list->box->line + i, buf, length );
        if( ok ) {
            uitextfield( list->box->vs, list->box->area.row + i,
                         list->box->area.col, list->box->area.width,
                         UIData->attrs[ attr ], buf, strlen( buf ) );
        } else {
            break;
        }
    }
    for( ; i < list->box->area.height; ++i ) {
        uitextfield( list->box->vs, list->box->area.row + i,
                     list->box->area.col, list->box->area.width,
                     UIData->attrs[ ATTR_NORMAL ], "", 0 );
    }
    uifree( buf );
}
Exemplo n.º 10
0
/* This function will add a string and matching event to KeyTrie. It adds
 * with the trie arrays sorted using linear insertion. It may be possible
 * to improve the performance, but I think any improvements would be slight,
 * as this function is only called at initialization.
 */
int TrieAdd( EVENT event, const char *str )
{
    eTrie       *trie = &KeyTrie;
    int         i;
    int         depth = 1;

    if( str == NULL || *str == '\0' )
        return( true );

    for( ;; ) {
        i = child_search( *str, trie );

        if( i == trie->num_child || trie->child[i].c != *str ) {
            // the char's not in the list, so we'd better add it

            trie->num_child++;

            if( trie->alc_child < trie->num_child ) {
                //eNode                 *tmp;

                // the array isn't big enough, expand it a bit
                trie->alc_child += TRIE_ARRAY_GROWTH;
                trie->child = uirealloc( trie->child, trie->alc_child * sizeof( eNode ) );
                if( trie->child == NULL ) {
                    trie->alc_child = 0;
                    return( false );
                }
            }

            if( i < ( trie->num_child - 1 ) ) {
                // We're in the middle of the list, so clear a spot
                memmove( &(trie->child[i + 1]), &(trie->child[i]),
                                ( trie->num_child - i - 1 ) * sizeof( eNode ) );
            }

            trie->child[i].c = *str;
            trie->child[i].ev = EV_UNUSED;
            trie->child[i].trie = NULL;
        }

        // advance current char pointer
        str++;

        // by this point, "i" is set to the index of a matching sub-trie.
        if( *str == '\0' ) {
            // at the end of the string, so insert the event
            trie->child[i].ev = event;
            return( true );
        }

        if( trie->child[i].trie == NULL ) {
            // our "matching sub-trie" does not yet exist...
            trie->child[i].trie = uimalloc( sizeof( eTrie ) );
            if( trie->child[i].trie == NULL ) {
                return( false );
            }
            trie->child[i].trie->child = NULL;
            trie->child[i].trie->num_child = 0;
            trie->child[i].trie->alc_child = 0;
        }

        // go down a level, and work on the next char
        trie = trie->child[i].trie;
        depth++;
        if( depth > KeyTrieDepth ) {
            KeyTrieDepth = depth;
        }
    }
}