Example #1
0
void *uibegdialog( char *title, VFIELD *fields, ORD rows, ORD cols, int rpos, int cpos )
{
    char                *lines[1];
    a_dialog            *info;

    lines[ 0 ] = NULL;
    info = uicalloc( 1, sizeof( a_dialog ) );
    if( info == NULL ) {
        return( NULL );
    }
    info->vs = uiinitdialog( title, UIData->attrs[ ATTR_NORMAL ],
                           lines, rows, cols, rpos, cpos );
    uireinitdialog( info, fields );
    return( info );
}
Example #2
0
a_list_info *uibeglistbox( VSCREEN *vs, SAREA *area, a_list *list )
{
    a_list_info     *box;
    unsigned        maxline;

    box = uicalloc( 1, sizeof( a_list_info ) );
    if( box == NULL ) {
        return( NULL );
    }
    if( list->get == NULL ) {
        list->get = ( bool (*) ( void *, unsigned, char *, unsigned ) )
                        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 );
}
Example #3
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 = uicalloc( 1, sizeof( eTrie ) );
            if( trie->child[i].trie == NULL ) {
                return( FALSE );
            }
        }

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