Beispiel #1
0
void ShowMsgBox( char *caption, char *msg )
{
    a_dialog            *msgbox;
    bool                done;
    EVENT               event;

    static EVENT        events[] = {
        EV_NO_EVENT,
        EV_ENTER,
        EV_ESCAPE,
        EV_MOUSE_PRESS,
        EV_LIST_BOX_DCLICK,
        EV_NO_EVENT
    };
    done = FALSE;

    uipushlist( NULL );     /* modal barrier */
    uipushlist( events );
    helpMsgBox[0].u.str = msg;
    msgbox = uibegdialog( caption, helpMsgBox, 5, 50, 0, 0 );
    while( !done ) {
        event = uidialog( msgbox );
        switch( event ) {
        case EV_ENTER:
            done = TRUE;
            break;
        }
    }
    uipoplist();
    uipoplist();
    uienddialog( msgbox );
}
Beispiel #2
0
void ShowMsgBox( char *caption, char *msg )
{
    a_dialog            *msgbox;
    bool                done;
    ui_event            ui_ev;

    static ui_event     events[] = {
        __rend__,
        EV_ENTER,
        EV_ESCAPE,
        EV_MOUSE_PRESS,
        EV_LIST_BOX_DCLICK,
        __end__
    };
    done = false;

    uipushlist( NULL );     /* modal barrier */
    uipushlist( events );
    helpMsgBox[0].u.str = msg;
    msgbox = uibegdialog( caption, helpMsgBox, 5, 50, 0, 0 );
    while( !done ) {
        ui_ev = uidialog( msgbox );
        switch( ui_ev ) {
        case EV_ENTER:
            done = true;
            break;
        }
    }
    uipoplist();
    uipoplist();
    uienddialog( msgbox );
}
Beispiel #3
0
static void TrackPopup( gui_window *wnd, gui_point *location,
                        MENUITEM *new_menu, gui_mouse_track track, gui_ctl_id *curr_id )
{
    MapLocation( wnd, location );

    MenuState = MENU_FLOAT;
    uipushlist( NULL );
    uipushlist( GUIUserEvents );
    GUICreateMenuPopup( wnd, location, new_menu, track, curr_id );
    uipoplist( /* GUIUserEvents */ );
    uipoplist( /* NULL */ );
    MenuState = MENU_NONE;
    GUIFreeMenuItems( new_menu );
}
Beispiel #4
0
static void open( void )
/**********************/
{
    ui_event    ui_ev;

    if( uivopen( &opwin ) ) {
        uipushlist( oplist );
        uivtextput( &opwin, 1, 2, UIData->attrs[ATTR_NORMAL], "Enter file name.", 16 );
        inputline.attr = UIData->attrs[ATTR_EDIT];
        /* blank out the buffer */
        inputline.index = 0;
        inputline.scroll = 0;
        inputline.update = true;
        for( ;; ) {
            ui_ev = uiveditline( &opwin, &inputline );
            if( ui_ev != EV_NO_EVENT ) {
                break;
            }
        }
        if( ui_ev == EV_ENTER ) {
            /* open file */
        } else if( ui_ev == EV_ESCAPE ) {
            /* do nothing */
        } else {
            /* must be an event handled in the mainline */
            uiungetevent();
        }
        uipoplist( /* oplist */ );
        uivclose( &opwin );
    }
}
Beispiel #5
0
EVENT GUICreatePopup( gui_window *wnd, gui_coord *point )
{
    EVENT       ev;
    gui_point   gpoint;

    gpoint.x = point->x - wnd->screen.area.col;
    gpoint.y = point->y - (wnd->screen.area.row - 1);
    uipushlist( NULL );
    uipushlist( GUIInternalEvents );
    uipushlist( GUIUserEvents );
    ev = GUICreateMenuPopup( wnd, &gpoint, wnd->menu, GUI_TRACK_LEFT, NULL );
    uipoplist( /* GUIUserEvents */ );
    uipoplist( /* GUIInternalEvents */ );
    uipoplist( /* NULL */ );
    return( ev );
}
Beispiel #6
0
void sample_dialog( void )
{
    ui_event            ui_ev;
    a_dialog            *ui_dlg_info;

    static ui_event     events[] = {
        __rend__,
        EV_ENTER,
        EV_ESCAPE,
        EV_SCREWUP,
        __end__
    };

    ui_dlg_info = uibegdialog( "TEST", FieldDialog, 12, 74, 0, 0 );
    uipushlist( events );
    for( ;; ) {
        ui_ev = uidialog( ui_dlg_info );
        if( ui_ev == EV_ESCAPE || ui_ev == EV_ENTER ) {
            break;
        } else if( ui_ev == EV_SCREWUP ) {
            list_box.data_handle = list_data;
            uiupdatelistbox( &list_box );
        }
    }
    uipoplist( /* events */ );
    uienddialog( ui_dlg_info );
}
Beispiel #7
0
EVENT global uiveditline( VSCREEN *vptr, VEDITLINE *editline )
/************************************************************/
{
    register    EVENT                   ev;

    uipushlist( LineEvents );
    ev = uivgetevent( vptr );
    uipoplist();
    ev = uiveditevent( vptr, editline, ev );
    return( ev );
}
Beispiel #8
0
void GUICloseDialog( gui_window *wnd )
{
    VFIELD      *fields;
    a_dialog    *ui_dlg_info;
    char        *name;
    dialog_node *dlg_node;
    bool        colours_set;

    dlg_node = GUIGetDlgByWnd( wnd );
    if( dlg_node != NULL ) {
        ui_dlg_info = dlg_node->ui_dlg_info;
        fields = ui_dlg_info->fields;
        name = dlg_node->name;
        colours_set = dlg_node->colours_set;
    }
    GUIPopControlEvents();
    uipoplist( /* DlgEvents */ );
    uipoplist( /* GUIUserEvents */ );
    uipoplist( /* NULL */ );
    GUIDestroyDialog( wnd );
}
Beispiel #9
0
void intern menuevent( VSCREEN *vptr )
/************************************/
{
    register    EVENT                   newevent;
    register    EVENT                   ev;

    newevent = EV_NO_EVENT;

    if ( InitMenuPopupPending ) {
        InitMenuPopupPending = FALSE;
        if( Menu->titles[ Menu->menu - 1].popup != NULL ) {
            newevent = EV_MENU_INITPOPUP;
        }
    }

    if( newevent == EV_NO_EVENT ) {
        if ( uimenuson() && !uimenuisdisabled() ) {
            uipushlist( menu_list );
            if( ( Menu->active == FALSE ) || isdialogue( vptr ) ) {
                ev = getprime( vptr );
            } else {
                ev = getprime( NULL );
            }
            switch( ev ) {
            case EV_SCROLL_PRESS:
                Menu->scroll = TRUE;
                break;
            case EV_SCROLL_RELEASE:
                Menu->scroll = FALSE;
                break;
            case EV_NUM_PRESS:
                Menu->num = TRUE;
                break;
            case EV_NUM_RELEASE:
                Menu->num = FALSE;
                break;
            case EV_CAPS_PRESS:
                Menu->caps = TRUE;
                break;
            case EV_CAPS_RELEASE:
                Menu->caps = FALSE;
                break;
            default:
                newevent = process_menuevent( vptr, ev );
            }
            uipoplist();
        } else {
            newevent = getprime( vptr );
        }
    }

    Event = newevent;
}
Beispiel #10
0
void GUICloseDialog( gui_window *wnd )
{
//    VFIELD      *fields;
//    a_dialog    *ui_dlg_info;
//    char        *name;
//    dialog_node *dlg_node;
//    bool        colours_set;

//    dlg_node = GUIGetDlgByWnd( wnd );
//    if( dlg_node != NULL ) {
//        ui_dlg_info = dlg_node->ui_dlg_info;
//        fields = ui_dlg_info->fields;
//        name = dlg_node->name;
//        colours_set = dlg_node->colours_set;
//    }
    uipoplist( /* GUIDlgEvents */ );
    uipoplist( /* GUIControlEvents */ );
    uipoplist( /* GUIUserEvents */ );
    uipoplist( /* NULL */ );
    GUIDestroyDialog( wnd );
}
Beispiel #11
0
int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance,
                    LPSTR lpCmdLine, int nShowCmd ) {

    EVENT               ev;
    SAREA               area;
    char                buff[80];
    an_event_string     *ptr;
    ORD                 evrow = TOP_ROW;
    BOOL                fixup = FALSE;
    int                 mrow, mcol;
    int                 diff;

    hInstance = hInstance;
    hPrevInstance = hPrevInstance;
    lpCmdLine = lpCmdLine;
    nShowCmd = nShowCmd;
    if( InitSwapper() ) return( 0 ); // Yes - well, I would make the swapper
                                     // return 1 on error, unlike everything
                                     // else, wouldn't I?
    if( !uistart() ) return( 0 );
    ToCharacter();

    initmouse( 2 );
    uimenus( barmenu, pulldownuimenus, EV_FUNC( 1 ) );
    UIData->mouse_clk_delay = uiclockdelay( 250 );
    UIData->tick_delay = uiclockdelay( 3000 );
    mainwin.area.height = UIData->height - 7;

    area.row = 0;
    area.col = 0;
    area.width = UIData->width;
    area.height = UIData->height;
    uidirty( area );
    uirefresh();

    if( uivopen( &mainwin ) ) {
        uirefresh();
        sprintf( buff, "screen height : %d\0", UIData->height );
        uivtextput( &mainwin, TOP_ROW - 1, 2,
                  UIData->attrs[ ATTR_NORMAL ],
                  buff, 30 );
        for( ; ; ) {
            uipushlist( evlist );
            ev = uivgetevent( NULL );
            uipoplist();
            if( ev == EV_QUIT ) break;
            if( ev == EV_ALT_R ) break;
            if( ev == EV_MOUSE_PRESS_R ) {
                uimousepos( NULL, &mrow, &mcol );
                mrow++;
                mcol++;
                uipushlist( evlist );
                ev = uicreatepopup( mrow, mcol, &filemenu, FALSE, TRUE, NULL );
                uipoplist();
            }
            switch ( ev ) {
                case EV_SAMPLE_DIALOG:
                    sample_dialog();
                    break;
                case EV_OPEN:
                    open();
                    break;
                case EV_FUNC(1):
                    area.width = 10;
                    area.height = 10;
                    area.row = 1;
                    area.col = 1;
                    uivattribute( &mainwin, area, (ATTR) 1 );
                    break;
                case EV_CURSOR_RIGHT:
                    mainwin.col++;
                    if( mainwin.col >= mainwin.area.width ) mainwin.col--;
                    fixup = TRUE;
                    break;
                case EV_CURSOR_DOWN:
                    mainwin.row++;
                    if( mainwin.row >= mainwin.area.height ) mainwin.row--;
                    fixup = TRUE;
                    break;
                case EV_CURSOR_LEFT:
                    if( mainwin.col > 0 ) {
                        mainwin.col--;
                        fixup = TRUE;
                    }
                    break;
                case EV_CURSOR_UP:
                    if( mainwin.row > 0 ) {
                        mainwin.row--;
                        fixup = TRUE;
                    }
                    break;
            }
            if( fixup ) {
                fixup = FALSE;
                uivsetcursor( &mainwin );
            }
            if( ev != EV_NO_EVENT ) {
                for( ptr=evstrs; ; ++ptr ){
                    if( ptr->ev == EV_NO_EVENT ) {
                        sprintf( buff, "event 0x%4.4x", ev );
                        break;
                    } else if( ptr->ev == ev ) {
                        strcpy( buff, ptr->str );
                        break;
                    }
                }
                uivtextput( &mainwin, evrow, 2,
                          UIData->attrs[ ATTR_NORMAL ],
                          buff, 30 );
                if( ++evrow >= mainwin.area.height ){
                    evrow = TOP_ROW;
                }
                uivtextput( &mainwin, evrow, 2,
                          UIData->attrs[ ATTR_NORMAL ],
                          "", 30 );
                switch( ev ) {
                case EV_MOUSE_PRESS:
                    BandOn = 1;
                    uimousepos( NULL, &mrow, &mcol );
                    BandArea.row = mrow;
                    BandArea.col = mcol;
                    BandArea.width = 0;
                    BandArea.height = 0;
                    uibandinit( BandArea, UIData->attrs[ ATTR_ACTIVE ] );
                    break;
                case EV_MOUSE_DRAG:
                    if( BandOn ) {
                        uimousepos( NULL, &mrow, &mcol );
                        diff = mcol - BandArea.col;
                        if( diff < 0 ) diff = 0;
                        BandArea.width = diff;
                        diff = mrow - BandArea.row;
                        if( diff < 0 ) diff = 0;
                        BandArea.height = diff;
                        uibandmove( BandArea );
                    }
                    break;
                case EV_MOUSE_RELEASE:
                    if( BandOn ) uibandfini();
                    BandOn = 0;
                    break;
                }
            }
        }
        uivclose( &mainwin );
    }
    uinomenus();
    uiswap();
    uirestorebackground();      /* must be after uiswap */
    finimouse();
    ToGraphical();
    uistop();
    FiniSwapper();
    return( 0 );
}
Beispiel #12
0
an_event uidialog( a_dialog *info )
{
    static EVENT    dialog_events[] = {
        'a',            'z',
        'A',            'Z',
        EV_ALT_Q,       EV_ALT_M,
        EV_NO_EVENT,
        EV_ALT_CURSOR_DOWN,
        EV_CURSOR_UP,   EV_CURSOR_DOWN,
        EV_CURSOR_LEFT, EV_CURSOR_RIGHT,
        EV_TAB_FORWARD, EV_TAB_BACKWARD,
        EV_MOUSE_PRESS, EV_MOUSE_RELEASE,
        EV_MOUSE_DRAG,  EV_MOUSE_REPEAT,
        EV_MOUSE_DCLICK,
        EV_ENTER,       ' ',
        EV_NO_EVENT
    };
    a_list      *list;
    an_event    ev;
    VFIELD      *field;

    ev = EV_NO_EVENT;
    enter_field( info, info->curr );

    while( ev == EV_NO_EVENT || !uiinlist( ev ) ) {
        field = info->curr;
        if( field != NULL ) {
            switch( field->typ ) {
                case FLD_EDIT:
                case FLD_INVISIBLE_EDIT:
                    uieditpushlist();
                    break;
                case FLD_PULLDOWN:
                    uiboxpushlist( );
                    break;
                case FLD_COMBOBOX:
                    uiboxpushlist( );
                    uieditpushlist();
                    break;
                case FLD_LISTBOX:
                case FLD_EDIT_MLE:
                    list = field->ptr;
                    uiboxpushlist();
                    break;
            }
        }
        uipushlist( dialog_events );
        ev = uidialogevent( info->vs );
        ev = uidialogcallback( info, ev );
        uipoplist( /* dialog_events */ );

        if( field != NULL ) {
            switch( field->typ ) {
            case FLD_EDIT:
            case FLD_INVISIBLE_EDIT:
                uieditpoplist();
                break;
            case FLD_PULLDOWN:
                uiboxpoplist();
                break;
            case FLD_COMBOBOX:
                uiboxpoplist();
                uieditpoplist();
                break;
            case FLD_LISTBOX:
            case FLD_EDIT_MLE:
                uiboxpoplist();
                break;
            }
        }
        ev = uiprocessdialogevent( ev, info );
    }
    /* This code will make sure to exit the current fields before returning
     * a default hot spot event. This is for consistency with windows.
     */
    if( uiisdefaulthotspot( info->fields, ev ) ) {
        if( exit_field( info, info->curr ) ) {
            info->dirty = TRUE;
        }
    }
    info->field = (VFIELD *)info->curr - (VFIELD *)info->fields;
    return( ev );
}
Beispiel #13
0
void uiboxpoplist( void )
{
    uipoplist();
}
Beispiel #14
0
void GUIPopControlEvents( void )
{
    uipoplist( /* ControlEvents */ );
}
Beispiel #15
0
void main( void )
/***************/
{
    ui_event            ui_ev;
    SAREA               area;
    char                buff[80];
    an_event_string     *ptr;
    ORD                 evrow = TOP_ROW;
    int                 mrow, mcol;
    int                 diff;

    if( uistart() ) {
#ifdef CHARMAP
        uiinitgmouse( INIT_MOUSE_INITIALIZED ); /* the 0=mouseless,1=mouse,2=initialized mouse */
//      uivgaattrs();
        FlipCharacterMap();
#else
        initmouse( INIT_MOUSE_INITIALIZED );
#endif
        uimenus( barmenu, pulldownuimenus, EV_F1 );
        UIData->mouse_clk_delay = uiclockdelay( 250  /* ms */ );
        UIData->tick_delay      = uiclockdelay( 3000 /* ms */ );
        mainwin.area.height = UIData->height - 7;
        if( uivopen( &mainwin ) ) {
            for( ;; ) {
                uipushlist( evlist );
                ui_ev = uivgetevent( &mainwin );
                uipoplist( /* evlist */ );
                if( ui_ev == EV_MOUSE_PRESS_R ) {
                    uimousepos( NULL, &mrow, &mcol );
                    mrow++;
                    mcol++;
                    uipushlist( evlist );
                    ui_ev = uicreatepopup( mrow, mcol, filemenu, false, true, EV_NO_EVENT );
                    uipoplist( /* evlist */ );
                }
                switch( ui_ev ) {
                case EV_QUIT:
                    break;
                case EV_BACKGROUND_RESIZE:
                    uivclose( &mainwin );
                    mainwin.area.height = UIData->height - 7;
                    uivopen( &mainwin );
                    if( evrow > mainwin.area.height ) {
                        evrow = TOP_ROW;
                    }
                    break;
                case EV_SAMPLE_DIALOG:
                    sample_dialog();
                    break;
                case EV_OPEN:
                    open();
                    break;
                case EV_GO:
                    uispawnstart();
                    uiblankscreen();
                    printf( "Type exit to return\n" );
#if defined( __QNX__ ) || defined( __UNIX__ )
                    system( "" );
#elif defined( __WINDOWS__ )
                    // do nothing
#else
                    {
                        const char  *command;

                        command = getenv( "COMSPEC" );
                        if( command == NULL ) {
                            command = "c:\\command.com";
                        }
                        system( command );
                    }
#endif
                    uispawnend();
//                      uibackground( "wf.img" );
                    area.row = 0;
                    area.col = 0;
                    area.height = UIData->height;
                    area.width = UIData->width;
                    uidirty( area );
                    break;
                case EV_F1:
                    area.width = 10;
                    area.height = 10;
                    area.row = 1;
                    area.col = 1;
                    uivattribute( &mainwin, area, (ATTR) 1 );
                    break;
                }
                if( ui_ev == EV_QUIT ) {
                    break;
                } else if( ui_ev != EV_NO_EVENT ) {
                    for( ptr = evstrs; ; ++ptr ) {
                        if( ptr->ui_ev == EV_NO_EVENT ) {
                            sprintf( buff, "event 0x%4.4x", ui_ev );
                            break;
                        } else if( ptr->ui_ev == ui_ev ) {
                            sprintf( buff, "event 0x%4.4x (%s)", ui_ev, ptr->str );
                            break;
                        }
                    }
                    uivtextput( &mainwin, evrow, 2, UIData->attrs[ATTR_NORMAL], buff, 40 );
                    if( ++evrow >= mainwin.area.height ) {
                        evrow = TOP_ROW;
                    }
                    uivtextput( &mainwin, evrow, 2, UIData->attrs[ATTR_NORMAL], "", 40 );
                    switch( ui_ev ) {
                    case EV_MOUSE_PRESS:
                        BandOn = 1;
                        uimousepos( NULL, &mrow, &mcol );
                        BandArea.row = mrow;
                        BandArea.col = mcol;
                        BandArea.width = 0;
                        BandArea.height = 0;
                        uibandinit( BandArea, UIData->attrs[ATTR_ACTIVE] );
                        break;
                    case EV_MOUSE_DRAG:
                        if( BandOn ) {
                            uimousepos( NULL, &mrow, &mcol );
                            diff = mcol - BandArea.col;
                            if( diff < 0 )
                                diff = 0;
                            BandArea.width = diff;
                            diff = mrow - BandArea.row;
                            if( diff < 0 )
                                diff = 0;
                            BandArea.height = diff;
                            uibandmove( BandArea );
                        }
                        break;
                    case EV_MOUSE_RELEASE:
                        if( BandOn )
                            uibandfini();
                        BandOn = 0;
                        break;
                    }
                }
            }
            uivclose( &mainwin );
        }
        uinomenus();
        uiswap();
        uirestorebackground();  /* must be after uiswap */
#ifdef CHARMAP
        FlipCharacterMap();
        uifinigmouse();
#else
        finimouse();
#endif
        uistop();
    }
}
Beispiel #16
0
static EVENT hlpwait( VTAB *tab )
{
    bool                done;
    static EVENT        bumpev = EV_NO_EVENT;
    char                *next_name;
    unsigned            len1;
    unsigned            len2;

    helpCur = field_find( helpTab, helpStack->cur );
    if( helpTab != NULL && helpCur == NULL ) {
        helpCur = helpTab;
    }
    tab->other = helpCur;
    tab->curr = helpCur;
    if( helpCur != NULL ) {
        tab->home = helpCur->area.col;
    }
    uipushlist( helpEventList );
    if( bumpev != EV_NO_EVENT ) {
        uitabfilter( bumpev, tab );
        helpCur = tab->curr;
        bumpev = EV_NO_EVENT;
    }
    done = false;
    while( !done ) {
        if( helpTab != NULL ) {
            uivattribute( &helpScreen, helpCur->area, AT( ATTR_CURR_EDIT ) );
        }
        do {
            uipushlist( keyShift );
            curEvent = uivget( &helpScreen );
            if( curEvent == EV_MOUSE_PRESS ) {
                ignoreMouseRelease = false;
            }
            uipoplist();
            curEvent = uigadgetfilter( curEvent, &vGadget );
            curEvent = uitabfilter( curEvent, tab );
        } while( curEvent == EV_NO_EVENT );
        if( eventMapFn != NULL ) {
            curEvent = (*eventMapFn)( curEvent );
        }
        curEvent = uihotspotfilter( &helpScreen, hotSpotFields, curEvent );
        if( helpTab != NULL ) {
            uivattribute( &helpScreen, helpCur->area, AT( ATTR_EDIT ) );
        }
        switch( curEvent ) {
        case EV_HELP:
            nexttopic( helpWord );
            done = true;
            break;
        case EV_BOTTOM:
        case E_UP:
        case EV_PAGE_UP:
        case EV_PAGE_DOWN:
        case EV_CURSOR_UP:
        case EV_CURSOR_DOWN:
        case EV_TOP:
        case E_DOWN:
        case EV_SCROLL_VERTICAL:
            if( curEvent == EV_BOTTOM ) {
                bumpev = EV_CURSOR_DOWN;
            } else if( curEvent == EV_TOP ) {
                bumpev = EV_CURSOR_UP;
            }
            helpStack->cur = field_count( helpTab, helpCur );
            done = true;
            break;
        case '-':
        case EV_MOUSE_RELEASE_R:
        case EV_ALT_B:
        case 'b':
        case 'B':
        case EV_F8:
        case EV_F4:
            prevtopic();
            if( strcmp( helpStack->helpfname, curFile ) ) {
                len1 = strlen( helpStack->word );
                len2 = strlen( helpStack->helpfname );
                helpCur = HelpMemAlloc( sizeof( a_field ) + len1 + len2 );
                memcpy( helpCur->keyword, helpStack->word, len1 );
                memcpy( helpCur->keyword + len1, helpStack->helpfname, len2 );
                helpCur->keyword[len1 + len2] = '\0';
                helpCur->key1_len = len1;
                helpCur->key2_len = len2;
                helpCur->next = NULL;
//              prevtopic();
                helpTab = helpCur;
            }
            done = true;
            break;
        case EV_ALT_S:
        case 'S':
        case 's':
            if( helpSearchHdl != NULL ) {
                uipoplist();
                next_name = HelpSearch( helpSearchHdl );
                if( next_name != NULL ) {
                    nexttopic( next_name );
                    HelpMemFree( next_name );
                    done = true;
                }
                uipushlist( helpEventList );
            }
            break;
        case EV_FIELD_CHANGE:
            helpCur = tab->curr;
            break;
        case EV_MOUSE_RELEASE:
            if( tab->other == NULL )
                break;
            if( ignoreMouseRelease ) {
                /* this mouse release is for a mouse press that occured
                 * before this help topic was opened */
                 ignoreMouseRelease = false;
                 break;
            }
            tab->other = tab->curr;
            /* fall through */
        case EV_ENTER:  /*same as page-down if there are other topics*/
        case EV_F7:
        case '+':
            // DEN 90/04/12 - next line necessary for mouse release kludge
            helpCur = tab->curr;
            if( helpTab != NULL ) {
                if( helpCur->key2_len == 0 ) {
                    nexttopic( helpCur->keyword );
                }
                done = true;
            }
            break;
        case EV_KILL_UI:
            uiforceevadd( EV_KILL_UI );
            /* fall through */
        case EV_ESCAPE:
            done = true;
            break;
        }
    }
    uipoplist();
    return( curEvent );
}
Beispiel #17
0
EVENT UIAPI uivfieldedit( VSCREEN *vptr, VFIELDEDIT *header )
/************************************************************/
{
    register    EVENT                   ev;
    register    VFIELD*                 cur;
    auto        VBUFFER                 buffer;
    auto        SAREA                   area;

    if( header->reset ) {
        header->reset = false;
        header->prevfield = NULL;
        header->curfield = NULL;
        header->cursor = true;
        area.height = 1;
        for( cur = header->fieldlist ; cur != NULL ; cur = cur->link ) {
            area.row = cur->row;
            area.col = cur->col;
            area.width = cur->length;
            uivattribute( vptr, area, header->exit );
        }
    }
    if( header->cursor ) {
        header->cursor = false;
        header->delpending = false;
        header->fieldpending = false;
        header->cancel = false;
        if( vptr->cursor == C_OFF ) {
            vptr->cursor = C_NORMAL;
        }
        return( movecursor( vptr, header, vptr->row, vptr->col ) );
    }
    if( header->fieldpending ) {
        header->update = true;
        if( header->cancel ) {
            header->cancel = false;
            header->curfield = NULL;
            setfield( vptr, header, header->prevfield, 0 );
        }
        header->fieldpending = false;
    }
    cur = header->curfield;
    if( header->update ) {
        header->update = false;
        if( cur ) {     /* this should always be non-NULL */
            uipadblanks( header->buffer, cur->length );
            if( header->delpending ) {
                buffer.content = header->buffer;
                buffer.length = cur->length;
                buffer.index = vptr->col - cur->col;
                uieditevent( EV_DELETE, &buffer );
                header->dirty = true;
                header->delpending = false;
            }
            uivtextput( vptr, cur->row, cur->col, header->enter,
                    header->buffer, cur->length );
        }
    }
    if( header->oktomodify ) {
        uipushlist( livefieldevents );
    } else {
        uipushlist( deadfieldevents );
    }
    ev = uivgetevent( vptr );
    if( ev > EV_NO_EVENT ) {
        if( uiintoplist( ev ) ) {
            if( cur ) {
                buffer.content = header->buffer;
                buffer.length = cur->length;
                buffer.index = vptr->col - cur->col;
                buffer.insert = ( vptr->cursor == C_INSERT );
                buffer.dirty = false;
                uieditevent( ev, &buffer );
                header->dirty |= buffer.dirty;
            }
            switch( ev ) {
            case EV_HOME:
                if( cur != NULL ) break; /* home is within field */
                /* WARNING: this case falls through to the next */
            case EV_TAB_FORWARD:
            case EV_TAB_BACKWARD:
                cur = tabfield( vptr, header->fieldlist, ev == EV_TAB_FORWARD );
                /* WARNING: the EV_HOME case falls through */
                if( cur != NULL ) {
                    ev = setfield( vptr, header, cur, 0 );
                    cur = NULL; /* kludge - avoid calling movecursor */
                }
                break;
            case EV_INSERT:
                if( vptr->cursor == C_INSERT ) {
                    vptr->cursor = C_NORMAL ;
                } else {
                    vptr->cursor = C_INSERT ;
                }
                break;
            case EV_CURSOR_UP:
                ev = movecursor( vptr, header, vptr->row - 1, vptr->col );
                break;
            case EV_CURSOR_DOWN:
                ev = movecursor( vptr, header, vptr->row + 1, vptr->col );
                break;
            case EV_RUB_OUT:
                header->delpending = true;
                /* WARNING: this case falls through to the next !!!! */
            case EV_CURSOR_LEFT:
                if( cur ) {
                    if( vptr->col > cur->col ) {
                        break; /* cursor movement within field */
                    }
                }
                ev = movecursor( vptr, header, vptr->row, vptr->col - 1 );
                break;
            case EV_CURSOR_RIGHT:
            case ' ':
                if( header->curfield ) {
                    if( vptr->col < cur->col + cur->length - 1 ) {
                        break; /* cursor movement within field */
                    }
                }
                ev = movecursor( vptr, header, vptr->row, vptr->col + 1 );
                break;
            }
            if( ev != EV_FIELD_CHANGE ) {
                if( cur ) {
                    ev = movecursor( vptr, header,
                           vptr->row, cur->col + buffer.index );
                    if( buffer.dirty && ( ev == EV_NO_EVENT ) ) {
                        uivtextput( vptr, cur->row, cur->col, header->enter,
                            header->buffer, cur->length );
                    }
                } else {
                    ev = EV_NO_EVENT;
                }
                header->delpending = false;
            }
        }
    }
    uipoplist();
    return( ev );
}
Beispiel #18
0
char *HelpSearch( HelpHdl hdl )
{
    EVENT               event;
    char                done;
    char                *ret;

    static EVENT        events[] = {
        EV_NO_EVENT,
        EV_ENTER,
        EV_ESCAPE,
        EV_MOUSE_PRESS,
        EV_LIST_BOX_DCLICK,
        EV_NO_EVENT
    };

    searchHdl = hdl;
    listData = hdl->header.topiccnt;
    curHelpDialog = uibegdialog( "Search", helpSearchDialog, 12, 60, 0, 0 );
    if( editCtl.buffer == NULL ) {
        fillListBox( "" );
    } else {
        fillListBox( editCtl.buffer );
    }
    uipushlist( NULL );     /* modal barrier */
    uipushlist( events );
    done = 0;
    while( !done ) {
        event = uidialog( curHelpDialog );
        switch( event ) {
        case EV_MOUSE_PRESS:
            if( curHelpDialog->curr != NULL ) {
                if( curHelpDialog->curr->ptr == &listBox ) {
                    copyLBLinetoEditCtl( listBox.box->row );
                }
            }
            break;
        case EV_KILL_UI:
            uiforceevadd( EV_KILL_UI );
        /* fall through */
        case EV_ESCAPE:
            ret = NULL;
            done = 1;
            break;
        case EV_ENTER:
        case EV_LIST_BOX_DCLICK:
            ret = HelpMemAlloc( MAX_EDIT_LINE_LEN );
            GetLBItemLiteral( &listData, listBox.box->row, ret,
                              MAX_EDIT_LINE_LEN );
            if( ret[0] == '\0' ) {
                HelpMemFree( ret );
                ret = NULL;
            }
            done = 1;
            break;
        }
    }
    uipoplist();
    uipoplist();
    uienddialog( curHelpDialog );
    return( ret );
}