Exemplo n.º 1
0
static EVENT cd_sizeevent( void )
/*******************************/
{
    SAREA       area;
    unsigned    state;
    unsigned    arm;

    if( !StatePending )
        return( EV_NO_EVENT );
    StatePending = 0;
    state = console_state( UIConCtrl, UIConsole, 0,
                (_CON_EVENT_ACTIVE|_CON_EVENT_INACTIVE|_CON_EVENT_SIZE) );
    arm = 0;
    if( state & _CON_EVENT_INACTIVE ) {
        clear_shift();
        arm = _CON_EVENT_ACTIVE;
    } else if( state & _CON_EVENT_ACTIVE ) {
        arm = _CON_EVENT_INACTIVE;
    }
    console_arm( UIConCtrl, UIConsole, 0, arm | _CON_EVENT_SIZE );
    if( !(state & _CON_EVENT_SIZE) )
        return( EV_NO_EVENT );
    if( !uiinlists( EV_BACKGROUND_RESIZE ) )
        return( EV_NO_EVENT );
    if( !setupscrnbuff() )
        return( EV_NO_EVENT );
    closebackground();
    openbackground();
    area.row = 0;
    area.col = 0;
    area.height = UIData->height;
    area.width = UIData->width;
    uidirty( area );
    return( EV_BACKGROUND_RESIZE );
}
Exemplo n.º 2
0
void uirestorebackground( void )
/******************************/
{
    ATTR        hold;

    hold = UIData->attrs[ ATTR_NORMAL ];
    UIData->attrs[ ATTR_NORMAL ] = 0x07;
    uidirty( UIData->blank.area );
    uirefresh();
    UIData->attrs[ ATTR_NORMAL ] = hold;
}
Exemplo n.º 3
0
static EVENT doget( bool update )
/*******************************/
{
    register    EVENT                   ev;
    static      short                   ReturnIdle = 1;
    SAREA       screen;

    for( ;; ) {
        ev = forcedevent();
        if( ev > EV_NO_EVENT )
            break;
        ev = _uievent();
        if( ev > EV_NO_EVENT )
            break;
        if( ReturnIdle ) {
            --ReturnIdle;
            return( EV_IDLE );
        } else {
            if( update )
                uirefresh();
            if( UIData->busy_wait ) {
                return( EV_SINK );
            }
        }
        _armkeyboard();
        Receive( UILocalProxy, 0, 0 ); /* wait for some input */
    }
    ReturnIdle = 1;
    switch( ev ) {
    case EV_REDRAW_SCREEN:
        screen.row = 0;
        screen.col = 0;
        screen.height= UIData->height;
        screen.width=  UIData->width;

        uidirty( screen );
        UserForcedTermRefresh = true;
        physupdate( &screen );
        break;
    case EV_MOUSE_HOLD:
    case EV_MOUSE_HOLD_R:
    case EV_MOUSE_HOLD_M:
    case EV_MOUSE_REPEAT:
    case EV_MOUSE_REPEAT_R:
    case EV_MOUSE_REPEAT_M:
        if( update )
            uirefresh();
        break;
    }
    return( ev );
}
Exemplo n.º 4
0
static EVENT td_sizeevent( void )
/*******************************/
{
    SAREA           area;

    if( !SizePending ) return (EV_NO_EVENT);
    if( !uiinlist(EV_BACKGROUND_RESIZE) ) return (EV_NO_EVENT);
    if( !setupscrnbuff(UIData->height,UIData->width) ) return (EV_NO_EVENT);
    SizePending = 0;
    area.row = 0;
    area.col = 0;
    area.height = UIData->height;
    area.width = UIData->width;
    uidirty(area);
    return (EV_BACKGROUND_RESIZE);
}
Exemplo n.º 5
0
static EVENT doget( bool update )
/*******************************/
{
    register    EVENT                   ev;
    static      short                   ReturnIdle = 1;

    for( ;; ) {
        ev = forcedevent();
        if( ev > EV_NO_EVENT )
            break;
        ev = _uievent();
        if( ev > EV_NO_EVENT )
            break;
        if( ReturnIdle ) {
            --ReturnIdle;
            return( EV_IDLE );
        } else {
            if( update )
                uirefresh();
            if( UIData->busy_wait ) {
                return( EV_SINK );
            }
        }
        kb_wait( 60, 0 );
    }
    ReturnIdle = 1;
    if( ev==EV_REDRAW_SCREEN ){
        extern bool     UserForcedTermRefresh;
        SAREA           screen={ 0, 0, 0, 0 };

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

        uidirty( screen );
        UserForcedTermRefresh= TRUE;
        physupdate( &screen );
    }
    return( ev );
}
Exemplo n.º 6
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();
    }
}
Exemplo n.º 7
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 );
}