sdlterm/src/sdlterm.cc
changeset 55 1ab0edd5d784
parent 54 86b84535726e
child 57 911927edbdde
equal deleted inserted replaced
54:86b84535726e 55:1ab0edd5d784
   305     redraw();
   305     redraw();
   306 }
   306 }
   307 
   307 
   308 
   308 
   309 Terminal::Terminal()
   309 Terminal::Terminal()
   310  : _screen(), _attr(7), _cursor_visible(false), _mousemove_last_x(-1)
   310  : _screen(), _attr(7), _cursor_x(0), _cursor_y(0), _cursor_visible(false),
       
   311    _mousemove_last_x(-1), _mousemove_last_y(-1)
   311 {
   312 {
   312     if (SDL_Init(SDL_INIT_VIDEO) == -1)
   313     if (SDL_Init(SDL_INIT_VIDEO) == -1)
   313     {
   314     {
   314         fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
   315         fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
   315         throw std::exception();
   316         throw std::exception();
   316     }
   317     }
   317     SDL_EnableUNICODE(1);
   318     SDL_EnableUNICODE(1);
       
   319     SDL_EnableKeyRepeat(250, SDL_DEFAULT_REPEAT_INTERVAL);
   318     SDL_WM_SetCaption("terminal", NULL);
   320     SDL_WM_SetCaption("terminal", NULL);
   319 }
   321 }
   320 
   322 
   321 
   323 
   322 Terminal::~Terminal()
   324 Terminal::~Terminal()
   385             case SDL_MOUSEBUTTONUP:
   387             case SDL_MOUSEBUTTONUP:
   386                 event.type = (sdl_event.type == SDL_MOUSEBUTTONDOWN) ? Event::MOUSEDOWN : Event::MOUSEUP;
   388                 event.type = (sdl_event.type == SDL_MOUSEBUTTONDOWN) ? Event::MOUSEDOWN : Event::MOUSEUP;
   387                 event.mouse.x = sdl_event.button.x / _screen.get_cell_width();
   389                 event.mouse.x = sdl_event.button.x / _screen.get_cell_width();
   388                 event.mouse.y = sdl_event.button.y / _screen.get_cell_height();
   390                 event.mouse.y = sdl_event.button.y / _screen.get_cell_height();
   389                 event.mouse.button = sdl_event.button.button;
   391                 event.mouse.button = sdl_event.button.button;
       
   392                 if (sdl_event.button.button == SDL_BUTTON_WHEELUP || sdl_event.button.button == SDL_BUTTON_WHEELDOWN)
       
   393                 {
       
   394                     if (sdl_event.type == SDL_MOUSEBUTTONUP)
       
   395                         break; // do not report button-up events for mouse wheel
       
   396                     event.type = Event::MOUSEWHEEL;
       
   397                 }
   390                 _mousemove_last_x = -1;
   398                 _mousemove_last_x = -1;
   391                 return;
   399                 return;
   392 
   400 
   393             case SDL_MOUSEMOTION:
   401             case SDL_MOUSEMOTION:
   394                 if (sdl_event.motion.state == 0)
   402                 if (sdl_event.motion.state == 0)