void PDC_gotoyx(int row, int col) { extern int PDC_blink_state; PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n", row, col, SP->cursrow, SP->curscol)); /* clear the old cursor, if it's on-screen: */ if( SP->cursrow >= 0 && SP->curscol >= 0 && SP->cursrow < SP->lines && SP->curscol < SP->cols) { const int temp_visibility = SP->visibility; SP->visibility = 0; PDC_transform_line( SP->cursrow, SP->curscol, 1, curscr->_y[SP->cursrow] + SP->curscol); SP->visibility = temp_visibility; } /* ...then draw the new (assuming it's actually visible). */ /* This used to require some logic. Now the redraw_cursor() */ /* function figures out what cursor should be drawn, if any. */ PDC_blink_state = 1; if( SP->visibility) { extern HWND PDC_hWnd; HDC hdc = GetDC( PDC_hWnd) ; SP->curscol = col; SP->cursrow = row; redraw_cursor( hdc); ReleaseDC( PDC_hWnd, hdc) ; } }
void t_pgrid::run() { bool quit= false; setvbuf(stdout, 0, _IONBF, 0); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); SDL_WM_SetCaption("pgrid", "pgrid"); lastmillis= curmillis= SDL_GetTicks(); SDL_ShowCursor(0); SDL_EnableUNICODE(true); gui= new flux_gui(); bool guimouse= false; while(!quit) { lastframephystime= physicstime; lastmillis= curmillis; curmillis= SDL_GetTicks(); SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: case SDL_KEYUP: { if(event.key.keysym.sym==SDLK_ESCAPE) quit= true; if(wnd_getkbdfocus()!=NOWND) { flux_keyboard_event(event.type==SDL_KEYDOWN, event.key.keysym.sym, event.key.keysym.unicode&0x7F); } else { current_workspace()->keyboard_event(event.key); editor->keyboard_event(event.key); for(t_dyninputhandler_list::iterator i= dyninputhandlers.begin(); i!=dyninputhandlers.end(); i++) (*i)->keyboard_event(event.key); } keystate[event.key.keysym.sym]= (event.key.state==SDL_PRESSED? 1: 0); break; } case SDL_MOUSEMOTION: flux_mouse_move_event(event.motion.xrel, event.motion.yrel); if( find_prim_pos(event.motion.x, event.motion.y, true) || find_mouse_handler(event.motion.x, event.motion.y) ) guimouse= true; else { guimouse= false; mouse.x= event.motion.x; mouse.y= event.motion.y; mouse.buttons= event.motion.state; current_workspace()->mouse_motion_event(event.motion); editor->mouse_motion_event(event.motion); for(t_dyninputhandler_list::iterator i= dyninputhandlers.begin(); i!=dyninputhandlers.end(); i++) (*i)->mouse_motion_event(event.motion); } break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: { int b= event.button.button; int fluxbutton= (b==SDL_BUTTON_RIGHT? 2: b==SDL_BUTTON_MIDDLE? 3: b)-1; flux_mouse_button_event(fluxbutton, event.type==SDL_MOUSEBUTTONDOWN); if( find_prim_pos(event.button.x, event.button.y, true) || find_mouse_handler(event.button.x, event.button.y) ) { guimouse= true; } else { guimouse= false; wnd_setkbdfocus(NOWND); if(event.type==SDL_MOUSEBUTTONUP) mouse.buttons&= ~(SDL_BUTTON(event.button.button)); else mouse.buttons|= SDL_BUTTON(event.button.button); mouse.x= event.button.x; mouse.y= event.button.y; current_workspace()->mouse_button_event(event.button); editor->mouse_button_event(event.button); for(t_dyninputhandler_list::iterator i= dyninputhandlers.begin(); i!=dyninputhandlers.end(); i++) (*i)->mouse_button_event(event.button); } break; } case SDL_QUIT: quit= true; break; case SDL_VIDEORESIZE: { SDL_Surface *surf= SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_OPENGL|SDL_RESIZABLE); if(!surf) break; screen.sdl_surface= surf; screen.gl_init(event.resize.w, event.resize.h); current_workspace()->centerimage(); break; } case SDL_ACTIVEEVENT: { if(event.active.state&SDL_APPINPUTFOCUS) { hasinputfocus= event.active.gain; SDL_ShowCursor(!hasinputfocus); } if(event.active.state&SDL_APPMOUSEFOCUS) hasmousefocus= event.active.gain; break; } case SDL_VIDEOEXPOSE: { if(!hasinputfocus) { glClear(GL_DEPTH_BUFFER_BIT); current_workspace()->render(); SDL_GL_SwapBuffers(); checkglerror(); } break; } } } int x, y; SDL_GetMouseState(&x, &y); mousepos.x= x; mousepos.y= y; SDL_GetRelativeMouseState(&x, &y); mousevel.x= x; mousevel.y= y; mousevel.mul( 1000.0/(curmillis-lastmillis) ); current_workspace()->image->frame_tick((curmillis-lastmillis)*0.001); runphysics(); if(hasinputfocus) { glClear(GL_DEPTH_BUFFER_BIT); //~ screen.setperspective(); current_workspace()->render(); if(hasmousefocus && !guimouse) editor->render(); #if 1 next_event(); //~ aq_exec(); run_timers(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, screen.width,screen.height, 0, -1000, 1000); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //~ glEnable(GL_POINT_SMOOTH); //~ glPointSize(1.0); //~ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //~ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glColor3f(1,1,1); glDisable(GL_TEXTURE_2D); redraw_rect(&viewport); //~ cliptext(0,0,0,0); update_rect(&viewport); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); #endif gui->tick( (curmillis-lastmillis)*0.001 ); if(guimouse) { glMatrixMode(GL_TEXTURE); glLoadIdentity(); glDisable(GL_DEPTH_TEST); redraw_cursor(); } SDL_GL_SwapBuffers(); checkglerror(); } int delay= 10 - (curmillis-lastmillis); if(!hasinputfocus) SDL_Delay(100); if(delay>0) SDL_Delay(delay); } SDL_WM_GrabInput(SDL_GRAB_OFF); delete gui; gui= 0; }