static void display_fields( void ) { a_field *p; for( p = helpTab; p != NULL; p = p->next ) { uivattribute( &helpScreen, p->area, AT( ATTR_EDIT ) ); } }
static void echoline( VSCREEN *vptr, VEDITLINE *editline ) /********************************************************/ { SAREA area; unsigned start; unsigned trim; if( editline->invisible ) { area.row = editline->row; area.col = editline->col; area.height = 1; area.width = editline->fldlen; uivfill( vptr, area, editline->attr, ' ' ); for( trim = editline->length ; trim > editline->index ; --trim ) { if( editline->buffer[ trim - 1 ] != ' ' ) break; } area.width = min( editline->fldlen, trim - editline->scroll ); uivfill( vptr, area, editline->attr, '*' ); } else { uitextfield( vptr, editline->row, editline->col, editline->fldlen, editline->attr, editline->buffer + editline->scroll, editline->length - editline->scroll ); } if( editline->marking ) { area.row = editline->row; area.height = 1; if( editline->mark_anchor < editline->index ) { start = editline->mark_anchor; area.width = editline->index - editline->mark_anchor; } else { start = editline->index; area.width = editline->mark_anchor - editline->index; } if( area.width + start >= editline->scroll && area.width > 0 ) { if( start > editline->scroll ) { area.col = editline->col + start - editline->scroll; } else { area.col = editline->col; area.width = area.width - editline->scroll + start; } if( area.width + area.col > editline->col + editline->fldlen ) { area.width = editline->fldlen + editline->col - area.col; } uivattribute( vptr, area, editline->mark_attr ); } } }
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(); } }
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 ); }
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 ); }
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 ); }