sdlterm/src/sdlterm.cc
changeset 55 1ab0edd5d784
parent 54 86b84535726e
child 57 911927edbdde
--- a/sdlterm/src/sdlterm.cc	Sun Jan 06 23:03:24 2013 +0100
+++ b/sdlterm/src/sdlterm.cc	Mon Jan 07 00:23:45 2013 +0100
@@ -307,7 +307,8 @@
 
 
 Terminal::Terminal()
- : _screen(), _attr(7), _cursor_visible(false), _mousemove_last_x(-1)
+ : _screen(), _attr(7), _cursor_x(0), _cursor_y(0), _cursor_visible(false),
+   _mousemove_last_x(-1), _mousemove_last_y(-1)
 {
     if (SDL_Init(SDL_INIT_VIDEO) == -1)
     {
@@ -315,6 +316,7 @@
         throw std::exception();
     }
     SDL_EnableUNICODE(1);
+    SDL_EnableKeyRepeat(250, SDL_DEFAULT_REPEAT_INTERVAL);
     SDL_WM_SetCaption("terminal", NULL);
 }
 
@@ -387,6 +389,12 @@
                 event.mouse.x = sdl_event.button.x / _screen.get_cell_width();
                 event.mouse.y = sdl_event.button.y / _screen.get_cell_height();
                 event.mouse.button = sdl_event.button.button;
+                if (sdl_event.button.button == SDL_BUTTON_WHEELUP || sdl_event.button.button == SDL_BUTTON_WHEELDOWN)
+                {
+                    if (sdl_event.type == SDL_MOUSEBUTTONUP)
+                        break; // do not report button-up events for mouse wheel
+                    event.type = Event::MOUSEWHEEL;
+                }
                 _mousemove_last_x = -1;
                 return;